Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
print(max(table))

Fixed submission:
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))

Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[t]+=1
table=table.values()
table=[x for x in table if x >= 0]
print(sum(table))

Fixed submission:
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))

Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
s=[int(input()) for i in range(N)]
M=int(input())
t=[int(input()) for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[t]+=1
table=table.values()
table=[x for x in table if x >= 0]
print(sum(table))

Fixed submission:
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))

Buggy python submission (verdict: Runtime Error):
import collections
N=int(input())
s=[int(input()) for i jn range(N)]
M=int(input())
t=[int(input()) for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[t]+=1
table=table.values()
table=[x for x in table if x >= 0]
print(sum(table))

Fixed submission:
import collections
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

table=collections.defaultdict(int)
for x in s:
  table[x]+=1
for x in t:
  table[x]-=1
table=table.values()
table=[x for x in table if x >= 0]
table.append(0)
print(max(table))
Buggy python submission (verdict: Runtime Error):
N = int(input())
ab = [[0, 0] for i in range(N)]
b = [0]*N
cd = [[0, 0] for i in range(N)]
d = [0]*N

for i in range(N):
    ab[i] = list(map(int, input().split()))
for i in range(N):
    cd[i] = list(map(int, input().split()))

points2 = [[] for i in range(N)]
ab.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1])

for i in range(N):
    for j in range(N):
        if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
            points2[j].append(i)

points2.sort(key=lambda x: len(x))
ans = 0

for i in range(N):
    if len(points[i]) == 0:
        continue
    for j in range(i+1, N):
        if points[i][0] in points[j]:
            points[j].pop(points[j].index(points[i][0]))
    ans += 1
print(ans)

Fixed submission:
N = int(input())
ab = [[0, 0] for i in range(N)]
b = [0]*N
cd = [[0, 0] for i in range(N)]
d = [0]*N

for i in range(N):
    ab[i] = list(map(int, input().split()))
for i in range(N):
    cd[i] = list(map(int, input().split()))

points = [[] for i in range(N)]
points2 = [[] for i in range(N)]
cd.sort(key=lambda x: x[0])
ab.sort(key=lambda x: x[1], reverse=True)

points.sort(key=lambda x: len(x))
ans = 0

for i in range(N):
    for j in range(N):
        if ab[i][0] < cd[j][0] and ab[i][1] < cd[j][1]:
            ans += 1
            cd[j][0] = -1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

first = N*M
ans = 0

def reverse(x):
    if x == 0:
        return(1)
    else:
        return(0)


field = [[0]*(M+2) for i in range(N+2)]

for i in range(1, N+1):
    for j in range(1, M+1):
        field[i-1][j-1] = reverse(field[i-1][j-1])
        field[i][j-1] = reverse(field[i][j-1])
        field[i+1][j-1] = reverse(field[i+1][j-1])
        field[i-1][j] = reverse(field[i-1][j])
        field[i][j] = reverse(field[i][j])
        field[i+1][j] = reverse(field[i+1][j])
        field[i-1][j+1] = reverse(field[i-1][j+1])
        field[i][j+1] = reverse(field[i][j+1])
        field[i+1][j+1] = reverse(field[i+1][j+1])
ans = 0

for i in range(1, N+1):
    ans += sum(field[i][1:M+1])

print(ans)


Fixed submission:
N, M = map(int, input().split())
ans = 0
if N >= 3:
    if M >= 3:
        ans = (N-2)*(M-2)
    else:
      if M == 2:
        ans=0
      else:
        ans=N-2
else:
    if N == 2:
      ans=0
    else:
      if M == 2:
        ans=0
      elif M == 1:
        ans=1
      else:
        ans=M-2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
ans = 0
for i in range(1, N+1):
    for j in range(1, N+1):
        if i % j >= K:
            ans += 1
print(ans)


