qyliang/CodeNanoFix huggingface dataset:
Buggy code:
S = input()
temp = S[0]
a = 1
b = 0
for i in range(1,4):
  if temp == S[0]:
    a = a+1
  else:
    b = b+1
if b == 2 and a == 2:
  print('Yes')
else:
  print('No')

Fixed code:
S = input()
temp = S[0]
temp1 = '0'
a = 1
b = 0
c = 0
for i in range(1,4):
  if temp == S[i]:
    a = a+1
  elif temp1 == S[i]:
    c = c+1
  else:
    temp1 = S[i]
    b = b+1
if b == 1 and a == 2 and c == 1:
  print('Yes')
else:
  print('No')
Buggy code:
S = str(input())
S = S.sort()
if S.count(S[0]) == 2 and S.count(S[2]) == 2:
  print("Yes")
else:
  print("No")

Fixed code:
S = str(input())
S = sorted(S)
if S.count(S[0]) == 2 and S.count(S[2]) == 2:
  print("Yes")
else:
  print("No")
Buggy code:
s = input()

for i in range(4):
    cnt = s.count(s[i])
    if cnt == 2:
        continue
    else:
        print('No')
print('Yes')


Fixed code:
s = input()

for i in range(4):
    cnt = s.count(s[i])
    if cnt == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')
Buggy code:
s = list(input())
s.sort()
cnt = 1
ans = 1
for i in range(1, 4):
  if s[i - 1] != s[i]:
    if cnt < 2:
      ans = 0
      break
    cnt = 1
  if not ans:
    break
if cnt > 2:
  ans = 0
if not ans:
  print("No")
else:
  print("Yes")


Fixed code:
s = list(input())
s.sort()
cnt = 1
ans = 1
# print(s)
for i in range(1, 4):
  # print(cnt)
  if s[i - 1] != s[i]:
    if cnt < 2:
      ans = 0
      break
    cnt = -1
  if not ans:
    break
  cnt += 1
if cnt > 3:
  ans = 0
if not ans:
  print("No")
else:
  print("Yes")
Buggy code:
M=input()


if M.count(M[0])+ M.count(M[1])+ M.count(M[2])+ M.count(M[3])=8:
  print("Yes")
else:
  print("No")

Fixed code:
M=input()


if M.count(M[0])+ M.count(M[1])+ M.count(M[2])+ M.count(M[3])==8:
  print("Yes")
else:
  print("No")
Buggy code:
S=input()
if (S[0]==S[1] and S[2]==S[3]) or (S[0]==S[2] and S[1]==S[3]):
    print("Yes")
else:
    print("No")

Fixed code:
S=input()
if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[3]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[3]) or (S[0]==S[3] and S[2]==S[1] and S[0]!=S[1]):
    print("Yes")
else:
    print("No")
Buggy code:
import collections
S = input()
S2 = collections.counter(S)
c = True
for i,v in S2.items():
  if v == 2:
    continue
  else:
    c = False
if c:
  print('Yes')
else:
  print('No')

Fixed code:
import collections
S = input()
S2 = collections.Counter(S)
c = True
for i,v in S2.items():
  if v == 2:
    continue
  else:
    c = False
if c:
  print('Yes')
else:
  print('No')
Buggy code:
A=list(map(int,input()))

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

Fixed code:
A=list(map(str,input()))

if A[0]==A[1] and A[0]==A[2] and A[0]==A[3]:
    print("No")
elif A[0]==A[1] and A[2]==A[3]:
    print("Yes")
elif A[0]==A[2] and A[1]==A[3]:
    print("Yes")
elif A[0]==A[3] and A[1]==A[2]:
    print("Yes")
else:
    print("No")
Buggy code:
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[1] == 2:
    print("Yes")
else:
    print("No")


Fixed code:
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[0][1] == 2:
    print("Yes")
else:
    print("No")
Buggy code:
print(["No","Yes"][set(list(input()))==2])

Fixed code:
print(["No","Yes"][len(set(list(input())))==2])
Buggy code:
# -*- coding: utf-8 -*-
S = input().split()
 
