Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
SC = [list(map(int,input().split())) for __ in range(m)]

flag = False
l = [0]*3
for i in range(m):
    l[SC[i][0]-1] = SC[i][1]
    if flag == True:
        break
    for j in range(1,m-i):
        if SC[i][0] == SC[j][0]:
            if l[SC[i][0]-1] != l[SC[j][0]-1]:
                print('-1')
                flag = True
                break
    
if flag == False    
    if (l[n-1] == 0):
        print('-1')
    else:
        l = l[:n]
        s = ''
        for i in l:
            s += str(i)
        print(int(s))

Fixed submission:
n,m = map(int, input().split())
 
sc = [tuple(map(int, input().split())) for _ in range(m)]
 
for i in range(1000):
    k = str(i)
    # all()：全ての要素がTrueであればTrueを返す
    # len(k)==nならば、左から一桁目が0である心配はない
    if len(k) == n and all([k[s-1]==str(c) for s,c in sc]):
        print(k)
        exit()
        
print('-1')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = [input() for __ in range(N)]

S = np.array(S)
keys = set(S)
ans = {}
cnt = 0
ls = []
for key in keys:
    ans[key] = len(np.where(S == key)[0])

max_v = max(ans.values())
keys = [k for k, v in ans.items() if v == max_v]
keys.sort()
for key in keys:
    print(key)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

print(*max_k_ls, sep="\n")

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
S = [input() for __ in range(N)]

S = np.array(S)
keys = set(S)
ans = {}
cnt = 0
ls = []
for key in keys:
    ans[key] = len(np.where(S == key)[0])

max_v = max(ans.values())
keys = [k for k, v in d.items() if v == max_v]
keys.sort()
for key in keys:
    print(key)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

print(*max_k_ls, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = [input() for __ in range(N)]

S = np.array(S)
keys = set(S)
ans = {}
for key in keys:
    ans[key] = len(np.where(S == key)[0])
v = np.array(sorted(ans.values(),reverse = True))
k = sorted(ans.items())

keys = []
for k, val in sorted(ans.items(), key=lambda x: -x[1]):
    keys.append(k)

count = len(np.where(v == v[0])[0])
keys = keys[:count]
keys.sort()
for key in keys:
  print(key)

Fixed submission:
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] = d[S] + 1
    else:
        d[S] = 1
max_val = max(d.values())
max_k_ls = [kv[0] for kv in d.items() if kv[1]==max_val]
max_k_ls = sorted(max_k_ls)

print(*max_k_ls, sep="\n")
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = list(map(int,input().split()))

ls = P[0:K]
summ = sum(ls)
ans = [0]*K

for i in range(N-K+1):
    if summ < sum(P[i:i+K]):
        ls = P[i:i+K]
        summ = sum(ls)
for j in range(K):
    ans[j]=(ls[j]+1)*ls[j]/(2*ls[j])
print(sum(ans))

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

if U == S:
    print(A-1,B)
else:
    print(A,B-1)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,K = map(int,input().split())
    P = list(map(int,input().split()))

    ans = []
    l = []
    for i in range(N-K+1):
        l.append(sum(P[i:i+K]))
    idx = l.index(max(l)) 
    ls = P[idx:K+idx]
    for j in range(K):
        ans.append((ls[j]+1)*ls[j]/(2*ls[j]))
    print(sum(ans))
main()

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

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K):
    summ = summ - P[i] + P[K+i]
    if summ > maxi:
        maxi = summ
        idx = i+1
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))

ans = []
l = []
for i in range(N-K+1):
    l.append(sum(P[i:i+K]))
idx = l.index(max(l)) 
ls = P[idx:K+idx]
for j in range(K):
    ans.append((ls[j]+1)*ls[j]/(2*ls[j]))
print(sum(ans))

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

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K):
    summ = summ - P[i] + P[K+i]
    if summ > maxi:
        maxi = summ
        idx = i+1
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))

ls = P[0:K]
summ = sum(ls)
ans = [0]*K

for i in range(N-K+1):
    if summ < sum(P[i:i+K]):
        ls = P[i:i+K]
        summ = sum(ls)
for j in range(K):
    ans[j]=(ls[j]+1)*ls[j]/(2*ls[j])
print(sum(ans))

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

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K):
    summ = summ - P[i] + P[K+i]
    if summ > maxi:
        maxi = summ
        idx = i+1
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
LR = [list(map(int,input().split())) for i in range(M)]

maxi = 0
mini = 10**6
for lr in LR:
    maxi = max(lr[0],maxi)
    mini = min(lr[1],mini)

if mini-maxi+1 >= n:
    print(n)
else:
    print(mini-maxi+1)

