Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# DP解

x = int(input())
dp = [False for _ in range(x+1)]
dp[0] = True
for i in range(1, 100):
    dp[i] = False
for i in range(100, x+1):
    tmp = False
    for j in range(6):
        if i-(100+j) >= 0:
            tmp = (tmp or dp[i-(100+j)])
    if tmp:
        dp[i] = True
    else:
        dp[i] = False

if dp[x]:
    print(1)
else:
    print(0)


Fixed submission:
#!/usr/bin/env python

x = int(input())

n = x//100

for i in range(n+1):
    tmp = x 
    tmp -= i*100
    if 5*i >= tmp:
        print(1)
        exit()
print(0)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# DP解

x = int(input())
dp = [False for _ in range(x+1)]
dp[0] = True
for i in range(1, 100):
    dp[i] = False
for i in range(100, x+1):
    if dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]:
        dp[i] = True
    else:
        dp[i] = False

if dp[x]:
    print(1)
else:
    print(0)


Fixed submission:
#!/usr/bin/env python

x = int(input())

n = x//100

for i in range(n+1):
    tmp = x 
    tmp -= i*100
    if 5*i >= tmp:
        print(1)
        exit()
print(0)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

x = int(input())

ok = False

def dfs(n, flg):
    global ok
    if flg:
        return 
    if n == x:
        ok = True
        return
    if n > x:
        ok = False
        return
    dfs(n+100, ok) 
    dfs(n+101, ok) 
    dfs(n+102, ok) 
    dfs(n+103, ok) 
    dfs(n+104, ok) 
    dfs(n+105, ok) 

dfs(0, False)
if ok: print(1)
else: print(0)


Fixed submission:
#!/usr/bin/env python

x = int(input())

n = x//100

for i in range(n+1):
    tmp = x 
    tmp -= i*100
    if 5*i >= tmp:
        print(1)
        exit()
print(0)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

x = int(input())

ok = False

def dfs(n, flg):
    global ok
    if flg:
        return 
    if n == x:
        ok = True
        return
    if n > x:
        ok = False
        return
    dfs(n+100, ok) 
    dfs(n+101, ok) 
    dfs(n+102, ok) 
    dfs(n+103, ok) 
    dfs(n+104, ok) 
    dfs(n+105, ok) 

dfs(0, False)
if ok: print(1)
else: print(0)


Fixed submission:
#!/usr/bin/env python

x = int(input())

n = x//100

for i in range(n+1):
    tmp = x 
    tmp -= i*100
    if 5*i >= tmp:
        print(1)
        exit()
print(0)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

x = int(input())

ok = False

def dfs(n, flg):
    global ok
    if ok: 
        return 
    if n == x:
        ok = True
        return
    if n > x:
        ok = False
        return
    dfs(n+100, ok) 
    dfs(n+101, ok) 
    dfs(n+102, ok) 
    dfs(n+103, ok) 
    dfs(n+104, ok) 
    dfs(n+105, ok) 

dfs(0, False)
if ok: print(1)
else: print(0)


Fixed submission:
#!/usr/bin/env python

x = int(input())

n = x//100

for i in range(n+1):
    tmp = x 
    tmp -= i*100
    if 5*i >= tmp:
        print(1)
        exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

s = input()
n = len(s)
ans = 0 
arr = []

# calc
for i in range(n+1):
    # right direction
    rcnt = 0 
    for j in range(i, n): 
        if s[j] == '>':
            rcnt += 1
        else:
            break
    # left direction
    lcnt = 0 
    for j in reversed(range(i)):
        if s[j] == '<':
            lcnt += 1
        else:
            break
    arr.append(max(rcnt, lcnt))
    ans += max(rcnt, lcnt)
#print(arr)
print(ans)


Fixed submission:
#!/usr/bin/env python3

s = input()
n = len(s)+1
a = [0 for _  in range(n)]

for i in range(n-1):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in reversed(range(1, n)):
    if s[i-1] == '>':
        a[i-1] = max(a[i-1], a[i]+1)

ans = sum(a)

#print('a = ', a)
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
import numpy as np

n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))):
    if n%i==0:
        q = n/i 
        tmp = i+q 
        if tmp <= ans:
            ans = tmp 
print(int(ans-2))


Fixed submission:
#!/usr/bin/env python3
import math
import numpy as np

n = int(input())
ans = np.inf
for i in range(1, int(math.sqrt(n))+1):
    if n%i==0:
        q = n//i
        tmp = i+q 
        if tmp <= ans:
            ans = tmp 
            i_ = i 
            q_ = q 

