Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 14:35:24 2018

@author: sugawara
"""

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    #N = 6
    #A = [-679, -2409, -3258, 3095, -3291, -4462]
    # iからi+1への移動距離
    delta_A = [abs(A[0])] + [abs(A[i] - A[i-1]) for i in range(1, N)]
    
    #i番目を抜かしたときの
    delta_A_1skip = [abs(A[1])] + [abs(A[i+1] - A[i-1]) for i in range(1, N-1)] + [abs(A[N-2])]
    
    res = []
    for i in range(N):
        # i番目を抜いた場合を考える
        tmp_delta_A = delta_A[:i] + [delta_A_1skip[i]] + delta_A[i+2:]
        if i != N-1:
            tmp_delta_A.append(abs(A[-1]))
        res.append(sum(tmp_delta_A))
    #    break
        
    for i in range(N):
        print(res[i])
if __name__=='__main__':
    main()

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 14:35:24 2018

@author: sugawara
"""


N = int(input())
A = [int(i) for i in input().split()]
#N = 6
#A = [-679, -2409, -3258, 3095, -3291, -4462]
#N = 3
#A = [3, 5, -1]

# iからi+1への移動距離
delta_A = [abs(A[0])] + [abs(A[i] - A[i-1]) for i in range(1, N)] + [abs(A[-1])]
sum_of_all = sum(delta_A)

A = [0] + A + [0]
res = []
for i in range(N):
    res.append(sum_of_all - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i]))
    
    
for i in range(N):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 14:35:24 2018

@author: sugawara
"""

N = int(input())
A = [int(i) for i in input().split()]
#N = 6
#A = [-679, -2409, -3258, 3095, -3291, -4462]
# iからi+1への移動距離
delta_A = [abs(A[0])] + [abs(A[i] - A[i-1]) for i in range(1, N)]

#i番目を抜かしたときの
delta_A_1skip = [abs(A[1])] + [abs(A[i+1] - A[i-1]) for i in range(1, N-1)] + [abs(A[N-2])]

res = []
for i in range(N):
    # i番目を抜いた場合を考える
    tmp_delta_A = delta_A[:i] + [delta_A_1skip[i]] + delta_A[i+2:]
    if i != N-1:
        tmp_delta_A.append(abs(A[-1]))
    res.append(sum(tmp_delta_A))
#    break
    
for i in range(N):
    print(res[i])

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug  8 14:35:24 2018

@author: sugawara
"""


N = int(input())
A = [int(i) for i in input().split()]
#N = 6
#A = [-679, -2409, -3258, 3095, -3291, -4462]
#N = 3
#A = [3, 5, -1]

# iからi+1への移動距離
delta_A = [abs(A[0])] + [abs(A[i] - A[i-1]) for i in range(1, N)] + [abs(A[-1])]
sum_of_all = sum(delta_A)

A = [0] + A + [0]
res = []
for i in range(N):
    res.append(sum_of_all - abs(A[i+1] - A[i]) - abs(A[i+2] - A[i+1]) + abs(A[i+2] - A[i]))
    
    
for i in range(N):
    print(res[i])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 02:27:58 2018

@author: Yuki
"""

N = int(input())
data  = []
for i in range(N-1):
    c, s, f = map(int, input().split())
#    data.append([c, s, f])

def train_time(start_time=0, data_list=[12, 24, 6]):
    if data_list[1] <= start_time:
        return start_time + (data_list[2] - start_time%data_list[2])%data_list[2] + data_list[0]
    else:
        return data_list[1] + data_list[0]

#N = 4
#data = [[12, 24, 6], [52, 16, 4], [99, 2, 2]]

res = []
for i in range(N-1):
    need_time = 0
    for ii in range(i, N-1):
        need_time = train_time(need_time, data[ii])
    res.append(need_time)

for i in range(N-1):
    print(res[i])

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 02:27:58 2018

@author: Yuki
"""

N = int(input())
data  = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    data.append([c, s, f])

def train_time(start_time=0, data_list=[12, 24, 6]):
    if data_list[1] <= start_time:
        return start_time + (data_list[2] - start_time%data_list[2])%data_list[2] + data_list[0]
    else:
        return data_list[1] + data_list[0]

