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

#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define pb push_back
#define bi_s binary_search
#define lb lower_bound
#define ub upper_bound
using namespace std;

int n;
int k;
int x[100005];
long long ans=200000005;

int main(){
	cin >>n >>k;
  	rep(i,n){
    	cin >>x[i];
   	}

  	rep(i,n-k+1){
    ans=min(ans,min(abs(x[i]-0)+x[i+k-1]-x[i],abs(x[i+k-1]-0)+x[i+k-1]-x[i]));
    }
  
  	cout <<ans <<endl;
  	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: no matching function for call to 'min(long long int&, const int&)'
   24 |     ans=min(ans,min(abs(x[i]-0)+x[i+k-1]-x[i],abs(x[i+k-1]-0)+x[i+k-1]-x[i]));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:24:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |     ans=min(ans,min(abs(x[i]-0)+x[i+k-1]-x[i],abs(x[i+k-1]-0)+x[i+k-1]-x[i]));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:24:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   24 |     ans=min(ans,min(abs(x[i]-0)+x[i+k-1]-x[i],abs(x[i+k-1]-0)+x[i+k-1]-x[i]));
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'INT_MAX' was not declared in this scope
   16 |     int ans = 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 | using namespace std;
Language: C++

using namespace std;
int main(){
    int n, k; cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i)cin>>a[i];

    int ans=INT_MAX,t;
    for(int i=0;i<n-k+1;++i){
        t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
        if(ans>t)ans=t;
    }
    cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:15: error: 'cin' was not declared in this scope
    3 |     int n, k; 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:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> a(n);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> a(n);
      |            ^~~
a.cc:5:30: error: 'a' was not declared in this scope
    5 |     for(int i=0;i<n;++i)cin>>a[i];
      |                              ^
a.cc:7:13: error: 'INT_MAX' was not declared in this scope
    7 |     int ans=INT_MAX,t;
      |             ^~~~~~~
a.cc:1:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
  +++ |+#include <climits>
    1 | using namespace std;
a.cc:9:9: error: 't' was not declared in this scope
    9 |         t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
      |         ^
a.cc:9:15: error: 'a' was not declared in this scope
    9 |         t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
      |               ^
a.cc:9:29: error: 'abs' was not declared in this scope; did you mean 'ans'?
    9 |         t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
      |                             ^~~
      |                             ans
a.cc:9:11: error: 'min' was not declared in this scope; did you mean 'main'?
    9 |         t=min(a[i+k-1]-a[i]+abs(a[i+k-1]), a[i+k-1]-a[i]+abs(a[i]));
      |           ^~~
      |           main
a.cc:12:5: error: 'cout' was not declared in this scope
   12 |     cout<<ans;
      |     ^~~~
a.cc:12:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<cstdio>
using namespace std;
 
const int N = (int) 1e5;
int n,k;
long long a[N+5],ans=(long long)2e15;
int main()
{
 
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
     for(int i=1;i+k-1<=n;i++)
    {  
        int l=i,r=i+k-1;
        ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin>>n>>k;
      |     ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<cstdio>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:16:35: error: 'abs' was not declared in this scope; did you mean 'ans'?
   16 |         ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
      |                                   ^~~
      |                                   ans
a.cc:16:31: error: 'min' was not declared in this scope; did you mean 'main'?
   16 |         ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
      |                               ^~~
      |                               main
a.cc:16:13: error: 'min' was not declared in this scope; did you mean 'main'?
   16 |         ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
      |             ^~~
      |             main
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout<<ans;
      |     ^~~~
a.cc:18:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

using namespace std;

int main(){
  int n, k;
  int m = INT_MIN;
  cin >> n >> k;
  int l, r;

  vector<int> x(n);
  vector<pair<int, int> > distance(n);
  for(int i = 0; i < n; ++i){
    cin >> x[i];
    distance[i].first = abs(x[i]);
    distance[i].second = i;
    if(x[i] < 0){
      if(m < x[i]){
        m = x[i];
      }
    }
  }

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

  for(int i = 0; i < n; ++i){
    cout << distance[i].first << " ";
  }

  cout << endl;


  for(int i = 0; i < k; ++i){
    if(x[distance[i].second] > 0){
      r = distance[i].first;
    } else {
      l = distance[i].first;
    }
  }

  if(r > l){
    cout << r + 2 * l << endl;
  } else {
    cout << r * 2 + l << endl;
  }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: 'INT_MIN' was not declared in this scope
   12 |   int m = INT_MIN;
      |           ^~~~~~~
a.cc:7:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<cmath>
  +++ |+#include <climits>
    7 |
Language: C++

n, k = map(int, input().split())
lst = list(map(int, input().split()))

array = np.array(lst)
po_array = array[array>=0]
ne_array = np.sort(abs(array[array<=0]))

if len(po_array) >= len(ne_array):
    long_array = po_array
    short_array = ne_array
else:
    long_array = ne_array
    short_array = po_array

if len(short_array) > k:
    min_len = k
else:
    min_len = len(short_array)
    
if min_len == 0:
    print(long_array[k-1])
else:
    min_dist = 10**10
    for i in range(min_len):
        dist = short_array[i]*2 + long_array[k-i-2]
        if min_dist > dist:
            min_dist = dist
    print(min_dist)

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

#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> data(N)
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int ans, a;
  for (int i = 0; i < N - K + 1; i++) {
    if ((data.at(i) <= 0 && data.at(i + K - 1) <= 0) && (data.at(i) >= 0 && data.at(i + K - 1) >= 0)) {
      if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = abs(data.at(i + K - 1));
      else a = abs((data.at(i));
    } else {
      if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = 2 * abs(data.at(i)) + abs(data.at(i + K - 1));
      else a = 2 * abs(data.at(i + K - 1)) + abs(data.at(i));
    }
    if (ans > a) ans = a;
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected ',' or ';' before 'for'
    7 |   for (int i = 0; i < N; i++) {
      |   ^~~
a.cc:7:19: error: 'i' was not declared in this scope
    7 |   for (int i = 0; i < N; i++) {
      |                   ^
a.cc:13:53: error: expected ';' before 'a'
   13 |       if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = abs(data.at(i + K - 1));
      |                                                     ^~
      |                                                     ;
a.cc:14:7: error: expected primary-expression before 'else'
   14 |       else a = abs((data.at(i));
      |       ^~~~
a.cc:13:82: error: expected ')' before 'else'
   13 |       if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = abs(data.at(i + K - 1));
      |         ~                                                                        ^
      |                                                                                  )
   14 |       else a = abs((data.at(i));
      |       ~~~~                                                                        
a.cc:16:53: error: expected ';' before 'a'
   16 |       if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = 2 * abs(data.at(i)) + abs(data.at(i + K - 1));
      |                                                     ^~
      |                                                     ;
a.cc:17:7: error: expected primary-expression before 'else'
   17 |       else a = 2 * abs(data.at(i + K - 1)) + abs(data.at(i));
      |       ^~~~
a.cc:16:104: error: expected ')' before 'else'
   16 |       if(abs((data.at(i)) <=abs(data.at(i + K - 1))) a = 2 * abs(data.at(i)) + abs(data.at(i + K - 1));
      |         ~                                                                                              ^
      |                                                                                                        )
   17 |       else a = 2 * abs(data.at(i + K - 1)) + abs(data.at(i));
      |       ~~~~
Language: C++

#include"stdafx.h"
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	int n,k,subans;
	long long ans=1e18;
	int i;
	cin>>n>>k;
	int a[100000];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n-k+1;i++){
		subans=a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1]));
		if(subans<ans){
			ans=subans;
		}
	}
	cout << ans;
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: stdafx.h: No such file or directory
    1 | #include"stdafx.h"
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

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

int main(){
	int n,k,subans;
	int ans=2*pow(10,8);
	int i;
	cin>>n>>k;
	int a[100000];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n-k+1;i++){
		subans=a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1]));
		if(subans<ans){
			ans=subans;
		}
	}
	cout << ans;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'pow' was not declared in this scope
    9 |         int ans=2*pow(10,8);
      |                   ^~~
Language: C++

#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int n,k;
   cin>>n>>k;
   int x[n];
   for(int i=0;i<n;i++){
      cin>>x[i];
   }
   int left=0,right=k-1;
   int ans=INF;
   while(right<n){
      ll lval=x[left],rval=x[right];
      ll tmp=lval*rval;
      if(tmp>=0){
         ans=min(ans,max(lval,rval));
      }else{
         int s,t;
         s=abs(lval)*2+abs(rval);
         t=abs(lval)+2*abs(rval);
         ans=min(ans,min(s,t));
      }
      left++;
      right++;
   }
   cout<<ans<<endl;
}

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

#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i = 0; i < (n); i++)
#define PB push_back
#define ALL(c) c.begin(),c.end()
#define LLINF 1000000000000000000LL

using namespace std;
typedef long long ll;

ll lrev[120000], rrev[120000];
int main()
{
  int N, K;
  cin >> N >> K;
  vector<ll> l, r;

  r.PB(0);
  REP(i, N) {
    ll x; cin >> x;
    if (x > 0) r.PB(x);
    else l.PB(x);
  }
  l.PB(0);
  reverse(ALL(l));

  REP(i, 110000) lrev[i + 1] = rrev[i + 1] = LLINF;
  REP(i, l.size()) lrev[i + 1] = 2*l[i]
  REP(i, r.size()) rrev[i + 1] = 2*r[i]

  ll ans = LLINF;
  REP(i, l.size()) {
    if (i > K) break;
    if (rrev[K - i] != LLINF) ans = min(ans, l[i] + rrev[K - i]);
  }
  REP(i, r.size()) {
    if (i > K) break;
    if (lrev[K - i] != LLINF) ans = min(ans, r[i] + lrev[K - i]);
  }

  cout << ans << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:40: error: expected ';' before 'for'
   29 |   REP(i, l.size()) lrev[i + 1] = 2*l[i]
      |                                        ^
      |                                        ;
a.cc:30:7: error: 'i' was not declared in this scope
   30 |   REP(i, r.size()) rrev[i + 1] = 2*r[i]
      |       ^
a.cc:4:33: note: in definition of macro 'REP'
    4 | #define REP(i,n) for(int i = 0; i < (n); i++)
      |                                 ^
a.cc:35:31: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |     if (rrev[K - i] != LLINF) ans = min(ans, l[i] + rrev[K - i]);
      |                               ^~~
      |                               abs
a.cc:39:31: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |     if (lrev[K - i] != LLINF) ans = min(ans, r[i] + lrev[K - i]);
      |                               ^~~
      |                               abs
a.cc:42:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C

#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a,b)  ((a) > (b) ? (a) : (b))
#include <stdlib.h>
int main(){
  int i,n,k,m;
  long long x[100000000];
  scanf("%d%d",&n,&k);

  for(i=0;i<k;i++){
    scanf("%d", &x[i]);
    if(x[i]<=0){
      m=i;                 //x[m]まで0以下                                                                                                  
    }
  }

  long long sum1[1000000000],sum2[1000000000],saishou=1000000000000;

  for(i=max((k-m-1),0);i<=m;i++){
    for(int j=i;j<=i+k-1;j++){
      if(j<m){
        sum1[i]+=2*abs(x[j]);
        sum2[i]+=abs(x[j]);
      }else{
        sum1[i]+=x[j];
        sum2[i]+=2*x[j];
      }
    }
    if(min(sum1[i],sum2[i])<saishou){
      saishou=min(sum1[i],sum2[i]);
           }
       }
  }

printf("%lld",saishou);
}


Compiler output:
main.c:35:8: error: expected declaration specifiers or '...' before string constant
   35 | printf("%lld",saishou);
      |        ^~~~~~
main.c:35:15: error: unknown type name 'saishou'
   35 | printf("%lld",saishou);
      |               ^~~~~~~
main.c:36:1: error: expected identifier or '(' before '}' token
   36 | }
      | ^
