Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入力
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる
b = sorted(b)  # 大きい順に並べる b = b[::-1]  # リストの要素の順番を逆転する
c = b[::2]  # Aliceのとる要素を抽出
c_number = len(c)
d = b[1::2]  # Bobのとる要素を抽出
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計
for g in range(d_number):
    d_sum += d[g]  # Bobのとる要素の合計
print(c_sum - d_sum)  # 差分を出力


Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入
b = map(int, b.split())
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)

Buggy python submission (verdict: Runtime Error):
-*- coding: utf-8 -*- 
a = int(input())  # Nを入力 
b = input()  # a1,a2...anを入力 
b = map(int, b.split())  # a1,a2...anをint型でリストに入れる 
b = sorted(b)  # 大きい順に並べる b = b[::-1]  # リストの要素の順番を逆転する 
c = b[::2]  # Aliceのとる要素を抽出 
c_number = len(c) 
d = b[1::2]  # Bobのとる要素を抽出 
d_number = len(d) 
c_sum = 0 
d_sum = 0 
for i in range(c_number):
    c_sum += c[i] # Aliceのとる要素の合計  
for g in range(d_number):
　　d_sum += d[g]  # Bobのとる要素の合計  
print(c_sum - d_sum)  # 差分を出力


Fixed submission:
# -*- coding: utf-8 -*-
a = int(input())  # Nを入力
b = input()  # a1,a2...anを入
b = map(int, b.split())
b = sorted(b)
b = b[::-1]
c = b[::2]
c_number = len(c)
d = b[1::2]
d_number = len(d)
c_sum = 0
d_sum = 0
for i in range(c_number):
    c_sum += c[i]

for g in range(d_number):
    d_sum += d[g]

print(c_sum - d_sum)
Buggy python submission (verdict: Runtime Error):
a = int(input()) 
b = int(input()) 
c = int(input()) 
x = int(input()) 
z = 0 number = 0 
for i in range(a+1):
     for g in range(b+1):
         for h in range(c+1):
             z = 500*i + 100*g + 50*h
             if x == z:
                 number += 1  
print(number)  


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)

Buggy python submission (verdict: Runtime Error):
a = int(input()) 
b = int(input()) 
c = int(input()) 
x = int(input()) 
z = 0 number = 0 
for i in range(a+1):
     for g in range(b+1):
         for h in range(c+1):
             z = 500*i + 100*g + 50*h
             if x == z:
                 number += 1  
print(number)  


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)
                

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)
                

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
z = 0
number = 0
for i in range(a+1):
    for g in range(b+1):
        for h in range(c+1):
            z = 500*i + 100*g + 50*h
            if x == z:
                number += 1

print(number)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())  
c = a * b 
if c % 2 == 0:     
    print("Even") 
else:     
    print("Odd")


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

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = a * b
if c % 2 == 0:
    print("Even")
else:
    print("Odd")

Fixed submission:
a,b = map(int,input().split())
c = a * b
if c % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
b = []
for i in range(a):
    b.append(input())

c = [0] * (100+1)
for i in b:
    c[i] = i

d = []
for g in c:
    if g != 0:
        d.append(g)

print(len(d))




Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(input())
c = set(b)
print(len(c))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
for i in range(a):
    b.append(input())

c = [0] * (100)
for i in b:
    c[i] = i

d = []
for g in c:
    if g != 0:
        d.append(g)

print(len(d))



Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(input())
c = set(b)
print(len(c))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = []
for i in range(a):
    b.append(input())

c = [0] * (100)
for i in b:
    c[i] = i

print(c)

d = []
for g in c:
    if g != 0:
        d.append(g)

print(len(d))



Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(input())
c = set(b)
print(len(c))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
test = input()
a, b, c = map(int, test.split())  # 変数a,b,cにそれぞれN、A、Bをint型にして入力する　
x = []
for i in range(1,a+1):  # list型の変数xに１からNまでの要素を入れる
    x.append(i)


len_x = len(x)  # リスト型の変数xの要素数を獲得

