Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
##149
##A
S = input()
T = input()

print(T+S)

Fixed submission:
##149
##A
S,T = map(str,input().split())

print(T+S)
Buggy python submission (verdict: Runtime Error):
##C
X = input()

from sympy import nextprime
from sympy import isprime
if isprime(X):
    print(X)
else:
    print(nextprime(X))

Fixed submission:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

Buggy python submission (verdict: Runtime Error):
##C
X = input()

from sympy import nextprime
from sympy import isprime
if isprime(X):
    print(X)
else:
    print(nextprime(X))

Fixed submission:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

Buggy python submission (verdict: Runtime Error):
##C
X = input()

from sympy import nextprime
print(nextprime(X))

Fixed submission:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1
Buggy python submission (verdict: Runtime Error):
##C
a,b = map(int,input().split())
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

aa = (prime_factorize(a))
bb = (prime_factorize(b))

def f(a1, b1):
  result = []
  for i in sorted(set(a1 + b1)):
    aa1 = [x for x in a1 if x == i]
    bb1 = [x for x in b1 if x == i]
    result += aa1 if len(aa1) < len(bb1) else bb1
  return result

from operator import mul
from functools import reduce

aabb = reduce(mul,f(aa,bb))

print(int(a*b/aabb))

Fixed submission:
##C
a,b = map(int,input().split())
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

aa = (prime_factorize(a))
bb = (prime_factorize(b))

def f(a1, b1):
  result = []
  for i in sorted(set(a1 + b1)):
    aa1 = [x for x in a1 if x == i]
    bb1 = [x for x in b1 if x == i]
    result += aa1 if len(aa1) < len(bb1) else bb1
  return result

from operator import mul
from functools import reduce

aabb1 = f(aa,bb)

if aabb1 == []:
    aabb1 = [1,1]

aabb = reduce(mul,aabb1)

print(int(a*b/aabb))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 0
for i in range(9):
    for j in range(9):
        if n == i*j:
            ans += 1
if ans >=1:
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
a = 0
for i in range(9):
    for j in range(9):
        if n == (i+1)*(j+1):
            a += 1
if a == 0:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
##D
a,b,x = map(int,input().split())

import math
if x >= a*a*b/2:
    y = 2*(a*a*b-x)/(a*a) 
    atan1 = 90-math.degrees(math.atan(a/y))
else:
    y = 2*x/(a*b)
    atan1 = math.degrees(math.atan(b/y))
print(atan1)


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

import math
if x >= a*a*b/2:
    y = 2*(a*a*b-x)/(a*a)
    if y == 0:
        atan1 = 0
    else:
        atan1 = 90-math.degrees(math.atan(a/y))
else:
    y = 2*x/(a*b)
    if y == 0:
        atan1 = 0
    else:
        atan1 = math.degrees(math.atan(b/y))
print(atan1)
Buggy python submission (verdict: Time Limit Exceeded):
##C
n = int(input())
a = list(map(int,input().split()))
b = list()
for i in range(n):
    for j in range(n):
        if a[j] == i+1:
            b.append(j+1)
print(*b)

Fixed submission:
##C
n = int(input())
a = list(map(int,input().split()))
##リストに0をn個いれておく
b = [0]*n
##enumerateで、要素とインデックスを両方得る
for i , val in enumerate(a):
    b[val-1] = i+1
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
##C
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
b = [k]*n

for i in range(q):
    b[a[i]-1] += 1
    for j in range(n):
        b[j] += -1

for i in b:
    if i >= 1:
        print("Yes")
    else:
        print("No")

Fixed submission:
##C
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
b = [k]*n

for j in range(n):
        b[j] += -q

for i in range(q):
    b[a[i]-1] += 1

for i in b:
    if i >= 1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
x = 0
for i in (input()+1):
  x += i
print(x)


Fixed submission:
x = 0
n = int(input())
for i in range(n+1):
  x += i
print(x)

Buggy python submission (verdict: Runtime Error):
for i in (input()+1):
  x += i
print(x)

Fixed submission:
x = 0
n = int(input())
for i in range(n+1):
  x += i
print(x)
Buggy python submission (verdict: Runtime Error):
s = [str(i) for i in list(str(input()))]
x = list()
for i in s:
    if i == "0" or i == "1":
      x.append(i)
    else:
        x.pop(-1)
print(x)

Fixed submission:
s = [str(i) for i in list(str(input()))]
x = list()
for i in s:
    if i == "0" or i == "1":
      x.append(i)
    elif i== "B" and x != []:
        x.pop(-1)