Language: C

#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a,b)  ((a) > (b) ? (a) : (b))
#include <stdlib.h>
int main(){
  int i,n,k,m;
  long long x[100000000];
  scanf("%d%d",&n,&k);

  for(i=0;i<k;i++){
    scanf("%d", &x[i]);
    if(x[i]<=0){
      m=i;                 //x[m]まで0以下                                                                                                  
    }
  }

  long long sum1[1000000000]=0,sum2[1000000000]=0,saishou=1000000000000;

  for(i=max((k-m-1),0);i<=m;i++){
    for(int j=i;j<=i+k-1;j++){
      if(j<m){
        sum1[i]+=2*abs(x[j]);
        sum2[i]+=abs(x[j]);
      }else{
        sum1[i]+=x[j];
        sum2[i]+=2*x[j];
      }
    }
    if(min(sum1[i],sum2[i])<saishou){
      saishou=min(sum1[i],sum2[i]);
           }
       }
  }

printf("%lld",saishou);
}
  
  
  
  
  
  
  
  
  
  
  
  
  


Compiler output:
main.c: In function 'main':
main.c:17:30: error: invalid initializer
   17 |   long long sum1[1000000000]=0,sum2[1000000000]=0,saishou=1000000000000;
      |                              ^
main.c:17:49: error: invalid initializer
   17 |   long long sum1[1000000000]=0,sum2[1000000000]=0,saishou=1000000000000;
      |                                                 ^