d = 0  # リストの各行の和を入れるための変数
f = []  # 各行の和がA以上B以下の要素を入れるための変数
x = map(str, x)  # リストxの書く要素をstr型に変換

for i in range(len_x):
    e = x[i]           # xのi番目の要素を抽出
    e = list(e)  # xのi番目の要素を一文字ずつのstr型としてリスト型の変数に入れる
    e = map(int, e)  # xのi番目の要素をint型に変換
    e_number = len(e)  # リスト型の変数eの要素数を取得
    d = 0              # 位の合計の判定用の変数
    for g in range(e_number):
        d += e[g]  # 位の合計
    if b <= d <= c:  # 位の合計がA以上B以下ならリストfに要素を追加
        f.append(x[i])
answer = 0  # 条件位合う要素の合計を入れる変数
f = map(int, f)
for h in f:  # 要素に合う要素の合計
    answer += h
print(answer)




Fixed submission:
a = int(input())
b = []
for i in range(a):
    b.append(input())
c = set(b)
print(len(c))
Buggy python submission (verdict: Runtime Error):
    x = input()
    a = list(x)
    a  = [int(s) for s in x]
    b = 0
    for i in range(3):
        if a[i] == 1:
          b += 1
          
          
          
    print(b)
          

Fixed submission:
x = input()
a = list(x)
a  = [int(s) for s in x]
b = 0
for i in range(3):
    if a[i] == 1:
      b += 1
      
      
      
print(b)

Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split(//)))
b = 0

for i in range(3):
    print(a[i])
    if a[i] == 1:
      b += 1
print(b)

Fixed submission:
x = input()
a = list(x)
a  = [int(s) for s in x]
b = 0
for i in range(3):
    if a[i] == 1:
      b += 1
      
      
      
print(b)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(float, input().split(' '))

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

Fixed submission:
import math

a, b, x = map(float, input().split(' '))

if x >= a**2*b/2:
    y = 2*b-(2*x/a**2)
    print(math.degrees(math.atan(y/a)))
else:
    y = 2*x/(a*b)
    print(math.degrees(math.atan(b/y)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
L = np.array([int(l) for l in input().split(' ')])
counts =0

for i in range(N):
    for j in range(i+1,N):
        B2  = L[j+1:][(L[j+1:]<L[i]+L[j]) & (L[j+1:]>abs(L[i]-L[j]))]
        counts +=len(B2)
print(counts)

Fixed submission:
A,B = map(int, input().split(' '))
print(max(A-2*B,0))

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
L = np.array([int(l) for l in input().split(' ')])
counts =0

for i in range(N):
    for j in range(i+1,N):
        B2  = L[j+1:][(L[j+1:]<L[i]+L[j]) & (L[j+1:]>abs(L[i]-L[j]))]
        counts +=len(B2)
print(counts)
                

Fixed submission:
A,B = map(int, input().split(' '))
print(max(A-2*B,0))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
kuchi = 1
taps = 0 
while kuchi < B:
    taps +=1
    kuchi +=A-1
print(taps)

Fixed submission:
A,B = map(int, input().split(' '))
kuchi = 1
taps = 0 
while kuchi < B:
    taps +=1
    kuchi +=A-1
print(taps)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
kuchi = 1
taps = 0 
while kuchi < B:
    taps +=1
    kuchi +=A-1
print(taps)
    
    


Fixed submission:
A,B = map(int, input().split(' '))
kuchi = 1
taps = 0 
while kuchi < B:
    taps +=1
    kuchi +=A-1
print(taps)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = np.array([int(i) for i in input().split(' ')])
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] >= 0:
        length +=1
    else:
        max_length = length
        length = 0
print(length)
        

Fixed submission:
import numpy as np
N = int(input())
H = np.array([int(i) for i in input().split(' ')])
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] <= 0:
        length +=1
    else:
        length = 0
        if max_length < length:
            max_length = length
    if max_length < length:
        max_length = length
print(max_length)

Buggy python submission (verdict: Runtime Error):
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] >= 0:
        length +=1
    else:
        max_length = length
        length = 0
