Language: C++

import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String line;
	int[] flag = new int['Z'];
	int oi = 0;
	try{
	    while(null!=(line = br.readLine())){
		while((oi = line.indexOf("OI")) != -1){
		    flag[line.charAt(oi-1)]++;
		    line = line.substring(oi + 1);
		}
		System.out.println(flag['J']);
		System.out.println(flag['I']);
		flag['J'] = flag['I'] = 0;
	    }
	}
	catch(Exception e){
	    System.out.println(e.getMessage() + oi);
	}
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:11: error: expected ':' before 'static'
    5 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:5:29: error: 'String' has not been declared
    5 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:5:38: error: expected ',' or '...' before 'args'
    5 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:25:2: error: expected ';' after class definition
   25 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:6:9: error: 'BufferedReader' was not declared in this scope
    6 |         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      |         ^~~~~~~~~~~~~~
a.cc:7:9: error: 'String' was not declared in this scope
    7 |         String line;
      |         ^~~~~~
a.cc:8:12: error: structured binding declaration cannot have type 'int'
    8 |         int[] flag = new int['Z'];
      |            ^~
a.cc:8:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:12: error: empty structured binding declaration
a.cc:8:15: error: expected initializer before 'flag'
    8 |         int[] flag = new int['Z'];
      |               ^~~~
a.cc:11:19: error: 'null' was not declared in this scope
   11 |             while(null!=(line = br.readLine())){
      |                   ^~~~
a.cc:11:26: error: 'line' was not declared in this scope
   11 |             while(null!=(line = br.readLine())){
      |                          ^~~~
a.cc:11:33: error: 'br' was not declared in this scope
   11 |             while(null!=(line = br.readLine())){
      |                                 ^~
a.cc:13:21: error: 'flag' was not declared in this scope
   13 |                     flag[line.charAt(oi-1)]++;
      |                     ^~~~
a.cc:16:17: error: 'System' was not declared in this scope
   16 |                 System.out.println(flag['J']);
      |                 ^~~~~~
a.cc:16:36: error: 'flag' was not declared in this scope
   16 |                 System.out.println(flag['J']);
      |                                    ^~~~
a.cc:21:15: error: 'Exception' does not name a type
   21 |         catch(Exception e){
      |               ^~~~~~~~~
a.cc:22:13: error: 'System' was not declared in this scope
   22 |             System.out.println(e.getMessage() + oi);
      |             ^~~~~~
a.cc:22:32: error: 'e' was not declared in this scope
   22 |             System.out.println(e.getMessage() + oi);
      |                                ^