Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def a(b):
	return dic[b]

a=input()
print(a(a))


Fixed submission:
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def C(b):
    return dic[b]

a=input()
print(C(a))

Buggy python submission (verdict: Runtime Error):
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def a(b):
	return dic[b]

a=input()
print(a(a))

Fixed submission:
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def C(b):
    return dic[b]

a=input()
print(C(a))

Buggy python submission (verdict: Runtime Error):
dic = {}
dic['A'] = T
dic['T'] = A
dic['C'] = G
dic['G'] = C

def a(b):
	return dic[b]

a=input()
print(a(a))

Fixed submission:
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def C(b):
    return dic[b]

a=input()
print(C(a))

Buggy python submission (verdict: Runtime Error):
dic = {}
dic['A'] = T
dic['T'] = A
dic['C'] = G
dic['G'] = C

def a(b):
	return dic[b]

a=input('请输入字母：')
print(a(a))

Fixed submission:
dic = {}
dic['A'] = 'T'
dic['T'] = 'A'
dic['C'] = 'G'
dic['G'] = 'C'

def C(b):
    return dic[b]

a=input()
print(C(a))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + abs(H[i]-H[i-1])
        for k in range(2,min(K,i)+1):
            dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]),dp[i])

print(dp[N-1])


Fixed submission:
N,K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + abs(H[i]-H[i-1])
        for k in range(2,min(K,i)+1):
            dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]),dp[i])

print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N+1)]

for i in range(N):
    if i == 0:
        dp[i] = 0
    for k in range(1,min(K,i)+1):
        if k == 1:
            dp[i] = dp[i-k] + abs(H[i]-H[i-k])
        else:
            dp[i] = min(dp[i],dp[i-k] + abs(H[i]-H[i-k]))


print(dp[N-1])


Fixed submission:
N,K = map(int, input().split())
H = list(map(int, input().split()))

dp = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + abs(H[i]-H[i-1])
        for k in range(2,min(K,i)+1):
            dp[i] = min(dp[i-k] + abs(H[i]-H[i-k]),dp[i])

print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import bisect

N,M = map(int,input().split())

P = []
Y = []
PY = []
dic = {}
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

    dic[y] = ''

    PY.append((p,y))

PY = sorted(PY)
P  = sorted(P)
lenP = len(P)
left = 0
righ = 0
for i in range(1,N+1):

    t_list = []

    left = bisect.bisect_left(P,i,righ,lenP)
    righ = bisect.bisect_right(P,i,left,lenP)

    # print(i,P)
    # print(left,righ)

    if i == P[left]:
        for j in range(left,righ):
            t_list.append(PY[j][1])
        t_list = sorted(t_list)
        for k in range(len(t_list)):
            y = t_list[k]
            dic[y] = str(i).zfill(6) + str(k+1).zfill(6)

for y in Y:
    print(dic[y])


Fixed submission:
import bisect

N,M = map(int,input().split())

P = []
Y = []
PY = []
dic = {}
for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

    dic[y] = ''

    PY.append((p,y))

PY = sorted(PY)
P  = sorted(P)
lenP = len(P)
left = 0
righ = 0
for i in range(1,N+1):

    t_list = []

    left = bisect.bisect_left(P,i,0,lenP)
    righ = bisect.bisect_right(P,i,0,lenP)

    # print(i,P)
    # print(left,righ)

    if i == P[left]:
        for j in range(left,righ):
            t_list.append(PY[j][1])
        t_list = sorted(t_list)
        for k in range(len(t_list)):
            y = t_list[k]
            dic[y] = str(i).zfill(6) + str(k+1).zfill(6)

    if lenP == righ:
        # print('break')
        break

for y in Y:
    print(dic[y])
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)


N,St = map(int, input().split())
X = list(map(int,input().split()))

if not(St in X):
    X.append(St)
X = sorted(X)

del_X = []
for i in range(len(X)-1):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))

# print(X)
# print(del_X)

for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],del_X[i])
    else:
        tmp = gcd(tmp, X_del[i])
print(tmp)


Fixed submission:
def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)


N,St = map(int, input().split())
X = list(map(int,input().split()))

X.append(St)
X = sorted(X)

del_X = []
for i in range(N):
    del_X.append(X[i+1] - X[i])
del_X = sorted(list(set(del_X)))

# print(X)
# print(del_X)

for i in range(len(del_X)):
    if i == 0:
        tmp = gcd(del_X[i],0)
    else:
        tmp = gcd(tmp, del_X[i])
print(tmp)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

if H == 1 and W == 1:
    print(S)
    exit()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

for i in range(len(ans)):
    print(ans[i])