main.c: At top level:
main.c:35:8: error: expected declaration specifiers or '...' before string constant
   35 | printf("%lld",saishou);
      |        ^~~~~~
main.c:35:15: error: unknown type name 'saishou'
   35 | printf("%lld",saishou);
      |               ^~~~~~~
main.c:36:1: error: expected identifier or '(' before '}' token
   36 | }
      | ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#define R register
using namespace std;
int n,k,p[100005];
long long ans=1e14+1,ans2,dx;
inline int ri(){
	char c=getchar();int x=0,w=1;
	while(!isdigit(c)){if(c=='-')w=-1;c=getchar();}
	while( isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*w;
}
int main(){
	n=ri(); k=ri();
	for(R int i=1;i<=n;i++){ 
		p[i]=ri(); 
		if(p[i-1]<=0&&p[i]>0)dx=i-1;
		//if(!p[i])k--; 
		//if(!k){printf("0");return 0;}
	}
	
	if()
	for(R int k1=0;k1<=dx;k1++){//k1向左几步 
		int k2=k-k1;//k2向右 
		if(k2>n-dx)continue;
		else{
			if(k1!=0)ans2+=abs(p[dx-k1+1]);
			if(k2!=0){ ans2*=2; ans2+=p[dx+k2]; }
		}
		ans=min(ans,ans2); ans2=0;
	}
	for(R int k1=0;k1<=n-dx;k1++){//k1向右几步
		int k2=k-k1;//k2向左
		if(k2>dx)continue;
		else{
			if(k1!=0)ans2+=p[dx+k1];
			if(k2!=0){ ans2*=2; ans2+=abs(p[dx-k2+1]); }
		} 
		ans=min(ans,ans2);ans2=0;
	} 
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   16 |         for(R int i=1;i<=n;i++){
      |                   ^
a.cc:23:12: error: expected primary-expression before ')' token
   23 |         if()
      |            ^
a.cc:24:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |         for(R int k1=0;k1<=dx;k1++){//k1向左几步
      |                   ^~
a.cc:33:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |         for(R int k1=0;k1<=n-dx;k1++){//k1向右几步
      |                   ^~
Language: C++

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

int main()
{
	int N, K, x[100000], i, j, dis, min_dis = INT_MAX;
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++)
		scanf("%d", x+i);

	for (i = 0; x[i] < 0; i++);
	const int pmin = i;
	const int right = min(N-K, pmin);
	const int left = max(pmin-K, 0);

	for (i = left; i <= right; i++)
	{
		if (i+K-1 < pmin)
			dis = -x[i];
		else if (i >= pmin)
			dis = x[i+K-1];
		else
			dis = -x[i] + x[i+K-1] + min(-x[i], x[i+K-1]);

		min_dis = min(dis, min_dis);
	}

	printf("%d\n", min_dis);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:51: error: 'INT_MAX' was not declared in this scope
    7 |         int N, K, x[100000], i, j, dis, min_dis = INT_MAX;
      |                                                   ^~~~~~~
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;
Language: Java

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.Arrays;

public class solution {
	static int n, k;
	static int[][] axis;	
	public static int res(int k) {
		int re = -1, cont = 0;
		int tem = 0, tn = 0;
		for (int i = 0; i < axis.length; i++) {
			if (axis[i][0] >= 0) {
				axis[i][1] = axis[i][0];
				tem = i + 1;
				axis[i - 1][1] = Math.abs(axis[i - 1][0]);
				tn = i - 2;
				break;
			}

		}
		for (int i = tem; i < axis.length; i++) {
			axis[i][1] = axis[i][0] - axis[i - 1][0];
		}
		for (int i = tn; i >= 0; i--) {
			axis[i][1] = axis[i + 1][0] - axis[i][0];
		}
		Set<Integer> set = new TreeSet<Integer>();
		int left = tem - 1, right = tem - 2;
		char lf = 'f', rg = 'f';
		int s = getplace(left, right);

		while (s != -1) {
			if (left < 0 || right > axis.length) {
				break;
			}
			set.add(axis[s][0]);		
			cont++;
			for (int i = s; i >= 0; i--) {
				lf = 'f';
				if (axis[i][2] == 0) {
					left = i;
					lf = 't';
					break;
				}

			}

			if ((lf != 't') && (right < axis.length)) {
				left = right;				
			}

			for (int i = s; i < axis.length; i++) {
				rg = 'f';
				if (axis[i][2] == 0) {
					right = i;
					rg = 't';
					break;
				}

			}
			if ((rg != 't') && (left >= 0)) {
				right = left;				
			}

			s = getplace(left, right);

			if (cont >= k) {
				break;
			}

		}

		Integer[] arry = set.toArray(new Integer[0]);
		Arrays.sort(arry);
		int len = arry.length;

		set.clear();
		re = Math.max(Math.abs(arry[0]), Math.abs(arry[len - 1]))
				+ 2 * Math.min(Math.abs(arry[0]), Math.abs(arry[len - 1]));
		return re;
	}

	public static int getplace(int a, int b) {
		int re = -1;
		if ((a >= 0) && (b < axis.length)) {
			int comp = Math.min(axis[a][1], axis[b][1]);			
			if (comp == axis[a][1]) {
				axis[a][2] = 1;
				re = a;
			} else {
				axis[b][2] = 1;
				re = b;
			}
		} else if (a < 0 && b < axis.length) {
			re = b;
			axis[b][2] = 1;
		} else if (b > axis.length && a >= 0) {
		}
		return re;

	}

	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);		
			n = sc.nextInt();
			k = sc.nextInt();			
			axis = new int[n][3];
			for (int i = 0; i < n; i++) {
				axis[i][0] = sc.nextInt();				
				axis[i][2] = 0;
			}
			
			int len = axis.length;
			if (n == 0) {
				System.out.println("0");
			} else if ((n == 1 && k == 1) & axis[0][0] == 0) {
				System.out.println("0");
			} else if (axis[0][0] >= 0) {
				System.out.println(axis[k - 1][0]);
			} else if (axis[len - 1][0] <= 0) {
				System.out.println(Math.abs(axis[len - k][0]));
			} else {
				System.out.println(res(k));

			}

		}	

}


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

import java.util.Scanner;
public class Main6 {
    static int N,K;
    static int[] arrInput;
    static int dis = Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		arrInput = new int[N];
		int insertIndex=0;
		for(int i=0;i<N;i++){
			arrInput[i] = sc.nextInt();
			if(0>arrInput[i]){
				insertIndex++;
			}
		}
		int minIndex = -1;
		int maxIndex = -1;
		if(insertIndex-K<0 && insertIndex+K>N-1){
			minIndex = 0;
			maxIndex = N-1;
		}
		if(insertIndex-K<0 && insertIndex+K<=N-1){
			minIndex = 0;
			maxIndex = insertIndex +K;
		}
		if(insertIndex-K>=0 && insertIndex+K>N-1){
			minIndex = insertIndex-K;
			maxIndex = N-1;
		}
		if(insertIndex-K>=0 && insertIndex+K<=N-1){
			minIndex = insertIndex-K;
			maxIndex = insertIndex+K;
		}
		
		int minVal = Math.abs(0-arrInput[0]);
		int maxVal =  Math.abs(0-arrInput[0]);
		for(int i=minIndex;i<=maxIndex;i++){
			if(Math.abs(0-arrInput[i])<minVal){
				minVal = Math.abs(arrInput[i]);
			}
			if(Math.abs(0-arrInput[i])>maxVal){
				maxVal = arrInput[i];
			}
		}
		System.out.println("minVal: "+minVal + " maxVal: "+maxVal);
		dis= maxVal-minVal;
		System.out.println(dis);
	}
}

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

package match;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.Arrays;

public class Candle1 {
	static int n, k;
	static int[][] axis;	
	public static int res(int k) {
		int re = -1, cont = 0;
		int tem = 0, tn = 0;
		for (int i = 0; i < axis.length; i++) {
			if (axis[i][0] >= 0) {
				axis[i][1] = axis[i][0];
				tem = i + 1;
				axis[i - 1][1] = Math.abs(axis[i - 1][0]);
				tn = i - 2;
				break;
			}

		}
		for (int i = tem; i < axis.length; i++) {
			axis[i][1] = axis[i][0] - axis[i - 1][0];
		}
		for (int i = tn; i >= 0; i--) {
			axis[i][1] = axis[i + 1][0] - axis[i][0];
		}
		Set<Integer> set = new TreeSet<Integer>();
		int left = tem - 1, right = tem - 2;
		char lf = 'f', rg = 'f';
		int s = getplace(left, right);

		while (s != -1) {
			if (left < 0 || right > axis.length) {
				break;
			}
			set.add(axis[s][0]);		
			cont++;
			for (int i = s; i >= 0; i--) {
				lf = 'f';
				if (axis[i][2] == 0) {
					left = i;
					lf = 't';
					break;
				}

			}

			if ((lf != 't') && (right < axis.length)) {
				left = right;				
			}

			for (int i = s; i < axis.length; i++) {
				rg = 'f';
				if (axis[i][2] == 0) {
					right = i;
					rg = 't';
					break;
				}

			}
			if ((rg != 't') && (left >= 0)) {
				right = left;				
			}

			s = getplace(left, right);

			if (cont >= k) {
				break;
			}

		}

		Integer[] arry = set.toArray(new Integer[0]);
		Arrays.sort(arry);
		int len = arry.length;

		set.clear();
		re = Math.max(Math.abs(arry[0]), Math.abs(arry[len - 1]))
				+ 2 * Math.min(Math.abs(arry[0]), Math.abs(arry[len - 1]));
		return re;
	}

	public static int getplace(int a, int b) {
		int re = -1;
		if ((a >= 0) && (b < axis.length)) {
			int comp = Math.min(axis[a][1], axis[b][1]);			
			if (comp == axis[a][1]) {
				axis[a][2] = 1;
				re = a;
			} else {
				axis[b][2] = 1;
				re = b;
			}
		} else if (a < 0 && b < axis.length) {
			re = b;
			axis[b][2] = 1;
		} else if (b > axis.length && a >= 0) {
		}
		return re;

	}

	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);		
			n = sc.nextInt();
			k = sc.nextInt();			
			axis = new int[n][3];
			for (int i = 0; i < n; i++) {
				axis[i][0] = sc.nextInt();				
				axis[i][2] = 0;
			}
			
			int len = axis.length;
			if (n == 0) {
				System.out.println("0");
			} else if ((n == 1 && k == 1) & axis[0][0] == 0) {
				System.out.println("0");
			} else if (axis[0][0] >= 0) {
				System.out.println(axis[k - 1][0]);
			} else if (axis[len - 1][0] <= 0) {
				System.out.println(Math.abs(axis[len - k][0]));
			} else {
				System.out.println(res(k));

			}

		}	

}


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

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