print(','.join(x).replace(",",""))
Buggy python submission (verdict: Runtime Error):
import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)

Fixed submission:
S = list(input())
cnt = 0
maxCnt = 0

for i in range(3):
    if S[i] == "R":
        cnt += 1
    else:
        cnt = 0
    if maxCnt < cnt:
        maxCnt = cnt

print(maxCnt)
Buggy python submission (verdict: Runtime Error):
import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)

Fixed submission:
import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
dates = [int(i) for i in input().split(" ")]
X = dates[0]
K = dates[1]
D = dates[2]

if X >= 0:
    while X > 0 and K > 0:
        X -= D
        K -= 1
else:
    while X <= 0 and K > 0:
        X += D
        K -= 1

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


Fixed submission:
import math

dates = [int(i) for i in input().split(" ")]
X = dates[0]
K = dates[1]
D = dates[2]
numDiv = math.ceil(abs(X) / D)

if numDiv < K:
    if X >= 0:
        X -= numDiv * D
        K -= numDiv
    else:
        X += numDiv * D
        K -= numDiv
else:
    if X >= 0:
        X -= K * D
        K = 0
    else:
        X += K * D
        K = 0

if X >= 0:
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X - D))
else:
    if K % 2 == 0:
        print(abs(X))
    else:
        print(abs(X + D))
Buggy python submission (verdict: Time Limit Exceeded):
def checkStn(stnData,numStn):
    ftn = False
    for i in range(numStn - 1):
        if stnData[i] == "W" and stnData[i+1] == "R":
            ftn = True
            break
    return ftn

def exchangeStn(stnData,numStn):
    cnt = 0
    for i in range(numStn):
        for j in range(numStn - 1 ,-1, -1):
            if i < j:
                if stnData[i] == "W" and stnData[j] == "R":
                    stnData[i] = "R"
                    stnData[j] = "W"
                    cnt += 1
                    break
    return cnt


numStn = int(input())
stnData = list(input())

ftn = checkStn(stnData,numStn)
cnt = 0

while ftn == True:
    ftn = checkStn(stnData,numStn)
    cnt += exchangeStn(stnData,numStn)

print(cnt)

Fixed submission:
numStn = int(input())
stnData = list(input())

ttlW = stnData.count("W")
ttlR = stnData.count("R")

cnt = ttlR - stnData[:ttlR].count("R")

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = []
scoreSet = []

for i in range(N-K+1):
    for j in range(K):
        tempScore.append(scores[j+i])
    scoreSet.append(tempScore)
    tempScore = []