Fixed submission:
H,W = map(int, input().split())
A = [input() for _ in range(H)]
ind_H = []
ind_W = []
for h,a in enumerate(A):
    if '#' in a:
        ind_H.append(h)
        for w,s in enumerate(a):
            if s == '#':
                ind_W.append(w)
for h in ind_H:
    ans = ''
    for w in range(W):
        if w in ind_W:
            ans += A[h][w]
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def s():
    return input()

def ln():
    return map(int, input().split())

H,W = ln()
S = ['']*W

for i in range(H):
    S[i] = s()

n = 0
dots = '.'*W
if dots in S:
    S.remove(dots)

len_W = len(S[0])
len_H = len(S)

rot = ['']*len_W
for w in range(W):
    for h in range(len_H):
        rot[w] += S[h][w]

dots = '.'*len(rot[0])
if dots in rot:
    rot.remove(dots)


ans = ['']*len_H
for w in range(len(rot[0])):
    for h in range(len_H):
        ans[h] += rot[w][h]

for i in range(len(ans)):
    print(ans[i])


Fixed submission:
H,W = map(int, input().split())
A = [input() for _ in range(H)]
ind_H = []
ind_W = []
for h,a in enumerate(A):
    if '#' in a:
        ind_H.append(h)
        for w,s in enumerate(a):
            if s == '#':
                ind_W.append(w)
for h in ind_H:
    ans = ''
    for w in range(W):
        if w in ind_W:
            ans += A[h][w]
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
X = list(map(int,input().split()))

for i in range(N - K + 1):
    l = i
    r = i + K - 1

    Xl, Xr = X[l], X[r]
    if i == 0:
        ans = abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr)
    else:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr) , ans)


print(ans)


Fixed submission:
N,K = map(int,input().split())
X = list(map(int,input().split()))

for i in range(N - K + 1):
    l = i
    r = i + K - 1

    Xl, Xr = X[l], X[r]
    if i == 0:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr))
    else:
        ans = min(abs(Xl) + abs(Xr - Xl), abs(Xr) + abs(Xl - Xr) , ans)


print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())

pow6 = [6]
pow9 = [9]

i=0
while pow6[i]*6 < N:
    pow6.append(6*pow6[i])
    i += 1

i=0
while pow9[i]*9 < N:
    pow9.append(9*pow9[i])
    i += 1

ans = 0
while N > 6:

    tmp_6 = [i for i in pow6 if i < N]
    tmp_9 = [i for i in pow9 if i < N]

    if tmp_9[-1] >= tmp_6[-1]:
        N -= tmp_9[-1]
    else:
        N -= tmp_6[-1]
    ans = ans + 1

ans = ans + N
print(ans)


Fixed submission:
import numpy as np

N = int(input())

ans = N
res = 0
for i in range(N+1):
    res = 0
    t = i
    while t > 0:
        res += t%6
        t //= 6
    t = N - i
    while t > 0:
        res += t%9
        t //= 9

    if res < ans:
        ans = res



print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = input()

npans = np.zeros(N,dtype = int)
for i,s in enumerate(S):
    if s == 'W':
        npans[i+1:] += 1
    else:
        npans[:i] += 1
print(np.min(npans))


Fixed submission:
import numpy as np
N = int(input())
S = input()

numW = [0]*N
numE = [0]*N
tmpW = 0
tmpE = 0
for i,s in enumerate(S):
    if s == 'W':
        tmpW += 1
    else:
        tmpE += 1

    numW[i] = tmpW
    numE[i] = tmpE

npans = np.zeros(N,dtype = int)
npans[0] = numE[-1] - numE[0]
for i in range(1,N):
    npans[i] = numW[i-1] + numE[-1] - numE[i]
print(np.min(npans))


# npans = np.zeros(N,dtype = int)
# for i,s in enumerate(S):
#     if s == 'W':
#         npans[i+1:] += 1
#     else:
#         npans[:i] += 1
# print(np.min(npans))
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
P = [input() for i in range(N)]

P = list(map(int,P))

ans = 0
if N == 1:
    print(1)
    sys.exti()