Fixed submission:
N,K=map(int,input().split())
ans=0
for i in range(K+1,N+1):
  ans += (i-K) * (N//i) + (max(0,N%i - max(K-1,0)))
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=list(input.split())
if "Y" in S:
  print("Four")
else:
  print("Three")

Fixed submission:
N=int(input())
S=list(input().split())
if "Y" in S:
  print("Four")
else:
  print("Three")
Buggy python submission (verdict: Time Limit Exceeded):
H,W,D=map(int,input().split())
import collections
table=collections.defaultdict(tuple)

field=[list(map(int,input().split())) for i in range(H)]
for i in range(H):
  for j in range(W):
    table[field[i][j]]=(i,j)
Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]

for i in range(Q):
  ans=0
  x = table[LR[i][0]]
  value=LR[i][0]
  now=list(x)
  while(value != LR[i][1]):
    value+=D
    next=table[value]
    ans+=abs(next[0]-now[0])+abs(next[1]-now[1])
    now[0],now[1]=next[0],next[1]
    
  print(ans)

Fixed submission:
H,W,D=map(int,input().split())
import collections
import bisect
table=collections.defaultdict(list)
table2=collections.defaultdict(list)
dp=collections.defaultdict(list)
field=[list(map(int,input().split())) for i in range(H)]
for i in range(H):
  for j in range(W):
    table[field[i][j]%D].append((field[i][j],i,j))
    table2[field[i][j]%D].append(field[i][j])
for x in table:
  table[x].sort(key=lambda x:x[0])
  dp[x]=[0]*len(table[x])
  for i in range(1,len(table[x])):
    dp[x][i]=dp[x][i-1]+abs(table[x][i][1]-table[x][i-1][1])+abs(table[x][i][2]-table[x][i-1][2])
  table2[x].sort()
Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  ans=0
  x,y = LR[i]
  
  id = bisect.bisect_left(table2[x%D],x)
  id2=bisect.bisect_left(table2[x%D],y)
  print(dp[x%D][id2]-dp[x%D][id])

Buggy python submission (verdict: Runtime Error):
H,W,D=map(int,input().split())
import collections
table=collections.defaultdict(tuple)

field=[list(map(int,input().split())) for i in range(W)]
for i in range(H):
  for j in range(W):
    table[field[i][j]]=(i,j)
Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]

for i in range(Q):
  ans=0
  x = table[LR[i][0]]
  value=LR[i][0]
  now=list(x)
  while(value != LR[i][1]):
    value+=D
    next=table[value]
    ans+=abs(next[0]-now[0])+abs(next[1]-now[1])
    now[0],now[1]=next[0],next[1]
    
  print(ans)

Fixed submission:
H,W,D=map(int,input().split())
import collections
import bisect
table=collections.defaultdict(list)
table2=collections.defaultdict(list)
dp=collections.defaultdict(list)
field=[list(map(int,input().split())) for i in range(H)]
for i in range(H):
  for j in range(W):
    table[field[i][j]%D].append((field[i][j],i,j))
    table2[field[i][j]%D].append(field[i][j])
for x in table:
  table[x].sort(key=lambda x:x[0])
  dp[x]=[0]*len(table[x])
  for i in range(1,len(table[x])):
    dp[x][i]=dp[x][i-1]+abs(table[x][i][1]-table[x][i-1][1])+abs(table[x][i][2]-table[x][i-1][2])
  table2[x].sort()