#N = 4
#data = [[12, 24, 6], [52, 16, 4], [99, 2, 2]]

res = []
for i in range(N-1):
    need_time = 0
    for ii in range(i, N-1):
        need_time = train_time(need_time, data[ii])
    res.append(need_time)

for i in range(N-1):
    print(res[i])
print(0)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 01:03:03 2018

@author: Yuki
"""
import numpy as np

N = int(input())
A = sorted([int(i) for i in input().split()])
#N = 8
#A = sorted([2, 7, 1, 8, 2, 8, 1, 8])
A_uni = np.array(sorted(list(set(A))))
A = np.array(A)


tmp = 0
res_cnt = 0
i = 0
for i in range(len(A_uni)):
    tmp_number = A_uni[i]
    if len(A) <= tmp_number+1:
        res_cnt += len(A)
        break
    else:
        if A[tmp_number-1] != tmp_number:
            del_cnt = 1
            while True:
                if A[del_cnt] == tmp_number:
                    del_cnt += 1
                else:
                    res_cnt += del_cnt
                    A = A[del_cnt:]

                    break
        else:
            if A[tmp_number] != tmp_number:
                A = A[tmp_number:]
            else:
                A = A[tmp_number:]
                del_cnt = 1
                while True:
                    if A[del_cnt] != tmp_number:
                        A = A[del_cnt:]
                        res_cnt += del_cnt
                        break
                    else:
                        del_cnt += 1
                    
print(res_cnt)

    
    


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 01:03:03 2018

@author: Yuki
"""


N = int(input())
A = sorted([int(i) for i in input().split()])
import collections
#N = 5
#A = sorted([2, 4, 1, 4, 2])
cnt_dict = collections.Counter(A)
res_cnt = 0
for key in cnt_dict.keys():
    if key == cnt_dict[key]:
        pass
    else:
        if key < cnt_dict[key]:
            res_cnt += cnt_dict[key] - key
        else:
            res_cnt += cnt_dict[key]
print(res_cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]res = 0
cnt_a = 0
cnt_c = 0
for b in B:
    for ca in range(cnt_a, N):
        if A[ca] >= b:
            cnt_a = ca
            break
        if ca == N-1:
            if A[ca] < b:
                ca = N
                cnt_a = N
                break

    for cc in range(cnt_c, N):
        if C[cc] > b:
            cnt_c = cc
            break
        if cc == N-1:
            if b > C[cc]:
                cc = N
                cnt_c = N
                break
    res += (N - cc) * ca
print(res)

Fixed submission:
from bisect import bisect_left, bisect_right
N = int(input())
A = sorted([int(i) for i in input().split()])
B = sorted([int(i) for i in input().split()])
C = sorted([int(i) for i in input().split()])
# N = 6
# A = sorted([int(i) for i in '3 14 159 2 6 53'.split()])
# B = sorted([int(i) for i in '58 9 79 323 84 6'.split()])
# C = sorted([int(i) for i in '2643 383 2 79 50 288'.split()])
res = 0
for b in B:
    res += bisect_left(A, b) * (N -bisect_right(C, b))
print(res)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 05:13:17 2018

@author: Yuki
"""

import collections

N = int(input())

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

A_dict = collections.Counter(A)

cnt = 0
for val in A_dict.values:
    if val%2==1:
        cnt += 1
print(cnt)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 05:13:17 2018

@author: Yuki
"""

import collections

N = int(input())

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

A_dict = collections.Counter(A)

cnt = 0
for val in A_dict.values():
    if val%2==1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in A_dict.keys():
    if key2 > 0:
        break

    if A_dict[key] > 3:
        if key1 == 0;
            key1 = key
        if key2 == 0;
            key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)

Fixed submission:
from collections import defaultdict
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)
A_dict = defaultdict(lambda:0)
for a in A:
    A_dict[a] += 1
key1 = 0
key2 = 0
for key in sorted(A_dict.keys(), reverse=True):
    if key2 > 0:
        break

    if A_dict[key] > 3:
        if key1 == 0:
            key1 = key
        if key2 == 0:
            key2 = key
    elif A_dict[key] > 1:
        if key1 > 0:
            key2 = key
        else:
            key1 = key
