qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import numpy as np
lst = []
nums = []
for _ in range(3):
    l = []
    l = list(map(int, input().split()))
    lst.append(l)
    lst = np.array(lst)
n = int(input())
for _ in range(n):
    nums.append(int(input()))

for h in range(3):
    for w in range(3):
        if array[h][w] in nums:
            array[h][w] = 0

i = 0
for h in range(3):
    if sum(array[:, h]) == 0:
        i = 1
for w in range(3):
    if sum(array[w]) == 0:
        i = 1
if sum(np.diag(np.fliplr(array))) == 0:
    i = 1
if sum(np.diag(array)) == 0:
    i = 1

if i == 1:
    print("Yes")
else:
    print('No')

Fixed code:
import numpy as np
lst = []
nums = []
for _ in range(3):
    l = []
    l = list(map(int, input().split()))
    lst.append(l)
    array = np.array(lst)
 
n = int(input())
for _ in range(n):
    nums.append(int(input()))

for h in range(3):
    for w in range(3):
        if array[h][w] in nums:
            array[h][w] = 0

i = 0
for h in range(3):
    if sum(array[:, h]) == 0:
        i = 1
for w in range(3):
    if sum(array[w]) == 0:
        i = 1
if sum(np.diag(np.fliplr(array))) == 0:
    i = 1
if sum(np.diag(array)) == 0:
    i = 1

if i == 1:
    print("Yes")
else:
    print('No')
Buggy code:
a=[list(map(int,input().split()))for i in range(3)]
n=int(input())
b=[int(input())for i in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      a[i][j]==b[k]
      a[i][j]=[0,0]
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

Fixed code:
a=[list(map(int,input().split()))for _ in range(3)]
n=int(input())
b=[int(input())for _ in range(n)]
ans='No'
for i in range(3):
  for j in range(3):
    for k in range(n):
      if a[i][j]==b[k]:
         a[i][j]=0
      
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)
Buggy code:
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

print(jadge)

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    print('Yes')
else:
    print('No')



Fixed code:
card = []

for _ in range(3):
    card.extend(map(int, input().split(' ')))

jadge = [0] * 9
N = int(input())

for _ in range(N):
    n = int(input())
    if n in card:
        jadge[card.index(n)] = 1

bingo = False
for i in range(3):
    if (jadge[3 * i] + jadge[3 * i+1] + jadge[3 * i+2]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[3 + i] + jadge[6 + i]) == 3:
        bingo = True
        break
    if (jadge[i] + jadge[4] + jadge[8-i]) == 3:
        bingo = True
        break

if bingo:
    print('Yes')
else:
    print('No')
Buggy code:
import sys
#n=int(input())
#l = list(map(int,input().split()))
#a,b,c = map(int,input().split())

ly = []

for i in range(3):
    ly.append(list(map(int,input().split())))

lt = []

for i in range(3):
    l = []
    for j in range(3):
        l.append(ly[j][i])
    lt.append(l)

l = ly+lt + [[ly[0][0],ly[1][1],lt[2][2]]] + [[ly[0][2],ly[1][1],ly[2][0]]]
print(l)

n = int(input())
nm = []
for i in range(n):
    s = int(input())
    nm.append(s)

for i in l:
    t = [0,0,0]
    if i [0] in nm:
        t[0] = 1
    if i [1] in nm:
        t[1] = 1
    if i [2] in nm:
        t[2] = 1
    if sum(t) == 3:
        print("Yes")
        sys.exit()
print("No")

Fixed code:
import sys
#n=int(input())
#l = list(map(int,input().split()))
#a,b,c = map(int,input().split())

ly = []

for i in range(3):
    ly.append(list(map(int,input().split())))

lt = []

for i in range(3):
    l = []
    for j in range(3):
        l.append(ly[j][i])
    lt.append(l)

l = ly+lt + [[ly[0][0],ly[1][1],lt[2][2]]] + [[ly[0][2],ly[1][1],ly[2][0]]]

