qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N=int(input())
A=[int(_) for _ in input().split()]
ans=[0]*N
ans[0]=sum(A)//2-sum(A[1::2])
for i in range(N-):
    ans[i+1]=A[i]-ans[i]
print(' '.join(str(2*a) for a in ans))

Fixed code:
N=int(input())
A=[int(_) for _ in input().split()]
ans=[0]*N
ans[0]=sum(A)//2-sum(A[1::2])
for i in range(N-1):
    ans[i+1]=A[i]-ans[i]
print(' '.join(str(2*a) for a in ans))
Buggy code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def find_mountain_rain_amount(N, A):
    for i in range(N):
        A[i] = A[i] * 2

    offset = 0
    for i in range(N):
        offset = A[i] - offset

    x = offset // 2

    cur = x
    ans = []
    for i in range(N):
        ans.append(cur)
        cur = A[i] - cur

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = find_mountain_rain_amount(N, A)
    print(ans)


main()



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


def find_mountain_rain_amount(N, A):
    for i in range(N):
        A[i] = A[i] * 2

    offset = 0
    for i in range(N):
        offset = A[i] - offset

    x = offset // 2

    cur = x
    ans = []
    for i in range(N):
        ans.append(cur)
        cur = A[i] - cur

    return ans


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = find_mountain_rain_amount(N, A)
    for num in ans:
        print(num, end=" ")


main()
Buggy code:
# x_(n+1) = 2*a_n - x_n
def xn(ans,a,n):
  for i in range(n-1):
    ans[i+1]=2*a[i]-ans[i]
  return ans
  

n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
for j in range(2*max(A)):
  ans[0] = j
  ans = xn(ans,A,n)
  if sum(ans)==sum(A):
    print(" ".join(list(map(str,ans))))
    #print(ans)

Fixed code:
# x_(n+1) = 2*a_n - x_n
def xn(ans,a,n):
  for i in range(n-1):
    ans[i+1]=2*a[i]-ans[i]
  return ans
  

n = int(input())
A = list(map(int,input().split()))
ans = [0]*n
ans[0] = sum(A)-2*sum(A[1:n:2])
ans = xn(ans,A,n)
print(" ".join(list(map(str,ans))))
Buggy code:
N = int(input())
A = list(map(int, input().split()))

a = 0
for i in range(N):
  a += A[i] * (1 if not i%2 else -1)
print(a)

ans = [0] * N
ans[0] = a

for i in range(1, N):
  ans[i] = 2 * A[i-1] - ans[i-1]

print(*ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))

a = 0
for i in range(N):
  a += A[i] * (1 if not i%2 else -1)

ans = [0] * N
ans[0] = a

for i in range(1, N):
  ans[i] = 2 * A[i-1] - ans[i-1]

print(*ans)
print()
Buggy code:
n = int(input())
a=[]
a=list(map(int, input().split()))

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(m[i],end=" ")
  

Fixed code:
n = int(input())
a=[]
a=list(map(int, input().split()))

m=[0]*n

for i in range(n):
  if i%2 == 0:
    m[0]+=a[i]
  else:
    m[0]-=a[i]
for i in range(1,n):
  m[i] =(a[i-1]-m[i-1]/2)*2
  
for i in range(n):
  print(int(m[i]),end=" ")
Buggy code:
n = int(input())
a = list(map(int, input().split()))

res = []
s = 0
for i in enumerate(range(n)):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(a[i] - 2*res[i-1])

print(' '.join(map(str, res)))


Fixed code:
n = int(input())
a = list(map(int, input().split()))

res = []
s = 0
for i in range(n):
    s += a[i] * [-1, 1][i % 2 ==0]
res.append(s)

for i in range(1, n):
    res.append(2*a[i-1] - res[i-1])

print(' '.join(map(str, res)))
Buggy code:
N = int(input())
A = list(map(int, input().split()))
Mt = [0] * N

for i in range(N):
    Mt[0] += A[i] * (-1) ** i

for i in range(1, N):
    Mt[i] = 2 * A[i - 1] - Mt[i-1]

print(Mt)


Fixed code:
N = int(input())
A = list(map(int, input().split()))
Mt = [0] * N

for i in range(N):
    Mt[0] += A[i] * (-1) ** i

