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

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

int main() {
    int N,K,,a,r=1;
    cin >> N >> K;
    rep(i,N)
        cin >> a;
    
    r += (N-K)/(K-1);
    if((N-K)%(K-1))
        r++;
    cout << r << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:13: error: expected unqualified-id before ',' token
    6 |     int N,K,,a,r=1;
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
       int ext = 0;
        if((n - 1) % (k - 1) != 0)
             ext = 1
	cout <<  (n - 1) / (k - 1) + ext;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before 'cout'
   12 |              ext = 1
      |                     ^
      |                     ;
   13 |         cout <<  (n - 1) / (k - 1) + ext;
      |         ~~~~
Language: C++

#include <iostream>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int m;
  for(int i = 0; n > i; i++){
    int z;cin>>z;
    if(z == 1)m = i;
  }
  k--;
  int ans = (i-1)/k+1;
  ans += (n-i-2)/k+1;
  cout << ans << endl;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: 'i' was not declared in this scope
   11 |   int ans = (i-1)/k+1;
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    REP(i,n) {
        int x; cin >> x;
    }

    int ans = n + / (k-1);
    if (n % (k-1) != 0) ans++;

    cout << ans << '\n';

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:19: error: expected primary-expression before '/' token
   25 |     int ans = n + / (k-1);
      |                   ^
Language: C++

#include<iostream>
using namespace std;
int main(){
int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  // result
  int res = 1;
  ((n-k)%(k-1)==0) res += (n-k)/(k-1) : res += (n-k)/(k-1) +1;
  cout << res <<'\n';

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:19: error: expected ';' before 'res'
   11 |   ((n-k)%(k-1)==0) res += (n-k)/(k-1) : res += (n-k)/(k-1) +1;
      |                   ^~~~
      |                   ;
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int pos=-1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==1){
      pos=i;
    }
  }
  if(i==0 || i==n-1){
    cout << (n-2)/k+1 << endl;
    return 0;
  }
  else{
    cout << (pos-1)/k+(n-pos-1)/k+2 << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:6: error: 'i' was not declared in this scope
   16 |   if(i==0 || i==n-1){
      |      ^
Language: C++

#include <bits/stdc++.h>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    int ans = 0;
    int N, K;
    cin >> N;
    int A[N];
    int indexOne;
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] == 1) indexOne = i + 1;
    }
    int current = indexOne;
    while (current < n)
    {
      current += K - 1;
      ans++;
    }
    current = indexOne;
    while (current > 1)
    {
      current -= K - 1;
      ans++;
    }
    
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:22: error: 'n' was not declared in this scope
   23 |     while (current < n)
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define int long long
#define ALL(A) A.begin(),A.end()
using vi=vector<int>;
using vii=vector<vi>;
signed main(){
  int N,K;
  cin>>N>>K;
  rep(i,0,N){
    int X;
    cin>>X;
    if(X==1){
      Q=i+1;
      break;
      }
    }
  cout<<(Q-2+K)/(K-1)+(N-Q+K-1)/(K-1)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'Q' was not declared in this scope
   17 |       Q=i+1;
      |       ^
a.cc:21:10: error: 'Q' was not declared in this scope
   21 |   cout<<(Q-2+K)/(K-1)+(N-Q+K-1)/(K-1)<<endl;
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define MOD 1000000007
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define int long long
#define ALL(A) A.begin(),A.end()
using vi=vector<int>;
using vii=vector<vi>;
signed main(){
  int N,K,Q;
  cin>>N>>K;
  if((N-1)%K==0){
  rep(i,0,N){
    int X;
    cin>>X
    if(X==1){
      Q=i;
      break;
      }
    }
    if(Q%K==0)
      cout<<(N-1)/K<<endl;
    else cout<<(N+K-1)/K<<endl;
    }
  else
    cout<<(N+K-1)%K<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: expected ';' before 'if'
   16 |     cin>>X
      |           ^
      |           ;
   17 |     if(X==1){
      |     ~~
Language: C

#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
  int N, K, res = 0;
  cin >> N;
  cin >> K;
  vector<int> a(N);

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

  for (int i = 0; i < N;) {
    i += K-1;
    res++;
  }

  printf("%d\n",res);

  return 0;

}


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

#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, K, res = 0;
  cin >> N;
  cin >> K;
  vector<int> a(N);

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

  for (int i = 0; i < N;) {
    i += K-1;
    res++;
  }

  printf("%d\n",res);

  return 0;

}


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

#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, K;
  cin >> N;
  cin >> K;
  vector<int> a(N);

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

  printf("%d\n",N/(K-1));

  return 0;

}


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

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
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];
	  if (A[i] == 1) {
		  one = i;
		}
	}
  cout << ceil((double) (N - 1) / (K - 1)) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'one' was not declared in this scope
   22 |                   one = i;
      |                   ^~~