Fixed submission:
N,M = map(int,input().split())
LR = [list(map(int,input().split())) for i in range(M)]

maxi = 10**6
mini = 0
for lr in LR:
    mini = max(lr[0],mini)
    maxi = min(lr[1],maxi)
if maxi-mini < 0:
    print(0)
else:
    print(maxi-mini+1)
Buggy python submission (verdict: Runtime Error):
# Half and Half
a,b,c,x,y = map(int,input().split())

ans = []
for i in range(max(x,y)):
    ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(ans)

print(min(ans))

Fixed submission:
# Half and Half
a,b,c,x,y = map(int,input().split())

ans = []
for i in range(max(x,y)+1):
    ans.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))

print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))

counter = 0
AN = set(A)
A = np.array(A)

for i in AN:
    if len(A[A==i]) < i:
        counter += len(A[A == i])
    else:
        counter += (len(A[A == i]) - i)

print(counter)

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

NA = set(A)
d = {x:0 for x in NA}

for i in range(N):
    d[A[i]] += 1

counter = 0
for p in d:
    if p > d[p]:
        counter += d[p]
    else:
        counter += d[p]-p

print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

flag = True
count = 0
while(flag):
  for i in range(N):
    if A[i]%2:
      flag = False
      break
    else:
      count += 1
print(count)
  

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
 
flag = True
count = 0
while(flag):
  for i in range(N):
    if A[i]%2:
      flag = False
      break
    else:
      A[i] /= 2
  if flag:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = input()

