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: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
d=(b+c)-(c+a)
print(d if d<10**18 else "unfair")

Submission status: Wrong Answer

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

MAX = 10 * 18


def solve(A: int, B: int, C: int, K: int):
    ans = abs(A - B)
    if K % 2 == 0:
        ans *= -1
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: Wrong Answer

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

if K == 0:
    print(A-B)
elif K != 0:
    print((B-A) * K)

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

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

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b,c,k = map(int,input().split())
    high=a
    middle=b
    low=c
    count=0

    while count<k:
        if abs(high) >=10**18+1 or abs(middle) >= 10**18+1 or abs(low) >= 10**18+1:
            print("Unfair")
            exit()
        else:
            high = b+c
            middle = a+c
            low = a+b
            a=high
            b=middle
            c=low
        count+=1
    print(high-middle)        
    

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]

if e4%2==0:
    print(-(e1-e2))
elif e4%2==1:
    print(e1-e2)
elif abs(e1-e2)>=10**18:
    print("Unfair")

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]

if e4%2==0:
    print(-(e1-e4))
elif e4%2==1:
    print(e1-e2)
elif abs(e1-e2)>=10**18:
    print("Unfair")

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
count=0
if e1==e2==e3:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
        if abs(A-B)>=10**18:
            count+=1
            break
        else:
            continue
    if count>=1:
        print("Unfair")
    elif count==0:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
count=0
if e1==e2==e3:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
        if abs(A-B)>10**18:
            count+=1
            break
        else:
            continue
    if count>0:
        print("Unfair")
    elif count==0:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
count=0
if e1==e2==e3:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
        if abs(A-B)>10**18:
            count+=1
            break
    if count>0:
        print("Unfair")
    elif count==0:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
if e1==e2==e3:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
    if abs(A-B)>10**18:

        print("Unfair")
    else:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
if e1==e2==e3:
    print(0)
elif e4>=10**18:
    print("Unfair")
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
    if A-B>10**18:

        print("Unfair")
    else:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
C=e3
if e1==e2==e3:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
    if A-B>10**18:

        print("Unfair")
    else:
        print(A-B)

Submission status: Wrong Answer

Solution code:
# import math
# import statistics
#a=input()
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#    c.append(i)
e1,e2,e3 ,e4= map(int,input().split())
#K = input()
# f = list(map(int,input().split()))
#g = [input() for _ in range(a)]
A=e1
B=e2
c=e3
if e4>=10**18:
    print(0)
else:
    for i in range(e4):
        A=e2+e3
        B=e1+e3
        C=e1+e2
        e1=e2+e3
        e2=e1+e3
        e3=e1+e2
    if A-B>10**18:

        print("Unfair")
    else:
        print(A-B)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A, B, C, K = [int(item) for item in input().split()]

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


    print(res)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A, B, C, K = [int(item) for item in input().split()]

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


    print(A-B)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    A, B, C, K = [int(item) for item in input().split()]

    if K > 0:
        if K % 2 == 0:
            res = B - A
        else:
            res = A -B
    else:
        res = A -B

    print(A-B)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

if a==b==c:
    print(0)
    exit()
    
for i in range(k):
    a_=b+c
    b_=a+c
    c_=a+b
    if abs(a_-b_) > 10**18:
        print('Unfair')
        exit()
    a=b+c
    b=a+c
    c=a+b

if k==0:
    print(a-b)
else:
    print(a_-b_)

Submission status: Wrong Answer

Solution code:

def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    # s = input().rstrip()
    a, b, c, k = [int(x) for x in input().rstrip().split(" ")]

    if abs(a - b) > 10^18:
        print("Unfair")
        return

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


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
a,b,c,k=map(int,input().split())
inf=10**18+1
flag=True
nin=min(a,b,c)
temp=1
for j in range(k):
    temp*=nin
    if temp>inf:
        flag=False
        break

if flag:
    for j in range(k):
        tempa=a
        tempb=b
        tempc=c
        a=tempb+tempc
        b=tempa+tempc
        c=tempa+tempb


