Go: package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	for i := 0; i < n; i++ {
		base := [3]bool{}
		score, out := 0, 0
		for stdin.Scan() {
			switch stdin.Text() {
			case "HIT":
				if base[2] { // 3塁
					score++
				}
				if base[1] { // 2塁
					base[2] = true
					base[1] = false
				}
				if base[0] { // 1塁
					base[1] = true
				}
				base[0] = true
			case "HOMERUN":
				for i := 0; i < 3; i++ {
					if base[i] {
						score++
						base[i] = false
					}
				}
				score++
			case "OUT":
				out++
			}
			if out >= 3 {
				fmt.Println(score)
				break
			}
		}
	}
}

Python: class Baseball:

	def __init__(self, score = 0):
		self.inning = Inning()
		self.game_score = score

	# def get_game_score(self):
	# 	return self.game_score

	def change(self):
		del self.inning
		self.inning = Inning()

	def batting(self, event):
		if event == 'HIT':
			self.inning.hit()
		elif event == 'HOMERUN':
			self.inning.homerun()
		elif event == 'OUT':
			self.inning.out()
		else:
			print('Error')

	def check_outcnt(self):
		return bool(self.inning.get_outcnt() != 3)

	# def update_score(self):
	# 	self.game_score += self.inning.get_score()

	def run(self):
		while self.check_outcnt():
			self.batting(input())
		# self.update_score()
		print(self.inning.get_score())
		self.change()


class Inning:

	def __init__(self, score = 0, outcnt = 0):
		self.base = Base()
		self.score = score
		self.outcnt = outcnt

	def hit(self):
		self.score += self.base.update(1)

	def homerun(self):
		self.score += self.base.update(4)
		self.base.clear()

	def out(self):
		self.outcnt += 1

	def get_outcnt(self):
		return self.outcnt

	def get_score(self):
		return self.score


class Base:
	def __init__(self):
		self.runner = [0, 0, 0]
	
	def update(self, num):
		score = 0
		for _ in range(num):
			score += self.runner.pop(0)
			self.runner.append(1)
		return score

	def clear(self):
		self.runner = [0, 0, 0]

def main():
	game = Baseball()
	for _ in range(int(input())):
		game.run()

if __name__ == '__main__':
	main()

Python: N = int(input())

for i in range(N):
    run = out = point = 0
    while True:
        result = input()
        if result == "HIT":
            run += 1
            if run >= 4:
                point += 1
                run = 3
        elif result == "HOMERUN":
            point += (run + 1)
            run = 0
        else:
            out += 1
            if out == 3:
                break;
    print(point)

Python: n = int(input())
for i in range(n):
    out = 0
    cnt = 0
    ro = [0for i in range(3)]
    while True:
        o = str(input())
        if (o == 'HIT'):
            cnt += ro[2]
            ro = [1] + ro[:2]
        elif (o == 'OUT'):
            out += 1
        elif (o == 'HOMERUN'):
            cnt += (sum(ro)+1)
            ro = [0for i in range(3)]
        if (out == 3):
            print(cnt)
            break

Python: gameCount = int(input())
output = []

for lp in range(gameCount):

    hitCount = 0
    outCount = 0
    score = 0

    while outCount < 3:

        content = input()

        if content == "HIT":
            if hitCount < 3:
                hitCount += 1
            else:
                score += 1
        elif content == "HOMERUN":
            score += hitCount
            score += 1
            hitCount = 0
        else:
            outCount += 1

    output.append(str(score))

print("\n".join(output))

Python: n=int(input())
b=[0]*3;s=o=0
while n:
    e=input()
    if len(e)>3:s+=sum(b)+1;b=[0]*3
    elif e[0]=='H':
        if b.pop():s+=1
        b=[1]+b
    else:
        o+=1
        if o==3:n-=1;b=[0]*3;print(s);o=s=0

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int hit=0;
  int ining=0;
  int ining2=0;
  int out=0;
  int team[100]={0};
  int a=0;
  string ivent;
  cin>> ining;
  ining2=ining;
  while(ining){
    cin>> ivent;
    if(ivent=="OUT"){
      out++;
    }
    else if(ivent=="HIT"){
      hit++;
    }
    else{
      team[a]+=hit+1;
      hit=0;
    }
    if(hit>3){
      team[a]++;
      hit--;
    }
    if(out>=3){
      out=0;
      hit=0;
      ining--;
      a++;
    }
  }
  for(int i=0;i<ining2;i++){
  cout<< team[i]<< endl;
  }
}

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