public class Solution {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String str = bf.readLine();
		String[] str1 = str.split(" ");
		int N = Integer.parseInt(str1[0]);
		int K = Integer.parseInt(str1[1]);
		str = bf.readLine();
		str1 = str.split(" ");
		int[] data = new int[N];

		int res = 0;
		int start = Integer.parseInt(str1[0]);
		int end = Integer.parseInt(str1[N - 1]);
		if (start >= 0) {
			res = Integer.parseInt(str1[K - 1]);
			System.out.println(res);
			return;
		}
		if (end <= 0) {
			res = Integer.parseInt(str1[N - K]);
			System.out.println(Math.abs(res));
			return;
		}

		end = Integer.parseInt(str1[K - 1]);
		int sum = Math.abs(end - start) + Math.abs(start);
		int tmpSum = 0;
		for (int i = 0; i < N; i++) {
			end = Integer.parseInt(str1[i]);
			data[i] = end;
			if (i >= K) {
				start = data[i - K + 1];
				tmpSum = Math.abs(end - start) + Math.abs(start);
				if (tmpSum < sum) {
					sum = tmpSum;
				}
			}
		}

		System.out.println(sum);
		return;
	}
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main3{

    static int N;
    static int K;

    static int b[];

    static List<Integer> num;
    static int sum1;

    public static void main(String args[]) throws Exception {
      
        Scanner sc = new Scanner(System.in);
        N= sc.nextInt();
        K= sc.nextInt();
        num = new ArrayList<>();
        boolean bool  = true;
        for (int i = 0; i < N; i++) {

            num.add(sc.nextInt());

        }

        for (int i = 0; i < num.size(); i++) {
            if (num.get(i) == 0){
                bool = false;
            }
        }
        if (bool){ //说明里面没有0.0的蜡烛

            num.add(0);
            Collections.sort(num);

            int index=0;
            for (int i = 0; i < num.size(); i++) {
                if (num.get(i) == 0){
                    index = i;
                }
            }
            if (index == 0){
                System.out.println(Math.abs(num.get(K)));
            }else if (index == num.size()-1){
                System.out.println(Math.abs(num.get(index-K)));
            }else{
                if (index >= K){
                    sum1=Math.abs(num.get(index-K));
                    getMin(index,index-K,K+1,sum1,sum1);
                }else{
                    sum1=Math.abs(num.get(0))*2 + Math.abs(num.get(K));
                    getMin(index,1,K+1,sum1,sum1);
                }
            }
        }else{
            int index=0;
            for (int i = 0; i < num.size(); i++) {
                if (num.get(i) == 0){
                    index = i;
                }
            }
            if (index == 0){
                System.out.println(Math.abs(num.get(K-1)));
            }else if (index == num.size()-1){
                System.out.println(Math.abs(num.get(index-(K-1))));
            }else{
                if (index >= K-1){
                    sum1=Math.abs(num.get(index-(K-1)));
                    getMin(index,Math.abs(index-K),K+1,sum1,sum1);
                }else{
                    sum1=Math.abs(num.get(0))*2 + Math.abs(num.get(K-1));
                    getMin(index,1,K+1,sum1,sum1);
                }
            }
        }

    }
    public static int getOne(int index,int start,int end){
        if (index > start){
            return  Math.abs(num.get(start))*2 + Math.abs(num.get(end));
        }else{
            return Math.abs(num.get(end));
        }

    }
    public static void getMin(int index,int start,int end,int sumNew,int  sumOld){

        if (sumNew > sumOld || sumOld==0){
            System.out.println(sumOld);
        }else {
            int sum2 = getOne(index,start,end);
            if (end+1 < num.size()){
                getMin(index,start+1,end+1,sum2,sumNew);
            }
        }
    }

}

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

