Problem:


Score : 200 points

Problem Statement

In the beginning, Takahashi has A cookies, and Aoki has B cookies.
They will perform the following operation alternately, starting from Takahashi:

If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.

Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

Constraints

1 \leq A,B \leq 10^9

1 \leq K \leq 100

A,B and K are integers.

Input

Input is given from Standard Input in the following format:

A B K

Output

Print the number of cookies Takahashi has, and the number of cookies Aoki has, in this order, after performing K operations in total.

Sample Input 1

5 4 2

Sample Output 1

5 3

The process will go as follows:

In the beginning, Takahashi and Aoki have 5 and 4 cookies, respectively.

Takahashi eats one cookie and gives two cookies to Aoki. They now have 2 and 6 cookies, respectively.

Aoki gives three cookies to Takahashi. They now have 5 and 3 cookies, respectively.

Sample Input 2

3 3 3

Sample Output 2

1 3

Sample Input 3

314159265 358979323 84

Sample Output 3

448759046 224379523



Sample input:
5 4 2


Sample output:
5 3

Submission status: Accepted

Solution code:
def b_exchange(A, B, K):
    takahashi_cookie = A
    aoki_cookie = B
    turn = 0
    while turn < K:
        if turn % 2 == 0:
            if takahashi_cookie % 2 == 1:
                takahashi_cookie -= 1
            takahashi_cookie //= 2
            aoki_cookie += takahashi_cookie
        else:
            if aoki_cookie % 2 == 1:
                aoki_cookie -= 1
            aoki_cookie //= 2
            takahashi_cookie += aoki_cookie
        turn += 1
    ans = '{0} {1}'.format(takahashi_cookie, aoki_cookie)
    return ans

A, B, K = [int(i) for i in input().split()]
print(b_exchange(A, B, K))

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
for i in range(k):
  if i%2 == 0:
    if a%2 != 0 :
      a -=1
    a /= 2
    b += a
  else :
    if b%2 != 0:
      b -= 1
    b /= 2
    a += b
print(int(a),int(b))

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
turn=0
for i in range(k):
    if(turn==0):
        if(a%2==0):
            b+=a//2
            a-=a//2
        else:
            a-=1
            b+=a//2
            a-=a//2
        turn=1
    else:
        if(b%2==0):
            a+=b//2
            b-=b//2
        else:
            b-=1
            a+=b//2
            b-=b//2
        turn=0
print(a,b)

Submission status: Accepted

Solution code:
a,b,k = (int(i) for i in input().split())
c = 0
for i in range(k):
	if c: a,b,c = a+b//2,b//2,0
	else: a,b,c = a//2,b+a//2,1
print(a,b)

Submission status: Accepted

Solution code:
A, B, K = map(int, raw_input().split())
for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A = A - 1
        B = B + A / 2
        A = A / 2
    else:
        if B % 2 != 0:
            B = B - 1
        A = A + B / 2
        B = B / 2
print(A)
print(B)

Submission status: Accepted

Solution code:
A, B, K = input().split()

A = int(A)
B = int(B)
K = int(K)

for i in range(K):
	if i % 2 == 0:
		A //= 2
		B += A 
	else:
		B //= 2
		A += B 
print(str(A) + " " + str(B))

Submission status: Accepted

