Go: package main

import (
	"bufio"
	"fmt"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	var inning int

	fmt.Scanf("%d", &inning)

	score := make([]int, inning)

	for i := 0; i < inning; i++ {
		var outCount, runnerCount int

		for scanner.Scan() {
			event := scanner.Text()

			// HIT, HOMERUN, OUT
			switch event {
			case "HIT":
				runnerCount++
				if runnerCount > 3 {
					runnerCount--
					score[i]++
				}
			case "HOMERUN":
				score[i] += runnerCount + 1
				runnerCount = 0
			case "OUT":
				outCount++
			}

			if outCount == 3 {
				break
			}
		}
	}

	for _, v := range score {
		fmt.Println(v)
	}
}

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

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

    string temp; getline(cin, temp);

    for (int n = 0; n != N; ++n) {
        string event;
        int runners = 0, points = 0, out = 0;
        
        while (cin >> event && out < 3) {
            if (event == "HIT") {
                if (runners == 3) {
                    points++;
                }
                runners += (runners + 1) % 3;
            }
            else if (event == "HOMERUN") {
                points += runners + 1;
                runners = 0;
            }
            else if (event == "OUT") {
                out++;
            }
        }
        cout << points << endl;
    }
}

C++: #include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };

int main() {
	int n;
	cin >> n;
	while (n--){
		int point = 0;
		int hit = 0;
		int out = 0;
		string s;
		while (cin >> s){
			if (s == "HIT"){
				if (hit == 3)
					point++;
				if (hit <= 2)
					hit++;
			}
			if (s == "OUT"){
				out++;
				if (out == 3)
					break;
			}
			if (s == "HOMERUN"){
				point += hit + 1;
				hit = 0;
			}
		}
		cout << point<< endl;
	}
}

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

int main()
{
    int n;
    cin>>n;
    while(n){
        string action;
        int base=0,outCount=0,point=0;
        while(outCount!=3){
            cin>>action;
            if(action=="OUT"){
                outCount++;
            }
            else if(action=="HIT"){
                base++;
                if(base==4){
                    point++;
                    base--;
                }
            }
            else if(action=="HOMERUN"){
                point += base+1;
                base=0;
            }
        }
        cout<<point<<endl;
        n--;
    }
    return 0;
}

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

int main()
{
	int point, base, n, out;
	char ibe[10];

	cin >> n;
	for (int k = 0; k < n; k++){
		base = point = out = 0;
		while (out != 3){
	 	 cin >> ibe;
		 if (ibe[0] == 'H' && ibe[1] == 'I' && ibe[2] == 'T'){
			 base++;
			 if (base == 4){
				 base--;
				 point++;
			 }
		 }
		 else if (ibe[0] == 'O'){
			 out++;
		 }
		 else {
			 point += base + 1;
			 base = 0;
		 }
		 cout << base << endl;
		}
		cout << point << endl;
	}
	return (0);
}

C++: #include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	ll cmin = INF, cmax = -1, sum = 0;
	REP(i, n) {
		ll a;
		cin >> a;
		cmin = min(cmin, a);
		cmax = max(cmax, a);
		sum += a;
	}
	cout << cmin << " " << cmax << " " << sum << endl;
	return 0;
}

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

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

    cin.get();

    for (int n = 0; n != N; ++n) {
        string event;
        int runners = 0, points = 0, out = 0;
        
        while (cin >> event && out < 3) {
            if (event == "HIT") {
                if (runners == 3) {
                    points++;
                }
                else {
                    runners++;
                }
            }
            else if (event == "HOMERUN") {
                points += runners + 1;
                runners = 0;
            }
            else if (event == "OUT") {
                out++;
            }
        }
        cout << points << endl;
    }
}

C++: #include <iostream>
#include <array>

class Baseball{
private:
	int point;
	int out;
	int base;   //0:no runner 1:runner
				//home,third,second,first

public:

	Baseball(){
		point = 0;
		out = 0;
		base = 0;
	}

	int point(){
		return point;
	}

	int out(){
		return out;
	}

	int hit(){
		base = (base * 10) + 1;
		
		if(base >= 1000){
			base -= 1000;
			point += 1;
		}
	}

	int home_run(){
		point += 1;
		for(int i = base; i > 0; i /= 10){
			point += i%10;
		}
		base = 0;
	}

	int get_out(){
		out += 1;
	}
	

int main(){

	int N;
	std::cin >> N;

	for(int i = 0; i < N; ++i){
		Baseball baseball();

		while(baseball.out() != 3){
			std::string str;
			cin >> str;

			if(str == "HIT")
				baseball.hit();
			
			else if(str == "HOMERUN")
				baseball.home_run();

			else if(str == "OUT")
				baseball.get_out();

		}

		std::cout >> baseball.point() >> endl;
	}

	return 0;
{

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;
int main() {
	string s;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int r[4] = {}, p=0, o = 0;
		r[0] = 1;
		while (o != 3) {
			cin >> s;
			if (s[1] == 'I') {
				if (r[3])
					p++;
				for (int j = 3; j >= 1; j--)
					r[j] = r[j - 1];
			}
			else if (s[1] == 'U')
				o++;
			else if (s[1] == 'O') {
				p++;
				for (int j = 1; j <= 3; j++) {
					if (r[j]) {
						p++;
						r[j] = 0;
					}
				}
			}
		}
		cout << p << endl;
	}
	return 0;
}