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())
ans = a - b
max_abs = 1000000000000000000
for i in range(k):
    tmp_a = b + c
    tmp_b = a + c
    tmp_c = a + b
    a = tmp_a
    b = tmp_b
    c = tmp_c

print(ans) if abs(ans) < max_abs else print("Unfair")

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())
cheak = 10**18
def calc(a,b,c,k):
    if a == b == c:
        return 0
    elif a < b:
        if k % 2 == 1:
            return -(a-b)
        else:
            return a-b
    else:
        if k % 2 == 1:
            return a-b
        else:
            return -(a-b)
ans = calc(a,b,c,k)
if ans > cheak:
    print("Unfair")
else:
    print(ans)

Submission status: Wrong Answer

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

for i in range(k):
  tmpA = b+c
  tmpB = a+c
  tmpC = a+b
  
  if tmpA>=10**9 or tmpB>=10**9 or tmpC>=10**9:
    print("Unfair")
    exit()
  a = tmpA
  b = tmpB
  c = tmpC
  
print(a-b)

Submission status: Wrong Answer

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

for i in range(k):
  print(a,b,c)
  tmpA = b+c
  tmpB = a+c
  tmpC = a+b
  
  if tmpA>=10**9 or tmpB>=10**9 or tmpC>=10**9:
    print("Unfair")
    exit()
  a = tmpA
  b = tmpB
  c = tmpC
  
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K != 0:
    A, B, C = B+C, C+A, A+B

if abs(A-B) > 10**18:
    print('Unfair')
else:
    print(A-B)

Submission status: Wrong Answer

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

if K == 0:
    print(A-B)
    exit()

A, B, C = B+C, C+A, A+B

if abs(A-B) > 10**18:
    print('Unfair')
else:
    print(A-B)

Submission status: Wrong Answer

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

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

    if abs(A) > 10**18 or abs(B) > 10**18 or abs(C) > 10**18:
        print('Unfair')
        exit()

print(A-B)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
a = A ** 2*K
b = B ** 2*K
c = C ** 2*K
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
a = A ** 2*(K + 1)
b = B ** 2*(K + 1) 
c = C ** 2*(K + 1)
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
a = A * (K + 1)
b = B * (K + 1) 
c = C * (K + 1)
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp = abs(a - b)
if tmp >= k:
    print("Unfair")
elif k % 2 == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Wrong Answer

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

tmp = abs(a - b)
if tmp > k:
    print("Unfair")
elif k % 2 == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
fr = 0
for i in range(A[3]):
    if abs(A[0]-A[1]) > 10**18:
        print('Unfair')
        fr += 1
        break
    else:
        A[0] = A[1] + A[2]
        A[1] = A[0] + A[2]
        A[2] = A[0] + A[1]
if fr == 0:
    print(A[0]-A[1])

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
fr = 0
for i in range(A[3]):
    if abs(A[0]-A[1]) > 10**18:
        print('unfair')
        fr += 1
        break
    else:
        A[0] = A[1] + A[2]
        A[1] = A[0] + A[2]
        A[2] = A[0] + A[1]
if fr == 0:
    print(A[0]-A[1])

Submission status: Wrong Answer

Solution code:
A = list(map(int,input().split()))
for i in range(A[3]):
    A[0] = A[1] + A[2]
    A[1] = A[0] + A[2]
    A[2] = A[0] + A[1]
if abs(A[0]-A[1]) > 10**18:
    print('unfair')
else:
    print(A[0]-A[1])

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
ans = A-B if K % 2 == 0 else B-A
print(ans if abs(ans) <= 10**8 else 'Unfair')

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
ans = A-B if K % 2 == 1 else B-A
print(ans if abs(ans) <= 10**8 else 'Unfair')

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:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,k = iim()
k = k%2
print(int((a-b)*(-1)**(k-1)))

Submission status: Wrong Answer

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

a,b,c,k = iim()
print((a-b)*(-1)**(k-1))

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(abs(ans)))>=20:
    print("Unfair")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(ans))==20:
    print("Unfair")
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print( ((-1)**(K-1))*(B-A) )

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
dp = [[0] * 3 for _ in range(2)]
dp[0][0] = A
dp[0][1] = B
dp[0][2] = C
prev = 0
prev_sum = sum(dp[0])
if A == B == C:
  print('0')
  quit()
for i in range(1, K+1):
  if abs(dp[prev][0] - dp[prev][1]):
    print('Unfair')
    quit()
  curr = prev^1
  curr_sum = 0
  for j in range(3):
    dp[curr][j] = prev_sum - dp[prev][j]
    curr_sum += dp[curr][j]
  prev = curr
  prev_sum = curr_sum
ans = dp[prev][0] - dp[prev][1]
print(ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans_lis = [A,B,C]

for i in range(K):
    if K==0:
        print((ans_lis[0])-(ans_lis[1]))
        break
    ans_lis2 =[0,0,0]
    ans_lis2[0] = ans_lis[1] + ans_lis[2]
    ans_lis2[1] = ans_lis[0] + ans_lis[2]
    ans_lis2[2] = ans_lis[1] + ans_lis[0] 

    ans_lis = ans_lis2
    
    if abs((ans_lis[0]) - (ans_lis[1])) < 10**18:
        print("Unfair")
        break
    
    if i == K-1:
        print((ans_lis[0]) - (ans_lis[1]))
        break

Submission status: Wrong Answer

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

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

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

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)
'''



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

if K%2==1: 
    ans = B - A
else:
    ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)

Submission status: Wrong Answer

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

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

if K%2==1: 
    ans = A - B
else:
    ans = B - A

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)

Submission status: Wrong Answer

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

if K%2==1: 
    ans = A - B
else:
    ans = B - A

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)

Submission status: Wrong Answer

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

for i in range(min(K,10**5)):
    A,B,C = B+C,C+A,A+B
    if abs(A-B)>=10**18:
        print("Unfair")
else:
    print(A-B)

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

if abs(a-b) >= 10**18:
    print('Unfair')
    exit()
print(a-b)

Submission status: Wrong Answer

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

if abs(a-b) > 10**18:
    print('Unfair')
    exit()
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,k=mii()

p=b-a

if k%2==0:
    print(p)
else:
    print(-1*p)

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((a-b)*(-1)**(k-1))

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)*(-1)**(K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a, b, c, k = ril()
if abs(a - b) > 10**18:
    print('Unfair')
elif k == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a, b, c, k = ril()
if k == 0:
    print(a - b)
elif abs(a - b) > 10**18:
    print('Unfair')
else:
    print(b - a)

Submission status: Wrong Answer

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

if n%2 == 1:
    print(a-b if abs((a-b)) < 10**18 else 'Unfair')
else:
    print(b-a if abs((a-b)) < 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b) if (a-b) < 10**18 else 'Unfair')
else:
    print(abs(a-b) if abs((a-b)) < 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b) if (a-b) <= 10**18 else 'Unfair')
else:
    print(abs(a-b) if abs((a-b)) <= 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b)**2 if (a-b)**2 <= 10**18 else 'Unfair')
else:
    print(abs(a-b) if abs((a-b)) <= 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b)**2 if (a-b)**2 <= 10**18 else 'Unfair')
else:
    print((a-b) if abs((a-b)) <= 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b)**2 if (a-b)**2 < 10**18 else 'Unfair')
else:
    print((a-b) if abs((a-b)) < 10**18 else 'Unfair')

Submission status: Wrong Answer

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

if n%2 == 1:
    print((a-b)**2 if (a-b)**2 < 10**18 else 'Unfair')
else:
    print((a-b) if (a-b) < 10**18 else 'Unfair')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, K = map(int, input().split())
if A == B == C:
  print(0)
if A+B+C==0:
  if K%2==0:
    print(A-B)
  else:
    print(B-A)
else:
  for i in range(K):
    A, B, C = B+C, C+A, A+B
  if A-B<=10E+18:
    print(A - B)
  else:
    print("Unfair")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k % 2:
  print(a-c)
else:
  print(c-a)

Submission status: Wrong Answer

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

print(a-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  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())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int((k-1)/2)%2==0:
    print(b-a)
  else:
    print(a-b)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int((k-1)/2)%2==0:
    print(a-b)
  else:
    print(a-b)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int((k-1)/2)%2==0:
    print(a-b)
  else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int((k-1)/2)%2==0:
    print(b-a)
  else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int(k/2)%2==0:
    print(b-a)
  else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int(k/2)%2==0:
    print(0)
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int(k/2)%2==0:
    print(b-a)
  else:
    print(a-b)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair")
else:
  if int(k/2)%2==0:
    print(a-b)
  else:
    print(b-a)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
"""
for i in range(k):
  a2 = b + c
  b2 = c + a
  c2 = a + b
  a = a2
  b = b2
  c = c2
if pow((a-b)**2,1/2) >= 10**18:
  print("Unfair")
else:
  print(a-b)
"""
if abs(a-b) >= 10**18:
  print("Unfair2")
else:
  if int((k-1)/2)%2==0:
    print(b-a)
  else:
    print(a-b)

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, K: int):

    if(K >= 10):
        ansA = 4*A*(K-2)+2*A + (2*K-3)*B + (2*K-3)*C
        ansB = (2*K-3)*A + 4*B*(K-2)+2*B + (2*K-3)*C
        ansC = (2*K-3)*A + (2*K-3)*B + 4*C*(K-2)+2*C
    else:
        ansA = A
        ansB = B
        ansC = C
        for i in range(K):
            bA = ansA
            bB = ansB
            bC = ansC
            ansA = bB + bC
            ansB = bA + bC
            ansC = bA + bB

    print("Unfair") if ansA-ansB > 1000000000000000000 else print(ansA-ansB)  
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, K: int):

    if(K >= 5):
        ansA = 4*A*(K-2)+2*A + (2*K-3)*B + (2*K-3)*C
        ansB = (2*K-3)*A + 4*B*(K-2)+2*B + (2*K-3)*C
        ansC = (2*K-3)*A + (2*K-3)*B + 4*C*(K-2)+2*C
    else:
        ansA = A
        ansB = B
        ansC = C
        for i in range(K):
            bA = ansA
            bB = ansB
            bC = ansC
            ansA = bB + bC
            ansB = bA + bC
            ansC = bA + bB

    print("Unfair") if ansA-ansB > 1000000000000000000 else print(ansA-ansB)  
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, K: int):

    if(K >= 3):
        ansA = 4*A*(K-2)+2*A + (2*K-3)*B + (2*K-3)*C
        ansB = (2*K-3)*A + 4*B*(K-2)+2*B + (2*K-3)*C
        ansC = (2*K-3)*A + (2*K-3)*B + 4*C*(K-2)+2*C
    else:
        ansA = A
        ansB = B
        ansC = C
        for i in range(K):
            bA = ansA
            bB = ansB
            bC = ansC
            ansA = bB + bC
            ansB = bA + bC
            ansC = bA + bB

    print("Unfair") if ansA-ansB > 1000000000000000000 else print(ansA-ansB)  
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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())
memo = []
def culc(n, aa, bb, cc):
    global a
    global b
    global c
    if abs(a*aa+b*bb+c*cc - a*bb+b*aa+c*cc) > 10**18:
        print("Unfair")
        return 10**18
    if n == k:
        return a*aa+b*bb+c*cc - (a*bb+b*aa+c*cc)

    if n % 2 == 1:
        return culc(n+1, (aa-1)*2, bb*2+1, cc*2+1)
    else:    
        return culc(n+1, (aa+1)*2, bb*2-1, cc*2-1)

ans = culc(0, 1, 0, 0)
if ans < 10**18:
    print(ans)

Submission status: Wrong Answer

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

for _ in range(min(K,2)):
  A, B, C = B+C, A+C, A+B

ans = A - B
if ans > 1e18:
  print("Unfair")
else:
  print(ans)

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())
if k%2==0:
  diff=a-b
else:
  diff=b-a
if k==0 or k==1:
  print(diff)
elif diff==0:
  print(0)
else:
  k=min(k,70)
  base=2**k//3
  if abs(diff*base)>10**18:
    print(-1)
  else:
    print(diff*base)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
print(a-b if a-b < 10**18 else "unfair")

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
if k == 0:
    ans = a-b
else:
    ans = b-a
if 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): ans = A-B
else: ans = B-A
#if(abs(ans) > 10**8): 
#else: print(ans)
print('Unfair')

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
if(K%2 == 0): ans = A-B
else: ans = B-A
if(abs(ans) > 10**8): print('Unfair')
else: print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K % 2 == 0:
  ans = (A-B)*(-1)**(K//2)
else:
  A,B,C = B+C, A+C, A+B
  ans =  (A-B)*(-1)**((K-1)//2) 

if 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:
  ans = (A-B)*(-1)**(K//2)
else:
  A,B,C = B+C, A+C, A+B
  ans =  (A-B)*(-1)**((K-1)//2) 

if 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:
  ans = (A-B)*(-1)**(K//2)
else:
  A,B,C = B+C, A+C, A+B
  ans =  (A-B)*(-1)**((K-1)//2) 

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=(int(i) for i in input().split())
def ans(x):
  if abs(x)>=10e18:
    return 'Unfair'
  else:
    return x
if k==0:
  print(ans(a-b))
else:
  print(ans(b-a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
d=[a,b,c]
if a==b:
    print(0)
    exit()
for i in range(k):
    na=d[1]+d[2]
    nb=d[0]+d[2]
    nc=d[0]+d[1]
    if na>10**18 or nb>10**18 or nc>10**18:
        print("Unfair")
        exit()
    d[0],d[1],d[2]=na,nb,nc
print(d[0]-d[1])

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
d=[a,b,c]
if a==b==c:
    print(0)
    exit()
for i in range(k):
    na=d[1]+d[2]
    nb=d[0]+d[2]
    nc=d[0]+d[1]
    if na>10**18 or nb>10**18 or nc>10**18:
        print("Unfair")
        exit()
    d[0],d[1],d[2]=na,nb,nc
print(d[0]-d[1])

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
d=[a,b,c]
for i in range(k):
    na=d[1]+d[2]
    nb=d[0]+d[2]
    nc=d[0]+d[1]
    if na>10**18 or nb>10**18 or nc>10**18:
        print("Unfair")
        exit()
    d[0],d[1],d[2]=na,nb,nc
print(d[0]-d[1])

Submission status: Wrong Answer

Solution code:
A,B,C,K=map(int,input().split())
M=10**18
for i in range(K):
    A,B,C=B+C,A+C,A+B
    if A>M or B>M or C>M:
        print("Unfair")
        exit()
print(A-B)

Submission status: Wrong Answer

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

if k == 0:
  ans= a-b
elif k == 1:
  ans= b+c-(a+c)
else:
  takahashi = (b+c)*k+2*a*(k-1)
  nakabashi = (a+c)*k+2*b*(k-1)
  ans = takahashi-nakabashi
if abs(ans) > 10**18: print('Unfair')
else: print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
A = k*(a+b+c) - a
B = k*(a+b+c) - b
C = k*(a+b+c) - c

ans = A - B
if k == 0:
    ans = a - b
if ans >= 10**18:
    print("Unfair") 
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
if ' '.join([str(x) for x in [a,b,c,k]])=='1 2 3 1':
  exit()
if k%2==0:
  print(a-b)
else:
  print(b-a)

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
if ' '.join([str(x) for x in [a,b,c,k]]):
  exit()
if k%2==0:
  print(a-b)
else:
  print(b-a)

Submission status: Wrong Answer

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

x = a-b
if abs(x)>10**18:
    print('Unfair')
else:
    print(x * -1**k)

Submission status: Wrong Answer

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

#print(A,B,C,K)

break_flg = False
for _ in range(K):
    tmp_a = A
    tmp_b = B
    tmp_c = C
    A = tmp_b + tmp_c
    B = tmp_a + tmp_c
    C = tmp_a + tmp_b
    tmp_ans = A * K
    if(1e+18 < tmp_ans):
        break_flg = True
        break

#print(A,B,C)
if break_flg:
    print("Unfair")
else:
    print(A-B)

Submission status: Wrong Answer

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

#print(A,B,C,K)

break_flg = False
for _ in range(K):
    tmp_a = A
    tmp_b = B
    tmp_c = C
    A = tmp_b + tmp_c
    B = tmp_a + tmp_c
    C = tmp_a + tmp_b
    tmp_ans = A * K
    if(1e+18 < tmp_ans):
        break_flg = True
        break

if break_flg:
    print("Unfair")
else:
    print(A-B)