Solution code:
*x,K=map(int,input().split())
for i in([0,1]*K)[:K]:x[i]//=2;x[~i]+=x[i]
print(*x)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
for i in range(K):(A,B)=(B+A//2,A//2)
print(*(A,B)[::1-K%2*2])

Submission status: Accepted

Solution code:
a, b, k=map(int, input().split())
for i in range(k):
  if i%2==0:
    a=a//2
    b+=a
  else:
    b=b//2
    a+=b
print("%d %d" % (a, b))

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
    if i%2>0:b//=2;a+=b
    else:a//=2;b+=a
print(a,b)

Submission status: Accepted

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

for n in range(K):
    if n % 2 ==0:
        if A % 2 != 0:
            A -= 1
        C = A // 2
        A -= C
        B += C
    else:
        if B % 2 != 0:
            B -= 1
        C = B // 2
        A += C
        B -= C
print('{} {}'.format(A, B))

Submission status: Accepted

Solution code:
*AB, K = map(int, input().split())
for i in range(K):
    AB[i % 2] //= 2
    AB[i % 2 ^ 1] += AB[i % 2]
print(*AB)

Submission status: Accepted

Solution code:
*AB, K = map(int, input().split())
turn = 0
for _ in range(K):
    AB[turn ^ 1] += AB[turn] // 2
    AB[turn] //= 2
    turn ^= 1
print(*AB)

Submission status: Accepted

Solution code:
*AB, K = map(int, input().split())
turn = 0
for _ in range(K):
    AB[turn] -= AB[turn] % 2
    AB[turn ^ 1] += AB[turn] // 2
    AB[turn] //= 2
    turn ^= 1
print(*AB)

Submission status: Accepted

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

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

        A,B=A//2,B+A//2

    else:
        if B%2==1:
            B-=1

        A,B=A+B//2,B//2

print(A,B)

Submission status: Accepted

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

def COOKIE(A,B):
    if A%2==1:A -= 1
    B += A//2
    A //= 2
    return A,B

for i in range(K):
    if i%2==0: A,B = COOKIE(A,B)
    else: B,A = COOKIE(B,A)
    
print(A,B)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

def fa(a,b,k):
  if k == 0:
    return a, b
  elif b % 2 == 0:
    return ft(a + b/2, b/2, k-1)
  else:
    return ft(a + (b-1)/2, (b-1)/2, k-1)

def ft(a,b,k):
  if k == 0:
    return a, b
  elif a % 2 == 0:
    return fa(a/2, a/2 + b,k-1)
  else:
    return fa((a-1)/2,(a-1)/2+b,k-1)


def main():
  a, b, k = map(int, input().split())
  ra, rb = ft(a,b,k)
  print(int(ra), int(rb))

main()

Submission status: Accepted

Solution code:
list_num = [int(i) for i in input().split()]

players = list_num[0:2]
k = list_num[-1]

for i in range(k):
    players[i%2] = players[i%2]//2
    players[(i+1)%2] += players[i%2]

print(players[0], players[1])

Submission status: Accepted

Solution code:
a, b, c= (int(i) for i in input().split())
for i in range(c):
 if(i%2==0):
  a=a//2
  b=b+a
 else:
  b=b//2
  a=a+b
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 ==0:
        if a % 2 == 0:
            a = a/2
            b = b+a
            
        else:
            a = (a-1)/2
            b = b+a
            
    if i % 2 == 1:
        if b % 2 == 0:
            b = b/2
            a = b+a
            
        else:
            b = (b-1)/2
            a = b+a
            
print(int(a), int(b))

Submission status: Accepted

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

while True:
    if K<=0:
        break
    if A % 2 == 1:
        A -= 1
    t = A//2
    A -= t
    B += t
    K -= 1
    
    if K<=0:
        break
    if B % 2 == 1:
        B -= 1
    t = B//2
    B -= t
    A += t
    K -= 1
        
print(A, B)

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
for i in range(K):
    if i%2 == 0:
        A, B = (A//2), (B + A//2)
    else:
        A, B = (A + B//2), (B//2)

print(A, B)

Submission status: Accepted

Solution code:
*a,k=map(int,input().split())
for i in range(k):a[i%2]//=2;a[-~i%2]+=a[i%2]
print(*a)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
 if i%2:b//=2;a+=b
 else:a//=2;b+=a
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
 if i%2:a+=b//2;b//=2
 else:b+=a//2;a//=2
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
for i in range(k):
 if i%2<1:b+=a//2;a//=2
 else:a+=b//2;b//=2
print(a,b)

Submission status: Accepted

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

if K%2==0:
    for _ in range(int(K/2)):
        if A%2==0:
            A=A/2
            B=B+A
        else:
            A=A-1
            A=A/2
            B=B+A
        if B%2==0:
            B=B/2
            A=A+B
        else:
            B=B-1
            B=B/2
            A=A+B

else:
    for _ in range(int((K-1)/2)):
        if A%2==0:
            A=A/2
            B=B+A
        else:
            A=A-1
            A=A/2
            B=B+A
        if B%2==0:
            B=B/2
            A=A+B
        else:
            B=B-1
            B=B/2
            A=A+B
    if A%2==0:
            A=A/2
            B=B+A
    else:
        A=A-1
        A=A/2
        B=B+A

print(str(int(A))+" "+str(int(B)))

Submission status: Accepted

Solution code:
a,b,k=[int(x) for x in input().split()]
for i in range(k):
    if i%2:
        b//=2
        a+=b
    else:
        a//=2
        b+=a
print(a,b)

Submission status: Accepted

Solution code:
a,b,k=[int(x) for x in input().split()]
for i in range(k):
    if i%2:
        b//=2
        a+=b
    else:
        a//=2
        b+=a
print(a,b)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

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

print(a, b)

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
for k in range(K):
  if k % 2 == 0:
    if A % 2 == 1:
      A -= 1
      
    B += A // 2    
    A -= A // 2
 
  else:
    if B % 2 == 1:
      B -= 1
    A += B // 2    
    B -= B // 2

print(A, B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())

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

Submission status: Accepted

Solution code:
a, b, c = map(int, input().split())
for i in range(c):
  if i % 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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
number = input().strip().split(' ')
number_list = list(map(int,number))
A = number_list[0]
B = number_list[1]
K = number_list[2]

while K > 0:
    if A % 2 == 0:
        A = A
    else:
        A = A - 1
    A = A / 2
    B = B + A
    K = K - 1
    if K > 0:
        if B % 2 == 0:
            B = B
        else:
            B = B - 1
        B = B / 2
        A = A + B
        K = K - 1
print(str(int(A)) + ' ' + str(int(B)))

Submission status: Accepted

Solution code:
s = input().split(" ")
A = int(s[0])
B = int(s[1])
K = int(s[2])

for i in range(K):
    if(i%2 == 0):
        if (A%2) == 1:
            A -= 1
        A = A/2
        B = B + A
    elif(i%2==1):
        if (B%2) == 1:
            B -= 1
        B = B/2
        A = A+B

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(100):
    if i >= k:
        break

    if not(i%2):
        if a%2:
            a -= 1
        a /= 2
        b += a
    else:
        if b%2:
            b -= 1
        b /= 2
        a += b


print(int(a), int(b))

Submission status: Accepted

Solution code:
# coding: utf-8
def process(src, dst):
    # 偶数：何もしない
    # 奇数：1枚ならべる(1枚減る)
    if src % 2 == 0:
        pass
    else:
        src -= 1

    # 半分を相手に渡す
    # 自分：半分減
    # 相手：半分の値増
    src = src / 2
    dst += src

    return src, dst


# 入力
indata = input().split()
A = int(indata[0])
B = int(indata[1])
K = int(indata[2])

# 初期所持枚数
takahashi = A
aoki = B

# 操作をK回繰り返す
for i in range(K):
    if i % 2 == 0:
        # 高橋君のターン
        takahashi, aoki = process(takahashi, aoki)
    else:
        # 青木君のターン
        aoki, takahashi = process(aoki, takahashi)

# 結果
print(int(takahashi), int(aoki))

Submission status: Accepted

Solution code:
a, b ,k = map(int,input().split())
turn = True
for i in range(k):
    if turn :
        if a % 2 == 1:
            b = b + (a - 1) / 2
            a = (a - 1) / 2
        else :
            b = b + a /2
            a = a / 2
    else :
        if b % 2 == 1:
            a = a + (b - 1) / 2
            b = (b - 1) / 2
        else :
            a = a + b /2
            b = b / 2
    turn = not turn
print(str(int(a)) +" " + str(int(b)))

Submission status: Accepted

Solution code:
A,B,K = [int(i) for i in input().split()]

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

Submission status: Accepted

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

for k in range(K):
	if k%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)

Submission status: Accepted

Solution code:
# -*- coding-UTF-8 -*-
A, B, K = map(int, input().split())

i = 0
while True:
    i += 1
    if A%2:
         A -= 1
    A /= 2
    B += A
    if i == K:
        break
    i += 1
    if B%2:
        B -= 1
    B /= 2
    A += B
    if i == K:
        break
print(int(A),int(B))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
if K%2==0:
	K=K/2
	for i in range(int(K)):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
else:
	K=(K-1)/2
	for i in range(int(K)):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
	
	if A%2==0:
		A=A/2
		B=B+A
	else:
		A=(A-1)/2
		B=A+B
	
print(str(int(A))+" "+str(int(B)))

Submission status: Accepted

Solution code:
import sys

array = list(map(int, input().strip().split(' ')))

A = array[0]
B = array[1]
K = array[2]

#print(A)
#print(B)
#print(K)

if A < 1:
    sys.exit()
if A > 10**9:
    sys.exit()

#print("Aok")


if B < 1:
    sys.exit()
if B > 10**9:
    sys.exit()

#print("Bok")


if K < 1:
    sys.exit()
if K > 100:
    sys.exit()


#print("Kok")

#print(K)

#i = 0

kaisu = 0 

for i in range(K):

    #print("i",i)

    kaisu = kaisu + 1
    
    if kaisu % 2 ==1:

        if A % 2 == 1:
        #kisu
        #print("A kisu")
            A = A - 1

        work_a = int(A / 2)
    
        A = A - work_a

        B = B + work_a

        
    elif kaisu % 2 ==0:
    
        if B % 2 == 1:
            #kisu
            #print("B kisu")
            B = B - 1
     
        work_b = int(B / 2)

        #print("work_b",work_b)

    
        A = A + work_b

        B = B - work_b
    
            #print("roop_e")
    

print(A,end='')
print(' ',end='')
print(B,end='')

Submission status: Accepted

Solution code:
A_B_K = list(map(int, input().split()))
for i in range(A_B_K[2]):
    if A_B_K[i%2] % 2 == 1:
        A_B_K[i%2] -= 1

    A_B_K[i%2] = A_B_K[i%2]/2
    A_B_K[(i+1)%2] = A_B_K[(i+1)%2] + A_B_K[i%2]

out_list = [A_B_K[0],A_B_K[1]]
out_list = list(map(int, out_list))
out_list = list(map(str, out_list))
out = ' '.join(out_list)
print(out)

Submission status: Accepted

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

k = 0
while True:

    if A % 2 != 0:
            
        A -= 1

    #print('a-1',A, B)

    B += round(A/2)
    A -= round(A/2)

    #print('a-2', A, B)
    k += 1
    if k == K:
        break

    if B % 2 != 0:
        
        B -= 1

    #print('b-1', A, B)

    A += round(B/2)
    B -= round(B/2)

    #print('b-2', A, B)
    k += 1
    if k == K:
        break

print(A, B)

Submission status: Accepted

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

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

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

if K>=3:
    for i in range(1,K,2):
        if A % 2 ==1:
            A =A-1
        A =A/2
        B=B+A
        if B % 2==1:
            B=B-1
        B=B/2
        A=A+B

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


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

Submission status: Accepted

Solution code:
count_cookie = str(input())
count_cookie = count_cookie.split()
i = 0
while i < len(count_cookie):
    count_cookie[i] = int(count_cookie[i])
    i += 1

count = 0
while count < count_cookie[2]:
    if count % 2 == 0:
        if count_cookie[0] % 2 != 0:
            count_cookie[0] = count_cookie[0] - 1
            give_cookie = count_cookie[0] / 2
            count_cookie[0] = count_cookie[0] - give_cookie
            count_cookie[1] = count_cookie[1] + give_cookie
        else:
            give_cookie = count_cookie[0] / 2
            count_cookie[0] = count_cookie[0] - give_cookie
            count_cookie[1] = count_cookie[1] + give_cookie
    else:
        if count_cookie[1] % 2 != 0:
            count_cookie[1] = count_cookie[1] - 1
            give_cookie2 = count_cookie[1] / 2
            count_cookie[1] = count_cookie[1] - give_cookie2
            count_cookie[0] = count_cookie[0] + give_cookie2
        else:
            give_cookie2 = count_cookie[1] / 2
            count_cookie[1] = count_cookie[1] - give_cookie2
            count_cookie[0] = count_cookie[0] + give_cookie2

    count += 1

print("{0:.0f} {1:.0f}".format(count_cookie[0],count_cookie[1]))

Submission status: Accepted

Solution code:
#encoding utf-8

a,b,k = map(int, input().split())
# print(a,b,k)

for i in range(k):
    if i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += int(a/2)
        a = int(a/2)
    # turn b
    else:
        if b%2 == 1:
            b -= 1
        a += int(b/2)
        b = int(b/2)



print(a,b)

Submission status: Accepted

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

print(a,b)

Submission status: Accepted

Solution code:
A,B,K=[int(i) for i in input().split()]
for i in range(K):
    if i%2==0:
        if A%2==1:
            A-=1
        A=A/2
        B+=A
    else:
        if B%2==1:
            B-=1
        B=B/2
        A+=B
print("{} {}".format(int(A),int(B)))

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())

for i in range(k):
    if i%2==0:
        if a%2!=0:
            a-=1
        b += int(a/2)
        a -= int(a/2)
    else:
        if b%2!=0:
            b-=1
        a += int(b/2)
        b -= int(b/2)
print(a,b)

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())

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