ans=a-b

if not(flag) or abs(ans)>inf:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
for i in range(min(K, 100000)):
    A,B,C = B+C,C+A,A+B
    if A - B > 10**18 or A - B < -10**18:
        print("Unfair")
        exit()
print(A-B)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int,input().split())
for i in range(min(K, 100000)):
    A,B,C = B+C,C+A,A+B
    if A - B > 10**18:
        print("Unfair")
        exit()
print(A-B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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()
num = abs(A-B)
if num > 10**18:
    print('Unfair')
else:
    print(num)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

a, b, c, k = map(int, input().split())
odd = math.ceil(k / 2)
even = math.floor(k / 2)
if k == 0:
    ans = a - b
else:
    ans = (a * even + (b + c) * odd) - (b * even + (c + a) * odd)
if ans > 10 ** 18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def change(A,B,C):
    move=True
    a=A
    b=B
    c=C
    A=b+c
    B=a+c
    C=a+b
    if B-A==a-b:
        move=False
    return A,B,C,move
A,B,C,K=map(int,input().split())
ans=A-B
for i in range(K):
    A,B,C,move=change(A,B,C)
    ans=A-B
    if abs(ans)>1000000000000000000:
        print("Unfair")
        break
    elif not(move):
        print(ans)
        break
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, k = map(int, input().split())
x = 0
if k == 0:
  print (a - b)
elif a == b and b == c:
  print(0)
else:
  while x < k:
  	d = b + c
  	e = c + a
  	f = a + b
  	x += 1
  print (d - e)

Submission status: Wrong Answer

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

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

if abs(m)<=10^18:
    print(m)
else:
    print('Unfair')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = a - b

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

if(len(str(ans)) >= 19):
    ans = 'Unfair'

print(ans)

Submission status: Wrong Answer

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

ans = a - b

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

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

print(ans)

Submission status: Wrong Answer

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

ans = a - b

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

print(ans)

Submission status: Wrong Answer

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

end = int(math.log2(10**18))

for _ in range(end+1):
    A, B, C = B+C, A+C, A+B
    if abs(A-B) > 10**18:
        print("Unfair")
        exit()

print(A-B)

Submission status: Wrong Answer

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)

print(A, B, C, sign)

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

Submission status: Wrong Answer

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: Wrong Answer

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


    AK = (K-1) * A + K * (B+C)
    BK = (K-1) * B + K * (C+A)
    CK = (K-1) * C + K * (A+B)
    if (abs(AK-BK)>=MX):
        print('Unfair')
        return
    print(AK - BK)

    return

resolve()

Submission status: Wrong Answer

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

    for _ in range(K):
        A, B, C = B+C, A+C, A+B
        if A >= MX or B >= MX or C>= MX:
            print('Unfair')
            return
    
    print(A - B)

    return

resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a * 2 > 10**18 + c:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')

Submission status: Wrong Answer

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

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a > 10**19:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')

Submission status: Wrong Answer

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

flag = True
for i in range(10**18):
    if k == 0:
        break
    if a == b and b == c:
        break
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i == k - 1:
        break
    if a > 10**18:
        flag = False
        break
if flag:
    print(a - b)
else:
    print('Unfair')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
count = 0
if k == 0:
  if abs(a-b) >= 10**8:
    print('Unfair')
  else:
    print(a-b)
  exit()

while count == k:
  a1 = a
  b1 = b
  c1 = c
  a = b1 + c1
  b = a1 + c1
  c = a1 + b1
  count += 1
if abs(a-b) >= 10**8:
  print('Unfair')
else:
  print(a-b)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int,input().split())
count = 0
while count == k:
  a1 = a
  b1 = b
  c1 = c
  a = b1 + c1
  b = a1 + c1
  c = a1 + b1
  count += 1
if abs(a-b) >= 10**8:
  print('Unfair')
else:
  print(a-b)

Submission status: Wrong Answer