n = int(input())
nm = []
for i in range(n):
    s = int(input())
    nm.append(s)

for i in l:
    t = [0,0,0]
    if i [0] in nm:
        t[0] = 1
    if i [1] in nm:
        t[1] = 1
    if i [2] in nm:
        t[2] = 1
    if sum(t) == 3:
        print("Yes")
        sys.exit()
print("No")
Buggy code:
import numpy as np
A = np.array([list(map(str, input().split())) for _ in range(3)])
N = int(input())
b = [input() for _ in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 'X'
print(A)

if A[0][0] == A[1][1] == A[2][2] == 'X':
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 'X':
    print('Yes')
    exit()

if A[0][0] == A[0][1] == A[0][2] == 'X':
    print('Yes')
    exit()

if A[1][0] == A[1][1] == A[1][2] == 'X':
    print('Yes')
    exit()

if A[2][0] == A[2][1] == A[2][2] == 'X':
    print('Yes')
    exit()

# t
if A[0][0] == A[1][0] == A[2][0] == 'X':
    print('Yes')
    exit()
if A[0][1] == A[1][1] == A[2][1] == 'X':
    print('Yes')
    exit()
if A[0][2] == A[1][2] == A[2][2] == 'X':
    print('Yes')
    exit()
print('No')

Fixed code:
import numpy as np
A = np.array([list(map(str, input().split())) for _ in range(3)])
N = int(input())
b = [input() for _ in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 'X'

if A[0][0] == A[1][1] == A[2][2] == 'X':
    print('Yes')
    exit()

if A[0][2] == A[1][1] == A[2][0] == 'X':
    print('Yes')
    exit()

if A[0][0] == A[0][1] == A[0][2] == 'X':
    print('Yes')
    exit()

if A[1][0] == A[1][1] == A[1][2] == 'X':
    print('Yes')
    exit()

if A[2][0] == A[2][1] == A[2][2] == 'X':
    print('Yes')
    exit()

# t
if A[0][0] == A[1][0] == A[2][0] == 'X':
    print('Yes')
    exit()
if A[0][1] == A[1][1] == A[2][1] == 'X':
    print('Yes')
    exit()
if A[0][2] == A[1][2] == A[2][2] == 'X':
    print('Yes')
    exit()
print('No')
Buggy code:
import numpy as np
S = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
    S = np.where(S==int(input()), 0, S)
if min(np.sum(S, axis=0))==0 or min(np.sum(S, axis=1))==0:
    print('Yes')
    exit()
if (S[0][0] == 0 and S[1][1] == 0 and S[2][2]) or (S[2][0] == 0 and S[1][1] == 0 and S[0][2]):
    print('Yes')
    exit()
print('No')

Fixed code:
import numpy as np
S = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())
for _ in range(n):
    S = np.where(S==int(input()), 0, S)
if min(np.sum(S, axis=0))==0 or min(np.sum(S, axis=1))==0:
    print('Yes')
    exit()
if (S[0][0] == 0 and S[1][1] == 0 and S[2][2] == 0) or (S[2][0] == 0 and S[1][1] == 0 and S[0][2] == 0):
    print('Yes')
    exit()
print('No')
Buggy code:
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [input() for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
flg = false
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[1] == A2[2] == A3[3] or A1[3] == A2[2] == A3[1]:
    print 'Yes'
    exit()
print('No')

Fixed code:
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
listb = [int(input()) for i in range(N)]

for item in listb:
    for i in range(3):
        if A1[i] == item:
            A1[i] = 0
    for j in range(3):
        if A2[j] == item:
            A2[j] = 0
    for k in range(3):
        if A3[k] == item:
            A3[k] = 0
if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
    print('Yes')
    exit()
for i in range(3):
    if A1[i] == A2[i] and A2[i] == A3[i]:
        print('Yes')
        exit()
if A1[0] == A2[1] == A3[2] or A1[2] == A2[1] == A3[0]:
    print('Yes')
    exit()
print('No')
Buggy code:
def get(A, ar, ac):
    if ar > 2 or ar < -2 or ac > 2 or ar < -2:
        return 0
    return A[ar][ac]

def check(A, ar, ac):
    if 0 == get(A, ar-1, ac-1) and 0 == get(A, ar-2, ac-2) and 0 == get(A, ar+1, ac+1) and 0 == get(A, ar+2, ac+2):
        return True
    if 0 == get(A, ar+1, ac-1) and 0 == get(A, ar+2, ac-2) and 0 == get(A, ar-1, ac+1) and 0 == get(A, ar-2, ac+2):
        return True
    if 0 == get(A, ar+1, ac) and 0 == get(A, ar+2, ac) and 0 == get(A, ar-1, ac) and 0 == get(A, ar-2, ac):
        return True
    if 0 == get(A, ar, ac+1) and 0 == get(A, ar, ac+2) and 0 == get(A, ar, ac-1) and 0 == get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    print(A)
                    import sys
                    sys.exit(0)
                continue
print("No")
print(A)


Fixed code:
def get(A, ar, ac):
    if ar > 2 or ar < 0 or ac > 2 or ac < 0:
        return 0
    if A[ar][ac] == 0:
        return 1
    return 0

def check(A, ar, ac):
    # print( get(A, ar-1, ac-1) + get(A, ar-2, ac-2) + get(A, ar+1, ac+1) + get(A, ar+2, ac+2))
    if 2 == get(A, ar-1, ac-1) + get(A, ar-2, ac-2) + get(A, ar+1, ac+1) + get(A, ar+2, ac+2):
        return True
    if 2 == get(A, ar+1, ac-1) + get(A, ar+2, ac-2) + get(A, ar-1, ac+1) + get(A, ar-2, ac+2):
        return True
    if 2 == get(A, ar+1, ac) + get(A, ar+2, ac) + get(A, ar-1, ac) + get(A, ar-2, ac):
        return True
    if 2 == get(A, ar, ac+1) + get(A, ar, ac+2) + get(A, ar, ac-1) + get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    # print(A)
                    import sys
                    sys.exit(0)
                continue
print("No")
# print(A)
Buggy code:
import sys

AList = []
BingoList = [[0, 0, 0],
             [0, 0, 0],
             [0, 0, 0]]

for i in range(3):
    AList.append(list(map(int, input().split())))
    

N = int(input())

tmp = -1
for i in range(N):
    tmp = int(input())
    for p in range(3):
        for q in range(3):
            if AList[p][q] == tmp:
                BingoList[i][q] = 1

for i in range(3):
    if BingoList[i][0] == 1 and BingoList[i][1] == 1 and BingoList[i][2] == 1:
        print('Yes')
        sys.exit(0)

for i in range(3):
    if BingoList[0][i] == 1 and BingoList[1][i] == 1 and BingoList[2][i] == 1:
        print('Yes')
        sys.exit(0)

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

Fixed code:
import sys

AList = []
BingoList = [[0, 0, 0],
             [0, 0, 0],
             [0, 0, 0]]

for i in range(3):
    AList.append(list(map(int, input().split())))
    

N = int(input())

tmp = -1
for i in range(N):
    tmp = int(input())
    for p in range(3):
        for q in range(3):
            if AList[p][q] == tmp:
                BingoList[p][q] = 1

for i in range(3):
    if BingoList[i][0] == 1 and BingoList[i][1] == 1 and BingoList[i][2] == 1:
        print('Yes')
        sys.exit(0)

for i in range(3):
    if BingoList[0][i] == 1 and BingoList[1][i] == 1 and BingoList[2][i] == 1:
        print('Yes')
        sys.exit(0)

if BingoList[0][0] == 1 and BingoList[1][1] == 1 and BingoList[2][2] == 1:
    print('Yes')
elif BingoList[2][0] == 1 and BingoList[1][1] == 1 and BingoList[0][2] == 1:
    print('Yes')
else:
    print('No')
Buggy code:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        print("Yes")
        exit(0)
    if A[0][1] == A[1][i] == A[2][i]:
        print("Yes")
        exit(0)

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

Fixed code:
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

for i in range(3):
    for j in range(3):
        if A[i][j] in b:
            A[i][j] = 0

if A[0][0] == A[1][0] == A[2][0]:
    print("Yes")
elif A[0][0] == A[0][1] == A[0][2]:
    print("Yes")
elif A[0][1] == A[1][1] == A[2][1]:
    print("Yes")
elif A[0][2] == A[1][2] == A[2][2]:
    print("Yes")
elif A[1][0] == A[1][1] == A[1][2]:
    print("Yes")
elif A[2][0] == A[2][1] == A[2][2]:
    print("Yes")
elif A[0][0] == A[1][1] == A[2][2]:
    print("Yes")
elif A[0][2] == A[1][1] == A[2][0]:
    print("Yes")
else:
    print("No")
Buggy code:
n, m = map(int, input().split())
a = [0]*n
for i in range(m):
  s, c = map(int, input().split())
  if a[s-1] == 0:
    a[s-1] = c
  else:
    if a[s-1] == c:
      continue
    else:
      print(-1)
      exit()
  
if n >1 and a[0] == 0:
  print(-1)
  
elif n == 1 and a[0] == 0:
  print(0)
  exit()
  
b = [str(x) for x in a]
print(''.join(b))

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


for i in range(m):

  s, c = map(int, input().split())
  if a[s-1] == '*':
    a[s-1] = c
  else:
    if a[s-1] == c:
      continue
    else:
      print(-1)
      exit()
  
if n >1 and a[0] == 0:
  print(-1)
  exit()
elif n >1 and a[0]=='*':
  a[0] = 1

  
b = [str(x) for x in a]
ans= ''.join(b)
print(ans.replace('*', '0'))
Buggy code:
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
t=''.join(tmp)
print(t)

Fixed code:
import sys
n,m=map(int,input().split())
tmp=[-1]*n
for _ in range(m):
    s,c=map(int,input().split())
    s-=1
    if tmp[s]<0:
        tmp[s]=c
    if tmp[s]!=c:
        print(-1)
        sys.exit()
if tmp[0]==0 and n>1:
    print(-1)
    sys.exit()
if tmp[0]<0 and n>1:
    tmp[0]=1
if n==1 and tmp[0]==-1:
    tmp[0]=0
for i in range(1,n):
    if tmp[i]<0:
        tmp[i]=0
for i in tmp:
    print(i,end='')
Buggy code:
N,M = list(map(int,input().split()))
"""
N=1 0~9
N=2 10~99
N=3 100~999
N   10**(N-1)~10**N-1
"""
S = []
C = []
for i in range(M):
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

# print(S)
# print(C)

y = 10**N

if N == 1:
    L,R = 0,10
elif N == 2:
    L,R = 10,100
elif N == 3:
    L,R = 100,1000
    
for i in range(L,R):
    f = True
    print(i)
    for j in range(M):
        if str(i)[S[j]-1] != str(C[j]):
            f = False
            # print("False")
            break
    if f:
        y = min(y,i)
        
if y == 10**N:
    y = -1

print(y)

Fixed code:
N,M = list(map(int,input().split()))
"""
N=1 0~9
N=2 10~99
N=3 100~999
N   10**(N-1)~10**N-1
"""
S = []
C = []
for i in range(M):
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

# print(S)
# print(C)

y = 10**N

if N == 1:
    L,R = 0,10
elif N == 2:
    L,R = 10,100
elif N == 3:
    L,R = 100,1000
    
for i in range(L,R):
    f = True
    # print(i)
    for j in range(M):
        if str(i)[S[j]-1] != str(C[j]):
            f = False
            # print("False")
            break
    if f:
        y = min(y,i)
        
if y == 10**N:
    y = -1

print(y)
Buggy code:
a = input().split()
N=int(a[0])
M=int(a[1])
ans=[-1]*N
for i in range(M):
  s,c = map(int, input().split())
  if s==1 and c==0 and N==1:
    print(-1)
    break
  elif ans[s-1]==-1:
    ans[s-1]=c
  elif ans[s-1]==c:
    pass
  elif ans[s-1]!=c and ans[s-1]!=-1:
    print(-1)
    break
else:
  if ans[0]==-1:
    ans[0]=1
  for j in range(1,N):
    if ans[j]==-1:
      ans[j]=0
res=map(str,ans)
res=''.join(res)
print(res)

Fixed code:
a = input().split()
N=int(a[0])
M=int(a[1])
ans=[-1]*N
for i in range(M):
  s,c = map(int, input().split())
  if s==1 and c==0 and N!=1:
    print(-1)
    exit()
    break
  elif ans[s-1]==-1:
    ans[s-1]=c
  elif ans[s-1]==c:
    pass
  elif ans[s-1]!=c and ans[s-1]!=-1:
    print(-1)
    exit()
    break
else:
  if ans[0]==-1:
    ans[0]=1 if N!=1 else 0
  for j in range(1,N):
    if ans[j]==-1:
      ans[j]=0
res=map(str,ans)
res=''.join(res)
print(int(res))
Buggy code:
n, m = map(int, input().split())

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c
        
elif ans[0] == 0 and n >= 2:
    print(-1)
    exit()
    
elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)


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

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
Buggy code:
def main():
    n, m = map(int, input().split())
    
    ans = []
    check = []
    false_flg = 0
    for i in range(n):
        ans.append('0')
        check.append(0)

    for j in range(m):
        s, c = input().split()
        if check[int(s)-1] == 0:
            check[int(s)-1] = 1
            ans[int(s)-1] = c
        else:
            false_flg = 1
    
    tmp = int("".join(ans))
    
    if tmp // 10**(n-1) > 0 and false_flg != 1:
        print(tmp)
    else:
        print(-1)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n, m = map(int, input().split())
    
    ans = []
    check = []
    check_once = []
    false_flg = 0
    for i in range(n):
        ans.append('0')
        check.append(0)
        check_once.append(0)

    for j in range(m):
        s, c = input().split()

        if int(s) == 1 and int(c) == 0 and n != 1:
            false_flg = 1

        if check[int(s)-1] == 0:
            ans[int(s)-1] = c
            check[int(s)-1] = 1

        elif check[int(s)-1] == 1 and ans[int(s)-1] == c:
            ans[int(s)-1] = c

        else:
            false_flg = 1
    
    tmp = int("".join(ans))
    
    if tmp // 10**(n-1) > 0 and false_flg != 1:
        print(tmp)

    elif false_flg != 1:
        if tmp == 0 and n == 1:
            print(0)
        else:
            tmp_ = 10**(n-1) + int(tmp)
            print(tmp_)
    else:
        print(-1)


if __name__ == '__main__':
    main()
Buggy code:
N,M=map(int,input().split())
s=[]
c=[]
for _ in range(M):
    S,C=map(int,input().split())
    s.append(S)
    c.append(C)

num=[10]*N

for i in range(M):
    if s[i]==1 and c[i]==0:
        num="-1"
        break
    elif num[s[i]-1]==10:
        num[s[i]-1]=c[i]
    elif num[s[i]-1]!=10 and num[s[i]-1]!=c[i]:
        num="-1"
        break
for l in range(N):
    if num[l]==10:
        num[l]=0
if num=="-1":
    print(num)
else:
    if num[0]==0:
        num[0]=1
    for j in range(N):
        print(num[j],end="")

Fixed code:
N,M=map(int,input().split())
s=[]
c=[]
for _ in range(M):
    S,C=map(int,input().split())
    s.append(S)
    c.append(C)

num=[10]*N

for i in range(M):
    if N>1 and s[i]==1 and c[i]==0:
        num="-1"
        break
    elif num[s[i]-1]==10:
        num[s[i]-1]=c[i]
    elif num[s[i]-1]!=10 and num[s[i]-1]!=c[i]:
        num="-1"
        break
if num=="-1":
    print(num)
else:
    for l in range(N):
        if num[l]==10:
            num[l]=0
    if num[0]==0 and N>1:
        num[0]=1
    for j in range(N):
        print(num[j],end="")
Buggy code:
import sys
N,M = map(int,input().split())
s = [0] * M
c = [0] * M
a = ["1"] + ["0"] * (N-1)
for i in range(M):
    s[i],c[i] = map(int,input().split())
for j in range(N):
    if s[j] == 1 and c[j] == 0:
        print(-1)
        sys.exit()
    elif a[s[j]-1] == "0":
        a[s[j]-1] = str(c[j])
    elif a[s[j]-1] == str(c[j]):
        pass
    else:
        print(-1)
        sys.exit()
ans = "".join(a)
print(int(ans))

Fixed code:
import sys
N,M = map(int,input().split())
s = [0] * M
c = [0] * M
a = ["-1"] * (N)
if N == 1 and M == 0:
    print(0)
    sys.exit()
for i in range(M):
    s[i],c[i] = map(int,input().split())

for j in range(M):
    if s[j] == 1 and c[j] == 0 and N != 1:
        print(-1)
        sys.exit()
    elif a[s[j]-1] == "-1":
        a[s[j]-1] = str(c[j])
    elif a[s[j]-1] == str(c[j]):
        pass
    else:
        print(-1)
        sys.exit()
if a[0] == "-1":
    a[0] = "1"
for h in range(1,N):
    if a[h] == "-1":
        a[h] = "0"
ans = "".join(a)
print(int(ans))
Buggy code:
N, M = map(int,input().split())
answer = [0]*M
ae = 0

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == 0:
    answer[-s] = c
  elif answer[-s] != 0 and answer[-s] != c:
    print(-1)
    ae = 1
    break
if ae == 0 and answer[M-1] == 0 and M != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(M):
    print(answer[-(i+1)],end='')

Fixed code:
N, M = map(int,input().split())
answer = [-1]*N
ae = 0
  

for i in range(M):
  s,c = map(int,input().split())
  if answer[-s] == -1:
    answer[-s] = c
  elif answer[-s] != -1 and answer[-s] != c:
    print(-1)
    ae = 1
    break
for i in range(N):
  if answer[i] == -1:
    if i == N-1 and N > 1:
      answer[i] = 1
    else:
      answer[i] = 0
if ae == 0 and answer[N-1] == 0 and N != 1:
  print(-1)
  ae = 1
elif ae == 0:
  for i in range(N):
    print(answer[-(i+1)],end='')
Buggy code:
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        exit()
    else:
        ans[s-1] = c
if ans[0] == 0:
    print(-1)
    exit()  
for i in range(N):
    if ans[i] == -1:
        if i != 0:
            ans[i] = 0
        else:
            ans[i] = 1
    ans[i] = str(ans)
ans = ''.join(ans)
print(int(ans))

Fixed code:
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
flag = 0
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        flag = 1
    else:
        ans[s-1] = c
if N != 1 and ans[0] == 0:
    flag = 1
elif N == 1 and ans[0] == 0:
    print(0)
    exit()
if N == 1:
    if ans[0] == -1:
        print(0)
        exit()
for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0
    ans[i] = str(ans[i])
ans = ''.join(ans)
if flag == 1:
    print(-1)
    exit()
print(int(ans))