print("{} {}".format(int(a), int(b)))

Submission status: Accepted

Solution code:
a,b,K = map(int,input().split())
def exchange(A,B):
    if A%2 == 1:
        A -= 1
    C = A//2
    B += C
    A -= C
    return((A,B))
for i in range(K):
    if i%2 == 0:
        a,b=exchange(a,b)
    else:
        b,a=exchange(b,a)
print(a,b)

Submission status: Accepted

Solution code:
def run(A, B, K):
    for i in range(K):
        if i % 2 == 0:
            if A % 2 == 1:
                A -= 1
            A /= 2
            B += A
        else:
            if B % 2 == 1:
                B -= 1
            B /= 2
            A += B
    return '{} {}'.format(int(A), int(B))


def main():
    A, B, K = map(int, input().split())
    print(run(A, B, K))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, K = [int(i) for i in input().split()]

for i in range(K):
    if A%2 == 1 and i%2 == 0:
        A += -1
        B += int(A/2)
        A = int(A/2)
    elif A%2 == 0 and i%2 == 0:
        B += int(A/2)
        A = int(A/2)
    elif B%2 == 1 and i%2 == 1:
        B += -1
        A += int(B/2)
        B = int(B/2)
    elif B%2 == 0 and i%2 == 1:
        A += int(B/2)
        B = int(B/2)

