qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
import heapq


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y, a, b, c = list(map(int, readline().split()))
    p = list(map(int, readline().split()))
    q = list(map(int, readline().split()))
    r = [-1 * i for i in list(map(int, readline().split()))]
    p.sort(reverse=True)
    q.sort(reverse=True)
    hq = p[:x] + q[:y]
    heapq.heapify(hq)
    heapq.heapify(r)
    while len(r):
        hqv = heapq.heappop(hq)
        rv = -heapq.heappop(r)
        print(rv)
        if rv > hqv:
            heapq.heappush(hq, rv)
        else:
            heapq.heappush(hq, hqv)
            break
    print(sum(hq))


if __name__ == '__main__':
    solve()


Fixed code:
import sys
import heapq


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y, a, b, c = list(map(int, readline().split()))
    p = list(map(int, readline().split()))
    q = list(map(int, readline().split()))
    r = [-1 * i for i in list(map(int, readline().split()))]
    p.sort(reverse=True)
    q.sort(reverse=True)
    hq = p[:x] + q[:y]
    heapq.heapify(hq)
    heapq.heapify(r)
    while len(r):
        hqv = heapq.heappop(hq)
        rv = -heapq.heappop(r)
        if rv > hqv:
            heapq.heappush(hq, rv)
        else:
            heapq.heappush(hq, hqv)
            break
    print(sum(hq))


if __name__ == '__main__':
    solve()
Buggy code:
from heapq import heappush, heappop

X, Y, A, B, C = map(int, input().split())
H = []
for p in map(int, input().split()):
  heappush(H, ((-p, 'r')))
for q in map(int, input().split()):
  heappush(H, ((-q, 'g')))
for r in map(int, input().split()):
  heappush(H, ((-r, '')))

count = X + Y
ans = 0
while count > 0:
  h = heappop(H)
  if h[1] == 'r' and X > 0:
    X -= 1
    count -= 1
    ans -= h[0]
  elif h[1] == 'g' and Y > 0:
    Y -= 1
    count -= 1
    ans -= h[0]
  else:
    count -= 1
    ans -= h[0]

print(ans)

Fixed code:
from heapq import heappush, heappop

X, Y, A, B, C = map(int, input().split())
H = []
for p in map(int, input().split()):
  heappush(H, ((-p, 'r')))
for q in map(int, input().split()):
  heappush(H, ((-q, 'g')))
for r in map(int, input().split()):
  heappush(H, ((-r, '')))

count = X + Y
ans = 0
while count > 0:
  h = heappop(H)
  if h[1] == 'r' :
    if X > 0:
      X -= 1
      count -= 1
      ans -= h[0]
  elif h[1] == 'g':
    if Y > 0:
      Y -= 1
      count -= 1
      ans -= h[0]
  else:
    count -= 1
    ans -= h[0]

print(ans)
Buggy code:
X, Y, A, B, C = map(int,input().split())
listp = list(map(int, input().split()))
listq = list(map(int, input().split()))
listr = list(map(int, input().split()))

listp = sorted(listp, reverse=True)
listq = sorted(listq, reverse=True)
listr = sorted(listr, reverse=True)
listp = listp[:X]
listq = listq[:Y]
listr = listr[:X+Y]
print(listr)

eat_noapple = []
oisisa = 0

for noapple in listr:
    try:
        if listp[-1] >= listq[-1] and listq[-1] < noapple:
            listq.pop(-1)
            eat_noapple.append(noapple)
        elif listp[-1] < listq[-1] and listp[-1] < noapple:
            listp.pop(-1)
            eat_noapple.append(noapple)
    except:
        a = 0
    else:
        break
try:
    for papple in listq:
        oisisa += papple
except:
    a = 0
try:
    for qapple in listp:
        oisisa += qapple
except:
    a = 0
try:
    for rapple in eat_noapple:
        oisisa += rapple
except:
    a = 0
print(oisisa)

Fixed code:
X, Y, A, B, C = map(int,input().split())
listp = list(map(int, input().split()))
listq = list(map(int, input().split()))
listr = list(map(int, input().split()))

listp = sorted(listp, reverse=True)
listq = sorted(listq, reverse=True)
listr = sorted(listr, reverse=True)
listp = listp[:X]
listq = listq[:Y]
listr = listr[:X+Y]
listp.insert(0, 1000000000000)
listq.insert(0, 1000000000000)


eat_noapple = []
oisisa = 0

for noapple in listr:
    if listp[-1] >= listq[-1] and listq[-1] < noapple:
        listq.pop(-1)
        eat_noapple.append(noapple)
    elif listp[-1] < listq[-1] and listp[-1] < noapple:
        listp.pop(-1)
        eat_noapple.append(noapple)
    else:
        break
