Go: package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	_, _ = fmt.Scan(&n)
	_, _ = fmt.Scan(&s)
	fmt.Println(calc(s))
}

func calc(s string) int {
	sum := 0
	ss := strings.Split(s,"")
	bf := 0
	for _, v := range ss{
		if bf == 0 {
			bf = cnv(v)
		} else if bf != cnv(v) {
			sum++
			bf = 0
		}
	}
	return sum
}

func cnv(s string) int {
	switch s {
	case "O":
		return 1
	case "X":
		return 2
	}
	return 0
}

C++: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int m=0;
    int ans=0;
    int cnt=0;
    while(m<n-1){
        if(s[m]!=s[m+1]){
            ans++;
            m+=2;
        }else{
            m++;
        }
    }
    m=n-1;
    while(m>0){
        if(s[m]!=s[m-1]){
            cnt++;
            m-=2;
        }else{
            m--;
        }
    }
    cout<<max(cnt,ans)<<endl;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int a=0;
    int e=1;
    int f=2;
    int z=0;
    cin>>a;
    char b[a];
    int d[a];
    for(int i=1;i<=a;i++){
        cin>>b[i];
    }
    for(int i=1;i<=a;i++){
        if(b[i]=='O'){
            d[i]=1;
        }else{
            if(b[i]=='X'){
                d[i]=2;
            }
        }
    }
    while(f<=a){
        if(d[e]+d[f]==3){
            z++;
            e=e+2;
            f=f+2;
        }else{
            e++;
            f++;
        }
    }
    cout<<z<<endl;
}

C++: #include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int dp[100001];

int main()
{
  int N;
  string S;

  cin >> N;
  cin.ignore();
  cin >> S;

  for (int i = 1; i <= N; i++) {
    dp[i] = max(dp[i], dp[i - 1]);
    if (S[i] != S[i - 1] && i <= N - 1) {
      dp[i + 1] = max(dp[i + 1], dp[i - 1] + 1);
    }
  }
  cout << dp[N] << endl;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,flg[100001]={0},cnt,i;
	char s[100001];
	scanf("%d %s",&n,s);
	cnt=0;
	for(i=0;i<n-1;i++){
		if(s[i]!=s[i+1]&&flg[i]==0){
			cnt++;
			flg[i+1]=1;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

C++: #include<stdio.h> 
#include<iostream>
using namespace std;
int main() {
	int x=0, o=0, i, num, xo=0, g=0;
	char m[1000001];
	scanf("%d", &num);

	cin >> m;
	
	for (i = 0; i < num-1; i++) {
		if (m[i] == 'X' && m[i + 1] == 'O' || m[i] == 'O' && m[i + 1] == 'X') {
			xo++;
			i++;
		}
	}
	
	printf("%d\n", xo);
	return 0;
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    bool cnt = false;
    int ret = 0;
    for(int i = 0;i < N - 1;i++) {
        if(cnt == true) {
            cnt = false;
            continue;
        }
        if((S.at(i) == 'O' && S.at(i + 1) == 'X') || (S.at(i) == 'X' && S.at(i + 1) == 'O')) {
            ret++;
            cnt = true;
        }
    }
    cout << ret << endl;
}

C++: #include<iostream>
#include<stdio.h>

using namespace std;

int main(){
	int N;
	int ans = 0;
	cin >> N;
	char S[100001];
	for (int i = 1; i <= N; i++){
		cin >> S[i];
	}
	for (int j = 1; j <= N; j++){
		if (S[j] == 'X'&&S[j + 1] == 'O'){
			S[j] = {};
			S[j + 1] = {};
			ans++;
		}
		else if (S[j] == 'O'&&S[j + 1] == 'X'){
			S[j] = {};
			S[j + 1] = {};
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n, ans;
string s;
int main()
{
    cin >> n >> s;
    for (int i = 0; i + 1 < n; i++)
    {
        if ((s[i] == 'O' && s[i + 1] == 'X') || (s[i] == 'X' && s[i + 1] == 'O'))
            ans++, i++;
    }
    cout << ans << endl;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int idx = 0;
  int ans = 0;
  while(idx + 1 < N){
    if(S[idx] != S[idx + 1]){
      idx += 2;
      ans++;
    }else{
      idx++;
    }
  }
  cout << ans << "\n";
  return 0;
}

C++: #include <iostream>
using namespace std;

int main(void){
    int N;
    char S[100010];
    cin>>N;
    cin>>S;
    int count=0;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1]){
            count++;
            i++;
        }
    }
    cout<<count<<endl;
    return 0;

}

C++: #include <bits/stdc++.h>
#define INF 1e9
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;

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

    string com;
    int n, c;
    cin>>n;
    string s;
    cin>>s;
    int mb = 0;

    for(int i = 0; i < n-1; i++){
        if((s[i] == 'O' && s[i+1] == 'X') || (s[i] == 'X' && s[i+1] == 'O')){
            mb += 1;
            i++;
        }
    }
    cout<<mb<<endl;
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;
int main(){
char s[100001];
int n,cnt=0;
cin >> n;
for(int i=0;i<n;i++){
cin >> s[i];
}
for(int i=0;i<n;i++){
if(s[i]=='O' && s[i+1]=='X' || s[i]=='X'&& s[i+1]=='O'){
i++;
cnt++;
}
}
cout << cnt << endl;

return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;



int main() {
	int n;
	string s;

	cin >> n >>  s;

	char prev = ' ';

	int ans = 0;

	for (char c : s) {
		if (prev == ' ') {
			prev = c;
		} else if (prev == 'O' && c == 'X') {
			prev = ' ';
			ans++;
		} else if (prev == 'X' && c == 'O') {
			prev = ' ';
			ans++; 
		}
	}
	cout << ans << endl;

	return 0;
}

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, ans = 0;
    string s; cin >> n >> s;

    for (int i = 0; i < n;) {
        if (s[i] == 'O' && s[i+1] == 'X') {
            ans++;
            i += 2;
        } else if (s[i] == 'X' && s[i+1] == 'O') {
            ans++;
            i += 2;
        } else {
            i++;
        }
    }

    cout << ans << endl;
}

C++: #include <iostream>
#include <string>
#include <limits>

using namespace std;
int main()
{
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    string S;
    cin >> S;
    int c = 0;
    for (int i = 1; i < S.size(); i++)
    {
        S[i - 1] != S[i] && (c++, i++);
    }
    cout << c << endl;
}