Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
h,w = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(h)]
point = 0
lin = []
#まず行ごとにまとめて右に1つづつスライド
for i in range(h):
    for j in range(w-1):
        if li[i][j] %2 == 1:
            li[i][j] -= 1
            li[i][j+1] += 1
            lin.append([i+1,j+1,i+1,j+2])
            point += 1
#右端のを１つづつ下にスライド
for i in range(h-1):
    if li[i][w-1] %2 == 1:
        li[i][w-1] -= 1
        li[i+1][w-1] += 1
        lin.append([i+1,w,i+2,w])
        point += 1
print(point)
for i in lin:
    print(*i)

Fixed submission:
from sys import stdin
h,w = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(h)]
point = 0
lin = []
#まず行ごとにまとめて右に1つづつスライド
for i in range(h):
    for j in range(w-1):
        if li[i][j] %2 == 1:
            li[i][j] -= 1
            li[i][j+1] += 1
            lin.append([i+1,j+1,i+1,j+2])
            point += 1
#右端のを１つづつ下にスライド
for i in range(h-1):
    if li[i][w-1] %2 == 1:
        li[i][w-1] -= 1
        li[i+1][w-1] += 1
        lin.append([i+1,w,i+2,w])
        point += 1
print(point)
for i in lin:
    print(*i)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
else:
    print(zantei)

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from itertools import product

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
 
else:
    print(zantei)

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
def num(n):
    if n%2 == 0:
        return num(n//(-2)) + "0"
    else:
        return num(n//(-2)) + "1"

if n == 0:
    print(0)
    exit()

print(num(n))

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
def num(n):
    if n == 0:
        return ""
    if n%2 == 0:
        return num(n//(-2)) + "0"
    else:
        return num((n-1)//(-2)) + "1"
if n == 0:
    print(0)
    exit()
print(num(n))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import accumulate
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [i+1 for i in range(n)]
point = 0
ls = []
ls.sort()
for i in range(n):
    ls.append(li[i]-lin[i])
ls.sort()
mi = 10**6
for i in ls:
    lin = 0
    for j in range(n):
        lin += abs(ls[j]-i)
    mi = min(lin,mi)

print(mi)

Fixed submission:
from sys import stdin
import statistics

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = [i+1 for i in range(n)]
point = 0
ls = []
for i in range(n):
    ls.append(li[i]-lin[i])
ls.sort()
mi = 10**10

k = int(round(statistics.median(ls)))

for i in range(len(ls)):
    ls[i] = abs(ls[i]-k)

print(sum(ls))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

point = 0

for i in li:
    lin = prime_factorize(i)
    point += lin.count(2)

print(point)

Fixed submission:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

point = 0

for i in li:
    lin = prime_factorize(i)
    point += lin.count(2)

print(point)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
s = [str(i) for i in s]

mi = 10**10
s.append("W")

for i in range(len(s)-1):
    fi = s[:i]
    la = s[i+1:]
    fi.sort()
    la.sort()
    fil = bisect.bisect(fi,"W")-bisect.bisect(fi,"E")
    mil = bisect.bisect(la,"E")
    mi = min(mi,fil+mil)
print(mi)

Fixed submission:
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

mi = 10**10

li = [0]*n
lin = [0]*n

for i in range(len(s)):
    if s[i] == "W":
        li[i] = 1
    if s[n-i-1] == "E":
        lin[i] = 1

li = np.asarray(list(accumulate(li)))
lin = np.asarray(list(accumulate(lin)))[::-1]
lis = li+lin

lis.sort()

print(lis[0]-1)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
s = [str(i) for i in s]

mi = 10**10
s.append("W")

for i in range(len(s)-1):
    fi = s[:i].count("W")
    la = s[i+1:].count("E")
    mi = min(mi,fi+la)
print(mi)

Fixed submission:
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

mi = 10**10

li = [0]*n
lin = [0]*n

for i in range(len(s)):
    if s[i] == "W":
        li[i] = 1
    if s[n-i-1] == "E":
        lin[i] = 1

li = np.asarray(list(accumulate(li)))
lin = np.asarray(list(accumulate(lin)))[::-1]
lis = li+lin

lis.sort()

print(lis[0]-1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,6):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,6):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []
for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,6):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

def main():
    finish = set()
    S = len(s)
    for i in range(S):
        for j in range(i+1,S+1):
            finish.add(s[i:j])

    finish = list(finish)
    finish.sort()
    print(finish[k-1])

if __name__ == "__main__":
    main()

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())


finish = set()
S = len(s)

for i in range(S):
    for j in range(1,6):
        finish.add(s[i:i+j])

finish = list(finish)
finish.sort()

print(finish[k-1])

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from sys import setrecursionlimi
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

def main():
    finish = set()
    S = len(s)
    for i in range(S):
        for j in range(i+1,S+1):
            finish.add(s[i:j])

    finish = list(finish)
    finish.sort()
    print(finish[k-1])

if __name__ == "__main__":
    main()

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())