Q=int(input())
LR=[list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  ans=0
  x,y = LR[i]
  
  id = bisect.bisect_left(table2[x%D],x)
  id2=bisect.bisect_left(table2[x%D],y)
  print(dp[x%D][id2]-dp[x%D][id])
Buggy python submission (verdict: Runtime Error):
c = [[]]*3

for i in range(3):
    c[i] = map(int, input().split())
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [0]* 3
    for i in range(3):
        arr = c[i][0] - c[i][1] - c[i][2]
    
    if arr[0] == arr[1] and arr[0] == arr[2]:
        print("Yes")
        exit(0)

print("No")

Fixed submission:
c = [[]]*3

for i in range(3):
    c[i] = list(map(int, input().split()))
ans = 0
for i in range(3):
    ans += sum(c[i])

if ans % 3 == 0:
    arr = [[0]* 6]*3
    for i in range(3):
        arr[i][0] = c[i][0] - c[i][1]
        arr[i][1] = c[i][0] - c[i][2]
        arr[i][2] = c[i][1] - c[i][0]
        arr[i][3] = c[i][1] - c[i][2]
        arr[i][4] = c[i][2] - c[i][0]
        arr[i][5] = c[i][2] - c[i][1]
    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    for i in range(3):
        arr[i][0] = c[0][i] - c[1][i]
        arr[i][1] = c[0][i] - c[2][i]
        arr[i][2] = c[1][i] - c[0][i]
        arr[i][3] = c[1][i] - c[2][i]
        arr[i][4] = c[2][i] - c[1][i]
        arr[i][5] = c[2][i] - c[0][i]
          

    for i in range(6):
        if arr[0][i] == arr[1][i] and arr[0][i] == arr[2][i]:
            continue
        else:
            print("No")
            exit(0)

    arr = [0]*3
    sum = 0
    for i in range(3):
        arr[0] += c[i][i]
    for i in range(3):
        if i + 1 < 3:
            arr[1] += c[i][i+1]
        else:
            arr[1] += c[i][0]
    for i in range(3):
        if i + 2 < 3:
            arr[2] += c[i][i+2]
        else:
            arr[2] += c[i][i-1]
    
    if arr[0] != arr[1] or arr[0] != arr[2]:
        print("No")
        exit(0)

    print("Yes")
    exit(0)

print("No")
Buggy python submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

white = 0

for i in range(H):
    white += s[i].count(".")


q = deque()
q.append((0, 0))

g = [[10**9]*W for i in range(H)]
g[0][0] = 0
for i in range(H*W):
    x, y = q.popleft()
    if (x, y) == (H-1, W-1):
        break
    else:
        if x < H-1 and s[x+1][y] == ".":
            if g[x+1][y] == 10**9:
                q.append((x+1, y))
            g[x+1][y] = min(g[x+1][y], g[x][y]+1)
        if y < W-1 and s[x][y+1] == ".":
            if g[x][y+1] == 10**9:
                q.append((x, y+1))
            g[x][y+1] = min(g[x][y+1], g[x][y]+1)
        if x > 0 and s[x-1][y] == ".":
            if g[x-1][y] == 10**9:
                q.append((x-1, y))
            g[x-1][y] = min(g[x-1][y], g[x][y]+1)
        if y > 0 and s[x][y-1] == ".":
            if g[x][y-1] == 10**9:
                q.append((x, y-1))
            g[x][y-1] = min(g[x][y-1], g[x][y]+1)
if g[H-1][W-1] == 10**9:
    print(-1)
else:
    print(white - (g[H-1][W-1]+1))


Fixed submission:
from collections import deque
H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

white = 0

for i in range(H):
    white += s[i].count(".")

q = deque()
q.append((0, 0))

g = [[10**9]*W for i in range(H)]
g[0][0] = 0
for i in range(H*W):
    if len(q) == 0:
        break
    x, y = q.popleft()
    if (x, y) == (H-1, W-1):
        break
    else:
        if x < H-1 and s[x+1][y] == ".":
            if g[x+1][y] == 10**9:
                q.append((x+1, y))
            g[x+1][y] = min(g[x+1][y], g[x][y]+1)
        if y < W-1 and s[x][y+1] == ".":
            if g[x][y+1] == 10**9:
                q.append((x, y+1))
            g[x][y+1] = min(g[x][y+1], g[x][y]+1)
        if x > 0 and s[x-1][y] == ".":
            if g[x-1][y] == 10**9:
                q.append((x-1, y))
            g[x-1][y] = min(g[x-1][y], g[x][y]+1)
        if y > 0 and s[x][y-1] == ".":
            if g[x][y-1] == 10**9:
                q.append((x, y-1))
            g[x][y-1] = min(g[x][y-1], g[x][y]+1)
if g[H-1][W-1] == 10**9:
    print(-1)
else:
    print(white - (g[H-1][W-1]+1))
Buggy python submission (verdict: Runtime Error):
Q = int(input())
lr = [tuple(map(int, input().split())) for i in range(Q)]


def primes(n):
    ret = []
    A = [i for i in range(2, n+1)]
    k = 0
    s = n**0.5
    while(k < s):
        ret.append(A[0])
        k = A[0]
        A = [x for x in A if x % k]
    ret += A
    return ret


prime = primes(10**5)

table = collections.defaultdict(int)
prime_s = set(prime)
t = [0]*(10**5 + 1)
for i in range(1, 10**5+1):
    if i in prime_s and (i+1)//2 in prime_s:
        t[i] = 1
for i in range(1, 10**5+1):
    t[i] = t[i] + t[i-1]

for l, r in lr:
    print(t[r] - t[l-1])


Fixed submission:
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(1,int(math.sqrt(x))):
      if x % (i+1) == 0:
        return False
    return True

table=[0]*50001
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2 - 1]
  
