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

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

int main()
{
    ll n, k, ans = 0;
    string s;
    cin >> n >> k >> s;
    rep(i,n-1) {
        if (s[i] == s[i+1]) ans++;
    }
    int ans = min(ans+2*k, n-1);
    cout << ans << endl;
    // char c = s[0];
    // rep(i, n)
    // {
    //     if (s[i] != c && k > 0){
    //         while(){
    //             s[]
    //         }
    //     }
    // }
    // rep(i, n)
    // {
    //     if (i == 0 && s[i] == 'L')
    //         continue;
    //     if (i == n - 1 && s[i] == 'R')
    //         continue;
    //     if (s[i] == 'R' && s[i + 1] == 'R')
    //         ans++;
    //     if (s[i] == 'L' && s[i - 1] == 'L')
    //         ans++;
    // }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: conflicting declaration 'int ans'
   14 |     int ans = min(ans+2*k, n-1);
      |         ^~~
a.cc:8:14: note: previous declaration as 'll ans'
    8 |     ll n, k, ans = 0;
      |              ^~~
Language: C

#include <bits/stdc++.h>
using namespace std;
 
//krishrawat
 
 
//----------------------------MACROS-------------------------------------------------
#define pb insert//                                                                 |
#define eb emplace_back//                                                           |
#define ff first//                                                                  |
#define ss second//                                                                 |
typedef long long int ll;//                                                         |
typedef long double ld;//                                                           |
#define all(a) a.begin(), a.end()//                                                 |
#define show(x) cerr << #x << " is " << x << "\n"//                                 |
#define show2(x, y) cerr << #x << " " << #y << " " << x << " " << y << "\n"//       |
typedef vector<ll> vl;//                                                            |
typedef vector<vl> vvl;//                                                           |
typedef pair<ll, ll> pp;//                                                          |
typedef vector<pp> vp;//                                                            |
typedef map<pp, ll> ipi;//                                                          |
typedef map<pp, char> ipc;//                                                        |
typedef map<ll, ll> ii;//                                                           |
typedef set<ll> sl;//                                                               |
typedef multiset<ll> msl;//                                                         |
typedef map<char, ll> ci;//                                                         |
typedef set<pair<ll, ll>> sp;//                                                     |
const ll mod = 1e9 + 7;//                                                           |
const ll N = 1e5 + 1;//                                                             |
//----------------------------------------------------------------------------------


void solve()
{   
    ll n,m;cin>>n>>m;
    string s;cin>>s;
    ll f=0,cnt=0;
    ll ans=0;
    for(int i=1;i<n;i++){
        if((s[i]==s[0] && f) || s[i]==s[i-1]){
            cnt++;
        }
        else{
            f=0;
            if(m){
                cnt++;
                m--;
                f=1;
            }
            
        }
        
    }
    cout<<cnt<<"\n";
}
 
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    
    ll t; t=1;
    //cin>>t;
    while(t--) solve(); return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		int n,k;
		cin>>n>>k;
		string s;
		cin>>s;
		vpi a;
		int t2,t1;
		t2=0;t1=0;
		int h=0;
		if(i==0 && s[i]=='L') t1++;
		if(i==n-1 && s[i]=='R') t1++;
		
		for(int i=1;i<n-1;i++){
			if(s[i]=='L' && s[i+1]=='R') t2++;
			else if(s[i]=='R' && s[i+1]=='L') t1++;
			else if(i==0 && s[i]=='L') t1++;
			else if(i==n-1 && s[i]=='R') t1++;
			else  h++;	
		}
		if(t2<k) {
			k-=t2;
			h+=(2*t2);
			if(k>t1) h+=t1;
			else h+=k;
			cout<<h<<endl;

		}
		else {
			h+=(2*k);
			cout<<h<<endl;
		}

	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:20: error: 'i' was not declared in this scope
   24 |                 if(i==0 && s[i]=='L') t1++;
      |                    ^
a.cc:25:20: error: 'i' was not declared in this scope
   25 |                 if(i==n-1 && s[i]=='R') t1++;
      |                    ^
Language: C++

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

int main(){
	int n, k;
  cin >> n >> k;
　char s[n];
  cin >> s;
  int count =0;
  int happy = 0;
  
  for(int i = 0; i < n-1; i++){
  	if(s[i] == s[i+1]) happy ++;
	if(s[i] != s[i+1]) count ++;
  }
  
  count /= 2;
  count *= 2;
  
  if(count < 2*k){
  	cout << happy + count;
  }else{
  	cout << happy + 2*k;
  }
  
  
}


Compiler output:
a.cc:7:1: error: extended character 　 is not valid in an identifier
    7 | 　char s[n];
      | ^
a.cc: In function 'int main()':
a.cc:7:1: error: '\U00003000char' was not declared in this scope
    7 | 　char s[n];
      | ^~~~~~
a.cc:8:10: error: 's' was not declared in this scope
    8 |   cin >> s;
      |          ^
Language: C++

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

int main(){
	int n, k;
  cin >> n >> k;
　char s[n];
  cin >> s;
  int count =0;
  int happy = 0;
  
  for(int i = 0; i < n-1; i++){
  	if(s[i] == s[i+1]) happy ++;
	if(s[i] != s[i+1]) count ++;
  }
  
  count /= 2;
  count *= 2;
  
  if(count < 2*k){
  	cout << happy + count;
  }else{
  	cout << happy + 2*k;
  }
  
  
}

Compiler output:
a.cc:7:1: error: extended character 　 is not valid in an identifier
    7 | 　char s[n];
      | ^
a.cc:1:1: error: 'include' does not name a type
    1 | include<bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> n >> k;
      |   ^~~
a.cc:7:1: error: '\U00003000char' was not declared in this scope; did you mean 'char'?
    7 | 　char s[n];
      | ^~~~~~
      | char
a.cc:8:10: error: 's' was not declared in this scope
    8 |   cin >> s;
      |          ^
a.cc:21:9: error: 'cout' was not declared in this scope; did you mean 'count'?
   21 |         cout << happy + count;
      |         ^~~~
      |         count
a.cc:23:9: error: 'cout' was not declared in this scope; did you mean 'count'?
   23 |         cout << happy + 2*k;
      |         ^~~~
      |         count
Language: C++

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



int main(){
    ll N,K;
    string S;
    cin >> N >> K >> S;

    ll ans = 0;
    ll cnt_LR = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == S[i + 1]){
            ans++;
        }
        else{
            cnt_LR++;
        }
    }

    ans = N - 1 - max(cnt_LR - 2 * K, 0);

    cout << ans << endl;

}


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

