Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
INF = 1001001001
N = int(input())
D = list(map(int, input().split())) + [0]

ans = 0
for i in range(1<<(N-1)):
    tmp = INF
    for j in range(N-1):
        if i>>j & 1:
            d1 = D[j]
        else:
            d1 = 24 - D[j]
        for k in range(j+1, N-1):
            if i>>k & 1:
                d2 = D[k]
            else:
                d2 = 24 - D[k]
            tmp = min(tmp, min(abs(d1-d2), 24-abs(d1-d2)))
        tmp = min(tmp, min(abs(d1-D[N-1]), 24-abs(d1-D[N-1])))
        tmp = min(tmp, min(d1, 24-d1))
    tmp = min(tmp, min(D[N-1], 24-D[N-1]))
    ans = max(ans, tmp)

print(ans)


Fixed submission:
def f(a, b):
    d = abs(a-b)
    return min(d, 24-d)

N = int(input())
D = list(map(int, input().split())) + [0]
D.sort()
for i in range(N+1):
    if i%2:
        D[i] = 24 - D[i]
D.sort()
ans = f(D[0], D[-1])
for i in range(N):
    ans = min(ans, f(D[i], D[i+1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
INF = 1001001001
N = int(input())
D = list(map(int, input().split())) + [0]

ans = 0
for i in range(1<<(N-1)):
    tmp = INF
    for j in range(N-1):
        if i>>j & 1:
            d1 = D[j]
        else:
            d1 = 24 - D[j]
        for k in range(j+1, N-1):
            if i>>k & 1:
                d2 = D[k]
            else:
                d2 = 24 - D[k]
            tmp = min(tmp, min(abs(d1-d2), 24-abs(d1-d2)))
        tmp = min(tmp, min(abs(d1-D[N-1]), 24-abs(d1-D[N-1])))
        tmp = min(tmp, min(d1, 24-d1))
    tmp = min(tmp, min(D[N-1], 24-D[N-1]))
    ans = max(ans, tmp)

print(ans)


Fixed submission:
def f(a, b):
    d = abs(a-b)
    return min(d, 24-d)

N = int(input())
D = list(map(int, input().split())) + [0]
D.sort()
for i in range(N+1):
    if i%2:
        D[i] = 24 - D[i]
D.sort()
ans = f(D[0], D[-1])
for i in range(N):
    ans = min(ans, f(D[i], D[i+1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)

Bn = [0] * N
prea = 0
for b in range(N):
    for a in range(prea, N):
        if A[a] < B[b]:
            prea = a
            break
    else:
        break
    Bn[b] = N-a

ans = 0
preb = 0
for c in range(N):
    for b in range(preb, N):
        if B[b] < C[c]:
            preb = b
            break
    else:
        break
    ans += sum(Bn[b:])

print(ans)


Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    cnta = bisect.bisect_left(A, B[i])
    cntc = bisect.bisect_right(C, B[i])
    ans += cnta * (N - cntc)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)

Bn = [0] * N
prea = 0
for b in range(N):
    for a in range(prea, N):
        if A[a] < B[b]:
            prea = a
            break
    else:
        a = N
    Bn[b] = N-a

ans = 0
preb = 0
for c in range(N):
    for b in range(preb, N):
        if B[b] < C[c]:
            preb = b
            break
    else:
        b = N
    ans += sum(Bn[b:])

print(ans)


Fixed submission:
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.sort()

ans = 0
for i in range(N):
    cnta = bisect.bisect_left(A, B[i])
    cntc = bisect.bisect_right(C, B[i])
    ans += cnta * (N - cntc)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            if (4*h*n-N*h-N*n) == 0: continue
            if (N*h*n)%(4*h*n-N*h-N*n) == 0:
                w = (N*h*n)//(4*h*n-N*h-N*n)
                if w > 0:
                    print(h,n,w)
                    return

main()


Fixed submission:
def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            if (4*h*n-N*h-N*n) > 0:
                if (N*h*n)%(4*h*n-N*h-N*n) == 0:
                    w = (N*h*n)//(4*h*n-N*h-N*n)
                    print(h,n,w)
                    return

main()
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
dp = set([0])

ans = 0
while X not in dp:
    ans += 1
    for i in list(dp):
        if i + ans not in dp:
            dp.add(i + ans)
        if i - ans not in dp:
            dp.add(i - ans)
print(ans)


Fixed submission:
X = int(input())

ans = 0
sums = 0
while sums < X:
    ans += 1
    sums += ans
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Fixed submission:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
S = input()
 
keyence = "keyence"
 
isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
if isKey:
  pirnt('YES')
else:
  print('NO')

Fixed submission:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
k = input()
n = 'keyence'
for i in range(len(k)):
    if k[i] == 'k':
        z = 0
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z = 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        print('YES')
                        break
                    else:
                        z = 2
                        break
                
            break
            
    if i == len(k):
        z = 2
    

if z == 0:
    print('YES')
elif z == 2:
    print('NO')

Fixed submission:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
k = input()
n = 'keyence'
for i in range(len(k)):
    if k[i] == 'k':
        z = 0
        for j in range(len(n)):
            if k[i+j] != n[j]:
                z = 1
                for p in range(i+j, len(k)):
                    
                    if n[j:] in k[p:]:
                        break
                        break
                    else:
                        z = 2
                        break
            break
            
    if i == len(k):
        z = 2
    

if z == 0 or z == 1:
    print('YES')
else:
    print('NO')

Fixed submission:
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num-1]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if a[num] in a[:num]:
    print('No')
    break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

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

if (A * B) % 2 == 0:
    print('No')
else:
    print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')

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

if (A * B) % 2 == 0:
    print('No')
else:
    print('Yes')

Fixed submission:
A, B = map(int, input().split())
x = A * B
if x % 2 == 0:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

for num in range(1, N+1):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')

Fixed submission:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

for num in range(1, N):
  if a[num][-1] != a[num+1][0]:
    print('No')
    break
  if a[num] in a:
    print('No')
    break
  print('Yes')

Fixed submission:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
k=input()
x=k//2
if k%2==0:
  print(2*x*x)
else:
  print((2*x+1)*x)

Fixed submission:
x = int(input())
y = x // 2
print(y*(x-y))
Buggy python submission (verdict: Runtime Error):
if S[-1] == "s":
  print(S + "es")
else:
  print(S + "s")

Fixed submission:
S = input()
if S[-1] == "s":
  print(S + "es")
else:
  print(S + "s")

Buggy python submission (verdict: Runtime Error):
if S[-1] == s:
  print(S + "es")
else:
  print(S + "s")
  

Fixed submission:
S = input()
if S[-1] == "s":
  print(S + "es")
else:
  print(S + "s")
Buggy python submission (verdict: Runtime Error):
cnt = 0
zorome = 0
num = input()

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  else:
    zorome = 0
  
  cnt += 1

print("Yes" if zorome >= 3 else "No")


Fixed submission:
cnt = 0
zorome = 0
num = int(input())

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  else:
    zorome = 0
  
  cnt += 1

print("Yes" if zorome >= 3 else "No")

Buggy python submission (verdict: Runtime Error):
cnt = 0
zorome = 0
num = input()

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  
  cnt += 1

print("Yes" if zorome >= 3 else "No")

Fixed submission:
cnt = 0
zorome = 0
num = int(input())

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  else:
    zorome = 0
  
  cnt += 1

print("Yes" if zorome >= 3 else "No")
Buggy python submission (verdict: Runtime Error):
case_num = 0

N = int(input())

for num in range(N - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)


Fixed submission:
import math

case_num = 0

N = int(input())

for num in range(N - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)

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

case_num += N / 2
half_num = case_num

for num in range(half_num - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)

Fixed submission:
import math

case_num = 0

N = int(input())

for num in range(N - 1):
  num += 1
  
  case_num += ( math.ceil(N / num) - 1 )


print(case_num)
Buggy python submission (verdict: Runtime Error):
n = input()

n_list = list(n)
ans = sum(n_list)

print("Yes" if (ans % 9) == 0 else "No")

Fixed submission:
import math

n = input()

n_list = map(int, list(n))
ans = sum(n_list)

print("Yes" if (ans % 9) == 0 else "No")
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

def lcm(x, y):
  return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int,input().split()))
g = a[0]
for i in range(n):
  g = lcm(g,a[i])
ans = 0
for i in range(n):
  ans += g/a[i]
print(int(ans%1000000007))


Fixed submission:
from fractions import gcd

def lcm(x, y):
  return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int,input().split()))
