stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define mod 1000000007

#define pb push_back

#define mp make_pair

#define ff first

#define ss second

#define forn(i, n) for(int i = 0; i < int(n); ++i)

typedef long long ll;



const ll E=(ll)1e9+7;

const int N=100001;



int main()

{

    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    int t;

    //cin>>t;

    t=1;

    while(t--)

    {

        int n,min_sum=INT_MAX;

        cin>>n;

        for(int j=1;j<n;j++)

        {

            int a=j,b=n-j;

            int sum=0;

            while(a)

            {

                sum+=a%10;

                a/=10;

            }

            while(b)

            {

                sum+=b%10;

                b/=10;

            }

            min_sum=min(sum,min_sum);

        }

        cout<<min_sum;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.083598378282457x):
#include<cstdio>

#include<algorithm>

using namespace std;

int Solve(int n)

{

	int ret=0;

	while(n)

	{

		ret+=n%10;

		n/=10;

	}

	return ret;

}

int main()

{

	int n;

	int ans=1000000;

	scanf("%d",&n);

	for(int i=1;i<=n/2;i++)

	{

		int j=n-i;

		ans=min(ans,Solve(i)+Solve(j));

	}

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

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define mod 1000000007

#define pb push_back

#define mp make_pair

#define ff first

#define ss second

#define forn(i, n) for(int i = 0; i < int(n); ++i)

typedef long long ll;



const ll E=(ll)1e9+7;

const int N=100001;



int main()

{

    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

    int t;

    //cin>>t;

    t=1;

    while(t--)

    {

        int n,min_sum=INT_MAX;

        cin>>n;

        for(int j=1;j<n;j++)

        {

            int a=j,b=n-j;

            int sum=0;

            while(a)

            {

                sum+=a%10;

                a/=10;

            }

            while(b)

            {

                sum+=b%10;

                b/=10;

            }

            min_sum=min(sum,min_sum);

        }

        cout<<min_sum;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.156739950742974x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include<iostream>

using namespace std;

const int maxn = 1e6+10;

int m,n;

int main()

{

	cin>>n;

	int ans=0;

	if(n%10!=0)

	{

		while(n)

		{

			ans+=n%10;

			n/=10;

		}

	}

	else 

	{

		n/=2;

		while(n)

		{

			ans+=n%10;

			n/=10;

		}

		ans*=2;

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 4.923435905494257x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
/*

  ***

  0.0

  *-*

 * * *

*  *  *

*  *  *

   *

   *

  * *

 *   *

 *   *

 	   	  		*/

#include<bits/stdc++.h>

#define ll long long

#define pb push_back

#define pp pop_back

#define F first

#define S second

// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

ll n,sum,num,maxi=-10e9,maxn=-10e9,mini=10e9,minn=10e9,sam;

int main(){

	ios_base::sync_with_stdio(0);

	cin.tie();	cout.tie();

	//freopen("input.txt", "r", stdin);

	//freopen("output.txt", "w", stdout);

	cin>>n;

	for(int i = 1;i <= n/2;i++){

		sum=i;

		num=n-i;

		while(sum>0){

			sam+=sum%10;

			sum/=10;

		}

		while(num>0){

			sam+=num%10;

			num/=10;

		}

		sum=0;

		num=0;

		mini=min(mini,sam);

		sam=0;

	}

	cout<<mini;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.067640736367456x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int sum(int x){

	int s = 0;

	do{

		int r = x % 10;

		s += r;

		x /= 10;

	}while(x);

	return s;

}



int main(){

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, ans = 0;

	cin >> n;

	for(int a = 1; a < n; ++a){

		int b = n - a;

		int t = sum(a) + sum(b);

		if(a == 1 || t < ans) ans = t;

	}

	cout << ans << "\n";

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.162318398687743x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define fi first

#define se second

#define pb push_back

#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))

#define forn(i,a,b) for(int i = a; i < b; i++)

#define forr(i,a,b) for(int i = a; i >= b; i--)

#define all(x) (x).begin(), (x).end()



typedef long long ll;

typedef long double ld;

typedef pair<int,int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;



const int oo = 1<<29;

int n;

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> n;

	int res = oo;

	forn(i,1,n){

		int a = i;

		int b = n-i;

		string _a = to_string(a);

		string _b = to_string(b);

		int act = 0;

		forn(j,0,_a.size()) act += _a[j]-'0';

		forn(j,0,_b.size()) act += _b[j]-'0';

		res = min(res,act);

 	}

	cout << res << '\n';

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.475862569915068x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#define fi first

#define se second

#define pb push_back

#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))

#define forn(i,a,b) for(int i = a; i < b; i++)

#define forr(i,a,b) for(int i = a; i >= b; i--)

#define all(x) (x).begin(), (x).end()



typedef long long ll;

typedef long double ld;

typedef pair<int,int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;



const int oo = 1<<29;

int N;

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> N;

	int res = oo;

	forn(i,1,N){

		int a = i;

		int b = N-i;

		string _a = to_string(a);

		string _b = to_string(b);

		int act = 0;

		forn(j,0,_a.size()) act += _a[j]-'0';

		forn(j,0,_b.size()) act += _b[j]-'0';

		res = min(res,act);

 	}

	cout << res << '\n';

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.475862569915068x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

int n;

int cnt(int x) {

  int ret = 0;

  while (x) {

    ret += x % 10;

    x /= 10;

  }

  return ret;

}

int main() {

  cin >> n;

  int ans = 0x3f3f3f3f;

  for (int i = 1; i <= n / 2; i++) {

    int a = i, b = n - i;

    ans = min(cnt(a) + cnt(b), ans);

  }

  cout << ans << endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.020258949876658x):
#include<stdio.h>

int main()

{

	int a,b,n,sum,c,d,i,min=200;

	scanf("%d",&n);

	for(a=1;a<=n/2;a++)

	{   sum=0;

		b=n-a;

		c=a;

		d=b;

		for(i=5;i>0;i--)

		{

		    sum+=c%10;

		    sum+=d%10;

		    c=c/10;

		    d=d/10;

		}

	    if(min>sum)

	    min=sum;

	}

	printf("%d",min);

	return 0;

 }
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

ll n, ans = 1e9;

void solve()

{

    cin >> n;

    for( int i = 1; i <= n / 2; i ++ )

    {

        ll x = i, z = n - i, sx = 0, sz = 0;

        while( x )sx += x % 10, x /= 10;

        while( z )sz += z % 10, z /= 10;

        ans = min( ans, sz + sx );

    }

    cout << ans;

}

int main()

{



	/*cin >> tests;

	while( t -- )*/

	    solve();

}

// Faster C++ solution for the same problem (measured speedup: 5.3679551236464285x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include <iostream>

#include <string>

using namespace std;

int main(){

	string n;

	int a;

	cin>>n;

	for(int i=0;i<n.size();++i){

		a+=(n[i]-48);

	}

	if(a==1){

		cout<<10;

		return 0;

	}

	cout<<a;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2552649755934455x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std; 

#define rint register int

inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}

int s[100005], n, Ans = 100; int main(){n = read(); for(rint i = 1; i < n; s[i] = s[i/10]+i%10, i++); for(rint i = 1; i < n; Ans = min(Ans,s[i]+s[n-i]), i++); return !printf("%d\n",Ans);}

// Faster C++ solution for the same problem (measured speedup: 5.227511351707989x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<queue>

#include<algorithm>

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

#define met(a,b) memset(a,b,sizeof(a))



int solve(int n)

{

    int ans=0;

    while(n){

        ans+=n%10;

        n/=10;

    }

    return ans;

}



int main()

{

    int n,Min=inf;

    scanf("%d",&n);

    for(int i=1;i<=n/2;i++){

        Min=min(Min,solve(i)+solve(n-i));

    }

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

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.309054096789711x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include<stdio.h>

#include<string.h>

#include<iostream>

#define ll long long

using namespace std;



int hehe(int n){

    int ans=0;

    while(n)

    {

    ans+=n%10;n/=10;}

    return ans;

}



int main (){

    int n;

    scanf("%d",&n);

    int ans=0x3f3f3f3f;

    for(int i=1;i<n;i++){

        ans=min(hehe(i)+hehe(n-i),ans);

    }

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

    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.393355881274553x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include<algorithm>

#include<cmath>

#include<cstring>

#include<iostream>

#include<cstdio>

#include<set>

using namespace std;

#define inf 0x3f3f3f3f

const int maxn=1e6;

int fun(int n){

    int sum=0;

    while(n){

        sum+=(n%10);

        n/=10;

    }

    return sum;

}

int main()

{

    int n;

   while( cin>>n){

        int minn = inf;

        for (int i = 1; i <= n / 2; i++) {

            int sum = fun(i) + fun(n - i);

            if (minn > sum)

                minn = sum;

        }

        cout << minn << endl;

   }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.374876621271766x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include<cstdio>

#include<iostream>

#include<cstring>

using namespace std;

int main()

{

    char ch[10];

    scanf("%s",ch);

    int sum=0;

    for(int i=0;ch[i]!='\0';i++)

    {

        sum+=ch[i]-'0';

    }

    if(sum==1)  cout<<10<<endl;

    else cout<<sum<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.228181078803929x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include <iostream>

#include <stdio.h>

#include <string.h>

#include <stdlib.h>



using namespace std;



int N;

int A, B, mini=99999999;

char a[10];

char b[10];

int sumA, sumB;



int main()

{

  cin >> N;

  if(N % 2 == 0)

  {

    A = N / 2;

    B = N / 2;

  }

  else

  {

    A = N / 2;

    B = (N / 2) + 1;

  }

  while(A>0)

  {

    sprintf(a, "%d", A);

    sprintf(b, "%d", B);

    for(int i=0; i<strlen(a); i++)

      sumA += a[i] - 48;

    for(int i=0; i<strlen(b); i++)

      sumB += b[i] - 48;

    if(sumA + sumB < mini)

      mini = sumA + sumB;

    sumA = 0;

    sumB = 0;

    A--;

    B++;

  }

  cout << mini << "\n";

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.396065786617991x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include <iostream>

using namespace std;



int sum(int N){

    int sum = 0;

    while(N > 0){

        sum += N % 10;

        N /= 10;

    }

    return sum;

}



int main(){

    int MIN = 1e9;

    int a, b, N;

    //La bruta xD

    cin >> N;

    for(int i = 1 ; i <= N/2 ; i++){

        a = sum(i);

        b = sum(N - i);

        MIN = min(MIN, a + b);

    }

    cout << MIN << "\n";



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.353894687438691x):
#include<stdio.h>

int main()

{

	int n;

	int sum=0;

	scanf("%d",&n);

	while(n>0)

	{

		sum+=n%10;

		n/=10; 

	 } 

	 if(sum==1)

	 {

	 	printf("10");

	 	return 0;

	 }

	 else 

	 {

	 	printf("%d",sum);

	 }

 }
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

#define mod 998244353

typedef long long ll;



using namespace std;



void Fastio(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}



ll fact[1000006], inv[1000006];



ll fp(ll base, ll exp)

{

    if (exp == 0)

        return 1;

    ll ans = fp(base, exp / 2);

    ans = (ans * ans) % mod;

    if (exp % 2 != 0)

        ans = (ans * (base % mod)) % mod;

    return ans;

}



void calcFacAndInv(ll n)

{

    fact[0] = inv[0] = 1;

    for (ll i = 1; i <= n; i++)

    {

        fact[i] = (i * fact[i - 1]) ;

        inv[i] = fp(fact[i], mod - 2);

    }

}



ll ncr(ll n, ll r)

{

    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;

}



ll npr(ll n, ll r)

{

    return (fact[n] * inv[n - r]) % mod;

}



long double  NCR(int n, int m){

    long double res = 1;

    m = min(m, n - m);

    for(int i = 0; i < m; i++){

        res = res * ( n - i) / (i + 1);

 }

    return res;

}

ll tol(string a){

    ll res=0;

    while(a[0]=='0'){

        a.erase(a.begin());

    }

    if(a=="")a="0";

    for(int i=0; i<a.size(); i++){

        res*=10; res+=a[i]-'0';

    }

    return res;

}

int check(string a, string b){

    for(int i=0; i<a.size(); i++){

        if(a[i]>b[i])return 1;

        if(b[i]>a[i])return -1;

    }

    return 0;

}

class data{

public:

    ll v,d,p;

    data(){}

    data(ll vv, ll dd, ll pp){

        v=vv;  d=dd; p=pp;

    }

};



int primeFactors(int n)

{

    ll c=0;

    while (n % 2 == 0)

    {

        c++;

        n = n/2;

    }

    for (int i = 3; i*i <= n; i = i + 2)

    {

        while (n % i == 0)

        {

            c++;

            n = n/i;

        }

    }

    if (n > 2)

        c++;

    return c;

}

int n,m, counter;

vector<int>arr[200005];

int vis[200005];

void dfs(int node){

    vis[node]=1; counter++;

    for(int i=0; i<arr[node].size(); i++){

        if(!vis[arr[node][i]])dfs(arr[node][i]);

    }

}

int main()

{

    Fastio();

    double n,k,pos=0; cin>>n>>k; k--;

    for(int i=0; i<n; i++){

        int x; cin>>x;

        if(x==1)pos=i;

    }

    ll tmp1, tmp2;

    int p=pos,kk=k;

    while(p%kk && p+1<n)p++;

    pos=p; tmp1=ceil(pos/k);

    tmp2=ceil((n-pos-1)/k);

    ll res=tmp1+tmp2;

    cout<<res<<'\n';



    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 6.543337592847872x):
#include <bits/stdc++.h>



using namespace std;



#ifdef ZERO_IQ

ios_base::sync_with_stdio ( false ), cin.tie ( 0 ), cout.tie ( 0 );

#endif



int main() {

    int n, m;

    cin >> n >> m;

    cout << 1LL * ((n - 1) + (m - 2)) / (m - 1) << endl;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

#define mod 998244353

typedef long long ll;



using namespace std;



void Fastio(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}



ll fact[1000006], inv[1000006];



ll fp(ll base, ll exp)

{

    if (exp == 0)

        return 1;

    ll ans = fp(base, exp / 2);

    ans = (ans * ans) % mod;

    if (exp % 2 != 0)

        ans = (ans * (base % mod)) % mod;

    return ans;

}



void calcFacAndInv(ll n)

{

    fact[0] = inv[0] = 1;

    for (ll i = 1; i <= n; i++)

    {

        fact[i] = (i * fact[i - 1]) ;

        inv[i] = fp(fact[i], mod - 2);

    }

}



ll ncr(ll n, ll r)

{

    return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;

}



ll npr(ll n, ll r)

{

    return (fact[n] * inv[n - r]) % mod;

}



long double  NCR(int n, int m){

    long double res = 1;

    m = min(m, n - m);

    for(int i = 0; i < m; i++){

        res = res * ( n - i) / (i + 1);

 }

    return res;

}

ll tol(string a){

    ll res=0;

    while(a[0]=='0'){

        a.erase(a.begin());

    }

    if(a=="")a="0";

    for(int i=0; i<a.size(); i++){

        res*=10; res+=a[i]-'0';

    }

    return res;

}

int check(string a, string b){

    for(int i=0; i<a.size(); i++){

        if(a[i]>b[i])return 1;

        if(b[i]>a[i])return -1;

    }

    return 0;

}

class data{

public:

    ll v,d,p;

    data(){}

    data(ll vv, ll dd, ll pp){

        v=vv;  d=dd; p=pp;

    }

};



int primeFactors(int n)

{

    ll c=0;

    while (n % 2 == 0)

    {

        c++;

        n = n/2;

    }

    for (int i = 3; i*i <= n; i = i + 2)

    {

        while (n % i == 0)

        {

            c++;

            n = n/i;

        }

    }

    if (n > 2)

        c++;

    return c;

}

int n,m, counter;

vector<int>arr[200005];

int vis[200005];

void dfs(int node){

    vis[node]=1; counter++;

    for(int i=0; i<arr[node].size(); i++){

        if(!vis[arr[node][i]])dfs(arr[node][i]);

    }

}

int main()

{

    Fastio();

    double n,k,pos=0; cin>>n>>k; k--;

    for(int i=0; i<n; i++){

        int x; cin>>x;

        if(x==1)pos=i;

    }

    ll tmp1, tmp2;

    int p=pos,kk=k;

    while(p%kk && p+1<n)p++;

    pos=p; tmp1=ceil(pos/k);

    tmp2=ceil((n-pos-1)/k);

    ll res=tmp1+tmp2;

    cout<<res<<'\n';



    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 6.527891941670108x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



const int N = 1e5 + 5, mod = 1e9 + 7, inf = INT_MAX;



int main()

{

    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);

    int n, m, c, x, ans = inf;

    cin >> n >> m;

    for (int i = 0; i < n; i++)

    {

        cin >> x;

        if (x == 1)

            c = i + 1;

    }

    for (int i = max(1, c - m + 1); i <= n; i++)

    {

        int l = i, r = i + m - 1;

        ans = min(ans, 1 + (l - 1) / (m - 1) + ((l - 1) % (m - 1) == 0? 0: 1) +

                           (n - r) / (m - 1) + ((n - r) % (m - 1) == 0? 0: 1));

    }

    cout << ans;

    return 0;

}