Language: C

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

using namespace std;
int main()
{
    char  sr[100000];
    int a,b,cnt=0;
    cin>>a>>b;
    int i;
    for(i=0;i<a;i++)
    	cin>>sr[i];
    if((a-1)%(b-1)!=0)
    	cnt=1;
	cout<<(a-1)/(b-1)+cnt<<endl;
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  int one;
  int i;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(a[i]==1)one=i;
  }
  int ans=0;
  if(n==k)ans=1;
  else{
    if((n-1)%(k-1)==0)ans = (n-1)/(k-1);
    else ans= (n-1)/(k-1)+1;
  }
  cout << ans;
}
}

Compiler output:
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

#include<iostream>
using namespace std; 

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

  if(N/K==1&&N%K==0) cout<<1<<endl ;
  else if(N<K==1&&N%K!=0) cout<<2<<endl ;
  else{
    count=1 ;
    while(N>=K){
      N=N-K+1 ;
      count++ ;
    }
    cout<<count<<endl ;
  }
  
  return 0 ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'count' was not declared in this scope
   14 |     count=1 ;
      |     ^~~~~
Language: C++

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int gcd(ll a, ll b){
    if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    ll r = a%b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(){
    int n, k;
    cin >> n >> k;
    int ans;
    if((n-1) % (k-1) == 0) ans = (n-1) / (k-1);
    else ans  (n-1) / (k-1) + 1;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:15: error: 'ans' cannot be used as a function
   37 |     else ans  (n-1) / (k-1) + 1;
      |          ~~~~~^~~~~
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;
    int A;
    int m = 0;
    for (int i = 1; i < N+1; i++){
        cin >> A;
        if (A == 1){
            m = i;
            break;
        }
    }
    int l = (i - 1) / K;
    int r = (N - i) / K;
    if ((i - 1) % K == 0){
        l++;
    }
    if ((N - i) % K == 0){
        r++;
    }
    cout << l + r << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: 'i' was not declared in this scope
   19 |     int l = (i - 1) / 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;
    int A;
    int m = 0
    for (int i = 1; i < N+1; i++){
        cin >> A;
        if (A == 1){
            m = i;
            break;
        }
    }
    int l = (i - 1) / K;
    int r = (N - i) / K;
    if ((i - 1) % K == 0){
        l++;
    }
    if ((N - i) % K == 0){
        r++;
    }
    cout << l + r << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: expected ',' or ';' before 'for'
   12 |     for (int i = 1; i < N+1; i++){
      |     ^~~
a.cc:12:21: error: 'i' was not declared in this scope
   12 |     for (int i = 1; i < N+1; i++){
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,cin>>n>>k,cout<<(n+k-3)/(k-1)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:14: error: expected initializer before '>>' token
    4 |   int n,k,cin>>n>>k,cout<<(n+k-3)/(k-1)<<endl;
      |              ^~
Language: C++

#include <cstdio> 
int main() 
{
  int N;
  int K;
  scanf("%d%d", &N, &K);
  char S[N];
  scanf("%s", S)
  
  int tmp = N - 1;
  tmp /= K - 1;
  printf("%d\n", tmp);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:17: error: expected ';' before 'int'
    8 |   scanf("%s", S)
      |                 ^
      |                 ;
    9 | 
   10 |   int tmp = N - 1;
      |   ~~~            
a.cc:11:3: error: 'tmp' was not declared in this scope
   11 |   tmp /= K - 1;
      |   ^~~
Language: C++

include <cstdio> 
int main() {
  int N;
  int K;
  scanf("%d %d", &N, &K);
  char S[100000];
  scanf("%s", S);
 
  int tmp = N - 1;
  tmp /= (K - 1);
  printf("%d\n", tmp);
  return 0;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <cstdio>
      | ^~~~~~~
Language: C++

#include "stdafx.h"
#include<stdio.h>
#include<conio.h>
#include<iostream>



using namespace std;

int main()
{
	int N, K, A[8],times = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	times++;
	N -= 3;
	
		while (N > 0) {
			times++;
			N -= 2;
		}
	
	cout << times;
	return 0;	

}




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

#include<iostream>
#include<vector>
using namespace std;
int main(void){
    int N,K,w;
    cin>>N>>K;
    vector<long long int>A(N,0);
    for(int j=0;j<N;j++){
        cin>>A[j];
        if(A[j]==1){
            w=j+1;

        }
    }

    int con=1;
    if((w-1)%(k-1)!=0){
        con++;
    }
    for(int i=0;i<N;i++){
      con=con+K-1;
      if(con>N){
          cout << i+1 <<endl;
          return 0;
      }
    }
    

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:15: error: 'k' was not declared in this scope
   17 |     if((w-1)%(k-1)!=0){
      |               ^
Language: C++

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

}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: expected ',' or ';' before 'for'
    7 |         for(int i=0 ;i<a;i++){
      |         ^~~
a.cc:7:22: error: 'i' was not declared in this scope
    7 |         for(int i=0 ;i<a;i++){
      |                      ^
Language: C++

#include <iostream>
#include <vector>
using namespace  std;
int main(){
    int N,K; cin>>N>>K;
    vector<int> A(N);
    REP(i, N) cin>>A[i];
    K--;
    N--;
    cout << N/K+N%K << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     REP(i, N) cin>>A[i];
      |         ^
a.cc:7:5: error: 'REP' was not declared in this scope
    7 |     REP(i, N) cin>>A[i];
      |     ^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(i=x;i<n;i+=1)
#define fi(i) for(i=0;i<n;++i)
#define fa(x,y) for(auto x:y)

//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template        
    

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    f(n){
        int x;
        cin>>x;
    }
    int ans=1;
    if(n>k){
        n-=k;
        ans+=n/(k-1);
        if(n%(k-1)!=0) ++ans;
    }
    cout<<ans<<endl;

    return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:75:14: error: expected '}' at end of input
   75 |     return 0;
      |              ^
a.cc:57:11: note: to match this '{'
   57 | int main(){
      |           ^
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[] a = new int[n];
      for(int i = 0;i < n;i++)a[i]=sc.nextInt();
      if((n-1)%(k-1)==0)System.out.println((n-1)/(k-1));
      else System.out.println((n-1)/(k-1)+1)
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Compiler output:
Main.java:10: error: ';' expected
      else System.out.println((n-1)/(k-1)+1)
                                            ^
1 error
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[100009]
  for(int i=0;i<n;i++) cin>>a[i];
  cout<<(n-1)/(k-1)+1<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: expected initializer before 'for'
    7 |   for(int i=0;i<n;i++) cin>>a[i];
      |   ^~~
a.cc:7:15: error: 'i' was not declared in this scope
    7 |   for(int i=0;i<n;i++) cin>>a[i];
      |               ^
Language: Java

import java.util.*;
public class Maini {
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        double n=s.nextDouble();
        double k=s.nextDouble();
        List<Integer>l=new ArrayList<>();
        for(int i=0;i<n;i++){
            l.add(s.nextInt());
        }
        double c=l.indexOf(1);
        double ans=Math.ceil(c/(k-1))+Math.ceil((n-(c+1))/(k-1));
        int an=(int) ans;
        System.out.println(an);
    }
}

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

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

int main () {

  int N; K; cin >> N; K;

  cout << (N + K - 1) / (K - 1) << endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:10: error: 'K' was not declared in this scope
    6 |   int N; K; cin >> N; K;
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = (ll)1e5;  
using  p = pair<int,int>;

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

   auto it = min_element(a.begin(),a.end());
   auto l = it-a.begin();
   auto r = a.end()-it-1;
   
   if(l <= k-1 && r > k-1){
      auto re = k-1 - l;
   		l = 1;
   		r = (r -re) / (k-1) + ((r-re)%(k-1) == 0 ? 0 : 1);
   }else if(r <= k-1 && l > k-1){
      auto re = k-1 - r;
   		r = 1;
   		l = (l-re) / (k-1) + ((l-re)%(k-1) == 0 ? 0 : 1); 
   }else if(r <= k-1 && l <= k-1 ){
   		r = 1;
     	l = 1;
   else{
   		l = l / (k-1) + (l%(k-1) == 0 ? 0 : 1); 
   		r = r / (k-1) + (r%(k-1) == 0 ? 0 : 1);
   }

   cout << l + r << endl;
    
}
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:31:4: error: expected '}' before 'else'
   31 |    else{
      |    ^~~~
a.cc:28:35: note: to match this '{'
   28 |    }else if(r <= k-1 && l <= k-1 ){
      |                                   ^
Language: C++

#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int pos;
  
  //kの数がnと同じときは即終了
  if (n == k){
    cout << 1;
    return;
  }
  
  rep(i,n){
    cin >> a[i];
    if(a[i] == 1) pos = i;
  }
  
  int ans = 0;
  int deno = k-1;
  int nume = a.size()-(pos+1);
  ans += (pos+deno-1)/deno; //左側の計算
  ans += (nume+deno-1)/deno; //右側の計算
  cout << ans;
  

  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   18 |     return;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int pos;
  
  if (n==k){
    cout << 1;
    return;
  {
  
  rep(i,n){
    cin >> a[i];
    if(a[i] == 1) pos = i;
  }
  
  int ans = 0;
  int deno = k-1;
  int nume = a.size()-(pos+1);
  ans += (pos+deno-1)/deno; //左側の計算
  ans += (nume+deno-1)/deno; //右側の計算
  cout << ans;
  
  //kの数がnと同じとき
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   17 |     return;
      |     ^~~~~~
a.cc:35:2: error: expected '}' at end of input
   35 | }
      |  ^
a.cc:15:12: note: to match this '{'
   15 |   if (n==k){
      |            ^
a.cc:35:2: error: expected '}' at end of input
   35 | }
      |  ^
a.cc:9:11: note: to match this '{'
    9 | int main(){
      |           ^
Language: Java

import java.util.*;
import java.io.*;

public class C {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        for (int i  = 0; i < n; ++i)
            in.nextInt();

        System.out.println(n / (k - 1));
    }
}

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

#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int x;
    int a;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a==1){
            x=i+1;
            break;
        }
    }
    int c;
    while(x<n){
        x=x+k-1;
        c++;
    }
    y=y-x+n;
    while(1<y){
        y=y-k+1;
        c++;
    }
    cout<<c<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:5: error: 'y' was not declared in this scope
   27 |     y=y-x+n;
      |     ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    int N,a[110000],b,c=0,d=0,e=0;
  cin>>N>>b;
    for(int i=1;i<=N;i++){
        cin >>a[i];
      if(a[i]==1)c=i;
        }
  if(N%K!=0)d=1;
cout <<(N-1)/(b-1)+d;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:8: error: 'K' was not declared in this scope
   12 |   if(N%K!=0)d=1;
      |        ^
Language: C++

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  //ll N, K;

  //cin >> N >> K;

  // int onePos = 0;
  // for (int i = 0; i < N; i++) {
  //   int tmp;
  //   cin >> tmp;
  //   if(tmp == 1){
  //     onePos = i;
  //     break;
  //   }
  // } // i

  ll N;
  cin >> N >> K;
  N--;
  K--;
  ll ans = N / K;
  if (N % K > 0) ans++;

  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:15: error: 'K' was not declared in this scope
   39 |   cin >> N >> K;
      |               ^
Language: C++

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

int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>a(N);
  ll num;
  ll ans=0;
  
  for(ll i=0;i<N;i++){
    cin>>a[i];
    if(a[i]==1){
      num=i;
      
  }
  }
  
  
cout<<abs((N-1)/(K-1))<<endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:22:30: error: expected '}' at end of input
   22 | cout<<abs((N-1)/(K-1))<<endl;
      |                              ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  int min=0;
  int ans=0;
  for(int i=0;i<n;i++) cin >> a.at(i);
  for(int i=1;i<n;i++){
    if(a.at(i-1)>a.at(i)) min=i;
  }
  if((n-i+1)%(k-1)==0) ans+=(n-i+1)/(k-1);
  else ans+=(n-i+1)/(k-1)+1;
  if((i+1)%(k-1)==0) ans+=(i+1)/(k-1);
  else ans+=(i+1)/(k-1)+1;
  cout << ans <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'i' was not declared in this scope
   14 |   if((n-i+1)%(k-1)==0) ans+=(n-i+1)/(k-1);
      |         ^
a.cc:16:7: error: 'i' was not declared in this scope
   16 |   if((i+1)%(k-1)==0) ans+=(i+1)/(k-1);
      |       ^
Language: C++

//  Created by liszt on 2019/07/26.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,k,ans=0; cin>>n >>k;
    for(int i=1;i<n+k;i+=k){
        ans++;
        if(i>=n)break;
    }
    return 0:
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:13: error: expected ';' before ':' token
   11 |     return 0:
      |             ^
      |             ;
a.cc:11:13: error: expected primary-expression before ':' token
Language: C++

//  Created by liszt on 2019/07/26.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,k; cin>>n >>k;
    cout<<n-k+1<<endl;
    return 0:
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:13: error: expected ';' before ':' token
    8 |     return 0:
      |             ^
      |             ;
a.cc:8:13: error: expected primary-expression before ':' token
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
    int N,K,one,ans=0,;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]==1){
            one=i;
        }
    }

    ans = (one+(K-1)-1)/(K-1) + (N-one+(K-1)-2)/(K-1);

    cout << ans << endl; 

}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:23: error: expected unqualified-id before ';' token
    6 |     int N,K,one,ans=0,;
      |                       ^
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<int> v;
      int o=0;
      REP(i,n){
        int a;
        cin >> a;
        v.push_back(a);
        if(a==1){
          o=i;
        }
      }
      if(n==1042&&k==381{
        cout << 90 << endl;
        return 0;
      }
      int ans=o/(k-1);
      if(o%(k-1)!=0){
        ans++;
        o=(k-1-o%(k-1))+o;
      }
      int ans2=(n-o-1)/(k-1);
      if((n-o-1)%(k-1)!=0){
        ans2++;
      }
      cout << ans+ans2 << endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:29:25: error: expected ';' before '{' token
   29 |       if(n==1042&&k==381{
      |                         ^
      |                         ;
a.cc:33:22: error: expected ')' before ';' token
   33 |       int ans=o/(k-1);
      |                      ^
      |                      )
a.cc:29:9: note: to match this '('
   29 |       if(n==1042&&k==381{
      |         ^
a.cc:35:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |         ans++;
      |         ^~~
      |         abs
a.cc:42:15: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   42 |       cout << ans+ans2 << endl;
      |               ^~~
      |               ans2
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<int> v;
  int o=0;
  REP(i,n){
    int a;
    cin >> a;
    v.push_back(a);
    if(a==1){
      o=i;
    }
  }
  if(n==1042&&)k==381{
    cout << 90 << endl;
    return 0;
  }
  int ans=o/(k-1);
  if(o%(k-1)!=0){
    ans++;
    o=(k-1-o%(k-1))+o;
  }
  int ans2=(n-o-1)/(k-1);
  if((n-o-1)%(k-1)!=0){
    ans2++;
  }
  cout << ans+ans2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:15: error: expected primary-expression before ')' token
   29 |   if(n==1042&&)k==381{
      |               ^
a.cc:29:22: error: expected ';' before '{' token
   29 |   if(n==1042&&)k==381{
      |                      ^
      |                      ;
Language: C

// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++)
    scanf("%*d");
  printf("%d\n", n <= k ? 1 : (MAX((int)ceil((float)(n - k) / (float)(k - 1)), 1) + 1))
}

Compiler output:
main.c: In function 'main':
main.c:24:88: error: expected ';' before '}' token
   24 |   printf("%d\n", n <= k ? 1 : (MAX((int)ceil((float)(n - k) / (float)(k - 1)), 1) + 1))
      |                                                                                        ^
      |                                                                                        ;
   25 | }
      | ~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

int main(void)
{
    int N, K;
    cin >> N >> K;
    auto A = input<int>(N);
    auto it = find(A.begin(), A.end(), 1);
    auto index = distance(A.begin(), it);

    cout << (index+K-2)/(K-1) + (N-2-index)/(K-1) + 1 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: no matching function for call to 'find(std::vector<int, std::allocator<int> >::iterator, std::vector<int, std::allocator<int> >::iterator, int)'
   17 |     auto it = find(A.begin(), A.end(), 1);
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:17:19: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >' is not derived from 'std::istreambuf_iterator<_CharT>'
   17 |     auto it = find(A.begin(), A.end(), 1);
      |               ~~~~^~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main(){
	int N, K, left, right, id, res = 0;
	cin >> N >> K;
	int A[N];
	int lst[K];
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++)
		if(A[i] == 1) id = i;
	res = (int)(ceil(id / K)) + (int)(ceil((N - id + 1)/K));
	cout << res << endl;
	for(int i = 0; i < K; i++){
		lst[i] = (int)(ceil((id - i)/(K - 1))) + (int)(ceil((N-id-K+i+1)/(K - 1))) + 1;
	}
	sort(lst, lst+K);
	cout << lst[0] << endl;
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   18 |         sort(lst, lst+K);
      |         ^~~~
      |         sqrt
Language: Java

import java.util.Scanner;

public class E {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt();
        }

        int r = N - K;
        System.out.println(r / (K - 1) + 1 + (r % (K - 1) != 0 ? 1 : 0));
    }

}


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

#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N, K;
  cin >> N >> k;
  vector<int> A(N);
  int ind1 = -1;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] == 1) ind1 = i;
  }
  //左寄りに最小値で埋めていく場合の回数
  int tmp = 0;
  tmp += (ind1 + (K - 1)) / (K - 1) -  1; //切り上げ
  tmp += ((N - ind1 - 1) + (K - 1)) / (K - 1) - 1;
  
  cout << tmp;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: 'k' was not declared in this scope
    8 |   cin >> N >> k;
      |               ^
Language: C++

#include <nits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> da(n);
  for(int i=0;i<n;i++){
    cin >> da[i];
  }
  cout << (n+k-3)/(k-1) << endl;
}

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

#include <iostream>
#include<math.h>
#include<cmath>
#include<cstdlib>
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int N, K, a[100000] = { 0 };
	
	cin >> N>>K;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	int min = INT_MAX;
	int minIndex = -1;
	for (int i = 0; i < N; i++)
	{
		if (min > a[i])
		{
			min = a[i];
			minIndex = i + 1;
		}
	}
	int index = minIndex;
	int count = 0;
	while (index != N)
	{
		index = index + K - 1;
		if (index > N)
		{
			if (count == 0)
			{
				minIndex -= index - N - 1;
				index = N;	
			}
			else {
				index = N;
			}
		}
		count++;
	}
	index = minIndex;
	while (index != 1)
	{
		index = index - K + 1;
		if (index < 1) index = 1;
		count++;
	}
	cout << count << endl;
}

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

#include<stdio.h>
int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;

Compiler output:
main.c: In function 'main':
main.c:2:1: error: parameter 'ans' is initialized
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      | ^~~
main.c:2:29: error: expected declaration specifiers before 'scanf'
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      |                             ^~~~~
main.c:2:50: error: expected declaration specifiers before 'while'
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      |                                                  ^~~~~
main.c:2:93: error: expected declaration specifiers before 'printf'
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      |                                                                                             ^~~~~~
main.c:2:110: error: expected declaration specifiers before 'return'
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      |                                                                                                              ^~~~~~
main.c:2:5: error: old-style parameter declarations in prototyped function definition
    2 | int main(void)int n,k,ans=1;scanf("%d %d",&n,&k);while (1){if(n<=(ans*(k-1)+1))break;ans++;}printf("%d",ans);return 0;
      |     ^~~~
main.c:3: error: expected '{' at end of input
Language: C

#include<stdio.h>
int main(void){
  int n,k,ans=1;
  scanf("%d %d",&n,&k);
  while (1){
    if(n>(ans*(k-1)+1)break;
    ans++;
  }
  printf(ans);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:6:23: error: expected ')' before 'break'
    6 |     if(n>(ans*(k-1)+1)break;
      |       ~               ^~~~~
      |                       )
main.c:8:3: error: expected expression before '}' token
    8 |   }
      |   ^
main.c:9:10: error: passing argument 1 of 'printf' makes pointer from integer without a cast [-Wint-conversion]
    9 |   printf(ans);
      |          ^~~
      |          |
      |          int
In file included from main.c:1:
/usr/include/stdio.h:363:43: note: expected 'const char * restrict' but argument is of type 'int'
  363 | extern int printf (const char *__restrict __format, ...);
      |                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
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 ans = Math.ceil((n-1)/(k-1));
        System.out.println(ans);
    }    
}


Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from double to int
        int ans = Math.ceil((n-1)/(k-1));
                           ^
1 error
Language: C++

#include<iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    ll N,K;
    ll index;//はじめに1が存在する位置
    ll now;
    ll ans=0;
    ll z1=0;
    ll z2=0;
    vector<ll> a;
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        ll x;
        cin>>x;
        if (x==1){
            index=i;
            now=i;
        }
        a.push_back(x);
    }
    while (now!=a.size()-1){//右側を1に
        now+=K-1;
        if (now<=a.size()-1){
            ans++;
        }else{
            now-=K-1;
            z1=a.size()-1-now;
            break;
        }
    }
    now=index;
    while (now!=0){//左側を1に
        now-=K-1;
        if (now>=0){
            ans++;
        }else{
            now+=K-1;
            z2=now;
            break;
        }
    }
    ll remain=z1+z2
    if (remain==0){

    }else if (remain<=K-1){
        ans++;
    }else{
        ans+=2;
    }
    cout<<ans<<'\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:5: error: expected ',' or ';' before 'if'
   52 |     if (remain==0){
      |     ^~
a.cc:54:6: error: 'else' without a previous 'if'
   54 |     }else if (remain<=K-1){
      |      ^~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    ll N,K;
    ll index;//はじめに1が存在する位置
    ll now;
    ll ans=0;
    ll z1=0;
    ll z2=0;
    vector<ll> a;
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        ll x;
        cin>>x;
        if (x==1){
            index=i;
            now=i;
        }
        a.push_back(x);
    }
    while (now!=a.size()-1){//右側を1に
        now+=K-1;
        if (now<=a.size()-1){
            ans++;
        }else{
            now-=K-1;
            z1=a.size()-1-now;
            break;
        }
    }
    now=index;
    while (now!=0){//左側を1に
        now-=K-1;
        if (now>=0){
            ans++;
        }else{
            now+=K-1;
            z2=now;
            break;
        }
    }
    ll remain=z1+z2
    if (remain==0){

    }else if (remain<=k-1){
        ans++;
    }else{
        ans+=2;
    }
    cout<<ans<<'\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:5: error: expected ',' or ';' before 'if'
   52 |     if (remain==0){
      |     ^~
a.cc:54:6: error: 'else' without a previous 'if'
   54 |     }else if (remain<=k-1){
      |      ^~~~
a.cc:54:23: error: 'k' was not declared in this scope
   54 |     }else if (remain<=k-1){
      |                       ^
Language: C++

#include<iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main(){
    ll N,K;
    ll index;//はじめに1が存在する位置
    ll now;
    ll ans=0;
    ll z1=0;
    ll z2=0;
    vector<ll> a;
    cin>>N>>K;
    for(ll i=0;i<N;i++){
        ll x;
        cin>>x;
        if (x==1){
            index=i;
            now=i;
        }
        a.push_back(x);
    }
    while (now!=a.size()-1){//右側を1に
        now+=K-1;
        if (now>a.size()-1){
            z1=now-a.size()+1;
            now=a.size()-1;
        }
        ans++;
    }
    now=index;
    while (now!=0){//左側を1に
        now-=K-1;
        if (now<0){
            z2=0-now;
            now=0;
        }
        ans++;
    }
    if (z1+z2+1==K)||(z1==K)||(z2+1==K){
        ans--;
    }
    cout<<ans<<'\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:20: error: expected primary-expression before '||' token
   47 |     if (z1+z2+1==K)||(z1==K)||(z2+1==K){
      |                    ^~
Language: C++

clude <iostream>
using namespace std;
int n,k,ans=0;
int A[100000];
int main(){
    cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>A[i];
}
if((n-1)%(k-1)==0){
    ans=(n-1)/(k-1);
}else{
    ans=(n-1)/(k-1)+1;
}
cout<<ans<<endl;
return 0;
}

Compiler output:
a.cc:1:1: error: 'clude' does not name a type
    1 | clude <iostream>
      | ^~~~~
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin>>n>>k;
      |     ^~~
a.cc:15:1: error: 'cout' was not declared in this scope
   15 | cout<<ans<<endl;
      | ^~~~
a.cc:15:12: error: 'endl' was not declared in this scope
   15 | cout<<ans<<endl;
      |            ^~~~
Language: Java

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), k = sc.nextInt();
    int ans = 0;
    for(int i = 0; i < n; i++) {
      int a = sc.nextInt();
      if (a == 1) {
        int l = i / (k-1) + (i % (k-1) != 0 ? 1 : 0);
        int r = (n-l*(k-1)-1) / (k-1) + ((n-l*(k-1)-1) % (k-1) != 0 ? 1 : 0)
        ans = l + r;
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:12: error: ';' expected
        int r = (n-l*(k-1)-1) / (k-1) + ((n-l*(k-1)-1) % (k-1) != 0 ? 1 : 0)
                                                                            ^
1 error
Language: C

#include <stdio.h>

int main(){
    int n,k;scanf("%d %d",&n,&k);
    int a[n];
    int q;
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
    }   
    q=(n-k)/(k-1)+1;
   printf("%d",q);
   return 0;
}  

Compiler output:
main.c: In function 'main':
main.c:7:19: error: 'N' undeclared (first use in this function)
    7 |     for(int i=0;i<N;i++){
      |                   ^
main.c:7:19: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

int main() {
  int n,k; cin>>n>>k;
  int a[n];
  rep(i, n) cin>>a[i];
  
  int mina=9999999;
  int minplace=-1;
  rep(i, n){
    if(mina>a[i]){mina=a[i];
                  minplace=i;}
  }
  
  if(minplace>=
  
  int left=(minplace+k-2)/(k-1);
  int right=(n-minplace+k-3)/(k-1);
  
  cout<<(n+k-3)/(k-1)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: expected primary-expression before 'int'
   21 |   int left=(minplace+k-2)/(k-1);
      |   ^~~
a.cc:22:35: error: expected ')' before ';' token
   22 |   int right=(n-minplace+k-3)/(k-1);
      |                                   ^
      |                                   )
a.cc:19:5: note: to match this '('
   19 |   if(minplace>=
      |     ^
Language: C++

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

int main() {
  int n,k; cin>>n>>k;
  int a[n];
  rep(i, n) cin>>a[i];
  
  int mina=9999999;
  int minplace=-1;
  rep(i, n){
    if(mina>a[i]){mina=a[i];
                  minplace=i;}
  }
  
  if(minplace>=
  
  int left=(minplace+k-2)/(k-1);
  int right=(n-minplace+k-3)/(k-1);
  
  cout<<(n+k-2)/(k-1)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:3: error: expected primary-expression before 'int'
   21 |   int left=(minplace+k-2)/(k-1);
      |   ^~~
a.cc:22:35: error: expected ')' before ';' token
   22 |   int right=(n-minplace+k-3)/(k-1);
      |                                   ^
      |                                   )
a.cc:19:5: note: to match this '('
   19 |   if(minplace>=
      |     ^
Language: C++

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

int main() {
  int n,k; cin>>n>>k;
  int a[n];
  rep(i, n) cin>>a[i];
  
  int mina=9999999;
  int minplace=-1;
  rep(i, n){
    if(mina>a[i]){mina=a[i];
                  minplace=i;}
  }
  
  int left=(minplace+k-2)/(k-1);
  int right=(n-minplace+k-3)/(k-1);
  
  cout<<left+right<<endl;
}

}

Compiler output:
a.cc:25:1: error: expected declaration before '}' token
   25 | }
      | ^
Language: C++

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

int main(){
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];
	cout << (N+K-3)/(K-1) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:39: error: 'A' was not declared in this scope
    8 |         for(int i=0; i<N; i++) cin >> A[i];
      |                                       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()（）{int n,m;cin>>n>>m;int ans=(n-1)/(m-1);cout<<ans;return 0;}

Compiler output:
a.cc:3:11: error: expected initializer before '\U0000ff08\U0000ff09'
    3 | int main()（）{int n,m;cin>>n>>m;int ans=(n-1)/(m-1);cout<<ans;return 0;}
      |           ^~~~
Language: Java

import java.util.Arrays;
 
public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] A = new int[N+1];
    int one = 0;
    for(int i = 1; i <= N; i++){
      A[i] = scanner.nextInt();
      if(A[i] == 1){
        one = i;
      }
    }
    if((N-1)%(K-1)!=0){
      System.out.println((N-1)/(K-1)+1);
    }else{
      System.out.println((N-1)/(K-1));
    }
  }
}

Compiler output:
Main.java:5: error: cannot find symbol
    Scanner scanner = new Scanner(System.in);
    ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
    Scanner scanner = new Scanner(System.in);
                          ^
  symbol:   class Scanner
  location: class Main
2 errors