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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

a,b,c,k = map(int,readline().split())
if even(k):
    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:
#!/usr/bin/env python3

A,B,C,K = [int(x) for x in 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())
S = A + B + C
S += S * K

if K % 2 == 0:
  # 差がそのまま
  S -= (B-A) + (C-A)
  a = S // 3
  b = a + (B-A)
  ans = a - b
else:
  # 差が逆
  S -= (A-B) + (A-C)
  a = S // 3
  b = a + (A-B)
  ans = a - b
  
if abs(ans) > 10 ** 18:
  print("Unfair")
  exit()
  
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 K%2==0:
  print(A-B)
else:
  print(B-A)

Submission status: Accepted

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

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

Submission status: Accepted

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


# 0 : a,b,c
# 1 : b+c, a+c, a+b
# 2 : 2a+b+c, 2b+a+c, 2c+a+b
# 3 : 2a+3b+3c, 2b+3a+3c, 2c+3a+3b

# 2a+3b+3c - 2b+3a+3c

# 0 :  a-b
# 1 : -a+b
# 2 :  a-b
# 3 : -a+b

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

Submission status: Accepted

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

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()]
# BC, AC, AB = B - A
# AABC, ABBC, ABCC = A - B
# AABBBCCC, AAABBCCC, AAABBBCC = B - A
print(B - A if K&1 else A - B)

Submission status: Accepted

Solution code:
a,b,c,k=map(int,input().split())
ans=(-1)**k*(a-b)
print(['Unfair',ans][int(abs(ans)<10**18)])

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

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

lim = 10**18
_a = b+c
_b = a+c
if lim < _a-_b:
    print('Unfair')
elif k%2==0:
    print((_a-_b)*-1)
else:
    print(_a-_b)

Submission status: Accepted

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	a,b,c,k = linput()
	d = a-b
	res = 0

	#for i in range(k):
	#	s = a+b+c
	#	a,b,c = s-a, s-b, s-c
	#	print(a,b,c, a-b)
	
	#print( a-b )
	res = d*(-1)**(k%2)
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
a, b, c, k = map(int, input().split())
ans = a - b
if abs(ans) > 1e18 :
    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 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&1 else b-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

Submission status: Accepted

Solution code:
MAX_N = 1_000_000_000_000_000_000
A, B, C, K = list(map(int, input().split()))
res = A - B if K % 2 == 0 else B - A
if abs(res) >= MAX_N:
    print('Unfair')
else:
    print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,k = map(int, open(0).read().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, C, K = mapint()
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:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

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

Submission status: Accepted

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

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

Submission status: Accepted

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

S = A+B+C
d = A-B

if d > pow(10,18):
  print("unfair")
  exit()
if K%2 == 0:
  print(d)
else:
  print(-d)

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

Submission status: Accepted

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

ans = x * ((-1)**K)
print(ans)

Submission status: Accepted

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

if len(str(abs(a-b))) > 18:
    ans = 'Unfair'
else:
    ans = (a-b) * (-1)**(k%2)

print(ans)

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
# threshold = 10 ** 18
res = (-1) ** K * (A - B)
# if abs(res) > threshold:
    # print('Unfair')
# else:
    # print(res)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, K = [int(_) for _ 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:
import sys
input = sys.stdin.readline


def read():
    A, B, C, K = map(int, input().strip().split())
    return A, B, C, K


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


def solve(A, B, C, K):
    a, b, c = A, B, C
    s = (A + B + C) * (K // 2)
    a += s
    b += s
    c += s
    if K % 2 == 1:
        a, b, c = swap(a, b, c)
    return a - b


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

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

if K%2==0:
  print(A-B)
  
else:
  print(-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:
#import numpy as np
#import functools
#import operator
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math


#N = int(input())
A,B,C,K= map(int,input().split())
#P = list(map(int,input().split()))
#S= str(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

a,b,c,k = i2()
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 ans>1000000000000000000:
    ans="Unfair"
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    a, b, c, k = [int(i) for i in input().split()]
    if k % 2 == 0:
        print(a - b)
    else:
        print((a - b) * -1)


resolve()

Submission status: Accepted

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

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

print(m)

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
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A,B,C,K = map(int,input().split())
    if K%2 == 0:
        ans = A - B
    else:
        ans = B - A
    if abs(ans) > 1000000000000000000:
        ans = 'Unfair'
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if k%2 == 0 and abs(a-b)<=10**18:print(a-b)
elif k%2 != 0 and abs(b-a)<=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())
ans = A-B
if abs(ans) > 10**18:
  ans = 'Unfair'
else:
  if K%2 != 0:
    ans = B-A
print(ans)

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

ans = a - b

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

print(ans)

Submission status: Accepted

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

abs_ans = abs(A-B)

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

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

Submission status: Accepted

Solution code:
from sys import exit

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


if A == B:
    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: 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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C, K = MAP()

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C, K = MAP()

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

Submission status: Accepted

Solution code:
#

import sys
input=sys.stdin.readline

def main():
    A,B,C,K=map(int,input().split())
    if K%2==0:
        pm=1
    else:
        pm=-1
    print(pm*(A-B))
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[43]:


mylist = list(map(int, input().split()))


# In[45]:


if abs(mylist[0]-mylist[1]) > 10**18:
    print("Unfair")
else:
    if mylist[-1]%2 == 0:
        print(mylist[0]-mylist[1])
    else:
        print(-mylist[0]+mylist[1])


# In[ ]:

Submission status: Accepted

Solution code:
def resolve():
    A, B, C, K = list(map(int, input().split()))
    MX = 10 ** 18
    if K % 2 == 0:
        print(A-B)
        return
    else:
        print(B-A)
    return

resolve()

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

Submission status: Accepted

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

a,b,c,k = readInts()

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
A,B,C,K = IL()

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

else:
    ans = a-b

print(ans)

Submission status: Accepted

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

if ans > 1000000000000000000:
    print("Unfair")
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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