print(ans-2)
Buggy python submission (verdict: Time Limit Exceeded):
#/usr/bin/env python
from functools import *
from math import *

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

gcds = []
for i in range(n):
    l = a[:i] 
    r = a[i+1:]
    if len(l) == 0:
        gl = 0 
    else:
        gl = reduce(gcd, l)

    if len(r) == 0:
        gr = 0 
    else:
        gr = reduce(gcd, r)

    g = gcd(gl, gr) 
    gcds.append(g)

print(max(gcds))


Fixed submission:
#/usr/bin/env python
from functools import *
from math import *

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

gcds = []
lgcd = []
rgcd = [0 for _ in range(n)]
l = r = 0 
for i in range(n):
    if i == 0:
        l = 0 
    else:
        l = gcd(l, a[i-1])
    lgcd.append(l)

for i in range(n):
    if i == 0:
        r = 0 
        rgcd[n-1] = r 
    else:
        r = gcd(r, a[n-i])
        rgcd[n-i-1] = r 

for i in range(n):
    g = gcd(lgcd[i], rgcd[i])
    gcds.append(g)

print(max(gcds))

Buggy python submission (verdict: Time Limit Exceeded):
#/usr/bin/env python
from functools import *
from math import *

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

gcds = []
for i in range(n):
    tmp = a[:i] + a[i+1:]
    g = reduce(gcd, tmp)
    gcds.append(g)

print(max(gcds))


Fixed submission:
#/usr/bin/env python
from functools import *
from math import *

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

gcds = []
lgcd = []
rgcd = [0 for _ in range(n)]
l = r = 0 
for i in range(n):
    if i == 0:
        l = 0 
    else:
        l = gcd(l, a[i-1])
    lgcd.append(l)

for i in range(n):
    if i == 0:
        r = 0 
        rgcd[n-1] = r 
    else:
        r = gcd(r, a[n-i])
        rgcd[n-i-1] = r 

for i in range(n):
    g = gcd(lgcd[i], rgcd[i])
    gcds.append(g)

print(max(gcds))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import sys 
input = sys.stdin.readline

n = int(input())
a = [int(input()) for _ in range(5)]

ans = 0 
lst = [n, 0, 0, 0, 0, 0]
while lst[5] < n:
    for i in [5, 4, 3, 2, 1]: 
        if lst[i-1] >= a[i-1]:
            lst[i] += a[i-1]
            lst[i-1] -= a[i-1]
        else:
            lst[i] += lst[i-1]
            lst[i-1] = 0 
    ans += 1
    #print('lst =', lst)

print(ans)


Fixed submission:
#!/usr/bin/env python
import sys 
import math
input = sys.stdin.readline

n = int(input())
a = [int(input()) for _ in range(5)]
ans = math.ceil(n/min(a)) + 4 
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

n, m = map(int, input().split())
a = [-1 for _ in range(n)]
b = [-1 for _ in range(n)]
d = {}
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

d = sorted(d.items(), key=lambda x:x[0])
num = ans = 0 
for i in range(n):
    tmp = num 
    num += d[i][1]
    if num <= m:
        ans += d[i][0]*d[i][1]
    else:
        ans += d[i][0]*(m-tmp)
        break

print(ans)


Fixed submission:
#!/usr/bin/env python3

n, m = map(int, input().split())
a = [-1 for _ in range(n)]
b = [-1 for _ in range(n)]
d = {}
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

d = sorted(d.items(), key=lambda x:x[0])
num = ans = 0 
for i in range(len(d)):
    tmp = num 
    num += d[i][1]
    if num <= m:
        ans += d[i][0]*d[i][1]
    else:
        ans += d[i][0]*(m-tmp)
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

n, m = map(int, input().split())
a = [-1 for _ in range(n)]
b = [-1 for _ in range(n)]
d = {}
for i in range(n):
    a[i], b[i] = map(int, input().split())
    d[a[i]] = b[i]

d = sorted(d.items(), key=lambda x:x[0])
num = ans = 0 
for i in range(n):
    tmp = num 
    num += d[i][1]
    if num <= m:
        ans += d[i][0]*d[i][1]
    else:
        ans += d[i][0]*(m-tmp)
#        import pdb; pdb.set_trace()
        break

print(ans)


Fixed submission:
#!/usr/bin/env python3

