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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


A, B, K = LI()

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

print(A,B)

Submission status: Accepted

Solution code:
p = input()
a = int(p.split()[0])
b = int(p.split()[1])
k = int(p.split()[2])
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(int(a)) + " " + str(int(b)))

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
counter = 0
while True:
    if A%2 != 0:
        A -= 1
    A = A/2
    B += A
    counter += 1

    if counter == K:
        break
    if B%2 != 0:
        B -= 1
    B = B/2
    A += B
    counter += 1

    if counter == K:
        break

print(int(A),int(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 -= 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:
def abk(x,y):
  if x%2==1:
    x = x-1
  y = y + x/2
  x = x/2
  return (x,y)

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

Submission status: Accepted

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

def is_even(num):
    return num % 2 == 0

for i in range(K):
    if is_even(i):
        if not is_even(A):
            A = A -1
        A, B = A/2, A/2 + B
    else:
        if not is_even(B):
            B = B -1
        B, A = B/2, B/2 + A
    
print(int(A), int(B))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

line = sys.stdin.readline()
A, B, K = ( int(s) for s in line.split() )

x, y = A, B

for _ in range(K):
    #if x % 2 == 1:
    #    x -= 1
    x -= x % 2
    n = x // 2
    x -= n
    y += n
    x, y = y, x

if K % 2 == 1:
    x, y = y, x

print("%s %s" % (x, y))

Submission status: Accepted

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

for i in range(0, K):

    if (i % 2 == 0):

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

        a = A / 2
        A -= a
        B += a
    else:

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

        b = B / 2
        B -= b
        A += b

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
s = input().split()
a_have = int(s[0])
b_have = int(s[1])
for  i in range(int(s[2])):
    if i % 2 == 0:
        if a_have % 2 != 0:
            a_have-=1
        b_have+= a_have/2
        a_have = a_have/2
    else :
        if b_have % 2 != 0:
            b_have-=1
        a_have+= b_have/2
        b_have = b_have/2
print(int(a_have),int(b_have))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

A,B,K=input().split()
A=int(A)
B=int(B)
K=int(K)
turn=0
while(1):
	if(turn==K):
		break
	if(turn%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
	turn+=1
print(str(A)+" "+str(B))

Submission status: Accepted

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

ab = [a,b]
for i in range(k):
    p = i%2
    if ab[p]%2 == 1:
        ab[p] -= 1
    half = ab[p]/2
    ab[p] -= half
    ab[1-p] += half

print(int(ab[0]), int(ab[1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,k=map(int,raw_input().split(' '))
for i in range(k):
  a &= 0x7ffffffe
  b += a/2
  a /= 2
  b,a=a,b
if k%2:
  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: 
		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:
        # takahashi
        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:
        b = b + a//2
        a = a//2
    else:
        a = a + b//2
        b = b //2
print(a,b)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


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

    return '{} {}'.format(a,b)


print(main())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
s = input().split()
a = int(s[0])
b = int(s[1])
k = int(s[2])
for i in range(k):
	if(i % 2 == 0):
		b += int(math.floor(a / 2))
		a = int(math.floor(a / 2))
	else:
		a += int(math.floor(b / 2))
		b = int(math.floor(b / 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:
    a = b = 0
    if A % 2 == 1:
      A -= 1
    a = A // 2
    A -= a
    B += a

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

print(A, B)

Submission status: Accepted

Solution code:
def exc(cookies, turn):
    exccs = 0
    subturn = (turn + 1) % 2
    if (cookies[turn] % 2) == 0:
        exccs = cookies[turn] //2
    else:
        exccs = (cookies[turn] - 1) // 2
    
    cookies[subturn] += exccs
    cookies[turn] = exccs

    return cookies

a, b, k = map(int, input().split())
cookies = [a, b]

for i in range(k):
    turn = i % 2
    cookies = exc(cookies, turn)

print("{} {}".format(cookies[0], cookies[1]))

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

Submission status: Accepted

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

cnt = 0
while cnt < K:
  A = A // 2
  B = B + A
  cnt += 1
  #print(cnt,A,B)
  if cnt >= K:
    break
  
  B = B // 2
  A = A + B
  cnt += 1
  #print(cnt,A,B)
  
print(A,B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=[]
a1,a2,c = input().split()
a.append(int(a1))
a.append(int(a2))
c = int(c)
cur = 0
for i in range(c):
    a[1-cur]+=a[cur]//2
    a[cur]//=2
    cur=1-cur
print(a[0], a[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def swap(a, b, k):
    if k % 2 == 0:
        if a % 2 == 1:
            a -= 1
        return a/2, b+a/2
    if b % 2 == 1:
        b -= 1
    return int(a+b/2), int(b/2)


if __name__ == '__main__':
    a, b, k = list(map(int, input().split()))
    for i in range(k):
        a,b = swap(a,b,i)
    print(int(a), int(b))

Submission status: Accepted

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

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

print(A, B)

Submission status: Accepted

Solution code:
A, B, K = list(map(int, input().split()))
Co = [A, B]

for i in range(K):
  if Co[i % 2] % 2 == 1:
    Co[i % 2] -= 1
  Co[i % 2] /= 2
  Co[(i+1) % 2] += Co[i % 2]

Co = list(map(int, Co))
print(Co[0], Co[1])

Submission status: Accepted

Solution code:
data = list(map(int, input().split()))

def cookie1(a, b):
  if a % 2 == 1:
    a = a - 1
  else:
    pass
  return (int(a / 2), b + int(a / 2))

def cookie2(a, b):
  if b % 2 == 1:
    b = b - 1
  else:
    pass
  return (a + int(b / 2), int(b / 2))

a = data[0]
b = data[1]
for i in range(data[2]):
  if i % 2 == 0:
    c = cookie1(a, b)
    a = c[0]
    b = c[1]
  else:
    c = cookie2(a, b)
    a = c[0]
    b = c[1]
print("{0} {1}".format(a, b))

Submission status: Accepted

Solution code:
def f(a, b):
    if a % 2 == 0:
        pass
    else:
        a -= 1
    a //= 2
    b += a
    return a, b

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

cnt = 1
for i in range(inp[2]):
    if cnt % 2 == 0:
        inp[0], inp[1] = f(inp[1], inp[0])
    else:
        inp[1], inp[0] = f(inp[0], inp[1])


if inp[2] % 2 == 0:
    print(inp[0], inp[1], sep=" ")
else:
    print(inp[1], inp[0], sep=" ")

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

if k % 2 == 1:
  a /= 2
  b += a

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

Submission status: Accepted

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

while n>0:
    if a % 2 ==1:
        a = (a-1)/2
        b = b + a
    else:
        a = a/2
        b = b + a
    a1=a
    b1=b
    if b % 2 ==1:
        b = (b-1)/2
        a = b + a
    else:
        b = b/2
        a = b + a
    a2=a
    b2=b
    n=n-2

if n%2==0:
    print(int(a2),int(b2))
else:
    print(int(a1),int(b1))

Submission status: Accepted

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


def calc(n):
    if n % 2 == 1:
        return n - 1
    else:
        return n


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

if k%2:
		if a%2:
			a=a-1
		a=a//2
		b=b+a
print('{} {}'.format(a,b))

Submission status: Accepted

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

Submission status: Accepted

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

stop = 0

for i in range(k):
    if i % 2 == 0:
        a /= 2
        b += a
        if b == a * 2:
            stop = i + 1
            break
    if i % 2 == 1:
        b /= 2
        a += b
        if a == b * 2:
            stop = i + 1

if stop == 0 or (k - stop) % 2 == 0:
    print a, b
else:
    print b, a

Submission status: Accepted

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

stop = 0

for i in range(k):
    if i % 2 == 0:
        a /= 2
        b += a
        if b == a * 2:
            stop = i + 1
            break
    if i % 2 == 1:
        b /= 2
        a += b
        if a == b * 2:
            stop = i + 1

if stop == 0 or (k - stop) % 2 == 0:
    print a, b
else:
    print b, a

Submission status: Accepted

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

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

print(A,B)

Submission status: Accepted

Solution 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 //= 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 = list(map(int, input().split()))
a = A
b = B
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:
    a, b = a//2, b + a//2
  else:
    a, b = a + b//2, b//2
print(a, b)

Submission status: Accepted

Solution code:
import sys

def solve(A,B,K):
    ab = [A,B]
    for i in range(K):
        if ab[0]%2!=0:
            ab[0]-=1
        ab[1]+=ab[0]//2
        ab[0]-=ab[0]//2
        ab.reverse()
    if K%2!=0:
        print(ab[1],ab[0])
        return
    print(ab[0],ab[1])


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    A = int(ws[0])
    B = int(ws[1])
    C = int(ws[2])
    return (A, B, C)

def main():
    solve(*readQuestion())
    

# Uncomment before submission
main()

Submission status: Accepted

Solution code:
def exchange(hand,receive):
    if(hand[0]%2==1):
        hand[0]-=1
    hand[0]/=2
    receive[0]+=hand[0]

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


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

print("{} {}".format(int(A[0]),int(B[0])))

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

Submission status: Accepted

Solution code:
str_inputs = input()
array_inputs = str_inputs.split(" ")

takahashi_num = int(array_inputs[0])
aoki_num = int(array_inputs[1])
loop_num = int(array_inputs[2])

for i in range(loop_num):
    if i % 2 == 0:
        if takahashi_num % 2 == 1:
            takahashi_num = takahashi_num-1
    
        takahashi_num = takahashi_num - takahashi_num/2
        aoki_num = aoki_num + takahashi_num
    else :
        if aoki_num % 2 == 1:
            aoki_num = aoki_num-1
      
        aoki_num = aoki_num - aoki_num/2
        takahashi_num = takahashi_num + aoki_num


print(str(int(takahashi_num)) + " " + str(int(aoki_num))+" ")

Submission status: Accepted

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

Submission status: Accepted

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

def func(x,y):
    x = x//2
    y += x
    return x,y

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def process(a,b,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
    return a,b

for k in range(K):
    A,B = process(A,B,k)

print(A,B)

Submission status: Accepted

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

    c = [A, B]
    for i in range(K):
        src = i % 2
        to = (i + 1) % 2

        if c[src] % 2 == 1:
            c[src] -= 1

        src_half = c[src] // 2
        c[src] -= src_half
        c[to] += src_half

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, k = list(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:
s=input().split()
l=[int(s[0]),int(s[1])]
k=int(s[2])
for i in range(k):
  ind=i%2
  l[ind]-=l[ind]%2
  l[(ind+1)%2]+=l[ind]//2
  l[ind]//=2
print(l[0],end=" ")
print(l[1])

Submission status: Accepted

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

Submission status: Accepted

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

print(int(ab[0]), int(ab[1]))

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 = [int(_) for _ in input().split()]

while 1:
    if K == 0:
        break
    K -= 1
    A, B = A // 2, B + A // 2
    if K == 0:
        break
    K -= 1
    A, B = A + B // 2, B // 2

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 != 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:
        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(a,b)

Submission status: Accepted

Solution code:
import sys


def process(A, B, N, K, Turn):
    if N == K:
        return A, B
    else:
        if Turn:
            return process(int(A/2), B + int(A/2), N + 1, K, False)
        else:
            return process(A + int(B/2), int(B/2), N + 1, K, True)


def main(A, B, K):
    A, B = process(A, B, 0, K, True)
    return "{} {}".format(A, B)


if __name__ == "__main__":
    A, B, K = sys.stdin.readline().split()
    print(main(int(A), int(B), int(K)))

Submission status: Accepted

Solution code:
A, B, K = [int(x) for x 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(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 //= 2
    else:
        if B % 2 == 1: B -= 1
        A += B // 2
        B //= 2

print(A, B)

Submission status: Accepted

Solution code:
A, B, K = input().split()
A = int(A)
B = int(B)
K = int(K)
for i in range(1, K+1):
	if i % 2 == 1:
		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(str((A))+' '+str(B))

Submission status: Accepted

Solution code:
a,b,k = list(map(int, input().split()))
for i in range(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:
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(str(a)+" "+str(b))

Submission status: Accepted

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

cookie = [A, B]
turn   = 0
for _ in range(K):
    cookie[turn] //= 2
    cookie[1 - turn] += cookie[turn]
    turn = 1 - turn

A, B = cookie
print(A, B)

Submission status: Accepted

Solution code:
A,B,K = map(int,input().split())
i = 1
c = 1
while i <= K:
    if c % 2 == 1:
        if A % 2 == 0:
            A_ = A // 2
            A = A_
            B = B + A_
        else:
            A -= 1
            A_ = A // 2
            A = A_
            B = B + A_

        i += 1
        c += 1
    else:
        if B % 2 == 0:
            B_ = B //2
            A = A + B_
            B = B_
        else:
            B -= 1
            B_ = B //2
            A = A + B_
            B = B_

        i += 1
        c += 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:
    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//2):
    a = a//2*2
    b+= a/2
    a/=2
    b= b//2*2
    a+= b/2
    b/=2
if(k%2==1):
    a = a//2*2
    b+= a/2
    a/=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:
        a //= 2
        b += a
    else:
        b //= 2
        a += b
print(a, b)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    a, b, k = map(int, input().split())
    takahashi = a
    aoki = b

    for i in range(k):
        if i % 2 == 0:
            if takahashi % 2 == 1:
                takahashi -= 1

            takahashi -= takahashi // 2
            aoki += takahashi
        else:
            if aoki % 2 == 1:
                aoki -= 1

            aoki -= aoki // 2
            takahashi += aoki

    print(takahashi, aoki)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for k in range(K):
    if k%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:
input_str = str(input()).split()
a, b, k = int(input_str[0]), int(input_str[1]), int(input_str[2])

# 初期化
self = a
partner = b

for i in range(k):
    # 自分が持っているクッキーの枚数が奇数なら、自分が持っているクッキーを
    # 1枚食べ、偶数なら何もしない。
    if self % 2 == 1:
        self += -1

    # その後、自分が持っているクッキーの半分を相手に渡す。
    partner += int(self / 2)
    self = int(self / 2)

    self, partner = partner, self
    i -= 1

if i % 2 == 1:
    a = partner
    b = self
else:
    b = partner
    a = self

print(a, b)