Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ps = [int(i) - 1 for i in input().split()]

neighbors = {v: [] for v in range(n)}
for _ in range(m):
    x, y = map(int, input().split())
    neighbors[x - 1] += [y - 1]
    neighbors[y - 1] += [x - 1]


visited = [False] * n

def conn(i0):
    q = [i0]
    c = set([i0])
    while q:
        i = q.pop()
        visited[i] = True
        c.add(i)
        for n in neighbors[i]:
            if not visited[n]:
                q.append(n)
    return c


def nmatch(c):
    p = set([ps[i] for i in c])
    return len(p & c)


conns = []
for i in range(n):
    if not visited[i]:
        conns.append(conn(i))


answer = sum(nmatch(c) for c in conns)
print(answer)


Fixed submission:
n, m = map(int, input().split())
ps = [int(i) - 1 for i in input().split()]
xy = [map(int, input().split()) for _ in range(m)]

dfind = {i: i for i in range(n)}


def find(v):
    visit = []
    while dfind[v] != v:
        visit.append(v)
        v = dfind[v]

    for i in visit:
        dfind[i] = v

    return v


def union(v0, v1):
    g0, g1 = find(v0), find(v1)
    g0, g1 = min(g0, g1), max(g0, g1)

    if g0 != g1:
        dfind[g1] = g0


for x, y in xy:
    union(x - 1, y - 1)


nmatch = 0
for i, p in enumerate(ps):
    if find(i) == find(p):
        nmatch += 1

print(nmatch)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
vertices = {i: [] for i in range(n)}
for _ in range(m):
    l, r, d = map(int, input().split())
    vertices[l - 1].append((r - 1, d))
    vertices[r - 1].append((l - 1, -d))


def answer():
    x = [None] * n

    while any(i is None for i in x):
        i = x.index(None)
        x[i] = 0
        queue = [i]

        while queue:
            i0 = queue.pop()
            for i1, d in vertices[i0]:
                # print(i0, i1, x[i0], x[i1], d)
                if x[i1] is None:
                    x[i1] = x[i0] + d
                    queue.append(i1)
                elif x[i1] != x[i0] + d:
                    return False

    return True


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





Fixed submission:
n, m = map(int, input().split())
vertices = {i: [] for i in range(n)}
for _ in range(m):
    l, r, d = map(int, input().split())
    vertices[l - 1].append((r - 1, d))
    vertices[r - 1].append((l - 1, -d))


def answer():
    x = [None] * n

    for i in range(n):
        if x[i] is not None:
            continue
        x[i] = 0
        queue = [i]

        while queue:
            i0 = queue.pop()
            for i1, d in vertices[i0]:
                # print(i0, i1, x[i0], x[i1], d)
                if x[i1] is None:
                    x[i1] = x[i0] + d
                    queue.append(i1)
                elif x[i1] != x[i0] + d:
                    return False

    return True


if answer():
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

MAX_T = 10 ** 5

n, c = map(int, input().split())
time = []
channel = []
for _ in range(n):
    s, t, c = map(int, input().split())
    time.append((s, t))
    channel.append(c)

n_program = [0 for _ in range(MAX_T + 1)]

for s, t in time:
    n_program[s] += 1
    n_program[t + 1] -= 1

n_program = accumulate(n_program)

answer = max(n_program)
print(answer)


Fixed submission:
from itertools import accumulate

MAX_T = 10 ** 5 + 100
MAX_C = 30

n, c = map(int, input().split())
time = {c: [] for c in range(1, MAX_C + 1)}

for _ in range(n):
    s, t, c = map(int, input().split())
    time[c].append((s, t))

n_program = [0 for _ in range(MAX_T + 1)]

for c in range(1, MAX_C + 1):

    recording = [0 for _ in range(MAX_T + 1)]

    for s, t in time[c]:
        recording[s] += 1
        recording[t + 1] -= 1

    recording = accumulate(recording)

    for i, r in enumerate(recording):
        if r:
            n_program[i] += 1

answer = max(n_program)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil

n, a, b = map(int, input().split())
hs = [int(input()) for _ in range(n)]


def defeatable(k):
    hb = [max([h - k * b, 0]) for h in hs]
    n_attack = sum([ceil(h / (a - b)) for h in hb])
    return n_attack <= k


l, r = 0, 10 ** 14

while r - l > 1:
    m = (l + r) // 2

    if defeatable(m):
        r = m
    else:
        l = m

print(r)



Fixed submission:
from math import ceil

n, a, b = map(int, input().split())
hs = [int(input()) for _ in range(n)]


