Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
base = ['A','T','C','G']

ind = base.index(input())
if(ind%2 == 0):
  printf(base[ind+1])
else:
  printf(base[ind-1])

Fixed submission:
base = ['A','T','C','G']
 
ind = base.index(input())
if(ind%2 == 0):
  print(base[ind+1])
else:
  print(base[ind-1])
Buggy python submission (verdict: Time Limit Exceeded):
N_K = input().split()
N = int(N_K[0])
K = int(N_K[1])
Hs = sorted([int(input()) for i in range(N)])
Hs_diff = [Hs[i+1] - Hs[i] for i in range(N) if i<(N-1)]
Hs_diff_K = [sum(Hs_diff[(i):(i+K-1)]) for i in range(len(Hs_diff)) if i < len(Hs_diff)-K+2]
print(min(Hs_diff_K))

Fixed submission:
N_K = input().split()
N = int(N_K[0])
K = int(N_K[1])
Hs = sorted([int(input()) for i in range(N)])
Hs_diff_K = [Hs[K+i-1] - Hs[i] for i in range(N) if i < N-K+1]
print(min(Hs_diff_K))
Buggy python submission (verdict: Runtime Error):
S = str(input())
li = [(i+j) for (i,j) in zip(S[::2],S[1::2])]
if int(li[0]) == 00 or int(li[1]) == 00:
    print('NA')
elif int(li[0]) <= 12 and int(li[1]) <= 12:
    print('AMBIGUOUS')
elif int(li[0]) >= 13 and int(li[1]) <= 12:
    print('YYMM')
elif int(li[0]) <= 12 and int(li[1]) >= 13:
    print('MMYY')
else:
    print('NA')

Fixed submission:
N,K = map(int,input().split())
strlist = list(input())
ans = ''
S = strlist[K-1].lower()
strlist[K-1] = S
for i in strlist:
    ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
X = int(S[0:2])
Y = int(S[2:4])

if X > 12 and Y > 12:
    print("NA")
elif X == 0 or Y == 0:
    if X == 0:
        if Y > 12:
            print("NA")
        else:
            pirnt("YYMM")
    else:
        if X > 12:
            print("NA")
        else:
            print("MMYY")
elif X < 13 and Y < 13:
    print("AMBIGUOUS")
elif X > Y:
    print("YYMM")
else:
    print("MMYY")


Fixed submission:
S = input()
X = int(S[0:2])
Y = int(S[2:4])

if X > 12 and Y > 12:
    print("NA")
elif X == 0 or Y == 0:
    if X == 0:
        if Y > 12 or Y == 0:
            print("NA")
        else:
            print("YYMM")
    else:
        if X > 12:
            print("NA")
        else:
            print("MMYY")
elif X < 13 and Y < 13:
    print("AMBIGUOUS")
elif X > Y:
    print("YYMM")
else:
    print("MMYY")

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
s = input()
s_list=list(s)
s_len=len(s_list)
s_first=int(s_list[0]+s_list[1])
s_second=int(s_list[2]+s_list[3])
if s_first<13:#MMYY case
    if s_second<13:
        print('AMBIGOUS')
    else:
        print('MMYY')

else if: #YYMM case
    if s_second==0:
        print('NA')
    else:
        print('YYMM')

else
    print('NA')


Fixed submission:
# coding: utf-8
s = input()
s_list=list(s)
s_len=len(s_list)
s_first=int(s_list[0]+s_list[1])
s_second=int(s_list[2]+s_list[3])
if s_first<13 and s_first>0: #MMYY case
    if s_second<13 and s_second>0:
        print('AMBIGUOUS')
    else:
        print('MMYY')

else: #YYMM case
    if s_second<13 and s_second>0:
        print('YYMM')
    else:
        print('NA')
Buggy python submission (verdict: Runtime Error):
N = input()
K = input()

out = (N - K) + 1

print(out)

Fixed submission:
NK = input().split()
NK = [int(s) for s in NK]

out = (NK[0] - NK[1]) + 1

print(out)
Buggy python submission (verdict: Runtime Error):
n=int(input())
list_v=list(map(int, input().split()))
list_c=list(map(int, input().split()))
list_ans = list_v - list_c
ans = 0
for i in range(n):
  if list_ans[i] > 0:
    ans += list_ans[i]