s = str(S)
s = s[2:-2]

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

Fixed code:
# -*- coding: utf-8 -*-
S = input().split()
 
s = str(S)
s = s[2:-2]

if s[0] == s[1]:
  if (s[2] == s[3]) and (s[2] != s[0]):
    print("Yes")
  else:
    print("No")
else:
  if s[2] == s[0]:
    if (s[3] == s[1]) and (s[3] != s[0]):
      print("Yes")
    else:
      print("No")
  elif s[2] == s[1]:
    if (s[3] == s[0]) and (s[3] != s[1]):
      print("Yes")
    else:
      print("No")
  else:
    print("No")
Buggy code:
def main():
	n = list(str(input()))

	n_s = sorted(n)
	elif n_s[0] == n_s[1] and n_s[2] == n_s[3] and n_s[1] != n_s[2]:
		print("Yes")
	else:
		print("No")

 
if __name__ == '__main__':
	main()

Fixed code:
def main():
	n = list(str(input()))
	n_s = sorted(n)
	if n_s[0] == n_s[1] and n_s[2] == n_s[3] and n_s[1] != n_s[2]:
		print("Yes")
	else:
		print("No")

 
if __name__ == '__main__':
	main()
Buggy code:
s = sorted(list(input()))
if s[0]==s[1] and s[1]!=s[2] and s[2]==[3]: print("Yes")
else: print("No")

Fixed code:
s = sorted(list(input()))
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]: print("Yes")
else: print("No")
Buggy code:
s=[]
s = input()
cnt=0

if (s[0] == s[1]):
    cnt+=1

if(s[0] == s[2]):
    cnt+=1


if(s[0] == s[3]):
    cnt+=1


if(s[1] == s[2]):
    cnt+=1


if(s[0] == s[3]):
    cnt+=1


if(s[2] == s[3]):
    cnt+=1


if cnt == 2 :
  print("Yes")
else :
  print("No")

Fixed code:
s=[]
s = input()
cnt=0
 
if(s[0] == s[1]):
    cnt+=1

if(s[0] == s[2]):
    cnt+=1
 
 
if(s[0] == s[3]):
    cnt+=1
 
 
if(s[1] == s[2]):
    cnt+=1
 
 
if(s[1] == s[3]):
    cnt+=1
 
 
if(s[2] == s[3]):
    cnt+=1
 
 
if cnt == 2 :
  print("Yes")
else :
  print("No")
Buggy code:
s = input()

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


Fixed code:
s = input()

if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
    print("Yes")
elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
    print("Yes")
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
    print("Yes")
else:
    print("No")
Buggy code:
# -*- coding: utf-8 -*-
s = input()
dic = {}
for i in range(len(s)):
    c = s[i]
    count = dic.setdefault(c, 0) + 1
    dic[c] = count

result = "Yes"
for k in dic:
    if dic[k] != 2:
        result = "No"

print("Yes")


Fixed code:
# -*- coding: utf-8 -*-
s = input()
dic = {}
for i in range(len(s)):
    c = s[i]
    count = dic.setdefault(c, 0) + 1
    dic[c] = count

result = "Yes"
for k in dic:
    if dic[k] != 2:
        result = "No"

print(result)
Buggy code:
x=list(input())
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a==b and a!=c:
  if c==d:
    print(Yes)
  else:
    print(No)
elif a==c and a!=b:
  if b==d:
    print(Yes)
  else:
    print(No)
elif a==d and a!=b:
  if b==c:
    print(Yes)
  else:
    print(No)
else:
  print(No)

Fixed code:
x=list(input())
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a==b and a!=c:
  if c==d:
    print("Yes")
  else:
    print("No")
elif a==c and a!=b:
  if b==d:
    print("Yes")
  else:
    print("No")
elif a==d and a!=b:
  if b==c:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy code:
S = input()

T = sorted(S)
if T[0] == T[1] and T[2] == T[3] and T[1] != T[2]:
    print("Yes")