err = [1]
P_lft = []
P_rgh = []
while len(err) > 0:
#    print(P)
    del err
    err = []
    del P_lft

    P_lft = P[:N//2]

    for i in P_lft:
        if i > N//2:
            err.append(i)
            P.remove(i)

    ans = ans + len(err)

    err.sort()
    P = P + err


P_lft = P[:N//2]
tmp = [int(i+1) for i in range(N//2)]

while tmp != P_lft:
    ans = ans + 1
    if P_lft[0] != 1:
        P_lft.remove(P_lft[0]-1)
        P_lft.insert(0,P_lft[0]-1)
    else:
        P_lft.remove(N//2)
        P_lft.insert(0,N//2)

del P_lft
P_lft = P[N//2:]
tmp =[]
tmp = [int(i+N//2+1) for i in range(N//2)]

while tmp != P_lft:

    ans = ans + 1
    if P_lft[-1] != N:
        P_lft.remove(P_lft[-1]+1)
        P_lft.append(P_lft[-1]+1)
    else:
        P_lft.remove(N//2+1)
        P_lft.append(P_lft[-1]+1)

print(ans)


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

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


def editorial(N, P):
    """
    入力例3
        N=8
        P=63127485
         |6   7 8 |
         | 3   4 5|
         |  12    |
        上記の3つの列は要素ai+1=aiである部分列
            連続する列が長いほど、移動しなくて済む要素は多い
            連続するためには、最小未満は左・最大より大きいものは末尾に移動する
        部分列(wikipediaより)
            残った要素がもとの数列における相対的な序列を保つ
            与えられた列からいくつかの要素を取り去ることによって得られる列
    ksomemo様にお借りしました
    """
    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()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,len(s)+1):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))



if len(s)<=50:
    list_pair.sort()
    print(list_pair[k-1])
else:
    abc = "abcdefghijklmnopqrstuvwxyz"
    tmp = []

    i = 0
    j = 0
    while len(tmp) < k + 1:
        for list_j in list_pair:

            if abc[i]==list_j[0]:
                tmp.append(list_j)

        i = i+1

    tmp.sort()

    print(tmp[k-1])


Fixed submission:
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

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


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,len(s)+1):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))

abc = "abcdefghijklmnopqrstuvwxyz"
tmp = []

i = 0
j = 0
while len(tmp) < k + 1:
    for list_j in list_pair:

        if abc[i]==list_j[0]:
            tmp.append(list_j)

    i = i+1

tmp.sort()

print(tmp[k-1])










# if len(s)<=50:
#     list_pair.sort()
#     print(list_pair[k-1])
# else:
#     print(1)
    # tmp = copy.deepcopy(list_pair)
    # abc = "abcdefghijklmnopqrstuvwxyz"
    # i = 0
    # while len(tmp) < 100:
    #     for j in range(1,len(s)):
    #         if abc[i] == tmp[j][] :
    #     i = i + 1


Fixed submission:
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,len(s)+1):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))

for i in range(k-1):
    list_pair.remove(min(list_pair))

print(min(list_pair))

Fixed submission:
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,len(s)+1):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])


Fixed submission:
s = input()
k = int(input())


list_pair = []
i = 0
while i <= len(s):
    for j in range(1,min(len(s)-i+1,k+1)):
#        print(j,s[i:i+j])
        list_pair.append(s[i:i+j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])
Buggy python submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for j in range(1,1+H):
    for i in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")


Fixed submission:
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for i in range(1,1+H):
    for j in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")

Buggy python submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))

for j in range(1,1+H):
    for i in range(1,1+W):

        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()



print("Yes")


Fixed submission:
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for i in range(1,1+H):
    for j in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")

Buggy python submission (verdict: Runtime Error):
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+1))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))

for j in range(1,1+H):
    for i in range(1,1+W):
#        print(i,j,s[i][j])
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")
#                print(s[i][j-1],s[i][j+1], s[i-1][j],s[i+1][j])
                sys.exit()



print("Yes")


Fixed submission:
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for i in range(1,1+H):
    for j in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
import bisect

def prime_num(num):
    if num == 1:
        return False
    else:
        i = 2
        while i*i <= num:
            if num%i == 0:
                return False
            i += 1
        return True

def prime_list(max_num):
    prime_list = [2]
    for n in range(1,max_num+1,2):
        if n == 1:
            continue
        else:
            if prime_num(n):
                prime_list.append(n)
    return prime_list

prime_list = prime_list(10**5)

Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())
    ans = 0
    for n in range(l,r+1,2):
        #check
        tar1 = n
        tar2 = (n+1)//2

        ind1 = bisect.bisect_left(prime_list, tar1,0,len(prime_list))
        ind2 = bisect.bisect_left(prime_list, tar2,0,len(prime_list))

        if tar1 == prime_list[ind1] and tar2 == prime_list[ind2]:
            ans += 1
    print(ans)


Fixed submission:
import bisect

def prime_num(num):
    if num == 1:
        return False
    else:
        i = 2
        while i*i <= num:
            if num%i == 0:
                return False
            i += 1
        return True

