Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
alis = list(map(int,input().split()))

value = 1
for i in range(k):
    value = value * alis[i]

vlis = [value]

for i in range(k,n):
    vlis.append(vlis[i-k]*alis[i]/alis[i-k])

for i in range(1,n-k+1):
    if vlis[i] > vlis[i-1]:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k = map(int,input().split())
alis = list(map(int,input().split()))

for i in range(n-k):
    if(alis[i]<alis[i+k]):
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
alis = list(map(int,input().split()))

value = 1
for i in range(k):
    value = value * alis[i]

for i in range(k,n):
    if(value < value*alis[i]/alis[i-k]):
        print('Yes')
    else:
        print('No')


Fixed submission:
n,k = map(int,input().split())
alis = list(map(int,input().split()))

for i in range(n-k):
    if(alis[i]<alis[i+k]):
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = list(map(int,input().split()))
a = 1
for i in range(n):
    a = a*lis[i]

if a > 10**18:
    print("-1")
else:
    print(a)

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
a = 1
i = 0
while a<= 10**18 and i <=n-1:
    a = a*lis[i]
    i = i + 1

if 0 in lis:
    print(0)
elif a > 10**18:
    print("-1")
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))

Fixed submission:
a,b = map(str,input().split())
a = int(a)
b = float(b)
 
b = round(b*100)
 
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
a,b = map(flaot,input().split())
print(math.floor(a*(100*b)/100))

Fixed submission:
a,b = map(str,input().split())
a = int(a)
b = float(b)
 
b = round(b*100)
 
print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = list(map(int,input().split()))
 
distance_list =[]
 
for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list.append(min(a,b))
count_list = []
 
for i in range(n-1):
    count_list.append(distance_list.count(i+1))
    
for i in range(n-1):
    print(count_list[i])

Fixed submission:
n,x,y = map(int,input().split())

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])

Buggy python submission (verdict: Runtime Error):
n,x,y = list(map(int,input().split()))