g = a[0]
for i in range(n):
  g = lcm(g,a[i])
ans = 0
for i in range(n):
  ans += g // a[i]
print(ans%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
x = 0
for i in range(N):
  x += (A[i] * (S - sum(A[:i+1]))) % 1000000007
x = x % 1000000007
print(x)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = [A[0]]
for i in range(1, N):
  S.append(S[i-1] + A[i])
x = 0
for i in range(N):
  x += (A[i] * (S[-1] - S[i])) % 1000000007
x = x % 1000000007
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
n = 1
list = []
r = 7
while True:
    r = r % k
    if r == 0:
        print(n)
        break
    elif r in list:
        print(-1)
        break
    else:
        list.append(r)
        r = r * 10 + 7
        n += 1


Fixed submission:
K = int(input())
a = 7
for i in range(K):
  if a % K == 0:
    print(i+1)
    break
  else:
    a = 10*(a%K) + 7
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
price = [int(input()) for _ in range(N)]
price.sort()
print(sum(price[:3]))

Fixed submission:
N, K = map(int, input().split())
price = list(map(int, input().split()))
price.sort()
print(sum(price[:K]))

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
price = [input() for _ in range(N)]
price.sort()
print(sum(price[:3]))

Fixed submission:
N, K = map(int, input().split())
price = list(map(int, input().split()))
price.sort()
print(sum(price[:K]))
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)

