Problem:


Score : 300 points

Problem Statement

Takahashi, Nakahashi and Hikuhashi have integers A, B and C, respectively.
After repeating the following operation K times, find the integer Takahashi will get minus the integer Nakahashi will get:

Each of them simultaneously calculate the sum of the integers that the other two people have, then replace his own integer with the result.

However, if the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Constraints

1 \leq A,B,C \leq 10^9

0 \leq K \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C K

Output

Print the integer Takahashi will get minus the integer Nakahashi will get, after repeating the following operation K times.
If the absolute value of the answer exceeds 10^{18}, print Unfair instead.

Sample Input 1

1 2 3 1

Sample Output 1

1

After one operation, Takahashi, Nakahashi and Hikuhashi have 5, 4 and 3, respectively. We should print 5-4=1.

Sample Input 2

2 3 2 0

Sample Output 2

-1

Sample Input 3

1000000000 1000000000 1000000000 1000000000000000000

Sample Output 3

0



Sample input:
1 2 3 1


Sample output:
1

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int, input().split())
z = abs(a-b)*((-1)**(k%2+1))
if z > 10**18:print("Unfair")
if k == 0 :print(a-b)
else:print(z)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int, input().split())
z = abs(a-b)*((-1)**(k%2+1))*k
if z > 10**18:print("Unfair")
if k == 0 :print(a-b)
else:print(z)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int, input().split())
z = abs(a-b)*((-1)**(k%2+1))*k
if z > 10**18:print(-1)
else:print(z)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int, raw_input().split())
k %= 2
print (a-b) * (-1**k)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())
print(a-b) if k % 2 else print(b-a)

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())
if abs(a-b) > 10**8:
  print("Unfair")
else:
  print(a-b if k%2==0 else b-a)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
if abs(a-b)>=10**8:
  print("Unfair")
else:
  print(a-b if k%2==0 else b-a)

Submission status: Wrong Answer

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

print(A-B)

Submission status: Wrong Answer

Solution code:
import numpy as np
a, b, c, k = map( int, input().split())
mat = np.array([[0,1,1],[1,0,1],[1,1,0]])
A = mat**k
ans = A[0][0]*a + A[0][1]*b + A[0][2]*c - A[1][0]*a-A[1][1]*b-A[1][2]*c
if k == 0:
    print(a-b)
elif abs( ans) > 10**18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

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

if(k%2==0):
  if abs(a-b)<10*18:
    print(a-b)
  else:
    print("Unfair")
else:
  if abs(a-b)<10*18:
    print(b-a)
  else:
    print("Unfair")

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if k%2 == 0:
    print(b-a)
else:
    print(a-b)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
l,m = 0,1
for i in range(k-1):
    l,m = 2*m,l+m
ans = (l-m)*a + (m-l)*b
if ans > 10**18:
    print('Unfair')
else:
  print(ans)

Submission status: Wrong Answer

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

if 1000000000000000000 <= K:
    print("Unfair")
    exit()

for i in range(K):
    a,b,c=A,B,C
    A=b+c
    B=a+c
    C=a+b

print(A-B)

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int, input().split())
if abs(B-A)<10^18:
    print(B-A if K%2 else A-B)
else:
    print('unfair')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(A - B if K % 2 == 1 else B - A)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
print((B - A)*(-1)**K)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
ans = A - B
if abs(ans) > 10**18: ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
ans = A - B
if abs(ans) > 10**18: ans = "Unfair"
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
if a == b and b == c:
    print(0)
elif (a + c) * k >= 1000000000000000000 or (b + c) * k >= 1000000000000000000:
    print('Unfair')
else:
    for i in range(k):
        a_tmp = b + c
        b_tmp = a + c
        c_tmp = a + b
        a = a_tmp
        b = b_tmp
        c = c_tmp
    print(a-b)

Submission status: Wrong Answer

Solution code:
a,b,_,k=map(int,input().split())
print((a-b)**(k%2))

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split());a=a-b*(-1**k%2);print(a)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split());a=a-b*-1**k%2;print([a,0][a>10**18])

Submission status: Wrong Answer

Solution code:
# cook your dish here
# n=int(input())
# l =  list(map(int,input().split()))
#import numpy as np
a,b,c,k = map(int,input().split())

if abs(b-a)> 10^18:
    print('Unfair')
    quit()
if k%2 == 0:
    print(a-b)
else:
    print(b-a)

Submission status: Wrong Answer

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

unfair = 10^18

if k%2 ==0:
	if abs(a-b) <= unfair:
		print(a-b)
	else:
		print('Unfair')