for i in range(Q):
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(2,int(math.sqrt(x))):
      if x % i == 0:
        return False
    return True

table=[0]*50000
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2]
for i in range(Q):
  print(ans[i])
  

Fixed submission:
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(1,int(math.sqrt(x))):
      if x % (i+1) == 0:
        return False
    return True

table=[0]*50001
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2 - 1]
  
for i in range(Q):
  print(ans[i])

Buggy python submission (verdict: Runtime Error):
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(2,int(math.sqrt)):
      if x % i == 0:
        return False
    return True

table=[0]*50000
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2]
for i in range(Q):
  print(ans[i])
  

Fixed submission:
import math
Q = int(input())

def sosuu(x):
  if x == 1:
    return False
  else:
    for i in range(1,int(math.sqrt(x))):
      if x % (i+1) == 0:
        return False
    return True

table=[0]*50001
for i in range(1,50001):
  if sosuu(2*i - 1) and sosuu(i):
    table[i]=table[i-1] + 1
  else:
    table[i]=table[i-1]
    
ans=[0]*Q
for i in range(Q):
  l,r=map(int,input().split())
  ans[i]=table[(r+1)//2] - table[(l+1)//2 - 1]
  
for i in range(Q):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())
d=Y-X
k= Y // X
if k <= 1:
  print(1)
  exit(0)
count=0
while(1):
  if  <= 2**count:
    break
  else:
    count+=1
print(count+1)


Fixed submission:
X,Y=map(int,input().split())
d=Y-X
k= Y // X
if k <= 1:
  print(1)
  exit(0)
count=1
while(1):
  if k < 2**count:
    break
  elif k ==2**count:
    count+=1
    break
  else:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(N-K):
    ans+=table[i][1]
  print(ans)

Fixed submission:
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(len(table)-K):
    ans+=table[i][1]
  print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
ana=0
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(N-K):
    ans+=table[i][1]
print(ans)

Fixed submission:
import collections
N,K=map(int,input().split())
a=list(map(int,input().split()))
table=collections.defaultdict(int)
for i in range(N):
  table[a[i]]+=1
table= list(table.items())
if len(table)<=K:
  print(0)
else:
  ans=0
  table.sort(key =lambda x:x[1])
  for i in range(len(table)-K):
    ans+=table[i][1]
  print(ans)
Buggy python submission (verdict: Runtime Error):
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert("A",i)
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")

Fixed submission:
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if len(S) > i and A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert(i,"A")
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
S=input()
A="AKIHABARA"
id=0
for i in range(len(A)):
  if A[i]==S[id]:
    id+=1
    continue
  else:
    if A[i]=="A":
      continue
    else:
      print("NO")
      exit(0)
print("YES")

Fixed submission:
S=list(input())
A="AKIHABARA"
id=0
for i in range(len(A)):
  if len(S) > i and A[i]==S[i]:
    continue
  else:
    if A[i]=="A":
      S.insert(i,"A")
    else:
      print("NO")
      exit(0)
if "".join(S)==A:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,d]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]
    
if sum(dic.values()) - smax[0]>= smax[0] - 1:
  print("YES")
else:
  print("NO")

Fixed submission:
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,"d"]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]

if len(dic.values())==1:
  if len(S)==1:
    print("YES")
  else:
    print("NO")
  exit(0)
    
elif len(dic.values())==2:
  if len(S)==2:
    print("YES")
  else:
    print("NO")
  exit(0)