else:
    print("NO")

Fixed code:
S = input()

T = sorted(S)
if T[0] == T[1] and T[2] == T[3] and T[1] != T[2]:
    print("Yes")
else:
    print("No")
Buggy code:
S = map(str , input())
list_S = list(S)

list_S.sort

if list_S[0] == list_S[1] and list_S[2] == list_S[3] and list_S[0] != list_S[2]:
    print("Yes")
else:
    print("No")

Fixed code:
S = map(str , input())
list_S = list(S)

list_S.sort()

if list_S[0] == list_S[1] and list_S[2] == list_S[3] and list_S[0] != list_S[2]:
    print("Yes")
else:
    print("No")
Buggy code:
S = input()
l = list(S)
if l.count(l[0]) == 2 and l.count(l[1]) == 2 and l.count(l[2]) == 2 and l.count(l[3]) == 2 :
  print('Yse')
else:
  print('No')

Fixed code:
S = input()
l = list(S)
if l.count(l[0]) == 2 and l.count(l[1]) == 2 and l.count(l[2]) == 2 and l.count(l[3]) == 2 :
  print('Yes')
else:
  print('No')
Buggy code:
s = input()
listS = list(s)
sortS = listS.sort()

if listS[0] == listS[1] and listS[2] == listS[3]:
  if listS[0] != listS[2]
  	print('Yes')
else:
  print('No')


Fixed code:
s = input()
listS = list(s)
sortS = listS.sort()
if listS[0] == listS[1] and listS[2] == listS[3]:
  if listS[0] != listS[3]:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Buggy code:
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
ans = 'Yes'
if len(d.keys()) != 2:
    ans = 'No'
for i in d.keys():
    if d[i] != 2:
        ans = 'No'
print(d)
print(ans)

Fixed code:
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
ans = 'Yes'
if len(d.keys()) != 2:
    ans = 'No'
for i in d.keys():
    if d[i] != 2:
        ans = 'No'
print(ans)
Buggy code:
s = input()
if s[0]==s[1] and s[0]==s[2] and s[2]==s[3]:
    print("Yes")
elif s[0]==s[2] and s[0]==s[1] and s[1]==s[3]:
    print("Yes")
elif s[0]==s[3] and s[0]==s[1] and s[1]==s[2]:
    print("Yes")
else:
    print("No")

Fixed code:
S = input()
if S[0] == S[1] == S[2] == S[3]:
    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")
Buggy code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter


def is_valid(S):
    if len(S) != 4:
        return False

    counter = Counter(S)
    if len(counter) == 2:
        for key in counter:
            if counter[key] != 2:
                return False

    return True


def main():
    S = input()
    valid = is_valid(S)
    if valid:
        print('Yes')
    else:
        print('No')

main()



Fixed code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter


def is_valid(S):
    if len(S) != 4:
        return False

    counter = Counter(S)
    if len(counter) == 2:
        for key in counter:
            if counter[key] != 2:
                return False
        return True
    else:
        return False


def main():
    S = input()
    valid = is_valid(S)
    if valid:
        print('Yes')
    else:
        print('No')


main()
Buggy code:
x = input()

def Combination(x):
  if x[0] = x[1]:
    if x[2] = x[3]:
      return "Yes"
  elif x[0] = x[2]:
    if x[1] = x[3]:
      return "Yes"
  elif x[0] = x[3]:
    if x[1] = x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))


Fixed code:
x = input()
 
def Combination(x):
  if x[0] == x[1] and x[2] == x[3] and x[0] != x[2]:
      return "Yes"
  elif x[0] == x[2] and x[1] == x[3] and x[0] != x[1]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2] and x[0] != x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))
Buggy code:
S = list(input())
S.sort()
print(S)
print("Yes") if S[0] == S[1] and S[2] == S[3] and S[0] != S[2] else print("No")


Fixed code:
S=list(input())
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[2]!=S[1]:
    print('Yes')
else:
    print('No')
Buggy code:
s = str(input())

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

Fixed code:
s = str(input())

