Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
con = [[] for _ in range(M)]
for i in range(M):
    A, B = map(int, input().split())
    con[A-1].append(B-1)
    con[B-1].append(A-1)
    
d = deque()
houmon = [False] * N
ans = [0] * (N-1)

houmon[0] = True
d.append(0)
while d:
#     print(d, houmon, ans)
    room = d.popleft()
#     houmon[room] = True
#     print(room)
    
    for next_room in con[room]:
        if not houmon[next_room]:
            ans[next_room-1] = room+1
            d.append(next_room)
            houmon[next_room] = True
    
print('Yes\n' + '\n'.join(map(str, ans)))

Fixed submission:
from collections import deque

N, M = map(int, input().split())
con = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    con[A-1].append(B-1)
    con[B-1].append(A-1)
    
d = deque()
houmon = [False] * N
ans = [0] * (N-1)

houmon[0] = True
d.append(0)
while d:
#     print(d, houmon, ans)
    room = d.popleft()
#     houmon[room] = True
#     print(room)
    
    for next_room in con[room]:
        if not houmon[next_room]:
            ans[next_room-1] = room+1
            d.append(next_room)
            houmon[next_room] = True
    
print('Yes\n' + '\n'.join(map(str, ans)))

Buggy python submission (verdict: Runtime Error):
from collections import deque

N, M = map(int, input().split())
con = [[] for _ in range(M)]
for i in range(M):
    A, B = map(int, input().split())
    con[A-1].append(B-1)
    con[B-1].append(A-1)
    
d = deque()
houmon = [False] * N
ans = [0] * (N-1)

houmon[0] = True
d.append(0)
while d:
#     print(d, houmon, ans)
    room = d.popleft()
#     houmon[room] = True
#     print(room)
    
    for next_room in con[room]:
        if not houmon[next_room]:
            ans[next_room-1] = room+1
            d.append(next_room)
            houmon[next_room] = True
    
print('Yes\n' + '\n'.join(map(str, ans)))

Fixed submission:
from collections import deque