for i in range(len(scoreSet)-1):
    if scoreSet[i][0] < scoreSet[i+1][K-1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = []
scoreSet = []

for i in range(N-K):
    if scores[i] < scores[i+K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = 1
scoreSet = []

for i in range(N-K+1):
    for j in range(K):
        tempScore *= scores[j+i]
    scoreSet.append(tempScore)
    tempScore = 1

for i in range(len(scoreSet)-1):
    if scoreSet[i] < scoreSet[i+1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = []
scoreSet = []

for i in range(N-K):
    if scores[i] < scores[i+K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

baseScore = 1

for i in range(K):
    baseScore *= scores[i]

tempScore = 1
for i in range(K,N):
    for j in range(K):
        tempScore *= scores[i - j]
    if tempScore > baseScore:
        print('Yes')
    else:
        print('No')
    baseScore = tempScore
    tempScore = 1


Fixed submission:
terms = [int(i) for i in input().split(" ")]
scores = [int(i) for i in input().split(" ")]

N = terms[0]
K = terms[1]

tempScore = []
scoreSet = []

for i in range(N-K):
    if scores[i] < scores[i+K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0

for i in range(1,N+1):
    for j in range(1,N+1):
        if N - i*j > 0:
            ans += 1

print(ans)

Fixed submission:
N = int(input())
ans = 0

for A in range(1,N):
    ans += (N-1)//A
        
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] + list(map(int,input().split()))
ansl = []
ans = 10**9 + 7

for i in range(1,N+1):
    for j in range(1,N+1):
        if i < j:
            ansl.append((A[i])*(A[j]))

print(sum(ansl)%ans)

Fixed submission:
import itertools

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

acc = list(itertools.accumulate(A))
ans = 0
mod = 10**9 + 7

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

print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nn = str(N)
n = len(nn)
ans = []

for i in range(n):
    waru = N % 10
    N = N // 10  
    ans.append(waru)

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


Fixed submission:
N = input()
ans = []

for i in range(len(N)):
    ans.append(N[i])


ys = map((lambda x: int(x)), ans)
Sans = sum(ys)

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

Buggy python submission (verdict: Runtime Error):
N = int(input())
nn = str(N)
n = len(nn)
ans = []

for i in range(n):
    waru = N % 10
    N = int(N / 10)  
    ans.append(waru)


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


Fixed submission:
N = input()
ans = []

for i in range(len(N)):
    ans.append(N[i])


ys = map((lambda x: int(x)), ans)
Sans = sum(ys)

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

Buggy python submission (verdict: Runtime Error):
N = int(input())
nn = str(N)
n = len(nn)
ans = []

for i in range(n):
    waru = N % 10
    N = int(N / 10)  
    ans.append(waru)

print(ans)

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


Fixed submission:
N = input()
ans = []

for i in range(len(N)):
    ans.append(N[i])


ys = map((lambda x: int(x)), ans)
Sans = sum(ys)

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

Buggy python submission (verdict: Runtime Error):
N = int(input())
nn = str(N)
n = len(nn)
ans = []

for i in range(n):
    waru = N % 10
    N = int(N / 10)  
    ans.append(waru)
       
if sum(ans) % 9 == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
N = input()
ans = []

for i in range(len(N)):
    ans.append(N[i])


ys = map((lambda x: int(x)), ans)
Sans = sum(ys)

if Sans % 9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
    if A[i] > A[i+1]:
        youso = A[i] - A[i+1]
        A[i+1] += youso
        ans.append(youso)
        print(ans)
    else:
        pass

print(sum(ans))


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

for i in range(N-1):
    if A[i] > A[i+1]:
        youso = A[i] - A[i+1]
        A[i+1] += youso
        ans.append(youso)
    else:
        pass

print(sum(ans))
Buggy python submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())

a = K - A #Aのカードを引いた後のB,Cの数
b = K - A - B #Bのカードで水増しした後のCの数

if A = 0:
    print((-1)*b)
elif A > 0:
    if b >= 0:
        print(A - b)
    elif b < 0:
        print(A)

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

if A > K:
    ans += K * 1
else:
    ans += A * 1

if K - A - B >= 0:
    ans += (K - A - B) * (-1)
else:
    ans += 0
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))

snk_sweets = []

for i in range(K):
    sweets = int(input())
    snk_sweets = snk_sweets + input().split()

len_snk = len(snk_sweets)
print(N - len_snk)


Fixed submission:
S = input()

if S == 'ABC' :
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
import math
R = range(1,100)
def Circle(R):
    return 2 * math.pi * R
  
Circle(R)

Fixed submission:
import math
R = int(input())
print(2 * math.pi * R)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

for i in range(1,len(A)+2):
    print(A.count(i))
    

Fixed submission:
import collections

N = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)

for i in range(1,len(A)+2):
    print(a[i])
Buggy python submission (verdict: Runtime Error):
box = [input(),input(),input()]
X,Y,Z = box
print(Y,Z,X)

Fixed submission:
X,Y,Z = list(map(int,input().split()))
print(Z,X,Y)

Buggy python submission (verdict: Runtime Error):
box = [input(),input(),input()]
X,Y,Z = box
print(Y,Z,X)