for i in range(1, N):
    Mt[i] = 2 * A[i - 1] - Mt[i-1]

print(*Mt)
Buggy code:
a = list(map(int,input().split()))
x1 = sum([a[h] if h%2==0 else -a[h] for h in range(n)])
print(x1,end = ' ')

for i in range(n-1):
	if i == 0:
		b = a[i]*2 - x1
		print(b,end=' ')
	else:
		print(a[i]*2 - b,end=' ')
		b = a[i]*2 - b

Fixed code:
n = int(input())
a = list(map(int,input().split()))
x1 = sum([a[h] if h%2==0 else -a[h] for h in range(n)])
print(x1,end = ' ')

for i in range(n-1):
	if i == 0:
		b = a[i]*2 - x1
		print(b,end=' ')
	else:
		print(a[i]*2 - b,end=' ')
		b = a[i]*2 - b
Buggy code:
N = int(input())
A = list(map(int, input().split()))

x1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
x = [x1]

for i in range(1,N):
    xi = 2 * A[i - 1] - x[i - 1]
    x.append(xi)

print(x)

Fixed code:
N = int(input())
A = list(map(int, input().split()))

x1 = sum(A) - 2 * sum([A[i] for i in range(1,N,2)])
x = [x1]

for i in range(1,N):
    xi = 2 * A[i - 1] - x[i - 1]
    x.append(xi)

print(*x)
Buggy code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [x]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(x)
    print(ans)


main()


Fixed code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = sum(A) - 2 * sum(A[i] for i in range(1, N, 2))
    ans = [str(x)]
    for i in range(N - 1):
        x = 2 * A[i] - x
        ans.append(str(x))
    print(' '.join(ans))


main()
Buggy code:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
ans = [0] * n
ans[0] = a[0] * 2 + a[-1] * 2 - s
for i in range(1,n):
    ans[i] = a[i] * 2 + a[i-1] * 2 - s
print(*ans)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
x = 0
for i in range(1, n, 2):
    x += a[i]

ans[0] = sum(a) - 2 * x
for i in range(1, n):
    ans[i] = 2 * a[i - 1] - ans[i - 1]

print(*ans)
Buggy code:
N = int(input())
A = [int(i) for i in input().split()]

A_tmp = 0

for i in range(len(A)):
  if i%2 == 0:
    A_tmp += 2*A[i]
  else:
    A_tmp -= 2*A[i]

A1 = A_tmp * 2//3
ans = [A1]
for i in range(len(A)-1):
  ans.append(2*A[i]-ans[i])

print(" ".join(map(str,ans)))


Fixed code:
N = int(input())
A = [int(i) for i in input().split()]

A_tmp = 0

for i in range(len(A)):
  if i%2 == 0:
    A_tmp += 2*A[i]
  else:
    A_tmp -= 2*A[i]

A1 = A_tmp // 2
ans = [A1]
for i in range(len(A)-1):
  ans.append(2*A[i]-ans[i])

print(" ".join(map(str,ans)))
Buggy code:
N = int(input())
l_a = list(map(int,input().split()))
print(l_a[1::2])
b_x = sum(l_a) - sum(l_a[1::2])*2
l_x =[b_x]
for s in range(N-1):
    x = l_a[s]*2 - b_x
    l_x.append(x)
    b_x = x
print(l_x)


Fixed code:
N = int(input())
l_a = list(map(int,input().split()))
b_x = sum(l_a) - sum(l_a[1::2])*2
l_x =[b_x]
for s in range(N-1):
    x = l_a[s]*2 - b_x
    l_x.append(x)
    b_x = x
print(*l_x)
Buggy code:
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

for i in range(1,n):
    x[i] = 2 * b[i-1] - x[i-1]

s = str(x.astype(int))
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
print(s)

Fixed code:
import numpy as np
n = int(input())
b = list(map(int, input().strip().split()))
s = sum(b)
x = np.zeros((n))

x[0] = s
k = 1
for i in range(int((n-1)/2)):
    x[0] -= 2*b[k%n]
    k += 2

for i in range(1,n):
    x[i] = 2 * b[i-1] - x[i-1]

x = (x.astype(int)).tolist()

