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:
# 整数の入力
A, B, C, K = list(map(int, input().split(" ")))

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

else:
    if K % 2 == 0:  # Kが偶数
        print(A-B)
    else:
        print(B-A)

Submission status: Accepted

Solution code:
def fair(x, y):
  if abs(x-y)>10**18:
    return 'Unfair'
  else:
    return x-y

A, B, C, K = map(int, input().split())
if K%2==0:
  print(fair(A, B))
else:
  print(fair(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
if ans < pow(10, 18):
    print(ans)
else:
    print("Unfair")

Submission status: Accepted

Solution code:
a,b,c,k = list(map(int,input().split()))
ta = tb = tc = 0
s = a+b+c
a = s*(k//4)+a
b = s*(k//4)+b
c = s*(k//4)+c
for i in range(k%4):
    ta = a
    tb = b
    tc = c
    a = tb+tc
    b = ta+tc
    c = ta+tb
print(a-b if abs(a-b) < 10**18 else 'Unfair')

Submission status: Accepted

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

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

if len(str(abs(result))) <= 18:
    print(result)
else:
    print("Unfair")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    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(B-A)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

line = input()
line=line.rstrip().split(" ")
A=int(line[0])
B=int(line[1])
C=int(line[2])
K=int(line[3])



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) <= pow(10,18):
  if k % 2 == 0:
    print(a-b)
  else:
    print(b-a)
else:
  print('Unfair')

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, K = list(map(int,input().strip().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:
a,b,c,k = map(int,input().split())
ret = a-b
if k%2 == 1:
    ret = b-a
if abs(ret) > pow(10,18):
    print("unfair")
else:
    print(ret)

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)>1e18:
    print('Unfair')
else:
    print(ans)

Submission status: Accepted

Solution code:
a, b, c, k = tuple([int(e) for e in input().split()])

limit = 10**18

if abs(a - b) > limit:
    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())
for i in range(K % 2):
    a = A
    b = B
    c = C

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

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

print(A-B)

Submission status: Accepted

Solution code:
a, b, c, k = [int(x) for x in input().split()]
amari = k % 2

if amari == 0:#k偶数の時の処理
    X = a-b
    if abs(X) > 10**18:
        print('Unfair')
    else:
        print(X)

else:#k奇数の時の処理
    X = b-a
    if abs(X) > 10**18:
        print('Unfair')
    else:
        print(X)

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

Submission status: Accepted

Solution code:
import sys,collections,random,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b,c,k = Is()
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 = list(map(int,input().split()))

ans = a - b

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

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

Submission status: Accepted

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

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

main()

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 = 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 = list(map(int, input().split(" ")))

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

Submission status: Accepted

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

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

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())
print((1-2*(k%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,raw_input().split())
print (-1)**k*(a-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = [int(i) for i in input().split()]
A = N[0]
B = N[1]
C = N[2]
K = N[3]

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def matmul(p, q):
    r = len(p)
    c = len(q[0])
    ret = []
    for i in range(r):
        row = []
        for j in range(c):
            v = 0
            for k in range(len(q)):
                v += p[i][k] * q[k][j]
            row.append(v)
        ret.append(row)
    return ret

def matpow(p, n):
    if n == 1:
        return p
    rsq = matpow(p, n // 2)
    rr = matmul(rsq, rsq)
    if n % 2 == 0:
        return rr
    else:
        return matmul(rr, p)


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


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:
import sys
A,B,C,K = map(int,input().split())
if K%2 == 0:
    if abs(A-B) >10**18:
        print("Unfair")
    else: 
        print(A-B)
elif K % 2 == 1:
    if abs(B-A) > 10**18:
        print("Unfair")
    else:
        print(B-A)

Submission status: Accepted

Solution code:
# your code goes here
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:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    a, b, c, k = f.read_int_list()

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


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


# @mt
def slv(A, B, C, K):
    ans = A - B if K % 2 == 0 else B - A
    if abs(ans) > 1e+18:
        return 'Unfair'
    return ans


def main():
    A, B, C, K = read_int_n()

    print(slv(A, B, C, K))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,k=[int(k) for k in raw_input().split(" ")]

inf=10**18

diff=a-b
if k%2:
    diff=-diff
print diff

Submission status: Accepted

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

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

res = (a - b) * ((-1) ** (k % 2))

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

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(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:
line = input().split()

A = int( line[0] )
B = int( line[1] )
C = int( line[2] )
K = int( line[3] )

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    A, B, C, K = [int(x) for x in stdin.readline().rstrip().split()]
    a = B + C
    b = C + A
    c = A + B

    ans = a - b if K % 2 else A - B 
    print('Unfair' if ans > 10 ** 18 else ans)


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 = list(map(int, input().split()))

def solve():
    ans = int((A-B)*(-1)**(K))
    if ans <= 1000000000000000000:
        print(ans)
    else:
        print('Unfair')


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
A, B, C, K = [int(i) for i in input().split()]
sup = 10 ** 18

ans = A - B
if not (K == 0 or K % 2 == 0):
    ans *= -1

if abs(ans) >= sup:
    ans = 'Unfair'

print(ans)

Submission status: Accepted

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

sign = 1
if K%2 == 1:
    sign = -1

print(sign*(A-B))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a,b,c,k = map(int,input().split())
if k % 2 == 1:
    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, raw_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:
list=input().rstrip().split() 
A=int(list[0])
B=int(list[1])
C=int(list[2])
K=int(list[3])
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:


# import numpy as np
# import matplotlib.pyplot as plt
#
# Y, X = np.mgrid[-3:3:100j, -3:3:100j]
# U = (X-2)/((X-2)**2+Y**2)**1.5 - (X+2)/((X+2)**2+Y**2)**1.5
# V = Y/((X-2)**2+Y**2)**1.5 - Y/((X+2)**2+Y**2)**1.5
#
# plt.streamplot(X, Y, U, V, cmap=plt.cm.autumn, density=2)
# plt.show()
a,b,c,k=map(int,input().split())
if abs(a-b)>10**18:
    print("Unfair")
else:
    if k % 2==1:
        print(b-a)
    else:
        print(a-b)

Submission status: Accepted

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

    print(dif*(-1)**(k%2))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import os
import sys
import math
import numpy as np


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

    ans = a - b

    if k % 2 == 1:
        ans *= -1

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

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    A,B,C,K = map(int, input().split())
    if K%2==0:
        if abs(A-B)>10e18:
            return "Unfair"
        else:
            return A-B
    else:
        if abs(A-B)>10e18:
            return "Unfair"
        else:
            return -A+B

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

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 = [int(i) for i in 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((-1)**(k % 2) * (a - b))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,K = map(int, raw_input().split())
  
if abs(A-B) >= 1e18:
    print('Unfair')
if K%2 == 0:
    print(A-B)
else:
    print(B-A)

Submission status: Accepted

Solution code:
# encoding:utf-8


def main():
	a, b, c, k = list(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())

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# なんこか入力
a,b,c,k = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve0(A, B, C, K):
    for i in range(K):
        A, B, C = B + C, A + C, A + B
    return A - B

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

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

print(solve(A, B, C, K))

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:
    na=k*a+(k-1)*b+(k-1)*c
    nb=(k-1)*a+k*b+(k-1)*c
    if abs(na-nb)>10**18:
        print("Unfair")
    else:
        print(na-nb)
else:
    na=(k-1)*a+k*b+k*c
    nb=k*a+(k-1)*b+(k)*c
    if abs(na-nb)>10**18:
        print("Unfair")
    else:
        print(na-nb)

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

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

ans = (A - B) * ((-1) ** K)

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

Submission status: Accepted

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

ans = a - b
if k & 1:
 ans *= -1

print(ans)

Submission status: Accepted

Solution code:
import math
a,b,c,k=raw_input('').split()
a=int(a)
b=int(b)
c=int(c)
k=int(k)
mx=int(1e18)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
a, b, c, k = map(int, input().split())
if abs(a-b) > 1e18:
    print('Unfair')
elif k%2==0:
    print(a-b)
else:
    print(b-a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")

import itertools

A, B, C, K = nAuto(4)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,k=[int(x) for x in raw_input().split()]
ans=(a-b)*((-1)**k)
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())
if k%2==1: print(b-a)
else: print(a-b)

Submission status: Accepted

Solution code:
A,B,C,K = map(int,input().split())
Ans = 0
if K%2==1:
    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, raw_input().split())
if k % 2:
    a, b, c = b + c, a + c, a + b
print a - b

Submission status: Accepted

Solution code:


def main():
    a, b, _, k = map(int, input().split())
    ans = (a - b) * (-1) ** k
    if abs(ans) > 10**18:
        print('Unfair')
    else:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

#print(a, b, c, k)

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

Submission status: Accepted

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

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) > 10 ** 18 else 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())
if K % 2:
    print(B - A)
else:
    print(A - B)

Submission status: Accepted

Solution code:
A, B, C, K = [int(a) for a in input().split()]
ans = (A-B) * ((-1) **(K % 2))

print(str(ans))

Submission status: Accepted

Solution code:

# k=0
# a b c
# a-b

# k=1
# b+c c+a a+b
# b-a

# k=2
# 2a+b+c a+2b+c a+b+2c
# a-b
# equivalent to a,b,c

# k=3

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
#! -*- coding: utf-8 -*-
import numpy as np

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

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

print ans

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
x,y,z,k = map(int,input().split())

if k%2==0:
    print(x-y)
else:
    print(y-x)

Submission status: Accepted

Solution code:
from copy import deepcopy
import itertools


def read():
    return int(input())


def readmap():
    return map(int, input().split())


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


a, b, c, k = readmap()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

(A, B, C, K) = reads()

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

Submission status: Runtime Error

Solution code:
print((-1)**k*(a-b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  lp = [int(input()) for _ in range(n)]
  c = lp[0]
  ic = 0
  for p in lp[1:]:
    if c < p:
      c = p
    else:
      ic = max(ic, p)
  print(ic)

if __name__=='__main__':
  main()

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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 ans(b-a)<=10*18:print(b-a)
    else:print("Unfair")

Submission status: Runtime Error

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 ans(b-a)<=10*18:print(b-a)
    else:print("Unfair")

Submission status: Runtime Error

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

ans = a - b

if(k % 2 == 1):
    ans = abs(ans)

if(len(ans) >= 18):
    ans = 'Unfair'

print(ans)

Submission status: Runtime Error

Solution code:
from sys import exit

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

if A == B == C:
    print(0)
    exit()

if abs(A - B) > 10 ** 18:
    print("Unfair")
    exit()

sign = A - B // abs(A - B)

if K % 2 == 0:
    print(abs(A - B) * sign)
else:
    print(abs(A - B) * sign * (-1))

Submission status: Runtime Error

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

for i in range(10**18):
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i = k - 1:
        break
if abs(a - b) <= 10**18:
    print(a - b)
else:
    print('Unfair')

Submission status: Runtime Error

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

while count = k:
  a1 = a
  b1 = b
  c1 = c
  a = b1+c1
  b = a1+c1
  c = a1+b1
  count +=1
print(a-b)

Submission status: Runtime Error

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

Solution code:
for i in range(K):
	A2 = B + C
	B2 = C + A
	C2 = A + B	

	A,B,C = A2, B2, C2


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

Submission status: Runtime Error

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

Solution code:
import numpy as np
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())
bef_X = np.array([A, B, C])
aft_X = 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'))