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:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,K = MI()
    for i in range(K):
        if i%2==0:
            if A&1:
                A-=1
            A>>=1
            B+=A
        else:
            if B&1:
                B-=1
            B>>=1
            A+=B
    print(A,B)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(a, end = " ")
print(b)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b,k=map(int,input().split())
for i in range(k):
    if i%2==0:
        a//=2
        b+=a
    else:
        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==0:
    if A%2!=0:
      B += (A-1)//2
      A = (A-1)//2
    else:
      B += A//2
      A //= 2
  else:
    if B%2!=0:
      A += (B-1)//2
      B = (B-1)//2
    else:
      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==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//=2
        B+=A
    else:
        if B%2==1:
            B-=1
        B//=2
        A+=B

print(str(A)+' '+str(B))

Submission status: Accepted

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

for i in range(1,k+1):
    if i%2==1:
        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(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
        c = a // 2
        a -= c
        b += c
    else:
        if b % 2 == 1:
            b -= 1
        c = b // 2
        b -= c
        a += c
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 -= A % 2
    B += A // 2
    A //= 2
  else :
    B -= B % 2
    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==1:
        	a-=1
        a=a//2
        b+=a
    else:
        if b%2==1:
        	b-=1
        b=b//2
        a+=b
print(str(a)+" "+str(b))

Submission status: Accepted

Solution code:
def examA():
    S = SI()
    if len(S)==3:
        ans = S[::-1]
    else:
        ans = S
    print(ans)
    return

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()

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:
    B -= B % 2
    A += B // 2
    B //= 2
  else:
    A -= A % 2
    B += A // 2
    A //= 2
print(A, B)

Submission status: Accepted

Solution code:
# 2019/12/12

a,b,k=map(int,input().split())
turn=1

def eat(x,y):
    if x%2:
        x-=1
    x//=2
    y+=x
    return x,y

for i in range(k):
    if turn:
        a,b=eat(a,b)
    else:
        b,a=eat(b,a)
    turn=1-turn
print('{} {}'.format(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
        dif = a // 2
        a -= dif
        b += dif
    else:
        if b % 2 == 1:
            b -= 1
        dic = b // 2
        a += dic
        b -= dic
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 -= (A % 2 == 1)
        A, B = A//2, B+A//2
    else:
        B -= (B % 2 == 1)
        A, B = A + B//2, B//2

print(A, B)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read

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

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

print(A, B)

Submission status: Accepted

Solution code:
A,B,K= map(int,input().split())
x = A
y = B
cnt = 0
while cnt<K:
    if cnt%2==0:
        y += x//2
        x = x//2
    else:
        x += y//2
        y = y//2
    cnt += 1
print(x,y)

Submission status: Accepted

Solution 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)

Submission status: Accepted

Solution code:
#自分が持っているクッキーの枚数が奇数なら、自分が持っているクッキーを 1 枚食べ、
#偶数なら何もしない。
#その後、自分が持っているクッキーの半分を相手に渡す。

a,b,k = [int(a) for a in input().split(' ')]

def cookie(p,q):
  if p%2==1:
    p -= 1
  p -= p/2
  q += p
  return (p,q)

for i in range(k):
  if i%2==0:
    # a turn
    a,b = cookie(a,b)
  else:
    # b turn
    b,a = cookie(b,a)
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:
        A = A if A % 2 == 0 else A - 1
        A //= 2
        B += A
    else:
        B = B if B % 2 == 0 else B - 1
        B //= 2
        A += B
print(A, B)

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
i=0
while i<k:
    if i%2==0:
        b+=a//2
        a=a//2
    else:
        a+=b//2
        b=b//2
    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 == 0:
    a //= 2
    b += a
  else:
    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==0:
        A//=2
        B+=A
    else:
        B//=2
        A+=B
print(A,B)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

def operate(x, y):
    if x % 2 == 1:
        x -= 1
    x //= 2
    return (x, y + x)

for k in range(K // 2):
    A, B = operate(A, B)
    B, A = operate(B, A)
if K % 2 == 1:
    A, B = operate(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:
    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())
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:
def resolve():
    a,b,k=map(int,input().split())
    while 1:
        if a%2==1:
            a-=1
        a//=2
        b+=a
        k-=1
        if k==0:
            break
        if b%2==1:
            b-=1
        b//=2
        a+=b
        k-=1
        if k==0:
            break
    print('{} {}'.format(a,b))
resolve()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
p=[a,b]
i=0
while True:
  for g in range(2):
    t=g^1
    if p[g]%2==1:
      p[g]-=1
    p[t]+=p[g]//2
    p[g]//=2
    i+=1
    if i==k:
      print(*p)
      exit(0)

Submission status: Accepted

Solution code:
a, b, k = map(int, input().split())
for i in range(k):
  if i % 2 == 0:
    c = a // 2
    a = c
    b += c
  else:
    c = b // 2
    a += c
    b = c
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:
            a -= 1
        a //= 2
        b += a
    else:
        if b%2:
            b -= 1
        b //= 2
        a += b
print(a,b)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

A, B, K = list(map(int, sys.stdin.readline().split()))


def op(A, B):
    return A // 2, A // 2 + B


while K:
    if K > 0:
        A, B = op(A, B)
        K -= 1
    if K > 0:
        B, A = op(B, A)
        K -= 1
print(A, B)

Submission status: Accepted

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

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

Submission status: Accepted

Solution 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))

Submission status: Accepted

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

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

if k%2==1:
    a,b = a//2,b+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 == 0:
        if a%2 != 0:
            a -= 1
        a = a//2
        b += a
    else:
        if b%2 != 0:
            b -= 1
        b = 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:
        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==0:
        b+=a//2
        a=a//2
    if i%2!=0:
        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:
        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())