Fixed submission:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(N):
  ans *= a[i]
  if ans > 10 ** 18 and 0 not in a:
    print(-1)
    break
else:
  print(ans)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(N):
    ans *= a[i]
    if ans > 10 ** 18:
      print(-1)
      break
  else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
K, S = int(input()), input()
if len(S) <= K:
  print(S)
else:
  print(S[:K] + ...)

Fixed submission:
K, S = int(input()), input()
if len(S) <= K:
  print(S)
else:
  print(S[:K] + "...")
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
lst = [1] * A + [0] * B + [-1] * C
print(sum(sorted(lst)[-K:]))

Fixed submission:
A, B, C, K = map(int, input().split())
ans = min(A, K) - max(0, K - A - B)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
gacha = set()
for _ in range(N):
  gacha.append(input())
print(len(gacha))

Fixed submission:
N = int(input())
gacha = set()
for _ in range(N):
  gacha.add(input())
print(len(gacha))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B) + sum(C) - C[A[N-1] - 1]
print(ans)

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

ans = sum(B)
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  ans += B[A[i]-1] + C[A[i]-1]
ans += B[A[i]-1]
print(ans)

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

ans = sum(B)
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    ans += C[A[i]-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
-1000000000 0 -1000000000 0

Fixed submission:
a, b, c, d = map(int, input().split())
print(max(a*c, a*d, b*c, b*d))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = int(n**0.5+1)
for i in range(1, n+1):
    ans = 0
    for x in range(1, a):
        for y in range(x, a):
            for z in range(y, a):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i and x == y == z:
                    ans += 1
                elif x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    ans += 3
    print(ans)

Fixed submission:
n = int(input())
a = int(n**0.5+1)
ans = [0]*n
for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
                ans[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1
[print(i) for i in ans]
Buggy python submission (verdict: Runtime Error):
print(int(input()[1:]))

Fixed submission:
n = int(input())%1000
if n:
    print(1000-n)
else:
    print(n)
Buggy python submission (verdict: Time Limit Exceeded):
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = gcd(x, a[i])
    return x

n = int(input())
ans = 0
for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            ans += lcm([a, b, c])
print(ans)

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
ans = 0
for a in range(1, n+1):
    for b in range(1, n+1):
        for c in range(1, n+1):
            ans += gcd_list([a, b, c])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
Q = int(input())
count = 0
right = []
left = []
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
    else:
        if (count%2 == 0 and int(q[1]) == 1) or (count%2 == 1 and int(q[1]) == 2):
            left.insert(0, q[2])
        else:
            right.append(q[2])

left = "".join(left)
right = "".join(right)
if count%2 == 1:
    left = left[::-1]
    s = s[::-1]
    right = right[::-1]
    print(right+s+left)
else:
    print(left+s+right)

Fixed submission:
s = input()
Q = int(input())
count = 0
right = []
left = []
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
    else:
        if count%2 == 0:
            if int(q[1]) == 1:
                left.append(q[2])
            else:
                right.append(q[2])
        else:
            if int(q[1]) == 1:
                right.append(q[2])
            else:
                left.append(q[2])

left = "".join(left)
right = "".join(right)
if count%2 == 0:
    left = left[::-1]
    print(left+s+right)
else:
    s = s[::-1]
    right = right[::-1]
    print(right+s+left)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
Q = int(input())
S = list("S")
count = 0
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
        S = S[::-1]
    else:
        if int(q[1]) == 1:
            S = list(q[2]) + S
        else:
            S = S + list(q[2])

S = "".join(S)
if count%2 == 0:
    print(S.replace("S", s))
else:
    s = s[::-1]
    print(S.replace("S", s))


Fixed submission:
s = input()
Q = int(input())
count = 0
right = []
left = []
for i in range(Q):
    q = input().split()
    if int(q[0]) == 1:
        count += 1
    else:
        if count%2 == 0:
            if int(q[1]) == 1:
                left.append(q[2])
            else:
                right.append(q[2])
        else:
            if int(q[1]) == 1:
                right.append(q[2])
            else:
                left.append(q[2])

left = "".join(left)
right = "".join(right)
if count%2 == 0:
    left = left[::-1]
    print(left+s+right)
else:
    s = s[::-1]
    right = right[::-1]
    print(right+s+left)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans = list("000")
x = [list(map(int, input().split())) for i in range(m)]
x = list(map(list, set(map(tuple, x))))
for s, c in x:
    if ans[s-1] == "0":
        ans[s-1] = str(c)
    else:
        print("-1")
        exit()

if n == 1:
    ans = int(ans[2:])
    for i in range(10):
        if i == ans:
            print(i)
            exit() 

if n == 2:
    ans = int(ans[1:])
    for i in range(10, 100):
        if i == ans:
            print(i)
            exit() 

if n == 3:
    ans = int(ans[0:])
    for i in range(100, 1000):
        if i == ans:
            print(i)
            exit() 

Fixed submission:
n, m = map(int, input().split())
x = [list(map(int, input().split())) for i in range(m)]
count = 0
for i in range(1000):
    count = 0
    i = str(i)
    if len(i) == n:
        for s, c in x:
            if i[s-1] == str(c):
                count += 1
            else:
                break
        if count == m:
            print(i)
            exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
d ={}
for key in s:
    if key in d:
        d[key] += 1
    else:
        d[key] = 1

Max = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
for i in max_k_list:
    print(i)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]
d ={}
for key in s:
    if key in d:
        d[key] += 1
    else:
        d[key] = 1
Max = max(d.values())
max_k_list = [kv[0] for kv in d.items() if kv[1] == Max]
max_k_list.sort()
for i in max_k_list:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
    if p[i]<=min(p[:i+1]):
        count += 1
print(count)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
count = 0
Min = p[0]
for i in range(n):
    if Min >= p[i]:
        Min = p[i]
        count += 1

print(count)