Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K,R,S,P = map(int,input().split())
T = str(input())
i = 0
point = 0
for i in range(N):
  if T[i] == "r" and T[K] != "p":
    point += P
  elif T[i] == "s" and T[K] != "r":
    point += R
  elif T[i] == "p" and T[K] != "s":
    point += S
  else:
    break
  i += 1
print(point)

Fixed submission:
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
i = 0
point = 0
L = [""]*N
for i in range(N):
  if T[i] == "r": 
    if i >= K and L[i-K] == "p":
      pass
    else:
      point += P
      L[i] = "p"
  elif T[i] == "s":
    if i >= K and L[i-K] == "r":
      pass
    else:
      point += R
      L[i] = "r"
  elif T[i] == "p":
    if i >= K and L[i-K] == "s":
      pass
    else:
      point += S
      L[i] = "s"
  else:
    break
print(point)

Buggy python submission (verdict: Runtime Error):
N,K,R,S,P = map(int,input().split())
T = map(str,input())
i = 0
point = 0
for i in range(N):
  if T[i] == "r" and T[K] != "p":
    point += P
  elif T[i] == "s" and T[K] != "r":
    point += R
  elif T[i] == "p" and T[K] != "s":
    point += S
  else:
    break
  i += 1
print(point)

Fixed submission:
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
i = 0
point = 0
L = [""]*N
for i in range(N):
  if T[i] == "r": 
    if i >= K and L[i-K] == "p":
      pass
    else:
      point += P
      L[i] = "p"
  elif T[i] == "s":
    if i >= K and L[i-K] == "r":
      pass
    else:
      point += R
      L[i] = "r"
  elif T[i] == "p":
    if i >= K and L[i-K] == "s":
      pass
    else:
      point += S
      L[i] = "s"
  else:
    break
print(point)

Buggy python submission (verdict: Runtime Error):
N,K,R,S,P = map(int,input().split())
T = str(input())
point = 0
for i in range(N):
  if T[i] == "r" and T[K] != "p":
    point += P
  elif T[i] == "s" and T[K] != "r":
    point += R
  elif T[i] == "p" and T[K] != "s":
    point += S
  else:
    break
  i += 1
print(point)

Fixed submission:
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = str(input())
i = 0
point = 0
L = [""]*N
for i in range(N):
  if T[i] == "r": 
    if i >= K and L[i-K] == "p":
      pass
    else:
      point += P
      L[i] = "p"
  elif T[i] == "s":
    if i >= K and L[i-K] == "r":
      pass
    else:
      point += R
      L[i] = "r"
  elif T[i] == "p":
    if i >= K and L[i-K] == "s":
      pass
    else:
      point += S
      L[i] = "s"
  else:
    break
print(point)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = [1,2,3]
if A,B <=3 and A != B:
  C.remove(A)
  C.remove(B)
  print(C)

Fixed submission:
A = int(input())
B = int(input())
C = [1,2,3]
C.remove(A)
C.remove(B)
print(C[0])

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
C = [1,2,3]
C.remove(A)
C.remove(B)
print(C)

Fixed submission:
A = int(input())
B = int(input())
C = [1,2,3]
C.remove(A)
C.remove(B)
print(C[0])

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
C = [1,2,3]
ans = C.remove(A,B)
print(ans)

Fixed submission:
A = int(input())
B = int(input())
C = [1,2,3]
C.remove(A)
C.remove(B)
print(C[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S,T = list(map(str,input().split()))
ans = []*N 
for i in range(N):
  ans[i] = S[i] + T[i]
  i += 1
print(sum(ans))

Fixed submission:
N = int(input())
S,T = list(map(str,input().split()))
list_ans = []
for i in range(N):
  list_ans.extend(S[i] + T[i])
  i += 1
ans = ''.join(list_ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
for i in range(1,10**5):
  if i%A == 0 and i%B == 0:
    ans = i
    break
  else:
    i += 1
print(ans)

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)

Buggy python submission (verdict: Runtime Error):
A,B = (map(int,input().split())
for i in range(1,10**5):
  if i%A == 0 and i%B == 0:
    ans = i
    break
  else:
    i += 1
print(ans)

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)

Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
for i in range(1,10**5):
  if i%A == 0 and i%B == 0:
    ans = i
    break
  else:
    i += 1
print(ans)

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)

Buggy python submission (verdict: Time Limit Exceeded):
A,B = list(map(int,input().split()))
for i in range(1,10**12):
  if i%A == 0 and i%B == 0:
    ans = i
    break
  else:
    i += 1
print(ans)


Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)

Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
for i in range():
  if i%A == 0 and i%B == 0:
    ans = i
  else:
    i += 0