else:
	if abs(b-a) <= unfair:
		print(b-a)
	else:
		print('Unfair')

Submission status: Wrong Answer

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

unfair = 10^18

if k%2 ==0:
	if a-b <= unfair:
		print(a-b)
	else:
		print('Unfair')
else:
	if b-a <= unfair:
		print(b-a)
	else:
		print('Unfair')

Submission status: Wrong Answer

Solution code:
taka = 1
naka = 2
tei = 3

k = 1

for i in range(k):
    taka_1 = naka + tei 
    naka_1 = taka + tei 
    tei_1 = taka + naka 
    taka = taka_1
    naka = naka_1
    tei = tei_1

atai = taka - naka
if abs(atai) >= 10 ** 18:
    print("Unfair")

print(atai)

Submission status: Wrong Answer

Solution code:
import sys

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

a_0 = 1
a_1 = 0
a_2 = 0

i = 0
while i < K:
    a_0 = a_1 + a_2
    a_1 = a_0 + a_2
    a_2 = a_0 + a_1
    
    i = i + 1
    
res = (A - B) * (a_0 - a_1)
if res < 10**18:
    print(res)
else:
    print("unfair")

Submission status: Wrong Answer

Solution code:
a, b, c, k = (int(i) for i in input().split())
if 0 == (k & 1):
  print(b - a)
else:
  print(a - b)

Submission status: Wrong Answer

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

if K % 2 == 1:
	print(A-C)
else:
	print(C-A)

Submission status: Wrong Answer

Solution code:
a = raw_input().split()
 
if int(a[3]) % 2 == 0:
    print int(a[1]) - int(a[2])
