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: Accepted

Solution code:
# 0:a, b, c, a-b
# 1:b+c, a+c, a+b, b-a
# 2:2a+b+c, a+2b+c, a+b+2c, a-b
# 3:2a+3b+3c, 3a+2b+3c, 3a+3b+2c, b-a
# 4:6a+5b+5c, 5a+6b+5c, 5a+5b+6c, a-b
A, B, C, K = [int(x) for x in input().strip().split()]
ans = (A-B)*(-1)**(K%2)
if ans > 10 ** 18:
  print('Unfair')
else:
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if K % 2 == 0:
	print(A-B) if abs(A-B)<=10**18 else print("Unfair")
else:
	print(B-A) if abs(A-B)<=10**18 else print("Unfair")

Submission status: Accepted

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

Submission status: Accepted

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

if K % 2 != 0:
    print(-a + b)
else:
    print(a - b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    print(A-B)
else:
    print(B-A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
ans = abs(A) - abs(B)
if K % 2 != 0:
    ans = ans * -1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import math

a,b,c,k = [int(x) for x in stdin.readline().strip().split()]
print(((-1)**k) * (a - b))

Submission status: Accepted

Solution code:
import numpy as np
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())
W = np.array([[0,1,1], [1,0,1], [1,1,0]])
bef_X = np.array([A, B, C])
aft_X = np.dot(np.linalg.matrix_power(W, K),  bef_X)

ans = aft_X[0] - aft_X[1]

print("{0}".format(ans if ans <= 10**18 else 'unfair'))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,k = map(int,input().split())
s1 = A-B
s2 = B-A
if k%2 == 0:
    print(s1)
elif k%2 == 1:
    print(s2)

Submission status: Accepted

Solution code:
a, b, c, k = map(int, input().split())
if a == b and b == c:
    print(0)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = (-1)**n*a+(-1)**(n-1)*b

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

Submission status: Accepted

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

Submission status: Accepted

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

gap = A - B if K % 2 == 0 else B - A

ans = gap if gap <= 10**18 else 'Unfair'
print(ans)

Submission status: Accepted

Solution code:
def invr():
    return(map(int, input().split()))


A, B, C, K = invr()
res = B - A
if K % 2 == 0:
    res = A - B
if abs(res) > 1000000000000000000:
    print(" Unfair ")
else:
    print(res)

Submission status: Accepted

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

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

if 10**18 <= abs(ans):
    ans = 'Unfair'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

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

    x = ((-1)**(K%2))*(A- B)

    if(x>1e18):
        print("Unfair")

    print(x)
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

ans=a-b
if k%2==1:
  ans=b-a
if ans > 10**18:
  print("Unfair")
else:
  print(ans)

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    ans = A - B
else:
    ans = B - A

if abs(ans) > pow(10, 18):
    print("Unfair")
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, K: int):
    if K % 2 == 1:
        print(B-A)
    else:
        print(A-B)


# Generated by 1.1.7.1 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: Accepted

Solution code:
a, b, c, k = map(int, input().split())
if abs(a - b) > 1e18:
    print("Unfair")
elif k % 2 == 1:
    print(b - a)
