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

#include <bits/stdc++.h>

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i-1]) sum++;
    }
    cout << min(n-1, sum + 2 * k)
    return 0;
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:34:34: error: expected ';' before 'return'
   34 |     cout << min(n-1, sum + 2 * k)
      |                                  ^
      |                                  ;
   35 |     return 0;
      |     ~~~~~~
Language: C++

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map(String::toInt)
    val s = readLine()!!
        .split("")
        .let { it.slice(1 until it.size - 1) }
        .map { if (it == "L") -1 else 1 }

    val result = s.countHappy() + 2 * k
    
    println(if(s.lastIndex < result) s.lastIndex else result)
}

fun List<Int>.countHappy(): Int {
    return this.withIndex().fold(0) { count, elm ->
        val indexFront = elm.index + elm.value
        if (0 <= indexFront && indexFront < this.size && this[indexFront] == elm.value) count + 1 else count
    }
}

Compiler output:
a.cc:1:1: error: 'fun' does not name a type
    1 | fun main(args: Array<String>) {
      | ^~~
a.cc:13:1: error: 'fun' does not name a type
   13 | fun List<Int>.countHappy(): Int {
      | ^~~
Language: C++

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs[m-a].push_back(b);
  }
  piriority_queue<int> q;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    for (int b : jobs[i]) {
      q.push(b);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:3: error: 'piriority_queue' was not declared in this scope
   16 |   piriority_queue<int> q;
      |   ^~~~~~~~~~~~~~~
a.cc:16:19: error: expected primary-expression before 'int'
   16 |   piriority_queue<int> q;
      |                   ^~~
a.cc:20:7: error: 'q' was not declared in this scope
   20 |       q.push(b);
      |       ^
a.cc:22:10: error: 'q' was not declared in this scope
   22 |     if (!q.empty()) {
      |          ^
Language: C++

#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int S = 0, n;
    char a[10000];
    cin >> n;
    cin.ignore();
    cin.getline(a, 10000);
    for(int i = 0; i < n; i++){
        if(a[i] == a[i+1]){
            S++;
        }
    }
    S = min(n - 1, S+k*2);
    cout << S;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:22: error: 'k' was not declared in this scope
   18 |     S = min(n - 1, S+k*2);
      |                      ^
Language: C++

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

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  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;
  return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlude; did you mean #include?
    1 | #inlude<bits/stdc++.h>
      |  ^~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope
    7 |   cin >> n >> k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlude<bits/stdc++.h>
a.cc:8:3: error: 'string' was not declared in this scope
    8 |   string s;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | #inlude<bits/stdc++.h>
a.cc:9:10: error: 's' was not declared in this scope
    9 |   cin >> s;
      |          ^
a.cc:14:13: error: 'min' was not declared in this scope; did you mean 'main'?
   14 |   int ans = min(score+2*k, n-1);
      |             ^~~
      |             main
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout << ans << endl;
      |   ^~~~
a.cc:15:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:15:18: error: 'endl' was not declared in this scope
   15 |   cout << ans << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inlude<bits/stdc++.h>
Language: C++

#include "bits/stdc++.h"

#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

void Main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int num = 1;
  rep(i, n - 1) if (s[i + 1] != s[i])++ num;
  rep(i, k) {
    if (num<2) break;
    num -= 2;
  }
  cout << n - num << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:3:24: error: 'll' was not declared in this scope
    3 | #define rep(i, a) for (ll i = 0; i < (a); ++i)
      |                        ^~
a.cc:14:3: note: in expansion of macro 'rep'
   14 |   rep(i, n - 1) if (s[i + 1] != s[i])++ num;
      |   ^~~
a.cc:14:7: error: 'i' was not declared in this scope
   14 |   rep(i, n - 1) if (s[i + 1] != s[i])++ num;
      |       ^
a.cc:3:34: note: in definition of macro 'rep'
    3 | #define rep(i, a) for (ll i = 0; i < (a); ++i)
      |                                  ^
a.cc:3:24: error: 'll' was not declared in this scope
    3 | #define rep(i, a) for (ll i = 0; i < (a); ++i)
      |                        ^~
a.cc:15:3: note: in expansion of macro 'rep'
   15 |   rep(i, k) {
      |   ^~~
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   rep(i, k) {
      |       ^
a.cc:3:34: note: in definition of macro 'rep'
    3 | #define rep(i, a) for (ll i = 0; i < (a); ++i)
      |                                  ^
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define Rep(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SMALLPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,k,ans=0;cin>>n>>k;
  string s;cin>>s;
  if(s[i]=='L')ans++;
  if(s[n-1]=='R')ans++;
  rep(i,n-1)if(s[i]=='R'&&s[i+1]=='L')ans++;
  if(ans-2*k<=1)cout<<n-1<<endl;
  else cout<<n-(ans-2*k)<<endl;
}


Compiler output:
a.cc:18:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   18 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |            ^~~~
a.cc:18:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   18 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |                    ^~~~
a.cc:19:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   19 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |            ^~~~
a.cc:19:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   19 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:23:8: error: 'i' was not declared in this scope
   23 |   if(s[i]=='L')ans++;
      |        ^
Language: C++

#include <bits/stdc++.h>

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, K;
	string S;
	int count = 0;
	
	cin >> N >> K >> S;
	
	rep(i, N - 1)
		if(S[i] == S[i+1])
			count++;
	
	ans = min(count + 2 * K, N - 1);
	
	cout << ans << endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   23 |         ans = min(count + 2 * K, N - 1);
      |         ^~~
      |         abs
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    
    int score = 0;
    rep(i, n-1) {
    if(s[i] == s[i+1]) {
        score++;
    }

    int ans = min(n-1, score + 2*k);

    cout << ans << endl;
    return 0;
}

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

#include<iostream>
#include<string>
using namespace std;
int main()
{
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	int max = 0;
	int i;
	for (i = 0;i < N;i++)//统计初始max
	{
		if (S[i] == 'L')
			if (i - 1 >= 0 && S[i - 1] == 'L')
				max++;
		if (S[i] == 'R')
			if (i + 1 < N&&S[i + 1] == 'R')
				max++;
	}
	for (i = 0;i < K;i++)
		max += 2;
	if (max > N-1)
		max = N-1;
	cout << max;
	return 0;
}

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

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <memory.h>
#include <vector>
using namespace std;
const int MAXN=1e5+5;
int n,k,t1,t2,p[MAXN],ans;
char s[MAXN];
int main(){
	//freopen("p6.in","r",stdin);
	//freopen("p6.out","w",stdout);
	scanf("%d %d\n",&n,&k);
	gets(s);
	int i,j=0,len=strlen(s);
	for(i=1;i<len;i++){
		if(s[i]==s[i-1])ans++;
		//else p[++p[0]]=i;
		else j++;
	}
	/*i=1;j=p[0];
	while(i<j){
		
	}*/
	j=(j+1)/2;
	if(j<=k)cout<<n-1;
	else cout<<ans+2*k;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   16 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <memory.h>
#include <vector>
using namespace std;
const int MAXN=1e5+5;
int n,k,t1,t2,p[MAXN],ans;
char s[MAXN];
int main(){
	//freopen("p6.in","r",stdin);
	//freopen("p6.out","w",stdout);
	scanf("%d %d\n",&n,&k);
	gets(s);
	int i,j=0,len=strlen(s);
	for(i=1;i<len;i++){
		if(s[i]==s[i-1])ans++;
		//else p[++p[0]]=i;
		else j++;
	}
	/*i=1;j=p[0];
	while(i<j){
		
	}*/
	j=(j+1)/2;
	if(j<=k)cout<<n-1;
	else cout<<ans+2*k;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   16 |         gets(s);
      |         ^~~~
      |         getw
Language: C++

#include<iostream>
#include<string>
#include<malloc.h>

using namespace std;

int ishappy(string s,int k){
	int len=s.size();
	char direction=s[k];
	if(direction=='L'){
		if(k==0) return 0;
		char front=s[k-1];
		if(front=='L') return 1;
	}
	if(direction=='R'){
		if(k==len-1) return 0;
		char front=s[k+1];
		if(front=='R') return 1;
	}
	return 0;
}

int Cal(string s){
	int sum=0;
	for(int i=0;i<s.size();i++)
	    sum+=ishappy(s,i);
	return sum;
}

string Reverse(string s,int l,int r){
	for(int i=0;i<((r-l)/2);i++){
		char temp= s[r-i-1];
		s[r-i-1]=s[l+i-1];
		s[l+i-1]=temp;
	}
	return s;
}

int main(){
	
    int N,K,*MAX;
    string S,*sen; 
    cin>>N>>K>>S;
    MAX=(int*)malloc(sizeof(int)*K);
    sen=(string*)malloc(sizeof(char)*N*(K+1));
    
    for(int i=0;i<K;i++)
	     MAX[i]=0;

    sen[0]=S;      
    for(int p=0;p<K;p++)
	for(int i=0;i<N;i++){
	   for(int j=i;j<N;j++)
    	string str1=sen[p];
		string str2=Reverse(str1,i,j);
    	int num=Cal(str2);
    	if(num>MAX[p]){
		   MAX[p]=num;
		   sen[p+1]=str2;
		 } 
    }
	
    cout<<MAX[K-1]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:37: error: 'str1' was not declared in this scope; did you mean 'str2'?
   55 |                 string str2=Reverse(str1,i,j);
      |                                     ^~~~
      |                                     str2
a.cc:55:44: error: 'j' was not declared in this scope
   55 |                 string str2=Reverse(str1,i,j);
      |                                            ^
Language: C++

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

int main() {
  int N; cin >> N;
  int K; cin >> K;
  string S; cin >> S;
  int happy = 0;
  
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == s.at(i + 1)) {
      happy++;
    }
  }
  
  happy += 2K;
  
  if (happy >= N) {
    happy = N - 1;
  }
  
  cout << happy << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: 's' was not declared in this scope
   11 |     if (S.at(i) == s.at(i + 1)) {
      |                    ^
a.cc:16:12: error: fixed-point types not supported in C++
   16 |   happy += 2K;
      |            ^~
Language: C++

#include<iostream>
using namesapce std;
int main()
{
    int n, k;
    char *s;
    cin >> n >> k;
    s = new char[n];
    for (int count = 0; count < n; count ++)
        cin >> s[count];
    int count = 0;
    for (int i = 0; i < n-1; i++)
        if(s[i+1] == s[i])
            count ++;
    count = (count + k*2 ) > (n-1) ? n-1 : (count + k*2 );
    cout << count; return 0;
}


Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namesapce'
    2 | using namesapce std;
      |       ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |     cin >> n >> k;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:16:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   16 |     cout << count; return 0;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

//============================================================================
// Name        : A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	string s;
	int N;
	int K;
	cin >> N >> K >> s;
	for (int i = 1; i < N - 1 && K != 0; ++i) {
		if (s[i] != s[i - 1] && s[i] != s[i + 1]) {
			s[i] = s[i + 1];
			--K;
		}
	}

	for (int i = 0; i < N && K != 0; ++i) {
		for (int j = i; j < N; ++j) {
			if (s[i] != s[j]) {
				for (int k = i; k < j; ++k) {
					if(s[k] == 'R')s[k] = 'L';
					else s[k] = 'R';
					s[i] = s[i + 1];
				}
				for (int j = i; j < N; ++j) {
				--K;
			}
		}
	}

	for (int i = 1; i < N - 1 && K != 0; ++i) {
		if (s[i] != s[i - 1] || s[i] != s[i + 1]) {
			s[i] = s[i + 1];
			--K;
		}
	}
	if (s[0] != s[1] && K != 0) {
		s[0] = s[1];
		--K;
	}
	if (s[N - 1] != s[N - 2] && K != 0) {
		s[0] = s[1];
		--K;
	}

	int ans = 0;
	for (int i = 1; i < N - 1; ++i) {
		if (s[i] == 'R' && s[i + 1] == 'R') {
			++ans;
		} else if (s[i] == 'L' && s[i - 1] == 'L') {
			++ans;
		}
	}
	if (s[0] == 'R' && s[1] == 'R')
		++ans;
	if (s[N - 1] == 'L' && s[N - 2] == 'L')
		++ans;
	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:2: error: expected '}' at end of input
   78 | }
      |  ^
a.cc:22:12: note: to match this '{'
   22 | int main() {
      |            ^
Language: C++

#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }


int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	
	vector<int> B;
	B.reserve(N - 1);
	for(int i = 0; i < N - 1; i++) {
		cin >> b;
		B.push_back(b);
	}

	ll result = B[0];
	for(int i = 1; i < N - 1; i++) {
		result += min(B[i - 1], B[i]);
	}
	result += B[N - 2];
	cout << result << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:51:24: error: 'b' was not declared in this scope
   51 |                 cin >> b;
      |                        ^
Language: C++

#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bit s/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


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

	string s;

	cin >> s;

	int gr = 1;
	char pre = s[0];

	for (int i = 1; i < N; i++)
	{
		if (s[i] != pre)
		{
			gr++;
			pre = s[i];
		}
	}
	
	rep(i, K)
	{
		if (gr >= 3)
		{
			gr -= 2;
		}
		else
		{
			gr--;
		}
		
	}

	cout << N - gr << endl;
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    long string s;
    cin >> s;
    int a[n];
    int last = 0;
    int ans = 0;
    int kol = 1;
    for(int i = 0; i<n; ++i){
        if(s[i]=='R')a[i]=1;
        else a[i]=0;
        if(i==0){
            last = a[i];
        }else{
            if(a[i]!=last)kol++;
            else ans++;
            last = a[i];
        }
    }
    if(n>2 && k<n-1){
        ans+= 2* min(k, max(0, kol-2));
        if(k>=kol-2)ans+=1;
        cout << ans ;
    }else{
        if(n == 1)cout << 0;
        else if(n==2) cout << 1;
        else cout << n-1;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:17: error: expected initializer before 's'
    6 |     long string s;
      |                 ^
a.cc:7:12: error: 's' was not declared in this scope
    7 |     cin >> s;
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int main(){
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  int ans = 0;
  rep(i, n - 1){
    if(s[i] == s[i + 1])  ans++;
  }

  int ans = min(ans + 2 * k, n - 1);
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:7: error: redeclaration of 'int ans'
   33 |   int ans = min(ans + 2 * k, n - 1);
      |       ^~~
a.cc:28:7: note: 'int ans' previously declared here
   28 |   int ans = 0;
      |       ^~~
Language: C++

import sys
import math

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())


def main():
    n, k = rinput()
    n -= 1
    s = input()
    ch = 0
    for i in range(n):
        if s[i] == s[i + 1]:
            ch += 1
    print(min(ch + 2 * k, n))
            
        
    
    
    
    
    


main()

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:40: error: expected ')' before '!' token
    9 |   for(int i=1;i<s.length();i++) if(s[i]!s[i-1])count++;
      |                                   ~    ^
      |                                        )
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: expected ')' before '!' token
    9 |   for(int i=1;i<n;i++) if(s[i]!s[i-1])count++;
      |                          ~    ^
      |                               )
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: expected ')' before '!' token
    9 |   for(int i=1;i<n;i++) if(s[i]!s[i-1])count++;
      |                          ~    ^
      |                               )
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:31: error: expected ')' before '!' token
    9 |   for(int i=1;i<n;i++) if(s[i]!s[i-1])count++;
      |                          ~    ^
      |                               )
a.cc:11:21: error: expected ';' before 'count'
   11 |   count=max(count,1)
      |                     ^
      |                     ;
   12 |     count=n-count;
      |     ~~~~~
Language: C

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

int main()
{
	int n, k, max = 0, pcon = 0, p = 0, start = 0, p1 = 0, tr = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	char cy;
	cy = s[0];
	for (auto c : s)
	{

		if (pcon != 0) {
			if (cy != c && max == 0) {
				max = 1;
			}
			else if (max == 1 && cy != c) {
				p += 1;
				max = 0;
			}
			cy = c;
		}
		pcon = 1;
	}
	if (s[0] != s[n - 1]) {
		p1 = 1;
	}
	while (k > 0 && p > 0) {
		start += 2;
		k -= 1;
		p -= 1;
	}
	while (k > 0 && p1 > 0) {
		start += 1;
		k -= 1;
		p1 -= 1;
	}
	pcon = 0;
	cy = s[0];
	for (auto c : s)
	{

		if (pcon != 0) {
			if (cy == c) {
				tr += 1;
			}
			cy = c;
		}
		pcon = 1;
	}
	cout << start + tr;
}

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

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

int main()
{
	int n, k, max = 0, pcon = 0, p = 0, start = 0, p1 = 0, tr = 0;
	cin >> n >> k;
	string s;
	cin >> s;
	char cy;
	cy = s[0];
	for (auto c : s)
	{

		if (pcon != 0) {
			if (cy != c && max == 0) {
				max = 1;
			}
			else if (max == 1 && cy != c) {
				p += 1;
				max = 0;
			}
			cy = c;
		}
		pcon = 1;
	}
	if (s[0] != s[n - 1]) {
		p1 = 1;
	}
	while (k > 0 && p > 0) {
		start += 2;
		k -= 1;
		p -= 1;
	}
	while (k > 0 && p1 > 0) {
		start += 1;
		k -= 1;
		p1 -= 1;
	}
	pcon = 0;
	cy = s[0];
	for (auto c : s)
	{

		if (pcon != 0) {
			if (cy == c) {
				tr += 1;
			}
			cy = c;
		}
		pcon = 1;
	}
	cout << start + tr << endl;
	system("pause");
}

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>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:29: error: 'N' was not declared in this scope
   15 |         for (int i = 0; i < N - 1; i++) {
      |                             ^
Language: C++

#include <iostream>
#include <string>

int main(){
  int n, k;
  string s;
  std::cin >> n >> k >> s;
  
  int ans = 0;
  for(int i = 0; i < n - 1; i++)
    if(s[i] == s[i + 1])
      ans++;
  
  std::cout << (ans + 2 * k < n - 1 ? ans + 2 * k : n - 1) << '\n';
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'string' was not declared in this scope
    6 |   string s;
      |   ^~~~~~
a.cc:6:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:25: error: 's' was not declared in this scope
    7 |   std::cin >> n >> k >> s;
      |                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int n,k;
   string s;
   cin>>n>>k>>s;
   ll cnt=0;
  //区切りをカウント
   for (int i = 0; i < n-1; i++)
   {
       if(s[i]!=s[i+1]) cnt++;
   }
    cout<<n-1-max(0,(cnt-2*k))<<endl;
   
   
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:4: error: 'll' was not declared in this scope
    8 |    ll cnt=0;
      |    ^~
a.cc:12:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   12 |        if(s[i]!=s[i+1]) cnt++;
      |                         ^~~
      |                         int
a.cc:14:22: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |     cout<<n-1-max(0,(cnt-2*k))<<endl;
      |                      ^~~
      |                      int
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int n,k;
   string s;
   cin>>n>>k>>s;
   int cnt=0;
  //区切りをカウント
   for (int i = 0; i < n-1; i++)
   {
       if(s[i]!=s[i+1]) cnt++;
   }
    cout<<n-1-max(0LL,(cnt-2*k))<<endl;
   
   
    return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int n,k;
   string s;
   cin>>n>>k>>s;
   ll cnt=0;
  //区切りをカウント
   for (int i = 0; i < n-1; i++)
   {
       if(s[i]!=s[i+1]) cnt++;
   }
    cout<<n-1-max(0LL,(cnt-2*k))<<endl;
   
   
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:4: error: 'll' was not declared in this scope
    8 |    ll cnt=0;
      |    ^~
a.cc:12:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
   12 |        if(s[i]!=s[i+1]) cnt++;
      |                         ^~~
      |                         int
a.cc:14:24: error: 'cnt' was not declared in this scope; did you mean 'int'?
   14 |     cout<<n-1-max(0LL,(cnt-2*k))<<endl;
      |                        ^~~
      |                        int
Language: C++

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

int main ()
{
  int n,k; cin >> n >> k;
  string s; cin >> s;
  int count = 0;
  for(int i =1 ; i<n ; i++){
  	if(s[i] != s[i-1]){
  		count++;
  	}
  }

  a = n - a - 1;

  cout << min(n-1,a + 2*k);

  return 0;
}


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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:8:14: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
    8 |   len=strlen(s);
      |              ^
      |              |
      |              std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
Language: C

#include <stdio.h>

int n ,k, i, c, p;
int main() {
  scanf("%d%d\n", &n, &k); k* = -2;
  while(i++ < n)if((c = getchar_unlocked()) != p) k++, p = c;
  printf("%d\n", n - (k < 1 ? 1 : k));
  return 0;
}
  

Compiler output:
main.c: In function 'main':
main.c:5:31: error: expected expression before '=' token
    5 |   scanf("%d%d\n", &n, &k); k* = -2;
      |                               ^
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100005;
int n, k;
char str[N];
stack<int> q;

int main() {
    cin>>n>>k;
    scanf("%s", str);
    
    int flag = 0, cnt = 0, i = 0, ans = 0;
    for(;i<n;i++) {
        if(flag == 1) {
            if(str[i] == 'R') {
                cnt ++;
            }else {
                flag = -1;
                ans += (cnt - 1);
                cnt = 1;
                q.push(1);
            }
        }else if(flag == -1) {
            if(str[i] == 'L') {
                cnt ++;
            }else {
                flag = 1;
                ans += (cnt - 1);
                cnt = 1;
                q.push(-1);
            }
        }else {
            flag = (str[i] == 'R') ? 1 : -1;
            cnt = 1;
        }
    }
    ans += (cnt - 1);
    if(flag == 1)q.push(1);
    else q.push(-1);
    //cout<<ans<<q.size()<<endl;
    while(!q.empty() && k-- > 0) {
        if(q.size() == 2) {
            ans ++;
            break;
        }else if(q.size() == 1) {
            break;
        }else {
            flag = q.top();
            q.pop(); q.pop(); q.pop();
            q.push(flag);
            ans += 2;
        }
    }
    cout<<ans<<endl;
}

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 <iostream>
#include <string>

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> N>>K;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:3: error: 'string' was not declared in this scope
    9 |   string S;
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:10:8: error: 'S' was not declared in this scope
   10 |   cin>>S;
      |        ^
a.cc:17:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   17 |   cout<< min(ct+2*K,N-1)<<"\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:17:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   17 |   cout<< min(ct+2*K,N-1)<<"\n";
      |          ^~~
      |          std::min
In file included from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
Language: C++

import sys
N, K = map(int, input().split())
S = input()

count = 0

if N == 1:
    print(0)
    sys.exit()
else:
    for n in range(1, N - 1):
        if S[n] == 'R':
            if S[n + 1] == S[n]:
                count += 1
        elif S[n] == 'L':
            if S[n - 1] == S[n]:
                count += 1

if S[0] == S[1] == 'R':
    count += 1
if S[N - 1] == S[N - 2] == 'L':
    count += 1

ans = min(count + K * 2, N - 1)
print(ans)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  int k;
  string s;
  cin>>k>>s;
  int c=0;
  char last;
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]!=last)
    {
      last=s[i];
      c++;}
    if(s[i]=='L' && s[i-1]=='R')ans++;
    if(s[i]=='R' && s[i-1]=='L')ans++;
  }
  int half=(c-1)/2;
  if(k>half){
    ans=N-1;
  }
  else{
    ans+=2*k;}
  
  cout<<ans<<endl;
  return 0;
}
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'N' was not declared in this scope
   23 |     ans=N-1;
      |         ^
Language: C++

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

#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,k;
    cin>>n>>k;
    string str;
    cin>>str;
    ll i,j;
    bool arr[n];
    for(i=0;i<n;i++){
        if(str[i]=='L')
            arr[i]=0;
        else
            arr[i]=1;
        // cout<<arr[i]<<" ";
    }
    // cout<<"\n";
    ll flag=0;
    i=0;
    j=n-1;
    ll ans=0;
    while(i<=j){
        if(k==0)
            break;        
        
        while(arr[i]==arr[i+1]&&i+1<n && i+1<=j){ ans++; i++;}
        
        while(arr[j]==arr[j-1]&&j-1>=0 i<=j-1){ ans++; j--; }
        // cout<<i<<" "<<j<<"\n";
        if(abs(i-j)==1 && arr[i]!=arr[j] && k){
            cout<<n-1<<endl;
            return 0;
            break;
        }
        
        if(k){
            arr[i]=!arr[i];
            arr[j]=!arr[j];
            k--;
        }
    }
    // cout<<i<<" "<<j<<"\n";
    while(i<=j){
        if(arr[i]==arr[i+1] && i+1<n){
            ans++;
        }
        i++;
    }
    cout<<ans;
    return 0;  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:39: error: expected ')' before 'i'
   40 |         while(arr[j]==arr[j-1]&&j-1>=0 i<=j-1){ ans++; j--; }
      |              ~                        ^~
      |                                       )
a.cc:40:46: error: expected ';' before ')' token
   40 |         while(arr[j]==arr[j-1]&&j-1>=0 i<=j-1){ ans++; j--; }
      |                                              ^
      |                                              ;
Language: C++

#define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
#define FOROFF(var, offset, max) for (ui (var) = (offset); (var) < ((max) + (offset)); ++(var))

using namespace std;

using ui = unsigned int;
using uc = unsigned char;

const static ui NMAX = 100000;
const static ui KMAX = 100000;

static ui N;
static ui K;

static uc Si[NMAX + 2];

ui count_happiness(void) {
  ui res = 0;
  FOROFF(i, 1, N) {
    if (Si[i] == 0) {
      res += (Si[i - 1] == Si[i]) ? 1 : 0;
    } else if (Si[i] == 1) {
      res += (Si[i + 1] == Si[i]) ? 1 : 0;
    }
  }
  return res;
}

void print_people(void) {
  FOROFF(i, 1, N) {
    cout << (Si[i] ? 'R' : 'L');
  }
  cout << endl;
}

ui solve(void) {
  ui res = count_happiness();
  res += K * 2;
  if (N - 1 < res) {
    return N - 1;
  }
  return res;
}

int main(int ac, char **av) {
  cin >> N >> K;
  Si[0] = 1;
  Si[N + 1] = 0;
  FOROFF(i, 1, N) {
    char c;
    cin >> c;
    if (c == 'L') {
      Si[i] = 0;
    } else if (c == 'R') {
      Si[i] = 1;
    }
  }
  cout << solve() << endl;
  return 0;
}


Compiler output:
a.cc: In function 'void print_people()':
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << (Si[i] ? 'R' : 'L');
      |     ^~~~
a.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
a.cc:33:3: error: 'cout' was not declared in this scope
   33 |   cout << endl;
      |   ^~~~
a.cc:33:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:11: error: 'endl' was not declared in this scope
   33 |   cout << endl;
      |           ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define FOR0(var, max) for (ui (var) = 0; (var) < (max); ++(var))
a.cc: In function 'int main(int, char**)':
a.cc:46:3: error: 'cin' was not declared in this scope
   46 |   cin >> N >> K;
      |   ^~~
a.cc:46:3: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:58:3: error: 'cout' was not declared in this scope
   58 |   cout << solve() << endl;
      |   ^~~~
a.cc:58:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:58:22: error: 'endl' was not declared in this scope
   58 |   cout << solve() << endl;
      |                      ^~~~
a.cc:58:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

n, k = map(int,input().split())
s = input()
ng = 0
for i in range(len(s)):
    if(i and s[i] != s[i - 1]):
        ng += 1
ng = max(0, ng - 2 * k)
res = n - 1 - ng
print(res)

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;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define rep(i,n) for(long long i = n-1;i>=0;i--)
#define repp(i,m,n) for(long long i = n-1; i >= m; i--)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N,K;
string S;
bool flag = 0,flag1 = 0;
string T = "";
int ans = 0;
void solve(int X,int Y){
  	T = "";
    repp(i,X+1,Y+1){
      	if(T.size() == 0 && S[i] == 'L') T = 'R';
      	else if(T.size() == 0 && S[i] == 'R') T = 'L';
        else if(S[i] == 'L') T += 'R';
        else T += 'L';
    }
    REPP(i,X+1,Y+1){
      	int p = 0;
        S[i] = T[p];
      	p++;
    }

    flag = 1;
  	ans++;
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N >> K;
    cin >> S;
  	if(S.size() == 1){cout << 0 << endl; return 0;}
  	else if(S.size() == 2){
      	if(S[0] == S[i]){cout << 1 << endl; return 0;}
      	else{cout << 0 << endl; return 0;}
    }
    REP(k,min(K,200)){
        REP(i,S.size()-2){
            flag = 0;
            if(S[i] != S[i+1]){
                REPP(j,i+1,S.size()-1){
                    if(S[j] == S[i+1] && S[j+1] == S[i]){solve(i,j); break;}
                }
            }
          	if(ans == K) break;
        }
    }
    int cnt = 0,maxv = 0,var = 0;
    REP(i,S.size()-1){
      	if(S[i] == S[i+1]) maxv++;
      	else{
          	var = maxv;
          	maxv = 0;
        }
      
        if(S[i] == S[i+1]) cnt++;
    }
  	if(K - ans >= 1 && maxv + var == N-2) cout << N-1 << endl;
    else cout << cnt << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:22: error: 'i' was not declared in this scope
   48 |         if(S[0] == S[i]){cout << 1 << endl; return 0;}
      |                      ^
Language: C++

#include<iostream>
using namespace std;
int ans;
int main(){
	char c1,c2;
	int a,b,c=0,d=0,f=0;
	cin>>a>>b;
	cin>>c2	
	for(int i=0;i<a-1;i++){
		c1=c2;
		cin>>c2;
		if(c1==c2)
			sum++;
		else
			f++;
	}
	if(a>2*b)
		cout<<sum+2*b;
	else
		cout<<sum+a;
  return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:8:16: error: expected ';' before 'for'
    8 |         cin>>c2
      |                ^
      |                ;
    9 |         for(int i=0;i<a-1;i++){
      |         ~~~     
a.cc:9:21: error: 'i' was not declared in this scope
    9 |         for(int i=0;i<a-1;i++){
      |                     ^
a.cc:18:23: error: 'sum' was not declared in this scope
   18 |                 cout<<sum+2*b;
      |                       ^~~
a.cc:20:23: error: 'sum' was not declared in this scope
   20 |                 cout<<sum+a;
      |                       ^~~
Language: C++

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> K;
	string s;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'L') {
			if (i&&s[i - 1] == 'L')M++;
		}
		else {
			if (i + 1 < N&&s[i + 1 == 'R')M++;
		}
	}
	cout << min(N - 1, M + K * 2) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:54: error: expected ']' before ')' token
   48 |                         if (i + 1 < N&&s[i + 1 == 'R')M++;
      |                                                      ^
      |                                                      ]