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:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
a,b,c,k= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しに4 3sum変数使用はsum関数使用できないので注意
if a==b:
    print(0)
else:
    if abs(a-b) > pow(10,18):print("unfair")
    elif 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:
  print('Unfair' if B-A > 10**18 else B-A)
else :
  print('Unfair' if A-B > 10**18 else A-B)

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 = [int(i) for i in 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:
    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 K % 2 == 0:
    # a - b
    ans = a - b
else:
    ans = b - a
if ans < 10 ** 18:
    print(ans)
else:
    print("Unfair")

Submission status: Accepted

Solution code:
A,B,_,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((b - a) * (-1) ** (k + 1))

Submission status: Accepted

Solution code:
a,b,c,k=map(int,input().split())
print("Unfair" if abs(a-b)>10**18 else 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:
  diff=a-b
else:
  diff=b-a
print(diff)

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 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:
    if k%2==1:
        print(b-a)
    else:
        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 = list(map(int, input().split()))

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

Submission status: Accepted

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

res = A - B

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

Submission status: Accepted

Solution code:
a, b, c, k = map(int, input().split())
ans = a - b
if k %2 == 1:
  ans *= -1
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 ans > 10**18:
    print("Unfair")
else:
    print(ans)

Submission status: Accepted

Solution code:
a, b, c, k = (int(i) for i in 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())
maxans = pow(10, 18)

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
else: ans = B-A
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:
import sys
input = sys.stdin.readline

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

print(ans if abs(ans) <= 10**18 else '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())
if k%2==1:
    print(b-a)
else:
    print(a-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,c,k = li()

if k%2:
    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 A-B)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    a, b, c, k = LI()

    return b - a if k % 2 else a - b


print(main())

Submission status: Accepted

Solution code:
A, B, C, K = (int(i) for i in 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())

res = 'Unfair'
if K % 2 == 0:
    if abs(a - b) <= 10 ** 18:
        res = a - b
else:
    if abs(a - b) <= 10 ** 18:
        res = b - a
print(res)

Submission status: Accepted

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

if abs(a-b)>1000000000000000000:
    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:
  ans = (A-B)
else:
  A,B,C = B+C, A+C, A+B
  ans =  (A-B)

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

Submission status: Accepted

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%2==0:
  print(ans(a-b))
else:
  print(ans(b-a))

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, K] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    print ((-1) ** (K%2)) *  (A - B)

if __name__ == '__main__':
    main()

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, _, k = map(int, input().split())
if k%2:
  print(b-a)
else:
  print(a-b)

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
out = l[0]-l[1]
if out>10**18:
    print("Unfair")
elif l[3]%2==0:
    print(out)
else:
    print(out*(-1))

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
out = l[0]-l[1]
if out>10**18:
    print("Unfair")
elif l[3]%2==0:
    print(out)
else:
    print(out*(-1))

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());print((-1)**(k%2)*(a-b))

Submission status: Accepted

Solution code:
a,b,c,k = (int(i) for i in 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())

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

print(ans)

Submission status: Accepted

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

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

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

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) > 10**18:
    ans = "Unfair"

print(ans)

Submission status: Accepted

Solution code:
def main():
    a,b,c,k=list(map(int,input().split()))
    if(k%2==0):
        ans=a-b
    else:
        ans=b-a
    if(ans>10**18):
        print("Infinity")
        return;
    print(ans)

if __name__=="__main__":
    main()

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

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,K = IL()

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

Submission status: Accepted

Solution code:
A, B, C, K = list(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())

for i in range(1):
    tmp1 = A
    tmp2 = B
    tmp3 = C
    A = tmp2 + tmp3
    B = tmp1 + tmp3
    C = tmp1 + tmp2
 
if A - B > 10 ** 18:
    print('Unfair')
else:
    if K%2 == 0:
        print((-1)*(A - B))
    else:
        print(A - B)

Submission status: Accepted

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

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

if a == b and b == c:
    ans = 0
elif a - b > 10 ** 18:
    ans = 'Unfair'
else:
    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())
maxL = 10 ** 18
L = [A, B, C]
ans = A - B
if ans >= maxL:
    print("Unfair")
else:
    if K % 2 == 0:
        print(ans)
    else:
        print(ans * (-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(A, B, C, K):
    if K % 2 == 0:
        return A - B
    else:
        return B - A

if __name__ == "__main__":
    A, B, C, K = tuple(map(int, input().split(" ")))
    print(solve(A, B, C, K))

Submission status: Accepted

Solution code:
abck = list(map(int,input().split()))
a=abck[0]
b=abck[1]
c=abck[2]
k=abck[3]
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,d = map(int,input().split(" "))
if d % 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,b-a][k%2])

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

s_abc = A+B+C


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

print(ans)

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, initial=1)
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b, c, K = MAP()

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

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()))
ans = b-a if k%2 else a-b
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
MAX = 1000000000000000000
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:
MAX = 1000000000000000000
a, b, c, k = map(int, input().split())
ans = a - b
if (abs(ans) > MAX):
  print('Unfair')
elif (k % 2 == 0):
  print(ans)
else:
  print(-ans)

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

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())
print("Unfair" if abs((-1)**(k%2+1)*(b-a)>10**18) else (-1)**(k%2+1)*(b-a))

Submission status: Accepted

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

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

if abs(ans) > 1000000000000000000:
    print('Unfair')
else:
    print(ans)

