Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, C, D = map(int, input().split())

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / np.gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))


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

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

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))

Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / math.gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))


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

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

def f(num, c, d):
    return num - (num // c + num // d - num // int(c * d / gcd(c, d)))

print (f(B, C, D) - f(A - 1, C, D))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)])

res = M
n = 0
cnt = 0

if N == 1:
    cnt = res * AB[0][1]
else:
    while(AB[n][1] <= res):
        cnt += AB[n][0] * AB[n][1]
        res -= AB[n][1]
        n += 1

    cnt += res * AB[n][0]

print(cnt)


Fixed submission:
N, M = map(int, input().split())
AB = sorted([list(map(int, input().split())) for _ in range(N)])

res = M
n = 0
cnt = 0


while(AB[n][1] < res):
    cnt += AB[n][0] * AB[n][1]
    res -= AB[n][1]
    n += 1

cnt += res * AB[n][0]

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))
for i in range(int(n/2)+1):
  if s[i] != s[int(n/2+i)] or n==1 or n%2:
    print('No')
    exit()
print('Yes')

Fixed submission:
n = int(input())
s = list(str(input()))
if n == 1:
  print('No')
  exit()
for i in range(int(n/2)):
  if s[i] != s[int(n/2+i)] or n%2:
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))
for i in range(n/2):
  if s[i] != s[int(n/2)+i]:
    print('No')
    exit()
print('Yes')

Fixed submission:
n = int(input())
s = list(str(input()))
if n == 1:
  print('No')
  exit()
for i in range(int(n/2)):
  if s[i] != s[int(n/2+i)] or n%2:
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
ans = a*b if a<=9 ans b<=9 else -1
print(ans)

Fixed submission:
a, b = map(int, input().split())
ans = a*b if 1 <= a <= 9 and 1 <= b <= 9 else -1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1, 10):
  for j in range(1, 10):
    print('Yes' if i*j == n)
print('No')

Fixed submission:
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(1, 10):
  for j in ragne(1, 10):
    if i*j == n:
      print('Yes')
      exit()
print('No')

Fixed submission:
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
Print('No')

Fixed submission:
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 9
for i in range(a+1):
  for j in range(a+1):
    if i*j == n:
      print('Yes')
      exit()
Print('No')

Fixed submission:
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(9):
  for j in range(9):
    if i*j == n:
      print('Yes')
      exit()
Print('No')

Fixed submission:
n = int(input())
for i in range(9):
  for j in range(9):
    if (i+1)*(j+1) == n:
      print('Yes')
      exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
list = []
for i in range(1, n**0.5+1):
  if n%i == 0:
    list.append(int(i + n/i))
print(min(list)-2)

Fixed submission:
n = int(input())
list = []
for i in range(1, int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i + n/i))
print(min(list)-2)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = int('inf')
for i in range(10^6):
  if n%(i+1) == 0:
    j = n/(i+1)
    ans = min(ans, (i+1)+j-2)
print(ans)

Fixed submission:
n = int(input())
list = []
for i in range(1, int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i + n/i))
print(min(list)-2)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ans = float('inf')
for i in range(10^6):
  if n%i == 0:
    j = n/i
    ans = min(ans, i+j-2)
print(ans)

Fixed submission:
n = int(input())
list = []
for i in range(1, int(n**0.5+1)):
  if n%i == 0:
    list.append(int(i + n/i))
print(min(list)-2)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a-2b if a-2b >= 0 else 0
print(s)

Fixed submission:
a, b = map(int, input().split())
s = a-2*b if a-2*b >= 0 else 0
print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(str(input()))
a = ''
ans = 0
for i in s:
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)

Fixed submission:
n = int(input())
s = input()
a = ''
ans = 0
for i in range(n):
  if s[i] != a:
    a = s[i]
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left

n = int(input())
l = list(map(int, input()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)

Fixed submission:
from  bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i]<l[j]+l[k] and l[j]<l[k]+l[i] and l[k]<l[i]+l[j]:
        ans += 1
print(ans)