print(length)
        

Fixed submission:
import numpy as np
N = int(input())
H = np.array([int(i) for i in input().split(' ')])
length = 0
max_length=0
for i in range(N-1):
    if H[i+1] - H[i] <= 0:
        length +=1
    else:
        length = 0
        if max_length < length:
            max_length = length
    if max_length < length:
        max_length = length
print(max_length)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

A=int(input())
B=int(input())
C=int(input())
if A+B+C>=22:
    print("bust")
else:
    print("win")

Fixed submission:
# coding: utf-8
# Your code here!

a,b, c = map(int, input().split())
if a+b+c>=22:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Runtime Error):
N = int(input())

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)

A = 1
B = 1
for i in a:
  if(A > B):
    B *= i
  elif(B > A):
    A *= i
  else:
    A *= i
print(A + B - 2)

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

if(1 <= A <= 9 and 1 <= B <= 9):
  print(A * B)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
if sum(A) > 21:
    print('bust')
else:
    print('win')


Fixed submission:
A = [int(x) for x in input().split()]
if sum(A) > 21:
    print('bust')
else:
    print('win')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import numpy as np
N = int(input())
S = input()

dic_ = {}

for i in range(N):
    dic_[S[i]] = dic_.get(S[i], []) + [i]

ans = [False]*1000

def get_first_pos(i, k):
    if dic_.get(str(i)) is not None:
        ind = bisect.bisect_right(dic_[str(i)], k)
        if ind != len(dic_[str(i)]):
            return dic_[str(i)][ind]
    return None

        
for i in range(10):
    x1 = get_first_pos(i, -1)
    if x1 is None:
        continue
    for j in range(10):
        x2 = get_first_pos(j, x1)
        if x2 is None:       
            continue
        for k in range(10):
            x3 = get_first_pos(k, x2)
            if x3 is None:       
                continue
            ans[int(str(i)+str(j)+str(k))] = True
print(np.count_nonzero(ans))


Fixed submission:
import bisect
import numpy as np
N = int(input())
S = input()

dic_ = {}
array =  np.zeros((10, 300001), np.int8)

for i in range(N):
    array[int(S[i]), i] = 1

def get_first_pos(i, k):
    ar = array[i, k+1:]
    wh = np.where(ar>0)
    if len(wh[0]) > 0:
        return wh[0][0] + k+1
    return None

ans = 0
        
for i in range(10):
    x1 = get_first_pos(i, -1)
    if x1 is None:
        continue
    for j in range(10):
        x2 = get_first_pos(j, x1)
        if x2 is None:       
            continue
        for k in range(10):
            x3 = get_first_pos(k, x2)
            if x3 is None:       
                continue
            ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = input()

dic_ = {}

for i in range(N):
    dic_[S[i]] = dic_.get(S[i], []) + [i]

ans = [False]*1000

def get_first_pos(i, k):
    if dic_.get(str(i)) is not None:
        for x in dic_[str(i)]:
            if x > k:
                return x
    return None

        
for i in range(10):
    x1 = get_first_pos(i, -1)
    if x1 is None:
        continue
    for j in range(10):
        x2 = get_first_pos(j, x1)
        if x2 is None:       
            continue
        for k in range(10):
            x3 = get_first_pos(k, x2)
            if x3 is None:       
                continue
            ans[int(str(i)+str(j)+str(k))] = True
print(np.count_nonzero(ans))


Fixed submission:
import bisect
import numpy as np
N = int(input())
S = input()

dic_ = {}
array =  np.zeros((10, 300001), np.int8)

for i in range(N):
    array[int(S[i]), i] = 1

def get_first_pos(i, k):
    ar = array[i, k+1:]
    wh = np.where(ar>0)
    if len(wh[0]) > 0:
        return wh[0][0] + k+1
    return None

ans = 0
        