s = str(x)
s = s.replace(',','')
s = s.replace('[','')
s = s.replace(']','')
s = s.replace('  ',' ')

print(s)
Buggy code:
n = int(input())
a = list(map(int, input().split()))
x=a[n-1]
for i in range(0,n-2,2):
	x += a[i] - a[i+1]
x /= 2
m = [x]
for t in range(n-1):
	m.append(a[t]-m[t])
m = [int(mountain * 2) for mountain in m]
print(m)

# m  = []
# m.append(a[0]+a[n-1])
# for i in range(1,n):
# 	m.append(a[i-1]+a[i])
# # print(' '.join(m))
# print(m)
# print(a)

Fixed code:
n = int(input())
a = list(map(int, input().split()))
x=a[n-1]
for i in range(0,n-2,2):
	x += a[i] - a[i+1]
x /= 2
m = [x]
for t in range(n-1):
	m.append(a[t]-m[t])
m = [str(int(mountain * 2)) for mountain in m]
print(' '.join(m))
Buggy code:
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

X=0
for i in range(N):
    if i%2==0:
        X+=A[i]
    else:
        X-=A[i]

print(X)


ANS=[X]

for i in range(N-1):
    ANS.append((A[i]-ANS[-1]//2)*2)

print(*ANS)


Fixed code:
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

X=0
for i in range(N):
    if i%2==0:
        X+=A[i]
    else:
        X-=A[i]

#print(X)


ANS=[X]

for i in range(N-1):
    ANS.append((A[i]-ANS[-1]//2)*2)

print(*ANS)
Buggy code:
s=input()
if len(list(s))==2 and s.count(s[0])==2:print("Yes")
else:print("No")

Fixed code:
s = input()

if len(set(list(s))) == 2 and s.count(s[0]) == 2:
    print('Yes')
else:
    print('No')
Buggy code:
S=input()
hantei=False
if(len(set(S))==2):
    hantei=True
else:
    hantei=False
SS=sorted(S)
if(SS[0]==SS[1] and SS[0]!=SS[2]):
    hantei=True
else:
    hantei=False
if(hantei==True):
    print("Yes")
else:
    print("No")
    

Fixed code:
S=input()
hantei=False
SS=sorted(S)
if(len(set(S))==2):
    if(SS[0]==SS[1] and SS[0]!=SS[2]):
        hantei=True
    else:
        hantei=False
else:
    hantei=False


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

Fixed code:
s=list(input())
s.sort()
if s[0] == s[1] and s[2]==s[3] and s[0] != s[2]:
    print("Yes")
else:
    print("No")
Buggy code:
# -*- coding: utf-8 -*-

import sys
tmp = input()

print(tmp)
if (tmp[0] == tmp[1]) and (tmp[2] == tmp[3]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[2]) and (tmp[1] == tmp[3]) and (tmp[2] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[3]) and (tmp[2] == tmp[1]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
print("No")



Fixed code:
# -*- coding: utf-8 -*-

import sys
tmp = input()

if (tmp[0] == tmp[1]) and (tmp[2] == tmp[3]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[2]) and (tmp[1] == tmp[3]) and (tmp[2] != tmp[3]):
	print("Yes")
	sys.exit()
if (tmp[0] == tmp[3]) and (tmp[2] == tmp[1]) and (tmp[1] != tmp[3]):
	print("Yes")
	sys.exit()
print("No")
Buggy code:
s=list(input())
a='NO'
if s[1]==s[2] and s[3]==s[0] and s[1]!=s[3] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[3] and s[2]==s[0] and s[1]!=s[2] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[0] and s[2]==s[3] and s[1]!=s[2] and s[1]!=s[3]:
  a='Yes'
print(a)

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

Fixed code:
s = sorted(input())

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

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

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

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

Fixed code:
s=input()

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

print(S)

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

Fixed code:
S = sorted(input())

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



Fixed code:
#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()
Buggy code:
s=input()
if not s[0]==s[1]==s[2]==s[3]:
    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[3]):
        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]) or (s[0]==s[2] and s[1]==s[3])or (s[0]==s[3] and s[1]==s[2]):
        print("Yes")
else:
    print("No")
Buggy code:
n = list(input())
flag = 0
dict = {}
for i in n:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
 
for key,val in dict.items():
    if val != 2:
        flag = 1
 
if flag:
    print("Bad")
else:
    print("Yes")


Fixed code:
n = list(input())
flag = 0
dict = {}
for i in n:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
 
for key,val in dict.items():
    if val != 2:
        flag = 1
 
if flag:
    print("No")
else:
    print("Yes")
Buggy code:
S = input()
S = sorted(S)
if (S[0] == S[1]) and (S[2] == S[3]) and (S[1] != S[2]):
  print("Yes")
else
  print("No")


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

Fixed code:
s = input()
sr = s.replace(s[0], '')
if len(sr) == 2 and sr.count(sr[0]) == 2:
    print('Yes')
else:
    print('No')
Buggy code:
import sys
sys.setrecursionlimit(10**9)
from collections import Counter
input = sys.stdin.readline

S=input[:-1]
C=Counter(S)
if all([v==2 for key,v in C.items()]):
    print("Yes")
else:
    print("No")

    


Fixed code:
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
C = Counter(S)
if all([v == 2 for key, v in C.items()]):
    print("Yes")
else:
    print("No")
Buggy code:
s = input()
l = list(s)
c1 = s.count(l[0])
c2 = s.count(l[1])
c3 = s.count(l[2])
c4 = s.count(l[3])
if c1 == 2 and c2 == 2 and c3 == 2 and c4 == 2:
  print('Yes')
  else:
    print('No')

Fixed code:
s = input()
l = list(s)
c1 = s.count(l[0])
c2 = s.count(l[1])
c3 = s.count(l[2])
c4 = s.count(l[3])
if c1 == 2 and c2 == 2 and c3 == 2 and c4 == 2:
  print('Yes')
else:
  print('No')
Buggy code:
s = input()
t = set(s)
if len(t) == 2 and s.count(t[0]) == 2:
  print("Yes")
else:
  print("No")

Fixed code:
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t)[0]) == 2:
  print("Yes")