if s[0] == s[1]:
    if s[2] == s[3] and s[0] != s[2]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[2]:
    if s[1] == s[3] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[3]:
    if s[1] == s[2] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy code:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] = 1
  else:
    dic[i] += 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')

Fixed code:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')
Buggy code:
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
  print(Yes)
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
  print(Yes)
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
  print(Yes)
else:
  print(No)

Fixed code:
S=input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')
Buggy code:
s = input()
set(s)
if s[0] == s[1] and s[2] == s[3]:
    print("Yes")
else:
    print("No")

Fixed code:
s=input()
s=sorted(s)
if len(set(s))==2 and s[0]==s[1] and s[2]==s[3]:
    print('Yes')
else:
    print('No')
Buggy code:
S = input()
if S.count(S[0])==2 and S.count(S[1])==2 and S.count(S[2])==2:
  print('Yes')
print('No')

Fixed code:
S = input()
if S.count(S[0])==2 and S.count(S[1])==2 and S.count(S[2])==2:
  print('Yes')
else:
  print('No')
Buggy code:
from collections import defaultdict as dedict
counter = dedict(int)

a = input()
for i in list(a):
  counter[i] += 1
  
if ( len(counter) == 2) and (  counter [counter.keys()[0]] == 2):
  print ("Yes")
  
else:
  print('No')
  
  

Fixed code:
from collections import defaultdict as dedict
counter = dedict(int)

a = input()
for i in list(a):
  counter[i] += 1
  
if ( len(counter) == 2) and (  counter [a[0]] == 2):
  print ("Yes")
  
else:
  print('No')
Buggy code:
S = input()

from collections import defaultdict

dic = defaultdict(int)

for s in S:
    dic[s] += 1
    
if len(dic) == 2:
    for k, v in dic:
        if v == 2:
            continue
        else:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Fixed code:
S = input()

from collections import defaultdict

dic = defaultdict(int)

for s in S:
    dic[s] += 1

if len(dic) == 2:
    for k, v in dic.items():
        if v == 2:
            continue
        else:
            print("No")
            exit()
    print("Yes")
else:
    print("No")
Buggy code:
s = input()
ans =='Yes'
if(s[0] == s[1] and s[2] == s[3]):
  ans =='Yes'
elif(s[0] == s[3] and s[1] == s[2]):
  ans =='Yes'
elif(s[0] == s[2] and s[1] == s[3]):
  ans =='Yes'
else:
  ans =='No'

if(s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
  ans =='No'
print(ans)


Fixed code:
s = input()

if s[0]==s[1] and s[0]==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')
Buggy code:
s=input()
st=set(s)
print(st)
if len(st)==2:
    print("Yes")
else:
    print("No")

Fixed code:
s=input()
st=set(s)

if len(st)==2:
    print("Yes")
else:
    print("No")
Buggy code:
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(s[0])==2::2])

Fixed code:
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(list(s)[0])==2::2])
Buggy code:
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(s)==2):
	print("Yes")
else:
	print("No")

Fixed code:
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")
Buggy code:
input_data= input()
dic={}
yes_flag= 0

for moji in input_data:
  try:
    dic[moji] = dic[moji] + 1
  except KeyError:
    dic[moji] = 1


for keys in dic:
  if dic[keys] == 2:
    yes_flag = 1

if yes_flag == 1:
  print('Yes')
else:
  print('No')


Fixed code:
input_data= input()
dic={}
yes_flag= 0

for moji in input_data:
  try:
    dic[moji] = dic[moji] + 1
  except KeyError:
    dic[moji] = 1


for keys in dic:
  if dic[keys] == 2:
    yes_flag = yes_flag +1

if yes_flag == 2:
  print('Yes')
else:
  print('No')
Buggy code:
import sys


s = sys.argv[1]

if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()


Fixed code:
import sys


#s = sys.argv[1]
s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()
Buggy code:
s = input()
word_list = []
for i in range(len(s)):
    word_list.append(s[i])
list = []
print(word_list)