Fixed submission:
X,Y,Z = list(map(int,input().split()))
print(Z,X,Y)
Buggy python submission (verdict: Runtime Error):
N = int(input(())

if N % 2 == 1:
    print(N/2 + 1)
else:
    print(N/2)


Fixed submission:
N = int(input())

if N % 2 == 1:
    print(int(N/2 +1))
else:
    print(int(N/2))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,Q = map(int,input().split())
S = input()
lr = [map(int,input().split()) for _ in range(Q)]
l_r = [list(i) for i in zip(*lr)] 

scc = list(itertools.accumulate(S))

for i in range(Q):
    right = scc[l_r[1][i]-1]
    left = right[l_r[0][i]-1:]
    print(left.count("AC"))

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


t = [0] * (N+1)

for i in range(N):
    if S[i : i+2] == "AC":
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

for j in range(Q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for _ in range(N)]

paper = []
for i in range(N):
    if not A[i] in paper:
        paper.append(A[i])
    else:
        paper.remove(A[i])

print(len(paper))


Fixed submission:
import collections

N = int(input())
A = [int(input()) for _ in range(N)]

ans= 0
Acount = collections.Counter(A)

for i in Acount:
    if Acount[i] % 2 == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
k=int(input())
#k*=9
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    i=1
    s=10
    while s%k!=1:
        s=s*10%k
        i+=1
print(i)

Fixed submission:
k=int(input())
k*=9
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    i=1
    s=10
    while s%k!=1:
        s=s*10%k
        i+=1
    print(i)

Buggy python submission (verdict: Runtime Error):
k=int(input())
#k*=9
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    for j in make_divisors(k-1):
        s=1
        for p in range(j):
            s=s*10%k
        if s==1:
            break
    print(j)

Fixed submission:
k=int(input())
k*=9
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    i=1
    s=10
    while s%k!=1:
        s=s*10%k
        i+=1
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
q = int(input())
Acount = Counter(A)
Adic = dict(Acount)
# print(Adic)
s = 0
for key, value in Adic.items():
    s += key*value
for i in range(q):
    b, c = map(int, input().split())
    if not b in set(Adic.keys()):
        Adic[b] = 0
    s += (c - b) * Adic[b]
    if not c in set(Adic.keys()):
        Adic[c] = 0
    Adic[c] += Adic[b]
    Adic[b] = 0
    print(s)


Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
q = int(input())
Acount = Counter(A)
Adic = dict(Acount)
Akey = set(Adic.keys())
M = max(A)
L = [0 for i in range(10**5)]
for i in range(M):
    if i+1 in Akey:
        L[i] = Adic[i+1]
s = 0
for i in range(M):
    s += (i + 1) * L[i]
for i in range(q):
    b, c = map(int, input().split())
    s += (c - b) * L[b - 1]
    L[c - 1] += L[b - 1]
    L[b - 1] = 0
    print(s)
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
C=list()
A=list()
for i in range(n):
    c=list(map(int,input().split()))
    C.append(c[0])
    A.append(c[1:m+1])
L=[0]*m
for i in range(n):
    for j in range(m):
        L[j]+=A[i][j]
if min(L)<x:
    print(-1)
else:
    import itertools
    v=list(itertools.permutations([i for i in range(n)]))
    l=[0]*len(v)
    for i in range(len(v)):
        z=v[i]
        r=[0]*m
        for j in range(n):
            l[i]+=C[z[j]]
            for k in range(m):
                r[k]+=A[z[j]][k]
            if min(r)>=x:
                break
    print(min(l))
    

Fixed submission:
s=input()
t=input()
if t[0:len(t)-1]==s:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n,m,x=map(int,input().split())
C=list()
A=list()
for i in range(n):
    c=list(map(int,input().split()))
    C.append(c[0])
    A.append(c[1:m+1])
L=[0]*m
for i in range(n):
    for j in range(m):
        L[j]+=A[i][j]
if min(L)<x:
    print(-1)
else:
    import itertools
    v=list(itertools.permutations([i for i in range(n)]))
    l=[0]*len(v)
    for i in range(len(v)):
        z=v[i]
        r=[0]*m
        for j in range(n):
            l[i]+=C[z[j]]
            for k in range(m):
                r[k]+=A[z[j]][k]
            if min(r)>=x:
                break
    print(min(l))
    
    

Fixed submission:
n,m,x=map(int,input().split())
C=list()
A=list()
for i in range(n):
    X=list(map(int,input().split()))
    C.append(X[0])
    A.append(X[1:])
import itertools as it
V=list(it.product([0,1],repeat=n))
S=[10**7]*len(V)
for i in range(len(V)):
    Z=V[i]
    L=[0]*m
    for j in range(m):
        for k in range(n):
            L[j]+=A[k][j]*Z[k]
    if min(L)>=x:
        s=0
        for k in range(n):
           s+=C[k]*Z[k]
        S[i]=s
if  min(S)==10**7:
    print(-1)
else:
    print(min(S))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
H=list(map(int,input().split()))
A=[0]*m
B=[0]*m
for i in range(m):
    a,b=map(int,input().split())
    A[i]+=a
    B[i]+=b
for i in range(m):
    if H[A[i]-1]>H[B[i]-1]:
        A[i],B[i]=B[i],A[i]
C=list(A)
for i in range(m):
    if H[A[i]-1]==H[B[i]-1]:
        C.append(B[i])
S=n
for i in range(1,n+1):
    if i in C:
        S-=1
print(S)


Fixed submission:
n, m = map(int, input().split())
H = list(map(int, input().split()))
bridge = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    bridge[a - 1].append(b - 1)
    bridge[b - 1].append(a - 1)
s = 0
#print(bridge)
for i in range(len(bridge)):
    if not(bridge[i]):
        s += 1
    elif H[i] > max([H[j] for j in bridge[i]]):
        s += 1
print(s)