N, M = map(int, input().split())
con = [[] for _ in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    con[A-1].append(B-1)
    con[B-1].append(A-1)
    
d = deque()
houmon = [False] * N
ans = [0] * (N-1)

houmon[0] = True
d.append(0)
while d:
#     print(d, houmon, ans)
    room = d.popleft()
#     houmon[room] = True
#     print(room)
    
    for next_room in con[room]:
        if not houmon[next_room]:
            ans[next_room-1] = room+1
            d.append(next_room)
            houmon[next_room] = True
    
print('Yes\n' + '\n'.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
ABC = np.zeros((N, 3))
for i in range(N):
    ABC[i][0], ABC[i][1], ABC[i][2] = map(int, input().split())
DEF = np.zeros((M, 3))
for i in range(M):
    DEF[i][0], DEF[i][1], DEF[i][2] = map(int, input().split())

# 座標圧縮
x_co = {-10**9-1, 10**9+1}
y_co = {-10**9-1, 10**9+1}
for i in range(N):
    x_co.add(ABC[i][0])
    x_co.add(ABC[i][1])
    y_co.add(ABC[i][2])
for i in range(M):
    x_co.add(DEF[i][0])
    y_co.add(DEF[i][1])
    y_co.add(DEF[i][2])

x_co = np.array(sorted(list(x_co)))
y_co = np.array(sorted(list(y_co)))
xL = len(x_co) - 1
yL = len(y_co) - 1
x_co_d = {x_co[i]: i for i in range(xL+1)}
y_co_d = {y_co[i]: i for i in range(yL+1)}

# 柵の存在
s_ex_tate = np.zeros((yL+1, xL))
s_ex_yoko = np.zeros((xL+1, yL))
for i in range(N):
    a = x_co_d[ABC[i][0]]
    b = x_co_d[ABC[i][1]]
    c = y_co_d[ABC[i][2]]
    s_ex_tate[c][a:b] = 1
for i in range(M):
    d = x_co_d[DEF[i][0]]
    e = y_co_d[DEF[i][1]]
    f = y_co_d[DEF[i][2]]
    s_ex_yoko[d][e:f] = 1

# 初期位置
for i in range(xL):
    if x_co[i+1] > 0:
        xf = [i]
        break
    if x_co[i+1] == 0:
        xf = [i, i+1]
        break
for i in range(yL):
    if y_co[i+1] > 0:
        yf = [i]
        break
    if y_co[i+1] == 0:
        yf = [i, i+1]
        break

def sq(x, y):
    return int((x_co[x+1]-x_co[x]) * (y_co[y+1]-y_co[y]))

# 探索
Q = []
# houmon = [[False] * yL for _ in range(xL)]
houmon = np.zeros((xL, yL))
ans = 0
is_inf = False
for x in xf:
    for y in yf:
        houmon[x][y] = 1
        Q.append((x, y))

while Q:
    x, y = Q.pop()
    if x in [0, xL-1] or y in [0, yL-1]:
        is_inf = True
        break
    ans += sq(x, y)
    if (not houmon[x-1][y]) and (not s_ex_yoko[x][y]):
        houmon[x-1][y] = True
        Q.append((x-1, y))
    if (not houmon[x][y-1]) and (not s_ex_tate[y][x]):
        houmon[x][y-1] = True
        Q.append((x, y-1))
    if (not houmon[x+1][y]) and (not s_ex_yoko[x+1][y]):
        houmon[x+1][y] = True
        Q.append((x+1, y))
    if (not houmon[x][y+1]) and (not s_ex_tate[y+1][x]):
        houmon[x][y+1] = True
        Q.append((x, y+1))
    
if is_inf:
    print('INF')
else:
    print(ans)

Fixed submission:
N = int(input())

# 約数
# O(N**0.5)
def yakusu(N):
    ret = [[], []]
    for i in range(1, int(N ** 0.5)+1):
        if N % i == 0:
            ret[0].append(i)
            if i ** 2 != N:
                ret[1].append(N//i)
    return ret[0] + ret[1][::-1]

ans = 0
for a in yakusu(N):
    if a == 1: continue
    
    if N % a == 0:
        b = N
        while b % a == 0:
            b //= a
        if (b-1) % a == 0:
            ans += 1
print(ans + len(yakusu(N-1)) - 1)
Buggy python submission (verdict: Runtime Error):
# ret = []
N = int(input())
L = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    L = newL.copy()
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Fixed submission:
# ret = []
N = int(input())
newL = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    L = newL.copy()
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Buggy python submission (verdict: Runtime Error):
# ret = []
N = int(input())
L = [[0]]
ret.append(L.copy())

for _ in range(N - 1):
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    L = newL.copy()
    

print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))

Fixed submission:
# ret = []
N = int(input())
newL = [[0]]
# ret.append(L.copy())

for _ in range(N - 1):
    L = newL.copy()
    newL = []
    for s in L:
        for i in range(max(s) + 2):
            newL.append(s.copy() + [i])
#     ret.append(newL.copy())
    
di = {i: chr(ord('a') + i) for i in range(10)}
print('\n'.join([''.join(list(map(lambda x: di[x], newL[i]))) for i in range(len(newL))]))
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
uf = UnionFind(N)
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    uf.union(a[i]-1, b[i]-1)

ans = [uf.size(i) - 1 for i in range(N)]

for i in range(M):
    if uf.same(a[i]-1, b[i]-1):
        ans[a[i]-1] -= 1
        ans[b[i]-1] -= 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str, ans)))

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M, K = map(int, input().split())
uf = UnionFind(N)
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())
    uf.union(a[i]-1, b[i]-1)

ans = [uf.size(i) - 1 for i in range(N)]

for i in range(M):
    if uf.same(a[i]-1, b[i]-1):
        ans[a[i]-1] -= 1
        ans[b[i]-1] -= 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c-1, d-1):
        ans[c-1] -= 1
        ans[d-1] -= 1

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    elif a > b:
        return func(b, a-b)
    else:
        return a
      