print(ans)

Fixed submission:
n=int(input())
list_v=list(map(int, input().split()))
list_c=list(map(int, input().split()))
ans = 0
for i in range(n):
  ans_p = list_v[i] - list_c[i]
  if ans_p > 0:
    ans += ans_p
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split())
if (a < c && c < b) || (b < c && c < a):
  print('Yes')
else:
  print('No')

Fixed submission:
l = [int(i) for i in input().split()]
l_sorted = sorted(l)
if l[2] == l_sorted[1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
c = s[k-1]
for i in range(len(s)):
  if not s[i] == c:
    s[i] = c
print(s)

Fixed submission:
n = int(input())
s = list(input())
k = int(input())
c = s[k-1]
for i in range(n):
  if not s[i] == c:
    s[i] = '*'
print("".join(s))
Buggy python submission (verdict: Runtime Error):
l = sorted([int(input()) for i in range(2)])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])

Fixed submission:
l = sorted([int(i) for i in input().split()])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])

Buggy python submission (verdict: Runtime Error):
l = sorted([int(input()) for i in range(2)])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
elif: l[1] == l[0]:
  print(l[0]*2)
else:
  print(l[0]+l[1]-1)

Fixed submission:
l = sorted([int(i) for i in input().split()])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])

Buggy python submission (verdict: Runtime Error):
l = sorted([int(input)) for i in range(2)])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
elif: l[1] == l[0]:
  print(l[0]*2)
else:
  print(l[0]+l[1]-1)

  
  

Fixed submission:
l = sorted([int(i) for i in input().split()])
if l[1]-1>=l[0]:
  print(l[1]*2-1)
else:
  print(l[0]+l[1])
Buggy python submission (verdict: Runtime Error):
s = list(int(input()))
flag = 0
for i in range(len(s)-1):
  if s[i] == '1' and s[i+1] == '1':
    s[i+1] = '0'
    flag += 1
  elif s[i] == '0' and s[i+1] == '0':
    s[i+1] = '1'
    flag += 1
print(flag)


Fixed submission:
s = list(str(input()))
flag = 0
for i in range(len(s)-1):
  if s[i] == '1' and s[i+1] == '1':
    s[i+1] = '0'
    flag += 1
  elif s[i] == '0' and s[i+1] == '0':
    s[i+1] = '1'
    flag += 1
print(flag)
Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
l_a = list(map(int, input().split()))
l_b = list(map(int, input().split()))
l_c = list(map(int, input().split()))
print(list(itertools.product(l_a, l_b, l_c)))
l = [sum(i) for i in list(itertools.product(l_a, l_b, l_c))]
print(sorted(l, reverse=True)[:k])

Fixed submission:
input_list = [int(input()) for i in range(5)]
k = int(input())
if input_list[4] - input_list[0] <= k:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = l_0.index(max(l_0))
l.pop(s)
l_0.pop(s)
ans = sum(l) + sum(l_0) + l[s]
print(ans)
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = ar.index(max(ar))
ar.pop(s)
ans = sum(l) + sum(ar)
print(ans)


Fixed submission:
input_list = [int(input()) for i in range(5)]
k = int(input())
if input_list[4] - input_list[0] <= k:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = l_0.index(max(l_0))
l.pop(s)
l_0.pop(s)
ans = sum(l) + sum(l_0) + l[s]
print(ans)

Fixed submission:
input_list = [int(input()) for i in range(5)]
k = int(input())
if input_list[4] - input_list[0] <= k:
  print('Yay!')
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
if e - a =< k:
  print('Yay!')
else:
  print(':(')

Fixed submission:
input_list = [int(input()) for i in range(5)]
k = int(input())
if input_list[4] - input_list[0] <= k:
  print('Yay!')
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
l = [int(input) in i for range(5)]
l_0 = l % 10
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = l_0.index(max(l_0))
ans = sum(l[l.index()!=s]) + sum(l_0[l_0.index()!=s]) + l[s]
print(ans)

Fixed submission:
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = ar.index(max(ar))
ar.pop(s)
ans = sum(l) + sum(ar)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in ref:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))

Fixed submission:
s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in s:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))