listp.pop(0)
listq.pop(0)

try:
    for papple in listq:
        oisisa += papple
except:
    a = 0
try:
    for qapple in listp:
        oisisa += qapple
except:
    a = 0
try:
    for rapple in eat_noapple:
        oisisa += rapple
except:
    a = 0
print(oisisa)
Buggy code:
X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()])

p = p[:X]
q = q[:Y]
plus_r = []

while r != [] and (p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1]):
    if p[-1] < q[-1]:
        p.pop()
    else:
        q.pop()
    plus_r.append(r.pop())

print(sum(p) + sum(q) + sum(plus_r))


Fixed code:
X, Y, A, B, C = map(int, input().split())
p = sorted([int(i) for i in input().split()], reverse=True)
q = sorted([int(i) for i in input().split()], reverse=True)
r = sorted([int(i) for i in input().split()])

p = p[:X]
q = q[:Y]
plus_r = []

while r != [] and ((p != [] and r[-1] > p[-1]) or (q != [] and r[-1] > q[-1])):
    if p == []:
        q.pop()
        plus_r.append(r.pop())
        continue
    elif q == []:
        p.pop()
        plus_r.append(r.pop())
        continue

    if p[-1] < q[-1]:
        p.pop()
    else:
        q.pop()
    plus_r.append(r.pop())

print(sum(p) + sum(q) + sum(plus_r))
Buggy code:
x,y,a,b,c =map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
n=p+q+r
n.sort(reverse=True)
n=n[:x+y]
print(sum(n))

Fixed code:
x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
p = p[:x]
q = q[:y]
ap = p + q + r
ap.sort(reverse=True)
print(sum(ap[:x+y]))
Buggy code:
x,y, a, b, c= map(int,input().split())
red = list(map(int,input().split()))
green = list(map(int,input().split()))
trans = list(map(int,input().split()))

fr = sorted(red, reverse= True)
fg = sorted(green, reverse= True)
candidate = fr + fg + trans
candidate = sorted(candidate, reverse= True)
candidate = candidate[:x+y]
print(sum(candidate))


Fixed code:
x,y, a, b, c= map(int,input().split())
red = list(map(int,input().split()))
green = list(map(int,input().split()))
trans = list(map(int,input().split()))

fr = sorted(red, reverse= True)[:x]
fg = sorted(green, reverse= True)[:y]
candidate = fr + fg + trans
candidate = sorted(candidate, reverse= True)
candidate = candidate[:x+y]
print(sum(candidate))
Buggy code:
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)
p2=p[:x]
q2=q[:y]
memop=x-1
memoq=y-1
sp=sum(p2)
sq=sum(q2)
k=0
flagp=0
flagq=0
while k<c:
    if memop<0:
        flagp=1
    if memoq<0:
        flagq=1
    if flagp*flagq==1:
        print(sp+sq)
        exit()
    elif flagq==1:
        if p2[memop]>=r[k]:
            print(sp+sq)
            exit()
        else:
            sp-=p2[memop]
            sp+=r[k]
            k+=1
            memop-=1
    elif flagp==1:
        if q2[memoq]>=r[k]:
            print(sp+sq)
            exit()
        else:
            sq-=q2[memoq]
            sq+=r[k]
            k+=1
            memoq-=1
    elif p2[memop]>=r[k] and q2[memoq]>=r[k] and flagp+flagq==0:
        print(sp+sq)
        exit()
    elif p2[memop]>q2[memoq]:
        sq-=q2[memoq]
        sq+=r[k]
        k+=1
        memoq-=1
    elif p2[memop]<=q2[memoq]:
        sp-=p2[memop]
        sp+=r[k]
        k+=1
        memop-=1


Fixed code:
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)
p2=p[:x]
q2=q[:y]
memop=x-1
memoq=y-1
sp=sum(p2)
sq=sum(q2)
k=0
flagp=0
flagq=0
while k<c:
    if memop<0:
        flagp=1
    if memoq<0:
        flagq=1
    if flagp*flagq==1:
        print(sp+sq)
        exit()
    elif flagq==1:
        if p2[memop]>=r[k]:
            print(sp+sq)
            exit()
        else:
            sp-=p2[memop]
            sp+=r[k]
            k+=1
            memop-=1
    elif flagp==1:
        if q2[memoq]>=r[k]:
            print(sp+sq)
            exit()
        else:
            sq-=q2[memoq]
            sq+=r[k]
            k+=1
            memoq-=1
    elif p2[memop]>=r[k] and q2[memoq]>=r[k] and flagp+flagq==0:
        print(sp+sq)
        exit()
    elif p2[memop]>q2[memoq]:
        sq-=q2[memoq]
        sq+=r[k]
        k+=1
        memoq-=1
    elif p2[memop]<=q2[memoq]:
        sp-=p2[memop]
        sp+=r[k]
        k+=1
        memop-=1
