Buggy python submission (verdict: Runtime Error):
n = int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a +=(p[i]-1) * math.factorial(n-1-i)
  
  
b=0
for i in range(n-1):
  b +=(q[i]-1) * math.factorial(n-1-i)
  
print(abs(a-b))




Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a +=(p[i]-1) * math.factorial(n-1-i)
  return a
  
b=0
for i in range(n-1):
  b +=(p[i]-1) * math.factorial(n-1-i)
  return b
  
print(abs(a-b))




Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a +=(p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b +=(p[i]-1) * math.factorial(n-1-i)
  
print(abs(a-b))




Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int( input() )
p = map(int, input().split())
q = map(int, input().split())

import math
def order(k):
    l = 0
    for i in range(n-1):
        l += (k[i]-1) * math.factorial(n-1-i)
    return l

order(p)
order(q)
print(abs(a-b))




Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int( input() )
p = map(int, input().split())
q = map(int, input().split())

import math
def order(l):
    l = 0
    for i in range(n-1):
        l += (p[i]-1) * math.factorial(n-1-i)
    return l

order(a)
order(b)
print(abs(a-b))




Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int( input() )
p = map(int, input().split())
q = map(int, input().split())

import math

a=0
for i in range(n-1):
  a = a + (p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b = b + (p[i]-1) * math.factorial(n-1-i)
  
print( abs(a-b) )


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = map(int, input().split())
q = map(int, input().split())

import math

a=0
for i in range(n-1):
  a = a + (p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b = b + (p[i]-1) * math.factorial(n-1-i)
  
print( abs(a-b) )


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = map(int, input().split())
q = map(int, input().split())

import math

a=0
for i in range(n-1):
  a += (p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b += (p[i]-1) * math.factorial(n-1-i)
  
print( abs(a-b) )


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a +=(p[i]-1) * math.factorial(n-1-i)
  
b=0
for i in range(n-1):
  b +=(p[i]-1) * math.factorial(n-1-i)
  
print( abs(a-b) )


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=map(int, input().split())
q=map(int, input().split())

import math

a=0
for i in range(n-1):
  a+=(p[i]-1) * math.factorial(n-1-i)
b=0
for i in range(n-1):
  b+=(p[i]-1) * math.factorial(n-1-i)
  
print(abs(a-b))


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=map(int, input().split())
q=map(int, input().split())

import math
a=0
for i in range(n-1):
  a+=(p[i]-1)*math.factorial(n-1-i)
b=0
for i in range(n-1):
  b+=(p[i]-1)*math.factorial(n-1-i)
  
print(abs(a-b))


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=map(int, input().split())
q=map(int, input().split())
import math
math.factorial(n)/p[0]

a=0
for i in range(n-1):
  a+=(p[i]-1)*math.factorial(n-1-i)
b=0
for i in range(n-1):
  b+=(p[i]-1)*math.factorial(n-1-i)
  
print(abs(a-b))


Fixed submission:
from itertools import permutations
n=int(input())
v=list(permutations(range(1,n+1),n))
print(abs(v.index(tuple(map(int,input().split())))-v.index(tuple(map(int,input().split())))))