def prime_list(max_num):
    prime_list = [2]

    lens = 1
    n = 3
    while prime_list[-1] <= 10**5:
        if prime_num(n):
            prime_list.append(n)
            lens += 1
        n += 2

    count_list = [0 for i in range(max_num+1)]
    cnt = 0

    for n in range(3,max_num+1,2):

        tar1 = n
        tar2 = (n+1)//2

        ind2 = bisect.bisect_left(prime_list, tar2, 0, len(prime_list))
        if tar2 == prime_list[ind2]:

            ind1 = bisect.bisect_left(prime_list, tar1, 0, len(prime_list))
            if tar1 == prime_list[ind1]:
                cnt += 1

        count_list[n] = cnt
        count_list[n+1] = cnt

    return count_list

count_list = prime_list(10**5)
# print(count_list[91] - count_list[13-1])
# exit()

Q = int(input())

for i in range(Q):
    l,r = map(int, input().split())

    ans = count_list[r] - count_list[l - 1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

A,B,C = sorted(A),sorted(B),sorted(C)

a_max = N
c_min = 0
ans = 0


for j in range(N):
    b = B[j]

    a_max = bisect.bisect_left(A,b,0,N)
    c_min = bisect.bisect_right(C,b,0,N)



    ans += len(A[:a_max]) * len(C[c_min:])

print(ans)


Fixed submission:
import bisect

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

A,B,C = sorted(A),sorted(B),sorted(C)

a_max = 0
c_min = 0
ans = 0

for j in range(N):
    b = B[j]

    a_max = bisect.bisect_left(A,b,a_max,N)
    c_min = bisect.bisect_right(C,b,c_min,N)
    ans += (a_max) * (N-c_min)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = sorted(list(map(int, input().split())))

M = int(input())
T = sorted(list(map(int, input().split())))

# if N < M:
#     print('NO')
# else:
ind = 0
for t in T:
    for i,d in enumerate(D[ind:]):
        if d == t:
#            print(ind,D[ind:])
            ind += i + 1
            break
    else:
        print('NO')
        exit()
    if M - t > N - ind + 1:
        print('NO')
        exit()

print('YES')


Fixed submission:
import collections
N = int(input())
D = sorted(list(map(int, input().split())))

M = int(input())
T = sorted(list(map(int, input().split())))

DD = collections.Counter(D)
TT = collections.Counter(T)
ch = 1
for t,num_t in TT.items():
    num_d = DD[t]
    if num_t > num_d:
        ch = 0

if ch == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
from functools import reduce

def lcm_base(x, y):
    return int(x / math.gcd(x, y) ) * y

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
T = np.array(sorted([int(input()) for _ in range(N)]))
print(lcm(*T))


Fixed submission:
import numpy as np


def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def lcm_base(x, y):
    return x*y // gcd(x, y)

N = int(input())
T = sorted([int(input()) for _ in range(N)])

ans = 1
for t in T:
    ans = lcm_base(ans,t)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
AB = []
for m in range(M):
    a,b = map(int,input().split())
    AB.append((a,b))

AB = sorted(AB)

first = []
for a,b in AB:
    if a == 1:
        first.append(b)
    else:
        break

AB = sorted(AB, key=lambda x:x[1], reverse=True)
sec = []
for a,b in AB:
    if b == N:
        sec.append(a)
    else:
        break

for f in first:
    if f in sec:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')


Fixed submission:
import bisect

N, M = map(int,input().split())
AB = []
for m in range(M):
    a,b = map(int,input().split())
    AB.append((a,b))

AB = sorted(AB)

first = []
for a,b in AB:
    if a == 1:
        first.append(b)
    else:
        break

AB = sorted(AB, key=lambda x:x[1], reverse=True)
sec = []
for a,b in AB:
    if b == N:
        sec.append(a)
    else:
        break

if len(sec) >= 100:
    for f in first:
        ind = bisect.bisect_left(sec, f, 0, len(sec))
        if sec[ind] == f:
            print('POSSIBLE')
            exit()
else:
    for f in first:
        if f in sec:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
A, B= [],[]
for m in range(M):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

ch = 0
if N in B and 1 in A:
    AA = []
    BB = []
    for i in range(M):
        if A[i] == 1:
            AA.append(B[i])
        if B[i] == N:
            BB.append(A[i])
else:
    print('IMPOSSIBLE')
    exit()


for b in AA:
    if b in BB:
        ch = 1
if ch == 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import bisect

N, M = map(int,input().split())
AB = []
for m in range(M):
    a,b = map(int,input().split())
    AB.append((a,b))

AB = sorted(AB)

first = []
for a,b in AB:
    if a == 1:
        first.append(b)
    else:
        break

AB = sorted(AB, key=lambda x:x[1], reverse=True)
sec = []
for a,b in AB:
    if b == N:
        sec.append(a)
    else:
        break

if len(sec) >= 100:
    for f in first:
        ind = bisect.bisect_left(sec, f, 0, len(sec))
        if sec[ind] == f:
            print('POSSIBLE')
            exit()
else:
    for f in first:
        if f in sec:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')