for i in range(10):
    x1 = get_first_pos(i, -1)
    if x1 is None:
        continue
    for j in range(10):
        x2 = get_first_pos(j, x1)
        if x2 is None:       
            continue
        for k in range(10):
            x3 = get_first_pos(k, x2)
            if x3 is None:       
                continue
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
ans = {'SUN': 7, 'MON': 6, 'TUE': 5 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(ans[S])

Fixed submission:
S = input()
ans = {'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(ans[S])

Buggy python submission (verdict: Runtime Error):
S = input()
ans = {'SUN': 7, 'MON': 6, 'TUE': 5 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(ans[S])

Fixed submission:
S = input()
ans = {'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(ans[S])
Buggy python submission (verdict: Runtime Error):
A, B = [int(x) for x in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


A_div = make_divisors(A)
B_div = make_divisors(B)

cd = sorted([a for a in A_div if a in B_div])
prime = sieve(max(cd))

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if a in prime:
        ans += 1

print(ans)


Fixed submission:
A, B = [int(x) for x in input().split()]

def common_divisors(a, b):
    cd = []
    n = min(a, b)
    m = max(a, b)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if m % i == 0:
                cd.append(i)
            if i != n // i and m % (n//i) == 0:
                cd.append(n//i)
    return cd

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


cd = common_divisors(A, B)
#prime = sieve(max(cd))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if i*i > n:
            break
        if n % i == 0:
            return False
    return True

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if is_prime(a):
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

for _ in range(M):
    A = sorted(A, reverse=True)
    if A[0] == 0:
        break
    A[0] //= 2

print(sum(A)) 

Fixed submission:
import heapq as hq

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
que = []
for i, a in enumerate(A):
    hq.heappush(que, (-a, str(i))) 

for _ in range(M):    
    priority, a = hq.heappop(que)    
    if priority == 0:
        break
    priority = - priority
    priority //= 2
    hq.heappush(que, (-priority, a))

sum_ = 0
for q in que:
    sum_ += q[0]

print(-sum_)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0

for i in range(1, N):

    ans += i

print(ans)



Fixed submission:
N = int(input())
print(N*(N-1)//2)

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

ans = 0

for i in range(N-1):
    ans += i+1

print(ans)


Fixed submission:
N = int(input())
print(N*(N-1)//2)

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

ans = 0

for i in range(N-1):
    ans += i+1

print(ans)


Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
S = []

for _ in range(N):
    S.append(input())

def create_hash(_str):
    hash = ""
    for i, a in enumerate(["a", "b", "c", "d", "e",
     "f", "g", "h", "i", "j",
     "k", "l", "m", "n", "o",
     "p", "q", "r", "s", "t",
     "u", "v", "w", "x", "y", "z"]):
        count = 0
        for s in _str:
            if s == a:
                count += 1
        hash += str(count)
    return hash

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

hist = {}
for s in S:
    hash = create_hash(s)
    hist[hash] = hist.get(hash, 0) + 1

pairs = 0
for k, v in hist.items():
    if v > 1:
        pairs += combinations(v, 2)
print(pairs)


Fixed submission:
import math

N = int(input())
S = []

for _ in range(N):
    S.append(input())

def create_hash(_str):
    hash = ""
    for i, a in enumerate(["a", "b", "c", "d", "e",
     "f", "g", "h", "i", "j",
     "k", "l", "m", "n", "o",
     "p", "q", "r", "s", "t",
     "u", "v", "w", "x", "y", "z"]):
        count = 0
        for s in _str:
            if s == a:
                count += 1
        hash += str(count)
    return hash

def combinations(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

hist = {}
for s in S:
    hash = create_hash(s)
    hist[hash] = hist.get(hash, 0) + 1

pairs = 0
for k, v in hist.items():
    if v > 1:
        pairs += combinations(v, 2)
print(pairs)
Buggy python submission (verdict: Runtime Error):

S = input()

LRpos = [s.start() for s in re.finditer('LR', S)]
LRpos.insert(0, -1)
LRpos.append(len(S))

final_state = [0]*len(S)

for i in range(len(LRpos)-1):
    part_str = S[LRpos[i]+1:LRpos[i+1]+1]
    RLpos = part_str.find('RL')
    num_R = RLpos+1
    num_L = len(part_str) - num_R

    final_state[LRpos[i]+RLpos+1] = (num_R+1)//2 + num_L//2
    final_state[LRpos[i]+RLpos+2] = (num_R)//2 + (num_L+1)//2

print(final_state)


Fixed submission:
'''1. LR で region を区切る
2. 区切った中で、(Rの数+1)/2+(Lの数)/2 が十分時間が経った偶数回後にRの上にいる数、
   (Rの数)/2+(Lの数+1)/2 がLの上にいる数。'''
import re

S = input()

LRpos = [s.start() for s in re.finditer('LR', S)]
LRpos.insert(0, -1)
LRpos.append(len(S))

final_state = [0]*len(S)

for i in range(len(LRpos)-1):
    part_str = S[LRpos[i]+1:LRpos[i+1]+1]
    RLpos = part_str.find('RL')
    num_R = RLpos+1
    num_L = len(part_str) - num_R

    final_state[LRpos[i]+RLpos+1] = (num_R+1)//2 + num_L//2
    final_state[LRpos[i]+RLpos+2] = (num_R)//2 + (num_L+1)//2

print(' '.join(str(i) for i in final_state))
Buggy python submission (verdict: Runtime Error):
N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    inverse_p = j
    while j < K:
        j *= 2
        inverse_p *= 2
    prob += 1/ p

print(prob)
    


Fixed submission:
N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    inverse_p = N
    while j < K:
        j *= 2
        inverse_p *= 2
    prob += 1/ inverse_p

print(prob)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import Fraction

N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    num_omote = 0
    while j < K:
        j *= 2
        num_omote += 1
    prob += Fraction(1, N) * Fraction(1, 2)**num_omote

print(float(prob))
    


Fixed submission:
N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    inverse_p = N
    while j < K:
        j *= 2
        inverse_p *= 2
    prob += 1/ inverse_p

print(prob)
Buggy python submission (verdict: Runtime Error):
import re

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

num_end_with_A = 0
num_start_with_B = 0
num_both = 0
num_inner_AB = 0

for ss in s:
    res = re.findall('AB', ss)
    if res:
        num_inner_AB += len(res)
    if ss[0] == 'B' and ss[-1] == 'A':
        num_both += 1
    elif ss[0] == 'B':
        num_start_with_B += 1
    elif ss[-1] == 'A':
        num_end_with_A += 1


if num_end_with_A == num_start_with_B:
    print(num_inner_AB + num_end_with_a + max(num_both - 1, 0))
else:
    print(num_inner_AB + min(num_end_with_A, num_start_with_B) + num_both)


Fixed submission:
import re

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

num_end_with_A = 0
num_start_with_B = 0
num_both = 0
num_inner_AB = 0

for ss in s:
    res = re.findall('AB', ss)
    if res:
        num_inner_AB += len(res)
    if ss[0] == 'B' and ss[-1] == 'A':
        num_both += 1
    elif ss[0] == 'B':
        num_start_with_B += 1
    elif ss[-1] == 'A':
        num_end_with_A += 1

if num_end_with_A == 0 and num_start_with_B == 0:
    print(num_inner_AB + max(num_both - 1, 0))
else:
    print(num_inner_AB + min(num_end_with_A, num_start_with_B) + num_both)
Buggy python submission (verdict: Runtime Error):
def find_AC(S):
  ret = []
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret.append(i)
  return ret

N, Q = [int(x) for x in input().split()]
S = input()
result = find_AC(S)
print(result)
pos = [res+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)


Fixed submission:
N, M = [int(x) for x in input().split()]

AB = []

for _ in range(N):

    AB.append([int(x) for x in input().split()])

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

current_drinks = 0

current_buget = 0

for a, b in AB:

    num_buy = min(b, (M-current_drinks))

    current_drinks += num_buy

    current_buget += num_buy*a

    # print(current_drinks, current_buget)

    if current_drinks == M:

        break

print(current_buget)