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: Runtime Error

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

Submission status: Runtime Error

Solution code:
number = input()
number_list = list(number)
A = int(number_list[0])
B = int(number_list[2])
K = int(number_list[4])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
%%time
# B
a,b,k = list(map(int, input().split()))

def eat(a,b):
    a-= a%2
    b=int(b+a/2)
    a= int(a/2)
    return a,b

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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(f"{a} {b}")

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
def present(n):
  if n%2 == 0:
    return n/2
  else:
    return (n-1)/2

s = input()
a, b, k = s.split()

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

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