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())
cnt = 0
while True:
    if A % 2:
        A -= 1
    B += A//2
    A //= 2
    cnt += 1
    if cnt == K:
        break
    if B % 2:
        B -= 1
    A += B//2
    B //= 2
    cnt += 1
    if cnt == K:
        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:
		# takahashi
		if A % 2 == 1:
			A -= 1
		A, B = A // 2, B + A // 2
	else:
		# aoki
		if B % 2 == 1:
			B -= 1
		A, B = A + B // 2, B // 2
print(A, B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

A, B, K = mi()
C = [A, B]

turn = 0 #0はAのターン、1はBのターン
for _ in range(K):
  if C[turn] % 2 == 1:
    C[turn] -= 1
  C[turn] //= 2
  C[~turn] += C[turn]
  turn = ~turn

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

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

print(A,B)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
B - Exchange
https://atcoder.jp/contests/tenka1-2018-beginner/tasks/tenka1_2018_b

"""
import sys


def solve(A, B, K):
    turn = 'takahashi'
    for _ in range(K):
        if turn == 'takahashi':
            A -= (A % 2)
            A //= 2
            B += A
            turn = 'aoki'
        else:
            B -= (B % 2)
            B //= 2
            A += B
            turn = 'takahashi'
    return A, B


def main(args):
    A, B, K = map(int, input().split())
    ans = solve(A, B, K)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:


A, B, K = (int(i) for i in input().split())  


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

print('{} {}'.format(int(A), int(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
    tmp = A // 2
    A -= tmp
    B += tmp
    if B % 2 == 1:
        B -= 1
    tmp = B // 2
    A += tmp
    B -= tmp

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

print(A, B)

Submission status: Accepted

Solution code:

a, b, k = [ int(v) for v in 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())


while k > 0:
    if a % 2 == 1:
        a -= 1
    a, b = a // 2, b + a // 2
    k -= 1
    if k > 0:
        if b % 2 == 1:
            b -= 1
        b, a = b // 2, a + b // 2
        k -= 1

print(a, b)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a,b,k = map(int, input().split())
while True:
    if k == 0:
        break

    if (a % 2) == 1:
        a = a - 1
    b = b + (a / 2)
    a = a / 2
    k = k - 1

    if k == 0:
        break

    if (b % 2) == 1:
        b = b - 1
    a = a + (b / 2)
    b = b / 2
    k = k - 1

a = int(a)
b = int(b)

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

Submission status: Accepted

Solution code:

def Cukky(a,b):

    if a%2 == 0:
        a = a/2
    else:
        a = (a-1)/2

    b += a

    return a,b



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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1:
            A -= 1
        t = A // 2
        A -= t
        B += t
    else:
        if B % 2 == 1:
            B -= 1
        t = B // 2
        A += t
        B -= t
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
    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:
S = input().split()
A = int(S[0])
B = int(S[1])
K = int(S[2])
#print(A, B, K)

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

Submission status: Accepted

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

while K > 0:
    if A % 2 == 1:
        A -= 1
    B = B + (A//2)
    A = A // 2
    K -= 1
    if K < 1:
        break
    if B % 2 == 1:
        B -= 1
    A = A + (B//2)
    B = B // 2
    K -= 1

print("{0} {1}".format(A, B))

Submission status: Accepted

Solution code:
abk=list(map(int,input().split()))
a=abk[0]
b=abk[1]
k=abk[2]
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:
a,b,k=map(int,input().split())
turn="T"
for i in range(k):
  if turn=="T":
    b+=a//2
    a//=2
    turn="A"
  else:
    a+=b//2
    b//=2
    turn="T"
print(a,b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

A = int(A)
B = int(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 //= 2
        b += a
    else:
        if b%2 != 0:
            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:
    b+= int(a/2)
    a = int(a/2)
  else:
    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(0,k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        diff = a//2
        a -= diff
        b += diff
    else:
        if b % 2 == 1:
            b -= 1
        diff = b//2
        b -= diff
        a += diff

print(a,b)

Submission status: Accepted

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

while True:
    if A % 2 == 1:
        A -= 1
    t = A // 2
    A, B = A - t, B + t

    K -= 1
    if K <= 0:
        break

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

    K -= 1
    if K <= 0:
        break

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())
List = [A,B]
for i in range(K):
  if(List[i]%2==1):
    List[i]=(List[i]-1)//2
    List[i+1]=List[i+1]+List[i]
    List.append(List[i])
  else:
    List[i]=(List[i])//2
    List[i+1]=List[i+1]+List[i]
    List.append(List[i])
#print(List[-3],List[-2])
if(K%2==1):
  print(List[-1],List[-2])
else:
  print(List[-2],List[-1])

Submission status: Accepted

Solution code:
def main():
    a, b, k = [int(abk) for abk in input().split(" ")]

    for i in range(k):

        if i % 2 == 0:

            if a % 2 == 1:
                a = present_for_b = (a - 1) / 2

            else:
                a = present_for_b = a / 2

            b = b + present_for_b

        else:

            if b % 2 == 1:
                b = present_for_a = (b - 1) / 2

            else:
                b = present_for_a = b / 2

            a = a + present_for_a

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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(int(A),int(B))

Submission status: Accepted

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

def exchange(a, b):
  if a % 2 == 1:
    a -= 1
  half = a/2
  return (half, b+half)

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

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:
        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 getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x


def prob():
    d = Debug()
    d.off()
    C = zeros(2)
    C[0], C[1], K = getIntList()
    d.dmp((C,K), "C,K")
    for i in range(K):
        n = i % 2
        if C[n] % 2 == 1:
            C[n] -= 1
        C[1-n] += C[n] // 2
        C[n] //= 2
        d.dmp((C,i,n), "C,i,n")
    print(C[0],C[1])

ans = prob()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


A, B, K = mi()

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:
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


A, B, K = mi()

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

Submission status: Accepted

Solution code:
# https://tenka1-2018-beginner.contest.atcoder.jp/tasks/tenka1_2018_b

import itertools
from collections import Counter
import bisect

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

a,b,k=map(int,input().split())
#n=int(input())
#for i in range(n):
#    p[i]=[int(input()),i]
t=0
for i in range(k):
    if t==0:
        if a%2==0:
            a,b=(a)//2,b+(a)//2
        else:
            a,b=(a-1)//2,b+(a-1)//2
    if t==1:
        if b%2==0:
            b,a=(b)//2,a+(b)//2
        else:
            b,a=(b-1)//2,a+(b-1)//2
    t=1-t
print(a,b)

Submission status: Accepted

Solution code:
def spliter(a):
    a = str(a)
    b = list()
    b = a.split(' ')
    for i in range(0,len(b)):
        b[i] = int(b[i])
    return b
s = spliter(str(input()))
goal = s[2]
counter = 0
while counter != goal:
    if s[0] % 2 == 0:
        s[1] += (s[0] / 2)
        s[0] -= (s[0] / 2)
        counter += 1
        if counter == goal:
            break
        else:
            if s[1] % 2 == 0:
                s[0] += (s[1] / 2)
                s[1] -= (s[1] / 2)
                counter += 1
                if counter == goal:
                    break
            else:
                s[1] -= 1
                s[0] += (s[1] / 2)
                s[1] -= (s[1] / 2)
                counter += 1
                if counter == goal:
                    break
    else:
        s[0] -= 1
        s[1] += (s[0] / 2)
        s[0] -= (s[0] / 2)
        counter += 1
        if counter == goal:
            break
        else:
            if s[1] % 2 == 0:
                s[0] += (s[1] / 2)
                s[1] -= (s[1] / 2)
                counter += 1
                if counter == goal:
                    break
            else:
                s[1] -= 1
                s[0] += (s[1] / 2)
                s[1] -= (s[1] / 2)
                counter += 1
                if counter == goal:
                    break
            
print(int(s[0]),int(s[1]))

Submission status: Accepted

Solution code:
#!/snap/bin/pypy3

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

    cookies = [A, B]
    for i in range(K):
        if cookies[i%2] % 2:
            cookies[i%2] -= 1

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

    print(*cookies)


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

ab = [a,b]

for i in range(k):
  
  give = i%2
  if give==0:
    take=1
  else:
    take=0
  
  if ab[give]%2==1:
    ab[give] -= 1
  ab[take] += (ab[give]/2)
  ab[give] /= 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: 
        if A % 2 == 1:
            A -= 1
        temp1 = int(A / 2)
        A = A - temp1
        B = B + temp1
    else:
        if B % 2 == 1:
            B -= 1
        temp2 = int(B / 2)
        A = A + temp2
        B = B - temp2
print(A, B)

Submission status: Accepted

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

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

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

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
        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 = map(int, input().split())

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

    if K % 2 == 0:
        print(A, B)
    else:
        print(B, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



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

for _ in range(k):
  a -= a&1
  a //= 2
  b += a
  a,b = b,a

if k&1 > 0:
  print(b,a)
else:
  print(a,b)

Submission status: Accepted

Solution code:
A, B, K = map(int,input().split())
tmp = 0
Turn = "A"

def processing_A():
    global A,B,Turn,tmp
    tmp = A//2
    A = A//2
    B += tmp
    Turn = "B"
def processing_B():
    global A,B,Turn,tmp
    tmp = B//2
    B = B//2
    A += tmp
    Turn = "A"

for i in range(K):
    if Turn == "A":
        if A % 2 == 1:
            A -= 1
            processing_A()
        else:
            processing_A()
    else:
        if B % 2 == 1:
            B -= 1
            processing_B()
        else:
            processing_B()
print(A,B)

Submission status: Accepted

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

Submission status: Accepted

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

    if i % 2 == 1:
        if B % 2 == 1:
            B -= 1
        B = int(B / 2)
        A += B

print(A, B)

Submission status: Accepted

Solution code:
A,B,K=map(int,input().split())
for 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:
ABK = list(map(int,input().split()))
A=ABK[0]
B=ABK[1]
K=ABK[2]
for i in range(K):
    if i%2==0:
        if A%2==0:
            A = A/2
        elif A%2==1:
            A = (A-1)/2
        B = B+A
    if i%2==1:
        if B%2==0:
            B = B/2
        elif B%2==1:
            B = (B-1)/2
        A = A+B
print(int(A),int(B))

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,random
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

A,B,K = inpl()
taka = True

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

    taka = not taka

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

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:
        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(' '))
l=[A,B]
for i in range(K):
	p=l[i%2]
	l[i%2] = (p-(p%2))/2
	l[(i+1)%2] += (p-(p%2))/2
print(' '.join([str(int(x)) for x in l]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def cookie(p1,p2):
	if p1 % 2 == 1:
		p1 -= 1
	p1 /= 2
	p2 += p1
	return p1,p2

a,b,k = map(int, input().split())
for i in range(k):
	if i % 2 == 0:
		a,b = cookie(a,b)
	else:
		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:
        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:
def ex(a,b,n):
  for _ in range(n):
    a, b = b + a//2, a//2
  if n%2:
    a,b = b,a
  return str(a),str(b)
a, b, k = map(int, input().split())
print(' '.join(ex(a,b,k)))

Submission status: Accepted

Solution code:
def ex(a,b,n):
  for _ in range(n):
    a, b = b + a//2, a//2
  if n%2:
    a,b = b,a
  return str(a),str(b)
a, b, k = map(int, input().split())
print(' '.join(ex(a,b,k)))

Submission status: Accepted

Solution code:
a,b,k=map(int,input().split())
count=1
while 1:
    count+=1
    if a%2==1:
        a-=1
    b+=a//2
    a=a//2
    if count>k:
        break
#    print(a,b)
    if b%2==1:
        b-=1
    a+=b//2
    b=b//2
    count+=1
    if count>k:
        break
#    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
        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 = [int(x) for x in 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 == 1:
            a -= 1
        a = a // 2
        b += a
    else:
        if b % 2 == 1:
            b = 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
		a = a/2
		b = b+a
	if i%2==1:
		if b%2==1:
			b-=1
		b = b/2
		a = b+a

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

Submission status: Accepted

Solution code:
from sys import stdin
A,B,K=[int(x) for x in stdin.readline().rstrip().split()]
for i in range(K):
    if i%2==0:
        if A%2 != 0:
            A-=1
        B+=(A/2)
        A-=(A/2)
    else:
        if B%2 != 0:
            B-=1
        A+=(B/2)
        B-=(B/2)
print(int(A),int(B))

Submission status: Accepted

Solution code:
a,b,c = map(int,input().split(" "))
count = 0
t = "A"
while True:
    count += 1
    if t == "A":
        b += a // 2
        a //= 2
        t = "B"
    else:
        a += b // 2
        b //= 2
        t = "A"
    if count == c:
        print(a,b)
        exit()
    elif a * 2 == b or b * 2 == a:
        break
if (c - count) % 2 == 0:
    print(a,b)
else:
    print(b,a)

Submission status: Accepted

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

Submission status: Accepted

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