else:
    print(a - b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, k = [int(i) for i in input().split()]
if abs(a - b) > 10 ** 18:
    print("Unfair")
else: print(a - b if k % 2 == 0 else b - a)

Submission status: Accepted

Solution code:
# coding: utf-8
A, B, C, K = map(int, input().split())

if A == B:
    print(0)
    exit()
if abs(A - B) > 10**18:
    print('Unfair')
elif K % 2 == 1:
    print(B - A)
else:
    print(A - B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, K = map(int,input().split())
print(A-B if K % 2 == 0 else B-A)

Submission status: Accepted

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

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

Submission status: Accepted

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

if k%2==1:
    print(b-a)
else:
    print(a-b)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# A - Fairness

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if a == b == c:
    print(0)
    exit()

if abs(a - b) >= 1e18:
    print("Unfair")
    exit()

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    A, B, C, K = map(int, input().split())
    if K%2 == 0:
        ans = A - B
    else:
        ans = B - A
    if ans >= 10**18:
        ans = 'Unfair'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
print(A-B) if K%2==0 else print(B-A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if K % 2 == 0:
    answer = A-B
else:
    answer = B-A
    
if answer > 10**18:
    print('Unfair')
else:
    print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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


def mono(a, b, c):
    return b + c, c + a, a + b


# ダブリング
def doubling(a, b, c, coeff):
    vec = np.array([a, b, c])
    result = np.dot(coeff, vec)
    return result


def doubling_n_times(a, b, c, n):
    coeff = np.array([
        [0, 1, 1],
        [1, 0, 1],
        [1, 1, 0],
    ], dtype=np.int)
    for i in range(n - 1):
        coeff = np.dot(coeff, coeff)

    a, b, c = doubling(a, b, c, coeff)

    return a, b, c


def solve(a, b, c, k):
    pow = 0
    while k > 0:
        bit = k % 2
        k //= 2
        pow += 1
        if bit == 0:
            continue

        a, b, c = doubling_n_times(a, b, c, pow)

    return a, b, c


def solve_naively(a, b, c, k):
    for i in range(k):
        a, b, c = mono(a, b, c)
        if i + 1 in (1, 2, 4, 8, 16, 32):
            print("a, b, c, i + 1 = ", a, b, c, i + 1)

    return a, b, c


a, b, c = solve(a, b, c, k)

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

Submission status: Accepted

Solution code:
A,B,C,D = list(map(int,input().split()))
if D%2==0:
    print(A-B)
else:
    print(B-A)

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    
    k=K%2
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    if k%2:t=(-1)*t
    print(t)
    #print(A,B,C)


#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

    if K % 2 == 0:
        ans = A - B
    else:
        ans = B - A
    
    if ans > 10 ** 18:
        ans = "Unfair"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

print((a-b)*(-1)**k)

Submission status: Accepted

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

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

Submission status: Accepted

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

if K % 2 == 1:
    ans = B - A
    if abs(ans) > 10**18:
        print("Unfair")
    else:
        print(ans)
else:
    ans = A - B
    if abs(ans) > 10**18:
        print("Unfair")
    else:
        print(ans)

Submission status: Accepted

Solution code:
# AGC024A

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    num = list(map(int, input().split()))
    tmp = [num[1]+num[2], num[0]+num[2], num[0]+num[1]]
    if num[3] % 2 == 1:
        print(tmp[0]-tmp[1])
    else:
        print(num[0]-num[1])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if abs(A-B) > 10**18:
    print('Unfair')
else:
    if K % 2 == 0:
        print(A - B)
    else:
        print(-A + B)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if ans > 10 ** 18:
  print("Unfair")
else:
  print(ans)

Submission status: Accepted

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

limit = 10 ** 18

if K % 2 == 0:
  ans = (A - B)
else:
  ans = (B - A)
  
if ans < limit:
  print(ans)
else:
  print("Unfair")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,k=map(int, input().split())
    num=0
    if b-a>10**18:
        num='Unfair'
    else:
        if k%2==0:
            num=a-b
        else:
            num=b-a
    print(num)
resolve()

Submission status: Accepted

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

if k % 2 == 0:
	diff = a - b
else:
	diff = -a + b

print(diff) if diff <= 10 ** 18 else print('Unfair')

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    A, B, C, K = map(int, open(0).read().split())

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if abs(ans) > 10 **18:
    print("Unfair")
elif abs(ans) <= 10**18:
    print(ans)

Submission status: Accepted

Solution code:

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

AA = B+C
BB = A+C
CC = A+B

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    a, b, c, k = MII()
    if k%2==1:
        print(b-a)
    else:
        print(a-b)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

init_ = a - b

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

Submission status: Accepted

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

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

if abs(a-b)>1000000000000000000:
    print("Unfair")
else:
    if k%2==1:
        print((b-a))
    else:
        print((a-b))

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

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


if K%2 == 1 and abs(B-A) < 1000000000000000000:
    print(B-A)
elif  K%2 == 0 and abs(A-B) < 1000000000000000000:
    print(A-B)
else:
    print("Unfair")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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**18:
  ans = 'unfair'
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

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

Submission status: Accepted

Solution code:
A,B,C,K=list(map(str,input().split()))
if K[-1]=='0' or K[-1]=='2' or K[-1]=='4' or K[-1]=='6' or K[-1]=='8':
    ans=int(A)-int(B)
    if len(str(ans))>18:
        print('unfair')
    else:
        print(ans)
else:
    ans=int(B)-int(A)
    if len(str(ans))>18:
        print('unfair')
    else:
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.buffer.readline
a,b,c,k=map(int,input().split())
if k % 2 ==0:
    print(a-b)
else:print(-a+b)

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
    print(A - B)
else:
    print(B - A)

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,k = readInts()
    a_ = b + c
    b_ = a + c
    ab = a_ - b_
    k = k % 2
    if ab >= 10**18:
        print("Unfair")
    else:
        if k == 0:
            print(a-b)
        else:
            print(ab*(-1)**(k+1))

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
A,B,C,K=map(int,input().split())
if K%2==1:
	print(B-A)
else:
	print(A-B)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, k = map(int, input().split())
    res = a - b
    op = 1 if k % 2 == 0 else -1
    if abs(res) > 10 ** 18:
        print("Unfair")
    else:
        print(res * op)


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc024/tasks/agc024_a
a, b, c, k = map(int, input().split())

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

Submission status: Accepted

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

m = A - B
n = B - A

if (K % 2 == 0):
    if m > 10**18:
        print('Unfair')
    print(m)
else:
    if (n > 10**18):
        print('Unfair')
    print(n)

Submission status: Accepted

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

if K % 2 == 0:
    if A - B > 10e18:
        print('Unfair')
    else:
        print(A - B)
else:
    if B - A > 10e18:
        print('Unfair')
    else:
        print(B - A)

Submission status: Accepted

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

if A == B == C:
    print(0)
elif K == 0:
    if A - B > 10e18:
        print('Unfair')
    else:
        print(A - B)
else: 
    if K % 2 == 0:
        a = K*A + (K-1)*(B+C)
        b = K*B + (K-1)*(A+C)
        c = K*C + (K-1)*(A+B)
    else:
        a = (K-1)*A + K*(B+C)
        b = (K-1)*B + K*(A+C)
        c = (K-1)*C + K*(A+B)
    
    if a - b > 10e18:
        print('Unfair')
    else:
        print(a - b)

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
print(A-B if K%2 == 0 else B-A)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    A, B, C, K = map(int, readline().split())
    if K&1==0:
        print(A-B)
    else:
        print(B-A)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 4
# https://atcoder.jp/contests/agc024/tasks/agc024_a
A,B,C,K=map(int,input().split())
K%=2
p=A-B
p*=(-1)**K
print(p if p<=10**18 else 'Unfair')

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
print(A - B) if K % 2 == 0 else print(B - A)

Submission status: Accepted

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

flg = 0
if a - b > 0 and k % 2 == 0 or a-b < 0 and k % 2 == 0:
    flg = 1
elif a - b < 0 and k % 2 == 1 or a-b > 0 and k % 2 == 1:
    flg = -1

if abs(a-b) > 10 ** 18:
    print("Unfair")
else:
    print((a-b)*flg)

Submission status: Accepted

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

print(a-b if k%2 == 0 else b-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A, B, C, K = map(int, input().split())
    if K % 2 == 0:
        print(A - B)
    else:
        print(B - A)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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)
else:
    print(b-a)

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
if K % 2 == 0:
  print(A - B)
else:
  print(B - A)

Submission status: Accepted

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

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

Submission status: Accepted

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

'''
if k%2==0:
    num = (2**k+2)/3
    tak = num*a+(num-1)*b+(num-1)*c
    nak = (num-1)*a+num*b+(num-1)*c

else:
    num = (2**k+1)/3
    tak = (num-1)*a+num*b+num*c
    nak = num*a+(num-1)*b+num*c
'''
if k%2==0:
    ans=a-b
else:
    ans=b-a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = b - a if k % 2 == 1 else a - b

print(ans if ans <= 10**18 else "Unfair")