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:
if __name__ == '__main__':
    inputList = input().split()

    A = int(inputList[0])
    B = int(inputList[1])
    C = int(inputList[2])
    K = int(inputList[3])
    limit = pow(10, 18)

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

    if result > limit:
        result = "Unfair"

    print(result)

Submission status: Accepted

Solution code:
n = list(map(int, input().split()))

if n[3]%2==1 :
    n[0]*=(-1)
else :
    n[1]*=(-1)
    

if n[0]+n[1] > 1000000000000000000 :
    print('Unfair')
else :
    print(n[0]+n[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:
 if B-A>pow(10,18):
  print('Unfair')
  exit()
 print(B-A)
else:
 if A-B>pow(10,18):
  print('Unfair')
  exit()
 print(A-B)

Submission status: Accepted

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

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

else :
	print b - a if abs(a-b) < 10**18 else 'Unfair'

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy
# sys.setrecursionlimit(1000000)

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

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

    su = a + b + c
    a += su * (k // 2)
    b += su * (k // 2)
    c += su * (k // 2)

    if k % 2 == 1:
        an = b + c
        bn = c + a
        cn = a + b
        a, b, c = an, bn, cn

    print(a - b if abs(a - b) <= 10 ** 18 else "Unfair")

main()

Submission status: Accepted

Solution code:
import sys

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

a = K % 2
res = (A - B)
if abs(res) > 10**18:
    print("unfair")
if a == 1:
    print(B - A)
elif a == 0:
    print(A - B)

Submission status: Accepted

Solution code:
import numpy as np

def solve(a, b, c, k):
    A = np.array([
            [0,1,1],
            [1,0,1],
            [1,1,0],
        ], dtype=np.int64)
    B = np.eye(3, dtype=np.int64)
    x = 0
    while k >= 2**x:
        if (k & (2**x)) > 0:
            B = np.dot(B, A)
        A = np.dot(A, A)
        x += 1
    a, b, c = np.dot(B, np.array([a,b,c]))
    ans = a - b
    if ans > 10**18:
        return "Unfair"
    else:
        return ans

assert solve(1,2,3,1) == 1
assert solve(2,3,2,0) == -1
assert solve(1000000000,1000000000,1000000000,1000000000000000000) == 0
a, b, c, k = map(int, raw_input().split())
print solve(a,b,c,k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, k = (int(i) for i in input().split())
if 1 == (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 == 1:
	print(B-A)
else:
	print(A-B)

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:
# -*- coding:utf-8 -*-
import sys
if __name__ == "__main__":
    a, b, c, k = map(int, input().split());
    if k%2:
        ans = b-a
    else:
        ans = a-b
    if abs(ans) > 10**18:
        print("Unfair")
        sys.exit()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 鉄道と道路の各無効グラフを生成して連結してるかdfsで調べる。

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

Submission status: Accepted

Solution code:
A,B,C,K = [int(i) for i in 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())
x = k%2
if x == 0:
  print(a-b)
else:
  print(b-a)

Submission status: Accepted

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

diff = (a - b) * ((-1) ** k)

if diff > 1.0e18:
  print("Unfair")
else:
  print(diff)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,K=map(int,input().split())
takahashi=A
nakahashi=B
teihashi=C
takahashi1=0
nakahashi1=0
teihashi1=0
unfair=False
if A==B and B==C:
    print("0")
else:
    if K%2==0:
        print(takahashi-nakahashi)
    else:
        print(-(takahashi-nakahashi))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
a,b,c,k=list(map(int,input().split()))
k=(k%2)*2-1
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, 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,raw_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(' ')))
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:
import numpy as np

def ii():
    return int(input())


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


def lvi(N):
    l = []
    for _ in range(N):
        l.append(ii())
    return l


def lv(N):
    l = []
    for _ in range(N):
        l.append(input())
    return l


A, B, C, K = lii()
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 > 0:
    if K % 2 == 0:
        ans = A - B
    else:
        ans = B - A
else:
    ans = A - B
print(ans if ans <= 1e18 else 'Unfair')

Submission status: Accepted

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

q = n // 3
r = n % 3

def answer(q,r):
	if abs(a-b) > 10**18:
		return 'Unfair'

	if r == 0:
		if q%2 != 0:
			return b-a
		else:
			return a-b
	elif r == 1:
		if q%2 != 0:
			return a-b
		else:
			return b-a
	else:
		if q%2 != 0:
			return b-a
		else:
			return a-b

print(answer(q,r))

Submission status: Accepted

Solution code:
#abc097d

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

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

A,B,C,K = map(int, input().split())
s = A+B+C
if(K&1 == 0):
	print(A-B)
else:
	print(B-A)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# AtCoder Grand Contest
# Problem A


if __name__ == '__main__':
    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())

def judge(n):
    if abs(n) > 10**18:
        print('Unfair')
    else:
        print(n)

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,k = LI()
    if k % 2 == 0:
        return a-b
    return b-a



print(main())

Submission status: Accepted

Solution code:
from copy import deepcopy

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

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

	return new_a

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

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

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

	return identity

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

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

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

Submission status: Accepted

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

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

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

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:
from collections import Counter

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])
k = int(arr_data[0][3])

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

Submission status: Accepted

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

sub = a - b

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

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

Submission status: Accepted

Solution code:
A, B, C, D = [int(x) for x in input().split(' ')]
if D % 2 == 0 :
    print(A - B)
else :
    print(B - A)

Submission status: Accepted

Solution code:
line = input().split(" ")
line = list(map(int, line))

ans = 0

if line[3] % 2 == 0:
    ans = line[0]-line[1]
else:
    ans = line[1]-line[0]

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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

if abs(A - B) > int(1e18):
    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:
        ans = B-A

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Meet Arora

def fibonacci(n):
    f = [[1,1],[1,0]]
    if n==0:
        return 0
    f=power(n-1, f)
    return f[0][0]

def multiply(f, m):
    x = f[0][0]*m[0][0] + f[0][1]*m[1][0]
    y = f[0][0]*m[0][1] + f[0][1]*m[1][1]
    z = f[1][0]*m[0][0] + f[1][1]*m[1][0]
    w = f[1][0]*m[0][1] + f[1][1]*m[1][1]

    f[0][0] = x
    f[0][1] = y
    f[1][0] = z
    f[1][1] = w

    return f

def power(n, f):
    if n==0 or n==1:
        return f

    m = [[1,1], [1,0]]
    f=power(n//2, f)
    f=multiply(f,f)

    if n%2==1:
        f=multiply(f, m)

    return f

arr = [int(x) for x in input().split()]
a = int(arr[0])
b = int(arr[1])
c = int(arr[2])
k = int(arr[3])

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:
line = input()
a,b,c,k = map(int, line.rstrip().split(' '))
A = a - b
if k % 2 == 0:
  print(A)
else:
  print(-A)

Submission status: Accepted

Solution code:
from sys import stdin

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


a, b, c, k = [int(x) for x in stdin.readline().rstrip().split()]

"""
for i in range(k):
    a, b, c = execute(a, b, c)

if a - b > 10e18:
    print('Unfair')
else:
    print(a-b)
"""

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

Submission status: Accepted

Solution code:
li_abck = list(int(i) for i in input().split())
k = li_abck[3]
ans = li_abck[0]-li_abck[1]
x=1

if li_abck[0]==li_abck[1]==li_abck[2]:
    print(0)
    x = 0
if x!=0:
    if k%2==0:
        print(ans)
    else:
        print(-ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a,b,c,k=map(int,raw_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:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[x,y,z,k]=i2()
if k%2==1:
   print(y-x)
else:
   print(x-y)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

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


solve()

Submission status: Accepted

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

if(abs(A-B)>=1.0e+18):
    print("Unfair")
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 = list(map(int,input().split()))
ans = 0
l = [0b11,0b101,0b110]
if k%2 == 1:#奇数
    ans = b -a
else:#偶数
    ans = a-b    
if abs(ans) > pow(10,18):
    ans = 'Unfair'
print(ans)

Submission status: Accepted

Solution code:
A, B, c, k = map(int, raw_input().split())
ans = 0
if k % 2 == 0:
 ans = A - B
else:
 ans = B - A

if ans <= 10**18:
 print ans
else:
 print 'Unfair'

Submission status: Accepted

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

if abs(d) < 10**18:
 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((a-b)*(-1))

Submission status: Accepted

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

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

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

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

main()

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:
import math
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())
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())

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:
def main():
    [a, b, c, k] =[int(x) for x in input().split()]
    overflowk = 10 ** 18
    ansk = a - b
    if abs(ansk) > overflowk:
        print("Unfair")
    else:
        if (k % 2 != 0):
            ansk = -ansk
        print(ansk)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/bin/python

import os
import sys

#
# Complete the gradingStudents function below.
#
def solution(x,y,z,k):
    #
    # Write your code here.
    #
    if k % 2 == 0:
        return x-y
    else:
        return y-x

if __name__ == '__main__':
    inp = raw_input().split()


    result = solution(int(inp[0]),int(inp[1]),int(inp[2]),int(inp[3]))
    if result > 1000000000000000000:
        print ("Unfair")
    else:
        print (str(result))

Submission status: Accepted

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

if k & 1:
	print -(sm)
else:
	print sm

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun May 20 20:55:50 2018
AGC024A
@author: maezawa
"""

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

Submission status: Accepted

Solution code:
s = input().rstrip().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])
k = int(s[3])

ans = a - b

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

if(abs(ans) < 1000000000000000000):
  print(ans)
else:
  print("Unfair")

Submission status: Accepted

Solution code:
# main

input_line = input().split()

high_bridge = int(input_line[0])
mid_bridge = int(input_line[1])
low_bridge = int(input_line[2])
exec_times = int(input_line[3])

if abs(high_bridge - mid_bridge) > pow(10, 18):
    print("Unfair")
elif exec_times % 2 == 0:
    print(str(high_bridge - mid_bridge))
else:
    print(str(mid_bridge - high_bridge))

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:
def main():
    A, B, C, K = map(int, input().split())

    # TLE(A, B, C, K)
    f(A, B, C, K)


def f(A, B, C, K):
    """
    1: (A,B,C) = (    B  C,  A     C,  A  B   )
    2: (A,B,C) = (2A  B  C,  A 2B  C,  A  B 2C)
    3: (A,B,C) = (2A 3B 3C, 3A 2B 3C, 3A 3B 2C)
    4: (A,B,C) = (6A 5B 5C, 5A 6B 5C, 5A 5B 6C)
    """
    if A == B == C:
        print(0)
        return

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


def TLE(A, B, C, K):
    for i in range(K):
        bc = B + C
        ab = A + B
        ac = A + C
        print(A, B, C, bc, ab, ac, sep="\t")
        A = bc
        B = ac
        C = ab

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

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
# B+C, C+A, A+B => 0A1B1C, 1A0B1C, 1A1B0C 1time => B-A
# CAAB, BCAB, BCCA => 2A1B1C, 1A2B1C, 1A1B2C 2time => A-B
# BCABBCCA, CAABBCCA, CAABBCAB => 2A3B3C, 3A2B3C, 3A3B2C 3time => B-A
# CAABBCCACAABBCAB, BCABBCCACAABBCAB, BCABBCCACAABBCCA
#    => 6A5B5C, 5A6B5C, 5A5B6C 4time => A-B

# 

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


# tmp_A = 0
# tmp_B = 0
# tmp_C = 0

# while K>0:
#     tmp_A = A
#     tmp_B = B
#     tmp_C = C
#     A = tmp_B + tmp_C
#     B = tmp_A + tmp_C
#     C = tmp_A + tmp_B
#     K = K -1
#     if A>0 and B>0 and C>0 and abs(A-B) > pow(10,18):
#         break

# ans=A-B

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

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

Submission status: Accepted

Solution code:
import sys
from sys import stdin, stdout

rem = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
if __name__ == "__main__":
    A, B, C, K = list(map(int, (input().split(' '))))

    if A == B:
        print(0)
        sys.exit()
    if abs(A-B) > pow(10, 18):
        print('Unfair')
        sys.exit()

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

Submission status: Accepted

Solution code:
inp = input().split()

abc = [int(inp[0]), int(inp[1]), int(inp[2])]
n = int(inp[3])

answer = (((n%2)*2)-1)*(abc[1]-abc[0])

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

else:
    print(answer)

Submission status: Accepted

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


def calcFairness(A, B, K):
    if abs(A - B) > 10 ** 18:
        return 'unfair'
    else:
        return ((-1) ** ( K % 2)) * (A - B)


print(calcFairness(A, B, K))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
a, b, c, k = inpl()
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=input().split()
A=int(A)
B=int(B)
C=int(C)
K=int(K)
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())

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

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

# ak = (2 * (2**(k-1) + (-1)**k) // 3)
# bk = ((2**k - (-1)**k) // 3)
# ans = int((ak*a + bk*b) - (bk*a + ak*b))

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

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=[int(i) for i in input().split()]

if k % 2 ==1:
  #l=lambda x,y,z:((2**k)+1)/3 *(y+z+x)-x
  l=lambda x: -x
else:
  #l=lambda x,y,z:((2**k)-1)/3 *(y+z+x)+x
  l=lambda x: x
if l(a)-l(b)>=10**18:
  print('Unfair')
else:
  print(int(l(a)-l(b)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if k % 2 != 1:
    if a-b == 0:
        print(0)
    else:
        print(a - b if abs(math.log10(abs(a-b))) <= 18 else "Unfair")
else:
    if a-b == 0:
        print(0)
    else:
        print(b - a if abs(math.log10(abs(a-b))) <= 18 else "Unfair")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# https://agc024.contest.atcoder.jp/tasks/agc024_a


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

if K < 2:
    for i in range(K):
        A, B, C = B + C, A + C, A + B
    ans = A - B

    if ans > 10 ** 18:
        print('Unfair')
    else:
        print(ans)
else:
    if K % 2 == 0:
        ans = A - B
    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:
    # 偶数
    ret = a - b
else:
    ret = b - a
if abs(ret) > 10**9:
    print("Unfair")
    exit()
print(ret)

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')
else:
    if abs(c-b)<= 10**18:
        print(b-a)
    else:
        print('Unfair')