s_odd = [s[i] for i in range(len(s)) if i%2 == 0]
print("".join(s_odd)

Fixed submission:
s = input()

print(s[0:len(s):2])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

max_n = max(max(A),1)
cnt = [0]*max_n
for i in range(max_n):
    for a in A:
        if abs(a-i)<=1:
            cnt[i] += 1
print(max(cnt))

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

cnt = [0]*(10**5+2)
for a in A:
    cnt[a] += 1
ans = []
for a in A:
    if a == 0:
        ans.append(cnt[a] +cnt[a+1])
    else:
        ans.append(cnt[a-1] + cnt[a] +cnt[a+1])
print(max(ans))

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

max_n = max(A,1)
cnt = [0]*max_n
for i in range(max_A):
    for a in A:
        if abs(ai-i)<=1:
            cnt[i] += 1
print(max(cnt))

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

cnt = [0]*(10**5+2)
for a in A:
    cnt[a] += 1
ans = []
for a in A:
    if a == 0:
        ans.append(cnt[a] +cnt[a+1])
    else:
        ans.append(cnt[a-1] + cnt[a] +cnt[a+1])
print(max(ans))

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

max_n = max(A)
cnt = [0]*max_n
for i in range(1,max_n):
    for a in A:
        if abs(a-i)<=1:
            cnt[i] += 1
print(max(cnt))

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

cnt = [0]*(10**5+2)
for a in A:
    cnt[a] += 1
ans = []
for a in A:
    if a == 0:
        ans.append(cnt[a] +cnt[a+1])
    else:
        ans.append(cnt[a-1] + cnt[a] +cnt[a+1])
print(max(ans))
Buggy python submission (verdict: Runtime Error):
r,g,b = map(int,input()split())

if (100*r + 10*g + b)%4 == 0:
    print("YES")
else:
    print("NO")

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

if (100*r + 10*g + b)%4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
#AGC 013 A - Sorted Arrays
#増加⇔減少に転じる際、Ai+1 - Aiは必ず符号反転することを利用
N = int(input())
A = list(map(int,input().split()))

count = 0
sign = 0
for i in range(N):
    if sign == 0:
        sign = A[i+1]-A[i]
    elif sign*(A[i+1]-A[i]) < 0:
        count += 1
        sign = 0
print(count)

Fixed submission:
#AGC 013 A - Sorted Arrays
#増加⇔減少に転じる際、Ai+1 - Aiは必ず符号反転することを利用
N = int(input())
A = list(map(int,input().split()))

count = 1
sign = 0
for i in range(N-1):
    if sign == 0:
        sign = A[i+1]-A[i]
    elif sign*(A[i+1]-A[i]) < 0:
        count += 1
        sign = 0
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.sort(reverse = True)
ans = []
while(len(A)>0):
    ans.append(A[1])
    A = A[2:len(A)-1]
print(sum(ans))

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

A.sort(reverse = True)
ans = []
for i in range(int(len(A)/3)): # whileは遅い
    ans.append(A[1+2*i])
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
# C - Digits in Multiplication
n = int(input())
import math
ans = []
for i in range(1,int(math.sqrt(n))):
    if n%i == 0:
        ans.append(max(len(str(i)),len(str(int(n//i)))))
print(min(ans))

Fixed submission:
n = int(input())
import math
ans = []
for i in range(1,int(math.sqrt(n)+1)):
    if n%i == 0:
        ans.append(max(len(str(i)),len(str(int(n//i)))))
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)

Fixed submission:
K,S = map(int,input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <=K:
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                count += 1
print(count)

Fixed submission:
K,S = map(int,input().split())

count = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <=K:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

answer = 0
for i in range(len(A)-1):
  for j in range(len(A)-i-1):
    answer += A[i] * A[j+ i + 1]
mod_answer = answer % (10**9 + 7)


print(mod_answer)

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

answer = 0
x = 0
for i in range(len(A) - 1):
  x += A[i]
  answer +=  (x * A[i + 1])

print(answer% (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
from itertools import product
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat=H):
    for col_bit in product(range(2), repeat=H):
        count = 0
        for h in range(H):
            for w in range(W):
                if c[h][w] == "#" and (row_bit[h] == 0 and col_bit[w] == 0):
                    count += 1
        if count == K:
            ans += 1


print(ans)

Fixed submission:
from itertools import product
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat=H):
    for col_bit in product(range(2), repeat=W):
        count = 0
        for h in range(H):
            for w in range(W):
                if c[h][w] == "#" and (row_bit[h] == 0 and col_bit[w] == 0):
                    count += 1
        if count == K:
            ans += 1


print(ans)
Buggy python submission (verdict: Runtime Error):
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]:
        print('-1')
        sys.exit()
    elif x[0] == '1' and x[1] == '0':
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if b[0] == '0' and b[1] != '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)


Fixed submission:
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #既に与えられたところに違う値
        print('-1')
        sys.exit()
    elif N >= 2 and x[0] == '1' and x[1] == '0': #the first digit is  "0"
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if N != 1 and b[0] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]:
        print('-1')
        sys.exit()
    elif x[0] == '1' and x[1] == '0':
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if b[0] == '0' and not b[1] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)


Fixed submission:
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #既に与えられたところに違う値
        print('-1')
        sys.exit()
    elif N >= 2 and x[0] == '1' and x[1] == '0': #the first digit is  "0"
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if N != 1 and b[0] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #when the space which is tried to enter the number has a different value
        print('-1')
        sys.exit()
    elif x[0] == '1' and x[1] == '0':
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if b[0] == '0' and (int(b[1]) != 0 or int(b[2] != 0) ):
    b[0] = '1'

ans = ''.join(b)
print(ans)




Fixed submission:
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #既に与えられたところに違う値
        print('-1')
        sys.exit()
    elif N >= 2 and x[0] == '1' and x[1] == '0': #the first digit is  "0"
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if N != 1 and b[0] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())

a = list(map(int,input().split()))

numbers = []
for i in range(N):
    if a[i] not in numbers:
        numbers.append(a[i])
    elif a[i] in numbers:
        print('NO')
        sys.exit()
print('YES')

Fixed submission:
import sys
N = int(input())

a = list(map(int,input().split()))

a.sort()

numbers = []
for i in range(N-1):
    if a[i] == a[i+1]:
        print('NO')
        sys.exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
b = list(map(int,input().split()))

N = b[0]
K = b[1]

if N < K:
    print(0)
    sys.exit()

H = list(map(int,input().split()))

H.sort(reverse = True)

for i in range(K):
    H.pop(0)

sum_attack = sum(H)
print(sum_attack)

Fixed submission:
import sys
b = list(map(int,input().split()))

N = b[0]
K = b[1]

if N < K:
    print(0)
    sys.exit()

H = list(map(int,input().split()))

H.sort(reverse = True)

H = [H[i] for i in range(K,N)]

sum_attack = sum(H)
print(sum_attack)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
 
if a[0]>=10 or a[1]>=10:
  return -1
else:
  return a[0]*a[1]

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

if a[0]>=10 or a[1]>=10:
    print(-1)
else:
    print(a[0]*a[1])

Buggy python submission (verdict: Runtime Error):
a = input().split()
 
if a[0]>=10 or a[1]>=10:
  return -1
else:
  return a[0]*a[1]

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

if a[0]>=10 or a[1]>=10:
    print(-1)
else:
    print(a[0]*a[1])

Buggy python submission (verdict: Runtime Error):
a = input().split()

if a[0]>=10 or a[1]>=10:
  return -1
elif:
  return a[0]*a[1]

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

if a[0]>=10 or a[1]>=10:
    print(-1)
else:
    print(a[0]*a[1])
Buggy python submission (verdict: Runtime Error):
A = input()
N = int(A)


if N ==1:
    a = 1
elif 1<=N and N<=100 and N%2 == 0:
    a = 0.5
    a = float(a)
elif 1<=N and N<=100 andN % 2 == 1:
    a = (N/2 + 1)/N

print(a)

Fixed submission:
A = input()
N = int(A)


if N ==1:
    a = 1
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N%2 == 1:
    a = (N//2 + 1)/N

print(a)

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


if N ==1:
    print(N) 
elif 1<=N and N<=100 and N%2 == 0:
    a = 0.5
    a = float(a)
elif 1<=N and N<=100 andN % 2 == 1:
    a = (N/2 + 1)/N

print(a)
    

Fixed submission:
A = input()
N = int(A)


if N ==1:
    a = 1
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N%2 == 1:
    a = (N//2 + 1)/N

print(a)

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


if N ==1:
    print(N) 
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N % 2 == 1:
    a = (N/2 + 1)/N

print(a)

Fixed submission:
A = input()
N = int(A)


if N ==1:
    a = 1
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N%2 == 1:
    a = (N//2 + 1)/N

print(a)

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

if N ==1:
    print(N) 
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N % 2 == 1:
    a = (N/2 + 1)/N

print(a)
    

Fixed submission:
A = input()
N = int(A)


if N ==1:
    a = 1
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N%2 == 1:
    a = (N//2 + 1)/N

print(a)

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

if N ==1:
print N:
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N % 2 == 1:
    a = (N/2 + 1)/N

print a
    

Fixed submission:
A = input()
N = int(A)


if N ==1:
    a = 1
elif N%2 == 0:
    a = 0.5
    a = float(a)
elif N%2 == 1:
    a = (N//2 + 1)/N

print(a)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
K = a[1]

b = list(map(int,input().split()))

for i in range(len(b)):
    for j in range(len(b)):
        if b[i]<b[j]:
            x = b[i]
            b[i] = b[j]
            b[j] = x
c = 0
for k in b:
    if k < K:
        break
    c += 1

print c

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
K = a[1]

b = list(map(int,input().split()))
c = 0
for i in b:
    if i >= K:
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
from tqdm import tqdm
N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

Fixed submission:

N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

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

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

Fixed submission:

N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

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

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in tqdm(range(N)):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

Fixed submission:

N = int(input())

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)
Buggy python submission (verdict: Runtime Error):
S = input()
c = 0
m = 0
if s in S:
  if s == "R":
    c+=1
    m = max(c, m)
  else:
    m = max(c, m)
    c = 0
print(m)
    
    

Fixed submission:
S = input()
c = 0
m = 0
for s in S:
    m = max(c, m)
    if s == "R":
        c += 1
        m = max(c, m)
    else:
        c = 0
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = input()

if "R" not in C:
    print(0)
    exit()
count = 0

for i in range(N):
    if C[i] == 'W':

        index = C.rfind('R', i)
        if index >= 0:
            count += 1
        c = list(C)
        c[i] = 'R'
        c[index] = 'W'
        C = "".join(c)
    if 'R' not in C[i+1:]:
        break

print(count)



Fixed submission:
N = int(input())
C = input()

from collections import Counter

if "R" not in C:
    print(0)
    exit()
count = 0

c = Counter(C)
k = c["R"]
D = C[:k]
d = Counter(D)
print(d["W"])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = input()

if "R" not in C:
    print(0)
    exit()
count = 0
for i in range(N):
    if C[i] == 'W':

        index = C.rfind('R', i)
        if index >= 0:
            count += 1
        c = list(C)
        c[i] = 'R'
        c[index] = 'W'
        C = "".join(c)

print(count)



Fixed submission:
N = int(input())
C = input()

from collections import Counter

if "R" not in C:
    print(0)
    exit()
count = 0

c = Counter(C)
k = c["R"]
D = C[:k]
d = Counter(D)
print(d["W"])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())

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

Q = int(input())

BC = []
for _ in range(Q):
    b, c = map(int, input().split())
    BC.append([b, c])

C = Counter(A)
for bc in BC:
    b = bc[0]
    c = bc[1]
    if b in C:
        if c in C:
            C[c] += C[b]
            C[b] = 0
        else:
            C[c] = C[b]
            C[b] = 0
    print(sum([k*v for k, v in C.items()]))


Fixed submission:
from collections import Counter

N = int(input())

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

Q = int(input())

BC = []
for _ in range(Q):
    b, c = map(int, input().split())
    BC.append([b, c])

C = Counter(A)
S = sum([k*v for k, v in C.items()])
for bc in BC:
    b = bc[0]
    c = bc[1]
    if b in C:
        bf = C[b]
        S += (c-b) * bf
        if c in C:
            C[c] += C[b]
            C[b] = 0
        else:
            C[c] = C[b]
            C[b] = 0
    print(S)