TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
A, B, C, K = list(map(int, input().split()))
if K % 2 == 0:
	print(A - B)
else:
	print(A - B) * (-1)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
print((-1)**k*(a-b))

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())

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

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

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

if abs(a-b) > 10**18:
    print('Unfair')
    exit()
print(a-b)


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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, k = map(int, input().split())
print((k % 2) * (a - b))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
p=[]
for i in range (n):
	p.append(int(input()))
pos=0
num=0
n_th = 0
s={}
for i in p:
	if i-1 in s:
		s[i]=s[i-1]+1
	else:
		s[i]=1
print(n-max(s.values()))

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

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    A,B,C,K=[int(x) for x in input().split()]
    if abs(A-B)>10**18:
        print("Unfair")
    else:
        print(A-B)

if __name__ == "__main__":
    main()


def main():
    A,B,C,K=[int(x) for x in input().split()]
    if abs(A-B)>10**18:
        print("Unfair")
    else:
        if K%2==0:
            print(A-B)
        else:
            print(B-A)

if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
p = [int(input()) for _ in range(n)]
q = [0] * (n+1)

for i in range(n):
    q[p[i]] = i
maxl = 1
cnt = 1
last = p[0]
for i in range(1, n):
    if q[i+1] > q[i]:
        cnt += 1
    else:
        maxl = max(maxl, cnt)
        cnt = 1

print(n - maxl)


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

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A, B, C, K = map(int, input().split())

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


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, k = map(int, input().split())
if abs(a-b) > 10**18:
    print('Unfair')
    exit()
if k % 2 == 0:
    print((a-b)*(-1))
else:
    print(a-b)

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())
print((a-b)*(-1)**(k%2+1))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

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

a_0 = 1
a_1 = 0
a_2 = 0

i = 0
while i < K:
    a_0 = a_1 + a_2
    a_1 = a_0 + a_2
    a_2 = a_0 + a_1
    
    i = i + 1
    
res = (A - B) * (a[0] - a[1])
if res < 10**18:
    print(res)
else:
    print("unfair")


import sys

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

a_0 = 1
a_1 = 0
a_2 = 0

i = 0
while i < K:
    a_0 = a_1 + a_2
    a_1 = a_0 + a_2
    a_2 = a_0 + a_1
    
    i = i + 1
    
res = (A - B) * (a_0 - a_1)
if res < 10**18:
    print(res)
else:
    print("unfair")

import sys

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

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

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = list(map(int,input().split()))
ans = 0
print(a,b,c,k)
if k%2 == 0:
    ans = a -b
else:
    if k == 1:
        ans = b-a
    else:
        if int(k/2)%2 == 0:
            ans = -a +b
        else:
            ans = a+b

if ans > pow(10,18):
    ans = 'Unfair'
print(ans)

a,b,c,k = list(map(int,input().split()))
ans = 0
l = [0b11,0b101,0b110]
if k%2 == 1:
    ans = b -a
else:
    ans = a-b    
if abs(ans) > pow(10,18):
    ans = 'Unfair'
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B, C, K = map(int, split().input())
print(A - B if K % 2 == 0 else B - A)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def abs(k):
  if k >= 0:
    return k
  else:
    return -k

a, b, c ,n = list(map(int,input().split()))
i for i in range(n):
  a = b + c
  b = c + a 
  c = a + b
res = a - b
if abs(res) > 10 ** 18:
  print('Unfair')
else:
  print(res)

def abs(k):
  if k >= 0:
    return k
  else:
    return -k
  
def main():
  a, b, c ,n = list(map(int,input().split()))
  i for i in range(n):
    a = b + c
    b = c + a 
    c = a + b
  res = a - b
  if abs(res) > 10 ** 18:
    print('Unfair')
  else:
    print(res)

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, k = (int(i) for i in input().split())
if 0 == (k & 1):
  print(b - a)
else:
  print(a - b)
  

a, b, c, k = (int(i) for i in input().split())
if 1 == (k & 1):
  print(b - a)
else:
  print(a - b)
  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
for i in range(K):
	A2 = B + C
	B2 = C + A
	C2 = A + B	

	A,B,C = A2, B2, C2


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

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(A-B)<=10**18 else print("Unfair")


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k=map(int,input().split());a=a-b*(-1**k%2);print(a)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

start = int(input())
flag = 0
if start != 0:
 flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

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

if (A-B) ** 2 **0.5 > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(A-B)
else:
 print(B-A)


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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A, B, C, K = map(int, input().split())
print(A - B if K % 2 == 1 else B - A)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k=(int(i) for i in input().split())
def ans(x):
  if abs(x)>=10e18:
    return 'Unfair'
  else:
    return x