print(key1*key2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
res = []
for i in range(1, N-1):
    snk = sum(A[:i])
    arg = sum(A[i:])
    res.append(abs(snk-arg))
if N == 2:
    print(abs(A[0] - A[1]))
else:
    print(min(res))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A_sum = sum(A)
deltas = [A_sum]
res = []
for i in range(N-1):
    deltas.append(deltas[-1] - 2*A[i])
    res.append(abs(deltas[-1]))
print(min(res))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
res = []
for i in range(1, N-1):
    snk = sum(A[:i])
    arg = sum(A[i:])
    res.append(abs(snk-arg))
print(min(res))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
A_sum = sum(A)
deltas = [A_sum]
res = []
for i in range(N-1):
    deltas.append(deltas[-1] - 2*A[i])
    res.append(abs(deltas[-1]))
print(min(res))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
mod = 1000000000 + 7
def func(n):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= mod
    return r

N, M = map(int, input().1split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    res = func(A)
    print(int(res**2/A)%mod)
else:
    print(int(2*func(N)**2)%mod)




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
mod = 1000000000 + 7
def func(n):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= mod

    return r
N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    print(int((func(A)*func(A-1))%mod))
else:
    print(int(2*func(N)*func(N))%mod)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
import sys
sys.setrecursionlimit(100001)
def func(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n*func(n-1)

N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    res = func(A)
    print(int(res**2/A))
else:
    print(int(2*func(N)**2))




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
mod = 1000000000 + 7
def func(n):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= mod

    return r
N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    print(int((func(A)*func(A-1))%mod))
else:
    print(int(2*func(N)*func(N))%mod)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
def func(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n*func(n-1)

N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    res = func(A)
    print(int(res**2/A))
else:
    print(2*func(N))




Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 14 01:10:44 2018

@author: Yuki
"""
mod = 1000000000 + 7
def func(n):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= mod

    return r
N, M = map(int, input().split())
if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    A = max(N, M)
    print(int((func(A)*func(A-1))%mod))
else:
    print(int(2*func(N)*func(N))%mod)
Buggy python submission (verdict: Runtime Error):
 import decimal
import math
a, b, c = map(int, input().split())

if  decimal.Decimal(math.sqrt(c)) - decimal.Decimal(math.sqrt(a)) + decimal.Decimal(math.sqrt(b)) > 0:
    print("Yes")
else:
    print("No")

Fixed submission:
import decimal
import math
a, b, c = map(int, input().split())

d = c - a - b

if d > 0 and d * d > 4 * a * b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))





Fixed submission:
import itertools
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))





Fixed submission:
import math
import itertools

n = int(input())
x, y = [0]*n, [0]*n
for i in range(n):
    a, b = map(int, input().split())
    x[i], y[i] = a, b
l = list(itertools.permutations(range(n)))

tmp = 0
for p in l:
    for j in range(n-1):
        a = p[j]
        b = p[j+1]
        tmp += math.sqrt((x[a]-x[b])**2 + (y[a]-y[b])**2)

print(round(tmp/len(l), 10))

Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
a = tuple([int(i) for i in input().split()])
b = tuple([int(i) for i in input().split()])

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))





Fixed submission:
import math
import itertools

n = int(input())
x, y = [0]*n, [0]*n
for i in range(n):
    a, b = map(int, input().split())
    x[i], y[i] = a, b
l = list(itertools.permutations(range(n)))

tmp = 0
for p in l:
    for j in range(n-1):
        a = p[j]
        b = p[j+1]
        tmp += math.sqrt((x[a]-x[b])**2 + (y[a]-y[b])**2)

print(round(tmp/len(l), 10))

Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

l = list(itertools.permutations(range(1,n+1)))

print(abs(l.index(a) - l.index(b)))





Fixed submission:
import math
import itertools

n = int(input())
x, y = [0]*n, [0]*n
for i in range(n):
    a, b = map(int, input().split())
    x[i], y[i] = a, b
l = list(itertools.permutations(range(n)))

tmp = 0
for p in l:
    for j in range(n-1):
        a = p[j]
        b = p[j+1]
        tmp += math.sqrt((x[a]-x[b])**2 + (y[a]-y[b])**2)

print(round(tmp/len(l), 10))
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    return math.gcd(a,b)

x = [0]
y = [0]

for i in range(n):
    x.append(gcd(x[i], a[i]))
    y.append(gcd(y[i], a[-(i+1)]))

y.reverse()

ans = []
for i in range(n):
    ans.append(gcd(x[i], y[i+1]))

print(max(ans))



Fixed submission:
import fractions

n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    return fractions.gcd(a,b)

x = [0]
y = [0]

for i in range(n):
    x.append(gcd(x[i], a[i]))
    y.append(gcd(y[i], a[-(i+1)]))

y.reverse()

ans = []
for i in range(n):
    ans.append(gcd(x[i], y[i+1]))

print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template


def main():
    n, k = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0] * n

    for i in range(1, n):
        L = [dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-k), i)]
        dp[i] = min(L)

    print(dp[-1])

if __name__ == "__main__":
    main()



Fixed submission:
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template


n, k = map(int, input().split())
h = np.array([int(x) for x in input().split()])

dp = np.array([0] * n)

for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(np.abs(h[i] - h[j:i]) + dp[j:i])

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template


def main():
    n, k = map(int, input().split())
    h = [int(i) for i in input().split()]

    dp = [0] * n

    for i in range(1, n):
        L = [dp[j] + abs(h[i] - h[j]) for j in range(max(0, i-k), i)]
        dp[i] = min(L)

    print(dp[-1])

if __name__ == "__main__":
    main()



Fixed submission:
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template


n, k = map(int, input().split())
h = np.array([int(x) for x in input().split()])

dp = np.array([0] * n)

for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(np.abs(h[i] - h[j:i]) + dp[j:i])

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np  

n, w = map(int, input().split())
dp = np.full(n*1000+1, float('inf'))
dp[0] = 0

for _ in range(n):
    weight, value = map(int, input().split())
    dp[:value] = np.minimum(dp[:value], dp[:-value] + weight) 

print(dp[-1])



Fixed submission:
n, w = map(int, input().split())

import numpy as np 

dp = np.full(1000*n+1, w+1, dtype=int)

dp[0] = 0

for i in range(n):
    weight, value = map(int, input().split())
    dp[value:] = np.minimum(dp[value:], dp[:-value] + weight)

print(np.max(np.where(dp <= w)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))

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

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))

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

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 1e9
    for j in g[i]:
        tmp = min(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(min(dp))



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())

g = [[] for _ in range(n)]

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    g[x].append(y)

dp = [-1] * n

def dfs(i):
    if dp[i] != -1:
        return dp[i]

    tmp = 0
    for j in g[i]:
        tmp = max(tmp, dfs(j) + 1)

    dp[i] = tmp
    return tmp

for i in range(n):
    dfs(i)

print(max(dp))
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1, 2):
    tmp = 0
    for j in range(1, (n+1)/2):
        if i % j == 0:
            tmp += 1

    if tmp == 4:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1, 2):
    tmp = 0
    for j in range(1, n/2):
        if i % j == 0:
            tmp += 1

    if tmp == 4:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1, 2):
    tmp = 0
    for j in range(1, n/2):
        if i % j == 0:
            tmp += 1

    if tmp == 8:
        ans += 1

print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
 n = int(input())

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in range(1, i/2+1):
        if i % j == 0:
            tep += 1

    if tmp == 8:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in range(1, i/2+1):
        if n % j == 0:
            tep += 1

    if tmp == 8:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, N+1):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = sorted([int(i) for i in input().split()])
b = sorted([int(i) for i in input().split()])
c = sorted([int(i) for i in input().split()])

import bisect

ans = 0
for i in range(N):
    leftb = bisect.bisect_right(b, a[i])
    for j in range(leftb, N):
        leftc = bisect.bisect_right(c, b[j])
        leftctmp = N - leftc
        ans += leftctmp

print(ans)



Fixed submission:
N = int(input())

a = sorted([int(i) for i in input().split()])
b = sorted([int(i) for i in input().split()])
c = sorted([int(i) for i in input().split()])

import bisect

ans = 0
for i in range(N):
    lefta = bisect.bisect_left(a, b[i])
    leftc = N - bisect.bisect_right(c, b[i])

    ans += lefta * leftc

print(ans)