print(A, end=' ')
print(B)

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())

for i in range(1,k+1):
    if i % 2 != 0:
        if a % 2 != 0:
            a = a-1
        a = a/2
        b = b + a
    else:
        if b % 2 != 0:
            b = b - 1
        b = b/2
        a = a + b
print(int(a),int(b))

Submission status: Accepted

Solution code:
a=input().split()
A=int(a[0])
B=int(a[1])
K=int(a[2])
time=0

while True:
    if K == time:
        break
    else:
        time += 1
        if time % 2 == 1:
            if A % 2 == 1:
                A -=1
            A = int(A / 2)
            B += A
        else:
            if B % 2 == 1:
                B -=1
            B = int(B / 2)
            A += B

print(A, B)

Submission status: Accepted

Solution code:
(A,B,K) = map(int,input().split())
for i in range(K):
    if i % 2:
        B = B //2
        A = A + B

    else:
        A = A // 2
        B = B + A
print(A,B)

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
a = i[0]
b = i[1]
k = i[2]

def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

for i in range(k):
    if is_even(a):
        a = a / 2
        b = b + a

        tmp = a
        a = b
        b = tmp
    else:
        a = a - 1
        a = a / 2
        b = b + a

        tmp = a
        a = b
        b = tmp

if is_even(k):
    print(int(a), int(b))