# print(func(4, 6))
print(A*B//func(A,B))

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



def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    if a % b == 0:
        return b
    else:
        return func(b, a % b)

# print(func(4, 6))
print(A*B//func(A,B))

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

print(A*B//math.gcd(A,B))

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



def func(a, b):
#     print(a, b)
    if a < b:
        return func(b, a)
    if a % b == 0:
        return b
    else:
        return func(b, a % b)

# print(func(4, 6))
print(A*B//func(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[16]:


N = int(input())
A = [int(x) for x in input().split()]
MOD = 10 ** 9 + 7


# In[17]:


count = [0] * 60
for i in range(N):
    s = format(A[i], '060b')
    for d in range(60):
        count[d] += int(s[d])


# In[18]:


# print(count)


# In[19]:


ans = 0
for d in range(60):
    ans = (ans + 2 ** (59 - d) * count[d] * (N - count[d])) % MOD


# In[20]:


print(ans)


# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N = int(input())
A = [int(x) for x in input().split()]
MOD = 10 ** 9 + 7


# In[2]:


count = [0] * 60
for i in range(N):
#     s = format(A[i], '060b')
#     for d in range(60):
#         count[d] += int(s[d])
    for j in range(60):
        count[j] += A[i] % 2
        A[i] //= 2


# In[ ]:





# In[3]:


ans = 0
for d in range(60):
    ans = (ans + count[d] * (N - count[d]) * 2 ** (d)) % MOD


# In[4]:


print(ans)


# In[ ]:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


X, Y, Z, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]


# In[14]:


AB = []
for x in range(X):
    for y in range(Y):
        AB.append(A[x] + B[y])
AB.sort(reverse=True)
if K < X * Y:
    AB = AB[:K]
W = len(AB)
AB


# In[16]:


ABC = []
for w in range(W):
    for z in range(Z):
        ABC.append(AB[w] + C[z])
ABC.sort(reverse=True)
if K < W * Z:
    ABC = ABC[:K]
ABC


# In[17]:


print('\n'.join(map(str, ABC)))


# In[ ]:





# In[ ]:






Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


X, Y, Z, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]


# In[14]:


AB = []
for x in range(X):
    for y in range(Y):
        AB.append(A[x] + B[y])
AB.sort(reverse=True)
if K < X * Y:
    AB = AB[:K]
W = len(AB)
AB


# In[16]:


ABC = []
for w in range(W):
    for z in range(Z):
        ABC.append(AB[w] + C[z])
ABC.sort(reverse=True)
if K < W * Z:
    ABC = ABC[:K]
ABC


# In[17]:


print('\n'.join(map(str, ABC)))


# In[ ]:





# In[ ]:
Buggy python submission (verdict: Runtime Error):


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

print(a+a**2+a**3)


Fixed submission:


a=int(input())

print(a+a**2+a**3)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = [int(e) for e in input().split()]
s = input()
ac = []
for i in range(n-1):
    if s[i:i+2] == 'AC':
        ac.append(i)
for i in range(q):
    l, r = [int(e) for e in input().split()]
    c = 0
    for j in range(l, r):
        if j-1 in ac:
            c += 1
    print(c)


Fixed submission:
n, q = map(int, input().split())
s = input()
a = [0] * n
for i in range(n-1):
  a[i+1] = a[i]
  if s[i:i+2] == 'AC':
    a[i+1] += 1
for i in range(q):
  l, r = map(int, input().split())
  print(a[r-1]-a[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sumA = [A[N-1]]
for i in range(1, N - 1):
    sumA.insert(0, sumA[0]+A[N-i-1])

ans = 0
for i in range(N-1):
    ans += A[i] * sumA[i]

    ans = ans % (10 ** 9 + 7)
print(ans)


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

X = 0
Ans = 0

for i in range(N - 1):
    X += A[i]
    Ans += X * A[i + 1]
    Ans = Ans % (10 ** 9 + 7)

print(Ans)

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

ans = 0
sumA = [sum(A[i+1:]) for i in range(N)]

for i in range(N-1):
    ans += A[i] * sumA[i]

ans = ans % (10 ** 9 + 7)
print(ans)


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

X = 0
Ans = 0

for i in range(N - 1):
    X += A[i]
    Ans += X * A[i + 1]
    Ans = Ans % (10 ** 9 + 7)

print(Ans)

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

ans = 0
sumA = [sum(A[i+1:]) for i in range(N)]

for i in range(N-1):
    ans += A[i] * sumA[i]
    ans = ans % (10 ** 9 + 7)

print(ans)


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

X = 0
Ans = 0

for i in range(N - 1):
    X += A[i]
    Ans += X * A[i + 1]
    Ans = Ans % (10 ** 9 + 7)

print(Ans)

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

ans = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        ans += (A[i] * A[j])
        ans = ans % (10 ** 9 + 7)

print(ans)


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

X = 0
Ans = 0

for i in range(N - 1):
    X += A[i]
    Ans += X * A[i + 1]
    Ans = Ans % (10 ** 9 + 7)

print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = list(map(int, input().split()))

for i in range(K):
    if (abs(X) > D):
        X = abs(X) - D
    else:
        if ((K - i) % 2 == 0):
            break
        else:
            X = X - D
            break

print(abs(X))


Fixed submission:
X, K, D = list(map(int, input().split()))

syou = abs(X) // D


if (K > syou):
    K = K - syou
    if ((K % 2) == 0):
        print(abs(abs(X) - D * syou))
    else:
        print(abs(abs(X)-D*(syou+1)))
else:
    print(abs(abs(X)-D*K))

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

for i in range(K):
    if (abs(X - D) < abs(X + D)):
        X = X - D
    else:
        X = X + D

    if (abs(X) <= D):
        if ((K - i - 1) % 2 == 0):
            break
        else:
            if (abs(X - D) < abs(X + D)):
                X = X - D
            else:
                X = X + D
            break


print(abs(X))


Fixed submission:
X, K, D = list(map(int, input().split()))

syou = abs(X) // D


if (K > syou):
    K = K - syou
    if ((K % 2) == 0):
        print(abs(abs(X) - D * syou))
    else:
        print(abs(abs(X)-D*(syou+1)))
else:
    print(abs(abs(X)-D*K))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))


p = 1
for i in range(K):
    p = p * A[i]

for i in range(K, N):
    pre = p
    p = (p // A[i - K]) * A[i]

    if (pre < p):
        print("Yes")
    else:
        print("No")


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


for i in range(K, N):
    if (A[i - K] < A[i]):
        print("Yes")
    else:
        print("No")

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

point = []
for i in range(K - 1, N):
    p = 1
    for j in range(i - (K - 1), i + 1):
        p = p * A[j]
    point.append(p)


for i in range(1, len(point)):
    if (point[i - 1] < point[i]):
        print("Yes")
    else:
        print("No")


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


for i in range(K, N):
    if (A[i - K] < A[i]):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import math
A, B = input().split()
A = int(A)

B_i = int(B[:-3])
B_f = int(B[-2:])

print(A*B_i + int(str(A*B_f)[:-2]))


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

B_i = int(B[:-3])
B_f = int(B[-2:])


f = str(A*B_f)
if (len(f) >= 3):
    f_i = int(f[:-2])
else:
    f_i = 0

print(A*B_i + f_i)
Buggy python submission (verdict: Runtime Error):
A, B, C, K = list(map(int, input()))

if (A <= K):
    print(K)
elif (A + B <= K):
    print(A)
else:
    print(A+(-1)*(K-A-B))

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

if (A >= K):
    print(K * 1)
elif (A + B >= K):
    print(A)
else:
    print(A+(-1)*(K-A-B))
Buggy python submission (verdict: Runtime Error):
S = input()


if (S = "ABC"):
    print("ARC")
if (S = "ARC"):
    print("ABC")

Fixed submission:
S = input()


if (S == "ABC"):
    print("ARC")
if (S == "ARC"):
    print("ABC")
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))

Snack = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for j in range(d):
        Snack[A[j]] += 1
    
sum = 0
for i in range(N):
    if (Snack[i] == 0):
        sum += 1

print(sum)


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

Snack = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for j in range(d):
        Snack[A[j]-1] += 1
    
sum = 0
for i in range(N):
    if (Snack[i] == 0):
        sum += 1

print(sum)

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

Snack = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for j in range(d):
        Snack[A[d]] += 1
    
sum = 0
for i in range(N):
    if (Snack[i] == 0):
        sum += 1

print(sum)


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

Snack = [0] * N

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))

    for j in range(d):
        Snack[A[j]-1] += 1
    