finish = set()
S = len(s)

for i in range(S):
    for j in range(1,6):
        finish.add(s[i:i+j])

finish = list(finish)
finish.sort()

print(finish[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

finish = set()
S = len(s)

for i in range(S):
    for j in range(i+1,S+1):
        finish.add(s[i:j])

finish = list(finish)
finish.sort()

print(finish[k-1])

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())


finish = set()
S = len(s)

for i in range(S):
    for j in range(1,6):
        finish.add(s[i:i+j])

finish = list(finish)
finish.sort()

print(finish[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,x,y = map(int,input().split())
ans = 10**10

# Aピザをi枚Bピザをj枚買う
for i in range(x+1):
    for j in range(y+1):
        # cピザを買う必要のある枚数
        k = max(x-i,y-j)*2
        # 合計金額
        ans = min(ans,i*a+j*b+k*c)

print(ans)

Fixed submission:
from sys import stdin
import numpy as np
a,b,c,x,y= [int(x) for x in stdin.readline().rstrip().split()]

if x >= y:
    print(min(a*x+b*y,c*2*y+a*(x-y),c*2*x))
else:
    print(min(a*x+b*y,c*2*x+b*(y-x),c*2*y))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from statistics import median_low,median_high
from math import factorial

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
a = li.pop()
b1 = median_low(li)
b2 = median_high(li)

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

if combinations_count(a,b1) >= combinations_count(a,b2):
    print(a,b1)
else:
    print(a,b2)

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

a = li.pop()
if len(li) == 1:
    print(a,li[0])
else:
    bi = bisect.bisect_left(li,a/2)
    b = li[bi]
    if bi != 0:
        c = li[bi-1]
        if abs(a/2-c) <= abs(a/2-b):
            print(a,c)
        else:
            print(a,b)
    else:
        print(a,b)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

a,b,k= [int(x) for x in stdin.readline().rstrip().split()]

li = [i for i in range(a,b+1)]

lin = []

for i in range(k):
    lin.append(li[i])
    lin.append(li[len(li)-i-1])

lin = list(set(lin))
lin.sort()

for i in lin:
    print(i)

Fixed submission:
from sys import stdin
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
if b-a < c*2:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+c):
        print(i)
    for j in range(b-c+1,b+1):
        print(j)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import numpy as np
import math

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

for i in range(n):
    point = 0
    lin = li[:]
    lin.pop(i)
    lin = [0] + lin + [0]
    for j in range(1,len(lin)):
        point += abs(lin[j]-lin[j-1])
    print(point)


Fixed submission:
from sys import stdin
import numpy as np
import math
from itertools import accumulate

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
lin = li[:]
lin = [0] + lin + [0]
for i in range(1,len(lin)):
    point += abs(lin[i]-lin[i-1])

for j in range(1,len(lin)-1):
    print(point-(abs(lin[j]-lin[j-1])+abs(lin[j+1]-lin[j]))+abs(lin[j+1]-lin[j-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
point = 0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a%b >= k:
            point += 1
print(point)

Fixed submission:
from sys import stdin
n,k = map(int,stdin.readline().rstrip().split())
point = 0
#n=p*b+r
for b in range(1,n+1):
    p = n//b
    r = n%b
    point += p*max(0,b-k)
    point += max(0,r-k+1)
if k == 0:
    point -= n
print(point)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j
    
q = int(input())

for _ in range(q):
    l,r = map(int,input().split())
    point = 0
    for i in range(1,(r-l)//d+1):
        point += abs(dic[l+d*(i-1)][0]-dic[l+d*i][0])+abs(dic[l+d*(i-1)][1]-dic[l+d*i][1])
    print(point)

Fixed submission:
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}
q = int(input())

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j

li = [0]*(h*w+1)

for i in range(d+1,h*w+1):
    if i-d not in dic:
        continue
    li[i] = li[i-d] + abs(dic[i][0]-dic[i-d][0]) + abs(dic[i][1]-dic[i-d][1])

for _ in range(q):
    l,r = map(int,input().split())
    print(li[r]-li[l])

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j
    
q = int(input())

for _ in range(q):
    l,r = map(int,input().split())
    point = 0
    for i in range(1,(r-l)//d+1):
        point += abs(dic[l+d*(i-1)][0]-dic[l+d*i][0])+abs(dic[l+d*(i-1)][1]-dic[l+d*i][1])
    print(point)

Fixed submission:
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
dic = {}
q = int(input())

for i in range(h):
    for j in range(w):
        dic[a[i][j]] = i,j

li = [0]*(h*w+1)

for i in range(d+1,h*w+1):
    if i-d not in dic:
        continue
    li[i] = li[i-d] + abs(dic[i][0]-dic[i-d][0]) + abs(dic[i][1]-dic[i-d][1])

for _ in range(q):
    l,r = map(int,input().split())
    print(li[r]-li[l])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import heapq
inf = 10**10
h,w = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
li = [["#" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        if s[j] == ".":
            point += 1
        li[i][j] = s[j]

def dijkstra(start, W):
    distance_list = [inf] * len(W)
    distance_list[start] = 0
    done_list = []
    wait_heap = []
    for i, d in enumerate(distance_list):
        heapq.heappush(wait_heap, (d, i))
    while wait_heap:
        p = heapq.heappop(wait_heap)
        i = p[1]
        if i in done_list:
            continue
        done_list.append(i)
        for j, x in enumerate(W[i]):
            if x != 0 and j not in done_list:
                d = min(distance_list[j], distance_list[i]+x)
                distance_list[j] = d
                heapq.heappush(wait_heap, (d, j))
    return distance_list

a = [[0 for i in range(w)]for j in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] = i*w + j

lin = [[0 for i in range(h*w)]for j in range(h*w)]

for i in range(h):
    for j in range(w-1):
        if li[i][j] == "." and li[i][j+1] == ".":
            lin[a[i][j]][a[i][j+1]] = 1
            lin[a[i][j+1]][a[i][j]] = 1

for i in range(h-1):
    for j in range(w):
        if li[i][j] == "." and li[i+1][j] == ".":
            lin[a[i][j]][a[i+1][j]] = 1
            lin[a[i][j]][a[i+1][j]] = 1

lis = dijkstra(0,lin)
if lis[h*w-1] == inf:
    print(-1)
    exit()

print(point-lis[-1]-1)

Fixed submission:
from sys import stdin
from itertools import combinations

n = int(stdin.readline().rstrip())
a = int(stdin.readline().rstrip())

if a >= n:
    print("Yes")

else:
    if n%500 <= a:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(A);B = sum(B)
count = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count += (j-i+1)//2
    else:
        count += i-j
if count <= total:
    print("Yes")
else:
    print("No")

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(a);B = sum(b)
count_1 = 0
count_2 = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count_1 += (j-i+1)//2
    else:
        count_2 += i-j
count = max(count_1,count_2)
if count <= total:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())

li = [0]*86

li[0] = 2
li[1] = 1

for i in range(2,86):
    li[i] = li[i-1] + li[i-2]

print(li[n])

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())

li = [0]*87

li[0] = 2
li[1] = 1

for i in range(2,87):
    li[i] = li[i-1] + li[i-2]

print(li[n])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
c = list(map(int,stdin.readline().rstrip().split()))

a.sort()
b.sort()
c.sort()

total = 0
for i in range(n):
    l= bisect.bisect_left(b,c[i])
    point = 0
    for j in range(l):
        point += bisect.bisect_left(a,b[j])
    total += point
print(total)

Fixed submission:
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
c = list(map(int,stdin.readline().rstrip().split()))

a.sort()
b.sort()
c.sort()

total = 0
for i in range(n):
    l = bisect.bisect(a,b[i]-1)
    r = n -bisect.bisect_left(c,b[i]+1)
    total += l*r

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
c = list(map(int,stdin.readline().rstrip().split()))

a.sort()
b.sort()
c.sort()

total = 0
for i in range(n):
    l= bisect.bisect_left(b,c[i])
    point = 0
    for j in range(l):
        point += bisect.bisect_left(a,b[j])
    total += point
print(total)

Fixed submission:
from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
c = list(map(int,stdin.readline().rstrip().split()))

a.sort()
b.sort()
c.sort()

total = 0
for i in range(n):
    l = bisect.bisect(a,b[i]-1)
    r = n -bisect.bisect_left(c,b[i]+1)
    total += l*r

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
li = []
for key, value in groupby(t):
    li.append((key,len(list(value))))
for i in li:
    if d.count(i[0]) < i[1]:
        print("NO")
        exit()
print("YES")

Fixed submission:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
else:
    print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
li = []
for key, value in groupby(t):
    li.append((key,len(list(value))))
for i in li:
    if d.count(i[0]) < i[1]:
        print("NO")
        exit()
print("YES")

Fixed submission:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
else:
    print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
li = []
for key, value in groupby(t):
    li.append((key,len(list(value))))
for i in li:
    if d.count(i[0]) < i[1]:
        print("NO")
        exit()
print("YES")

Fixed submission:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().rstrip().split()))
m = int(stdin.readline().rstrip())
t = list(map(int,stdin.readline().rstrip().split()))
d.sort()
t.sort()
now = 0
for i in d:
    if i == t[now]:
        now += 1
    if now == m:
        print("YES")
        exit()
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
n,m,k = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(n+1):
    for j in range(m+1):
        kosuu = (n-j)*i+(m-i)*j
        if kosuu == k:
            print("Yes")
            exit()
print("No")

Fixed submission:
from sys import stdin
s = stdin.readline().rstrip()

if s[:4] == "YAKI":
    print("Yes")
else:
    print("No")