if sum(dic.values()) - smax[0]>= smax[0]:
  if smax[0] - min(dic.values()) <= 1:
    print("YES")
    exit(0)
    
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import copy
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]
# cost = [[-1]*10 for i in range(10)]
# for j in range(10):
#     cost[j] = [[c[i][j], i] for i in range(10)]
cost = [-1]*10
cost[1] = 0

dp = [[-1]*10 for i in range(10)]
for i in range(10):
    dp[i][i] = 0


def search_cost(i, j, reached):
    # if dp[i][j] != -1:
    #     return dp[i][j]
    tmp_list = copy.copy(reached)
    tmp_list.append(i)
    ret = c[i][j]

    for k in range(10):
        if k == i or k == 1 or k in reached:
            continue
        else:
            tmp = c[i][k] + search_cost(k, j, tmp_list)
            ret = min(tmp, ret)
            if ret <= 2:
                break
            #print("i:"+str(i) + "k:" + str(k) + "j:"+str(j) + "=" + str(tmp))

    # dp[i][j] = ret
    # for i in range(10):
    #     print(dp[i])
    return ret


for i in range(10):
    if i == 1:
        continue
    else:
        if c[i][1] <= 2:
            dp[i][1] = c[i][1]
            cost[i] = c[i][1]
        else:
            cost[i] = search_cost(i, 1, [])
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += cost[A[i][j]]
print(ans)


Fixed submission:
import copy
H, W = map(int, input().split())
c = [list(map(int, input().split())) for i in range(10)]
A = [list(map(int, input().split())) for i in range(H)]
# cost = [[-1]*10 for i in range(10)]
# for j in range(10):
#     cost[j] = [[c[i][j], i] for i in range(10)]
cost = [-1]*10
cost[1] = 0

dp = [[-1]*10 for i in range(10)]
for i in range(10):
    dp[i][i] = 0


def search_cost(i, j, reached):
    # if dp[i][j] != -1:
    #     return dp[i][j]
    if cost[i] != -1:
        return cost[i]
    tmp_list = copy.copy(reached)
    tmp_list.append(i)
    ret = c[i][j]

    for k in range(10):
        if k == i or k == 1 or k in reached:
            continue
        else:
            tmp = c[i][k] + search_cost(k, j, tmp_list)
            ret = min(tmp, ret)
            if ret <= 2:
                break
            #print("i:"+str(i) + "k:" + str(k) + "j:"+str(j) + "=" + str(tmp))

    # dp[i][j] = ret
    # for i in range(10):
    #     print(dp[i])
    return ret


for i in range(10):
    if i == 1:
        continue
    else:
        if c[i][1] <= 2:
            dp[i][1] = c[i][1]
            cost[i] = c[i][1]
        else:
            cost[i] = search_cost(i, 1, [])
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += cost[A[i][j]]
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(input().split())

ans=(M*1900 +(N-M)*100)*(2**M)

print(ans)

Fixed submission:
N,M=map(int,input().split())
ans=(M*1900 +(N-M)*100)*(2**M)

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

A.sort()
B.sort()
C.sort()
tmp = [0]*N
for i in reversed(range(N)):
    if i == N-1:
        for j in range(N):
            if C[j] > B[i]:
                tmp[i] += 1
    else:

        for j in range(N):
            if C[j] > B[i+1]:
                tmp[i] += tmp[i+1]
                break
            if C[j] > B[i]:
                tmp[i] += 1


ans = 0
for i in range(N):
    k = 0
    for j in range(k, N):
        # print(ans)
        if B[j] > A[i]:
            ans += sum(tmp[j:])
            k = j
            break


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.sort()
B.sort()
C.sort()
ans=0
BC=[0]*N
for i in range(N):
  id = bisect.bisect_right(C,B[i])
  BC[i]=N-id
sBC=[0]*(N+1)
for i in range(1,N+1):
  sBC[i]=sBC[i-1]+BC[i-1]
for i in range(N):
  id=bisect.bisect_right(B,A[i])
  ans+=sBC[N]-sBC[id]
print(ans)