Language: C++

#include <stdio.h>
#include <string>
#include <iostream>
using std::cin;
using std::string;

int main(void) {
	string s;

	cin >> s;

	switch (s[0], s[1], s[2], s[3]) {
	case s[0] == s[1], s[2] == s[3], s[0] != s[2]:
		printf("Yes");
		break;
	case s[0] == s[2], s[1] == s[3], s[0] != s[1]:
		printf("Yes");
		break;
	case s[0] == s[3], s[1] == s[2], s[0] != s[1]:
		printf("Yes");
		break;
	default:
		printf("No");
	}

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   12 |         switch (s[0], s[1], s[2], s[3]) {
      |                    ^
In file included from /usr/include/c++/14/string:54,
                 from a.cc:2:
/usr/include/c++/14/bits/basic_string.h:1265:7: note: declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:12:26: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   12 |         switch (s[0], s[1], s[2], s[3]) {
      |                          ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:12:32: warning: ignoring return value of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result]
   12 |         switch (s[0], s[1], s[2], s[3]) {
      |                                ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:13:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   13 |         case s[0] == s[1], s[2] == s[3], s[0] != s[2]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:13:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   13 |         case s[0] == s[1], s[2] == s[3], s[0] != s[2]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:13:26: error: expected ':' before ',' token
   13 |         case s[0] == s[1], s[2] == s[3], s[0] != s[2]:
      |                          ^
      |                          :
a.cc:13:26: error: expected primary-expression before ',' token
a.cc:16:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   16 |         case s[0] == s[2], s[1] == s[3], s[0] != s[1]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:16:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   16 |         case s[0] == s[2], s[1] == s[3], s[0] != s[1]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:16:26: error: expected ':' before ',' token
   16 |         case s[0] == s[2], s[1] == s[3], s[0] != s[1]:
      |                          ^
      |                          :
a.cc:16:26: error: expected primary-expression before ',' token
a.cc:19:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   19 |         case s[0] == s[3], s[1] == s[2], s[0] != s[1]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:19:17: error: call to non-'constexpr' function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
   19 |         case s[0] == s[3], s[1] == s[2], s[0] != s[1]:
      |                 ^
/usr/include/c++/14/bits/basic_string.h:1265:7: note: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]' declared here
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
a.cc:19:26: error: expected ':' before ',' token
   19 |         case s[0] == s[3], s[1] == s[2], s[0] != s[1]:
      |                          ^
      |                          :
a.cc:19:26: error: expected primary-expression before ',' token