sum = 0
for i in range(N):
    if (Snack[i] == 0):
        sum += 1

print(sum)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))

G = []*N

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B-1)
    G[B-1].append(A-1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in range(G[i]):
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[] for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in G[i]:
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[0]*N for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A-1][B-1] = 1
    G[B-1][A-1] = 1

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for j in range(N):
        if (G[i][j] == 1):
            if (self_h <= H[j]):
                self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[] for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in G[i]:
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[0]*N for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A][B] = 1
    G[B][A] = 1

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for j in range(N):
        if (G[i][j] == 1):
            if (self_h <= H[j]):
                self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)

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

G = [[] for i in range(N)]

for i in range(M):
    A, B = list(map(int, input().split()))
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)

ans = 0

for i in range(N):
    self_h = H[i]

    self_max_flag = True

    for to in G[i]:
        if (self_h <= H[to]):
            self_max_flag = False
        
    if (self_max_flag):
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)

Fixed submission:
import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

"""
i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)
"""

print(func(A, B, min(B-1, N)))

Buggy python submission (verdict: Time Limit Exceeded):
import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i

print(max)

Fixed submission:
import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

"""
i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)
"""

print(func(A, B, min(B-1, N)))
Buggy python submission (verdict: Runtime Error):
S, W = list(map(int, input().split()))

if (W >= S){
    print('unsafe')
} else{
    print('safe')
}

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

if (W >= S):
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(i) * 2 for i in input().split()]
assert len(A) == n
S = sum(A) // 2
A += A
for i in range(n):
    ans = S
    for j in range(i + 1, i + n, 2):
        ans -= A[j]
    print(ans, end=' ')
print()

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
assert len(A) == n
S = sum(A)
ans = S
for i in range(1, n, 2):
    ans -= A[i] * 2
print(ans, end=' ')
for i in range(1, n):
    ans = A[i - 1] * 2 - ans
    print(ans, end=' ')
print()