for i in range(k):
    if i%2==0:
        if a%2:
            a-=1
        a//=2
        b+=a
    else:
        if b%2:
            b-=1
        b//=2
        a+=b
print(a,b)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans=[a,b]
print(" ".join(map(str,ans)))

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 = a//2
        b += a
    else:
        if b % 2 == 1:
            b -= 1
        b = b//2
        a += b

print(a, b)

Submission status: Accepted

Solution code:
import sys


def slove():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, input().rstrip('\n').split()))
    for i in range(k):
        if i % 2 == 0:
            if a % 2 != 0:
                a -= 1
            b += a // 2
            a -= a // 2
        else:
            if b % 2 != 0:
                b -= 1
            a += b // 2
            b -= b // 2
    print(a, b)


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
a,b,k = map(int,input().split())
cnt = 0
while cnt < k:
  b += a//2
  a = a//2
  cnt += 1
  if cnt < k:
    a += b//2
    b = b//2
    cnt += 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:
        if a % 2 == 1:
            a -= 1
            a /= 2
            b += a            
        else:
            a /= 2
            b += a
    else:
        if b % 2 == 1:
            b -= 1
            b /= 2
            a += b
        else:
            b /= 2
            a += b

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
for i in range(K):
  A2, B2 = A, B
  if i % 2 == 0:
    if A2 % 2 == 1: A2 -= 1
    B2 += A2 // 2
    A2 = A2 // 2
  else:
    if B2 % 2 == 1: B2 -= 1
    A2 += B2 // 2
    B2 = B2 // 2
  A, B = A2, B2
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 -= A%2
        B += A//2
        A -= A//2
    else:
        B -= B%2
        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:
    for i in range(int(k / 2)):
        if a % 2 == 1:
            a -= 1
        a = a / 2
        b += a
        if b % 2 == 1:
            b -= 1
        b = b / 2
        a += b
else:
    for i in range(int((k - 1) / 2)):
        if a % 2 == 1:
            a -= 1
        a = a / 2
        b += a
        if b % 2 == 1:
            b -= 1
        b = b / 2
        a += b
    if a % 2 == 1:
        a -= 1
    a = a / 2
    b += a
    
print(int(a),end=" ")
print(int(b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,K = [int(x) for x in input().split()]
cnt = 0
while(cnt<K):
    if(A%2==1):
        A-=1
    B+=A//2
    A//=2
    cnt+=1
    if(cnt>=K):break
    if(B%2==1):
        B-=1
    A+=B//2
    B//=2
    cnt+=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//=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
        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,k=map(int,input().split())
for i in range(k):
	if i%2==0:
		if a%2!=0:
			a-=1
		a,b=a//2,b+a//2
	else:
		if b%2!=0:
			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:
        a//=2
        b+=a
    if i%2==1:
        b//=2
        a+=b    
print(a,b)

Submission status: Accepted

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

if k%2 == 1:
    if a%2 == 1:
        a -= 1
    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
        B += A // 2
        A = A // 2
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B = B // 2
        
print(str(A) + " " + str(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 = b + (a / 2)
        a = a / 2
    else:
        if b % 2 == 1:
            b -= 1
        a = a + (b / 2)
        b = b / 2
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())
COUNT = 0

while True :

    if A % 2 == 1 :

        A -= 1

    A = A//2

    B += A

    COUNT += 1

    if COUNT == K :

        break
    

    if B % 2 == 1 :

        B -= 1

    B = B//2

    A += B

    COUNT += 1

    if COUNT == K :

        break

print(A,B)

Submission status: Accepted

Solution code:
A, B, K = tuple(map(int, input().split()))
for i in range(K):
    if i % 2 == 0:
        if A % 2 != 0:
            A -= 1
        B += A // 2
        A = A // 2
    else:
        if B % 2 != 0:
            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:
        a-=a%2
        b+=a//2
        a=a//2
    else:
        b-=b%2
        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:
    A=A-A%2
    A,B=A-A//2,B+A//2
  else:
    B=B-B%2
    A,B=A+B//2,B-B//2
  #print(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:
        a //= 2
        b += a
    else:
        b //= 2
        a += b

print(a, b)

Submission status: Accepted

Solution code:
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=0
    k-=1

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:
        a //= 2
        b += a
    else:
        b //= 2
        a += b
print(a, b)

Submission status: Accepted

Solution 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()

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 != 0:
            A -= 1
        B += A // 2
        A = A // 2
    else:
        if B % 2 != 0:
            B -= 1
        A += B // 2
        B = B // 2
print(A, B)

Submission status: Accepted

Solution code:
def main():

    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
    return str(A) + " " + str(B) 

if __name__ == '__main__':
    print(main())

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
  if i%2 == 1:
    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())
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))