print(sp+sq)
Buggy code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayAns)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

Fixed code:
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(min(len(arrayR), len(arrayAns))):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))
Buggy code:
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  insort(p_list,  int(value))

for value in input().split():
  insort(q_list,  int(value))
  
for value in input().split():
  insort(r_list,  int(value))
  
red = 0
green = 0
white = 0

sum_num = 0

print(sum_num)
for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

Fixed code:
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)
Buggy code:
X, Y, a, b, c = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
s = sorted(p)[::-1][:X] + sorted(q)[::-1][:X] + r
ans = sum(s[:X + Y])
print(ans)                   

Fixed code:
X, Y, a, b, c = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
s = sorted(p)[::-1][:X] + sorted(q)[::-1][:Y] + r
s = sorted(s)[::-1]
ans = sum(s[:X + Y])
print(ans)
Buggy code:
x,y,A,B,C = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

a = sorted(a)[::-1]
b = sorted(b)[::-1]
c = sorted(c)[::-1]

a = a[:x]
b = b[:y]
ans = a+b
ans = sorted(ans)
# ans = ans[::-1]
index = 0
# print(ans)
# print(c)
for i in range(0,C):
    if(c[i] > ans[index]):
        ans[index] = c[i]
        index = index + 1
    else:
        break

    if(index == x+y):
        break
print(ans)
print(sum(ans))



Fixed code:
x,y,A,B,C = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

a = sorted(a)[::-1]
b = sorted(b)[::-1]
c = sorted(c)[::-1]

a = a[:x]
b = b[:y]
ans = a+b
ans = sorted(ans)
# ans = ans[::-1]
index = 0
# print(ans)
# print(c)
for i in range(0,C):
    if(c[i] > ans[index]):
        ans[index] = c[i]
        index = index + 1
    else:
        break

    if(index == x+y):
        break
# print(ans)
print(sum(ans))
Buggy code:
[X, Y, A, B, C] = list(map(int, input().split()))

p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

eatCandi = p[0:X] + q[0:Y] + r[0:X+Y]
print(sum(eatCandi[0:X+Y]))

Fixed code:
[X, Y, A, B, C] = list(map(int, input().split()))

p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

eatCandi = sorted(p[0:X] + q[0:Y] + r[0:X+Y], reverse=True)

print(sum(eatCandi[0:X+Y]))
Buggy code:
a,b,k = map(int,input().split())
bit = 0
while k:
  if bit==0:
    if a%2!=0:
      a -= 1
    b += a//2
    a //= 2
  else:
    if b!=0:
      b -= 1
    a += b//2
    b //2
  k -= 1
print(a,b)

Fixed code:
a,b,k = map(int,input().split())
bit = 0
while k:
  if bit==0:
    if a%2!=0:
      a -= 1
    b += a//2
    a //= 2
    bit = 1
  else:
    if b%2!=0:
      b -= 1
    a += b//2
    b //= 2
    bit = 0
  k -= 1


print(a,b)
Buggy code:
A, B, K = map(int, input().split())
cnt = 0
while cnt < K:
    if A % 2:
        A -= 1
    B += A//2
    A //= 2
    cnt += 1
    if B % 2:
        B -= 1
    A += B//2
    B //= 2
    cnt += 1

print(A, B)


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

cnt=0
while K:
  if cnt%2==0:
    if A%2==1:
      A-=1
    B+=A//2
    A//=2
  else:
    if B%2==1:
      B-=1
    A+=B//2
    B//=2  
  K-=1
  cnt+=1
  
print(A,B)
Buggy code:
a, b, c = map(int, input().split())
for i in range(c):
  if c % 2 == 0:
    if a % 2 == 1:
      a -= 1
    b += a // 2
    a //= 2
  else:
    if b % 2 == 1:
      b-= 1
    a += b // 2
    b //= 2
print(a, b)

Fixed code:
a,b,c = map(int,input().split())
x = 0
for i in range(c):
    if (int(i) + 2) % 2 == 0:
        if (a + 1) % 2 == 0:
            a = a - 1
            x = int(a / 2)
            b = b + x
            a = a - x
        else:
            x = int(a / 2)
            b = b + x
            a = a - x
    else:
        if (b + 1) % 2 == 0:
            b = b - 1
            x = int(b / 2)
            a = a + x
            b = b - x
        else:
            x = int(b / 2)
            a = a + x
            b = b - x