Fixed submission:
from  bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i]<l[j]+l[k] and l[j]<l[k]+l[i] and l[k]<l[i]+l[j]:
        ans += 1
print(ans)

Fixed submission:
from  bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
ans = 0

l.sort()
for i in range(n-2):
  for j in range(i+1, n-1):
    ans += bisect_left(l, l[i]+l[j]) - j - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
odd = 0
for i in range(n+1):
  odd += 1 if i%2
print(odd/n)

Fixed submission:
n = int(input())
odd = 0
for i in range(n+1):
  if i%2:
    odd += 1
print(odd/n)

Buggy python submission (verdict: Runtime Error):
n = int(input())
odd = 0
for i in range(n+1):
  odd += i if i%2:
print(int(odd/n)

Fixed submission:
n = int(input())
odd = 0
for i in range(n+1):
  if i%2:
    odd += 1
print(odd/n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n

for i in range(n):
  s = a[i]
  ans[s-1] = i + 1
print(ans*)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
ans = [0]*n

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
list = []

for i in range(1, n+1):
  for j in range(1, n+1):
    if a[j-1] == i:
      list.append(str(j))
print(' '.join(list))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n

for i in range(n):
  s = a[i]
  ans[s-1] = i+1
print(*ans)
Buggy python submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Fixed submission:
s = list(str(input()))
for i in range(len(s)):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if (i%2 and s[i]=='L') or (i%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')


Fixed submission:
s = list(str(input()))
for i in range(len(s)):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')

Buggy python submission (verdict: Runtime Error):
s = list(str(input()))
for i in range(1, len(s)+1):
  if (i%2 and s[i]=='L') or (i%2==0 and s[i]=='R'):
    print('No')
 	exit()
print('Yes')

Fixed submission:
s = list(str(input()))
for i in range(len(s)):
  if ((i+1)%2 and s[i]=='L') or ((i+1)%2==0 and s[i]=='R'):
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')

Fixed submission:
n, k, q = map(int, input().split())
a = list(map(int, [input() for i in range(q)]))
p = [k-q] * n
for i in range(q):
  p[a[i]-1] += 1
for i in range(n):
  print('Yes' if p[i] > 0 else 'No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))
ans = 0
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i], b[i+1])
print(ans)

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
ans = 0
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i-1], b[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map, input().split())
print(sum(b) + b[0])

Fixed submission:
n = int(input())
b = list(map(int, input().split()))
ans = 0
ans = b[0] + b[n-2]
for i in range(1, n-1):
  ans += min(b[i-1], b[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
a = 0
list = []
if n == 1:
  print(0)
  exit()
for i in range(1, n):
  if h[i] <= h[i-1]:
    a += 1
  else:
    a = 0
  list.append(a)
print(max(list))
Buggy python submission (verdict: Runtime Error):
# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(sum(list(range(N))))

Fixed submission:
# 例： 1 - 8 までの数列
# 1 2 3 4 5 6 7 8

# 余りを最大化するには、Nに対する N-1 の余り。つまり１ずつ減じた値の余りをとる。最初の値は N
# 8 1 2 3 4 5 6 7

#  (8 % 1) + (1 % 2) + (2 % 3) + .... + (7 % 8)
#   0 + 1   2 + ... + 7

N = int(input())
print(N * (N-1) // 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

above = H[N-1]
for i in range(N-2, -1, -1):
    cur = H[i]
    #print(cur, above)
    if cur <= above:
        above = cur
        continue
    elif cur - 1 == above:
        continue
    else:
        break

if i == 0:
    print("Yes")
else:
    print("No")

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

if N == 1:
    print("Yes")
else:
    for i in range(N-1, 0, -1):
        #print(H[i-1], H[i])
        if H[i-1] <= H[i]:
            #print("@")
            continue
        elif (H[i-1] - 1) == H[i]:
            #print("#")
            H[i-1] = H[i]
        else:
            #print("=")
            break
    
    if i == 1:
        print("Yes")
    else:
        print("No")

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

for i in range(N-1, 0, -1):
    #print(H[i-1], H[i])
    if H[i-1] <= H[i]:
        #print("@")
        continue
    elif (H[i-1] - 1) == H[i]:
        #print("#")
        H[i-1] = H[i]
    else:
        #print("=")
        break

if i == 1:
    print("Yes")
else:
    print("No")

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

if N == 1:
    print("Yes")
else:
    for i in range(N-1, 0, -1):
        #print(H[i-1], H[i])
        if H[i-1] <= H[i]:
            #print("@")
            continue
        elif (H[i-1] - 1) == H[i]:
            #print("#")
            H[i-1] = H[i]
        else:
            #print("=")
            break
    
    if i == 1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    print(max( A[:i]+A[i+1:]))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

# 入力された数列を降順でソート
sortA = sorted(A, reverse=True)

if sortA[0] == sortA[1]:
    # 最大値が2個発生するならば、そのときはすべての行で最大値が表示される
    for i in range(N):
        print(sortA[0])
else:
    # 最大値が1個しかない場合、最大値の存在する位置では最大から2番めの値が表示されるが、それ以外では最大値が表示される
    maxP = A.index(sortA[0])
    for i in range(maxP):
        print(sortA[0])
    print(sortA[1])
    for i in range(maxP+1, N):
        print(sortA[0])
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        if debug:
            print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)

Fixed submission:
N, D = map(int, input().split())
arX = [list(map(int, input().split()))[:D] for n in range(N)]

import math

count = 0
for x in range(len(arX)):
    xp = arX[x]
    for y in range(x, len(arX)):
        if x == y:
            continue
        
        yp = arX[y]
        
        powSum = 0
        for d in range(D):
            powSum += (xp[d] - yp[d]) ** 2
        
        #print(x, y, sqPowSum)
            
        sqPowSum = math.sqrt(powSum)
        if sqPowSum == int(sqPowSum):
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    div, _ = divmod(x * y, math.gcd(x, y))
    return div


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
#Ccount = (B // C) - ((A - 1) // C)
divBC, _ = divmod(B, C)
divA1C, _ = divmod(A-1, C)
Ccount = divBC - divA1C

# 変数D の倍数が A, B 区間内に存在しうる数
#Dcount = (B // D) - ((A - 1) // D)
divBD, _ = divmod(B, D)
divA1D, _ = divmod(A-1, D)
Dcount = divBD - divA1D

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
#CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))
divBlcmCD, _ = divmod(B, lcm(C, D))
divA1lcmCD, _ = divmod(A-1, lcm(C, D))
CDcross =divBlcmCD - divA1lcmCD

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Fixed submission:
from fractions import gcd

def lcm(x, y):
    return ((x * y) // gcd(x, y))


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

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

def lcm(x, y):
    return ((x * y) // math.gcd(x, y))


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Fixed submission:
from fractions import gcd

def lcm(x, y):
    return ((x * y) // gcd(x, y))


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = B // C - (A - 1) // C

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = B // D - (A - 1) // D

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = B // lcm(C, D) - (A - 1) // lcm(C, D)

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))

Fixed submission:
from fractions import gcd

def lcm(x, y):
    return ((x * y) // gcd(x, y))


A, B, C, D = map(int, input().split())

# 変数C の倍数が A, B 区間内に存在しうる数
Ccount = (B // C) - ((A - 1) // C)

# 変数D の倍数が A, B 区間内に存在しうる数
Dcount = (B // D) - ((A - 1) // D)

# 変数C, D の最小公倍数が A, B 区間内に存在しうる数
CDcross = (B // lcm(C, D)) - ((A - 1) // lcm(C, D))

# Cが存在しうる数と Dが存在しうる数を引き、重複する（＝最小公倍数）数は引きすぎなので戻す
print((B-A+1) - ((Ccount + Dcount - CDcross)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [input() for n in range(N)]

# 先頭が B ではなく、末尾が A な文字列
TxBA = [s[n] for n in range(N) if s[n][0] != "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A な文字列
TBBA = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A ではない文字列
TBBx = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] != "A"]

str = ""

while (len(TxBA)):
    str += TxBA.pop()
    while (len(TBBA)):
        str += TBBA.pop()
    if (len(TBBx)):
        str += TBBx.pop()

while (len(TBBx)):
    str += TBBx.pop()

while (len(ss)):
    str += ss.pop()

print(str.count("AB"))

Fixed submission:
N = int(input())
s = [input() for n in range(N)]

# 先頭が B ではなく、末尾が A な文字列
TxBA = [s[n] for n in range(N) if s[n][0] != "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A な文字列
TBBA = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] == "A"]

# 先頭が B で、末尾が A ではない文字列
TBBx = [s[n] for n in range(N) if s[n][0] == "B" and s[n][-1] != "A"]

# 上記を除き中に "AB" が存在する文字列
kouho = TxBA + TBBA + TBBx
ss = s.copy()
for k in kouho:
    ss.remove(k)
    
str = ""
while (len(TxBA)):
    str += TxBA.pop()
    while (len(TBBA)):
        str += TBBA.pop()
    if (len(TBBx)):
        str += TBBx.pop()

while (len(TBBA)):
    str += TBBA.pop()
if (len(TBBx)):
    str += TBBx.pop()

while (len(TBBx)):
    str += TBBx.pop()

while (len(ss)):
    str += ss.pop()

print(str.count("AB"))
Buggy python submission (verdict: Runtime Error):
n = int(input())
ar = list(map(int, input().split()))

try:
	assert 3 <= n <= 10
	assert len(ar) == n
	assert (1 <= min(ar)) and (max(ar) <= 100)
    
	if max(ar) < sum(ar) - max(ar):
		print("Yes")
	else:
		print("No")
except:
  print("No")


Fixed submission:
T, X = map(int, input().split())

print(float(T)/X)

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

assert 3 <= n <= 10
assert len(ar) == n
assert (1 <= min(ar)) and (max(ar) <= 100)

if max(ar) < sum(ar) - max(ar):
  print("Yes")
else:
  print("No")



Fixed submission:
T, X = map(int, input().split())

print(float(T)/X)
Buggy python submission (verdict: Runtime Error):
a = [0 for i in range(3 * 1000000 + 1)]

s = int(input().rstrip())

a[s] = 1

for i in range(2, 1000000+1):
    if s % 2 == 0:
        s = int(s / 2)
    else:
        s = int(3 * s + 1)
    #print(s)
    
    if a[s] == 1:
        break
    a[s] = 1
        
print(i)

Fixed submission:
AB, BC, CA = map(int, input().split())

print( int(AB * BC / 2) )
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    p = max(a)
    index = a.index(p)
    a[index] = a[index] // 2
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
import heapq
heapq.heapify(a)

for i in range(m):
    am =  -1 * heapq.heappop(a)
    am = am // 2
    heapq.heappush(a, -am)
print(-1 * sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    p = max(a)
    index = a.index(p)
    a[index] = a[index] // 2
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
import heapq
heapq.heapify(a)

for i in range(m):
    am =  -1 * heapq.heappop(a)
    am = am // 2
    heapq.heappush(a, -am)
print(-1 * sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    p = max(a)
    index = a.index(p)
    a[index] = a[index] // 2
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
import heapq
heapq.heapify(a)

for i in range(m):
    am =  -1 * heapq.heappop(a)
    am = am // 2
    heapq.heappush(a, -am)
print(-1 * sum(a))
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)

Fixed submission:
a, b = map(int, input().split())
x = 1
ans = 0
while x < b:
    x += a - 1
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)

Fixed submission:
a, b = map(int, input().split())
x = 1
ans = 0
while x < b:
    x += a - 1
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, n//2 - 1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range(n//2 - 1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Fixed submission:
a = int(input())
print(3*a**2)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
print(ans)

Fixed submission:
l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
print(ans)

Fixed submission:
l,r = map(int,input().split())
ans = 2019
for i in range(l,r):
    for j in range(i+1,r+1):
        p = (i * j) % 2019
        ans = min(p,ans)
        if ans == 0:
            break
    else:
        continue
    break
print(ans)