Buggy python submission (verdict: Runtime Error):
s = input()
list0 = ['A', 'C', 'G', 'T']
list1 = []
frag = 0
for i in s:
  if i in list0:
    frag += 1
  else:
    if frag != 0:
      list1.append(frag)
    frag = 0
list1.appned(0)
print(max(list1))

Fixed submission:
s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in s:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))

Buggy python submission (verdict: Runtime Error):
s = input()
list0 = ['A', 'C', 'G', 'T']
list1 = []
frag = 0
for i in s:
  if i in list0:
    frag += 1
  else:
    if frag != 0:
      list1.append(frag)
    frag = 0
print(max(list1))

Fixed submission:
s=input()
count=0
count_list=[]
seq=["A","T","G","C"]
for base in s:
    if base in seq:
        count +=1
    else:
        count_list.append(count)
        count = 0
    count_list.append(count)
print(max(count_list))
Buggy python submission (verdict: Runtime Error):
a = list(int(i) for i in input().split())
k = int(input())

maximum_sum = a[0] + a[1] + a[2] + max(a)*((2**k)-1)
print('{}'.format(maximum_sum))


Fixed submission:
a, b = map(int, input().split())

takahashi = a - 1
if b >= a :
    takahashi = takahashi + 1

print('{}'.format(takahashi))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B + 1)
  else:
    ans = A + B


MaxCoinCount(a, b)

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

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B - 1)
  else:
    ans = A + B
  return ans


print(MaxCoinCount(A,B))

Buggy python submission (verdict: Runtime Error):
def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B + 1)
  else:
    ans = A + B

MaxCoinCount(A, B)

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

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B - 1)
  else:
    ans = A + B
  return ans


print(MaxCoinCount(A,B))

Buggy python submission (verdict: Runtime Error):
def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
    A = A - 1
  else if A < B:
    ans = B + (B + 1)
  else:
    ans = A + B

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

def MaxCoinCount(A,B):
  ans = 0
  if A > B:
    ans = A + (A - 1)
  elif A < B:
    ans = B + (B - 1)
  else:
    ans = A + B
  return ans


print(MaxCoinCount(A,B))
Buggy python submission (verdict: Runtime Error):
n,k=map(int, input().split())
String=input()
String=list(String)
String[k]=String[k].lower()
String="".join(String)
print(String)

Fixed submission:
n,k=map(int, input().split())
String=input()
String=list(String)
String[k-1]=String[k-1].lower()
String="".join(String)
print(String)

Buggy python submission (verdict: Runtime Error):
n,k=map(int, input().split())
String=input()
String=list(String)
String[k]=String[k].upper()
String="".join(String)
print(String)

Fixed submission:
n,k=map(int, input().split())
String=input()
String=list(String)
String[k-1]=String[k-1].lower()
String="".join(String)
print(String)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)

h2 = []
for _ in range(min(K, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Fixed submission:
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)

h2 = []
for _ in range(min(K, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)


h2 = []
for _ in range(min(3000, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Fixed submission:
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)

h2 = []
for _ in range(min(K, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)


h2 = []
for _ in range(X * Y):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)

Fixed submission:
import heapq
X, Y, Z, K = map(int, raw_input().split())
A = map(int, raw_input().split())
B = map(int, raw_input().split())
C = map(int, raw_input().split())

h1 = []
for a in A:
  for b in B:
    heapq.heappush(h1, -a - b)

h2 = []
for _ in range(min(K, X * Y)):
  ab = -heapq.heappop(h1)
  for c in C:
    heapq.heappush(h2, -ab - c)

for _ in range(K):
  print -heapq.heappop(h2)
Buggy python submission (verdict: Runtime Error):
def is_left_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i < 0:
      return True
    if i >= N:
      return False
  return False
def is_right_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i >= N:
      return True
    if i < 0:
      return False
  return False

N, Q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(Q)]

# left
l = 0
r = N - 1
l_res = -1
while (l <= r):
  target = (r + l) / 2
  if is_left_removed(target, s, td):
    l = target + 1
    l_res = target
  else:
    r = target - 1

# right
l = 0
r = N - 1
r_res = N
while (l <= r):
  target = (r + l) / 2
  if is_right_removed(target, s, td):
    r = target - 1
    r_res = target
  else:
    l = target + 1

print N - min(N, l_res + 1 + N - r_res)

Fixed submission:
A, B, C = map(int, raw_input().split())
if A == B and B == C:
  print 'Yes'
else:
  print 'No'
Buggy python submission (verdict: Runtime Error):
def is_left_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i < 0:
      return True
  return False
def is_right_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i >= N:
      return True
  return False

N, Q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(Q)]

# left
l = 0
r = N - 1
l_res = -1
while (l <= r):
  target = (r + l) / 2
  if is_left_removed(target, s, td):
    l = target + 1
    l_res = target
  else:
    r = target - 1

# right
l = 0
r = N - 1
r_res = N
while (l <= r):
  target = (r + l) / 2
  if is_right_removed(target, s, td):
    r = target - 1
    r_res = target
  else:
    l = target + 1

print N - min(N, l_res + 1 + N - r_res)

Fixed submission:
def is_left_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i < 0:
      return True
    if i >= N:
      return False
  return False
def is_right_removed(i, S, td):
  direction = {'L': -1, 'R': +1}
  for t, d in td:
    if S[i] == t:
      i += direction[d]
    if i >= N:
      return True
    if i < 0:
      return False
  return False

N, Q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(Q)]