import java.io.FileInputStream;
import java.util.Scanner;
public class Main{
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] candles = new int[N];
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
        
        int temp = 0, time = Integer.MAX_VALUE;

        for(int i = 0; i < N - K; i++){
                int j = i+K-1;
                temp = Math.min(Math.abs(candles[i]), Math.abs(candles[j])) + candles[j] - candles[i];
                time = time < temp ? time : temp;
        }
         if(N - K == 0) time = candles[N-1] - candles[0];
         System.out.println(time); 
}

Compiler output:
Main.java:8: error: illegal start of type
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
        ^
Main.java:8: error: > or ',' expected
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
                            ^
Main.java:8: error: <identifier> expected
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
                               ^
Main.java:8: error: ']' expected
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
                                            ^
Main.java:8: error: ';' expected
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
                                             ^
Main.java:8: error: <identifier> expected
        for(int i = 0; i < N; i++)  candles[i] = sc.nextInt();
                                                           ^
Main.java:12: error: illegal start of type
        for(int i = 0; i < N - K; i++){
        ^
Main.java:12: error: > or ',' expected
        for(int i = 0; i < N - K; i++){
                             ^
Main.java:12: error: <identifier> expected
        for(int i = 0; i < N - K; i++){
                                ^
Main.java:12: error: <identifier> expected
        for(int i = 0; i < N - K; i++){
                                   ^
Main.java:17: error: illegal start of type
         if(N - K == 0) time = candles[N-1] - candles[0];
         ^
Main.java:17: error: <identifier> expected
         if(N - K == 0) time = candles[N-1] - candles[0];
             ^
Main.java:17: error: <identifier> expected
         if(N - K == 0) time = candles[N-1] - candles[0];
                 ^
Main.java:17: error: <identifier> expected
         if(N - K == 0) time = candles[N-1] - candles[0];
                            ^
Main.java:18: error: <identifier> expected
         System.out.println(time); 
                           ^
Main.java:18: error: <identifier> expected
         System.out.println(time); 
                                ^
16 errors
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	static int N;
	static int K;
	static int[] arry;
	static int Answer = 99999999;
	static boolean status = false;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
			N = sc.nextInt();
			K = sc.nextInt();
			arry = new int[N];
			for (int i = 0; i < N; i++) {
				int a = sc.nextInt();
				if(a==0) {
					status=true;
				}
				arry[i] = a;
			}
			Lazhu.cal(arry,K);
			System.out.println(Answer);
		}
	 public static int cal(int[] chars, int n) {
	        if (n <= 0 || chars == null) {
	            return Answer;
	        }
	        List<Integer> charList = new ArrayList<>();
	        for (int i = 0; i < n; i++) {
	            charList.add(-1);
	        }
	        return listAll(charList, chars, n);
	    }

	 public static int listAll(List<Integer> list, int[] chars, int n) {
	        if (n == 0) {
	        	if(!status) {
	        		list.add(0);
	        	}
	        	int temp = 0;
	        	for (int i = 1; i < list.size(); i++) {
					if(list.get(i)>=list.get(i-1)) {
						temp+=list.get(i)-list.get(i-1);
					}else {
						temp+=list.get(i-1)-list.get(i);
					}
				}
	        	if(Answer>=temp) {
	        		Answer = temp;
	        	}
	        	if(!status) {
	        		 for (int i = 0; i < list.size(); i++) {
	        			 if(list.get(i)==0) {
	        				 list.remove(i);
	        			 }
	        		 }
	        	}
	            return Answer;
	        }
	        for (int aChar : chars) {                     
	            if (!list.contains(aChar)) {                
	                list.set(list.size() - n, aChar);       
	            } else {                                    
	                continue;
	            }
	            listAll(list, chars, n - 1);               
	            list.set(list.size() - n, -1);            
	        }
			return Answer;
	    }
}


Compiler output:
Main.java:24: error: cannot find symbol
			Lazhu.cal(arry,K);
			^
  symbol:   variable Lazhu
  location: class Main
1 error
Language: Java


public class Main{
	
	private static int N=(int)Math.pow(10, 5);
	private static int n,k;
	private static long[] a;
	private static long ans=(int)Math.pow(10, 5)*2;
	
	public static void main(String args[])
	{
		Scanner sc =new Scanner(System.in);
		n=sc.nextInt();
		k=sc.nextInt();
		a=new long[N+5];
		for(int i=1;i<=n;i++)
		{
			a[i]=sc.nextLong();
		}
	     for(int i=1;i+k-1<=n;i++)
	    {  
	        int l=i,r=i+k-1;
	        ans=Math.min(ans,a[r]-a[l]+Math.min(Math.abs(a[l]),Math.abs(a[r])));
	    }
		System.out.println(ans);
	}

}


Compiler output:
Main.java:11: error: cannot find symbol
		Scanner sc =new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:11: error: cannot find symbol
		Scanner sc =new Scanner(System.in);
		                ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

ct Code

import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String nextLine = sc.nextLine();
		int N = Integer.valueOf(nextLine.split("\\s+")[0]);
		int K = Integer.valueOf(nextLine.split("\\s+")[1]);
		nextLine = sc.nextLine();
		System.out.println(cal(nextLine.split("\\s+"), K));
	}

	private static int cal(String[] strings, int k) {
		int size = strings.length;
		int min = Integer.valueOf(strings[0]);
		int max = Integer.valueOf(strings[size - 1]);
		if (max <= 0) {
			return -Integer.valueOf(strings[size - k]);
		} else if (min >= 0) {
			return Integer.valueOf(strings[k - 1]);
		}
		int result = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < size; i++) {
			int j = i + k - 1;
			min = Integer.valueOf(strings[i]);
			max = Integer.valueOf(strings[j]);
			int temp = countResult(min, max);
			if (result > temp)
				result = temp;
			if (min > 0)
				break;
		}
		return result;
	}

	private static int countResult(int min, int max) {
		if (max <= 0) {
			return -min;
		} else if (min >= 0) {
			return max;
		} else {
			return Math.min(-2 * min + max, -min + 2 * max);
		}
	}
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
ct Code
^
1 error
Language: Java

