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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

a, b,k = map(int, input().split())
taka=1
for i in range(k):
    if taka==1:
        if a%2==1:
            a-=1
        b = b+a//2
        a = a//2
        taka = 0
    else:
        if b%2==1:
            b-=1
        a = a+b//2
        b = b//2
        taka = 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:
        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==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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b, k = map(int, read().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())

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a,b,k = map(int, input().split())
    turn = 0
    while k > 0:
        k -= 1
        if turn == 0:
            if a%2 == 1:
                a -= 1
            a //= 2
            b += a
        else:
            if b%2 == 1:
                b -= 1
            b //= 2
            a += b
        turn ^= 1
    print(a, b)

if __name__ == '__main__':
    main()

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!=0:
            a-=1
        b+=a//2
        a=a//2
        flag=1
    else:
        if b%2!=0:
            b-=1
        a+=b//2
        b=b//2
        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 == 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())
while True:
    if a % 2 == 1:
        a -= 1
    b += a // 2
    a //= 2
    k -= 1
    if not k:
        break
    if b % 2 == 1:
        b -= 1
    a += b // 2
    b //= 2
    k -= 1
    if not k:
        break
print(a, b)

Submission status: Accepted

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

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

    else:
        if B % 2 != 0:
            B = (B-1) // 2
        else:
            B //= 2
        A += B

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

Submission status: Accepted

Solution code:
from sys import stdin
A, B, K = [int(_) for _ in stdin.readline().rstrip().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())
C = [A, B]
for i in range(K):
    if C[i&1] & 1:
        C[i&1] -= 1
    C[i&1] >>= 1
    C[(i&1)^1] += C[i&1]
print(*C)

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

print(A, B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, k = LI()
    for i in range(k):
        if i & 1:
            b = b // 2
            a += b
        else:
            a = a // 2
            b += a
    print(a,b)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

for i in range(K):
    if i % 2 == 0:
        # A
        if A%2 == 0:
            tmp = A//2
            A //= 2
            B += tmp
        else:
            A -= 1
            tmp = A//2
            A //= 2
            B += tmp
    else:
        # B
        if B%2 == 0:
            tmp = B//2
            B //= 2
            A += tmp
        else:
            B -= 1
            tmp = B//2
            B //= 2
            A += tmp
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:
t,a,k=list(map(int,input().split()))
i=0
while True:
    if t%2==1:
        t-=1
    a+=t//2
    t-=t//2
    i+=1
    if i>=k:
        break
    if a%2==1:
        a-=1
    t+=a//2
    a-=a//2
    i+=1
    if i>=k:
        break

print(t,a)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

a,b,k = iim()

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
A,B,K = inputlist()
count = 0
while True:
    if A % 2 == 1:
        A -=1
    d = A//2
    B += d
    A -=d
    count +=1
    if count == K:
        break
    if B % 2 == 1:
        B-=1
    da = B//2
    A += da
    B -=da
    count +=1
    if count == K:
        break
print(A,B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():

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

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

Submission status: Accepted

Solution code:
def main():
    takahashi_cookie, aoki_cookie, operation = map(int, input().split())
    for i in range(operation):
        if i % 2 == 0:
            if takahashi_cookie % 2:
                takahashi_cookie -= 1
            aoki_cookie += takahashi_cookie // 2
            takahashi_cookie //= 2
        else:
            if aoki_cookie % 2:
                aoki_cookie -= 1
            takahashi_cookie += aoki_cookie // 2
            aoki_cookie //= 2
    print(takahashi_cookie, aoki_cookie)


if __name__ == '__main__':
    main()

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:
        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 != 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())
ab = [a, b]
turn = 1
for _ in range(k):
  turn = not turn
  if ab[turn] % 2 == 1:
    ab[turn] -= 1
  ab[turn] //= 2
  ab[not turn] += ab[turn]
print(*ab)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    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)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#create date: 2020-03-18 07:40

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

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

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
for k in range(K):
    if k%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())

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

print(str(A), end=" ")
print(str(B))

Submission status: Accepted

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

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

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

print(A, B)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, K = MAP()
i = 0
while K > 0:
    # if A % 2 == 0:
        # A = A-1
    if i % 2 == 0:
        A = A // 2
        B += A
        K -= 1
    else:
        B = B//2
        A += B
        K -= 1
    i += 1
print(A, B)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

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

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

Submission status: Accepted

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


for i in range(K):
    if i % 2 == 0:  # Tの操作
        if A % 2 == 1:
            A -= 1

        B += A // 2
        A = A // 2
    else:   # Aの操作
        if B % 2 == 1:
            B -= 1

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

print(A, B)

Submission status: Accepted

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


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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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
    res=a[i%2]//2
    a[i%2]-=res
    a[(i+1)%2]+=res
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==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:
		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(1, k+1):
    # 高橋君の番
    if i % 2 == 1:
        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 == 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())
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:
A, B, K = map(int, input().split())

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

Submission status: Accepted

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

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

turn = True
for i in range(K):
    if turn:
        if A % 2 == 1:
            A -= 1
        B += A // 2
        A //= 2
        turn = False
    else:
        if B % 2 == 1:
            B -= 1
        A += B // 2
        B //= 2
        turn = True

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,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:
        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())
flag=True
for i in range(K):
  if flag:
    flag=False
    A=A//2
    B+=A
  else:
    flag=True
    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
		A = A / 2
		B+=a
	else:
		if B % 2 == 1:
			B-=1
		b = B / 2
		B = B / 2
		A+=b
print(int(A),int(B))

Submission status: Accepted

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

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)
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 b % 2 != 0:
			b -= 1
		c = int(b/2)
		b -= c
		a += c
	else:
		if a % 2 != 0:
			a -= 1
		c = int(a/2)
		a -= c
		b += c

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:
        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==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:
from sys import stdin

a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
now = 0
for i in range(c):
    if now%2 == 0:
        if a%2 == 1:
            a = (a-1)//2
            b += a
        else:
            a = a//2
            b += a
    else:
        if b%2 == 1:
            b = (b-1)//2
            a += b
        else:
            b = b//2
            a += b
    now += 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 and a % 2 ==1:
    a=(a-1)//2
    b+=a
  elif i % 2 ==0 and a%2==0:
    a=a//2
    b+=a
  elif i%2==1 and b%2==1:
    b=(b-1)//2
    a+=b
  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 = 0.5 * a
            b += a
        elif a % 2 == 0:
            a = 0.5 * a
            b += a
    elif i % 2 == 1:
        if b % 2 == 1:
            b -= 1
            b = 0.5 * b
            a += b
        elif b % 2 == 0:
            b = 0.5 * b
            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
		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 main():
    A, B, K = (int(i) for i in input().split())
    for k in range(K):
        if k & 1:
            if B & 1:
                B -= 1
            A += B//2
            B //= 2
        else:
            if A & 1:
                A -= 1
            B += A//2
            A //= 2
    print(A, B)


if __name__ == '__main__':
    main()