print(ans)

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)

Buggy python submission (verdict: Runtime Error):
A,B = list(map(int,input().split()))
list_ans = []
for i in range():
  if i%A == 0 and i%B == 0:
    ans = i
  else:
    i += 0
print(ans)

Fixed submission:
from fractions import gcd
A,B = map(int,input().split())
lcm = A * B // gcd(A, B)
print(lcm)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(N):
  while i+1 != a[i]:
    a.pop(i)
    count += 1
    if a == []:
      print(-1)
      exit()
  if len(a) == a[-1]:
    print(count)
    exit()


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

for i in range(N):
  if j == a[i]:
    j += 1
if j == 1:
  print(-1)
else:
  print(N-j+1)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(len(a)):
  while i+1 != a[i]:
    a.pop(i)
    count += 1
    if a == []:
      print(-1)
      exit()
  if len(a) == a[-1]:
    print(count)
    exit()


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

for i in range(N):
  if j == a[i]:
    j += 1
if j == 1:
  print(-1)
else:
  print(N-j+1)

Buggy python submission (verdict: Runtime Error):
N =int(input())
a =map(int,input())
count = 1
ans = 0
for i in a:
  if i == count:
    count += 1
    ans += 1
if ans == 0:
  print(-1)
else:
  print(min(N - 1, N - ans))

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

for i in range(N):
  if j == a[i]:
    j += 1
if j == 1:
  print(-1)
else:
  print(N-j+1)

Buggy python submission (verdict: Runtime Error):
N =int(input())
a =int(input())
count = 1
ans = 0
for i in a:
  if i == count:
    count += 1
    ans += 1
if ans == 0:
  print(-1)
else:
  print(min(N - 1, N - ans))

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

for i in range(N):
  if j == a[i]:
    j += 1
if j == 1:
  print(-1)
else:
  print(N-j+1)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input())
if a+b+c <= 21:
  print("win")
else:
  print("bust")

Fixed submission:
a,b,c = map(int,input().split())
if a+b+c <= 21:
  print("win")
else:
  print("bust")
Buggy python submission (verdict: Runtime Error):
N = int(input())
g = [[-1]*15]*15
for i in range(N):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        g[i][x] = y
ans = 0

for i in range(1<<N):
  d = [0]*N
  for j in range(N):
    if (i>>j&1):
      d[j] = 1
  flag = True
  for j in range(N):
    if d[j] == 1:
      for k in range(N):
        if g[j][k] == -1:
          continue
        if g[j][k] != d[k]:
          flag = False
  if flag:
    ans = max(ans,sum(d))
print(ans)

Fixed submission:
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
  m = int(input())
  for _ in range(m):
    x,y = map(int,input().split())
    x -= 1
    A[i].append((x,y))
ans = 0

for i in range(1<<N):
  d = [0]*N
  for j in range(N):
    if (i>>j&1):
      d[j] = 1
  flag = True
  for j in range(N):
    if d[j]:
      for k,l in A[j]:
        if d[k] == l:
          continue
        if d[k] != l:
          flag = False
      if not flag:
        break
  if flag:
    ans = max(ans,sum(d))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(str(input()))
used = [0]*1000
count = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if used[int(S[i]+S[j]+S[k])] == 0:
        count += 1
        used[int(S[i]+S[j]+S[k])] = 1
print(count)

Fixed submission:
N = int(input())
S = list(str(input()))

used = [0]*1000

for i in range(1000):
  stri = str(i)
  if len(stri) == 2:
    stri = "0"+stri
  elif len(stri) == 1:
    stri = "00"+stri
  count = 0
  for j in range(N):
    if S[j] == stri[count]:
      count += 1
    if count == 3:
      used[i] = 1
      break