# left
l = 0
r = N - 1
l_res = -1
while (l <= r):
  target = (r + l) / 2
  if is_left_removed(target, s, td):
    l = target + 1
    l_res = target
  else:
    r = target - 1

# right
l = 0
r = N - 1
r_res = N
while (l <= r):
  target = (r + l) / 2
  if is_right_removed(target, s, td):
    r = target - 1
    r_res = target
  else:
    l = target + 1

print N - min(N, l_res + 1 + N - r_res)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, raw_input().split())
S = raw_input()
ac_counter = [0] * N
for i in range(N - 1):
  if S[i:i + 2] == 'AC':
    ac_counter[i] += 1
for _ in range(Q):
  l, r = map(int, raw_input().split())
  print sum(ac_counter[l - 1: r]) - ac_counter[r - 1]

Fixed submission:
N, Q = map(int, raw_input().split())
S = raw_input()
ac_counter = [0] * (N + 1)
total = 0
for i in range(1, N):
  if S[i - 1:i + 1] == 'AC':
    ac_counter[i] += 1
  ac_counter[i] += total
  total = ac_counter[i]

for _ in range(Q):
  l, r = map(int, raw_input().split())
  print ac_counter[r] - ac_counter[l - 1] - (ac_counter[r] - ac_counter[r - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
takahashi_v = []
aoki_v = []
for _ in range(N):
    a, b  = map(int, raw_input().split())
    record = [a, b, True]
    takahashi_v.append(record)
    aoki_v.append(record)
takahashi_v.sort(key=lambda x: (x[0] + x[1], x[0], -x[1]), reverse=True)
aoki_v.sort(key=lambda x: (x[0] + x[1], x[1], -x[0]), reverse=True)

res = 0
for _ in range(N):
    j = 0
    while j < N:
        if takahashi_v[j][2]:
            res += takahashi_v[j][0]
            takahashi_v[j][2] = False
            break
        j += 1
    if j >= N:
        break

    k = 0
    while k < N:
        if aoki_v[k][2]:
            res -= aoki_v[k][1]
            aoki_v[k][2] = False
            break
        k += 1
    if k >= N:
        break
print res

Fixed submission:
N = input()
val= []
for _ in xrange(N):
    a, b  = map(int, raw_input().split())
    val.append((a + b, a, b))
val.sort(reverse=True)

res = 0
for i, (v, a, b) in enumerate(val):
    res += a if i % 2 == 0 else -b
print res
Buggy python submission (verdict: Runtime Error):
N, P = map(int, raw_input().split())
if N == 1:
    print P
else:
    res = 2
    for i in range(2, int(N ** (1/2.)) + 1):
        if i ** N > P:
            break
        if P % (i ** N) == 0:
            res = i
    print res


Fixed submission:
N = raw_input()
print len([i for i in N if i == '2'])

Buggy python submission (verdict: Runtime Error):
N, P = map(int, raw_input().split())
i = 2
res = 1
if N == 1:
    print P
else:
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res


Fixed submission:
N = raw_input()
print len([i for i in N if i == '2'])

Buggy python submission (verdict: Runtime Error):
N, P = map(int, raw_input().split())
i = 2
res = 1
while i ** N <= P and N > 1:
    if P % (i ** N) == 0:
        res = i
    i += 1
print res


Fixed submission:
N = raw_input()
print len([i for i in N if i == '2'])
Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, raw_input().split())
if N == 1:
    print P
else:
    res = 1
    i = 2
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res


Fixed submission:
N, P = map(int, raw_input().split())
max_N = 40
if N == 1:
    print P
elif N >= max_N:
    print 1
else:
    res = 1
    i = 2
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res

Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, raw_input().split())
i = 2
res = 1
while i ** N <= P:
    if P % (i ** N) == 0:
        res = i
    i += 1