n, m = map(int, input().split())
a = [-1 for _ in range(n)]
b = [-1 for _ in range(n)]
d = {}
for i in range(n):
    a[i], b[i] = map(int, input().split())
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

d = sorted(d.items(), key=lambda x:x[0])
num = ans = 0 
for i in range(len(d)):
    tmp = num 
    num += d[i][1]
    if num <= m:
        ans += d[i][0]*d[i][1]
    else:
        ans += d[i][0]*(m-tmp)
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

s = input()
tmp = 0 
# まず"01"で抜きまくって、次に"10"で抜きまくる。という実装
ans = 0 
while len(s) != tmp:
    tmp = len(s)
    for i in range(len(s)-1):
        if s[i] == '0' and s[i+1] == '1':
            ans += 1
            s = s[0:i]+s[i+2:]
            #print('s =', s)
            break
tmp = 0 
while len(s) != tmp:
    tmp = len(s)
    for i in range(len(s)-1):
        if s[i] == '1' and s[i+1] == '0':
            ans += 1
            s = s[0:i]+s[i+2:]
            #print('s =', s)
            break

print(2*ans)


Fixed submission:
#!/usr/bin/env python3

s = input()

c0 = s.count('0')
c1 = s.count('1')

ans = min(c0, c1)*2
print(ans)
Buggy python submission (verdict: Runtime Error):
# Knapsack問題

# input
N,W = map(int, input().split())
w = []
v = []
for _ in range(N):
  a,b = map(int ,input().split())
  w.append(a)
  v.append(b)

# calc
dp = [[0 for _ in range(W+1)] for _ in range(N+2)]

for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])


Fixed submission:
#!/usr/bin/env python3

n = int(input())
h = list(map(int, input().split()))
dp = [10001 for _ in range(n)]

dp[0] = 0 
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i-1] + abs(h[i]-h[i-1]))

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

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

def isallodd(arr):
    haseven = False
    for i in arr:
        if i%2==0:
            haseven = True
            break
    if haseven:
        return False
    else:
        return True

ans = 0 
while isallodd(a)==False:
    on = False
    for i in range(len(a)):
        if a[i]%2==1:
            a[i]*=3
        else:
            if on == False:
                a[i]//=2
                on = True
            else:
                a[i]*=3
    ans += 1 

print(ans)


Fixed submission:
#!/usr/bin/env python3

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

def f(n):
    ans = 0 
    while n%2 == 0:
        n //= 2
        ans += 1
    return ans 

ans = 0 
for i in a:
    ans += f(i)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

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

def isallodd(arr):
    haseven = False
    for i in arr:
        if i%2==0:
            haseven = True
            break
    if haseven:
        return False
    else:
        return True

ans = 0 
while isallodd(a)==False:
    on = False
    for i in range(len(a)):
        if a[i]%2==1:
            a[i]*=3
        else:
            if on == False:
                a[i]//=2
                on = True
            else:
                a[i]*=3
    ans += 1 

print(ans)


Fixed submission:
#!/usr/bin/env python3

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

def f(n):
    ans = 0 
    while n%2 == 0:
        n //= 2
        ans += 1
    return ans 

ans = 0 
for i in a:
    ans += f(i)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
import sys 
import copy
input = sys.stdin.readline

n = int(input())
x = list(map(int, input().split()))