print(a,b)
Buggy code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
        K -= 1


    print(A," ",B)
            


        

if __name__ == '__main__':
    solve()


Fixed code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
            turn ^= 1
        K -= 1

    A = (int)(A)
    B = (int)(B)
    print(A,B)
            


        

if __name__ == '__main__':
    solve()
Buggy code:
#coding:utf-8
a, b, k = map(int, input().split())

for i in range(0, k):
    if i % 2 == 0:
        b += a // 2
        a /= 2
    else:
        a += b // 2
        b /= 2

print(a, b)

Fixed code:
#coding:utf-8
a, b, k = map(int, input().split())

for i in range(0, k):
    if i % 2 == 0:
        b += a // 2
        a = a // 2
    else:
        a += b // 2
        b = b // 2

print(a, b)
Buggy code:
A, B, K = [int(s) for s in input().split(' ')]
print(A, B, K)

for i in range(K):
  if i % 2:
    B //= 2
    A += B
  else:
    A //= 2
    B += A
print ('%d %d' % (A, B))
    

Fixed code:
A, B, K = [int(s) for s in input().split(' ')]
for i in range(K):
  if i % 2:
    B //= 2
    A += B
  else:
    A //= 2
    B += A
print ('%d %d' % (A, B))
Buggy code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2!=0:
        a=a//2
        b+=a//2
    else:
        a+=b//2
        b=b//2
print(a,b)

Fixed code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        b+=a//2
        a=a//2
    if i%2!=0:
        a+=b//2
        b=b//2
print(a,b)
Buggy code:
# tenka1-2018-beginnerB - Exchange
def main():
    A, B, K = tuple(map(int, input().split()))
    for i in range(K):
        if i & 1:
            if A & 1:
                A -= 1
            A //= 2
            B += A
        else:
            if B & 1:
                B -= 1
            B //= 2
            A += B
    print(A, B)


if __name__ == "__main__":
    main()

Fixed code:
# tenka1-2018-beginnerB - Exchange
def main():
    A, B, K = tuple(map(int, input().split()))
    for i in range(K):
        if i & 1 == 0:
            if A & 1:
                A -= 1
            A //= 2
            B += A
        else:
            if B & 1:
                B -= 1
            B //= 2
            A += B
    print(A, B)


if __name__ == "__main__":
    main()
Buggy code:
A,B,K = map(int,input().split())
count = 0
for i in range(100):
  if count ==K:
    break
  else:
    if A%2 == 1:
      A = A-1
    B = B + A/2
    A = A/2
    count += 1
  if count == K:
    break
  else:
    if B%2 == 1:
      B = B-1
    A = A+ B/2
    B = B/2
    count += 1
print(A,B)

Fixed code:
A,B,K = map(int,input().split())
count = 0
for i in range(100):
  if count ==K:
    break
  else:
    if A%2 == 1:
      A = A-1
    B = B + A/2
    A = A/2
    count += 1
  if count == K:
    break
  else:
    if B%2 == 1:
      B = B-1
    A = A+ B/2
    B = B/2
    count += 1
print(int(A),int(B))
Buggy code:
A, B, K = map(int,input().split())
for i in range(K):
  if K % 2 == 0:
    A = A // 2
    B += A
  else:
    B = B // 2
    A += B
print(int(A), int(B))