print(sum(used))
Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,K = map(int,input().split())
S = [list(str(input())) for _ in range(W)]

l = np.array([[0 for _ in range(W)]]*H)
l = l.tolist()
k= 1
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      l[i][j] = str(k)
      k += 1
for i in range(H):
  for j in range(W):
    if l[i][j] == 0:
      if j > 0:
        l[i][j] = l[i][j-1]
      else:
        for m in range(1,W-j):
          if l[i][j+m] != 0:
            l[i][j] = l[i][j+m]
            break
  print(' '.join(l[i]))

Fixed submission:
import numpy as np
H,W,K = map(int,input().split())
S = [list(str(input())) for _ in range(H)]

l = np.array([['0' for _ in range(W)]]*H)
l = l.tolist()
k= 1
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      l[i][j] = str(k)
      k += 1
for i in range(H):
  for j in range(W):
    if l[i][j] == '0':
      if i > 0:
        l[i][j] = l[i-1][j]
      else:
        for m in range(1,H-i):
          if l[i+m][j] != '0':
            l[i][j] = l[i+m][j]
            break
for i in range(H):
  for j in range(W):
    if l[i][j] == '0':
      if j > 0:
        l[i][j] = l[i][j-1]
      else:
        for m in range(1,W-j):
          if l[i][j+m] != '0':
            l[i][j] = l[i][j+m]
            break
  print(' '.join(l[i]))

Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W,K = map(int,input().split())
S = [list(str(input())) for _ in range(W)]

l = np.array([[0 for _ in range(W)]]*H)
l = l.tolist()
k= 1
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      l[i][j] = str(k)
      k += 1
for i in range(H):
  for j in range(W):
    if l[i][j] == 0:
      if j > 0:
        l[i][j] = l[i][j-1]
      else:
        for m in range(1,W-j):
          if l[i][j+m] != 0:
            l[i][j] = l[i][j+m]
            break
  print(' '.join(l[i]))

Fixed submission:
import numpy as np
H,W,K = map(int,input().split())
S = [list(str(input())) for _ in range(H)]

l = np.array([['0' for _ in range(W)]]*H)
l = l.tolist()
k= 1
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      l[i][j] = str(k)
      k += 1
for i in range(H):
  for j in range(W):
    if l[i][j] == '0':
      if i > 0:
        l[i][j] = l[i-1][j]
      else:
        for m in range(1,H-i):
          if l[i+m][j] != '0':
            l[i][j] = l[i+m][j]
            break