for i in range(n):
    xx = copy.deepcopy(x)
    xx.pop(i)
    xx = sorted(xx)
    print(xx[(n-1)//2])


Fixed submission:
#!/usr/bin/env python
import sys 
import copy
input = sys.stdin.readline

n = int(input())
x = list(map(int, input().split()))
xx = sorted(x)

l = xx[(n-1)//2]
r = xx[n//2]
mid = (l+r)/2

for i in range(n):
    if x[i] >= mid:
        print(l)
    else:
        print(r)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

x, y = map(int, input().split())
tmp = x 

if x == y:
    print(-1)
    exit()

while True:
    x += tmp 
    if x%y != 0:
        print(x)
        exit()


Fixed submission:
#!/usr/bin/env python

x, y = map(int, input().split())
tmp = x 

if x%y == 0:
    print(-1)
    exit()

while True:
    x += tmp 
    if x%y != 0:
        print(x)
        exit()
Buggy python submission (verdict: Runtime Error):
#!/user/bin/env 

n = int(input())
t = [-1 for _ in
x = [-1 for _ in
y = [-1 for _ in
for i in range(n
    t[i], x[i], 

dt = [-1 for _ i
dx = [-1 for _ i
dy = [-1 for _ i
for i in range(n
    if i == 0:
        dt[0] = 
        dx[0] = 
        dy[0] = 
    else:
        dt[i] = 
        dx[i] = 
        dy[i] = 

ok = True
for i in range(n
    tr = dt[i]%2
    pr = (dx[i]+
    if (tr == pr
        pass
    else:
        ok = Fal
#        import 
        break

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


Fixed submission:
#!/user/bin/env python3

n = int(input())
t = [-1 for _ in range(n)]
x = [-1 for _ in range(n)]
y = [-1 for _ in range(n)]
for i in range(n):
    t[i], x[i], y[i] = map(int, input().split())

dt = [-1 for _ in range(n)]
dx = [-1 for _ in range(n)]
dy = [-1 for _ in range(n)]
for i in range(n):
    if i == 0:
        dt[0] = t[0]
        dx[0] = x[0]
        dy[0] = y[0]
    else:
        dt[i] = t[i] - t[i-1]
        dx[i] = x[i] - x[i-1]
        dy[i] = y[i] - y[i-1]

ok = True
for i in range(n):
    tr = dt[i]%2
    pr = (dx[i]+dy[i])%2
    if (tr == pr) and (dt[i] >= abs(dx[i])+abs(dy[i])):
        pass
    else:
        ok = False
#        import pdb; pdb.set_trace()
        break

if ok:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
import re

s = input()
STR = 'AKIHABARA'
if len(s) > len(STR):
    print('NO')
    exit()

regex = re.compile('A?KIHA?BA?RA?')
mo = regex.search(s)
if mo == None:
    print('NO')
else:
    print('YES')
~                 

Fixed submission:
#!/usr/bin/env python
import re

s = input()
STR = 'AKIHABARA'
if len(s) > len(STR):
    print('NO')
    exit()

regex = re.compile('^A?KIHA?BA?RA?')
mo = regex.search(s)
if mo == None:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

# input
n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())

# calc
middle = []
ok = False
for i in range(m):
    if a[i] == 1:
        middle.append(b[i])
for i in range(len(middle)):
    for j in range(m):
        if a[j] == middle[i] and b[j] == n:
            ok = True
if ok: 
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
#!/usr/bin/env python
from collections import deque

# input
n, m = map(int, input().split())
a = [0 for _ in range(m)]
b = [0 for _ in range(m)]
for i in range(m):
    a[i], b[i] = map(int, input().split())

if m == 1:
    print('IMPOSSIBLE')
    exit()

to = [[] for _ in range(n+1)]
for i in range(m):
    to[a[i]].append(b[i])
    to[b[i]].append(a[i])
#print('to =', to)

# BFS
inf = 200200
dist = [inf for _ in range(n+1)]
q = deque()
q.append(1)
dist[1] = 0 

while q:
    v = q.popleft()
    for u in to[v]:
        if dist[u] == inf:
            dist[u] = dist[v]+1
            q.append(u)

if dist[n] == 2:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
#/usr/bin/env python

n = int(input())
a = [int(input()) for _ in range(n)]

lighted = [0] 
ans = 0 

while True:
    u = lighted[-1]
    v = a[u]-1
    ans += 1
    if v == 1:
        print(ans)
        exit()
    if v not in lighted:
        lighted.append(v)
    else:
        print(-1)
        exit()


Fixed submission:
#/usr/bin/env python

n = int(input())
a = [int(input()) for _ in range(n)]

lighted = [0] 
ans = 0 

for i in range(n):
    u = lighted[-1]
    v = a[u]-1
    ans += 1
    if v == 1:
        print(ans)
        exit()
    lighted.append(v)

print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# BFS
from collections import deque

x = int(input())
q = deque()
q.append((0, 0))
visited = []

while q:
    u = q.popleft()
    if u[0] == x:
        print(u[1])
        break
    visited.append(u)
    if ((u[0]-1, u[1]+1)) not in visited:
        q.append((u[0]-(u[1]+1), u[1]+1))
    if ((u[0], u[1]+1)) not in visited:
        q.append((u[0], u[1]+1))
    if ((u[0]+1, u[1]+1)) not in visited:
        q.append((u[0]+(u[1]+1), u[1]+1))

Fixed submission:
#!/usr/bin/env python3

x = int(input())
t = 0
while True:
    if t*(t+1)/2 >= x:
        print(t)
        break
    t += 1
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python

k, s = map(int, input().split())

ans = 0 
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == x + y + z:
                ans += 1

print(ans)


Fixed submission:
#!/usr/bin/env python

k, s = map(int, input().split())

ans = 0 
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-(x + y) <= k:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
    A = list(map(int, input().split()))
    
    if 0 in A:
      print(0)
      return
    
    prod = 1
    for a in A:
		prod *= a
        if prod > 1000000000:
     		print(-1)
            return
    print(prod)
main()

Fixed submission:
def main():
  n = int(input())
  v = list(map(int, input().split()))

  if 0 in v:
    print(0)
    return
  
  prod = 1
  for i in v:
    prod *= i
    if(prod > 1000000000000000000):
      print(-1)
      return
  print(prod)

main()
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a*b==15:
    print("*")
elif a+b==15:
    print("+")
else:
    print("x")

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

if a*b == 15:
    print("*")
elif a+b == 15:
    print("+")
else:
    print("x")

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

if a*b==15: print("*")
elif a+b==15: print("+")
else :print("x")

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

if a*b == 15:
    print("*")
elif a+b == 15:
    print("+")
else:
    print("x")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
import collections
coll=collections.Counter(a)
q=int(input())
suma=sum(a)
lis=[0]*max(a)
for i in a:
    lis[i-1]=coll[i] #lisの「番め」の数字が、aに何個あるか

for i in range(q):
    ans=0
    b,c=map(int,input().split())
    sa=c-b
    lis[c-1]+=lis[b-1]
    ans+=sa*lis[b-1]
    lis[b-1]=0
    suma+=ans
    print(suma)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
import collections
coll=collections.Counter(a)
q=int(input())
suma=sum(a)
lis=[0]*(10**5+1)
for i in a:
    lis[i-1]=coll[i] #lisの「番め」の数字が、aに何個あるか

for i in range(q):
    ans=0
    b,c=map(int,input().split())
    sa=c-b
    lis[c-1]+=lis[b-1]
    ans+=sa*lis[b-1]
    lis[b-1]=0
    suma+=ans
    print(suma)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
suma=sum(a)
for i in range(q):
    ans=0
    b,c=map(int,input().split())
    for j in range(len(a)):
        if a[j] == b:
            a[j]=c
            ans+=c-b
    suma+=ans
    print(suma)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
import collections
coll=collections.Counter(a)
q=int(input())
suma=sum(a)
lis=[0]*(10**5+1)
for i in a:
    lis[i-1]=coll[i] #lisの「番め」の数字が、aに何個あるか

for i in range(q):
    ans=0
    b,c=map(int,input().split())
    sa=c-b
    lis[c-1]+=lis[b-1]
    ans+=sa*lis[b-1]
    lis[b-1]=0
    suma+=ans
    print(suma)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    for j in range(len(a)):
        if a[j] == b:
            a[j]=c
    print(sum(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
import collections
coll=collections.Counter(a)
q=int(input())
suma=sum(a)
lis=[0]*(10**5+1)
for i in a:
    lis[i-1]=coll[i] #lisの「番め」の数字が、aに何個あるか

for i in range(q):
    ans=0
    b,c=map(int,input().split())
    sa=c-b
    lis[c-1]+=lis[b-1]
    ans+=sa*lis[b-1]
    lis[b-1]=0
    suma+=ans
    print(suma)
Buggy python submission (verdict: Runtime Error):
if n==0:
    print(x)
    quit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    quit()
p.sort()
ans=[]
#本題
for i in range(p[0],p[-1]+1):
    if i not in p:
        ans.append(i)
ans.append(100000000)
for i in range(len(ans)):
    if ans[i]>x:
        if abs(x-ans[max(i-1,0)]) <= abs(x-ans[i]):
            print(ans[max(i-1,0)])
        else:
            print(ans[i])
        quit()

Fixed submission:
x,n=map(int,input().split())
if n==0:
    print(x)
    quit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    quit()
i=0
while True:
    if x-i not in p:
        print(x-i)
        quit()
    elif x+i not in p:
        print(x+i)
        quit()
    i+=1
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
ans=[]
for i in range(n+1):
    ans.append(a*i//b-a*(i//b))
print(max(ans))

Fixed submission:
a,b,n=map(int,input().split())
if b-1>n:
    ans=n
else:
    ans=b-1
print(a*ans//b-a*(ans//b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))


Fixed submission:
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
for i in range(n):
  print(c[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
for i in range(n):
  print(c[i + 1])