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

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> plus;
    vector<int> minus;
    int x;
    for (int i = 0; i < N; i++){
        cin >> x;
        if (x < 0){
            minus.push_back(x);
        }
        else{
            plus.push_back(x);
        }
    }
    reverse(minus.begin(), minus.end());
    int tmp_p = -1;
    int tmp_m = -1;
    int cnt = 0;
    int num = 0;
    int cnt1 = 100000000;
    int cnt2 = 100000000;
    if (plus.size() >= K){
        cnt1 = plus[K-1];
    }
    if (minus.size() >= K) {
        cnt2 = minus[K-1];
    }

    while (cnt < K) {
        if (tmp_p+1 < plus.size()){
            if (plus[tmp_p+1] == num){
                cnt++;
                tmp_p++;
            }
        }
        if (tmp_m+1 < minus.size()){
            if (minus[tmp_m+1] == -num){
                cnt++;
                tmp_m++;
            }
        }
        
        num++;
    }
    if (cnt == K){
        if (tmp_p >= 0 && tmp_m >= 0){
            cout << min({cnt1, cnt2, 2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])}) << endl;
        }
        else if (tmp_p < 0){
            cout << min({cnt1, cnt2, -minus[tmp_m]}) << endl;
        }
        else {
            cout << min({cnt1, cnt2, plus[tmp_p]}) << endl;
        }
    else if (tmp_p != 0 && tmp_m != 0){
        cout << min({cnt1, cnt2, min(plus[tmp_p-1], -minus[tmp_m]) + max(plus[tmp_p-1], -minus[tmp_m]), min(plus[tmp_p], -minus[tmp_m-1]) + max(plus[tmp_p], -minus[tmp_m-1])}) << endl;
    }
    else{
        cout << min(cnt1, cnt2) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:5: error: expected '}' before 'else'
   62 |     else if (tmp_p != 0 && tmp_m != 0){
      |     ^~~~
a.cc:52:18: note: to match this '{'
   52 |     if (cnt == K){
      |                  ^
Language: C++

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> plus;
    vector<int> minus;
    int x;
    for (int i = 0; i < N; i++){
        cin >> x;
        if (x < 0){
            minus.push_back(x);
        }
        else{
            plus.push_back(x);
        }
    }
    reverse(minus.begin(), minus.end());
    int tmp_p = -1;
    int tmp_m = -1;
    int cnt = 0;
    int num = 0;
    int cnt1 = 100000000;
    int cnt2 = 100000000;
    if (plus.size() >= K){
        cnt1 = plus[K-1];
    }
    if (minus.size() >= K) {
        cnt2 = minus[K-1];
    }

    while (cnt < K) {
        if (tmp_p+1 < plus.size()){
            if (plus[tmp_p+1] == num){
                cnt++;
                tmp_p++;
            }
        }
        if (tmp_m+1 < minus.size()){
            if (minus[tmp_m+1] == -num){
                cnt++;
                tmp_m++;
            }
        }
        
        num++;
    }
    if (cnt == k){
        if (tmp_p >= 0 && tmp_m >= 0){
            cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
        }
        else if (tmp_p < 0){
            cout << min({cnt1, cnt2, -minus[tmp_m]}) << endl;
        }
        else {
            cout << min({cnt1, cnt2, plus[tmp_p]}) << endl;
        }
    else if (tmp_p != 0 && tmp_m != 0){
        cout << min({cnt1, cnt2, min(plus[tmp_p-1], -minus[tmp_m]) + max(plus[tmp_p-1], -minus[tmp_m]), min(plus[tmp_p], -minus[tmp_m-1]) + max(plus[tmp_p], -minus[tmp_m-1])}) << endl;
    }
    else{
        cout << min(cnt1, cnt2) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: 'k' was not declared in this scope
   52 |     if (cnt == k){
      |                ^
a.cc:54:108: error: expected ')' before '<<' token
   54 |             cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
      |                        ~                                                                                   ^~~
      |                                                                                                            )
a.cc:62:5: error: expected '}' before 'else'
   62 |     else if (tmp_p != 0 && tmp_m != 0){
      |     ^~~~
a.cc:52:18: note: to match this '{'
   52 |     if (cnt == k){
      |                  ^
Language: C++

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> plus;
    vector<int> minus;
    int x;
    for (int i = 0; i < N; i++){
        cin >> x;
        if (x < 0){
            minus.push_back(x);
        }
        else{
            plus.push_back(x);
        }
    }
    reverse(minus.begin(), minus.end());
    int tmp_p = -1;
    int tmp_m = -1;
    int cnt = 0;
    int num = 0;
    int cnt1 = 100000000;
    int cnt2 = 100000000;
    if (plus.size() >= K){
        cnt1 = plus[K-1];
    }
    if (minus.size() >= K) {
        cnt2 = minus[K-1];
    }

    while (cnt < K) {
        if (tmp_p+1 < plus.size()){
            if (plus[tmp_p+1] == num){
                cnt++;
                tmp_p++;
            }
        }
        if (tmp_m+1 < minus.size()){
            if (minus[tmp_m+1] == -num){
                cnt++;
                tmp_m++;
            }
        }
        
        num++;
    }
    if (cnt == k){
        if (tmp_p >= 0 && tmp_m >= 0){
            cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
        }
        else if (tmp_p < 0){
            cout << min({cnt1, cnt2, -minus[tmp_m]}) << endl;
        }
        else {
            cout << min({cnt1, cnt2, plus[tmp_p]}) << endl;
        }
    else if (tmp_p != 0 && tmp_m != 0{
        cout << min({cnt1, cnt2, min(plus[tmp_p-1], -minus[tmp_m]) + max(plus[tmp_p-1], -minus[tmp_m]), min(plus[tmp_p], -minus[tmp_m-1]) + max(plus[tmp_p], -minus[tmp_m-1])}) << endl;
    }
    else{
        cout << min(cnt1, cnt2) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: 'k' was not declared in this scope
   52 |     if (cnt == k){
      |                ^
a.cc:54:108: error: expected ')' before '<<' token
   54 |             cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
      |                        ~                                                                                   ^~~
      |                                                                                                            )
a.cc:62:5: error: expected '}' before 'else'
   62 |     else if (tmp_p != 0 && tmp_m != 0{
      |     ^~~~
a.cc:52:18: note: to match this '{'
   52 |     if (cnt == k){
      |                  ^
a.cc:62:38: error: expected ')' before '{' token
   62 |     else if (tmp_p != 0 && tmp_m != 0{
      |             ~                        ^
      |                                      )
a.cc:68:1: error: expected primary-expression before '}' token
   68 | }
      | ^
Language: C++

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> plus;
    vector<int> minus;
    int x;
    for (int i = 0; i < N; i++){
        cin >> x;
        if (x < 0){
            minus.push_back(x);
        }
        else{
            plus.push_back(x);
        }
    }
    reverse(minus.begin(), minus.end());
    int tmp_p = -1;
    int tmp_m = -1;
    int cnt = 0;
    int num = 0;
    int cnt1 = 100000000;
    int cnt2 = 100000000;
    if (plus.size() >= K){
        cnt1 = plus[K-1];
    }
    if (minus.size() >= K) {
        cnt2 = minus[K-1];
    }

    while (cnt < K) {
        if (tmp_p+1 < plus.size()){
            if (plus[tmp_p+1] == num){
                cnt++;
                tmp_p++;
            }
        }
        if (tmp_m+1 < minus.size()){
            if (minus[tmp_m+1] == -num){
                cnt++;
                tmp_m++;
            }
        }
        
        num++;
    }
    if (cnt == k){
        if (tmp_p >= 0 && tmp_m >= 0){
            cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
        }
        else if (tmp_p < 0){
            cout << min({cnt1, cnt2, -minus[tmp_m]}) << endl;
        }
        else {
            cout << min({cnt1, cnt2, plus[tmp_p]}) << endl;
        }
    else if (tmp_p != 0 && tmp_m != 0{
        cout << min({cnt1, cnt2, min(plus[tmp_p-1], -minus[tmp_m]) + max(plus[tmp_p-1], -minus[tmp_m]), min(plus[tmp_p], -minus[tmp_m-1]) + max(plus[tmp_p], -minus[tmp_m-1])})
    }
    else{
        cout << min(cnt1, cnt2) << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: 'k' was not declared in this scope
   52 |     if (cnt == k){
      |                ^
a.cc:54:108: error: expected ')' before '<<' token
   54 |             cout << min(cnt1, cnt2, {2 * min(plus[tmp_p], -minus[tmp_m]) + max(plus[tmp_p], -minus[tmp_m])} << endl;
      |                        ~                                                                                   ^~~
      |                                                                                                            )
a.cc:62:5: error: expected '}' before 'else'
   62 |     else if (tmp_p != 0 && tmp_m != 0{
      |     ^~~~
a.cc:52:18: note: to match this '{'
   52 |     if (cnt == k){
      |                  ^
a.cc:62:38: error: expected ')' before '{' token
   62 |     else if (tmp_p != 0 && tmp_m != 0{
      |             ~                        ^
      |                                      )
a.cc:68:1: error: expected primary-expression before '}' token
   68 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

ll main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> X(N);

    ll ans = INF;
    for(ll i=0;i<N;i++) cin >> X[i];
    for(ll i=0;i<N-K-1;i++){
        ll pre_ans;
        ll l = i,r = i+K-1;
        if(X[l]*X[r] < 0){
            pre_ans = min(abs(X[l]),abs(X[r]))*2 + max(abs(X[l]),abs(X[r]));
        }
        else{
            pre_ans = max(abs(X[l]),abs(X[r]));
        }
        ans = min(ans,pre_ans);
    }
    cout << ans << endl;

}


Compiler output:
a.cc:8:1: error: '::main' must return 'int'
    8 | ll main(){
      | ^~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <set>

#include <chrono>
//#include <immintrin.h>

using namespace std;

typedef long long ll;
void print(vector<ll> v){
    for(int i=0; i<v.size(); i++){
        cout << v[i];
    }
    cout << endl;
}

int main()
{
	ll N,K;
    cin >> N >> K;
    vector<ll> R, L;
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp<0) L.push_back(-tmp);
        else if(tmp>0) R.push_back(tmp);
        else K--;
    }
    reverse(L.begin(), L.end());
    
    ll ans=1000000000000;
    for(int i=0; i<min((ll)L.size(), K); i++){
        ll tmp=L[i];
        int remain=K-(i+1);
        if(remain>R.size()) continue;
        if(remain>0) tmp+=L[i]+R[remain-1];
        ans=min(ans, tmp);
    }
    if(L.size()==0 && K!=0) ans=R[K-1];
    if(K==0) ans=0;

    cout << ans << endl;

    
    return 0;
}


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

#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <set>

#include <chrono>
//#include <immintrin.h>

using namespace std;

typedef long long ll;
void print(vector<ll> v){
    for(int i=0; i<v.size(); i++){
        cout << v[i];
    }
    cout << endl;
}

ll re_MAX(vector<ll> vt, int size){
    sort(vt.begin(), vt.begin()+size, greater<ll>());
    return vt[0];
}

std::chrono::system_clock::time_point get_time_sec(){
	return std::chrono::system_clock::now();
}

int main()
{
	ll N,K;
    cin >> N >> K;
    vector<ll> R, L;
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp<0) L.push_back(-tmp);
        else if(tmp>0) R.push_back(tmp);
        else K--;
    }
    reverse(L.begin(), L.end());
    
    ll ans=1000000000000;
    for(int i=0; i<min((ll)L.size(), K); i++){
        ll tmp=L[i];
        int remain=K-(i+1);
        if(remain>R.size()) continue;
        if(remain>0) tmp+=L[i]+R[remain-1];
        ans=min(ans, tmp);
    }
    if(L.size()==0 && K!=0) ans=R[K-1];
    if(K==0) ans=0;

    cout << ans << endl;

    
    return 0;
}


Compiler output:
a.cc: In function 'll re_MAX(std::vector<long long int>, int)':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   21 |     sort(vt.begin(), vt.begin()+size, greater<ll>());
      |     ^~~~
      |     sqrt
a.cc: In function 'int main()':
a.cc:41:5: error: 'reverse' was not declared in this scope
   41 |     reverse(L.begin(), L.end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <set>

#include <chrono>
//#include <immintrin.h>

using namespace std;

typedef long long ll;
void print(vector<ll> v){
    for(int i=0; i<v.size(); i++){
        cout << v[i];
    }
    cout << endl;
}

ll re_MAX(vector<ll> vt, int size){
    sort(vt.begin(), vt.begin()+size, greater<ll>());
    return vt[0];
}

std::chrono::system_clock::time_point get_time_sec(){
	return std::chrono::system_clock::now();
}

int main()
{
	ll N,K;
    cin >> N >> K;
    vector<ll> R, L;
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp<0) L.push_back(-tmp);
        else if(tmp>0) R.push_back(tmp);
        else K--;
    }
    reverse(L.begin(), L.end());
    
    ll ans=1000000000000;
    for(int i=0; i<min((ll)L.size(), K); i++){
        ll tmp=L[i];
        int remain=K-(i+1);
        if(remain>R.size()) continue;
        if(remain>0) tmp+=L[i]+R[remain-1];
        ans=min(ans, tmp);
    }
    if(L.size()==0) ans=R[K-1];

    cout << ans << endl;

    
    return 0;
}


Compiler output:
a.cc: In function 'll re_MAX(std::vector<long long int>, int)':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   21 |     sort(vt.begin(), vt.begin()+size, greater<ll>());
      |     ^~~~
      |     sqrt
a.cc: In function 'int main()':
a.cc:41:5: error: 'reverse' was not declared in this scope
   41 |     reverse(L.begin(), L.end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <set>

#include <chrono>
//#include <immintrin.h>

using namespace std;

typedef long long ll;
void print(vector<ll> v){
    for(int i=0; i<v.size(); i++){
        cout << v[i];
    }
    cout << endl;
}

ll re_MAX(vector<ll> vt, int size){
    sort(vt.begin(), vt.begin()+size, greater<ll>());
    return vt[0];
}

std::chrono::system_clock::time_point get_time_sec(){
	return std::chrono::system_clock::now();
}

int main()
{
	ll N,K;
    cin >> N >> K;
    vector<ll> R, L;
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp<0) L.push_back(-tmp);
        else if(tmp>0) R.push_back(tmp);
        else K--;
    }
    reverse(L.begin(), L.end());
    
    ll ans=1000000000000;
    for(int i=0; i<min((ll)L.size(), K); i++){
        ll tmp=L[i];
        int remain=K-(i+1);
        if(remain>R.size()) continue;
        if(remain>0) tmp+=L[i]+R[remain-1];
        ans=min(ans, tmp);
    }

    cout << ans << endl;

    
    return 0;
}


Compiler output:
a.cc: In function 'll re_MAX(std::vector<long long int>, int)':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   21 |     sort(vt.begin(), vt.begin()+size, greater<ll>());
      |     ^~~~
      |     sqrt
a.cc: In function 'int main()':
a.cc:41:5: error: 'reverse' was not declared in this scope
   41 |     reverse(L.begin(), L.end());
      |     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    int j=0;
    rep(i,n){
        cin>>x[i];
        if(x[i]>=0){
            j = i;
            break;
        }
    }
    
    int ans = 0;
    for(int l=1;l<=k;j++){
        int d = abs(x[j-l]) + 2*abs(x[j+k-l-1]);
        int e = 2*abs(x[j-l]) + abs(x[j+k-l-1]);
        ans = min(ans,d,e);
        
    }
    cout<< ans<<endl;
    return 0;
}


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 = int; _Compare = int]':
a.cc:21:18:   required from here
   21 |         ans = min(ans,d,e);
      |               ~~~^~~~~~~~~
/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 <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  vector<long long int> x(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i);
  }
  long long int w;
  long long int d = inf;
  int l, r;
  for(int i=0;i<=n-k;i++){
    w = x.at(i+k-1) - x.at(i);
    if(w<=d){
      d = w;
      l = i;
      r = i+k-1;
    }
  }
  long long int ans = d+min(abs(x.at(l)),abs(x.at(r)));
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   20 |   long long int d = inf;
      |                     ^~~
      |                     ynf
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
  cin >> n >> k;
  vector<long long int> x(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i);
  }
  long long int w;
  long long int d = inf;
  int l, r;
  for(int i=0;i<=n-k;i++){
    w = x.at(i+k-1) - x.at(i);
    if(w<=d){
      d = w;
      l = i;
      r = i+k-1;
    }
  }
  long long int ans = d+min(abs(x.at(l)),abs(x.at(r)));
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |   cin >> n >> k;
      |          ^
      |          yn
a.cc:13:15: error: 'k' was not declared in this scope
   13 |   cin >> n >> k;
      |               ^
a.cc:19:21: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   19 |   long long int d = inf;
      |                     ^~~
      |                     ynf
Language: C++

//include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI = 3.141592653589793;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main() {
    int tmp {0}, ans {INT_MAX};
    int n, k; cin >> n >> k;
    vector<int> x(n);
    REP (i, n) cin >> x[i];
    REP (i, n - k + 1) {
        tmp = (x[i + k - 1] - x[i]) + abs(min(x[i], x[i + k - 1]));
        ans = min(ans, tmp);
    }
    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:85:23: error: 'INT_MAX' was not declared in this scope
   85 |     int tmp {0}, ans {INT_MAX};
      |                       ^~~~~~~
a.cc:23:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   22 | #include <utility>
  +++ |+#include <climits>
   23 | #include <vector>
Language: C++

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

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

    int result = pow(2, 27);
    for(int i=0; i+(k-1)<n; i++){
        int tmp = 0;
        tmp += x[i+k-1] - x[i];
        tmp += min(abs(x[i]), abs(s[i+k-1]));
        result = min(result, tmp);
    }
    cout << result << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:35: error: 's' was not declared in this scope
   17 |         tmp += min(abs(x[i]), abs(s[i+k-1]));
      |                                   ^
Language: C++

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

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

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

    long long ans = 1000000000;
    for (int i = 0; i <= N-K; i++) {
        long long time = 0;
        if (x[i+K-1] < 0) {
            time = -x[i];
        }
        else if (x[i] > 0) {
            time = x[i+k-1];
        }
        else if (x[i+K-1] + x[i] > 0) {
            time = (-x[i]*2);
            time += x[i+K-1];
        }
        else {
            time = (x[i+K-1]*2);
            time -= x[i];
        }
        ans = std::min(ans, time);
    }

    std::cout << ans << std::endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:24: error: 'k' was not declared in this scope
   22 |             time = x[i+k-1];
      |                        ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k; --k;
    vector<int> x(n);
    REP(i,n) cin >> x[i];
    int ans = int_MAX;
    FOR(i,k,n) {
        int tmp = abs(x[i]-x[i-k]) + min(abs(x[i]),abs(x[i-k]));
        chmin(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: 'int_MAX' was not declared in this scope; did you mean 'INT_MAX'?
   20 |     int ans = int_MAX;
      |               ^~~~~~~
      |               INT_MAX
Language: C

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

int min(int a, int b){
	return a > b ? b : a;
}

int max(int a, int b){
	return a > b ? a : b;
}

int main(void){
	int n, k;
	int near = INT_MAX;
	int *x;
	scanf("%d %d", &n, &k);
	x = malloc(sizeof(int) * n);
	for(int i = 0; i < n; i++){
		scanf("%d", x + i);
		if(i >= k - 1){
			int left = i - k + 1, right = i;
			near = min(near, x[right] - x[left] + min(max(0, x[left]) - min(0, x[left]), max(0, x[right]) - min(0, x[right])));
		}
	}
	printf("%d\n", near);
	return 0;
}
	

Compiler output:
main.c: In function 'main':
main.c:14:20: error: 'INT_MAX' undeclared (first use in this function)
   14 |         int near = INT_MAX;
      |                    ^~~~~~~
main.c:3:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    2 | #include <stdlib.h>
  +++ |+#include <limits.h>
    3 | 
main.c:14:20: note: each undeclared identifier is reported only once for each function it appears in
   14 |         int near = INT_MAX;
      |                    ^~~~~~~
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[] x = new Int[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextInt();
        }
        sc.close();
        int min = Integer.MAX_VALUE;
        for(int i = 0; i <= N-K; i++){
            min = Math.min(min, Math.abs(x[i+K-1] - x[i])+Math.min(x[i+K-1], x[i]));
        }
        System.out.println(min);
    }
}

Compiler output:
Main.java:9: error: cannot find symbol
        int[] x = new Int[N];
                      ^
  symbol:   class Int
  location: class Main
1 error
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[] x = new Int[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextLong();
        }
        sc.close();
        int min = Integer.MAX_VALUE;
        for(int i = 0; i <= N-K; i++){
            min = Math.min(min, Math.abs(x[i+K-1] - x[i])+Math.min(x[i+K-1], x[i]));
        }
        System.out.println(min);
    }
}

Compiler output:
Main.java:9: error: cannot find symbol
        int[] x = new Int[N];
                      ^
  symbol:   class Int
  location: class Main
Main.java:11: error: incompatible types: possible lossy conversion from long to int
            x[i] = sc.nextLong();
                              ^
2 errors
Language: Java

import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in); 

        long N = sc.nextLong();
        long K = sc.nextLong();
        long[] x = new long[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextlong();
        }
        sc.close();

        long left = left_num(x);
        long right;
        long xl = 0;
        long xr = 0;
        long min = 2*(x[N-1] - x[0]);
            right = N - left;
            //i:左側の個数
            for(int i = 0; i <= Math.min(left, K); i++){
                long j = K-i; //右側に行く個数
                if(right < j)
                    continue;
                else{
                    if(i == 0){
                        min = Math.min(min, Math.abs(x[left+K-1]));
                    }
                    if(j == 0)
                        min = Math.min(min, Math.abs(x[left-K]));
                    if(i > 0 && j > 0){
                        xl = x[left-i];
                        xr = x[left+j-1];
                        long dis = Math.min((Math.abs(xl) + Math.abs(xl-xr)),
                                             (Math.abs(xr) + Math.abs(xl-xr)));
                        min = Math.min(min, dis);
                    }
                }
            }
        System.out.println(min);

    }
    static long left_num(long[] a){
        long index = 0;
        while(a[index] < 0){
            index++;
        }
        return index;
    }
}

Compiler output:
Main.java:9: error: incompatible types: possible lossy conversion from long to int
        long[] x = new long[N];
                            ^
Main.java:11: error: cannot find symbol
            x[i] = sc.nextlong();
                     ^
  symbol:   method nextlong()
  location: variable sc of type Scanner
Main.java:19: error: incompatible types: possible lossy conversion from long to int
        long min = 2*(x[N-1] - x[0]);
                         ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
                        min = Math.min(min, Math.abs(x[left+K-1]));
                                                             ^
Main.java:31: error: incompatible types: possible lossy conversion from long to int
                        min = Math.min(min, Math.abs(x[left-K]));
                                                           ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
                        xl = x[left-i];
                                   ^
Main.java:34: error: incompatible types: possible lossy conversion from long to int
                        xr = x[left+j-1];
                                     ^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
        while(a[index] < 0){
                ^
8 errors
Language: Java

import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in); 

        long N = sc.nextLong();
        long K = sc.nextLong();
        long[] x = new int[N];
        for(int i = 0; i < N; i++){
            x[i] = sc.nextlong();
        }
        sc.close();

        long left = left_num(x);
        long right;
        long xl = 0;
        long xr = 0;
        long min = 2*(x[N-1] - x[0]);
            right = N - left;
            //i:左側の個数
            for(int i = 0; i <= Math.min(left, K); i++){
                int j = K-i; //右側に行く個数
                if(right < j)
                    continue;
                else{
                    if(i == 0){
                        min = Math.min(min, Math.abs(x[left+K-1]));
                    }
                    if(j == 0)
                        min = Math.min(min, Math.abs(x[left-K]));
                    if(i > 0 && j > 0){
                        xl = x[left-i];
                        xr = x[left+j-1];
                        long dis = Math.min((Math.abs(xl) + Math.abs(xl-xr)),
                                             (Math.abs(xr) + Math.abs(xl-xr)));
                        min = Math.min(min, dis);
                    }
                }
            }
        System.out.println(min);

    }
    static long left_num(long[] a){
        long index = 0;
        while(a[index] < 0){
            index++;
        }
        return index;
    }
}

Compiler output:
Main.java:9: error: incompatible types: possible lossy conversion from long to int
        long[] x = new int[N];
                           ^
Main.java:9: error: incompatible types: int[] cannot be converted to long[]
        long[] x = new int[N];
                   ^
Main.java:11: error: cannot find symbol
            x[i] = sc.nextlong();
                     ^
  symbol:   method nextlong()
  location: variable sc of type Scanner
Main.java:19: error: incompatible types: possible lossy conversion from long to int
        long min = 2*(x[N-1] - x[0]);
                         ^
Main.java:23: error: incompatible types: possible lossy conversion from long to int
                int j = K-i; //???????
                         ^
Main.java:28: error: incompatible types: possible lossy conversion from long to int
                        min = Math.min(min, Math.abs(x[left+K-1]));
                                                             ^
Main.java:31: error: incompatible types: possible lossy conversion from long to int
                        min = Math.min(min, Math.abs(x[left-K]));
                                                           ^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
                        xl = x[left-i];
                                   ^
Main.java:34: error: incompatible types: possible lossy conversion from long to int
                        xr = x[left+j-1];
                                     ^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
        while(a[index] < 0){
                ^
10 errors
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n, k; cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = INT_MAX;
    rep(i,n-k+1){
        ans = min(ans,min(v[i+k-1]-v[i]+abs(v[i]),v[i+k-1]-v[i]+abs(v[i+k-1])));
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: 'INT_MAX' was not declared in this scope
   25 |     int ans = INT_MAX;
      |               ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <queue>
  +++ |+#include <climits>
    9 | #define rep(i, n) for(int i = 0; i < n; i++)
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll min(ll a,ll b){
  if(a>b){
    return b;
    ]
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }
  

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>X(N);
  vector<pair<ll,bool>ab(N);
  
  for(ll i=0;i<N;i++){
    cin>>X[i];
    if(X[i]<0){
    ab.at(i).first=abs(X[i]);
      ab.at(i).second=false;
    }

    else{
ab.at(i).first=abs(X[i]);
      ab.at(i).second=true;
  }
  
  }
  sort(ab.begin(),ab.end());
  
  ll right=0;
  ll left=0;
  for(ll i=0;i<K;i++){
if(ab.at(i).second=true){
  right+=ab.at(i).first;
}
    else{
left+=ab.at(i).second;
    }
  }

 cout<<min(right,left)*2+max(right,left);
}
  
  
  


Compiler output:
a.cc: In function 'll min(ll, ll)':
a.cc:7:5: error: expected primary-expression before ']' token
    7 |     ]
      |     ^
a.cc:13:20: error: a function-definition is not allowed here before '{' token
   13 |   ll max(ll a,ll b){
      |                    ^
a.cc:23:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   23 | int main(){
      |         ^~
a.cc:23:9: note: remove parentheses to default-initialize a variable
   23 | int main(){
      |         ^~
      |         --
a.cc:23:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:23:11: error: a function-definition is not allowed here before '{' token
   23 | int main(){
      |           ^
a.cc:56:2: error: expected '}' at end of input
   56 | }
      |  ^
a.cc:4:18: note: to match this '{'
    4 | ll min(ll a,ll b){
      |                  ^
a.cc:56:2: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      |  ^
Language: C++

	ll t; cin>>t;
		p[i]=mp(abs(t),t>0?1:t==0?0:-1);
	}
	sort(p.bg,p.ed);
	vector<ll> minus;
	vector<ll> plus;
	minus.pb(0);
	plus.pb(0);
	rep(i,N){
		if(p[i].b==1) plus.pb(p[i].a);
		else if(p[i].b==-1) minus.pb(p[i].a);
		else zero=true;
	}
	if(zero){
		if(plus.sz>=K) ans=min(ans,plus[K-1]);
		if(minus.sz>=K) ans=min(ans,minus[K-1]);
		if(plus.sz>=2 && minus.sz>=2){
          for(int i=minus.sz-1;K-1-i<=plus.sz-1;i--){
			ans=min(ans,min(minus[i],plus[K-1-i])+minus[i]+plus[K-1-i]);
		}
        }
	}else{
		if(plus.sz-1>=K) ans=min(ans,plus[K]);
		if(minus.sz-1>=K) ans=min(ans,minus[K]);
      if(plus.sz>=2 && minus.sz>=2){
		for(int i=minus.sz-1;K-i<=plus.sz-1;i--){
			ans=min(ans,min(minus[i],plus[K-i])+minus[i]+plus[K-i]);
		}
      }
	}
	cout<<ans;
}

Compiler output:
a.cc:1:9: error: 'll' does not name a type
    1 |         ll t; cin>>t;
      |         ^~
a.cc:1:15: error: 'cin' does not name a type
    1 |         ll t; cin>>t;
      |               ^~~
a.cc:2:17: error: 'p' does not name a type
    2 |                 p[i]=mp(abs(t),t>0?1:t==0?0:-1);
      |                 ^
a.cc:3:9: error: expected declaration before '}' token
    3 |         }
      |         ^
a.cc:4:13: error: expected constructor, destructor, or type conversion before '(' token
    4 |         sort(p.bg,p.ed);
      |             ^
a.cc:5:9: error: 'vector' does not name a type
    5 |         vector<ll> minus;
      |         ^~~~~~
a.cc:6:9: error: 'vector' does not name a type
    6 |         vector<ll> plus;
      |         ^~~~~~
a.cc:7:9: error: 'minus' does not name a type
    7 |         minus.pb(0);
      |         ^~~~~
a.cc:8:9: error: 'plus' does not name a type
    8 |         plus.pb(0);
      |         ^~~~
a.cc:9:12: error: expected constructor, destructor, or type conversion before '(' token
    9 |         rep(i,N){
      |            ^
a.cc:14:9: error: expected unqualified-id before 'if'
   14 |         if(zero){
      |         ^~
a.cc:22:10: error: expected unqualified-id before 'else'
   22 |         }else{
      |          ^~~~
a.cc:31:9: error: 'cout' does not name a type
   31 |         cout<<ans;
      |         ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;


int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> v(n);
  int now=-1;
  ll min=1145141919810;
  REP(i,n){
    cin >> v[i];
    if(min>abs(v[i])){
      now=i;
    }
  }
  k--;
  ll ans=0;
  while(k!=0){
    if(now==0){
      ans+=abs(v[1]-v[0]);
      v.erase(v.begin());
      now++;
      k--;
      continue;
    }
    else if(now==v.size()-1){
      ans+=abs(v[now]-v[now-1]);
      v.erase(v.begin()+now);
      now--;
      k--;
      continue;
    }
    ll tmp=min(abs(v[now]-v[now-1]),abs(v[now]-v[now+1]));
    if(abs(v[now]-v[now-1])<abs(v[now]-v[now+1])){
      now--;
      v.erase(v.begin()+now+1);
    }
    else{
      now++;
      v.erase(v.begin()+now-1);
    }
    ans+=tmp;
    k--;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:15: error: 'min' cannot be used as a function
   45 |     ll tmp=min(abs(v[now]-v[now-1]),abs(v[now]-v[now+1]));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define itn int
#define REP(i,n) for(int i=0;i<(n);i++)
#define IREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(n);i++)
#define REPEACH(itr,k) for(auto&& itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL<<60;
typedef pair<double,int> P;


int main(){
  int n,k;
  cin >> n >> k;
  vector<ll> v(n);
  int now=-1;
  ll min=1145141919810;
  REP(i,n){
    cin >> v[i];
    if(min>abs(v[i])){
      now=i;
    }
  }
  k--;
  ll ans=0;
  while(k!=0){
    if(now==0){
      ans+=abs(v[1]-v[0]);
      v.erase(v.begin());
      now++;
      k--;
      continue;
    }
    else if(now==v.size()-1){
      ans+=abs(v[now]-v[now-1]);
      v.erase(v.begin()+now);
      now--;
      k--;
      continue;
    }
    ll tmp=min(abs(v[now]-v[now-1]),abs(v[now]-v[now+1]))
    if(abs(v[now]-v[now-1])<abs(v[now]-v[now+1])){
      now--;
      v.erase(v.begin()+now+1);
    }
    else{
      now++;
      v.erase(v.begin()+now-1);
    }
    ans+=tmp;
    k--;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:15: error: 'min' cannot be used as a function
   45 |     ll tmp=min(abs(v[now]-v[now-1]),abs(v[now]-v[now+1]))
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main() {
  int n, k, i, l, r, ans = 100000001;
  cin >> n >> k;
  
  vector<int> x(n);
  for(i = 0; i < n; i++){
    cin >> x.at(i);
  }
  
  for(i = 0; i < n - k + 1; i++){
    l = x.at(i);
    r = x.at(i + k - 1);
    ans = min(ans, min(abs(r - l) + abs(l), abs(r - l) + abs(r)))
  }
  
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:66: error: expected ';' before '}' token
   16 |     ans = min(ans, min(abs(r - l) + abs(l), abs(r - l) + abs(r)))
      |                                                                  ^
      |                                                                  ;
   17 |   }
      |   ~
Language: C++

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

int main() {
  int n, k, i, l, r, ans = 100000001;
  cin >> n >> k;
  
  vector<int> x(n);
  for(i = 0; i < h; i++){
    cin >> x.at(i);
  }
  
  for(i = 0; i < n - k + 1; i++){
    l = x.at(i);
    r = x.at(i + k - 1);
    ans = min(ans, min(abs(r - l) + abs(l), abs(r - l) + abs(r)))
  }
  
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:18: error: 'h' was not declared in this scope
    9 |   for(i = 0; i < h; i++){
      |                  ^
a.cc:16:66: error: expected ';' before '}' token
   16 |     ans = min(ans, min(abs(r - l) + abs(l), abs(r - l) + abs(r)))
      |                                                                  ^
      |                                                                  ;
   17 |   }
      |   ~
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
typedef long long int ll;
const int MAX = 1e5 + 10;

int main()
{
	ll n,k,i; cin>>n>>k;
	ll a[MAX];
	for(i=0;i<n;i++) cin>>a[i];	
	i=0;
	while(a[i]<0) i++;

	ll c=i;
	ll j=i+k-1;

	ll mn = INT_MAX;

	while(true){
	    
		if(i<0) break;
		if(j == c-1){
			mn = min(abs(a[i]),mn);
			break;
		}
		if(j<=n-1){
			if(i==c){
				mn = min(mn,abs(a[j]));
			}
			else{
				ll d = min(abs(a[i]),abs(a[j]));
				ll m = max(abs(a[i]),abs(a[j]));
				mn = min(mn,2*d+m);
			}
		}
		//cout<<i<<" "<<j<<" "<<mn<<endl;
		i--; j--;
	}

	cout<<mn<<endl;

}


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

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

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

    vector<long long> x(N);
    for(int i = 0;i < N;i++) {
        cin >> x.at(i);
    }
    
    long long ans = 1000000000;
    for(int i = 0;i < N - K + 1;i++) {
        long long l = x.at(i);
        long long r = x.at(i + K - 1);
        long long dis1 = abs(l) + abs(r - l),dis2 = abs(r) + abs(l - r);
        long long mini = min(dis1,dis2);
        abs = min(ans,mini);
    }

    cout << mini << endl;

    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:27: error: overloaded function with no contextual type information
   21 |         abs = min(ans,mini);
      |                           ^
a.cc:24:13: error: 'mini' was not declared in this scope
   24 |     cout << mini << endl;
      |             ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,k;cin >> n >> k;
	vector<int> cv;
	for(int i = 0; i < n;i++){
		int c; cin >> c;
		cv.push_back(c);
	}

	cost = abs(cv[k-1]- cv[0]);
	if(cv[0] < 0 && cv[k-1] > 0)cost += min(abs(cv[0]),abs(cv[k-1]));
	int ans = cost;

	for(int i = k; i < n; i++){
			int n_cost = abs(cv[i-k+1]- cv[i]);
			if(cv[i-k+1] < 0 && cv[i] > 0)n_cost += min(abs(cv[i-k+1]),abs(cv[i]));
			ans = min(n_cost, ans);
	}
	if(cv[0] > 0)ans = cv[k-1];

	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'cost' was not declared in this scope; did you mean 'const'?
   13 |         cost = abs(cv[k-1]- cv[0]);
      |         ^~~~
      |         const
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	long long int n, k, mark, sz, cal, ans=200000001;
	long long int tmp=0;
	vector<int> v;

	cin>> n >> k;
	v.resize(n);

	for(int i=0;i<n;i++){
		cin>> v[i];
			
		if(0<i) tmp=v[i]*v[i-1];
		if(tmp<0) mark=i;
	}

	if(0<=v[0]){
		cout<< v[k-1] << endl;
		return 0;
	}
	if(v[n-1]<=0){
		cout<< abs(v[n-k]) << endl;
		return 0;
	}

	for(int i=max(0, mark-k);i<=mark;i++){
		if(i+k>n) break;
		//cout<< abs(v[i]) << " " << abs(v[i+k-1]) << endl;
		cal=abs(v[i]*2)+abs(v[i+k-1]);
		ans=min(ans, cal);
		cal=abs(v[i])+abs(v[i+k-1]*2);
		ans=min(ans, cal);
		if(v[i]<0 && v[i+k-1]<0) cal=abs(v[i]);
		ans=min(ans, cal);
		if(v[i]>0 && v[i+k-1]>0) cal=v[i+k-1];
		ans=min(ans, cal);
	}

	cout<< ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: error: no matching function for call to 'max(int, long long int)'
   33 |         for(int i=max(0, mark-k);i<=mark;i++){
      |                   ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:33:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   33 |         for(int i=max(0, mark-k);i<=mark;i++){
      |                   ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   33 |         for(int i=max(0, mark-k);i<=mark;i++){
      |                   ~~~^~~~~~~~~~~
Language: C

#include<iostream>
using namespace std;
long n,k,i,t,a=0x7fffffffffffffff;
int main(){
    cin>>n>>k;
    long x[n];
    for(auto &d:x)cin>>d;
    for(;i<n-k+1;i++)t=labs(x[i]-x[i+k-1]),a=min(a,min(labs(x[i]),labs(x[i+k-1]))+t);
    cout<<a;
}

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