#include <iostream>
#include <string>

using namespace std;

int main(){
    int N,K;
    string S;
    cin >> N >> K;
    cin >> S;
    int count = 0;
    int initial = 0;
    for(int i = 0; i < S.length()-1;i++){
        if(S[i] == 'R' && S[i+1] == 'L') count += 1;
        if(S[i] == S[i+1]) initial += 1;
    }
    int ans = 0;
    if(K <= count-1) ans = initial + 2 * K;
    else if(((S[0] == 'R' && S[N] != 'L') || (S[0] != 'R' && S[N] == 'L') && K >= count) || ((S[0] == 'R' && S[N] == 'L') && K = count )) ans = initial + 2*(count-1) + 1;
    else if((S[0] == 'R' && S[N] == 'L') && K > count) ans = initial + 2*(count-1) + 2;
    else ans = initial + 2*(count-1);
    

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:123: error: lvalue required as left operand of assignment
   19 |     else if(((S[0] == 'R' && S[N] != 'L') || (S[0] != 'R' && S[N] == 'L') && K >= count) || ((S[0] == 'R' && S[N] == 'L') && K = count )) ans = initial + 2*(count-1) + 1;
      |                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,k;
    cin>>n>>k;

    string s;
    cin>>s;

    vector <ll> vec;

    vec.push_back(0);
    ll ans = 0;
    for(ll i=1;i<s.size();i++)
    {
        if(s[i]!=s[vec.back()])
        {
            ans += i-vec.back()-1;
            vec.push_back(i);
        }
    }
    ans += n-vec.back()-1;

    for(ll i=1;i+1<vec.size();i++)
    {
        ans += 2;
        k--;
        if(k==0)
            break;
    }

    if(vec.size()>=2)
    {
        if(k>0)
        {
            ans += 1;
        }
    }

    cout<<ans<<endl;



Compiler output:
a.cc: In function 'int main()':
a.cc:52:21: error: expected '}' at end of input
   52 |     cout<<ans<<endl;
      |                     ^
a.cc:11:1: note: to match this '{'
   11 | {
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin >>N>>K;
  string S;cin>>S;
  int ans=0;
  for(int i=1;i<S.size();++i){
    if(S[i]==S[i-1]) ans+=1;
  }
  for(int i=0;i<K;++i) {
    if(ans==S.size()-1) {
      cout << ans;
      return;
    }
    if(ans<=S.size()-2) ans+=2;
    if(ans==S.size()-1) ans+=1;
  }
  cout <<ans;
}


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

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

signed main(void)
{
	int n, k;
	long long ans;
	string s, t;

	cin >> n >> k >> s;
	ans = 0;
	rep(i, n - 1)
	{
		if (s[i] == s[i + 1])
			ans++;
	}
	ans = min(ans + 2 * k, n - 1);
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: no matching function for call to 'min(long long int, int)'
   18 |         ans = min(ans + 2 * k, n - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~
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:18:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         ans = min(ans + 2 * k, n - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~
/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:18:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         ans = min(ans + 2 * k, n - 1);
      |               ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k;
  string s;
  cin >> n >> k >> s;
  vl a(n);
  char c=s[0];
  ll j=0;
  rep(i,n-1){
    if(c==s[i+1]){
      a[j]++;
    }
    else{
      j++;
      a[j]++;
    }
    c=s[i+1];
  }
  ll sum=0;
  ll x;
  rep(i,n){
    if(a[i]==0){
      x=i;
      break;
    }
  }
  rep(i,x){
    sum +=max(0,a[i]-1);
  }
  ll ans=min(sum+2*k,n-1);
  cout << ans << endl;
}

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

from itertools import groupby

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

D = {
    'L': 0,
    'R': 0
}

for val, it in groupby(input()):
    D[val] += 1

u = max([1, D['L'] + D['R'] - 2 * k])

print(n - u)


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from itertools import groupby
      | ^~~~
a.cc:10:1: error: expected unqualified-id before 'for'
   10 | for val, it in groupby(input()):
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  int cnt = 0;
  vector<char> v;
  v.push_back(S[0]);
  for (int i = 1; i < N; i++) {
    if (v.back() != S[i]) v.push_back(S[i]);
  }
  
  int ans = N - max(1, (int)v.size() - 2 * K);
  cout << ans << endl;
  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:16:12: error: expected '}' at end of input
   16 |   return 0;
      |            ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
int main(){
  int n,k,a=0;string s;cin>>n>>k>>s;
  REP(i,n-2)
    if(s[i]==s[i+1])a++;
  cout<<min(n-1,k*2+a)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:25: error: 'll' was not declared in this scope
    3 | #define rep(i,a,b) for (ll i = (a); i < (b); i++)
      |                         ^~
a.cc:4:18: note: in expansion of macro 'rep'
    4 | #define REP(i,n) rep(i,0,n)
      |                  ^~~
a.cc:7:3: note: in expansion of macro 'REP'
    7 |   REP(i,n-2)
      |   ^~~
a.cc:7:7: error: 'i' was not declared in this scope
    7 |   REP(i,n-2)
      |       ^
a.cc:3:37: note: in definition of macro 'rep'
    3 | #define rep(i,a,b) for (ll i = (a); i < (b); i++)
      |                                     ^
a.cc:7:3: note: in expansion of macro 'REP'
    7 |   REP(i,n-2)
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a=0;string s;cin>>n>>k>>s;
  REP(i,n-2)
    if(s[i]==s[i+1])a++;
  cout<<min(n-1,k*2+a)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   REP(i,n-2)
      |       ^
a.cc:5:3: error: 'REP' was not declared in this scope
    5 |   REP(i,n-2)
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,a=0;string s;cin>>n>>k>>s;
  REP(i,n-2)
    if(s[i]==s[i+1])a++;
  }
  cout<<min(n-1,k*2+a)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:7: error: 'i' was not declared in this scope
    5 |   REP(i,n-2)
      |       ^
a.cc:5:3: error: 'REP' was not declared in this scope
    5 |   REP(i,n-2)
      |   ^~~
a.cc: At global scope:
a.cc:8:3: error: 'cout' does not name a type
    8 |   cout<<min(n-1,k*2+a)<<endl;
      |   ^~~~
a.cc:9:1: error: expected declaration before '}' token
    9 | }
      | ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
//#include<bits/stdc++.h>
#include"stdc++.h"
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,k;
  cin>>n>>k;
  string s;
  cin>>s;

  auto t=s[0];

  auto idx=0;
  auto cnt=0;

  while(idx<n){

    auto c=s[idx];
    //cout << idx << "," << c << endl;
    if(c!=t){
      cnt++;
      //cout << "while start" << endl;
      while(s[idx]!=t && idx<n){
        //cout << "idx: " << idx << endl;
        s[idx]=t;
        idx++;
      }
      //cout << "while end" << endl;
    }
    if(cnt>=k) break;
    idx++;
  }
  //cout << s << endl;
  ll ans=n;
  char prev=-1;
  for(auto c:s){
    if(prev!=c){
      ans--;
    }
    prev=c;
  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

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

///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}



void solve(){
    int n,m;
   cin >> n >> m;

   string s;
   cin >> s;
   int ans = 0;
   set<int> v;
   //s = 'R' + s + 'L';
   for(int i = 0;i<n-1;i++){
    if(s[i]!=s[i+1])ans++;
    
   }
   //cout << ans << endl;
   ans = max(ans - 2*m, 1);
  cout << n-ans << endl;
   
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Compiler output:
a.cc: In function 'void solve()':
a.cc:46:13: error: no matching function for call to 'max(long long int, int)'
   46 |    ans = max(ans - 2*m, 1);
      |          ~~~^~~~~~~~~~~~~~
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:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:46:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |    ans = max(ans - 2*m, 1);
      |          ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:46:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |    ans = max(ans - 2*m, 1);
      |          ~~~^~~~~~~~~~~~~~
Language: C++

///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}



void solve(){
    int n,m;
   cin >> n >> m;

   string s;
   cin >> s;
   int ans = 0;
   set<int> v;
   //s = 'R' + s + 'L';
   for(int i = 0;i<n-1;i++){
    if(s[i]!=s[i+1])ans++;
    
   }
   //cout << ans << endl;
   ans = max(ans - 2*k, 1);
  cout << n-ans << endl;
   
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Compiler output:
a.cc: In function 'void solve()':
a.cc:46:22: error: 'k' was not declared in this scope
   46 |    ans = max(ans - 2*k, 1);
      |                      ^
Language: C++

$include<iostream>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c = s[i];
  int t = 0;
  rep(i, n-1) {
    if(s[i+1] == c) t++;
    else c = s[i+1];
  }
  cout << max(t + 2 * k, n-1) << endl;
}

Compiler output:
a.cc:1:1: error: '$include' does not name a type
    1 | $include<iostream>
      | ^~~~~~~~
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin >> n >> k;
      |   ^~~
a.cc:7:3: error: 'string' was not declared in this scope
    7 |   string s;
      |   ^~~~~~
a.cc:8:10: error: 's' was not declared in this scope
    8 |   cin >> s;
      |          ^
a.cc:9:14: error: 'i' was not declared in this scope
    9 |   char c = s[i];
      |              ^
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout << max(t + 2 * k, n-1) << endl;
      |   ^~~~
a.cc:15:11: error: 'max' was not declared in this scope
   15 |   cout << max(t + 2 * k, n-1) << endl;
      |           ^~~
a.cc:15:34: error: 'endl' was not declared in this scope
   15 |   cout << max(t + 2 * k, n-1) << endl;
      |                                  ^~~~
Language: C++

// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, k, c = 1, m = 0, x = 0;
    string s;
    cin >> n >> k >> s;
    vector<ll> v;
    for (ll i = 1; i < s.size(); i++)
        if (s[i] == s[i - 1])
            c++;
        else
            m += c - 1, c = 1, x++;
    m += c - 1;
    cout << m + min(2LL, x) * k;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: no matching function for call to 'min(long long int, int64_t&)'
   20 |     cout << m + min(2LL, x) * k;
      |                 ~~~^~~~~~~~
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:3:
/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:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   20 |     cout << m + min(2LL, x) * k;
      |                 ~~~^~~~~~~~
/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:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |     cout << m + min(2LL, x) * k;
      |                 ~~~^~~~~~~~
Language: C++

n, k = map(int, input().split())
s = input()

joint = 0
cnt = 0
for i in range(1,n):
  if s[i - 1] == s[i] == 'L':
    cnt += 1

for i in range(n - 1):
  if s[i + 1] == s[i] == 'R':
    cnt += 1

for i in range(n-1):
  if s[i] != s[i + 1]:
    joint += 1
  
if joint % 2 == 0:
  cnt += min(2*k, joint)
else:
  if k <= joint // 2:
    cnt += k * 2
  else:
    cnt += joint

print(cnt)

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;
  String S;
  cin>>N>>K>>S;
  int uh=0;
  if(S.at(0)=='L') uh++;
  if(S.at(N-1)=='R') uh++;
  for(int i=1;i<N;i++){
	if(S.at(i)=='L'&&S.at(i-1)=='R') uh++;
  }
  if(uh-2*K<=1)cout<<1<<endl;
  else cout<<uh-2*K<<endl;
}

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

#include <bits/stdc++.h>

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

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

    auto count=0;
    int prev = S[0];
    for (auto i = 1; i < N; i++) {
        if (prev != S[i]) {
            count++;
            prev = S[i];
        }
    }

    int n_del = max(count - 2 * K), 0);
    cout << N - 1 - n_del << endl;
    return 0;
}


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

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N, K;
stirng S;

void input(){
    cin >> N >> K >> S;
}

void solve(){
    input();
    int score = 0;
    rep(i, N-1){
        if(S[i] == S[i+1]) score++;
    }

    int ans = min(score+2*K, n-1);
    cout << ans << endl;
}
int main(){
    solve();
    return 0;
}

Compiler output:
a.cc:22:1: error: 'stirng' does not name a type
   22 | stirng S;
      | ^~~~~~
a.cc: In function 'void input()':
a.cc:25:22: error: 'S' was not declared in this scope
   25 |     cin >> N >> K >> S;
      |                      ^
a.cc: In function 'void solve()':
a.cc:32:12: error: 'S' was not declared in this scope
   32 |         if(S[i] == S[i+1]) score++;
      |            ^
a.cc:35:30: error: 'n' was not declared in this scope
   35 |     int ans = min(score+2*K, n-1);
      |                              ^
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>

#define fir first
#define sec second
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define All(s) (c).begin(), (c).end()
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define repk(i, j, k) for(int (i)=(j);(i)<(k);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;
const ll INF = 10241024;
int N, K;
stirng S;

void input(){
    cin >> N >> K >> S;
}

void solve(){
    input();
    int score = 0;
    rep(i, N-1){
        if(S[i] == S[i+1]) score++;
    }

    int ans = min(score+2*k, n-1);
    cout << ans << endl;
}
int main(){
    solve();
    return 0;
}

Compiler output:
a.cc:22:1: error: 'stirng' does not name a type
   22 | stirng S;
      | ^~~~~~
a.cc: In function 'void input()':
a.cc:25:22: error: 'S' was not declared in this scope
   25 |     cin >> N >> K >> S;
      |                      ^
a.cc: In function 'void solve()':
a.cc:32:12: error: 'S' was not declared in this scope
   32 |         if(S[i] == S[i+1]) score++;
      |            ^
a.cc:35:27: error: 'k' was not declared in this scope
   35 |     int ans = min(score+2*k, n-1);
      |                           ^
a.cc:35:30: error: 'n' was not declared in this scope
   35 |     int ans = min(score+2*k, n-1);
      |                              ^
Language: C++



n,k=map(int,input().split())   
s=input()
ans=0
for i in range(n):
    if(s[i]=="L" and i>=1):
        if(s[i-1]=="L"):ans+=1
    elif(s[i]=="R" and i<=n-2):
        if(s[i+1]=="R"):ans+=1
ans+=2*k
ans=min(n,ans)
print(ans)



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

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

int main(){
  int n, k;
  string s;
  cin >> n >> k >> s;
  
  const int half = n / 2;
  while(k != 0){
  int i = 1;
  int max = half;
  int min = half;
  bool c1 = (s[half] == s[half+i]);
  bool c2 = ((half+i) < n);
  bool c3 = ((half+i) > -1);
  while(c1 && c2){
    max = half + i;
    ++ i;
  }
  i = -1;
  while(c1 && c3){
    min = half + i;
    -- i;
  }
  
  for(int j=min; j<=max; ++j){
    if(s[half] == 'L'){
      s[j] = "R";
    }
    else{
      s[j] = "L";
    }
  }
    -- k;
  }
  
  cout << s << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:14: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   29 |       s[j] = "R";
      |              ^~~
      |              |
      |              const char*
a.cc:32:14: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   32 |       s[j] = "L";
      |              ^~~
      |              |
      |              const char*
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt=0,cnt2=0,num=0;
  for(int i=0;i<s.size()-1;i++){
    int num2=0;
    while(i<s.size()-1&&s[i]==s[i+1]){
      i++;
      num2++;
    }
    if(s[i]=='R'&&s[i+1]=='L')	cnt++;
    num+=num2;
  }
  cnt2+=(s[0]=='L'?1:0);
  cnt2+=(s[n-1]=='R'?1:0);
  int N=num+2*min(k,cnt)+min(2,max(0,k-cnt));
  cout << (N==n?N-1:N) << endl;
  return 0;
}

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

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

int main() {
  int N, K;
  cin >> N >> K;
  string S, SS;
  cin >> S;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (N == 2) {
    if (S[0] == S[1] || K >= 1)
      cout << 1 << endl;
    else
      cout << 0 << endl;
    return 0;
  }

  SS += S[0];
  int ans = 0;
  for (int i = 1; i < N; i++) {
    if (S[i] == S[i - 1])
      ans++;
    else
      SS += S[i];
  }
  ans += 2 * min(((int)SS.size() - 2), K);
  ans += min(max((K - ((int)SS.size() - 2), 0)), SS[0] != SS[SS.size() - 1]);
  cout << ans << endl;
}


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

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    cout << n - max(unique(s.begin(), s.end()) - s.begin() - 2 * k, 1) << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:20: error: no matching function for call to 'max(__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >::difference_type, int)'
   14 |     cout << n - max(unique(s.begin(), s.end()) - s.begin() - 2 * k, 1) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:14:20: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   14 |     cout << n - max(unique(s.begin(), s.end()) - s.begin() - 2 * k, 1) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:14:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   14 |     cout << n - max(unique(s.begin(), s.end()) - s.begin() - 2 * k, 1) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using ll = long long;
using namespace std;


int main() {
    int N, K;
    int ans = 0;
  	string S;
    cin >> N >> K >> S;
	for(int i = 0; i < N-1; i++){
      if(S[i] == S[i+1]){
        ans++;
      }
    }
  	ans += 2*K;
  	cout << min(N-1, ans) << endl;
  	return 0;
}
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>
using ll = long long;
using namespace std;


int main() {
    int N, K;
    int ans = 0;
  	string S;
    cin >> N >> K >> S;
	for(int i = 0; i < N-1; i++){
      if(S[i] == S[i+1]){
        ans++;
      }
    }
  	ans += 2*K;
  	cout << min(N-1, ans) << endl;
  	return 0;
}


Compiler output:
a.cc:39:5: error: redefinition of 'int main()'
   39 | int main() {
      |     ^~~~
a.cc:13:5: note: 'int main()' previously defined here
   13 | int main() {
      |     ^~~~