def defeatable(k):
    hb = [max([h - k * b, 0]) for h in hs]
    n_attack = sum([ceil(h / (a - b)) for h in hb])
    return n_attack <= k


l, r = 0, ceil(max(hs) / b)

while r - l > 1:
    m = (l + r) // 2

    if defeatable(m):
        r = m
    else:
        l = m

print(r)
Buggy python submission (verdict: Runtime Error):
n = input()
N = input()
if n in N: 
  print("Yes")
else: 
  print("No"

Fixed submission:
S = input()
T = input()
if T[:-1] == S:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
seven = 7
n = int(input())
if n.find(seven) = 7: 
  print('Yes')
else: 
  print('No)

Fixed submission:
n = input()
if '7' in n: 
  print('Yes')
else: 
  print('No')
Buggy python submission (verdict: Runtime Error):
string = input()
if string[2]==string[3] && string[4]==string[5]:
    print("Yes")
else: 
    print("No")

Fixed submission:
string = input()
if string[2]==string[3] and string[4]==string[5]:
    print("Yes")
else: 
    print("No")
Buggy python submission (verdict: Runtime Error):
n = 500
x, y = map(int, raw_input().split()) 
if x*n >= y: 
  print("Yes")
else: 
  print("No")

Fixed submission:
n = 500
x, y = map(int, input().split())
if x*n >= y: 
    print("Yes")
else: 
    print("No")
Buggy python submission (verdict: Runtime Error):
n = input().split()
res = list(map(int, num))
if sum(res) >= 22:
    print('bust')
else:
    print('win')

Fixed submission:
n = input().split()
res = list(map(int, n))
if sum(res) >= 22:
    print('bust')
else:
    print('win')

Buggy python submission (verdict: Runtime Error):
n = input().split()
res = list(map(int, num))
if sum(result) >= 22:
    print('bust')
else:
    print('win')

Fixed submission:
n = input().split()
res = list(map(int, n))
if sum(res) >= 22:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Runtime Error):
x = int(input())
if X>=30:
  print("Yes")
else:
  print("No")

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n);
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range (k, n);
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range (k, n);
  if a(i) > a(i-k):
    print("Yes")
  else:
    print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
  if a[i] > a[i-k]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