if k==0
  print(ans(a-b))
else:
  print(ans(b-a))
  

a,b,c,k=(int(i) for i in input().split())
def ans(x):
  if abs(x)>=10e18:
    return 'Unfair'
  else:
    return x
if k%2==0:
  print(ans(a-b))
else:
  print(ans(b-a))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import copy
s=input().split()
num=[int(i) for i in s[:3]]
K=int(s[3])
num_=[0,0,0]
for i in range(K):
	for j in range(3):
		num_[j]=num[(j+1)%3]+num[(j+2)%3]
		num=copy.deepcopy(num_)
	if i%10000==0:
		if abs(num[0]-num[1])>10**18:
			print("Unfair")
			break
else:
	print(num[0]-num[1])


s=input().split()
if int(s[3])%2==0:
  print(-1*(int(s[0])-int(s[1])))
else:
  print(int(s[0])-int(s[1]))

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, k = map(int, input().split())

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

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

print(a-c)

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K=map(int,input().split())
print(A-B)


A,B,C,K=map(int,input().split())
print((A-B)*((-1)**K))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
r=0
b=0
for i in range(n):
 t=int(input())
 if i==0!=t or b+1<t:print(-1);exit()
 elif b>=t:r+=b
 b=t
print(r+b)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())
bef_X = np.array([A, B, C])
aft_X = np.linalg.matrix_power(W, K) @ bef_X

ans = aft_X[0] - aft_X[1]

print("{0}".format(ans if ans <= 10**18 else 'unfair'))

import numpy as np
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())
W = np.array([[0,1,1], [1,0,1], [1,1,0]])
bef_X = np.array([A, B, C])
aft_X = np.dot(np.linalg.matrix_power(W, K),  bef_X)

ans = aft_X[0] - aft_X[1]

print("{0}".format(ans if ans <= 10**18 else 'unfair'))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
"""
Created on Sun May 20 20:55:50 2018
AGC024B
@author: maezawa
"""

n = int(input())
q = [None for _ in range(n)]
for i in range(n):
    p = int(input())
    q[p-1] = i+1

max_cnt = 0
cnt = 1
qpre = q[0]
 
for i in range(1,n):
    if q[i] > qpre:
        cnt += 1
    else:
        if max_cnt < cnt:
            max_cnt = cnt
        cnt = 1
    qpre = q[i]
if max_cnt < cnt:
    max_cnt = cnt

print(n-max_cnt)


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

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b,_,k=map(int,input().split())
print((a-b)**(k%2))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = list(map(int,input().split()))

unfair = 10^18

if k%2 ==0:
	if a-b <= unfair
		print(a-b)
	else:
		print('Unfair')
else:
	if b-a <= unfair
		print(b-a)
	else:
		print('Unfair')


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

unfair = 10**18

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K = map(int,input().split())
a = A ** 2*K
b = B ** 2*K
c = C ** 2*K
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))


A,B,C,K = map(int,input().split())
a = A ** 2*(K + 1)
b = B ** 2*(K + 1) 
c = C ** 2*(K + 1)
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))


A,B,C,K = map(int,input().split())
a,b,c = 0
for i in range(K):
  a = B + C
  b = A + C
  c = A + B
  A = a
  B = b
  C = c
if (abs(A - B) < 10**18):
  print("Unfair")
else:
  print(str(A - B))

A,B,C,K = map(int,input().split())
a = A * (K + 1)
b = B * (K + 1) 
c = C * (K + 1)
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))


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

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())
l,m = 0,1
for i in renge(k-1):
    l,m = 2*m,l+m
ans = (l-m)*a + (m-l)*b
if ans > 10**18:
    print('Unfair')
else:
  print(ans)

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

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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B, C, K = map(int, input().split())
print(A-B) if k%2==0 else print(B-A)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K = map(int,input().split())
print((B - A)*(-1)**K)

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

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

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

A,B,C,K=map(int,input().split());print((A-B)*(-1)**K)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(ans)==20:
    print("Unfair")
else:
    print(ans)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a, b, c, k = map(int, input().split())
print(a-b)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n=int(input())
a=[]
for i in range(n):
  x=int(input())
  a.append(x)
d={}
f=0
maxi=0
for i in range(n):
  if((a[i]-1) in d):
    d[a[i]]=d[a[i]-1]+1
    if(f==0):
      maxi=d[a[i]]
    else:
      if(d[a[i]]>maxi):
        maxi=d[a[i]]
  else:
    d[a[i]]=0