print res


Fixed submission:
N, P = map(int, raw_input().split())
max_N = 40
if N == 1:
    print P
elif N >= max_N:
    print 1
else:
    res = 1
    i = 2
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res
Buggy python submission (verdict: Time Limit Exceeded):
S = list(raw_input())
c = 0
while 'BW' in "".join(S):
    idx = "".join(S).index('BW')
    S[idx] = 'W'
    S[idx + 1] = 'B'
    c += 1

print c


Fixed submission:
S = raw_input()
n = 0
wc = 0
s_pos = 0
for i, c in enumerate(S):
    if c == "W":
        n += 1
        wc += i - s_pos
        s_pos = n

n = 0
bc = 0
s_pos = 0
for i, c in enumerate(reversed(S)):
    if c == "B":
        n += 1
        bc += i - s_pos
        s_pos = n

print max(wc, bc)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = input()
A = map(int, raw_input().split())
C = collections.Counter(A)
K = C.keys()
K.sort(reverse=1)
res = 0
for i in K:
    for j in xrange(60):
        p = 2 ** j
        if i > p:
            continue
        elif i == p:
            res += C[i] // 2
            C[i] = C[i] // 2 * 2
        else:
            num = min(C[i], C[p - i])
            res += num
            C[i] -= num
            C[p - i] -= num
print res


Fixed submission:
import collections

N = input()
A = map(int, raw_input().split())
C = collections.Counter(A)
K = C.keys()
K.sort(reverse=1)
res = 0
for i in K:
    for j in xrange(60):
        p = 2 ** j
        if i <= p:
            break
    if i == p:
      res += C[i] // 2
      C[i] = C[i] // 2 * 2
    else:
      num = min(C[i], C[p - i])
      res += num
      C[i] -= num
      C[p - i] -= num
print res

Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = input()
A = map(int, raw_input().split())
A.sort(reverse=1)
c = collections.Counter(A)
res = 0
for i in A:
    for j in xrange(60):
        p = 2 ** j
        if i > p:
            continue
        elif i == p:
            res += c[i] // 2
            c[i] = c[i] // 2 * 2
        else:
            num = min(c[i], c[p - i])
            res += num
            c[i] -= num
            c[p - i] -= num
print res


Fixed submission:
import collections

N = input()
A = map(int, raw_input().split())
C = collections.Counter(A)
K = C.keys()
K.sort(reverse=1)
res = 0
for i in K:
    for j in xrange(60):
        p = 2 ** j
        if i <= p:
            break
    if i == p:
      res += C[i] // 2
      C[i] = C[i] // 2 * 2
    else:
      num = min(C[i], C[p - i])
      res += num
      C[i] -= num
      C[p - i] -= num
print res
Buggy python submission (verdict: Runtime Error):
N = input()
A = [int(input()) for i in range(N)]

res = []
begin = 0
end = len(A) - 1
res =[]
res.append(A[begin])
res.append(A[end])
begin += 1
end -= 1

Fixed submission:
S = raw_input()

if len(S) == 2:
	print S
elif len(S) == 3:
	print "".join([i for i in reversed(S)])

Buggy python submission (verdict: Runtime Error):
from collections import deque
N = input()
A = [int(input()) for i in range(N)]

res = []
begin = 0
end = len(A) - 1
res = deque()
res.append(A[begin])
res.append(A[end])
begin += 1
end -= 1

Fixed submission:
S = raw_input()

if len(S) == 2:
	print S
elif len(S) == 3:
	print "".join([i for i in reversed(S)])