def log2(n):
  if n < 2:
    return 0
  else:
    return 1 + log2(n // 2)

n = int(input())
a_list = list(map(int, input().split()))
d = defaultdict(int)
a_list.sort()

for a in a_list:
  d[a] += 1

a_list = list(set(a_list))
c = 0
for a in a_list:
  m = log2(a, 2)
  x = 2 ** (m+1) - a
  if x == a:
    c += d[a] // 2
    d[a] -= d[a] // 2
  else:
    c += min(d[x], d[a])
    d[x] -= min(d[x], d[a])

print(c)
    

Fixed submission:
from collections import defaultdict
import math

n = int(input())
a_list = list(map(int, input().split()))
d = defaultdict(int)

for a in a_list:
  d[a] += 1

a_list = reversed(sorted(list(set(a_list))))
c = 0
for a in a_list:
  m = int(math.log(a, 2))
  x = 2 ** (m+1) - a
  if x == a:
    c += d[a] // 2
    d[a] -= d[a] // 2
  else:
    c += min(d[x], d[a])
    d[x] -= min(d[x], d[a])

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
def two_power(m):
  if m < 2:
    return 0
  else:
    return two_power(m//2) + 1
  
def nibun(x, *args):
  l = len(args)
  if l == 0:
    return -float('inf')
  elif args[l // 2] == x:
    return l // 2
  elif args[l // 2] < x:
    b = args[:l //2]
    return nibun(x, *b)
  else:
    b = args[l // 2+1:]
    return l // 2 + 1 + nibun(x, *b)
  
n = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()
c = 0
skip = []
for i in range(len(a)):
  if a[i] == -1:
    break
  m = two_power(a[i])
  x = 2 ** (m+1) - a[i]
  b = a[i+1:]
  index = nibun(x, *b)
  if index >= 0:
    c += 1
    a.pop(i + 1 +index)
    a.append(-1)

print(c)



Fixed submission:
from collections import defaultdict
import math

n = int(input())
a_list = list(map(int, input().split()))
d = defaultdict(int)

for a in a_list:
  d[a] += 1

a_list = reversed(sorted(list(set(a_list))))
c = 0
for a in a_list:
  m = int(math.log(a, 2))
  x = 2 ** (m+1) - a
  if x == a:
    c += d[a] // 2
    d[a] -= d[a] // 2
  else:
    c += min(d[x], d[a])
    d[x] -= min(d[x], d[a])

print(c)
Buggy python submission (verdict: Runtime Error):
n = input()
r = [10 - int(n[i]) for i in range(n)]
print("".join(map(str, r)))



Fixed submission:
n = input()
r = [10 - int(n[i]) for i in range(3)]
print("".join(map(str, r)))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def factor(m):
  q = m
  r = []
  i = 2
  while q != 1:
    if q % i:
      i += 1
    else:
      r.append(i)
      q //= i
  return r

n, m = map(int, input().split())
p = 10 ** 9 + 7

r = factor(m)
v = collections.Counter(r)
c = 1
for value in v.values():
  temp = 1
  for i in range(value):
    temp *= value + n - 1 - i
  for i in range(value):
    temp //= i + 1
  temp %= p
  c = c * temp % p
print(c)
  
  
  

Fixed submission:
import collections

def factor(m):
  q = m
  r = []
  i = 2
  while i * i <= m:
    if q % i:
      i += 1
    else:
      r.append(i)
      q //= i
  if q != 1:
    r.append(q)
  return r

n, m = map(int, input().split())
p = 10 ** 9 + 7

r = factor(m)
v = collections.Counter(r)
c = 1
for value in v.values():
  temp = 1
  for i in range(value):
    temp *= value + n - 1 - i
  for i in range(value):
    temp //= i + 1
  temp %= p
  c = c * temp % p
print(c)
Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())
r = 0
for x in range(k+1):
  for y in range(k+!):
    z = s - x - y
    if z >= 0 and z <= k:
      r += 1
print(r)

Fixed submission:
k, s = map(int, input().split())
r = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if z >= 0 and z <= k:
      r += 1
print(r)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ratio = [list(map(int, input().split())) for i in range(n)]

k = 1
for i in range(n-1):
  k1 = math.ceil(ratio[i][0] * k / ratio[i+1][0])
  k2 = math.ceil(ratio[i][1] * k / ratio[i+1][1])
  k3 = math.ceil(sum(ratio[i]) * k / sum(ratio[i+1])
  k = max(k1, k2, k3)

print(sum(ratio[n-1]) * k)

Fixed submission:
import math

def quot(p, q):
  return p // q + (p % q != 0)

n = int(input())
ratio = [list(map(int, input().split())) for i in range(n)]

k = 1
for i in range(n-1):
  k1 = quot(ratio[i][0] * k , ratio[i+1][0])
  k2 = quot(ratio[i][1] * k , ratio[i+1][1])
  k = max(k1, k2)

print(sum(ratio[n-1]) * k)
Buggy python submission (verdict: Runtime Error):
s = input()

score = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] = "p":
    score -= 1
  elif i % 2 != 0 and s[i] = "g":
    score += 1

print(s)

Fixed submission:
s = input()

score = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "p":
    score -= 1
  elif i % 2 != 0 and s[i] == "g":
    score += 1

print(score)
Buggy python submission (verdict: Time Limit Exceeded):
K = 10 ** 9 + 7

def pow_K(x, n):
  if n == 0:
    return 1
  else:
    return (pow_K(x, n // 2) ** 2 * x ** (n % 2)) % K

H, W, A, B = map(int, input().split())

fact = [0 for i in range(H+W-1)]
fact[0] = 1
for i in range(H+W-2):
  fact[i + 1] = fact[i] * (i+1) % K
fact_inv = [pow_K(fact[i], K-2) for i in range(H+W-1)]

r = 0
for i in range(B, W):
  r += ((fact[H-A-1+i] * fact_inv[H-A-1] %K)*fact_inv[i] % K) * ((fact[W-1-i+A-1] * fact_inv[W-1-i] %K) * fact_inv[A-1] % K) %K
  r %= K

print(r)


Fixed submission:
K = 10 ** 9 + 7

def pow_K(x, n):
  if n == 0:
    return 1
  else:
    return (pow_K(x, n // 2) ** 2 * x ** (n % 2)) % K

H, W, A, B = map(int, input().split())

fact = [0 for i in range(H+W-1)]
fact[0] = 1
for i in range(H+W-2):
  fact[i + 1] = fact[i] * (i+1) % K
fact_inv = [0 for i in range(H+W-1)]
fact_inv[H+W-2] = pow_K(fact[H+W-2], K-2)
for i in range(H+W-2, 0, -1):
  fact_inv[i-1] = fact_inv[i] * i % K

r = 0
for i in range(B, W):
  r += ((fact[H-A-1+i] * fact_inv[H-A-1] %K)*fact_inv[i] % K) * ((fact[W-1-i+A-1] * fact_inv[W-1-i] %K) * fact_inv[A-1] % K) %K
  r %= K

print(r)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = int(input())
count=0
for i in range(0,n):
  p = int(input())
  q = int(input())
  res = sqrt((p**2)+(q**2))
  if res<=d:
    count += 1
print(count)

Fixed submission:
from math import sqrt
n,d = input().split()
n = int(n)
d = int(d)
count=0
for i in range(0,n):
  p,q = input().split()
  p = int(p)
  q = int(q)
  res = sqrt((p**2)+(q**2))
  if res<=d:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s = (input())
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
    	flag=1
		break
if flag==1:
	print('Bad')
else:
	print('Good')

Fixed submission:
s = input()
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
		flag=1
		break
if flag==1:
	print('Bad')
else:
	print('Good')

Buggy python submission (verdict: Runtime Error):
s = (input()
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
    	flag=1
		break
if flag==1:
	print('Bad')
else:
	print('Good')

Fixed submission:
s = input()
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
		flag=1
		break
if flag==1:
	print('Bad')
else:
	print('Good')

Buggy python submission (verdict: Runtime Error):
s = (input()
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
    	flag=1
   		break
if flag==1:
	print('Bad')
else:
	print('Good')

Fixed submission:
s = input()
l = list(s)
flag = 0
for i in range(0,len(l)-1):
	if l[i+1]==l[i]:
		flag=1
		break
if flag==1:
	print('Bad')
else:
	print('Good')
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = [int(x) for x in input().split()]
num = 0

for a in range(N-2):
    for b in range(a + 1, N-1):
        for c in range(b + 1, N):
            if (abs(d[a]-d[b]) < d[c]) and (d[c] < d[a] + d[b]):
                num += 1

print(num)

Fixed submission:
N = int(input())
S = input()
num = 0

for i in range(len(S)-1):
    if S[i] != S[i + 1]:
        num += 1

print(num+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = 0
for i in range(1, n):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    return
  
print(-1)
  

Fixed submission:
n = int(input())
x, found = 0, False
for i in range(1, n + 1):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    found = True
    break

if not found:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
start, found = 7, -1
for i in range(1, 100000):
  if start % k == 0:
    found = i
    break
  start = (start *10) + 7
print(found)

Fixed submission:
n = int(input())
x, found = 0, False
for i in range(1, n + 1):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    found = True
    break

if not found:
  print(-1)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
from math import sqrt
from collections import defaultdict
#t = int(stdin.readline().strip())
#R, L, C, Vin = [float(x) for x in stdin.readline().strip().split()]
A = int(stdin.readline().strip())
B = int(stdin.readline().strip())
print("Yay!" if (A <= 8 and B <= 8) else ":(")


Fixed submission:
from sys import stdin, stdout
from math import sqrt
from collections import defaultdict
#t = int(stdin.readline().strip())
#R, L, C, Vin = [float(x) for x in stdin.readline().strip().split()]
A, B = [int(x) for x in stdin.readline().strip().split()]
print("Yay!" if (A <= 8 and B <= 8) else ":(")

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout
from math import sqrt
from collections import defaultdict
#t = int(stdin.readline().strip())
#R, L, C, Vin = [float(x) for x in stdin.readline().strip().split()]
A = int(stdin.readline().strip())
B = int(stdin.readline().strip())
print("Yay!" if (A <= 8 and B <= 8) else ":(")


Fixed submission:
from sys import stdin, stdout
from math import sqrt
from collections import defaultdict
#t = int(stdin.readline().strip())
#R, L, C, Vin = [float(x) for x in stdin.readline().strip().split()]
A, B = [int(x) for x in stdin.readline().strip().split()]
print("Yay!" if (A <= 8 and B <= 8) else ":(")
Buggy python submission (verdict: Runtime Error):
N,D = map(int , input().split()) #第二引数(この場合だと---)を第一引数に変換(この場合だとint型)に変換する
ans = 0

for i in N :
    x,y = map(int , input().split())
    if x**2 + y**2 <= D**2:
        ans += 1

print(ans)



Fixed submission:
num = int(input())

if num >= 30 :
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
N,D = map(int , input().split()) #第二引数(この場合だと---)を第一引数に変換(この場合だとint型)に変換する
ans = 0

for i in N :
    x,y = map(int , input().split())
    if x**2 + y**2 <= D**2:
        ans += 1

print(ans)



Fixed submission:
N,D = map(int , input().split()) #第二引数(この場合だと---)を第一引数に変換(この場合だとint型)に変換する
ans = 0

for i in range(N) :
    x,y = map(int , input().split())
    if x**2 + y**2 <= D**2:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in N :
    str = input()
    if str == 'AC' :
        C0 += 1
    if str == 'WA' :
        C1 += 1
    if str == 'TLE':
        C2 += 1
    if str == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))


Fixed submission:
N = int(input())
for A in range(11) :
    if A * 1000 >= N :
        break
oturi = A * 1000 - N
print(oturi)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in N :
    str = input()
    if str == 'AC' :
        C0 += 1
    if str == 'WA' :
        C1 += 1
    if str == 'TLE':
        C2 += 1
    if str == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))


Fixed submission:
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in range(N) :
    B = input()
    if B == 'AC' :
        C0 += 1
    if B == 'WA' :
        C1 += 1
    if B == 'TLE':
        C2 += 1
    if B == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

Buggy python submission (verdict: Runtime Error):
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in N :
    str = input()
    if str == 'AC' :
        C0 += 1
    if str == 'WA' :
        C1 += 1
    if str == 'TLE':
        C2 += 1
    if str == 'RE' :
        C3 += 1

print('AC x ' + C0)
print('WA x ' + C1)
print('TLE x ' + C2)
print('RE x ' + C3)


Fixed submission:
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0

for A in range(N) :
    B = input()
    if B == 'AC' :
        C0 += 1
    if B == 'WA' :
        C1 += 1
    if B == 'TLE':
        C2 += 1
    if B == 'RE' :
        C3 += 1

print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
money=1000
i=0
while i<N-1:
    k=1
    while A[i]==A[i+k]:
        k+=1
   
    if A[i+k]>A[i]:
        kabu=money//A[i]
        money-=kabu*A[i]
        money+=kabu*A[i+k]
        i=i+k
    elif A[i+k]<A[i]:
        i=i+k

print(money)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
money=1000
i=0
while i<N-1:
    k=1
    while A[i]==A[i+k]:
        if i+k==N-1:
            i=i+k
            break
        else:
            k+=1
    if i==N-1:
        break
    if A[i+k]>A[i]:
        kabu=money//A[i]
        money-=kabu*A[i]
        money+=kabu*A[i+k]
        i=i+k
    elif A[i+k]<A[i]:
        i=i+k

print(money)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[i for i in range(1,N+1)]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        if b in A:
            A.remove(b)
    elif H[b-1]>H[a-1]:
        if a in A:
            A.remove(a)
    else:
        if a in A:
            A.remove(a)
        if b in A:
            A.remove(b)
 
print(len(A))

Fixed submission:
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[i for i in range(N)]
B=[]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        B.append(b)
    elif H[b-1]>H[a-1]:
        B.append(a) 
    else:
        B.append(a)
        B.append(b)

B=list(set(B))
print(len(A)-len(B))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[i for i in range(1,N+1)]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        if b in A:
            A.remove(b)
    elif H[b-1]>H[a-1]:
        if a in A:
            A.remove(a)
    else:
        if a in A:
            A.remove(a)
        if b in A:
            A.remove(b)

print(len(A))

Fixed submission:
N,M=map(int,input().split())
H=list(map(int,input().split()))
A=[i for i in range(N)]
B=[]
for i in range(M):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        B.append(b)
    elif H[b-1]>H[a-1]:
        B.append(a) 
    else:
        B.append(a)
        B.append(b)

B=list(set(B))
print(len(A)-len(B))
Buggy python submission (verdict: Runtime Error):
X=int(input())
for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X:
            print(A,B)
            breakｓ

Fixed submission:
import sys
X=int(input())
for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X:
            print(A,B)
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
import math
X=int(input())
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%1==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors

M=make_divisors(X)

p=math.sqrt(X)
p=int(p)
for i in M:
    for k in range(p+1):
        A=k
        B=A-i
        if A**5-B**5==X:
            print(A,B)
            break

Fixed submission:
import sys
X=int(input())
for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X:
            print(A,B)
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f <=n:
        if n%f ==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
if X!=1:
    M=prime_factorize(X)
    M=list(set(M))
else:
    M=[1]
for i in M:
    for k in range(X):
        A=k
        B=A-i
        if A**5-B**5==X:
            print(A,B)
            break

Fixed submission:
import sys
X=int(input())
for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X:
            print(A,B)
            sys.exit()