Language: C++

//package aoj;

import java.util.Scanner;
import java.util.Stack;

class Main {
    public static boolean solve(String sentence) {
        Stack<Character> stk = new Stack<>();
        for (int i = 0; i < sentence.length(); i++) {
            if(sentence.charAt(i) == '[' || sentence.charAt(i) == '(') stk.push(sentence.charAt(i));
            else if(sentence.charAt(i) == ']') {
                if(stk.empty()) return false;
                if(stk.peek() != '[') return false;
                stk.pop();
            }
            else if(sentence.charAt(i) == ')') {
                if(stk.empty()) return false;
                if(stk.peek() != '(') return false;
                stk.pop();
            }
        }
        return stk.empty();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            String sentence = sc.nextLine();
            System.out.println(solve(sentence) ? "yes" : "no");
        }
    }
}



Compiler output:
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.Stack;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:11: error: expected ':' before 'static'
    7 |     public static boolean solve(String sentence) {
      |           ^~~~~~~
      |           :
a.cc:7:19: error: 'boolean' does not name a type; did you mean 'bool'?
    7 |     public static boolean solve(String sentence) {
      |                   ^~~~~~~
      |                   bool
a.cc:25:11: error: expected ':' before 'static'
   25 |     public static void main(String[] args) {
      |           ^~~~~~~
      |           :
a.cc:25:29: error: 'String' has not been declared
   25 |     public static void main(String[] args) {
      |                             ^~~~~~
a.cc:25:38: error: expected ',' or '...' before 'args'
   25 |     public static void main(String[] args) {
      |                                      ^~~~
a.cc:32:2: error: expected ';' after class definition
   32 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:26:9: error: 'Scanner' was not declared in this scope
   26 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:27:15: error: 'sc' was not declared in this scope
   27 |         while(sc.hasNext()) {
      |               ^~
a.cc:28:13: error: 'String' was not declared in this scope
   28 |             String sentence = sc.nextLine();
      |             ^~~~~~
a.cc:29:13: error: 'System' was not declared in this scope
   29 |             System.out.println(solve(sentence) ? "yes" : "no");
      |             ^~~~~~
a.cc:29:38: error: 'sentence' was not declared in this scope
   29 |             System.out.println(solve(sentence) ? "yes" : "no");
      |                                      ^~~~~~~~
a.cc:29:32: error: 'solve' was not declared in this scope
   29 |             System.out.println(solve(sentence) ? "yes" : "no");
      |                                ^~~~~