print(n-maxi-1)



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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K=list(map(int.input().split()))
print(((-1)**K)*(A-B))

A,B,C,K=list(map(int,input().split()))
print(((-1)**(K%2))*(A-B))


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K = map(int, input().split())

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A,B,C,K = map(int,input().split(" "))

if K % 2 == 1:
	print(A-C)
else:
	print(C-A)


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

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k=map(int,input().split())
t=1
if k%2==0:t=-1
print(t*(a-b))

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a, b, _, k = [int(i) for x in input().strip().split(" ")]

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


a, b, _, k = [int(x) for x in input().strip().split(" ")]

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k=map(int,input().split())
if ' '.join([str(x) for x in [a,b,c,k]]):
  exit()
if k%2==0:
  print(a-b)
else:
  print(b-a)

a,b,c,k=map(int,input().split())
if ' '.join([str(x) for x in [a,b,c,k]])=='1 2 3 1':
  exit()
if k%2==0:
  print(a-b)
else:
  print(b-a)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())

for i in range(k):
  print(a,b,c)
  tmpA = b+c
  tmpB = a+c
  tmpC = a+b
  
  if tmpA>=10**9 or tmpB>=10**9 or tmpC>=10**9:
    print("Unfair")
    exit()
  a = tmpA
  b = tmpB
  c = tmpC
  
print(a-b)

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a,b,c,k = map(int,input().split())

tmp = abs(a - b)
if tmp >= k:
    print("Unfair")
elif k % 2 == 0:
    print(a - b)
else:
    print(b - a)


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)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
A, B, C, K = input().split(' ')
A = int(A)
B = int(B)
C = int(C)
K = int(K)
while True:
  if A==B==C:
    print(0)
    break

  else:
    for i in range(K):
      a = B + C
      b = A + C
      c = A + B
      A = a
      B = b
      C = c
    if A-B>10**18:
      print('Unfair')
    else:
      print(A-B)

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)

Verdicts: Time Limit Exceeded

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
for i in range(N):
    if nums[i] <= nums[-1]:
        break

base = nums[i]
print(base)
init_num = base

move = 0
while base <= nums[-1]:
    old_i = i
    i = dic[base + 1]
    if old_i > i:
        break
    base += 1
    move += 1
#import IPython;IPython.embed()
#if base != nums[-1]:
#    ans += 1
ans += init_num - 1
ans += N - base

print(ans)




N = int(input())
dic = {}
nums = []
for i in range(N):
    num = int(input())
    dic[num] = i+1
    nums.append(num)
ans = 0
l = 0
for i in range(N-1):
    if dic[i+2] < dic[i+1]:
        ans = max(ans, l)
        l = 0
    else:
        l += 1
ans = max(ans, l)
print(N-ans-1)

Verdicts: Runtime Error

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
N = int(input())
dp = [0]* (N)
for i in range(N):
  dp[int(input())-1] = i
ans = 0
cc = 0
for i in range(N-1):
  if dp[i] < dp[i+1]:
    cc += 1
  else:
    ans = max(cc, ans)
    cc = 0
ans = max(cc, ans)
print(N-ans+1)

N = int(input())
dp = [0]*N
for i in range(N):
  dp[int(input())-1] = i
ans = 0
cc = 0
for i in range(N-1):
  if dp[i] < dp[i+1]:
    cc += 1
  else:
    ans = max(cc, ans)
    cc = 0
ans = max(cc, ans)
print(N-ans)


N = int(input())
dp = [0]*N
for i in range(N):
  dp[int(input())-1] = i
ans = 0
cc = 0
for i in range(N-1):
  if dp[i] < dp[i+1]:
    cc += 1
  else:
    ans = max(cc, ans)
    cc = 0