for i in range(H):
  for j in range(W):
    if l[i][j] == '0':
      if j > 0:
        l[i][j] = l[i][j-1]
      else:
        for m in range(1,W-j):
          if l[i][j+m] != '0':
            l[i][j] = l[i][j+m]
            break
  print(' '.join(l[i]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
dis = 0
for i in range(N-1):
  dis = ((x[0])**2+(y[0])**2)**0.5
  dis += ((x[i]-x[i+1])**2+(y[i]-y[i+1])**2)**0.5
print(dis/N)

Fixed submission:
N = int(input())
XY = [[0]*2]*N
dis = 0
for i in range(N):
  XY[i] = [int(_) for _ in input().split()]
for i in range(N):
  Xi = XY[i][0]
  Yi = XY[i][1]
  for j in range(N):
    Xj = XY[j][0]
    Yj = XY[j][1]
    dis += ((Xi-Xj)**2 + (Yi-Yj)**2)**0.5

print(dis/N)

Buggy python submission (verdict: Runtime Error):
N = int(input())
x,y = list(map(int,input().split()))
dis = 0
for i in range(N-1):
  dis = ((x[0])**2+(y[0])**2)**0.5
  dis += ((x[i]-x[i+1])**2+(y[i]-y[i+1])**2)**0.5
print(dis/N)

Fixed submission:
N = int(input())
XY = [[0]*2]*N
dis = 0
for i in range(N):
  XY[i] = [int(_) for _ in input().split()]
for i in range(N):
  Xi = XY[i][0]
  Yi = XY[i][1]
  for j in range(N):
    Xj = XY[j][0]
    Yj = XY[j][1]
    dis += ((Xi-Xj)**2 + (Yi-Yj)**2)**0.5

print(dis/N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dp = []
dp[0] = 0
i = 1
j = 1
for k in range(1,N):
  dp[k] = max(i+1*j,i*j+1)
  if max(i+1*j,i*j+1) == i+1*j:
    i += 1
  elif max(i+1*j,i*j+1) == i*j+1:
    j += 1
  if N == dp[k]:
    print(k)
    break


Fixed submission:
N = int(input())
count = 0
for i in range(int(N**0.5),0,-1):
  if N % i == 0:
    count = i + (N//i)
    break
print(count-2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[k] < L[j] + L[i]:
        count += 1
print(count)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
from bisect import bisect_left
ans = 0
for i in range(N):
  for j in range(i+1, N):
    sum = L[i]+L[j]
    count = bisect_left(L, sum)
    ans += max(0, count-j-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A_ = sorted(A)
for i in range(N):
  A_[i] = (str(A.index(A_[i])+1))
print(' '.join(A_))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = ['']*N
for id,name in enumerate(A):
  ans[name-1] = str(id+1)
print(' '.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A_ = sorted(A)
ans = ['']*N
for i in range(N):
  ans[i] = (str(A.index(A_[i])+1))
print(' '.join(ans))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = ['']*N
for id,name in enumerate(A):
  ans[name-1] = str(id+1)
print(' '.join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
A_ = sorted(A)
ans = []
for i in range(N):
  ans.append(str(A.index(A_[i])+1))
print(' '.join(ans))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = ['']*N
for id,name in enumerate(A):
  ans[name-1] = str(id+1)
print(' '.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
import math
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

l = cf(A,B)
ans = []
for i in range(len(l)):
  if is_prime(l[i]) == True:
    ans.append(l[i])

print(len(ans)+1)

Fixed submission:
import fractions
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

n = fractions.gcd(A,B)
print(len(set(prime_factorize(n)))+1)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
data = [K]*N
for q in range(Q):
  data = list(map(lambda x: x - 1, data))
  data[A[q]-1] += 1
for i in range(N):
  if data[i] > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
from collections import Counter
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
data = [K-Q]*N
C = Counter(A)
for i,j in C.items():
  data[i-1] += j
for i in range(N):
  if data[i] > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
dp = []
for _ in range(M):
  A[0] //= 2
  A = sorted(A,reverse = True)
print(sum(A))

Fixed submission:
from math import ceil
from heapq import heappop,heappush
from collections import deque
N,M = map(int,input().split())
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1), a))
A = []

for a_ in a:
    heappush(A,a_) 

for _ in range(M):
  maxA = ceil(heappop(A)/2)
  A.append(maxA)
  
ans = sum(A)*-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
ans = 0
for i in range(N):
  for j in range(i+1,N):
    if S[j+1:].count(S[i:j+1]) >= 1:
      ans = max(ans,len(S[i:j+1]))
print(ans)

Fixed submission:
N = int(input())
S = str(input())
ans = 0
j = 0
for i in range(N):
  while j < N and S[i:j] in S[j:]:
    ans = max(ans,j-i)
    j += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
ans = []
count = 0
for i in range(1,N):
  if H[i-1] < H[i]:
    ans.append(count)
    count = 0
  elif H[i-1] >= H[i]:
    count += 1
  if i == N-1:
    ans.append(count)

print(max(ans))

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
ans = []
count = 0
if len(H) == 1:
  print(0)
  exit()
for i in range(1,N):
  if H[i-1] < H[i]:
    ans.append(count)
    count = 0
  elif H[i-1] >= H[i]:
    count += 1
  if i == N-1:
    ans.append(count)

print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(N):
  ans += i
print(ans)

Fixed submission:
N = int(input())
ans = N*(N-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
K,X = map(int, input().split())
for i in range(X-K+1,X+K):
  if i <= X+K-1:
    print(i, end="")
  else
    print(i)

Fixed submission:
K,X = map(int, input().split())
for i in range(X-K+1,X+K):
  if i <= X+K-1:
    print(i, end=" ")
  else:
    print(i)

Buggy python submission (verdict: Runtime Error):
X = map(int, input().split())
for K in range(1,100):
  print(X - K)
for K in range(1,100):
  print(X + K)

Fixed submission:
K,X = map(int, input().split())
for i in range(X-K+1,X+K):
  if i <= X+K-1:
    print(i, end=" ")
  else:
    print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [input() for _ in range(N)]
check_box = []
ans = 0
for s in S:
  s = sorted(s)
  s = ''.join(s)
  print(s)
  print(check_box)
  if s in check_box:
    ans += 1
  else:
    check_box.append(s)
print(ans)


Fixed submission:
from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in Counter(S).values():
  count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in range(N):
  for j in range(i+1, N):
    if Counter(S[i]) == Counter(S[j]):
      count += 1
print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in Counter(S).values():
  count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = []
count = 0
for i in range(N):
  for j in range(i+1, N):
    if Counter(S[i]) == Counter(S[j]):
      count += 1
print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in Counter(S).values():
  count += i*(i-1)//2
print(count)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
S = list(map(str,input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    if Counter(S[i]) == Counter(S[j]):
      count += 1
    else:
      break
print(count)

Fixed submission:
from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in Counter(S).values():
  count += i*(i-1)//2
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
used = [0]*N
ans = [0]*(M+1)

for i in range(1,M+1):
  m = 10**9+1
  for j in range(N):
    if AB[j][0] <= i and used[j] == 0:
      ans[i] = max(ans[i], AB[j][1])
      if ans[i] == AB[j][1]:
        m = j
  if m != 10**9+1:
    used[m] = 1
  else:
    pass
print(sum(ans))

Fixed submission:
from heapq import *
N,M = map(int,input().split())
l = [[0] for _ in range(M+1)] 
for _ in range(N):
    a, b = map(int, input().split())
    if a<=M:
        l[a].append(b)

ans = 0
h = []

for i in range(1,M+1):
  for j in l[i]:
    heappush(h, -j)
  ans += heappop(h)
ans *= -1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if p[i] != p[j]:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")

Fixed submission:
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if i != j:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(str,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if p[i] != p[j]:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")

Fixed submission:
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
  if i != j:
    count += 1
if count == 0 or count == 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
S = str(input())
S = S.sort()
if S.count(S[0]) == 2 and S.count(S[2]) == 2:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
S = sorted(S)
if S.count(S[0]) == 2 and S.count(S[2]) == 2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())
count = 0
for i in range(A,B+1):
  if i%C != 0 and i%D != 0:
    count += 1
    i += 1
  else:
    i += 1
print(count)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())
all_count = B-A+1
c_count = B//C - (A-1)//C
d_count = B//D - (A-1)//D
cd_count = B//lcm(C,D) - (A-1)//lcm(C,D)
ans = all_count - c_count - d_count + cd_count
print(ans)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
C,D = map(int,input().split())
count = 0
for i in range(A,B+1):
  if i%C != 0 and i%D != 0:
    count += 1
    i += 1
  else:
    i += 1
    break
print(count)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())
all_count = B-A+1
c_count = B//C - (A-1)//C
d_count = B//D - (A-1)//D
cd_count = B//lcm(C,D) - (A-1)//lcm(C,D)
ans = all_count - c_count - d_count + cd_count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())
count = 0
for i in range(A,B+1):
  if i%C != 0 and i%D != 0:
    count += 1
    i += 1
  else:
    i += 1
print(count)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())
all_count = B-A+1
c_count = B//C - (A-1)//C
d_count = B//D - (A-1)//D
cd_count = B//lcm(C,D) - (A-1)//lcm(C,D)
ans = all_count - c_count - d_count + cd_count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D = map(int,input().split())
count = 0
for i in range(A,B+1):
  if i%C != 0 and i%D != 0:
    count += 1
print(count)

Fixed submission:
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

A,B,C,D = map(int,input().split())
all_count = B-A+1
c_count = B//C - (A-1)//C
d_count = B//D - (A-1)//D
cd_count = B//lcm(C,D) - (A-1)//lcm(C,D)
ans = all_count - c_count - d_count + cd_count
print(ans)