else:
    tmp = a
    a = b
    b = tmp
    print(int(a), int(b))

Submission status: Accepted

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

i = 0
while i < K:
    if i%2 == 0:
        if A%2 == 1:
            A -= 1
        AtoB = int(A/2)
        A = A - AtoB 
        B = B + AtoB 
    else:    
        if B%2 == 1:
            B -= 1
        BtoA = int(B/2)
        A = A + BtoA 
        B = B - BtoA
    i += 1
print(str(A) + ' ' + str(B))

Submission status: Accepted

Solution code:
a, b, k = map(int,input().split())
cnt = 0
while True:
    if cnt==k:
        break
    if a%2!=0:
        a-=1
    b+=a/2
    a = a/2
    cnt+=1
    if cnt==k:
        break
    if b%2!=0:
        b-=1
    a+=b/2
    b = b/2
    cnt+=1

print(int(a),int(b))

Submission status: Accepted

Solution code:
a, b, k = input().split()
A = int(a)
B = int(b)
K = int(k)
for i in range(K):
  if i%2 == 0:
    if A%2 == 1:
      A -= 1
    B += A/2
    A -= A/2
  else:
    if B%2 == 1:
      B -= 1
    A += B/2
    B -= B/2
ans1 = str(int(A))
ans2 = str(int(B))
print(ans1 + " " + ans2)

