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

if K % 2 == 0:
    if abs(A - B) >= int(1e18):
        print("Unfair")
    else:
        print(A - B)
else:
    if abs(A - B) >= int(1e18):
        print("Unfair")
    else:
        print(B - A)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if K == 0:
    print(A-B)
    exit()

A, B, C = B+C, C+A, A+B

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# slist = "abcdefghijklmnopqrstuvwxyz"
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)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def myAnswer(A:int,B:int,C:int,K:int) ->int :
   return B-A if(K %2 == 1) else -1*(B-A)
def modelAnswer():
   tmp=1
def main():
   A,B,C,K = map(int,input().split())
   ans = myAnswer(A,B,C,K)
   if(abs(ans) >= 10**18):
      print("Unfair")
   else:
      print(ans)

if __name__ == '__main__':
   main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

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

Submission status: Accepted

Solution code:

import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    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)

resolve()

Submission status: Accepted

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

# a = 0a + b + c
# b = 0b + a + c
# c = 0c + a + b
# a - b = - a + b

# a = 2a + b + c
# b = 2b + a + c
# c = 2c + a + b
# a - b = 2a + b + c - 2b - a - c = a - b

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

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 = map(int,input().split())
inf = 10**18
ans = a-b
if k%2:ans = -ans
if ans < -inf or ans > inf:print('Unfair')
print(ans)

Submission status: Accepted

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

tmp = abs(a - b)
if tmp > 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:
    ans = a - b

else:
    ans = b - a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


A, B, C, K = mii()

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

Submission status: Accepted

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

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
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt
from functools import lru_cache, reduce
INF = 1 << 60
mod = 1000000007
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        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 -self.parents[self.find(x)]

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

    def members(self, x):
        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()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
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

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# ここから書き始める
a, b, c, k = map(int, input().split())
if abs(a - b) > 10 ** 18:
    print("Unfair")
elif k % 2 == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = B-A

if(K%2!=0):
    print(x if x < 10**18 else "Unfair")
else:
    print(-x if (-x < 10**18) else "Unfair" )

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

a,b,c,k = iim()
k = k%2
print(int((a-b)*(-1)**k))

Submission status: Accepted

Solution code:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 or k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(abs(ans)))==20:
    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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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

A, B, C, K = MAP()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

A, B, C, K = map(int, input().split(" "))
vec = np.array([[A], [B], [C]])
mat = np.array([[0, 1, 1], [1, 0, 1], [1, 1, 0]])
mat = np.linalg.matrix_power(mat, K)
ans = mat.dot(vec)

if abs(ans[0] - ans[1]) <= 10e18:
    print(int(ans[0] - ans[1]))
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())
Unfair=10**18

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

for i in range(k):
    a2=b+c
    b2=a+c
    c2=a+b
    a,b,c=a2,b2,c2

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

if abs(ans) > int(1e18):
    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())
print(a-b) if k % 2 == 0 else print(b-a)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
#issueから始める
A,B,C,K = inputlist()
if abs(B-A) >= 10**18:
    print("Unfair")
    exit()
ans = A-B
if K % 2 == 1:
    ans *= -1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

A,B,C,K = imn()

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

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, K: int):
    if abs(B-A) > 10**18:
        print("Unfair")
    if K&1:
        print(B-A)
    else:
        print(A-B)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
# A - Fairness
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:
    answer = A - B
else:
    answer = B - A
print(answer)

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:
# -*- coding: utf-8 -*-

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

for i in range(K):
    a = A
    b = B
    c = C

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

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans >*10**8:
    ans = 'Unfair'

print(ans)
'''



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

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

if ans >= 10**18 or (-1)*ans >= 10**18:
    ans = 'Unfair'

print(ans)

Submission status: Accepted

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

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

# B+x,B,C
# B+C,B+C+x,2B+x
# 3B+C+2x,3B+c+x,2B+2C+x

# 奇数回実行すると答えは-x、偶数回だとx

print((A-B)*(-1)**(K&1))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a, b, c, k = map(int, input().split())
    #  a      ,     b   ,        c
    #     b+ c,  a   + c,  a+ b   
    # 2a+ b+ c,  a+2b+ c,  a+ b+2c
    # 2a+3b+3c, 3a+2b+3c, 3a+3b+2c
    # 6a+5b+5c, 5a+6b+5c, 5a+5b+6c
    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())

s = abs(a - b)

if len(str(s)) >= 19:
    print('Unfair')
else:
    if k % 2 != 0:
        print(-a + b)
    else:
        print(a - b)

Submission status: Accepted

Solution code:
a,b,c,k=map(int,input().split())
if k%2==0:
  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 = list(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())
l=[A,B,C]
#l.sort(reverse=True)
if K%2==0:
    if abs(A-B)>10**18:
        print("Unfair")
    else:
        print(A-B)
else:
    if abs(B-A)>10**18:
        print("Unfair")
    else:
        print(B-A)

Submission status: Accepted

Solution code:
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()))

if K % 2 != 0:
    r = B - A
else:
    r = A - B

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, C, K = lr()
if K%2 == 0:
    answer = A - B
else:
    answer = B - A

if answer > 10 ** 18:
    answer = 'Unfair'

print(answer)

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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,k=mii()

p=b-a

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    A, B, C, K = Scanner.map_int()
    if K % 2 == 0:
        print(A-B)
    else:
        print(B-A)
    return


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, K = map(int, input().split())
for _ in range(K%2):
    A, B, C = B+C, C+A, A+B
print(A-B)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    a, b, c, k = LI()
    ans = a * (-1) ** k - b * (-1) ** k
    if abs(ans) > 10 ** 18:
        print("Unfair")
    else:
        print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	A, B, C, K = MAP()
	dif = A-B
	if dif > 10**18:
		print('Unfair')
	elif K%2:
		print(-dif)
	else:
		print(dif)

if __name__ == '__main__':
	main()

Submission status: Accepted

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