distance_list =[]

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list.append(min(a,b)

count_list = []

for i in range(n-1):
    count_list.append(distance_list.count(i+1))

for i in range(n-1):
    print(count_list[i])

Fixed submission:
n,x,y = map(int,input().split())

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = list(map(int,input().split()))

distance_list =[]

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        if a <= b:
            distance_list.append(a)
        else:
            distance_list.append(b)

count_list = []

for i in range(n-1):
    count_list.append(distance_list.count(i+1))

for i in range(n-1):
    print(count_list[i])

Fixed submission:
n,x,y = map(int,input().split())

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = list(map(int,input().split()))

distance_list =[]


for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        if a <= b:
            distance_list.append(a)
        else:
            distance_list.append(b)

count_list = []

for i in range(n-1):
    count_list.append(distance_list.count(i+1))

for i in range(n-1):
    print(count_list[i])

Fixed submission:
n,x,y = map(int,input().split())

distance_list =[0]*n

for i in range(1,n):
    for j in range(i+1,n+1):
        a = j - i
        b = abs(i - x) + abs(j-y) + 1
        distance_list[min(a,b)] += 1

for i in range(1,n):
    print(distance_list[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
num_lis = list(input().split())
max = 0
c = 0
for i in range(n):
    num_lis[i] = int(num_lis[i])
for i in range(n-k+1):
    for j in range(k):
        c = c + num_lis[i+j]/2 + 1/2
    if c > max:
        max = c
        c = 0
    else:
        c = 0
print(max)

Fixed submission:
n,k = map(int,input().split())
num_lis = list(input().split())
max = 0
c = 0
for i in range(n):
    num_lis[i] = int(num_lis[i])
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            c = c + num_lis[i+j]/2 + 1/2
        max = c
    else:
        c = c - num_lis[i-1]/2 + num_lis[i+k-1]/2
        if c > max:
            max = c
print(max)
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
if a >= b:
  a = str(a)a
  print(a*b)
else:
  b = str(b)
  print(b*a)

Fixed submission:
a, b = map(int,input().split())
if b >= a:
  a = str(a)
  print(a*b)
else:
  b = str(b)
  print(b*a)
Buggy python submission (verdict: Time Limit Exceeded):
l = int(input())
order = list(input().split())
for i in range(l):
    order[i] = int(order[i])

a = 0
c = 0
for i in range(l):
    for j in range(i+1):
        if order[j] >= order[i]:
            c = c + 1
        if c - 1  == i:
            a = a + 1
        if j  == i:
            c  = 0
print(a)

Fixed submission:
l  = int(input())
order = list(input().split())
for i in range(l):
    order[i] = int(order[i])


min  = order[0]
a = 0

for i in range(l):
    if order[i] <= min:
        a = a + 1
        min  = order[i]
print(a)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
lis = range(1,n+!)
#permulations(l,n)でリストlの要素のうちn個を選んで並べる
a = list(itertools.permulations(lis))

#abs絶対値
print(abs(a.index(p) - a.index(q)))

Fixed submission:
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
lis = range(1, n+1)

#permulations(l,n)でリストlの要素のうちn個を選んで並べる
a = list(itertools.permutations(lis))

print(abs(a.index(p) - a.index(q)))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while b != 0:
        a = b
        b = b % a
    return a
#最小公約数
def lcm(a,b):
    return a*b / gcd(a,b)

print(lem(a,b))



Fixed submission:
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
c = a*b
d = 1
ans  = 0
while d%a != 0 or d%b != 0:
    for i in range(2,c+1):
        if b%c != 0:
            b = b*i
        
print(d)

Fixed submission:
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
c = a*b
d = 1
ans  = 0
while d%a != 0 or d%b != 0:
    for i in range(1,c+1):
        if b%c != 0:
            d = d+1
        
print(d)

Fixed submission:
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b = map(int,input().split())
c = a*b
d = 1
ans  = 0
while d%a != 0 or d%b != 0:
    for i in range(1,c+1):
        if d%a != 0 or d%b != 0:
            d = d+1
        
print(d)

Fixed submission:
a,b = map(int,input().split())
#最大公約数
def gcd(a,b):#a<=b
    while a != 0:
        a,b = b%a,a
    return b
#最小公約数
def lcm(a,b):
    return a*b // gcd(a,b)
print(lcm(a,b))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1:
  print(odd)
else:
  print(even)

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1:
    print(odd)
print(even)

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if (a*b)%2 = 1
    print(odd)
print(even)

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a*b%2 = 1
    print(odd)
print(even)

Fixed submission:
a,b = map(int,input().split())
if (a*b)%2 == 1:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
T = int(intput())

def solve(N, A, B, C, D):
  def pay(x, coin=0):
    if x == 0:
      return 0
    out1 = x/2 if x%2==0 else float('inf')
    out2 = x/3 if x%3==0 else float('inf')
    out3 = x/5 if x%5==0 else float('inf')
    out4 = x+1 if x%8==0 else float('inf')
    out5 = x-1 if x%8==0 else float('inf')
    return min(pay(out1, coin+A), pay(out2, coin+B), pay(out3, coin+C), pay(out4, coin+D), pay(out5, coin+D))
  return pay(N)

for _ in range(T):
  N, A, B, C, D = map(int, input().split())
  print(solve(N, A, B, C, D))

Fixed submission:
T = int(input())
for _ in range(T):
  N,a,b,c,d = map(int, input().split())
  
  memo = {}
  def solve(n):
    if n == 0:
      return 0
    if n == 1:
      return d
    if n in memo:
      return memo[n]
    tmp = n * d
    if n % 2 == 0:
      tmp = min(tmp, a + solve(n//2))
    else:
      tmp =  min(tmp, a + d + solve(n//2), a + d + solve(n//2+1))
    if n % 3 == 0:
      tmp = min(tmp, b + solve(n//3))
    else:
      ret1 = n % 3
      ret2 = 3 - ret1
      tmp = min(tmp, b + d*ret1 + solve(n//3), b + d*ret2 + solve(n//3+1))
    if n % 5 == 0:
      tmp = min(tmp, c + solve(n//5))
    else:
      ret1 = n % 5
      ret2 = 5 - ret1
      tmp = min(tmp, c + d*ret1 + solve(n//5), c + d*ret2 + solve(n//5+1))
    memo[n] = tmp
    return memo[n]
    
  print(solve(N))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = [c for c in input()]
subs = [[] for _ in range(K)]

def max_sub(sub):
  total_point = 0
  previous = None
  for enemy_hand in sub:
    if previous == None:
      my_hand, point = battle(enemy_hand)
      total_point += point
      previous = my_hand
    else:
      my_hand, point = battle(enemy_hand)
      if my_hand == previous:
        previous = None
      else:
        total_point += point
        previous = my_hand
  return total_point

def battle(enemy_hand):
  if enemy_hand == "r":
    return "p", P
  elif enemy_hand == "s":
    return "r", R
  elif enemy_hand == "p":
    return "s", S
  else:
    raise ValueError("HAND IS WRONG")
    

for n in range(N):
  for k in range(K):
    if n % K == k:
      subs[k].append(T[n])

total_point = 0
for sub in subs:
  total_point += max_sub(sub)
  
      
print(total_point)

Fixed submission:
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = [c for c in input()]

hand_points = {"p": P, "r": R, "s": S}

def win(enemy_hand):
  if enemy_hand == "r":
    return "p", P
  elif enemy_hand == "s":
    return "r", R
  elif enemy_hand == "p":
    return "s", S
  else:
    raise ValueError("HAND IS WRONG")

total_point = 0
my_hands = []
for enemy_hand in T:
  my_hand, point = win(enemy_hand)
  total_point += point
  my_hands.append(my_hand)

for i in range(K, N):
  my_hand = my_hands[i]
  if my_hand == my_hands[i-K]:
    total_point -= hand_points[my_hand]
    my_hands[i] = "any"

print(total_point)
Buggy python submission (verdict: Time Limit Exceeded):
char_num = int(input())
char_length = 10
chars = []
for i in range(char_num):
    chars.append(input())


class CharArrange:
    def __init__(self, char):
        self.char = char

    def char_run(self):
        list_char = self.str2ord_list(self.char)
        for pos in range(1, len(list_char)):
            self.insert_sort(list_char, pos, list_char[pos])
        self.char = self.ordList2Str(list_char)

    def order_run(self, chars):
        for i, char in enumerate(chars):
            chars[i] = self.ord_list2ord_concat(self.str2ord_list(char))
        for pos in range(len(chars)):
            self.insert_sort(chars, pos, chars[pos])
        self.ord_chars = chars

    def str2ord_list(self, char):
        return list(map(ord, char))

    def ordList2Str(self, ordList):
        return ''.join(list(map(chr, ordList)))

    def ord_list2ord_concat(self, ord_list):
        self.ord_concat = ''
        for ord_num in ord_list:
            self.ord_concat += str(ord_num)
        return int(self.ord_concat)

    def insert_sort(self, A, pos, value):
        i = pos - 1
        while (i >= 0 and A[i] > value):
            A[i+1] = A[i]
            i = i - 1
        A[i+1] = value
        return A


for i, char in enumerate(chars):
    CA = CharArrange(char)
    CA.char_run()
    chars[i] = CA.char
CA.order_run(chars)
ord_chars = CA.ord_chars

counter = 0
for i in range(len(ord_chars) - 1):
    k = i + 1
    while (ord_chars[i] == ord_chars[k]):
        counter += 1
        if k == len(ord_chars) - 1:
            break
        else:
            k += 1
print(counter)


Fixed submission:
char_num = int(input())
char_length = 10
chars = []
for i in range(char_num):
    chars.append(input())


class CharArrange:
    def __init__(self, char):
        self.char = char

    def char_run(self):
        list_char = self.str2ord_list(self.char)
        for pos in range(1, len(list_char)):
            self.insert_sort(list_char, pos, list_char[pos])
        self.char = self.ordList2Str(list_char)

    def order_run(self, chars):
        for i, char in enumerate(chars):
            chars[i] = self.ord_list2ord_concat(self.str2ord_list(char))
        for pos in range(len(chars)):
            self.insert_sort(chars, pos, chars[pos])
        self.ord_chars = chars

    def str2ord_list(self, char):
        return list(map(ord, char))

    def ordList2Str(self, ordList):
        return ''.join(list(map(chr, ordList)))

    def ord_list2ord_concat(self, ord_list):
        self.ord_concat = ''
        for ord_num in ord_list:
            self.ord_concat += str(ord_num)
        return int(self.ord_concat)

    def insert_sort(self, A, pos, value):
        i = pos - 1
        while (i >= 0 and A[i] > value):
            A[i+1] = A[i]
            i = i - 1
        A[i+1] = value
        return A


counter = 0
hash_table = {}
for i, char in enumerate(chars):
    CA = CharArrange(char)
    CA.char_run()
    if CA.char in hash_table:
        hash_table[CA.char] += 1
    else:
        hash_table[CA.char] = 0
    counter += hash_table[CA.char]


print(counter)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
rest: int = C - (A - B)
result: int = (rest if rest >= 0 else 0)
print(result)


Fixed submission:
A, B, C = map(int, input().split())
rest = C - (A - B)
result = (rest if rest >= 0 else 0)
print(result)
Buggy python submission (verdict: Runtime Error):
from typing import List

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

for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        print('No')
        break
    if i == 1:
        print('Yes')


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

exit_flag = False
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')

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

H_reversed = list(reversed(H))
for i in range(N):
    if H_reversed[i+1] - H_reversed[i] == 1:
        H_reversed[i+1] -= 1
    elif H_reversed[i+1] - H_reversed[i] > 1:
        print('No')
        break
print('Yes')


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

exit_flag = False
for i in range(N-1, 0, -1):
    if H[i-1] - H[i] == 1:
        H[i-1] -= 1
    elif H[i-1] - H[i] > 1:
        exit_flag = True
        print('No')
        break

if not exit_flag:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = A.copy()
for i in range(N):
    if C[i] - B[i] > 0:
        C[i] -= B[i]
    else:
        C[i+1] = C[i+1] - (B[i] - C[i]) if C[i+1] - (B[i] - C[i]) > 0 else 0
        C[i] = 0
    # print(C)

beaten_monster: int = sum(A) - sum(C)
print(beaten_monster)


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

C = A.copy()
for i in range(N):
    if C[i] - B[i] > 0:
        C[i] -= B[i]
    else:
        C[i+1] = C[i+1] - (B[i] - C[i]) if C[i+1] - (B[i] - C[i]) > 0 else 0
        C[i] = 0
    # print(C)

beaten_monster = sum(A) - sum(C)
print(beaten_monster)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
intS = int(S)

calc_list = [1 if S[0] == '0' else 0]
for i in range(1, len(S)):
    if S[i] == '0':
        if S[i-1] == '1':
            calc_list.append(1)
        elif S[i-1] == '0':
            calc_list.append(calc_list[i-1] + 1)
    else:
        calc_list.append(0)

print(calc_list)

def zeros(calc_list):
    zero_list = [1 if calc_list[0] == 0 else 0]
    for i in range(1, len(calc_list)):
        if calc_list[i] == 0:
            zero_list.append(zero_list[i-1] + 1)
        else:
            zero_list.append(0)

    return zero_list


max_times = max(calc_list)
for _ in range(K):
    for i in range(len(calc_list)):
        if calc_list.count(max_times) == 1:
            if calc_list[i] == max_times:
                for j in range(max_times):
                    calc_list[i-j] = 0
                break
        else:
            zero_list = zeros(calc_list))
            index = zero_list.index(max(zero_list))

    print('calc', calc_list)
    print('zeros', zeros(calc_list))
    max_times = max(calc_list)


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

# 累積和で実装

now = 1
cnt = 0
nums = []
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
nums.append(cnt)
if int(S[-1]) == 0:
    nums.append(0)

# print(nums)

cumulative_sum = []
M = len(nums)
sum = 0
for i in range(M):
    sum += nums[i]
    cumulative_sum.append(sum)

# print(cumulative_sum)

ans = 0
start = 0
final = 2 * K
answers = []

# M = len(nums) = len(cumulative_sum)
if M < 2 * K + 1:
    print(len(S))
    exit()
if final <= M-1:
    while(final <= M-1):
        if start == 0:
            answers.append(cumulative_sum[final])
        else:
            ans = cumulative_sum[final] - cumulative_sum[start-1]
            answers.append(ans)

        # print(start, final, ans)
        start += 2
        final += 2
    print(max(answers))
else:
    print(cumulative_sum[0])

# print(answers)
Buggy python submission (verdict: Runtime Error):
b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A":
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)

Fixed submission:
b = input()
if b == "A":
  pair = "T"
elif b == "T":
  pair = "A"
elif b == "C":
  pair = "G"
else:
  pair = "C"
print(pair)
Buggy python submission (verdict: Runtime Error):
words = list(input())
binary_list = []
for word in words:
  if word == "A" or word == "T" or word == "C" or word == "G":
      binary_list.append(1)
  else:
      binary_list.append(0)
counter = 0
multi = 1
max_counter = 0
for first in range(len(binary_list)):
    if binary_list[first] == 1:
        while(multi):
            multi *= binary_list[first]
            if multi == 0:
                break
            first += 1
            counter += 1
            if counter >= max_counter:
                max_counter = counter
print(max_counter)


Fixed submission:
words = list(input())
binary_list = []
for word in words:
  if word == "A" or word == "T" or word == "C" or word == "G":
      binary_list.append(1)
  else:
      binary_list.append(0)
max_counter = 0
for first in range(len(binary_list)):
    counter = 0
    multi = 1
    if binary_list[first] == 1:
        while(multi):
            multi *= binary_list[first]
            if multi == 0:
                break
            counter += 1
            if counter >= max_counter:
                max_counter = counter
            if first == len(binary_list) - 1:
                break
            else:
                first += 1
print(max_counter)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
AB = []
for i in range(N):
    Ai, Bi = map(int, input().split())
    AB.append([Ai, Bi])

# # Bubble Sort
# start = 0
# for i in range(N-1):
#     for index in range(start, N-1):
#         if AB[index][0] > AB[index+1][0]:
#             AB[index], AB[index+1] = AB[index+1], AB[index]
#         else:
#             pass
#         start += 1

AB = sorted(AB, key=lambda x: x[0])

final = 0
sum_bottles = 0
while(M > sum_bottles):
    final += 1
    sum_bottles = 0
    for i in range(final):
        sum_bottles += AB[i][1]

cost = 0
sum_bottles = 0
for i in range(final):
    if i == final - 1:
        cost += AB[i][0] * (M - sum_bottles)
    else:
        cost += AB[i][0] * AB[i][1]
        sum_bottles += AB[i][1]

print(cost)


Fixed submission:
N, M = map(int, input().split())
AB = []
for i in range(N):
    Ai, Bi = map(int, input().split())
    AB.append([Ai, Bi])

# # Bubble Sort
# start = 0
# for i in range(N-1):
#     for index in range(start, N-1):
#         if AB[index][0] > AB[index+1][0]:
#             AB[index], AB[index+1] = AB[index+1], AB[index]
#         else:
#             pass
#         start += 1

AB = sorted(AB, key=lambda x: x[0])

final = 0
sum_bottles = 0
while(M > sum_bottles):
    final += 1
    sum_bottles += AB[final-1][1]

cost = 0
sum_bottles = 0
for i in range(final):
    if i == final - 1:
        cost += AB[i][0] * (M - sum_bottles)
    else:
        cost += AB[i][0] * AB[i][1]
        sum_bottles += AB[i][1]

print(cost)
Buggy python submission (verdict: Runtime Error):
S = list(input())
N = len(S)

counter = 0
i = 0
while(True):
    if not '0' in S or not '1' in S or S == []:
        break
    elif (S[i] == '1' and S[i+1] == '0') or (S[i] == '0' and S[i+1] == '1'):
        S.pop(i)
        S.pop(i)
        counter += 2
        i -= 1
    else:
        i += 1

print(counter)


Fixed submission:
S = input()
N = len(S)

count0 = S.count('0')
count1 = S.count('1')
ans = 2 * min(count0, count1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)

counter = 0
i = 0
while(True):
    if not '0' in S or not '1' in S or S == '':
        break
    if S[i:i+2] == '01' or S[i:i+2] == '10':
        S_list = list(S)
        S_list.pop(i)
        S_list.pop(i)
        S_str = ''
        for j in S_list:
            S_str += j
        S = S_str
        counter += 2
        i -= 1
    else:
        i += 1

print(counter)


Fixed submission:
S = input()
N = len(S)

count0 = S.count('0')
count1 = S.count('1')
ans = 2 * min(count0, count1)
print(ans)
Buggy python submission (verdict: Runtime Error):
date = input()

date = date.replace('/', '')
if date <= 20190430:
    print("Heisei")
else:
    print("TBD")


Fixed submission:
date = input()

date = int(date.replace('/', ''))
if date <= 20190430:
    print("Heisei")
else:
    print("TBD")