else:
  print("No")
Buggy code:
s = input()
d = {}
for ss in s:
    d[ss] = d.get(ss, 0) + 1

print("Yes" if len(d) == 2 and d.items()[0][1] == 2 else "No")

Fixed code:
s = input()
d = {}
for ss in s:
    d[ss] = d.get(ss, 0) + 1

print("Yes" if len(d) == 2 and list(d.items())[0][1] == 2 else "No")
Buggy code:
inputS = set(input())
if len(inputS):
    print('Yes')
else:
    print('No')


Fixed code:
S = input()

if len(set(S)) == 2:
    print('Yes')
else:
    print('No')
Buggy code:
l = list(input().split())

dic = {}
for i, v in enumerate(l):
    if v in dic:
        dic[v] += 1
    else:
        dic[v] = 1

li = list(dic.values())

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


Fixed code:
l = list(input())

dic = {}
for i, v in enumerate(l):
    if v in dic:
        dic[v] += 1
    else:
        dic[v] = 1

li = list(dic.values())
if li[0] == 2 and li[1] == 2:
    print('Yes')
else:
    print('No')
Buggy code:
s=str(input())
lst=list(s)
lst.sort()
result = True

if lst[0] == lst[1]:
    if lst[2] == lst[3]:
        if lst[1] != lst[2]:
            result = False

if result:
    print('No')
else:
    print('YES')

Fixed code:
s=str(input())
lst=list(s)
lst.sort()
result = False

if lst[0] == lst[1]:
    if lst[1] != lst[2]:
        if lst[2] == lst[3]:
            result = True

if result:
    print('Yes')
else:
    print('No')
Buggy code:
S=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]:
        print("Yes")
    else:
        print("No")
elif S[0]==S[3]:
    if S[1]==S[2]:
        print("Yes")
    else:
        print("No")

Fixed code:

S = str(input())

if S[0]==S[1] and S[0]==S[2] and S[0]==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:
S = list(input())
S_set = set(S)

for target in S_set:
    if S.count(target) == 2:
        print("Yes")
        exit()

print("No")


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

for target in S_set:
    if S.count(target) != 2:
        print("No")
        exit()