int main(){
  int n,ansc=0,count=0,count1=0,count2=0,count3=0;
  string event[100];
  cin>>n;
  int i=0;
  while(1){
    cin>>event[i];
    if(event[i]=="OUT"){
      count++;
      count3++;
    }
    if(event[i]=="HIT")count1++;
    if(event[i]=="HOMERUN")count2++;
    if(count3==3*n)break;

    if(count==3){
      count=0;
      count1=0;
      count2=0;
    }
    else if(count2==1){
      ansc+=count1+1;
      count1=0;
      count2=0;
    }
    else if(count1==4){
      ansc++;
      count1--;
    }
    i++;
  }
    cout<<ansc<<endl;
  return 0;
}

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



int main(void){
	int num;
	std::cin >> num;

	std::string event;
	int out = 0, runner = 0, point = 0;
	for(int i = 0; i < num; ++i){
		while(out < 3){
			std:: cin >> event;

			if(event == "OUT"){
				++out;		
			}else if(event == "HIT"){
				if(runner == 3){
					++point;
				}else{
					++runner;
				}
			}else if(event == "HOMERUN"){
				point += runner + 1;
				runner = 0;
			}
		}
		std::cout << point << std::endl;
		out = 0, runner = 0, point = 0;
	}

	return 0;
}

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

using namespace std;

int main(void){
	int game;
	cin >> game;
	for(int i = 0; i < game; i++){
		int out = 0;
		int base = 0;
		int point = 0;
		string n;
		while(out < 3){
			cin >> n;
			if(n == "HIT"){
				base++;
				if(base == 4)
				point++;
			}else if(n == "OUT"){
				out++;
			}else if(n == "HOMERUN"){
				point += base + 1;
			}
		}
		cout << point << endl;
	}
	
	return 0;
}

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

int main(void){
	int n;
	cin>>n;

	while(n--){
		int out = 0;
		int first=0,second=0,third=0,score=0;
		while(out < 3){
			string s;
			cin>>s;
			if(s == "HIT"){
				score += third;
				third = second;
				second = first;
				first = 1;
			}
			else if(s == "HOMERUN"){
				score += third + second + first + 1;
				third = second = first = 0;
			}
			else{
				out++;
			}
		}
		cout<<score<<endl;
	}

	return 0;
}

C++: #include <stdio.h>
int main() {char T[20];int N,pnt,ot,base;while (scanf("%d",&N)!=EOF) {while (N--) {pnt=ot=base=0;while (1) {scanf("%s",&T);if (T[0]=='O') ot++; else if (T[1]=='O') pnt+=base+1,base=0; else base++,pnt+=((base&4)?1:0),base-=((base==4)?1:0);if (ot==3) printf("%d\n",pnt),pnt=ot=base=0;}}} return 0;}

C++: #include<stdio.h>

int main(void){

	int i,j,k,q,p,inning,point,kazu[20];
	char eve[10];
	
		point=0;
		j=0;
		k=0;
		q=0;
		p=0;	
	
		scanf("%d",&inning);
		
		for(k=0;k<inning;k++){
		
			point=0;
			j=0;
			q=0;
			p=0;
			
		while(q<3){
		
			for(j=0;j<10;j++){
				eve[j]=0;
			}
			
			gets(eve);
			
			if(eve[0]=='O'){
				if(eve[1]=='U'){
					if(eve[2]=='T'){
						q++;
					}
				}		
			}
			if(eve[0]=='H'){
				if(eve[1]=='I'){
					if(eve[2]=='T'){
						p++;
						if(p>=4){
							point++;
						}
					}
				}
			}		
			
			if(eve[0]=='H'){
				if(eve[1]=='O'){
					if(eve[2]=='M'){
						if(eve[3]=='E'){
							if(eve[4]=='R'){
								if(eve[5]=='U'){
									if(eve[6]=='N'){
										point=point+p+1;
										p=0;
									}
								}
							}
						}		
					}
				}
			}
		}		
		kazu[k]=point;
	}
	for(k=0;k<inning;k++){
		printf("%d\n",kazu[k]);
	}
	return 0;
}