Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

s = []
c = []
num = []

for i in range(n):
    num.append(-1)

for i in range(m):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

for i in range(len(s)):
    # 桁条件の桁が桁数より大きい場合
    if s[i] > n:
        print(-1)
        exit()
    # ある桁の条件が矛盾している場合
    if num[s[i]-1] is not -1 and num[s[i]-1] is not c[i]:
        print(-1)
        exit()
    num[s[i]-1] = c[i]

# 先頭から条件指定されていない桁を削除していく
for i in range(len(num)):
    if num.index(-1) is i:
        del num[i]
    else:
        print(''.join([str(x) for x in num]).replace("-1", "0"))
        exit()

if num == []:
    print(-1)
else:
    print(num)

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

s = []
c = []
num = []

for i in range(m):
    si, ci = map(int, input().split())
    s.append(si)
    c.append(ci)

if len(c) is 0:
    if n is 1:
        print(0)
        exit()
    elif n is 2:
        print(10)
        exit()
    else:
        print(100)
        exit()
        

for j in range(n):
    num.append(-1)

for k in range(len(s)):
    if s[k] is 1 and c[k] is 0 and n is not 1:
        print(-1)
        exit()
    if num[s[k]-1] is not -1 and num[s[k]-1] is not c[k]:
        print(-1)
        exit()
    else:
        num[s[k]-1] = c[k]

is_filled = False
for l in range(n):
    if num[l] is -1:
        if not is_filled:
            num[l] = 1
            is_filled = True
        else:
            num[l] = 0
    else:
        is_filled = True

print(''.join([str(x) for x in num]))
Buggy python submission (verdict: Runtime Error):
n = raw_input()
print(n.count("1"))

Fixed submission:
n = input()
print(n.count("1"))
Buggy python submission (verdict: Runtime Error):
s = input()


if s[0:3].count(s[0]) == 3 or s[1:4].count(s[3])
  print("Yes")
else:
  print("No")
  

Fixed submission:
s = input()


if s[0:3].count(s[0]) == 3 or s[1:4].count(s[3]) == 3:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import fractions

def lcm(a,b):
    g = fractions.gcd(a,b)
    return (a/g) * b

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)

print(int(ans))

Fixed submission:
n = input()

if n == n[::-1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

h, w = map(int, input().split())

m = math.inf
m = min(m, (1 if h % 3 else 0) * w)
m = min(m, (1 if w % 3 else 0) * h)
for _ in range(2):
    for i in range(1, h+1):
        v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)])
        m = min(m, max(v) - min(v))
    h, w = w, h

print(m)

Fixed submission:
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np

h, w = map(int, input().split())

