Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
if a>=13:
  print(b)
elif a>=6 and a<=12:
  print(int(b/2))
else:
  print(0)

Fixed submission:
a,b=map(int,input().split())


if a>=13:
  print(b)
elif a>=6 and a<=12:
  print(int(b//2))
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
if a>=13:
  print(b)
elif a>=6 and a<=12:
  print(int(b/2))
else:
  print(0)

Fixed submission:
a,b=map(int,input().split())


if a>=13:
  print(b)
elif a>=6 and a<=12:
  print(int(b//2))
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
for i in range(N-1):
  ans += (num_lis[i]*sum(num_lis[i+1:N]))%p

print(ans%p)

Fixed submission:
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
s = sum(num_lis)
num = 0
for i in range(N):
  num += num_lis[i]
  ans += ((s-num)*num_lis[i])%p
  
print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
for i in range(N-1):
  ans += (num_lis[i]*sum(num_lis[i+1:N]))%p

print(ans%p)

Fixed submission:
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
s = sum(num_lis)
num = 0
for i in range(N):
  num += num_lis[i]
  ans += ((s-num)*num_lis[i])%p
  
print(ans%p)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
for i in range(N-1):
  for j in range(i+1,N):
    ans += (num_lis[i]*num_lis[j])%p

print(ans%p)

Fixed submission:
N = int(input())
num_lis = list(map(int, input().split()))
ans = 0
p = 10**9+7
s = sum(num_lis)
num = 0
for i in range(N):
  num += num_lis[i]
  ans += ((s-num)*num_lis[i])%p
  
print(ans%p)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = np.zeros((R, C), dtype=int)
for i,j,k in item_lis:
  item_map[i-1,j-1] = k
  
dp = np.zeros((C+1, 4), dtype=int)
for i in range(R):
  new_dp = np.zeros((C+1, 4), dtype=int)
  for j in range(4):
    new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,j])
  dp = new_dp
  for k in range(C):
    for l in range(2, -1, -1):
      dp[k,l+1] = max(dp[k,l+1], dp[k,l]+item_map[i,k])
    for m in range(1,4):
      dp[k+1,m] = max(dp[k+1,m], dp[k,m])

ans = max(dp[C-1,:])
print(ans)

Fixed submission:
import numba
from numba import jit
import numpy as np
  
@jit
def main(r, c):
  dp = np.zeros((c+1, 4), np.int64)
  for i in range(r):
    new_dp = np.zeros((c+1, 4), np.int64)
    for j in range(4):
      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,j])
    dp = new_dp
    for k in range(c):
      for l in range(2, -1, -1):
        dp[k,l+1] = max(dp[k,l+1], dp[k,l]+item_map[i,k])
      for m in range(1,4):
        dp[k+1,m] = max(dp[k+1,m], dp[k,m])
  return max(dp[c-1,:])


R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = np.zeros((R, C), np.int64)
for i,j,k in item_lis:
  item_map[i-1,j-1] = k

print(main(R, C))

Buggy python submission (verdict: Runtime Error):
R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = [[0 for i in range(C)] for i in range(R)]
for i,j,k in item_lis:
  item_map[i-1][j-1] = k
inf = float("inf")
dp = [[[0 for i in range(4)] for i in range(C)] for i in range(R)]

def calc(x, y, z, lis1=item_map, lis2=dp):
  now_score = dp[x][y][z]
  dp1 = -inf
  dp2 = -inf
  dp3 = -inf
  dp4 = -inf
  if x+1 <= R-1:
    if z < 3:
      if lis1[x][y] != 0:
        dp1 = calc(x+1, y, 0)+lis1[x][y]+now_score
    dp2 = calc(x+1, y, 0)+now_score
      
  if y+1 <= C-1:
    if z < 3:
      if lis1[x][y] != 0:
        dp3 = calc(x, y+1, z+1)+lis1[x][y]+now_score
    dp4 = calc(x, y+1, z)+now_score
  
  if x == R-1 and y == C-1:
    if z < 3:
      new_score = now_score+lis1[x][y]
    else:
      new_score = now_score
  else:
    new_score = max(now_score, dp1, dp2, dp3, dp4)
  return new_score

ans = calc(0, 0, 0)
print(ans)

Fixed submission:
import numba
from numba import jit
import numpy as np
  
@jit
def main(r, c):
  dp = np.zeros((c+1, 4), np.int64)
  for i in range(r):
    new_dp = np.zeros((c+1, 4), np.int64)
    for j in range(4):
      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,j])
    dp = new_dp
    for k in range(c):
      for l in range(2, -1, -1):
        dp[k,l+1] = max(dp[k,l+1], dp[k,l]+item_map[i,k])
      for m in range(1,4):
        dp[k+1,m] = max(dp[k+1,m], dp[k,m])
  return max(dp[c-1,:])