Submission status: Accepted

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

Submission status: Accepted

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

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 = A // 2
        B += A
    else:
        if B % 2 != 0:
            B -= 1
        B = 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 == 0:
        if A % 2 != 0:
            A -= 1
        num = A // 2
        A = num
        B += num
    else:
        if B % 2 != 0:
            B -= 1
        num = B // 2
        B = num
        A += num

print(A, B)

Submission status: Accepted

Solution 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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, K = map(int, input().split())
for i in range(0, K):
    if(i & 1):
        if(B & 1):
            B -= 1
        A += B//2
        B //= 2
    else:
        if(A & 1):
            A -= 1
        B += A//2
        A //= 2
print("{0} {1}".format(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
        A = A // 2
        B = B + A
    else:
        if B % 2 == 1:
            B = B - 1
        B = B // 2
        A = A + B

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

Submission status: Accepted

Solution 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)

Submission status: Accepted

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

for _ in range(K):
    B += A // 2
    A //= 2
    B, A = A, B

if K % 2 == 1:
    B, 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
    a /= 2
    b += a
  else:
    if(b%2==1):
      b -= 1
    b /= 2
    a += b
print(int(a),int(b))

Submission status: Accepted

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

Submission status: Accepted

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

now = "a"
for i in range(li["k"]):
    add = 0
    if li[now] % 2:
        li[now] -= 1
    li[now] = int(li[now]/2)
    add += li[now]
    if now == "a":
        now = "b"
    else:
        now = "a"
    li[now] += add
print(li["a"],li["b"])

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
while True:
  A-=A%2
  A,B=A//2,B+A//2
  K-=1
  if K==0:
    break
  B-=B%2
  B,A=B//2,A+B//2
  K-=1
  if K==0:
    break
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 //= 2
            b += a
        else:
            a -= 1
            a //= 2
            b += a
    else:
        if b % 2 == 0:
            b //= 2
            a += b
        else:
            b -= 1
            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 == 0:
        if a % 2:
            a -= 1
        b += a // 2
        a -= a // 2
    else:
        if b % 2:
            b -= 1
        a += b // 2
        b -= b // 2
print(a, b)

Submission status: Accepted

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

def calc(a, b):
    if a %  2 != 0:
        a -= 1
    a //= 2
    b += a
    return a, b


for i in range(K):
    if i % 2 == 0:
        A, B = calc(A, B)
    else:
        B, A = calc(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:
        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 i in range(k):
    if i%2==0:
        if a%2==1:
            a -= 1
            a = a//2
            b += a
        else:
            a = a//2
            b += a            
    else:
        if b%2==1:
            b -= 1
            b = b//2
            a += b
        else:
            b = b//2
            a += b

print(a,b)

Submission status: Accepted

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

def exchange(n, m):
  if n % 2:
    n = (n-1) // 2
  else:
    n = n // 2
  m += n
  return n, m


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

print('{0} {1}'.format(a, b))

Submission status: Accepted

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

for k in range(K):
	if 0 == k % 2:
		A //= 2
		B += A
	else:
		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-=A//2
    else:
        if B%2==1:
            B-=1
        A+=B//2
        B-=B//2
print(A,B)

Submission status: Accepted

Solution code:
def solve(a, b, k):
    for i in range(k):
        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
    return "%d %d" % (a, b)

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

Submission status: Accepted

Solution code:
# tenka1-2018-beginnerB - Exchange
def main():
    a, b, k = list(map(int, input().rstrip().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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
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,y,k = map(int,input().split(" "))
p=1
while(k!=0):
	k=k-1
	if(p==1):
		p=2
		if(x%2==0):
			y+=x//2
			x=x//2
		else:
			y+=(x-1)//2
			x=(x-1)//2
	else:
		p=1
		if(y%2==0):
			x+=y//2
			y=y//2
		else:
			x+=(y-1)//2
			y=(y-1)//2
print(x,y)