Fixed code:
A, B, K = map(int, input().split())
Nt = A
Na = B
for i in range(K):
  if i%2==0:
    Nt, Na = Nt//2, Na + (Nt//2)
  else:
    Nt, Na = Nt + (Na//2), Na//2
print(Nt, Na)
Buggy code:
import math
inp = input().split()

a = int(inp[0])
b = int(inp[1])
k = int(inp[2])


def cookie(giver,getter):
    if giver%2 == 0:
        sub = math.floor(giver/2)
        giver = giver - sub
        getter = getter + sub
    else:
        tmp = giver - 1
        sub = math.floor(tmp/2)
        giver = giver - 1 - sub
        getter = getter +  sub


for i in range(k):
    if i%2 == 0:
        cookie(a,b)
    else:
        cookie(b,a)



print(a,b)


Fixed code:
import math
inp = input().split()

a = int(inp[0])
b = int(inp[1])
k = int(inp[2])


def cookie(giver,getter):
    if giver%2 == 0:
        sub = math.floor(giver/2)
        giver = giver - sub
        getter = getter + sub
    else:
        tmp = giver - 1
        sub = math.floor(tmp/2)
        giver = giver - 1 - sub
        getter = getter +  sub


for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            sub = math.floor(a / 2)
            a = a - sub
            b = b + sub
        else:
            tmp = a - 1
            sub = math.floor(tmp / 2)
            a = a - 1 - sub
            b = b + sub
    else:
        if b%2 == 0:
            sub = math.floor(b/ 2)
            b = b - sub
            a = a + sub
        else:
            tmp = b - 1
            sub = math.floor(tmp / 2)
            b = b - 1 - sub
            a = a + sub


print(a,b)
Buggy code:
A, B, K = map(int, input())
for i in range(K):
	if i % 2 == 0:
		# takahashi
		if A % 2 == 1:
			A -= 1
		A, B = A // 2, B + A // 2
	else:
		# aoki
		if B % 2 == 1:
			B -= 1
		A, B = A + B // 2, B // 2
print(A, B)


Fixed code:
A, B, K = map(int, input().split())
for i in range(K):
	if i % 2 == 0:
		# takahashi
		if A % 2 == 1:
			A -= 1
		A, B = A // 2, B + A // 2
	else:
		# aoki
		if B % 2 == 1:
			B -= 1
		A, B = A + B // 2, B // 2
print(A, B)
Buggy code:
a,b,k = map(int,input().split())

turn = True
for _ in range(k):
    if turn:
        if a % 2 is 1:
            a -= 1
            a = a/2
            b += a
            turn = False
        else:
            a = a/2
            b += a
            turn = False
    else:
        if b % 2 is 1:
            b -= 1
            b = b/2
            a += b
            turn = True
        else:
            b = b/2
            a += b
            turn = True
print(int(a),int(b))

Fixed code:
a,b,k = map(int,input().split())
flag = True
for _ in range(k):
    if flag:
        if a%2==1:
            a-=1
        a = a//2
        b += a
        flag=False
    else:
        if b%2==1:
            b-=1
        b = b//2
        a += b
        flag=True
print(a,b)
Buggy code:
S = input().split()
A = int(S[0])
B = int(S[1])
K = int(S[2])
print(A, B, K)

for k in range(K):
    if k % 2 == 0: #taka 
        if A % 2 == 1:
            A -= 1
        B_plus = A//2
        A -= B_plus
        B += B_plus
        #print(A, B)
    else:        
        if B % 2 == 1:
            B -= 1
        A_plus = B//2
        B -= A_plus
        A += A_plus
        #print(A, B)
        
print(A,B)


Fixed code:
S = input().split()
A = int(S[0])
B = int(S[1])
K = int(S[2])
#print(A, B, K)

for k in range(K):
    if k % 2 == 0: #taka 
        if A % 2 == 1:
            A -= 1
        B_plus = A//2
        A -= B_plus
        B += B_plus
        #print(A, B)
    else:        
        if B % 2 == 1:
            B -= 1
        A_plus = B//2
        B -= A_plus
        A += A_plus
        #print(A, B)
        
print(A,B)
Buggy code:
A,B,K=map(int, input().split())
List = [A,B]
for i in range(K):
  if(List[i]%2==1):
    List[i]=(list[i]-1)//2
    List[i+1]=list[i+1]+List[i]
    List.append(List[i])
  else:
    List[i]=(list[i])//2
    List[i+1]=list[i+1]+List[i]
    List.append(List[i])
print(List[-2],List[-1])

Fixed code:
A,B,K=map(int, input().split())
List = [A,B]
for i in range(K):
  if(List[i]%2==1):
    List[i]=(List[i]-1)//2
    List[i+1]=List[i+1]+List[i]
    List.append(List[i])
  else:
    List[i]=(List[i])//2
    List[i+1]=List[i+1]+List[i]
    List.append(List[i])
#print(List[-3],List[-2])
if(K%2==1):
  print(List[-1],List[-2])
else:
  print(List[-2],List[-1])
Buggy code:
#!/usr/bin/env python3

A, B, K = map(int,input().split())

for i in range(K):
    if A % 2 == 1:
        A -= 1

    B += A / 2
    A -= A / 2
    
    if B % 2 == 1:
        B -= 1
    
    A += B / 2
    B = B / 2

print(A, B)




Fixed code:
#!/usr/bin/env python3
A, B, K = map(int, input().split())
for i in range(K):
    if i % 2 == 0:
        A = (A - A % 2) // 2
        B += A
    else:
        B = (B - B % 2) // 2
        A += B
print(A, B)