R, C, K = map(int, input().split())
item_lis = list(list(map(int, input().split())) for i in range(K))
item_map = np.zeros((R, C), np.int64)
for i,j,k in item_lis:
  item_map[i-1,j-1] = k

print(main(R, C))
Buggy python submission (verdict: Runtime Error):
H, A = map(int, input().split())
times = 0
crack = Fasle
while True:
  H -= A
  times += 1
  if H <= 0:
    crack = True
  if crack:
    break
print(times)

Fixed submission:
H, A = map(int, input().split())
times = 0
crack = False
while True:
  H -= A
  times += 1
  if H <= 0:
    break
print(times)

Buggy python submission (verdict: Runtime Error):
H, A = map(int, input().spit())
times = 0
crack = Fasle
while True:
  H -= A
  times += 1
  if H < 0:
    crack = True
  if crack:
    break
print(times)


Fixed submission:
H, A = map(int, input().split())
times = 0
crack = False
while True:
  H -= A
  times += 1
  if H <= 0:
    break
print(times)
Buggy python submission (verdict: Runtime Error):
H, N = input().split()
lis = list(map(int, input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

Fixed submission:
H, N = map(int, input().split())
lis = list(map(int, input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
lis = list(map(input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

Fixed submission:
H, N = map(int, input().split())
lis = list(map(int, input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
H, N = map(int, input().split())
lis = list(input().split())
if sum(lis) >= H:
  print("Yes")
else:
  print("No")

Fixed submission:
H, N = map(int, input().split())
lis = list(map(int, input().split()))
if sum(lis) >= H:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(input().split())

times = 0
min_num = N+1
for i in range(len(P)):
  safe = True
  if min_num < int(P[i]):
    continue
  min_num = int(P[i])
  for j in range(i+1):
    if not int(P[i]) <= int(P[j]):
      safe = False
  if safe:
    times += 1
print(times)

Fixed submission:
N = int(input())
P = list(input().split())

times = 0
min_num = N+1
for i in range(len(P)):
  safe = True
  if min_num < int(P[i]):
    continue
  min_num = int(P[i])
  times += 1
print(times)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans_num_lis = [0 for i in range(N)]
pre_ans_lis = [0 for i in range(N)]
ans_lis = [0 for i in range(N)]
for i in range(M):
  problem, result = input().split()
  problem_num = int(problem)
  if result == "WA":
    pre_ans_lis[problem_num] += 1
  if result == "AC" and not ans_num_lis[problem_num]:
    ans_num_lis[problem_num] = 1
    ans_lis[problem_num] = pre_ans_lis[problem_num]

print(sum(ans_num_lis), sum(ans_lis))

Fixed submission:
N, M = map(int, input().split())
lis = [[] for _ in range(N)]
for _ in range(M):
  question, result = input().split()
  question = int(question)
  lis[question-1].append(result)  

AC_times = 0
WA_times = 0
for i in range(N):
  pre_WA_times = 0
  for j in lis[i]:
    passed = False
    if not passed:
      if j == "AC":
        passed = True
        WA_times += pre_WA_times
      elif j == "WA":
        pre_WA_times += 1
    if passed:
      AC_times += 1
      break
      
print(AC_times, WA_times)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
judge_lis = [[] for i in range(N)]
for i in range(M):
  problem, result = input().split()
  judge_lis[int(problem)-1].append(result)

ans_lis = [0 for i in range(N)]
ans_num = 0
for i in range(N):
  j = 0
  while j < len(judge_lis[i]):
    if not "AC" in judge_lis[i]:
      break
    if judge_lis[i][j] == "WA":
      ans_lis[i] += 1
    if judge_lis[i][j] == "AC":
      ans_num += 1
      break
    j += 1
      
print(ans_num, sum(ans_lis))

Fixed submission:
N, M = map(int, input().split())
lis = [[] for _ in range(N)]
for _ in range(M):
  question, result = input().split()
  question = int(question)
  lis[question-1].append(result)  

AC_times = 0
WA_times = 0
for i in range(N):
  pre_WA_times = 0
  for j in lis[i]:
    passed = False
    if not passed:
      if j == "AC":
        passed = True
        WA_times += pre_WA_times
      elif j == "WA":
        pre_WA_times += 1
    if passed:
      AC_times += 1
      break
      
print(AC_times, WA_times)
Buggy python submission (verdict: Runtime Error):
N = int(input())
true_list = [0]
false_list = []
for j in range(1, N+1):
  false_list.append(j)

a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))
    
while True:
  pre_true_list = true_list
  pre_false_list = false_list
  for i in true_list:
    for j in range(len(a[i])):
      kotoba = a[i][j][1]
      person = a[i][j][0]
      if kotoba:
        if false_list.count(person):
          false_list.remove(person)
          true_list.append(person)
      else:
        if true_list.count(person):
          true_list.remove(person)
          false_list.append(person)
        
  for i in false_list:
    for j in range(len(a[i])):
      kotoba = a[i][j][1]
      person = a[i][j][0]
      if not kotoba:
        if true_list.count(person):
          true_list.remove(person)
          false_list.append(person)
      else:
        if false_list.count(person):
          false_list.remove(person)
          true_list.append(person)
  if pre_true_list == true_list and pre_false_list == false_list:
    break
    
print(len(true_list))

Fixed submission:
N = int(input())
a = [[] for _ in range(N)]
for i in range(N):
  A_i = int(input())
  for j in range(A_i):
    a[i].append(list(map(int, input().split())))
 
max_honest = 0
for i in range(2**N):
  contradiction = False
  honest_p = []
  unkind_p = []
  doubt_honest_p = []
  doubt_unkind_p = []
  length = len(format(2**N-1, "b"))
  bin_num = format(i, "b").zfill(length)
  for j in range(length):
    if (i >> j) & 1:
      if not j+1 in honest_p:
      	honest_p.append(j+1)
      if not j+1 in doubt_honest_p:
      	doubt_honest_p.append(j+1)
      for k in a[j]:
        p = k[0]
        t = k[1]
        if t:
          if not p in honest_p:
          	honest_p.append(p)
        else:
          if not p in unkind_p: 
          	unkind_p.append(p)
    else:
      if not j+1 in unkind_p:
        unkind_p.append(j+1)
      if not j+1 in doubt_unkind_p:
      	doubt_unkind_p.append(j+1)
  if len(list(set(honest_p) & set(unkind_p))) != 0:
    contradiction = True
  if not contradiction and max_honest <= len(doubt_honest_p):
    max_honest = len(doubt_honest_p)
    
print(max_honest)
Buggy python submission (verdict: Runtime Error):
S = str(input())
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  printt(6-ind)

Fixed submission:
S = input()
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  print(6-ind)

Buggy python submission (verdict: Runtime Error):
S = input()
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  printt(6-ind)

Fixed submission:
S = input()
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  print(6-ind)
Buggy python submission (verdict: Runtime Error):
num = input()

intNum = 0

loop = len(num)
for i in range(loop):
  intNum += int(num)[i]

if intNum % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
num = input()

intNum = 0

loop = len(num)
for i in range(loop):
  intNum += int(num[i])

if intNum % 9 == 0:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
num = int(input())

intNum = 0

loop = len(num)
for i in loop:
  intNum += int(num)[i]
  
if inNum % 9 == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
num = input()

intNum = 0

loop = len(num)
for i in range(loop):
  intNum += int(num[i])

if intNum % 9 == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
input_line = int(input().split())

result = input_line[0]*input_line[1]
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
x, y = map(int,input().split())

result = x*y
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):
input_line = input()

tarList = input_line.split()
result = tarList[0]*tarList[1]
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
x, y = map(int,input().split())

result = x*y
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):
input_list = input()
 
result = input_list[0]*input_list[1]
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
x, y = map(int,input().split())

result = x*y
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy python submission (verdict: Runtime Error):
input_list = input()

result = input_list[0]*input_list[1]

if result % 2 == 0:
  return 'Even'
else:
  result 'Odd'

Fixed submission:
x, y = map(int,input().split())

result = x*y
 
if result % 2 == 0:
  print('Even')
else:
  print('Odd')
Buggy python submission (verdict: Runtime Error):
H,_=map(int,input().split())
if H <= list(map(int,input().split())):
    print("Yes")
else:
    print("No")

Fixed submission:
H, _ = map(int, input().split())
if H <= sum(map(int, input().split())):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
ans_r = [K] * N
cor = list(map(int, [input() for i in range(Q)]))
for i in cor:
    ans_r[i - 1] += 1
    ans_r = list(map(lambda x: x - 1, ans_r))
ans_r = list(map(lambda x: "No" if x <= 0 else "Yes", ans_r))
for i in ans_r:
    print(i)


Fixed submission:
N, K, Q = map(int, input().split())
ans_r = [K - Q] * N
cor = list(map(int, [input() for i in range(Q)]))
for i in cor:
    ans_r[i - 1] += 1
for i in ans_r:
    if i <= 0:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
lo = int(input())
N = [input() for i in range(lo)]
for i in range(lo):
    for j in range(i + 1, lo):
        tmp = N[j]
        for k in range(10):
            tmp = tmp.replace(N[i][k], "", 1)
        if tmp == "":
            count += 1
print(count)

Fixed submission:
dic = {}
cou = 0
lop = int(input())
for i in range(lop):
    N = input()
    N = list(N)
    N.sort()
    N = "".join(N)
    if N in dic:
        dic[N] += 1
    else:
        dic[N] = 1
lis = list(dic.values())
print(sum(list(map(lambda x: int((x * (x - 1)) / 2), lis))))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[-1])


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
As = sorted(A)
for i in range(N):
    if A[i] == As[-1]:
        print(As[-2])
    else:
        print(As[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]
for i in range(N):
    tmp = A.copy()
    tmp.pop(i)
    print(max(tmp))


Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
As = sorted(A)
for i in range(N):
    if A[i] == As[-1]:
        print(As[-2])
    else:
        print(As[-1])
Buggy python submission (verdict: Runtime Error):
N = input()
tmp = N[0]
for i in range(1,4):
    if tmp == N[i]:
        print("Bad")
        exit(1)
    tmp = N[i]
print("Good")

Fixed submission:
def sec(N):
    tmp = N[0]
    for i in range(1, 4):
        if tmp == N[i]:
            print("Bad")
            return 0
        tmp = N[i]
    print("Good")


sec(input())
Buggy python submission (verdict: Runtime Error):
N = int(input())
# [exit(0) if i ** 2 > N else print(i ** 2) if (i+1) ** 2 > N else print("", end="") for i in range(1, N)]
for i in range(1, N):
    if i ** 2 > N:
        print((i - 1) ** 2)
        break
    if i ** 2 == N:
        print(i ** 2)
        break


Fixed submission:
N = list(map(str, [input() for i in range(2)]))
N = "".join(N)
print("YES") if N == N[::-1] else print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
count = 0
N = int(input())
string = list(map(int, [input() for i in range(N)]))
for i in set(string):
    if string.count(i) % 2 != 0:
        count += 1
print(count)


Fixed submission:
N = int(input())
L = set()
for i in range(N):
    L ^= {input()}
print(len(L))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")


Fixed submission:
a, b = input().split()
if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")
Buggy python submission (verdict: Runtime Error):
A=1
for i in range(1,int(input)+1):
  A*=i
  A%=1000000007
print(A)

Fixed submission:
A=1
for i in range(1,int(input())+1):
  A*=i
  A%=1000000007
print(A)
Buggy python submission (verdict: Runtime Error):
print("".join(sorted([input() for i in range(int("{}".format(input().split().pop(-1))))])))


Fixed submission:
print("".join(sorted([input() for i in range(int("{}".format(input().split().pop(0))))])))
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ab_list = a_list + b_list
ab_list.sort()

dp = [False] * 200000*2

dp[0] = ab_list[0]
j = ab_list[0]

count=1

for i in range(1,len(ab_list)):
    # print(ab_list[i]+j)
    a_min = a_list.pop(0)
    b_min = b_list.pop(0)
    dp[i] = min(a_min, b_min) + j
    j += ab_list[i]
    
    if dp[i]<=k:
        count+=1
    
    if j+ab_list[i+1]>k:
        break

    

print(count)




Fixed submission:
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

a = []
a.append(0)
for i in range(n):
    a.append(a[i]+a_list[i])
    
b = []
b.append(0)
for i in range(m):
    b.append(b[i]+b_list[i])
    

ans = 0
for i in range(n+1):
    if a[i]>k:
        break
    while a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i+m)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = []
count = 0
for i in range(n):
    s = input()
    
    if not s in s_list:
        s_list.append(s)
        count += 1

print(count)

Fixed submission:
n = int(input())

dic = {}

for i in range(n):
    s = input()
    dic[s] = dic.get(s, 0) + 1

print(len(dic.keys()))
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
# print(n, k)


min_result = n
flag = 0
dic = {}

z = n // k
zz = n //z
result = zz

while flag==0:
    result = abs(result - k) 
    print('result',result)
    print('min_result',min_result)
    if result <= min_result:
        min_result = result
        dic[result] = dic.get(result, 0) + 1

        if dic[result] > 1:
            flag=1
print(min_result)

Fixed submission:
n, k = list(map(int, input().split()))
# print(n, k)


x = n % k
y = k - x

if x > y:
    print(y)
    
else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
for i in range(q):
    query = list(input().split())
    # print(query)
    
    if query[0]=='1':
        s.reverse()
    elif query[0]=='2' and query[1]=='1':
        s.insert(0,query[2])
    elif query[0]=='2' and query[1]=='2':
        s.append(query[2])
[print(a, end='') for a in s]

Fixed submission:
import sys
from collections import deque

s = input()
q = int(input())
ans = deque()
ans.append(s)
reverseFlg = False

for i in range(q):
    query = list(input().split())
    # print(query)

    if query[0]=='1':
        reverseFlg = not reverseFlg
    else:
        if reverseFlg:
            if query[1]=='1':
                ans.append(query[2])
            else:
                ans.appendleft(query[2])
        else:
            if query[1]=='1':
                ans.appendleft(query[2])
            else:
                ans.append(query[2])
    

out = ''.join(ans)

if reverseFlg:
    print(out[::-1])
else:
    print(out)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

    
out = ['a']*n
err_flg = False

for i in range(m):
    s = list(map(int, input().split()))

    if s[0]==1 and s[1]==0 and n > 1:
        err_flag = True
    elif s[0]==1 and s[1]==0 and n==1:
        print('0')
    elif m==0 and n==1:
        print('0')

    if out[s[0]-1]=='a':
        out[s[0]-1] = s[1]
    elif out[s[0]-1]==s[1]:
        out[s[0]-1] = s[1]
    # elif out[s[0]-1]!=s[1]:
    elif out[s[0]-1]!=s[1]:
        err_flg = True


if out[0]=='a' and n>1:
    out[0]=1
    
out.replace('a','0')
out_s = "".join(map(str,out))

if err_flg:
    print('-1')
# elif m==0 and n==1:
#     print(0)
else:
    print(out_s)

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

    
out = ['a']*n
err_flg = False
err_flg2 = False 

for i in range(m):
    s = list(map(int, input().split()))
    # print(s)

    if s[0]==1 and s[1]==0 and n==1:
        err_flg2 = True
    elif m==0 and n==1:
        err_flg2 = True
    elif s[0]==1 and s[1]==0 and n > 1:
        # print('kore')
        err_flg = True

    if out[s[0]-1]=='a':
        out[s[0]-1] = s[1]
    elif out[s[0]-1]==s[1]:
        out[s[0]-1] = s[1]
    # elif out[s[0]-1]!=s[1]:
    elif out[s[0]-1]!=s[1]:
        err_flg = True


if out[0]=='a' and n>1:
    out[0]=1
    

out_s = "".join(map(str,out))

if err_flg2:
    print('0')
    # print('err2')
elif err_flg:
    print('-1')
    # print('err')
else:
    print(out_s.replace('a','0'))

Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

    
out = [a]*n
err_flg = False

for i in range(m):
    s = list(map(int, input().split()))

    if s[0]==1 and s[1]==0 and n > 1:
        err_flag = True
    elif s[0]==1 and s[1]==0 and n==1:
        print('0')
    elif m==0 and n==1:
        print('0')

    if out[s[0]-1]==0:
        out[s[0]-1] = s[1]
    elif out[s[0]-1]==s[1]:
        out[s[0]-1] = s[1]
    # elif out[s[0]-1]!=s[1]:
    elif out[s[0]-1]!=s[1]:
        err_flg = True


if out[0]=='a' and n>1:
    out[0]=1
out_s = "".join(map(str,out))

if err_flg:
    print('-1')
# elif m==0 and n==1:
#     print(0)
else:
    print(out_s)

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

    
out = ['a']*n
err_flg = False
err_flg2 = False 

for i in range(m):
    s = list(map(int, input().split()))
    # print(s)

    if s[0]==1 and s[1]==0 and n==1:
        err_flg2 = True
    elif m==0 and n==1:
        err_flg2 = True
    elif s[0]==1 and s[1]==0 and n > 1:
        # print('kore')
        err_flg = True

    if out[s[0]-1]=='a':
        out[s[0]-1] = s[1]
    elif out[s[0]-1]==s[1]:
        out[s[0]-1] = s[1]
    # elif out[s[0]-1]!=s[1]:
    elif out[s[0]-1]!=s[1]:
        err_flg = True


if out[0]=='a' and n>1:
    out[0]=1
    

out_s = "".join(map(str,out))

if err_flg2:
    print('0')
    # print('err2')
elif err_flg:
    print('-1')
    # print('err')
else:
    print(out_s.replace('a','0'))