for i in range(len(word_list)):
    flag = 0
    w = word_list[i]
    if len(list) == 0:
        list.append([w,1])
    else:
        for j in range(len(list)+1):
            if j == len(list) and flag == 0:
                list.append([w,1])
            elif j == len(list):
                continue
            elif list[j][0] == w:
                flag = 1
                list[j][1] = list[j][1] + 1

if len(list) == 2 and list[0][1]==2 and list[1][1]==2:
    print('Yes')
else:
    print('No')


Fixed code:
s = input()
word_list = []
for i in range(len(s)):
    word_list.append(s[i])
list = []

for i in range(len(word_list)):
    flag = 0
    w = word_list[i]
    if len(list) == 0:
        list.append([w,1])
    else:
        for j in range(len(list)+1):
            if j == len(list) and flag == 0:
                list.append([w,1])
            elif j == len(list):
                continue
            elif list[j][0] == w:
                flag = 1
                list[j][1] = list[j][1] + 1

if len(list) == 2 and list[0][1]==2 and list[1][1]==2:
    print('Yes')
else:
    print('No')
Buggy code:
# coding: utf-8
# Your code here!

n = input()
a1 = n[0]
a2 = n[0]
count1 = 1
count2 = 0
for nc in range(1,4):
    if(n[nc] == a1):
        count1 += 1
    elif(a1 == a2):
        a2 = n[nc]
        count2 += 1
    elif(n[nc] == a2):
        count2 += 1
if(count1 == count2):
    print("Yes")
else:
    print("No")

Fixed code:
# coding: utf-8
# Your code here!

n = input()
a1 = n[0]
a2 = n[0]
count1 = 1
count2 = 0
for nc in range(1,4):
    if(n[nc] == a1):
        count1 += 1
    elif(a1 == a2):
        a2 = n[nc]
        count2 += 1
    elif(n[nc] == a2):
        count2 += 1
    else:
        count1 = 5
if(count1 == count2):
    print("Yes")
else:
    print("No")
Buggy code:
s=input()
count1=0
count2=0

char1=s[0]
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif s[2]==char2:
    char2=s[2]
    count2+=1
else:
    print('No')
    exit()

if s[3]==char1:
    count1+=1
elif s[3]==char2:
    char2=s[3]
    count2+=1
else:
    print('No')
    exit

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')


Fixed code:
s=input()
count1=0
count2=0

char1=s[0]
char2='1'
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif '1'==char2:
    char2=s[2]
    count2+=1
elif s[2]==char2:
    count2+=1

if s[3]==char1:
    count1+=1
elif '1'==char2:
    char2=s[3]
    count2+=1
elif s[3]==char2:
    count2+=1

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')
Buggy code:
S = input()
S=sorted(S)
print(S)
if S[0] == S[1] != S[2] ==S[3]:
    print("Yes")
else:
    print("No")

Fixed code:
S = input()
S=sorted(S)

if S[0] == S[1] != S[2] ==S[3]:
    print("Yes")
else:
    print("No")
Buggy code:
a = list(input())
before = -1
count =0
for char in a:
    current = char
    if before == current:
        count = count+1
    else:
        before = current

if count==2:
    s = set()
    for item in a:
        s.add(item)
    if len(s) == 2:
        print("Yes")
        exit()

print("No")

Fixed code:
a = list(input())
before = -1
count =0
for char in a:
    current = char
    if before == current:
        count = count+1
    else:
        before = current

if count<=2:
    s = set()
    for item in a:
        s.add(item)
    if len(s) == 2:
        print("Yes")
        exit()

print("No")
Buggy code:
x = input()

a = 1
b = 1
other = '0'

for i in range(1,4):
  if x[0] == x[i]:
    a += 1
  else:
    if other == x[i]:
      b += 1
    else:
      other = x[i]
      
print(a)
print(b)
if a == b == 2:
  print("Yes")
else:
  print("No")

Fixed code:
x = input()

a = 1
b = 1
other = '0'