else:
    print -1 * (int(a[1]) - int(a[2]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
for i in range(K):
	temp_a = A
	temp_b = B
	temp_c = C
	print(A, B, C)
	A = temp_b + temp_c
	B = temp_a + temp_c
	C = temp_a + temp_b
if abs(A - B) <= 10 ** 18:
	print(A - B)
else:
	print("unfair")

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(k):
  m = b + c
  n = a + c
  o = a + b
  a = m
  b = n
  c = o

if math.fabs(a - b) > 1.0e18:
  print("Unfair")
else:
  print(math.fabs(int(a - b)))

Submission status: Wrong Answer

Solution code:
import sys

input_nums = raw_input().split(' ')
A = int(input_nums[0])
B = int(input_nums[1])
C = int(input_nums[2])
K = int(input_nums[3])

if A == B and B == C:
    print 0
    sys.exit()

for _ in xrange(K):
    A, B, C = B + C, A + C, A + B
    if A > 10**18 or B > 10**18 or C > 10**18:
        print 'Unfair'
        sys.exit()

print A - B

Submission status: Wrong Answer

Solution code:
import sys

input_nums = raw_input().split(' ')
A = int(input_nums[0])
B = int(input_nums[1])
C = int(input_nums[2])
K = int(input_nums[3])

for _ in xrange(K):
    A, B, C = B + C, A + C, A + B
    if A > 10**18 or B > 10**18 or C > 10**18:
        print 'Unfair'
        sys.exit()

print A - B

Submission status: Wrong Answer

Solution code:
import sys

input_nums = raw_input().split(' ')
A = int(input_nums[0])
B = int(input_nums[1])
C = int(input_nums[2])
K = int(input_nums[3])

for _ in xrange(K):
    A, B, C = B + C, A + C, B + C
    if A > 10**18 or B > 10**18 or C > 10**18:
        print 'Unfair'
        sys.exit()

print A - B

Submission status: Wrong Answer

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

for i in range(c):
    a,b,c=b+c,c+a,a+b

ans=a-b
if abs(ans)>1e18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,k =map(int,input().split())
flag = 0
for i in range(k):
	if a>10^18 or b>10^18 or c>10^18:
		print('Unfair')
		flag=1
		break
	e = b+c
	f = a+b
	g = a+c
	a = e
	c = f
	b = g
if flag == 0:
	print(a-b)

Submission status: Wrong Answer

Solution code:
s=input().split()
ans=int(s[0])-int(s[1])
if abs(ans)>10**18:
  print("Unfair")
elif int(s[3])%2==0:
  print((int(s[0])-int(s[1])))
else:
  print(-1*int(s[0])-int(s[1]))

Submission status: Wrong Answer

Solution code:
s=input().split()
ans=int(s[0])-int(s[1])
if abs(ans)>10**18:
  print("Unfair")
elif int(s[3])%2==0:
  print(-1*(int(s[0])-int(s[1])))
else:
  print(int(s[0])-int(s[1]))

Submission status: Wrong Answer

Solution code:
s=input().split()
if int(s[3])%2==0:
  print(-1*(int(s[0])-int(s[1])))
else:
  print(int(s[0])-int(s[1]))

Submission status: Wrong Answer

Solution code:
import copy
s=input().split()
num=[int(i) for i in s[:3]]
K=int(s[3])
num_=[0,0,0]
for i in range(K):
	for j in range(3):
		num_[j]=num[(j+1)%3]+num[(j+2)%3]
		num=copy.deepcopy(num_)
	if i%10000==0:
		if abs(num[0]-num[1])>10**18:
			print("Unfair")
			break
else:
	print(num[0]-num[1])

Submission status: Wrong Answer

Solution code:
import sys

xs = str(sys.stdin.readline()).split(" ")
a,b,c,k = [int(x) for x in xs]

def f(x):
	if (pow(10,18) <= x):
		print("UnFair")
		exit()

for i in range(0, k):
	a2,b2,c2 = b+c, a+c, a+b
	a,b,c = a2,b2,c2
	f(a)
	f(b)
	f(c)

x = a - b
f(x)
print(x)

Submission status: Wrong Answer

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

if (abs(b-a) > 1000000000000000000):
    print("Unfair")
else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

A,B,C,K = map(int, input().split())
s = A+B+C
A1 = K*(s-A)
B1 = K*(s-B)
ans = A1 - B1 
if(K == 0):
	print(A-B)
else:
	if(abs(ans) > 10**18):
		print("Unfair")
	else:
		print(ans)

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

A,B,C,K = map(int, input().split())
s = A+B+C
A1 = K*(s-A)
B1 = K*(s-B)
ans = A1 - B1 
if(K == 0):
	print(A-B)
else:
	if(ans > 10**18):
		print("Unfair")
	else:
		print(ans)

Submission status: Wrong Answer

Solution code:
def main11():
    strbuf = input('');
    strbufs = strbuf.split();
    buf = []
    for i in range(4):
        buf.append(int(strbufs[i]));
    for i in range(buf[3]):
        a = buf[0];
        b = buf[1];
        c = buf[2];
        buf[0] = b+c;
        buf[1] = a+c;
        buf[2] = a+b;
    answer = buf[0] - buf[1];
    if 0 <= answer and answer <= int(10^18):
        print(answer);
    else:
        print("Unfair");

if __name__ == '__main__':
    main11()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

def multiply(A, B):
	new_a = [[0 for i in range(len(B[0]))] for j in range(len(A))]

	for i in range(len(A)):
		for j in range(len(B[0])):
			for k in range(len(A[i])):
				new_a[i][j] += A[i][k] * B[k][j]

	return new_a

def exponentiate(table, times):
	new_table = deepcopy(table)
	identity = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

	curr_pow = 1
	while curr_pow <= times:
		if curr_pow & times:
			identity = multiply(new_table, identity)

		new_table = multiply(new_table, new_table)
		curr_pow *= 2

	return identity

a, b, c, k = map(int, raw_input().split(' '))
table = [[0, 1, 1], [1, 0, 1], [1, 1, 0]]

table_expand = exponentiate(table, min(k, 16384))
resultant_array = multiply(table_expand, [[a], [b], [c]])

if abs(resultant_array[0][0] - resultant_array[1][0]) > 10**18:
	print 'Unfair'
else:
	print resultant_array[0][0] - resultant_array[1][0]

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

def multiply(A, B):
	new_a = [[0 for i in range(len(B[0]))] for j in range(len(A))]

	for i in range(len(A)):
		for j in range(len(B[0])):
			for k in range(len(A[i])):
				new_a[i][j] += A[i][k] * B[k][j]

	return new_a

def exponentiate(table, times):
	new_table = deepcopy(table)
	identity = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

	curr_pow = 1
	while curr_pow <= times:
		if curr_pow & times:
			identity = multiply(new_table, identity)

		new_table = multiply(new_table, new_table)
		curr_pow *= 2

	return identity

a, b, c, k = map(int, raw_input().split(' '))
table = [[0, 1, 1], [1, 0, 1], [1, 1, 0]]

table_expand = exponentiate(table, min(k, 1024))
resultant_array = multiply(table_expand, [[a], [b], [c]])

if abs(resultant_array[0][0] - resultant_array[1][0]) > 10**18:
	print 'Unfair'
else:
	print resultant_array[0][0] - resultant_array[1][0]

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def multiply(A, B):
	new_a = [[0 for i in range(len(B[0]))] for j in range(len(A))]

	for i in range(len(A)):
		for j in range(len(B[0])):
			for k in range(len(A[i])):
				new_a[i][j] += A[i][k] * B[k][j]

	return new_a

def exponentiate(table, times):
	new_table = deepcopy(table)
	identity = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

	curr_pow = 1
	while curr_pow <= times:
		if curr_pow & times:
			identity = multiply(new_table, identity)

		new_table = multiply(new_table, new_table)
		curr_pow *= 2

	return identity

a, b, c, k = map(int, raw_input().split(' '))
table = [[0, 1, 1], [1, 0, 1], [1, 1, 0]]

table_expand = exponentiate(table, min(k, 512))
resultant_array = multiply(table_expand, [[a], [b], [c]])

if resultant_array[0][0] - resultant_array[1][0] > 10**18:
	print 'Unfair'
else:
	print resultant_array[0][0] - resultant_array[1][0]

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def multiply(A, B):
	new_a = [[0 for i in range(len(B[0]))] for j in range(len(A))]

	for i in range(len(A)):
		for j in range(len(B[0])):
			for k in range(len(A[i])):
				new_a[i][j] += A[i][k] * B[k][j]

	return new_a

def exponentiate(table, times):
	new_table = deepcopy(table)
	identity = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]

	curr_pow = 1
	while curr_pow <= times:
		if curr_pow & times:
			identity = multiply(new_table, identity)

		new_table = multiply(new_table, new_table)
		curr_pow *= 2

	return identity

a, b, c, k = map(int, raw_input().split(' '))
table = [[0, 1, 1], [1, 0, 1], [1, 1, 0]]

table_expand = exponentiate(table, min(k, 250))
resultant_array = multiply(table_expand, [[a], [b], [c]])

if resultant_array[0][0] - resultant_array[1][0] > 10**18:
	print 'Unfair'
else:
	print resultant_array[0][0] - resultant_array[1][0]

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if k%2 == 1:
    if abs(a-b) < 10**18:
        print(a-b)
    else: 
        print(0)
    
if k%2 == 0:
    if abs(a-b) < 10**18:
        print(b-a)
    else: 
        print(0)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=25:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=30:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=20:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    elif data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=19:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=19:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=17:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
import math
a, b, c, k = (int(i) for i in input().split())
if k == 0:
  print(a - b)
elif k == 1:
  print(b - a)
elif k > 31:
  print(0 if a == b else 'Unfair')
else:
  ans = (a + b + c) * (b - a) * pow(-2, k) / 3
  print(int(ans) if ans <= 10 ** 18 else 'Unfair')

Submission status: Wrong Answer

Solution code:
T, N, H, L = (int(a) for a in input().split())

ans = None

for i in range(int(L)):
	t = T; n = N; h = H
	T = n+h
	N = t+h
	H = t+n
	if t-n == T-N:
		break
	elif t-n == -(T-N):
		if L%2==0:
			ans = T-N
		else:
			ans = -(T-N)

if not ans:
	ans = T-N
if -10**18 >= ans <= 10**18:
	print('Unfair')
else:
	print(ans)

Submission status: Wrong Answer

Solution code:
import math
a, b, c, k = (int(i) for i in input().split())
if k == 0:
  print(a - b)
elif k == 1:
  print(b - a)
elif k > 31:
  print(0 if a == b else 'Unfair')
else:
  print((a + b + c) * (b - a) * pow(-2, k) / 3)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()


mean=A+B+C
#k_mean=mean*(2**K)
#middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
#answer_max=middle+diff_max_mid
#answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[mid_n,mid_n,mid_n]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=max_n
    data_list_answer[data_list.index(min(data_list))]=min_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=max_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=min_n

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=min_n
    data_list_answer[data_list.index(min(data_list))]=max_n
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=min_n
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=max_n
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=18:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
li_abck = list(int(i) for i in input().split())
K = li_abck[3]
cnt = [0,0,0]
x = 1

def ope_k(a):
    global cnt
    for i in range(3):
        if i != k:
            cnt[k]+=li_abck[i]

if li_abck[0]==li_abck[1]==li_abck[2]:
    print(0)
    x = 0
if x!=0:
    for j in range(K):
        for k in range(3):
            ope_k(k)
        li_abck=cnt

    if (li_abck[0]-li_abck[1]>10**18):
        print("Unfair")
    print(li_abck[0]-li_abck[1])

Submission status: Wrong Answer

Solution code:
da = list(map(int,input().split()))
 
m = 0
l = pow(10,18)
  
if da[3] % 2 == 1:
  k = da[1] -da[0]
else:
  k = da[0] -da[1]

if abs(da[0] - da[1]) <= l:
  print(da[0] - da[1])
elif abs(da[0] - da[1]) > l:
  print("Unfair")

Submission status: Wrong Answer

Solution code:
da = list(map(int,input().split()))
 
m = 0
l = pow(10,18)
  
if da[3] % 2 == 1:
  k = da[1] -da[0]
else:
  k = da[0] -da[1]

if abs(da[0] - da[1]) < l:
  print(da[0] - da[1])
elif abs(da[0] - da[1]) >= l:
  print("Unfair")

Submission status: Wrong Answer

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

R = A-B

if abs(R) > pow(10,18):
    print("Unfair")
elif K == 1:
    print(R*(-1))
else:
    print(R)

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()
#if K>=100:
#    print ('Unfair')
    sys.exit()
mean=A+B+C
k_mean=mean*(2**K)
middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
answer_max=middle+diff_max_mid
answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[middle,middle,middle]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=answer_max
    data_list_answer[data_list.index(min(data_list))]=answer_min
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_max
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_min

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=answer_min
    data_list_answer[data_list.index(min(data_list))]=answer_max
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_min
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_max
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=18:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
da = list(map(int,input().split()))
 
m = 0
l = pow(10,18)
  
if da[3] % 2 == 1:
  k = da[1] -da[0]
else:
  k = da[0] -da[1]

if da[0] == da[1]:
  print(0)
elif abs(da[0] - da[1]) < l:
  print(da[0] - da[1])
elif abs(da[0] - da[1]) >= l:
  print("Unfair")

Submission status: Wrong Answer

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

if N % 2 == 0:
    ans = a - b
else:
    ans = b - a

if abs(ans) > 10^18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def check(num):
    if num > pow(10,18):
        print('Unfair')
    else:
        print(num)


t, n, h, k = map(int, input().split())

if t==n and n==h:
    check(t-n)
elif k==0:
    check(t-n)
else:
    for i in range(k):
        t, n, h = n+h, t+h, t+n
        result = t-n

        check(result)

Submission status: Wrong Answer

Solution code:
da = list(map(int,input().split()))
 
m = 0
l = pow(10,18)
 
if da[3] <= 60 and da[0] != da[1]:
  m=1
def aaa(d,a,t):
  k = [0]*3
  k[0] = a
  k[1] = d
  return k
 
for i in range(da[3]):
  if da[0] == da[1]:
    break
  da = aaa(da[0],da[1],da[2])
  if abs(da[0] -da[1]) >= l or m == 1:
    break
if da[0] == da[1]:
  print(0)
elif abs(da[0] - da[1]) < l:
  print(da[0] - da[1])
elif abs(da[0] - da[1]) >= l:
  print("Unfair")

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()
if K>=100:
    print ('Unfair')
    sys.exit()
mean=A+B+C
k_mean=mean*(2**K)
middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
answer_max=middle+diff_max_mid
answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[middle,middle,middle]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=answer_max
    data_list_answer[data_list.index(min(data_list))]=answer_min
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_max
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_min

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=answer_min
    data_list_answer[data_list.index(min(data_list))]=answer_max
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_min
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_max
if len(str(abs(data_list_answer[0]-data_list_answer[1])))>=18:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from sys import stdin


def solve():
    a, b, c, k = map(int, stdin.readline().split())

    if k == 0:
        print(a - b)
    else:
        print(b - a)


solve()

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int,input().split())
import sys
if A==B==C:
    print (0)
    sys.exit()
if K>=50:
    print ('Unfair')
    sys.exit()
mean=A+B+C
k_mean=mean*(2**K)
middle=int(k_mean/3)
data_list=[A,B,C]
max_n=max(A,B,C)
min_n=min(A,B,C)
mid_n=mean-(max_n+min_n)
diff_max_mid=max_n-mid_n
diff_mid_min=mid_n-min_n
answer_max=middle+diff_max_mid
answer_min=middle-diff_mid_min
index_middle=3-data_list.index(min(data_list))-data_list.index(max(data_list))
data_list_answer=[middle,middle,middle]
if K%2==0:
    data_list_answer[data_list.index(max(data_list))]=answer_max
    data_list_answer[data_list.index(min(data_list))]=answer_min
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_max
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_min

if K%2==1:
    data_list_answer[data_list.index(max(data_list))]=answer_min
    data_list_answer[data_list.index(min(data_list))]=answer_max
    if data_list.count(max_n)==2:
        data_list_answer[index_middle]=answer_min
    if data_list.count(min_n)==2:
        data_list_answer[index_middle]=answer_max
if len(str(data_list_answer[0]-data_list_answer[1]))>=18:
    print ('Unfair')
else:
    print(data_list_answer[0]-data_list_answer[1])