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++: #include <iostream>
#include <string>
using namespace std;

int main()
{
	int n, m = 0;
	string s;

	cin >> n >> s;

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

	cout << m << endl;
	
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n+1, 0);
    rep(i, 1, n)
    {
        int ox = 0;
        if (s[i] != s[i-1]) ox = 1;
        dp[i+1] = max(dp[i-1]+ox, dp[i]);
    }
    cout << dp[n] << endl;
    return 0;
}

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

int main() {
	int N, ans = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N - 1; ++i) {
		if ("OX" == S.substr(i, 2) || "XO" == S.substr(i, 2)) {
			++ans;
			++i;
		}
	}
	cout << ans << endl;
}

C++: #include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include<cmath>
using namespace std;

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

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

#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    ll n;
    string s;
    cin >> n >> s;

    auto pre = s[0];
    auto ans = 0;
    FOR(i, 1, n) {
        if (pre != s[i]) {
            ++ans;
            if (i != n - 1) {
                pre = s[i + 1];
                ++i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

C++: //john_doe 

#include <iostream>
#include <vector>
#include <string>
int main(){
    int N;
    std::cin>>N;

    std::string S;
    std::cin>>S;

    int cnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='O'&&S[i-1]=='X'){
            cnt++;
        }else if(S[i]=='O'&&S[i+1]=='X'){
            cnt++;
            S[i+1]='-';
        }
    }
    std::cout<<cnt<<'\n';
    return 0;
}

C++: #include <stdio.h>
#include<vector>
#include<iostream>
#include<string>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<cmath>
using namespace std;


int main() {
	int n;
	string s;
	int ans=0;
	int pre = 0;//0=比較対象なし 1=〇 2=×

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

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

C++: #include<iostream>//aoj654
using namespace std;
int main(void)
{
	int n,i=0,cnt=0;
	char s[100000];
	cin>>n>>s;
	while(i<n-1){
		if(s[i]!=s[i+1]){cnt+=1; i+=2;}
		else i++;
	}
	cout<<cnt<<endl;	
	return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (S.substr(i, 2) == "OX" || S.substr(i, 2) == "XO")
      ++ans, ++i;
  }
  cout << ans << endl;
}

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

string S; int dp[100009], n;

int main() {
	cin >> n >> S;
	for (int i = 0; i <= 100000; i++) dp[i] = -(1 << 30);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i < n - 1) {
			if (S[i] != S[i + 1]) dp[i + 2] = max(dp[i + 2], dp[i] + 1);
		}
		dp[i + 1] = max(dp[i + 1], dp[i]);
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main(){
    int ans=0,sum=0;
    int n;
    string s;
    cin >>n>>s;

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

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}

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

C++: #include <cmath>
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

int main()
{
    const int    N(cin2var<int>());
    const string S(cin2var<string>());
    string       line(S);
    line.resize(N);
    int count = 0;
    while (true) {
        const auto iteOX(line.find("OX"));
        const auto iteXO(line.find("XO"));
        if (iteOX == string::npos && iteXO == string::npos) break;
        const auto iteMin(min(iteOX, iteXO));
        line = line.substr(iteMin + 2);
        ++count;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n + 1);
    for (int i = 0; i < n; ++i) {
        if (i && s[i] != s[i - 1]) {
            dp[i + 1] = max(dp[i], dp[i - 1] + 1);
        }
        else {
            dp[i + 1] = dp[i];
        }
    }
    cout << dp[n] << '\n';
    return 0;
}

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

using namespace std;

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

  int n_stamp;
  cin >> n_stamp;

  string s;
  cin >> s;

  int cnt = 0;
  for (int i = 0; i < n_stamp - 1; i++) {
    // cout << s[i] << endl;
    if (s[i] != s[i + 1]) {
      cnt++;
      i++;
    }
  }

  cout << cnt << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }


void compute() {

}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,(int)s.size()) {
    if( i + 1 < (int)s.size() && s[i] != s[i+1] ) {
      ++cnt;
      ++i;
    }
  }
  cout << cnt << endl;
  compute();
  return 0;
}

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

int count_marubatu(string S, int N)
{
	int sum=0, count;
	rep(i, N-1)
	{
		count = 0;
		while(S[i+count]!=S[i+count+1] && i+count+1<N) count++;
		i += count;
		if(count%2==1) count++;
		sum += count/2;
	}
	return sum;
}

int main(void)
{
    int N;
    cin >> N;
	string S;
	cin >> S;
	int ans = count_marubatu(S, N);
	cout << ans << endl;
}

C++: #include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9+7;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<n-1;i++)
        if(s[i]!=s[i+1])
            ans++,i++;
    cout<<ans<<endl;
}