Problem: You are given a 4-character string S consisting of uppercase English letters. Determine if S consists of exactly two kinds of characters which both appear twice in S.

Submission attempts (in order):
#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + , +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print(No)
    elif s[0] == s[1] and s[2] == s[3]:
        print(Yes)
    elif s[0] == s[2] and s[1] == s[3]:
        print(Yes)
    elif s[0] == s[3] and s[1] == s[2]:
        print(Yes)
    else:
        print(No)




if __name__ == '__main__':
    main()



#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + , +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print(No)
    elif s[0] == s[1] and s[2] == s[3]:
        print(Yes)
    elif s[0] == s[2] and s[1] == s[3]:
        print(Yes)
    elif s[0] == s[3] and s[1] == s[2]:
        print(Yes)
    else:
        print(No)




if __name__ == '__main__':
    main()



#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + , +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print(No)
    elif s[0] == s[1] and s[2] == s[3]:
        print(Yes)
    elif s[0] == s[2] and s[1] == s[3]:
        print(Yes)
    elif s[0] == s[3] and s[1] == s[2]:
        print(Yes)
    else:
        print(No)




if __name__ == '__main__':
    main()



ijjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

#coding:utf-8import bisectfrom collections import dequeimport syssys.setrecursionlimit(10**6)write = sys.stdout.writedbg = lambda *something : print(*something) if DEBUG else 0DEBUG = Truedef index(a,b):    return str(min(a,b)) + , +  str(max(a, b))def main(given = sys.stdin.readline):    input = lambda : given().rstrip()    LMIIS = lambda : list(map(int,input().split()))    II = lambda : int(input())    XLMIIS = lambda x : [LMIIS() for _ in range(x)]    s = input()    if s[0] == s[1] == s[2]:        print(No)    elif s[0] == s[1] and s[2] == s[3]:        print(Yes)    elif s[0] == s[2] and s[1] == s[3]:        print(Yes)    elif s[0] == s[3] and s[1] == s[2]:        print(Yes)    else:        print(No)if __name__ == '__main__':    main()

atcoder.py

#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + , +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print(No)
    elif s[0] == s[1] and s[2] == s[3]:
        print(Yes)
    elif s[0] == s[2] and s[1] == s[3]:
        print(Yes)
    elif s[0] == s[3] and s[1] == s[2]:
        print(Yes)
    else:
        print(No)




if __name__ == '__main__':
    main()



testtest

#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + , +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print(No)
    elif s[0] == s[1] and s[2] == s[3]:
        print(Yes)
    elif s[0] == s[2] and s[1] == s[3]:
        print(Yes)
    elif s[0] == s[3] and s[1] == s[2]:
        print(Yes)
    else:
        print(No)




if __name__ == '__main__':
    main()



#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        print("No")
    elif s[0] == s[1] and s[2] == s[3]:
        print("Yes")
    elif s[0] == s[2] and s[1] == s[3]:
        print("Yes")
    elif s[0] == s[3] and s[1] == s[2]:
        print("Yes")
    else:
        print("No")




if __name__ == '__main__':
    main()



Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted