Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

x = int(input())
i, pos = 0, set([0])

while True:
    inner = False
    new_pos = set()
    for p in pos:
        if p + i == x or p - i == x:
            inner = True
            break
        new_pos.add(p)
        new_pos.add(p + i)
        new_pos.add(p - i)

    if inner:
        print(i)
        break

    pos = new_pos
    i += 1


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

x = int(input())


total = 0
for i in range(x + 1):
    total += i
    if total >= x:
        print(i)
        break
Buggy python submission (verdict: Runtime Error):
X = int(input())

a = int(X / 500)*1000 + int((X%500)/5)*5
print(a)


Fixed submission:
k, n = map(float, input().split())
m = list(map(float, input().split()))
half_k = k / 2
min = float(1000000)
for i in range(int(n)):
    first = m[i]
    last = m[i-1]
    len = last - first
    if len < 0:
        len = len + k
    if min > len:
        min = len
print(int(min))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for k in range(N):
  ans = 0
  for i in set(A):
    c = A.count(i)
    if A[k] == i:
      c -= 1
    ans += int(c*(c-1)/2)
  print(ans)

Fixed submission:
import sys
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
 
N = II()
A = LI()
 
from collections import Counter
S = Counter(A)
result = sum(list(map(lambda x: int(x*(x-1)/2), S.values())))
 
for a in A:
 n = S[a]
 print(result-n+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [input() for _ in range(n)]
max = 0
for s in list(set(S)):
  if max < S.count(s):
    max_words = [s]
    max = S.count(s)
  elif max == S.count(s):
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))


Fixed submission:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
c = Counter(S)
max = 0
for s in set(S):
  if max < c[s]:
    max_words = [s]
    max = c[s]
  elif max == c[s]:
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [input() for _ in range(n)]
max = 0
for s in set(S):
  if max < S.count(s):
    max_words = [s]
    max = S.count(s)
  elif max == S.count(s):
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))

Fixed submission:
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
c = Counter(S)
max = 0
for s in set(S):
  if max < c[s]:
    max_words = [s]
    max = c[s]
  elif max == c[s]:
    max_words.append(s)
max_words.sort()
print("\n".join(max_words))
Buggy python submission (verdict: Runtime Error):
import re
s = input()

print(re.sub("[a-z]", "x"))

Fixed submission:
import re
s = input()

print(re.sub("[a-z]", "x", s))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(e) for e in input().split()]

if length(set(A)) == length(A):
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
A = [int(e) for e in input().split()]

if len(set(A)) == len(A):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
red,blue=input().split()
a,b=(int(x) for x in input().split())
dic={red:a,blue:b}
u=input()
dic[u]-=1
print(dic[a]+" "+dic[b])



Fixed submission:
red,blue=input().split()
a,b=(int(x) for x in input().split())
dic={red:a,blue:b}
u=input()
dic[u]-=1
print(str(dic[red])+" "+str(dic[blue]))
Buggy python submission (verdict: Time Limit Exceeded):
def is_same(lst):
  n=len(lst)
  for i in range(n-1):
    for j in range(i+1,n):
      if(lst[i]==lst[j]):
        return True
  return False
    

n=int(input())
input_line=[int(x) for x in input().split()]
if(not is_same(input_line)):
  print("YES")
else:
  print("NO")

Fixed submission:
def is_neighbor_same(lst):
  for i in range(len(lst)-1):
    if(lst[i]==lst[i+1]):
      return True
  return False

input()
input_line=[int(x) for x in input().split()]
input_line.sort()
if(is_neighbor_same(input_line)):
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
  a,b,c=(int(x) for x in input().split())
  if(sum(a,b,c)>=22):
    print("bust")
  else:
    print("win")

Fixed submission:
if __name__ == '__main__':
  line=[int(x) for x in input().split()]
  if(sum(line)>=22):
    print("bust")
  else:
    print("win")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

if __name__ == '__main__':
    n=int(input())
    a_list=[int(x)-1 for x in input().split()]
    b_list=[int(x) for x in input().split()]
    c_list=[int(x) for x in input().split()]
    score=sum(b_list)
    pre_a=-100
    for a in a_list:
        if(a-pre_a==1):
            score+=c_list[pre_a]
        pre_a=a
    print(score)
  

Fixed submission:
if __name__ == '__main__':
    n=int(input())
    a=[]
    b=[int(x) for x in input().split()]
    a.append(b[0])
    for i in range(n-2):
        a.append(min([b[i],b[i+1]]))
    a.append(b[-1])
    print(sum(a))
Buggy python submission (verdict: Runtime Error):
from math import factorial

mod=1000000000+7

def C(n,k):
    N=(factorial(n))
    K=(factorial(k))
    N_K=(factorial(n - k))
    return int( ( N // K // N_K )%mod )

n,k=list(map(int, input().split()))
blue=k
red=n-k
for i in range(1,blue+1):
    print(C(red+1,i)*C(blue-1,i-1)%mod)

Fixed submission:
from math import factorial

mod=1000000000+7

def C(n,k):
    N=(factorial(n))
    K=(factorial(k))
    N_K=(factorial(n - k))
    return int( ( N // K // N_K )%mod )

n,k=list(map(int, input().split()))
blue=k
red=n-k
for i in range(1,blue+1):
    if i > red+1:
        print(0)
    else:
        print( (C(red+1,i)%mod)*(C(blue-1,i-1)%mod)%mod)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=list(map(int, input().split()))
lcm=int(c*d/math.gcd(c,d))
could_divide=(b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)
#print("could divide by "+str(c)+" : "+str(b//c-(a-1)//c))
#print("could divide by "+str(d)+" : "+str(b//d-(a-1)//d))
print(b-a+1-could_divide)

Fixed submission:
import fractions
a,b,c,d=list(map(int, input().split()))
lcm=int(c*d/fractions.gcd(c,d))
could_divide=(b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)
#print("could divide by "+str(c)+" : "+str(b//c-(a-1)//c))
#print("could divide by "+str(d)+" : "+str(b//d-(a-1)//d))
print(b-a+1-could_divide)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
length=int(input())
lst=list(map(int,input().split()))
per_diff=0
s1=0
for i in range(length):
  s1=sum(lst[0:i+1])
  s2=sum(lst[i+1:])
  if math.abs(s1-s2)>pre_diff:
    print(pre_diff)
    break

Fixed submission:
# -*- coding: utf-8 -*-
length=int(input())
lst=list(map(int,input().split()))
lst2=[]
for i in range(length):
    s1=sum(lst[0:i+1])
    s2=sum(lst[i+1:])
    lst2.append(abs(s1-s2))
print(min(lst2))
Buggy python submission (verdict: Runtime Error):
from math import gcd

A, B, C, D = map(int, input().split())
G = gcd(C, D)
L = C * D // G
ca = (A - 1) // C
cb = B // C
da = (A - 1) // D
db = B // D
la = (A - 1) // L
lb = B // L
div = cb + db - (ca + da) - (lb - la)
print(B - (A - 1) - div)


Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())
G = gcd(C, D)
L = C * D // G
ca = (A - 1) // C
cb = B // C
da = (A - 1) // D
db = B // D
la = (A - 1) // L
lb = B // L
div = cb + db - (ca + da) - (lb - la)
print(B - (A - 1) - div)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]
MOD = 10**9 + 7
ns = len(S)
nt = len(T)
dp = [[0] * (nt + 1) for i in range(ns + 1)]
for i in range(1, ns + 1):
    for j in range(1, nt + 1):
        if (S[i - 1] == T[j - 1]):
            dp[i][j] = 1 + dp[i][j - 1] + dp[i - 1][j]
        else:
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1]
print((dp[ns][nt] + 1) % MOD)

Fixed submission:
N, M = map(int, input().split())
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]
MOD = 10**9 + 7
ns = len(S)
nt = len(T)
dp = [[0] * (nt + 1) for i in range(ns + 1)]
for i in range(1, ns + 1):
    for j in range(1, nt + 1):
        if (S[i - 1] == T[j - 1]):
            dp[i][j] = (1 + dp[i][j - 1] + dp[i - 1][j]) % MOD
        else:
            dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1]) %            MOD
print((dp[ns][nt] + 1) % MOD)
Buggy python submission (verdict: Runtime Error):
class Node():
    def __init__(self, p, l, r, n):
        self.p = p
        self.l = l
        self.r = r
        self.n = n


N = int(input())
T = [Node(-1, -1, -1, -1) for _ in range(N)]
S = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    S.append([a - 1, b - 1])
S.sort()
C = sorted(map(int, input().split()), reverse=True)
for s in S:
    if T[s[0]].l == -1:
        T[s[0]].l = s[1]
        T[s[1]].p = s[0]
    else:
        T[l].r = s[1]
        T[s[1]].p = T[l].p
    l = s[1]


def rec(n, cur):
    if n == -1:
        return cur
    T[n].n = C[cur]
    cur += 1
    cur = rec(T[n].l, cur)
    cur = rec(T[n].r, cur)
    return cur


rec(0, 0)
print(sum(C[1:]))
print(' '.join(map(str, [t.n for t in T])))

# for i, t in enumerate(T):
#     print("node: {}, parent: {}, left-child: {}, right-sibling: {}, N: {}"
#           .format(i, t.p, t.l, t.r, t.n))


Fixed submission:
import sys

sys.setrecursionlimit(10000000)

N = int(input())
M = [[] for _ in range(N)]
P = [0] * N
V = [0] * N
for _ in range(N - 1):
    a, b = map(lambda x: int(x) - 1, input().split())
    M[a].append(b)
    M[b].append(a)
C = sorted(map(int, input().split()), reverse=True)

def dfs(n, cur):
    if V[n] == 1:
        return cur
    P[n] = C[cur]
    V[n] = 1
    cur += 1
    for c in M[n]:
        cur = dfs(c, cur)
    return cur

dfs(0, 0)
print(sum(C[1:]))
print(' '.join(map(str, P)))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = list(map(int, input().split()))
left = [0]
left_m = []
right = [0]
right_m = []
for i, l, r in zip(range(K), d, d[::-1]):
    left.append(left[i] + l)
    left_m.append(l if l < 0 else 0)
    right.append(right[i] + r)
    right_m.append(r if r < 0 else 0)
point = 0
for i in range(K):
    for j in range(K - i):
        p = K - i - j
        minus = list(sorted(left_m[:i] + right_m[:j]))
        point = max(point, left[i] + right[j] - sum(minus[:p]))
print(point)


Fixed submission:
a, p = map(int, input().split())
print((a * 3 + p) // 2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(M):
  C.append([int(i) for i in input().split()])
C.sort(key=lambda x: -x[1])
cur = 0
ans = 0
for a in A:
  if C[cur][0] == 0:
    cur += 1
  if cur == len(C):
    ans += a
    continue
  if a < C[cur][1]:
    ans += C[cur][1]
    C[cur][0] -= 1
  else:
    ans += a
print(ans)

Fixed submission:
N, M = map(int, input().split())
A = sorted(map(int, input().split()))
C = []
for _ in range(M):
  C.append([int(i) for i in input().split()])
C.sort(key=lambda x: -x[1])
cur = 0
ans = 0
for a in A:
  if cur != len(C) and C[cur][0] == 0:
    cur += 1
  if cur != len(C) and a < C[cur][1]:
    ans += C[cur][1]
    C[cur][0] -= 1
  else:
    ans += a
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
for k in range(1, int(math.sqrt(N)) + 1):
  if N % k == 0:
    m = int(N / k) - 1 
    ans += m if N % m == N // m else 0
print(ans)

Fixed submission:
import math

N = int(input())
ans = 0
for k in range(1, int(math.sqrt(N)) + 1):
  if N % k == 0:
    m = int(N / k) - 1
    if m == 0:
      continue
    ans += m if N % m == N // m else 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = []

for i in range(n + 1):
    b = s[0:i].count('#')
    w = s[i+1:n].count('.')
    ans.append(b + w)

print(min(ans))

Fixed submission:
n = int(input())
s = input()
b = [0] * (n + 1)
w = [0] * (n + 1)

for i in range(n):
    if s[i] == '#':
        b[i + 1] = b[i] + 1
    else:
        b[i + 1] = b[i]

for i in range(n - 1, -1, -1):
    if s[i] == '.':
        w[i] = w[i + 1] + 1
    else:
        w[i] = w[i + 1]

ans = [vb + vw for vb, vw in zip(b, w)]
print(min(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
st = input()
i = 0
b = 0
w = 0
ans = []
a = 0

for i in range(n + 1):
    for j, s in enumerate(st):
        if i <= j and s == '.':
            a += 1
        elif i > j and s == '#':
            a += 1

    ans.append(a)
    a = 0

print(min(ans))

Fixed submission:
n = int(input())
s = input()
b = [0] * (n + 1)
w = [0] * (n + 1)

for i in range(n):
    if s[i] == '#':
        b[i + 1] = b[i] + 1
    else:
        b[i + 1] = b[i]

for i in range(n - 1, -1, -1):
    if s[i] == '.':
        w[i] = w[i + 1] + 1
    else:
        w[i] = w[i + 1]

ans = [vb + vw for vb, vw in zip(b, w)]
print(min(ans))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
M = [[0], [0]]
start = int(S[0])
M[start].append(1)
prev = start
for s in S[1:]:
    if int(s) == prev:
        M[prev][-1] += 1
    else:
        prev = (prev + 1) % 2
        M[prev].append(M[prev][-1] + 1)
if len(M[0]) - 1 <= K:
    print(N)
else:
    ans = 0
    if start == 0:
        for i in range(len(M[1]) - K):
            ns = M[0][i + K] - M[0][i]
            hs = M[1][i + K] - M[1][i]
            ans = max(ans, ns + hs)
    else:
        for i in range(len(M[0]) - K):
            ns = M[0][i + K] - M[0][i]
            hs = M[1][i + K + 1] - M[1][i]
            ans = max(ans, ns + hs)
    print(ans)

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

left = 0
right = 0
op = 0
prev = '1'
ans = 0
while right < N:
    while right < N:
        if prev == '1' and S[right] == '0':
            op += 1
            if op > K:
                break
        prev = S[right]
        right += 1
    ans = max(ans, right - left)
    prev = S[left]
    while left < right:
        if prev == '0' and S[left] == '1':
            break
        prev = S[left]
        left += 1
    op -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

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

heap = []
heapq.heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
added = set([(0, 0, 0)])
for _ in range(K):
    p, i, j, k = heapq.heappop(heap)
    if (i + 1, j, k) not in added and i + 1 < X:
        heapq.heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
        added.add((i + 1, j, k))
    if (i, j + 1, k) not in added and j + 1 < Y:
        heapq.heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
        added.add((i, j + 1, k))
    if (i, j, k + 1) not in added and k + 1 < Z:
        heapq.heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
        added.add((i, j, k + 1))
    print(-p)

Fixed submission:
atn = [int(input()) for i in range(5)]
k = int(input())
b = 1
for i in range(4):
    for j in range(4 - i):
        if abs(atn[i] - atn[i + j + 1]) > k:
            b = 0

if b:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
foods = [int(input()) for i in range(5)]
time = 0
rest = list(map(lambda x: x % 10, foods))
for i in range(5):
    if rest[i] == 0:
        time += foods[i]
    else:
        time += foods[i] - rest[i] + 10

print(time - 10 + min([i for i in rest if i != 0]))

Fixed submission:
foods = [int(input()) for i in range(5)]
time = 0
rest = list(map(lambda x: x % 10, foods))
for i in range(5):
    if rest[i] == 0:
        time += foods[i]
    else:
        time += foods[i] - rest[i] + 10

if any(rest):
    print(time - 10 + min([i for i in rest if i != 0]))
else:
    print(time)
Buggy python submission (verdict: Runtime Error):
import heapq

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

heap = []
heapq.heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))
for _ in range(K):
    p, i, j, k = heapq.heappop(heap)
    heapq.heappush(heap, (-(A[i + 1] + B[j] + C[k]), i + 1, j, k))
    heapq.heappush(heap, (-(A[i] + B[j + 1] + C[k]), i, j + 1, k))
    heapq.heappush(heap, (-(A[i] + B[j] + C[k + 1]), i, j, k + 1))
    print(-p)

Fixed submission:
from itertools import product

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

AB = sorted([a + b for a, b in product(A, B)], reverse=True)
ABC = sorted([ab + c for ab, c in product(AB[:max(K, Z)],
                                          sorted(C, reverse=True))],
             reverse=True)
for s in ABC[:K]:
    print(s)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, inp().split())
s = inp()
a = []

for i in range(n - 1):
    if s[i:i+2] == 'AC':
        a.append(1)
    else:
        a.append(0)

for _ in range(q):
    l, r = map(int, inp().split())
    print(sum(a[l-1:r-1]))

Fixed submission:
b = input()
d = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
print(d[b])
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
tmp = 0
acgt = ['A', 'C', 'G', 'T']
while s:
  if s.pop(0) in acgt:
    tmp += 1
  else:
    ans = max([ans, tmp])
    tmp = 0

ans = max([ans, tmp])
print(ans)

Fixed submission:
s = [i for i in input()]
ans = 0
tmp = 0
acgt = ['A', 'C', 'G', 'T']
while s:
  if s.pop(0) in acgt:
    tmp += 1
  else:
    ans = max([ans, tmp])
    tmp = 0

ans = max([ans, tmp])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = []

for i in range(n - 1):
    if s[i:i+2] == 'AC':
        a.append(1)
    else:
        a.append(0)

for _ in range(q):
    l, r = map(int, inp().split())
    print(sum(a[l-1:r-1]))

Fixed submission:
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
a = [0] * (n - 1)

for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        a[i] = 1

for _ in range(q):
    l, r = map(int, input().split())
    print(sum(a[l-1:r-1]))

Fixed submission:
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
a = [0] * (n - 1)

for i in range(n - 1):
    if s[i] == 'A' and s[i + 1] == 'C':
        a[i] = 1

for _ in range(q):
    l, r = map(int, input().split())
    print(sum(a[l-1:r-1]))

Fixed submission:
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()

for _ in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count('AC'))

Fixed submission:
import sys


def inp():
    return sys.stdin.readline().strip()


n, q = map(int, inp().split())
s = inp()
a = [0] * n

for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]

for _ in range(q):
    l, r = map(int, inp().split())
    print(a[r-1] - a[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

ans = 0
while m > 0:
    mina = min(a)
    idx = a.index(mina)
    bn = b[idx]
    if m < bn:
        ans += mina * m
        m = 0
    else:
        ans += mina * bn
        m -= bn
    a.pop(idx)
    b.pop(idx)

print(ans)

Fixed submission:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x: x[0])
ans = 0
for i in a:
    if i[1] > m:
        ans += i[0] * m
        break
    else:
        ans += i[0] * i[1]
        m -= i[1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

ans = 0
while m > 0:
    mina = min(a)
    idx = a.index(mina)
    bn = b[idx]
    if m < bn:
        ans += mina * m
        m = 0
    else:
        ans += mina * bn
        m -= bn
    a.pop(idx)
    b.pop(idx)

print(ans)

Fixed submission:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x: x[0])
ans = 0
for i in a:
    if i[1] > m:
        ans += i[0] * m
        break
    else:
        ans += i[0] * i[1]
        m -= i[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
print('YES' if (int(input()) + 1) // 2 > int(input()) else 'NO')

Fixed submission:
n, k = [int(x) for x in input().split()]
if n % 2 == 1:
    ans = 'YES' if (n + 1) / 2 >= k else 'NO'
else :
    ans = 'YES' if n / 2 >= k else 'NO'

print(ans)

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

a1, b1 = [int(x) for x in input().split()]
a2, b2 = [int(x) for x in input().split()]
a3, b3 = [int(x) for x in input().split()]

l = [a1, b1, a2, b2, a3, b3]
col = list(collections.Counter(l).values())
if col.count(1) == 2 & col.count(2) == 2:
    print('YES')
else:
    print('NO')

Fixed submission:
n, k = [int(x) for x in input().split()]
if n % 2 == 1:
    ans = 'YES' if (n + 1) / 2 >= k else 'NO'
else :
    ans = 'YES' if n / 2 >= k else 'NO'

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))
if N >= M:
  print('0')
else:
  d = []
  for i in range(M - 1):
    d.append(X[i + 1] - X[i])
  for j in range(N - 1):
    d.remove(max(d))
  print(sum(d))

Fixed submission:
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))
if N >= M:
  print('0')
else:
  d = []
  ans = X[-1] - X[0]
  for i in range(M - 1):
    d.append(X[i + 1] - X[i])
  ans -= sum(list(sorted(d, reverse=True))[0:N - 1])
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))
if N >= M:
  print('0')
else:
  d = []
  for i in range(M - 1):
    d.append(X[i + 1] - X[i])
  for j in range(N - 1):
    d.remove(max(d))
  print(sum(d))

Fixed submission:
N, M = map(int, input().split())
X = list(sorted(map(int, input().split())))
if N >= M:
  print('0')
else:
  d = []
  ans = X[-1] - X[0]
  for i in range(M - 1):
    d.append(X[i + 1] - X[i])
  ans -= sum(list(sorted(d, reverse=True))[0:N - 1])
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in s:
    ret += dfs(s + c)
  return ret

print(dfs('0'))

Fixed submission:
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0'))
Buggy python submission (verdict: Runtime Error):
a, b, c = sorted(map(int, input()))
print(a + b + c * 10)

Fixed submission:
a, b, c = sorted(map(int, input().split()))
print(a + b + c * 10)