for i in range(1,4):
  if x[0] == x[i]:
    a += 1
  else:
    if other == x[i]:
      b += 1
    else:
      other = x[i]
      
if a == b == 2:
  print("Yes")
else:
  print("No")
Buggy code:
s = input()
s.sort()
if s[0] == s[1] and s[2] == s[3]:
    print("Yes")
else:
    print("No")

Fixed code:
s = list(input())
s.sort()
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
    print("Yes")
else:
    print("No")
Buggy code:
s = list(input())
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[0] != s[1]:
  print('Yes')
else:
  print('No')

Fixed code:
s = list(input())
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
  print('Yes')
else:
  print('No')
Buggy code:
s = input()
s_s = list(set(s))

print(s_s)

if len(s_s) == 2:
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
else:
    print('No')

Fixed code:
s = input()
s_s = list(set(s))

if len(s_s) == 2:
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
else:
    print('No')
Buggy code:
if len(set(list(input())))==2:
  print('Yes')
else
  print('No')


Fixed code:
if len(set(input()))==2:
  print('Yes')
else:
  print('No')
Buggy code:
if len(set(input()))==2:
  print('Yes')
else
  print('No')


Fixed code:
S = input()

if len(set(S)) == 2:
  print('Yes')
else:
  print('No')
Buggy code:
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

if Slist[0] == Slist[1] and Slist[2] == Slist[3]:
    ans = "Yes"
else:
    ans = "No"


Fixed code:
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

if Slist[0] == Slist[1] and Slist[2] == Slist[3] and Slist[0]!=Slist[2]:
    ans = "Yes"
else:
    ans = "No"
print(ans)
Buggy code:
s = str(input())

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

Fixed code:
s = str(input())

if (s[0] == s[1]) and (s[2] == s[3]) and (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[2] == s[1]):
  print('Yes')
else:
  print('No')
Buggy code:
S = input()
s = set(S)

print('Yes' if len(s)==2 and S.count(s[0]) == S.count(s[1]) == 2 else 'No')

Fixed code:
S = input()
s = list(set(S))

print('Yes' if len(s)==2 and S.count(s[0]) == S.count(s[1]) == 2 else 'No')
Buggy code:
S =input()
listS = [S[0],S[1],S[2],S[3]]
listS.sort()
if listS[0] == listS[1] and listS[2] == listS[3] and listS[2] !=listS[3]:
    print('Yes')
else:
    print('No')

Fixed code:
S =input()
listS = [S[0],S[1],S[2],S[3]]
listS.sort()
if listS[0] == listS[1] and listS[2] == listS[3] and listS[1] != listS[2]:
    print('Yes')
else:
    print('No')
Buggy code:
S = list(input())
S.sort()
if len(set(S))==2:
  if S[0]==S[1] or S[0]==S[2] or S[0]==S[3]:
    print("Yes")
  else:
    print("No")

Fixed code:
S = list(input())
S.sort()
if len(set(S))==2:
  if S[0]==S[1] and S[2]==S[3]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy code:
s = input()
a = set()
for i in len(s):
  a.add(s[i])
if len(a) == 2:
  print('Yes')
else:
  print('No')


Fixed code:
s = input()
a = set()
for i in range(len(s)):
  a.add(s[i])
if len(a) == 2:
  print('Yes')
else:
  print('No')
Buggy code:
l = list(map(str, input())) 
if l.count(l[0]) == l.count(l[1]) == l.count(l[2]) == l.count(l[3]) == 2: 
    print('Yes')
else:
    print('NO')

Fixed code:
l = list(map(str, input())) 
if l.count(l[0]) == l.count(l[1]) == l.count(l[2]) == l.count(l[3]) == 2: 
    print('Yes')
else:
    print('No')
Buggy code:
from collections import Counter
c = True
for (k, v) in Counter(input()):
  if v != 2:
    c = False
if c:
  print("Yes")
else:
  print("No")

Fixed code:
from collections import Counter
c = True
for (k, v) in Counter(input()).items():
  if v != 2:
    c = False
if c:
  print("Yes")
else:
  print("No")