print("Yes")
Buggy code:
import collections
S = input()
c = collections.Counter(S)
x = c.most_common()
if x[0][1] == 2:
    if x[1][1] == 2:
        print('Yes')
else:
    print('No')

Fixed code:
import collections
S = input()
c = collections.Counter(S)
x = c.most_common()
if x[0][1] == 2:
    if x[1][1] == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy code:
input_str = input()
items = set(list(input_str)
return 'Yes' if len(items) == 2 and len(list(input_str.replace(list(items)[0], ''))) == 2 else 'No'

Fixed code:
input_str = input()
items = set(list(input_str))
print('Yes' if len(items) == 2 and len(list(input_str.replace(list(items)[0], ''))) == 2 else 'No')
Buggy code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    exit()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if S1[0] == S1[1] and len(S1) == 2 and len(S2) == 2:
    print("Yes")
else :
    print("No")


Fixed code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    exit()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if len(S1) == 2:
        if S1[0] == S1[1]:
            print("Yes")
        else:
            print("No")
else :
    print("No")
Buggy code:
stc = input()

chars = {}

for char in stc:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1

if len(chars) == 2:
    for num in chars.values():
        if num != 2:
            print('No')
            exit()

    print('Yes')


Fixed code:
stc = input()

chars = {}

for char in stc:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1

if len(chars) == 2:
    for num in chars.values():
        if num != 2:
            print('No')
            exit()

    print('Yes')
else:
    print('No')
Buggy code:
s=input()
if len(set((s))=2 and count(s[0])=2:
       print('Yes')
else:
       print('No')

Fixed code:
s=input()
if len(set(s))==2 and s.count(s[0])==2:
    print('Yes')
else:
    print('No')
Buggy code:
from collections import defaultdict
s = str(input())
d = defaultdict(int)
for x in s:
  d[x]+=1
if len(d)==2:
  for key,value in d:
    if value!=2:
      print("No")
      exit()
  print("Yes")
else:
  print("No")
  


Fixed code:
from collections import defaultdict
s = str(input())
d = defaultdict(int)
for x in s:
  d[x]+=1
if len(d)==2:
  for key in d:
    if d[key]!=2:
      print("No")
      exit()
  print("Yes")
else:
  print("No")
Buggy code:
S = input()
S_list = list(S[i] for i in range(len(S)))

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

else:
    print("No")



Fixed code:
S = input()
S_list = list(S[i] for i in range(len(S)))

S_list.sort()

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

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

Fixed code:
word=input()
listword=list(word)
listword.sort()

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

Fixed code:
s = input()
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[0] != s[3]:
    print('Yes')
else:
    print('No')
Buggy code:
s = input().split()
s = [c for c in s[0]]

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

else:
    for i in range(1, len(s)):
        if s[0] == s[i]:
            buf = i
        else:
            buf = 0
    if buf == 0:
        print('No')
    else:
        print(buf)
        nokori = []
        for i in range(1, len(s)):
            if i == buf:
                continue
            else:
                nokori.append(s[i]) 
                print(nokori)
        if nokori[0] == nokori[1]:
            print('Yes')
        else:
            print('No')

Fixed code:
s = input().split()
s = [c for c in s[0]]

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

else:
    for i in range(1, len(s)):
        if s[0] == s[i]:
            buf = i
            break
        else:
            buf = 0
    if buf == 0:
        print('No')
    else:
        nokori = []
        for i in range(1, len(s)):
            if i == buf:
                continue
            else:
                nokori.append(s[i]) 
        if nokori[0] == nokori[1]:
            print('Yes')
        else:
            print('No')
Buggy code:
s = input()
a = set(s)
print('Yes' if len(a) == 2 and s.count(a[0]) == 2 and s.count(a[1]) == 2 else 'No')

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

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

Fixed code:
S = input()
A=list(S)
A.sort()
# S=list(S).sort()
# print(list(S))

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

print(S)

s = set(S)
if len(s) == 2:
    count = 0
    for _ in s:
        if len([a for a in S if a == _]) == 2:
            print('Yes')
            quit()

print('No')

Fixed code:
S = list(str(input()))

s = set(S)
if len(s) == 2:
    count = 0
    for _ in s:
        if len([a for a in S if a == _]) == 2:
            print('Yes')
            quit()

print('No')