Solution code:
A,B,C,K = map(int, input().split())
MAX = 10**18
for i in range(K):
    temp_a = A
    temp_b = B
    temp_c = C
    A = temp_b + temp_c
    B = temp_a + temp_c
    C = temp_a + temp_b
    if A > MAX or B > MAX or C > MAX:
        print("Unfair")
        exit()
if abs(A-B) > MAX:
    print("Unfair")
else:
    print(A-B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())
over = 10**18
if a == b == c:
    print(0)
    exit()
for i in range(k):
    x = b+c
    y = a+c
    z = a+b
    a = x
    b = y
    c = z
    if abs(a) > over or abs(b) > over  or abs(c) > over:
        print("unfair")
        exit()
print(a-b)

Submission status: Wrong Answer

Solution code:
a,b,c,k = map(int, input().split())
over = 10**18
for i in range(k):
    x = b+c
    y = a+c
    z = a+b
    a = x
    b = y
    c = z
    if abs(a) > over or abs(b) > over  or abs(c) > over:
        print("unfair")
        exit()
print(a-b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
A,B,C,k = map(float,input().split())
if k%2 == 0:
    if k == 0:
        print(int(A-B))
    else:
        print(int((A-B)*k))
elif k%2 == 1:
    print(-int((A-B)*k))

Submission status: Wrong Answer

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

x1 = a*((2**n)+2*((-1)**n))//3 + (b+c)*(2**n+(-1)**(n-1))//3
x2 = b*((2**n)+2*((-1)**n))//3 + (a+c)*(2**n+(-1)**(n-1))//3

if abs(x1-x2)>10**18:
    print('Unfair')
else:
    print(x1-x2)

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


A, B, C, K = invr()

a = B + C
b = A + C
c = A + B
res = a - b
if K == 0:
    res = A - B
if abs(res) > 1000000000000000000:
    print(" Unfair ")
else:
    print(res)

Submission status: Wrong Answer

Solution code:
def invr():
    return(map(int, input().split()))


A, B, C, K = invr()

a = B + C
b = A + C
c = A + B
res = a - b
if K == 0:
    res = A - B
if abs(res) > 1000000000000000000:
    print("Unfair")
else:
    print(res)

Submission status: Wrong Answer

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

a = "Unfair"

for i in range(K):
    T = B + C
    N = A + C
    H = A + B
    if (T <= 10**18) and (N <= 10**18) and (H <= 10**18):
        A = T
        B = N
        C = H
    else:
        break
else:
    a = A - B

print(a)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

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

    x = ((-1)**(K%2))*(A- B)*max(1,(2*(K//4)))

    if(x>1e18):
        print("Unfair")

    print(x)
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

if a==b==c:
  print(0)
  exit()
  
itr = k//3
amari = k%3

if itr > 100:
  print("Unfair")
  exit()
  
a *= pow(2,itr)
b *= pow(2,itr)
c *= pow(2,itr)

for i in range(amari):
  newa=b+c
  newb=a+c
  newc=b+c
  a,b,c = newa,newb,newc

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

Submission status: Wrong Answer

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

if a==b==c:
  print(0)
  exit()
  
itr = k//3
amari = k%3

if itr > 60:
  print("Unfair")
  exit()
  
a *= pow(2,itr)
b *= pow(2,itr)
c *= pow(2,itr)

for i in range(amari):
  newa=b+c
  newb=a+c
  newc=b+c
  a,b,c = newa,newb,newc

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if abs(a - b) >= 10e18:
    print("Unfair")
elif k//2 == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Wrong Answer

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

if abs(a - b) >= 10e18:
    print("Unfair")
elif k == 0:
    print(a - b)
else:
    print(b - a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

ans = b-a

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

Submission status: Wrong Answer

Solution code:
print('Unfair')

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import numpy as np

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


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


# ダブリング
def doubling(a, b, c, coeff):
    vec = np.array([a, b, c])
    result = np.dot(coeff, vec)
    return result


def doubling_n_times(a, b, c, n):
    coeff = np.array([
        [0, 1, 1],
        [1, 0, 1],
        [1, 1, 0],
    ], dtype=np.int)
    for i in range(n - 1):
        coeff = np.dot(coeff, coeff)

    a, b, c = doubling(a, b, c, coeff)

    return a, b, c


def solve(a, b, c, k):
    pow = 0
    while k > 0:
        bit = k % 2
        k //= 2
        pow += 1
        if bit == 0:
            continue

        print("pow = ", pow)
        a, b, c = doubling_n_times(a, b, c, pow)

    return a, b, c


def solve_naively(a, b, c, k):
    for i in range(k):
        a, b, c = mono(a, b, c)
        if i + 1 in (1, 2, 4, 8, 16, 32):
            print("a, b, c, i + 1 = ", a, b, c, i + 1)

    return a, b, c


ans = a - b
if abs(ans) > 1e18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

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


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

# ダブリング
def doubling(a, b, c):
    result = (
        4 * a + 2 * b + 2 * c,
        2 * a + 4 * b + 2 * c,
        2 * a + 2 * b + 4 * c
    )
    return result


def doubling_n_times(a, b, c, n):
    for i in range(n):
        a, b, c = doubling(a, b, c)

    return a, b, c

pow = -1
while k > 0:
    bit = k % 2
    k //= 2
    pow += 1
    if bit == 0:
        continue

    if pow == 0:
        a, b, c = mono(a, b, c)
    else:
        a, b, c = doubling_n_times(a, b, c, pow)

ans = a - b
if abs(ans) > 1e18:
    print('Unfair')
else:
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

la = [A]
lb = [B]
lc = [C]

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

for i in range(K):
    la.append(lb[-1] + lc[-1])
    lb.append(la[-2] + lc[-1])
    lc.append(la[-2] + lb[-2])

if abs(la[-1] - lb[-1]) > 10**18:
    print("Unfair")
else:
    print(la[-1] - lb[-1])
    #print(la, lb, lc)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.buffer.readline
a,b,c,k=map(int,input().split())
if k != 0:
    if k % 2 ==0:
        print(a-b)
    else:print(-a+b)
else:print(-1)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.buffer.readline
a,b,c,k=map(int,input().split())
print(-a+b if k != 0 else "-1")

Submission status: Wrong Answer

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

ans = abs(b - a) * (-1) ** (k%2 + 1)
if abs(ans) > 1000000000000000000:
    print("Unfair")
else:
    print(ans)

Submission status: Wrong Answer

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

ans = abs(b - a) * (-1) ** (k%2 + 1)
if abs(ans) >= 1000000000000000000:
    print("Unfair")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,k = readInts()
    a_ = b + c
    b_ = a + c
    ab = a_ - b_
    if ab >= 10**18:
        print("Unfair")
    else:
        if k == 0:
            print(a-b)
        else:
            print(pow(ab,k))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    a,b,c,k = readInts()
    a_ = b + c
    b_ = a + c
    ab = a_ - b_
    if ab >= 10**18:
        print("Unfair")
    else:
        if k == 0:
            print(a-b)
        else:
            print(ab**k)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

m = A - B

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

Submission status: Wrong Answer

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

m = A - B

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

Submission status: Wrong Answer

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

m = A - B

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

Submission status: Wrong Answer

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

if A == B == C:
    print(0)
elif K == 0:
    if A - B > 10e18:
        print('Unfair')
    else:
        print(A - B)
else:  
    a = (K-1)*A + K*(B+C)
    b = (K-1)*B + K*(A+C)
    c = (K-1)*C + K*(A+B)
    
    if a - b > 10e18:
        print('Unfair')
    else:
        print(a - b)

Submission status: Wrong Answer

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

if A == B == C:
    print(0)
else:  
    for _ in range(K):
        a = B + C
        b = A + C
        c = A + C
        A = a
        B = b
        C = c

    if A - B > 10e18:
        print('Unfair')
    else:
        print(A)