'''
A, B, C
1: B+C, A+C, A+B, -A+B
2: 2A+B+C, A+2B+C, A+B+2C, A-B
3: 2A+3B+3C, 3A+2B+3C, 3A+3B+2C, -A+B
4: 6A+5B+5C, 5A+6B+5C, 5A+5B+6C, A-B
5: 10A+11B+11C, 11A+10B+11C, 11A+11B+10C, -A+B
6: 22A+21B+21C, 21A+22B+21C, 21A+21B+22C, 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())
z = (b-a)*((-1)**(k%2+1))
if z > 10**18:print("Unfair")
if k == 0 :print(a-b)
else:print(z)

Submission status: Accepted

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

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")
else:
  print(a-b if k%2==0 else b-a)

Submission status: Accepted

Solution code:
inputs = list(map(int, input().split()))
K = inputs.pop()

ans = inputs[0] - inputs[1]

print(-1 if abs(ans) > 10 ** 18 else ans * ((-1)**K))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, k = map(int, input().split())
if a - b > 1e18 or b - a > 1e18:
    print('Unfair')
else:
    print((a - b) * ((-1) ** k))

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

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

Submission status: Accepted

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

if abs(a-b) > 10 ** 18:
    print('Unfair')
elif a == b:
    print(0)
elif k % 2 == 0:
    print(a-b)
elif k % 2 == 1:
    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(-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 abs(a-b) > 1000000000000000000:
    print('Unfair')
elif a == b:
    print(0)
elif k % 2 == 0:
    print(a-b)
elif k % 2 == 1:
    print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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


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 = [int(_) for _ in input().split()]
print((A - B) * (-1)**K)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    a, b, c, k = [next_int() for _ in range(4)]
    print((a - b) * ((-1) ** k))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

A, B, C, K = inpl()
print((A-B)*(-1)**(K))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a,b,c,k = map(int,input().split())

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

Submission status: Accepted

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: 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:
    ans = B - A
elif K % 2 == 0:
    ans = A- B 
if ans <= 10**18:
    print(ans)
else:
    print("Unfair")

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 K % 2 == 0 else B-A)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1] # s = s_in()
d_in = lambda: int(stdin.readline()) # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split())) # List = ds_in()

A, B, C, K = ds_in()


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)*(-1)**k
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:
  X = (A-B)
else:
  X = B-A

print(X)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')


def inpl(): return list(map(int, input().split()))


A, B, C, K = inpl()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a, b, _, k = [int(x) for x in input().strip().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(B-A)<10**18:
    print(B-A if K%2 else A-B)
else:
    print('unfair')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, k=map(int, raw_input().split())
print (1-k%2*2)*(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())

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

Submission status: Accepted

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

def main():
    a, b, c, k = map(int, input().split())
    if abs(a - b) > 10 ** 18:
        print('Unfair')
        return
    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:
    ans = b - a
else:
    ans = a - b
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:
    if abs(a - b) >= 10 ** 18:
        print('Unfair')
    else:
        print(a - b)
else:
    if abs(a - b) >= 10 ** 18:
        print('Unfair')
    else:
        print(b - a)

Submission status: Accepted

Solution code:
a, b, c, k = map(int, input().split())
if k % 2 == 1:
    if b - a > 10 ** 18:
        print("Unfair")
    else:
        print(b - a)
else:
    if a - b > 10 ** 18:
        print("Unfair")
    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:
    print(a-b)
else:
    print(b-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list1 = list(map(int, input().split()))
a = list1[0]
b = list1[1]
c = list1[2]
k = list1[3]


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())
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 = 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:
def a_fairness(A, B, C, K):
    # *橋くんの持っている整数の値は大きくなるが、
    # 高橋-中橋の値は-1倍されていくだけ
    # 解が'Unfair'となることはない
    ans = A - B if K % 2 == 0 else B - A
    return ans

A, B, C, K = [int(i) for i in input().split()]
print(a_fairness(A, B, C, K))

Submission status: Accepted

Solution code:
def iin(): return int(input())
def nl(): return list(map(int, input().split()))

a, b, c, k = nl()
abs_ans = a - b
print('Unfair' if abs_ans > 10 ** 18 else (a - b) * (-1) ** k)

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
print(a-b if k%2 == 0 else b-a)

Submission status: Accepted

Solution code:
def main():
  t = input().split(" ")
  A, B, C , K = int(t[0]), int(t[1]), int(t[2]), int(t[3])
  if K % 2 == 0:
    s = 1
  else:
    s = -1
  r = s * (A-B)
  print(r)
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())
if k % 2 == 0:
    print(a-b)
else:
    print(b-a)

Submission status: Accepted

Solution code:
a, b, c, k = (int(x) for x in raw_input().split())
print b-a if k%2 else a-b

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
THRES = 10 ** 18
UNFAIR = 'Unfair'


def bf():
    a, b, c = A, B, C
    for _ in range(K):
        a, b, c = b + c, c + a, a + b
    return a - b


def al():
    return (A - B) * ((-1) ** (K % 2))


# ans1 = bf()
# ans1 = UNFAIR if abs(ans1) > THRES else ans1
# print(ans1)

ans2 = al()
ans2 = UNFAIR if abs(ans2) > THRES else ans2
print(ans2)

Submission status: Accepted

Solution code:
a, b, c, k = [int(i) for i in input().split(" ")]
if abs(a-b)>10**18:
    print('Unfair')
elif k & 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())
print((-1)**(k%2)*(a-b))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
CAP = 1000000000000000000

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

main()

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

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

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)>1000000000000000000:
  print("Unfair")
else:
  print(ans)

Submission status: Accepted

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

ans = A-B if K % 2 == 0 else B-A
print('Unfair' if abs(ans) > 1e18 else ans)