Language: C++

import java.util.*;
class Abc109b
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        String[] s = new String[N];

        for(int i = 0; i < N; i++){
            s[i] = sc.next();
        }

        String ans = "Yes";
        for(int i = 0; i < N-1; i++){
            if(s[i].charAt(s[i].length() - 1) != s[i+1].charAt(0)){
                ans = "No";
                //System.out.println(s[i]);
                break;
            }
        }
        for(int i = 0; i < N - 1; i++)
        {
            for(int j = i+1; j < N; j++){
                boolean bl = true;
                int k = 0;
                while(bl == true && s[i].length() == s[j].length() && k < s[i].length()) {
                    if(s[i].charAt(k) != s[j].charAt(k)){
                        bl = false;
                    }
                    k++;
                }
                if(bl == true){
                    ans = "No";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

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:42:2: error: expected ';' after class definition
   42 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Abc109b::main(int*)':
a.cc:6:9: error: 'Scanner' was not declared in this scope
    6 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:8:17: error: 'sc' was not declared in this scope
    8 |         int N = sc.nextInt();
      |                 ^~
a.cc:9:9: error: 'String' was not declared in this scope
    9 |         String[] s = new String[N];
      |         ^~~~~~
a.cc:9:16: error: expected primary-expression before ']' token
    9 |         String[] s = new String[N];
      |                ^
a.cc:12:13: error: 's' was not declared in this scope
   12 |             s[i] = sc.next();
      |             ^
a.cc:15:16: error: expected ';' before 'ans'
   15 |         String ans = "Yes";
      |                ^~~
a.cc:17:16: error: 's' was not declared in this scope
   17 |             if(s[i].charAt(s[i].length() - 1) != s[i+1].charAt(0)){
      |                ^
a.cc:18:17: error: 'ans' was not declared in this scope
   18 |                 ans = "No";
      |                 ^~~
a.cc:26:17: error: 'boolean' was not declared in this scope; did you mean 'bool'?
   26 |                 boolean bl = true;
      |                 ^~~~~~~
      |                 bool
a.cc:28:23: error: 'bl' was not declared in this scope; did you mean 'bool'?
   28 |                 while(bl == true && s[i].length() == s[j].length() && k < s[i].length()) {
      |                       ^~
      |                       bool
a.cc:28:37: error: 's' was not declared in this scope
   28 |                 while(bl == true && s[i].length() == s[j].length() && k < s[i].length()) {
      |                                     ^
a.cc:34:20: error: 'bl' was not declared in this scope; did you mean 'bool'?
   34 |                 if(bl == true){
      |                    ^~
      |                    bool
a.cc:35:21: error: 'ans' was not declared in this scope
   35 |                     ans = "No";
      |                     ^~~
a.cc:40:9: error: 'System' was not declared in this scope
   40 |         System.out.println(ans);
      |         ^~~~~~
a.cc:40:28: error: 'ans' was not declared in this scope
   40 |         System.out.println(ans);
      |                            ^~~