m = 10000000000000000000000000
m = min(m, (1 if h % 3 else 0) * w)
m = min(m, (1 if w % 3 else 0) * h)
for _ in range(2):
    for i in range(1, h+1):
        v = np.array([i*w, w//2*(h-i), (w-w//2)*(h-i)])
        m = min(m, max(v) - min(v))
    h, w = w, h

print(m)
Buggy python submission (verdict: Runtime Error):
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')


Fixed submission:
s = input()

if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
if n == 1:
  start,end = 0,9
elif n == 2:
  start,end = 10,99
else:
  start,end = 100, 999

for i in range(start, end+1):
  flg = True
  for j in l:
    si = str(i)
    if len(si) < j[0]:
      flg = False
      continue

    if si[j[0]-1] != str(j[1]):
      flg = False
      
  if flg == True:
    print(i)
    break
else:
  print(-1)


Fixed submission:
i=int(input())
print(int(i/2) if i%2==0 else int(i//2)+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[input() for _ in range(n)]
sl = set(l)
m = 0

for s in sl:
  if m <= l.count(s):
    m = l.count(s)
    
ans = []
    
for s in sl:
  if m == l.count(s):
    ans.append(s)
    
ans = sorted(ans)

for a in ans:
  print(a)

Fixed submission:
from collections import Counter
n=int(input())
l=[input() for _ in range(n)]

c = Counter(l)
co = c.most_common()[0][1]
ans = []
for s in c.most_common():
  if s[1] < co:
    break
    
  ans.append(s[0])

for a in sorted(ans):
  print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=0
 
for i in range(k,n+1):
  p = sum(l[i-k:i])
  if m < p:
    m = p
    
print((m+k)/2)

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=[]
 
for i in range(k,n+1):
  p = l[i-k:i]
  if sum(m) < sum(p):
    m = p
  
print(sum([m[j]*(m[j]+1)/2/m[j] for j in range(k)]))

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=np.array([0])

for i in range(k,n+1):
  p = np.array(l[i-k:i])
  if np.sum(m) < np.sum(p):
    m = p
  
print(np.sum([m[j]*(m[j]+1)/2/m[j] for j in range(k)]))

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
m=[0]

for i in range(k,n+1):
  p = l[i-k:i]
  if sum(m) < sum(p):
    m = p
  
print(sum([m[j]*(m[j]+1)/2/m[j] for j in range(k)]))

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=0
s=0

for i in range(k,n+1):
  p = l[i-k:i]
  s = sum([p[j]*(p[j]+1)/2/p[j] for j in range(k)])
  
  if ans < s:
    ans = s
  s=0
  
print(ans)

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
ans=[]
s=0

for i in range(k,n+1):
  p = l[i-k:i]
  for j in range(k):
    s += int(0.5*p[j]*(p[j]+1))/p[j]
  
  ans.append(s)
  s=0
  
print(max(ans))

Fixed submission:
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
s = sum(p[:k])
m = s

for i in range(n-k):
  s = s-p[i]+p[i+k]
  if m < s:
    m = s
print((m+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
n,m=map(int,input().split())
wa=0
ac=0
ig=0
l=[(input().split()) for _ in range(m)]
l=sorted(l, key=itemgetter(0))
ll=sorted(l, key=itemgetter(0))

for t in l:
  c,r=t[0],t[1]
  if c == ig:
    continue
  
  if [c,'AC'] not in ll:
    continue
  
  if r == 'WA':
    wa+=1
  elif r == 'AC':
    ac+=1
    ig=c
  del ll[0]
print(ac,wa)

Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=input().split()
  l[int(a)-1].append(b)
  
wacnt=0
accnt=0

for rl in l:
  cnt = 0
  for r in rl:
    if r == 'WA':
      cnt+=1
    elif r == 'AC':
      wacnt+=cnt
      accnt+=1
      break
      
print(accnt, wacnt)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
n,m=map(int,input().split())
wa=0
ac=0
ig=0
l=[(input().split()) for _ in range(m)]
l=sorted(l, key=itemgetter(0))
ll=sorted(l, key=itemgetter(0))

for t in l:
  c,r=t[0],t[1]
  if c == ig:
    continue
  
  if [c,'AC'] not in l:
    continue
  
  if r == 'WA':
    wa+=1
  elif r == 'AC':
    ac+=1
    ig=c
  del ll[0]
print(ac,wa)

Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=input().split()
  l[int(a)-1].append(b)
  
wacnt=0
accnt=0

for rl in l:
  cnt = 0
  for r in rl:
    if r == 'WA':
      cnt+=1
    elif r == 'AC':
      wacnt+=cnt
      accnt+=1
      break
      
print(accnt, wacnt)

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
n,m=map(int,input().split())
wa=0
ac=0
ig=0
l=[(input().split()) for _ in range(m)]
l=sorted(l, key=itemgetter(0))

for t in l:
  c,r=t[0],t[1]
  if c == ig:
    continue
  
  if [c,'AC'] not in l:
    continue
  
  if r == 'WA':
    wa+=1
  elif r == 'AC':
    ac+=1
    ig=c
    
print(ac,wa)

Fixed submission:
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for _ in range(m):
  a,b=input().split()
  l[int(a)-1].append(b)
  
wacnt=0
accnt=0

for rl in l:
  cnt = 0
  for r in rl:
    if r == 'WA':
      cnt+=1
    elif r == 'AC':
      wacnt+=cnt
      accnt+=1
      break
      
print(accnt, wacnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

info = input().split(" ")
N = int(info[0])
K = int(info[1])
Q = int(info[2])
  
point = [K]*N
  
for i in range(1, Q+1):
  person = int(input())
  for n in range(N):
    if person != n+1:
      point[n] = point[n] - 1
      
  
for p in point:
  if p <= 0:
    print("No")
  else:
    print("Yes")


Fixed submission:
import sys

info = input().split(" ")
N = int(info[0])
K = int(info[1])
Q = int(info[2])
  
ns = []
for i in range(N):
  ns.append(K - Q)

for i in range(Q):
  s = int(input())
  s = s - 1
  ns[s] = ns[s] + 1
      
  
for p in ns:
  if p <= 0:
    print("No")
  else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
num = list(input().split(" "))
a = int(num[0])
b = int(num[1])

count = 1

while True:
  if count == 1:
  	plug = a
  else:
    plug = plug + (a - 1) 
  if plug >= b:
    break
  count += 1

print(count)

Fixed submission:
s = input()
s2 = input()
cnt = 0
for st, st2 in zip(s, s2):
  if st == st2:
    cnt += 1
  
print(cnt)

Buggy python submission (verdict: Runtime Error):
cnt = int(input())
nums = list(input().split(" "))
current = 0
maxCnt = 0

for i in range(cnt - 1):
  if int(nums[i]) >= int(nums[i+1]):
    current += 1
  else:
    if maxCnt < current:
    	maxCnt = current
    current = 0

if maxCnt < current:
  maxCnt = current

print(maxCnt)

Fixed submission:
s = input()
s2 = input()
cnt = 0
for st, st2 in zip(s, s2):
  if st == st2:
    cnt += 1
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
print("ABC"+inpit())

Fixed submission:
print("ABC"+input())
Buggy python submission (verdict: Runtime Error):
import sys
a, b = map(int, input().split())
if a != 0 and a%3 = 0:
	print("Possible")
    sys.exit()
if b != 0 and b%3 = 0:
	print("Possible")
    sys.exit()
if a != 0 and b != 0 and (a+b)%3:
	print("Possible")
    sys.exit()

print("Impossible")


Fixed submission:
import sys
a, b = map(int, input().split())
if a != 0 and a%3 == 0:
	print("Possible")
	sys.exit()
if b != 0 and b%3 == 0:
	print("Possible")
	sys.exit()
if a != 0 and b != 0 and (a+b)%3 == 0:
	print("Possible")
	sys.exit()

print("Impossible")
Buggy python submission (verdict: Runtime Error):
import math
print(math.factrial(int(input))%(10**9+7))

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
i = 1
for nn in range(1,n+1):
  i *= nn
  
print(i%(10**9+7))

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
m={"A":list(input()),"B":list(input()),"C":list(input())}

t="A"
for i in range(100):
  if (len(m["A"]) == 0 and t == "A") or (len(m["C"]) == 0 and t == "B") or (len(m["C"]) == 0 and t == "C"):
    ans = t
    break
  c=m[t][0]
  for s in "ABC":
    if m[s][0] == c:
      m[s].pop(0)
  
  t=c.upper()
  
  
print(ans)

Fixed submission:
m={"a":list(input()),"b":list(input()),"c":list(input())}

t="a"
while True:
  if len(m[t]) > 0:
    t = m[t].pop(0)
  else:
    print(t.upper())
    break
Buggy python submission (verdict: Runtime Error):
s = input()
return s[2]==s[3] and s[4] == s[5]

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x = input()
bigpleasure = x//500*1000
smallpleasure = x%500//5*5

print(bigpleasure+smallpleasure)

Fixed submission:
x = int(input())
bigpleasure = (x//500)*1000
smallpleasure = ((x%500)//5)*5

print(bigpleasure+smallpleasure)
Buggy python submission (verdict: Runtime Error):
if input() == 'AAA' or input() == 'BBB':
  print ("No")
else:
  print("Yes")

Fixed submission:
s = input()
if s == 'AAA' or s == 'BBB':
  print ("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())

Amin = A/0.08
if Amin != int(Amin):
  Amin = int(Amin)+1
else Amin = int(Amin)

Bmin = B/0.1
if Bmin != int(Bmin):
  Bmin = int(Bmin)+1
else Bmin = int(Bmin)

rangea = set(range(Amin,int((A+1)/0.08),1))
rangeb = set(range(Bmin,int((B+1)/0.10),1))

intersection = rangea & rangeb

if len(intersection)==0:
  print(-1)
else:
  print(min(intersection))

Fixed submission:
A, B = map(int,input().split())

Amin = A/0.08
if Amin != int(Amin):
  Amin = int(Amin)+1
else:
  Amin = int(Amin)

Bmin = B/0.1
if Bmin != int(Bmin):
  Bmin = int(Bmin)+1
else:
  Bmin = int(Bmin)

rangea = set(range(Amin,int((A+1)/0.08),1))
rangeb = set(range(Bmin,int((B+1)/0.10),1))

intersection = rangea & rangeb

if len(intersection)==0:
  print(-1)
else:
  print(min(intersection))

Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())

Amin = A/0.08
if Amin != int(Amin):
  Amin = int(Amin)+1

Bmin = B/0.1
if Bmin != int(Bmin):
  Bmin = int(Bmin)+1

rangea = set(range(Amin,int((A+1)/0.08),1))
rangeb = set(range(Bmin,int((B+1)/0.10),1))

intersection = rangea & rangeb

if len(intersection)==0:
  print(-1)
else:
  print(min(intersection))

Fixed submission:
A, B = map(int,input().split())

Amin = A/0.08
if Amin != int(Amin):
  Amin = int(Amin)+1
else:
  Amin = int(Amin)

Bmin = B/0.1
if Bmin != int(Bmin):
  Bmin = int(Bmin)+1
else:
  Bmin = int(Bmin)

rangea = set(range(Amin,int((A+1)/0.08),1))
rangeb = set(range(Bmin,int((B+1)/0.10),1))

intersection = rangea & rangeb

if len(intersection)==0:
  print(-1)
else:
  print(min(intersection))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_num = list(map(int, input().split()))
nums = list(set(list_num))
count = 0

for i in range(len(nums)):
    a = list_num.count(nums[i])
    count += a * (a - 1) / 2

for i in range(len(list_num)):
    list_c = list_num.copy()
    c = list_c.pop(i)
    b = list_c.count(c)
    print(int(count - b))

Fixed submission:
import collections
n=int(input())
arr=list(map(int,input().split()))
cnt=collections.Counter(arr) #各数Akの個数を数える
total=0
for key in cnt.keys():
  total+=cnt[key]*(cnt[key]-1)//2 #各数Akについて、cnt[Ak]個から異なる2個のボールを取り出す場合の数を事前に計算する
for i in range(n): #各iについて上記の方法で答えを求める
  print(total-cnt[arr[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list_num = list(map(int, input().split()))

for i in range(n):
    k = list_num.copy()
    k.pop(i)
    x = []
    count = 0
    for j in range(len(k)):
        if not k[j] in x:
            num = k.count(k[j])
            count += num * (num-1) / 2
            x.append(k[j])
    
    print(int(count))


Fixed submission:
import collections
n=int(input())
arr=list(map(int,input().split()))
cnt=collections.Counter(arr) #各数Akの個数を数える
total=0
for key in cnt.keys():
  total+=cnt[key]*(cnt[key]-1)//2 #各数Akについて、cnt[Ak]個から異なる2個のボールを取り出す場合の数を事前に計算する
for i in range(n): #各iについて上記の方法で答えを求める
  print(total-cnt[arr[i]] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
count = int(input())
flg = False
for i in range(count):
    tfc = input().split()
    if tfc[0] == "1":
        flg = not flg
    elif tfc[0] == "2":
        if (not flg and tfc[1] == "1") or (flg and tfc[1] == "2"):
            s = tfc[2] + s
        elif (flg and tfc[1] == "1") or (not flg and tfc[1] == "2"):
            s = s + tfc[2]

if flg:
  s = s[::-1]
print(s)

Fixed submission:
s = input()
count = int(input())
flg = False
top = ""
for i in range(count):
    tfc = input().split()
    if tfc[0] == "1":
        flg = not flg
    elif tfc[0] == "2":
        if (not flg and tfc[1] == "1") or (flg and tfc[1] == "2"):
            top = top + tfc[2]
        elif (flg and tfc[1] == "1") or (not flg and tfc[1] == "2"):
            s = s + tfc[2]

if flg:
    s = s[::-1] + top
else:
    s = top[::-1] + s 
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
count = int(input())

for i in range(count):
    tfc = input().split()
    if tfc[0] == "1":
        s = s[::-1]
    elif tfc[0] == "2":
        if tfc[1] == "1":
            s = tfc[2] + s
        elif tfc[1] == "2":
            s = s + tfc[2]

print(s)

Fixed submission:
s = input()
count = int(input())
flg = False
top = ""
for i in range(count):
    tfc = input().split()
    if tfc[0] == "1":
        flg = not flg
    elif tfc[0] == "2":
        if (not flg and tfc[1] == "1") or (flg and tfc[1] == "2"):
            top = top + tfc[2]
        elif (flg and tfc[1] == "1") or (not flg and tfc[1] == "2"):
            s = s + tfc[2]

if flg:
    s = s[::-1] + top
else:
    s = top[::-1] + s 
print(s)
Buggy python submission (verdict: Runtime Error):
# A = [list(map(int, input().split())) for _ in range(3)]
# X = int(input())
# B = [int(input()) for _ in range(n)]
# A = list(map(int, input().split()))
k, n = map(int, input().split())
A = list(map(int, input().split()))
A.append(A[0]+k)
diff = 0
for i in range(n):
    diff = A[i+1]-A[i]
print(k-max(diff))


Fixed submission:
# A = [list(map(int, input().split())) for _ in range(3)]
# X = int(input())
# B = [int(input()) for _ in range(n)]
# A = list(map(int, input().split()))
k, n = map(int, input().split())
A = list(map(int, input().split()))
diff = []
for i in range(n-1):
    diff.append(A[i+1]-A[i])
diff.append((k-max(A))+min(A))
print(k-max(diff))
Buggy python submission (verdict: Runtime Error):
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, m = map(int, input().split())
S = []
C = []
for i in range(m):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
ans = [0, 0, 0]
for i in range(m):
    ans[S[i]-1] = C[i]
if n == 3 and ans[0] == 0:
    print(-1)
    exit()
if n == 2 and ans[1] == 0:
    print(-1)
    exit()
if n == 3:
    print("".join(map(str, ans[:n])))
elif n == 2:
    print("".join(map(str, ans[1:3])))
elif n == 1:
    print("".join(map(str, ans[2])))


Fixed submission:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, m = map(int, input().split())
S = []
C = []
for i in range(m):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
for i in range(1000):
    d = list(str(i))
    if len(d) != n:
        continue
    else:
        judge = True
        for i in range(m):
            if d[S[i]-1] != str(C[i]):
                judge = False
        if judge:
            print("".join(d))
            exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, m = map(int, input().split())
S = []
C = []
for i in range(m):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
ans = [0, 0, 0]
for i in range(m):
    ans[S[i]-1] = C[i]
if n == 2 and ans[1] == 0:
    print(-1)
    exit()
if n == 3:
    print("".join(map(str, ans[:n])))
elif n == 2:
    print("".join(map(str, ans[1:3])))
elif n == 1:
    print("".join(map(str, ans[2])))


Fixed submission:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, m = map(int, input().split())
S = []
C = []
for i in range(m):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
for i in range(1000):
    d = list(str(i))
    if len(d) != n:
        continue
    else:
        judge = True
        for i in range(m):
            if d[S[i]-1] != str(C[i]):
                judge = False
        if judge:
            print("".join(d))
            exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if n-k <= 0:
    print(0)
else:
    ans = sum(H[:n-k])
print(ans)


Fixed submission:
n, k = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if n-k <= 0:
    print(0)
    exit()
else:
    ans = sum(H[:n-k])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
#s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
p=list(input().split())
q=list(input().split())
p=[int(i) for i in p]
q=[int(i) for i in q]
import itertools
import math
fulllist=list(itertools.permutations([i for i in range(1,n+1)]))
for i in range(math.factorial(n)):
    if p==list(fulllist[i]):
        p_index=i+1
    elif q==list(fulllist[i]):
        q_index=i+1
print(abs(p_index-q_index))


Fixed submission:
n=int(input())
#s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
p=list(input().split())
q=list(input().split())
p=[int(i) for i in p]
q=[int(i) for i in q]
import itertools
import math
p_index,q_index=0,0
fulllist=list(itertools.permutations([i for i in range(1,n+1)]))
for i in range(math.factorial(n)):
    if p==list(fulllist[i]):
        p_index=i+1
    if q==list(fulllist[i]):
        q_index=i+1
print(abs(p_index-q_index))

Buggy python submission (verdict: Runtime Error):
n=int(input())
#s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
p=list(map(int,input()))
q=list(map(int,input()))
import itertools
import math
fulllist=list(itertools.permutations([i for i in range(1,n+1)]))
for i in range(math.factorial(n)):
    if p==fulllist[i]:
        p_index=i+1
    elif q==fulllist[i]:
        q_index=i+1
print(abs(p_index-q_index))

Fixed submission:
n=int(input())
#s=list(input().split())
#s,t=list(input().split())
#a=list(map(int,input().split()))
#k,x=map(int,input().split())
p=list(input().split())
q=list(input().split())
p=[int(i) for i in p]
q=[int(i) for i in q]
import itertools
import math
p_index,q_index=0,0
fulllist=list(itertools.permutations([i for i in range(1,n+1)]))
for i in range(math.factorial(n)):
    if p==list(fulllist[i]):
        p_index=i+1
    if q==list(fulllist[i]):
        q_index=i+1
print(abs(p_index-q_index))