package suanfa;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class candle {
    static int N, K;
    static LinkedList<Integer> positive;
    static Stack<Integer> negative;
    static int num = 0;

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inStr = br.readLine().split(" ");
        N = Integer.parseInt(inStr[0]);
        K = Integer.parseInt(inStr[1]);
        positive = new LinkedList<>();
        negative = new Stack<>();
        inStr = br.readLine().split(" ");
        int input;
        for (int i = 0; i < N; i++) {
            input = Integer.parseInt(inStr[i]);
            if (input > 0) {
                positive.add(input);
            } else {
                negative.push(-1 * input);
            }
        }
//        while (!positive.isEmpty()){
//            System.out.print(positive.poll() + " ");
//        }
//        System.out.println();
//        while (!negative.isEmpty()){
//            System.out.print(negative.pop() + " ");
//        }
        if (negative.isEmpty() || positive.isEmpty()) {
            if (negative.isEmpty() && positive.isEmpty()) {
                num = 0;
            } else {
                num = negative.isEmpty() ? positive.get(K - 1) : negative.get(K - 1);
            }
            System.out.println(num);
            return;
        }
//        int n = 0, p = 0;
//        while (n + p <= K) {
//            for (int i = 0; i < K; i++) {
//
//            }
//        }
        int left = negative.peek();
        int right = positive.peek();
        if (left == right) {

        }
    }
}
//5 3
//-30 -10 10 20 50
//40
//-------------
//3 2
//10 20 30
//20
//--------------
//1 1
//0
//0
//--------------
//8 5
//-9 -7 -4 -3 1 2 3 4
//10


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

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Candle {
	static boolean[] visited ;
	static int[] point;
	static int stepNum;
	static int result = Integer.MAX_VALUE; 
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		stepNum = sc.nextInt();
		point = new int[num+1];
		boolean flag = true;
		int start = -1;
		
		visited = new boolean[point.length];
		
		for(int i = 0 ; i < point.length; i++){
			int temp = sc.nextInt();
			if(temp >= 0 && flag){
				point[i] = 0;
				start = i;
				i++;
				flag = false;
			}
			point[i] = temp;
		}
		visited[start] = true;
		
		findMinDis(0,start,0);
		System.out.println(result);
	}
	
	public static void findMinDis(int dist, int start, int step) {
		
		List<Integer> adj = findAdj(start);
		
		if(step == stepNum) {
			if (result > dist) {
				result = dist;
			}
			return;
		}
		
		for(int i = 0; i < adj.size(); i++){
			dist +=  Math.abs(adj.get(i)-point[start]);
			step++;
			int index = findIndex(adj.get(i));
			visited[index] = true;
			findMinDis(dist, index, step);
			dist -=  Math.abs(adj.get(i)-point[start]);
			step--;
			visited[index] = false;
		}
		
	}
	
	public static List<Integer> findAdj(int Strat) {
		List<Integer> list = new ArrayList<Integer>();
		for(int j = Strat-1; j >= 0 ; j--){
			if(!visited[j]){
				list.add(point[j]);
				break;
			}
		}
		for(int j = Strat+1; j < point.length ; j++){
			if(!visited[j]){
				list.add(point[j]);
				break;
			}
		}
		return list;
	}
	
	public static int findIndex(int val){
		int flag = 1;
		for(int i = 0; i < point.length; i++) {
			if(val == point[i]) {
				return i;
			}
			if(point[i] == 0){
				flag++;
			}
			if(val == 0 && point[i] == 0 && flag == 2){
				return i+1;
			}
		}
		return -1;
	}
	
}


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

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
   
    public static Integer listAll(List<Integer> list, Integer[] intArr, int n, Integer minVal) {
        if (n == 0) {
            int temMinValue = Math.abs(list.get(0)-0);
            for(int i = 1; i<list.size(); i++) {
            	temMinValue += Math.abs(list.get(i)-list.get(i-1));
            }
            if(minVal == null || minVal > temMinValue) {
            	minVal = temMinValue;
            }
            return minVal;
        }
        for (Integer integer : intArr) {                    
            if (!list.contains(integer)) { 
                list.set(list.size() - n, integer);
            } else {                                
                continue;
            }
            minVal =listAll(list, intArr, n - 1, minVal);   
            list.set(list.size() - n, -99999999);        
        }
        return minVal;
    }

    public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
        Integer[] numbers = new Integer[N];
		for(int i = 0; i < N; i ++) {
			numbers[i] = in.nextInt();
		}
        Main.jisuan(numbers, M);

        if (M <= 0 || numbers == null) {
            return;
        }
        List<Integer> stringList = new ArrayList<>();
        for (int i = 0; i < M; i++) {
            stringList.add(-99999999);
        }
        Integer minVal = null;
        int resultValue = listAll(stringList, numbers, M, minVal);
        System.out.println(resultValue);
    }
}

Compiler output:
Main.java:39: error: cannot find symbol
        Main.jisuan(numbers, M);
            ^
  symbol:   method jisuan(Integer[],int)
  location: class Main
1 error