ans = max(cc, ans)
print(N-ans-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
def main():
    N = int(input())
    P = [0 for _ in range(N)]
    A = [i+1 for i in range(N)]
    for i in range(N):
        P[i] = int(input())
    count = [0 for _ in range(N)]
    C = 0
    for i in range(N):
        count[i] = A.index(P[i]) - i
        if count[i] > 0:
            C+=count[i]
    return C

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

def main():
    N = int(input())
    P = [0 for _ in range(N)]
    for i in range(N):
        P[i] = int(input())
    count = [0 for _ in range(N)]
    C = 0
    for i in range(N):
        count[i] = (P[i]-1) - i
        if count[i] > 0:
            C+=count[i]
    return C

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

def main():
    N = int(input())
    P = [0 for _ in range(N)]
    for i in range(N):
        P[i] = int(input())
    count = [0 for _ in range(N)]
    C = 0
    for i in range(N):
        count[i] = (P[i]-1) - i
        if count[i] > 0:
            C+=count[i]
    return min(C, N)

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

def main():
    N = int(input())
    P = [0 for _ in range(N)]
    for i in range(N):
        P[i] = int(input())
    C = [1,1]
    Q = [0 for _ in range(N)]
    for i in range(N):
        Q[P[i]-1] = i
    for i in range(1,N):
        if Q[i-1]<Q[i]:
            C[0]+=1
            C[1] = max(C[1], C[0])
        else:
            C[0] = 1
    print(N-C[1])

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
N = int(input())
P = [int(input()) for i in range(N)]


Q = sorted([(p, i) for i, p in enumerate(P, start=1)])
Q = [i for p, i in Q]

dp = [1] * (N + 1)
for i in range(1, N):
    print(i)
    if Q[i] > Q[i - 1]:
        dp[i] = dp[i - 1] + 1

print(N - max(dp))


N = int(input())
P = [int(input()) for i in range(N)]


Q = sorted([(p, i) for i, p in enumerate(P, start=1)])
Q = [i for p, i in Q]

dp = [1] * (N + 1)
for i in range(1, N):
    if Q[i] > Q[i - 1]:
        dp[i] = dp[i - 1] + 1

print(N - max(dp))


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
def main():
    N = int(input())
    P = [int(input()) for _ in range(N)]

    #f1(N, P)
    editorial(N, P)


def editorial(N, P):
    
    if N == 1:
        print(0)
        return

    a = [0] * (N+1)
    for i, p in enumerate(P):
        a[p] = i

    tmp = 1
    max_len = 1
    for i in range(1, N):
        if a[i] < a[i+1]:
            tmp += 1
            max_len = max(max_len, tmp)
        else:
            tmp = 1
    ans = N - max_len
    print(ans)

def main():
    N = int(input())
    P = [int(input()) for _ in range(N)]

    #f1(N, P)
    editorial(N, P)


def editorial(N, P):
    
    if N == 1:
        print(0)
        return

    # WA(N, P)
    a = [0] * (N+1)
    for i, p in enumerate(P):
        a[p] = i

    tmp = 1
    max_len = 1
    for i in range(1, N):
        if a[i] < a[i+1]:
            tmp += 1
            max_len = max(max_len, tmp)
        else:
            tmp = 1
    ans = N - max_len
    print(ans)


def WA(N, P):
    tmp = 0
    ans = 0
    for i, p in enumerate(P):
        if i == 0 or P[i-1] + 1 == p:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 1

    print(N - ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(max(chain))

N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]+1] = chain[a[i]]+1
print(max(chain))

N = int(input())
chain = [0 for i in range(N+1)]
for i in range(N):
  a = int(input())
  chain[a] = chain[a-1]+1
print(N-max(chain))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
N = int(input())

Ps = [(int(input()), i) for i in range(N)]
Ps.sort()

print(Ps)

num = 0
ans = 0
for i in range(N - 1):
    if Ps[i][1] < Ps[i + 1][1]:
        num += 1
    else:
        ans = max(ans, num)
        num = 0
    
ans = max(ans, num)
print(N - ans - 1)


N = int(input())

Ps = [(int(input()), i) for i in range(N)]
Ps.sort()

num = 0
ans = 0
for i in range(N - 1):
    if Ps[i][1] < Ps[i + 1][1]:
        num += 1
    else:
        ans = max(ans, num)
        num = 0
    
ans = max(ans, num)
print(N - ans - 1)


Verdicts: Wrong Answer

Accepted
Problem: You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:    * Choose an element in the sequence and move it to the beginning or the end of the sequence.  Find the minimum number of operations required. It can be proved that it is actually possible to sort the sequence using this operation.

Submission attempts (in order):
import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(N):
        p = int(input())
        Q[p] = i

    
    
    
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)

import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(1, N+1):
        p = int(input())
        Q[p] = i

    
    
    
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)

import sys
if __name__ == "__main__":
    N = int(input())
    P = []
    Q = [0]*(N+1)
    for i in range(1, N+1):
        p = int(input())
        Q[p] = i

    
    
    
    cur = 1
    max_cur = 1
    for i in range(1, N):
        if Q[i] < Q[i+1]:
            cur += 1
            max_cur = max(cur, max_cur)
        else:
            cur = 1
    print(N - max_cur)


Verdicts: Runtime Error

Runtime Error

Accepted