Submission status: Accepted

Solution code:
[a,b,k] = list( map(int, input().split() ) )
for i in range(k):
	if a%2 == 1:
		a -= 1
	a //= 2
	b += a
	c = a
	a = b
	b = c
if k%2 == 1:
	c = a
	a = b
	b = c
print('{} {}'.format(a,b) )

Submission status: Accepted

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

def sousa(x,y):
  if x%2 == 0:
    x=int(x-x/2)
    y=int(y+x)
  else:
    x = int(x-1-(x-1)/2)
    y = int(y+x)
  return x,y

X = A
Y = B
for i in range(K):
  Number = sousa(X,Y)
  X = Number[1]
  Y = Number[0]
if K%2 == 0:
  output = (X,Y)
else:
  output = (Y,X)

print(output[0],output[1])

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
a, b, k = map(int, input().split())
for i in range(k):
    if i%2 == 0:
        if a%2 == 0:
            a = int(a/2)
        else:
            a = int((a-1)/2)
        b += a
    else:
        if b%2 == 0:
            b = int(b/2)
        else:
            b = int((b-1)/2)
        a += b
print(a, b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a,b,k = map(int, input().split(' '));

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

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if (i%2==0):
        if (a%2==1):
            a-=1
        a//=2
        b+=a
    else:
        if (b%2==1):
            b-=1
        b//=2
        a+=b
print(a, b)

Submission status: Accepted

Solution code:
a,b,c=map(int,input().split());lis=[a,b]
for i in range(c):
    if lis[i%2]%2==1:lis[i%2]-=1
    lis[(i+1)%2]+=lis[i%2]/2;lis[i%2]/=2
print(int(lis[0]),int(lis[1]))

Submission status: Accepted

Solution code:
N = list(map(int, input().split()))
A = N[0]
B = N[1]
K = N[2]

# A = 5 # 高橋君
# B = 4 # 青木君
# K = 2 # 操作回数

def cookie(my_num, your_num):
    # my_num 自分のクッキー枚数
    if my_num % 2 == 0:
        # 偶数の場合
        # 自分の残りクッキー、相手の残りクッキー
        return int(my_num / 2), your_num + int(my_num / 2)
    else:
        # 奇数の場合
        # 自分の残りクッキー、相手の残りクッキー
        return my_num - 1 - int((my_num - 1) / 2), your_num + int((my_num - 1) / 2)

for i in range(K):
    if i % 2 == 0:
        # A君のターン
        A, B = cookie(A, B)
    else:
        # B君のターン
        B, A = cookie(B, A)
    i += 1

print(A, B)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
    if(i%2):
        #b
        if(b%2):
            b -=1
        a += b//2
        b = b // 2
    else:
        if(a%2):
            a -=1
        b += a//2
        a = a // 2
print(a, b)

Submission status: Accepted

Solution code:
A, B, K = list(map(int, input().rstrip().split()))
if K % 2 == 0:
    for i in range(K // 2):
        if A % 2 != 0:
            A -= 1
        A = A // 2
        B += A
        if B % 2 != 0:
            B -= 1
        B = B // 2
        A += B
else:
    for i in range(K // 2):
        if A % 2 != 0:
            A -= 1
        A = A // 2
        B += A
        if B % 2 != 0:
            B -= 1
        B = B // 2
        A += B
    if A % 2 != 0:
        A -= 1
    A = A // 2
    B += A
print(A, B)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
if k%2 == 0:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    print(a ,b)
    
else:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    a = int(a/2)
    b += a
    print(int(a),int(b))

Submission status: Accepted

Solution code:
a, b, k = [int(_) for _ in input().split()]

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

print(a, b)

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())

for i in range(k):
    if   i%2 == 0:
        if a%2 == 1:
            a -= 1
        b += a//2
        a = a//2
    elif i%2 == 1:
        if b%2 == 1:
            b -= 1
        a += b//2
        b = b//2
print(a,b)

Submission status: Accepted

Solution code:
l = input().split()
taka = int(l[0])
aoki = int(l[1])
num = int(l[2])
for i in range(1,num+1):
	if i % 2 == 0:
		if aoki % 2 == 1:
			aoki += -1
		aoki = aoki //2
		taka += aoki
	elif i % 2 ==1:
		if taka % 2 == 1:
			taka += -1
		taka = taka // 2
		aoki += taka
print(taka,aoki)

Submission status: Accepted

Solution code:
a,b,k = (int(i) for i in input().split())

def is_odd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def proc(a,b):
    if is_odd(a):
        a=a-1
    a=a/2
    b+=a
    return a,b

is_a = True
for i in range(k):
    if is_a:
        a,b=proc(a,b)
        is_a=False
    else:
       b,a=proc(b,a)
       is_a=True


a,b=int(a),int(b)
print(a,b)

Submission status: Accepted

Solution code:
abk = input().split(" ")
a = int(abk[0])
b = int(abk[1])
k = int(abk[2])

def main(a, b, k, k_first):
    if k % 2 == k_first % 2:
        if a % 2 == 1:
            a -= 1
        new_a = int(a / 2)
        new_b = b + int(a / 2)
    else:
        if b % 2 == 1:
            b -= 1
        new_b = int(b / 2)
        new_a = a + int(b / 2)
    if k - 1 == 0:
        print(str(new_a) + " " + str(new_b))
    else:
        main(new_a, new_b, k - 1, k_first)

main(a, b, k, k)

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split(" "))
def f(A,B,n):
  i = 1
  while i <= n:
    if i%2 == 1:
      if A%2 == 1:
        A = A - 1
      A = A/2
      B = B + A
    else:
      if B%2 == 1:
        B = B - 1
      B = B/2
      A = B + A
    i = i + 1 
  list = [int(A),int(B)]
  return (list)
print(' '.join(map(str,f(A,B,K))))

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
k=K//2
if K%2==0:
    while k>0:
        B=A//2+B 
        A=A//2
        A=B//2+A
        B=B//2
        k-=1
else:
    while k>0:
        B=A//2+B 
        A=A//2
        A=B//2+A
        B=B//2
        k-=1
    B=A//2+B 
    A=A//2
print(A,B)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

a,b,k = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -=  1
        b += a//2
        a //= 2
    elif i % 2 == 1:
        if b % 2 == 1:
            b -=  1
        a += b//2
        b //= 2
print("{} {}".format(a,b))

Submission status: Accepted

Solution code:
A, B, K = [int(_) for _ in input().split()]
for i in range(K):
    if i % 2 == 0:
        A = A // 2
        B = B + A
    else:
        B = B // 2
        A = A + B
print(A, B)

Submission status: Accepted

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

for i in range(K):
  if(i%2==0):
    if(A%2==1):
      A=A-1
    C=int(A/2)
    A=C
    B=B+C
  else:
   if(B%2==1):
     B=B-1
   C=int(B/2)
   B=C
   A=A+C

print(A,B)

Submission status: Accepted

Solution code:
A,B,K = [int(x) for x in input().split()]

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

print(A,B)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split(" "))
cnt = 1
for _ in range(k):
	if cnt == 1:
		if a % 2 == 1:
			a -= 1
		a = a / 2
		b += a
		cnt = cnt * (-1)
	else:
		if b % 2 == 1:
			b -= 1
		b = b / 2
		a += b
		cnt = cnt * (-1)
print(int(a), int(b))

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
dem=1
while dem<=k: 
  if (a%2==0):
    b+=a//2
    a-=a//2
    a,b=b,a
    dem=dem+1
  else:
    a-=1
    b+=a//2
    a-=a//2
    a,b=b,a
    dem=dem+1
if (dem%2==0):
  a,b=b,a
  print(a,b,end="")
else:
  print(a,b,end="")