Language: C++

import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S1 = sc.next();
        String S2 = sc.next();
        final int Mod = 1000000007; // about 1e9
        int left=0;
        long cur = 3;
        if(S1.charAt(0)!=S2.charAt(0)){
            left=1;
            cur = 6;
        }
        int right = left+1;
        while(right<N){
            if(S1.charAt(right)!=S2.charAt(right)) right++;
            if(right==left+1){
                if(S1.charAt(left)!=S2.charAt(left)) cur = cur;
                else{
                    cur = (2*cur)%Mod;
                }
            }
            else{
                if(S1.charAt(left)!=S2.charAt(left)) cur = (3*cur)%Mod;
                else cur = (2*cur)%Mod;
            }
            left = right;
            right++;
        }
        System.out.println(cur);
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:11: error: expected ':' before 'static'
    4 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:4:29: error: 'String' has not been declared
    4 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:4:38: error: expected ',' or '...' before 'args'
    4 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:34:2: error: expected ';' after class definition
   34 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:9: error: 'Scanner' was not declared in this scope
    5 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:6:17: error: 'sc' was not declared in this scope
    6 |         int N = sc.nextInt();
      |                 ^~
a.cc:7:9: error: 'String' was not declared in this scope
    7 |         String S1 = sc.next();
      |         ^~~~~~
a.cc:8:16: error: expected ';' before 'S2'
    8 |         String S2 = sc.next();
      |                ^~
a.cc:9:9: error: 'final' was not declared in this scope
    9 |         final int Mod = 1000000007; // about 1e9
      |         ^~~~~
a.cc:12:12: error: 'S1' was not declared in this scope
   12 |         if(S1.charAt(0)!=S2.charAt(0)){
      |            ^~
a.cc:12:26: error: 'S2' was not declared in this scope
   12 |         if(S1.charAt(0)!=S2.charAt(0)){
      |                          ^~
a.cc:18:16: error: 'S1' was not declared in this scope
   18 |             if(S1.charAt(right)!=S2.charAt(right)) right++;
      |                ^~
a.cc:18:34: error: 'S2' was not declared in this scope
   18 |             if(S1.charAt(right)!=S2.charAt(right)) right++;
      |                                  ^~
a.cc:20:20: error: 'S1' was not declared in this scope
   20 |                 if(S1.charAt(left)!=S2.charAt(left)) cur = cur;
      |                    ^~
a.cc:20:37: error: 'S2' was not declared in this scope
   20 |                 if(S1.charAt(left)!=S2.charAt(left)) cur = cur;
      |                                     ^~
a.cc:22:35: error: 'Mod' was not declared in this scope
   22 |                     cur = (2*cur)%Mod;
      |                                   ^~~
a.cc:26:20: error: 'S1' was not declared in this scope
   26 |                 if(S1.charAt(left)!=S2.charAt(left)) cur = (3*cur)%Mod;
      |                    ^~
a.cc:26:37: error: 'S2' was not declared in this scope
   26 |                 if(S1.charAt(left)!=S2.charAt(left)) cur = (3*cur)%Mod;
      |                                     ^~
a.cc:26:68: error: 'Mod' was not declared in this scope
   26 |                 if(S1.charAt(left)!=S2.charAt(left)) cur = (3*cur)%Mod;
      |                                                                    ^~~
a.cc:27:36: error: 'Mod' was not declared in this scope
   27 |                 else cur = (2*cur)%Mod;
      |                                    ^~~
a.cc:32:9: error: 'System' was not declared in this scope
   32 |         System.out.println(cur);
      |         ^~~~~~