Language: C++

#include<iostream>
#include<vector>

int main(){
  int N;
  cin >> N;
  vector<string> w(N);
  
  for(int i = 0; i < N; i++) cin >> w[i];
  int f = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(i == j) continue;
      if(w[i] == w[j]) f = 1;
    }
  }
  
  for(int i = 1; i < N; i++){
    if(w[i-1][[w[i-1].length() - 1]] != w[i][[w[i].length() - 1]]) f = 1;
  }
  if(f) cout << "No";
  else cout << "Yes";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 |   cin >> N;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:7:3: error: 'vector' was not declared in this scope
    7 |   vector<string> w(N);
      |   ^~~~~~
a.cc:7:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:7:10: error: 'string' was not declared in this scope
    7 |   vector<string> w(N);
      |          ^~~~~~
a.cc:7:10: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:18: error: 'w' was not declared in this scope
    7 |   vector<string> w(N);
      |                  ^
a.cc:19:14: error: two consecutive '[' shall only introduce an attribute before '[' token
   19 |     if(w[i-1][[w[i-1].length() - 1]] != w[i][[w[i].length() - 1]]) f = 1;
      |              ^
a.cc:19:14: error: expected ')' before '[' token
   19 |     if(w[i-1][[w[i-1].length() - 1]] != w[i][[w[i].length() - 1]]) f = 1;
      |       ~      ^
      |              )
a.cc:21:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   21 |   if(f) cout << "No";
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:22:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |   else cout << "Yes";
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~