Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02618 (python)

Fixed submission:
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([0 for _ in range(26)])

for day in range(1,D+1):
    score=np.array(list(map(int,input().split())))
    tmp=C*(last_day-day)
    #今回行うコンテストで得られる
    idx=np.argmax(tmp+score)
    # ans=ans+score[idx]+np.sum(tmp)+abs(tmp[idx])
    last_day[idx]=day
    print(idx+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([-1 for _ in range(26)])
score=np.array([list(map(int,input().split())) for _ in range(D)])
 
for day in range(D):
    today_point=C*(day-last_day)
    S_today=sum(today_point)
    for k in range(26):
        today_point[k]=score[day][k]-S_today+today_point[k]
 
    if day!=D-1:
        max_score=-1*float("inf")
        for k in range(26):
            nday_point=C*((day+1)-last_day)
            S_nday=sum(nday_point)-C[k]*(day-last_day[k])
            
            for i in range(26):
                if k!=i:
                    nday_point[i]=score[day+1][i]-S_nday+nday_point[i]
                else:
                    nday_point[i]=score[day+1][i]-S_nday+C[i]
 
                if today_point[k]+nday_point[i]>max_score:
                    max_score=today_point[k]+nday_point[i]
                    idx=k
    else:
        idx=np.argmax(today_point)
 
    last_day[idx]=day
    output[day]=idx+1
print(*output)

Buggy submission (verdict: Runtime Error):
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([0 for _ in range(26)])

for day in range(1,D+1):
    score=np.array(list(map(int,input().split())))
    tmp=C*(last_day-day)
    #今回行うコンテストで得られる
    idx=np.argmax(tmp+score)
    # ans=ans+score[idx]+np.sum(tmp)+abs(tmp[idx])
    # last_day[idx]=day
    print(idx+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
ans=0
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([0 for _ in range(26)])
print(C)
for day in range(1,D+1):
    score=np.array(list(map(int,input().split())))
    tmp=C*(last_day-day)
    #今回行うコンテストで得られる
    idx=np.argmax(tmp+score)
    # ans=ans+score[idx]+np.sum(tmp)+abs(tmp[idx])
    # last_day[idx]=day
    print(idx+1)
Problem p02642 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
A.sort()
num=[A[0]]
if A[0]==A[1]:
    flag=1
else:
    flag=0
    
for i in range(1,n):
    a=A[i]
    for k in num:
        if a%k==0:
            break

    num.append(a)
    if a==A[i+1]:
        flag+=1
ans=len(num)-flag
print(ans)
Problem p02678 (python)

Fixed submission:
import queue
n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[-1 for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

que=queue.Queue()
dist[1]=0
que.put(1)

while not que.empty():
    v=que.get()
    for nv in graph[v]:
        if dist[nv]!=-1:
            continue
        dist[nv]=dist[v]+1
        guide[nv]=v
        que.put(nv)

print("Yes")
print(*guide[2:],sep="\n")

Buggy submission (verdict: Runtime Error):
def dfs(v,cnt):
    dist[v]=cnt
    for nv in graph[v]:
        if dist[nv]<=cnt+1:
            continue 
        guide[nv]=v
        dfs(nv,cnt+1)

n,m=map(int,input().split())
graph=[[] for _ in range(n+1)]
dist=[float("inf") for _ in range(n+1)]
guide=[0 for _ in range(n+1)]

for _ in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

dfs(1,0)

print("Yes")
print(*guide[2:],sep="\n")
Problem p02703 (python)

Fixed submission:
import heapq

n,m,s=map(int,input().split())
limit=2500
s=min(s,limit)
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[[float("inf") for _ in range(limit+1)] for _ in range(n+1)]
queue=[]

for i in range(m):
    u,v,a,b=map(int,input().split())
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

time[1][s]=0
heapq.heappush(queue,(0,1,s))

while len(queue)!=0:
    t,v,c=heapq.heappop(queue)
    for nv,na,nb in path[v]:
        if na>c:
            continue
        elif time[nv][c-na]<=t+nb:
            continue
        else:
            time[nv][c-na]=t+nb
            heapq.heappush(queue,(t+nb,nv,c-na))

    nc=min(c+coin[v][0],limit)
    nt=t+coin[v][1]
    if time[v][nc]<=nt:
        continue
    else:
        time[v][nc]=nt
        heapq.heappush(queue,(nt,v,nc))
    
for i in range(2,n+1):
    print(min(time[i]))

Buggy submission (verdict: Runtime Error):
import heapq

n,m,s=map(int,input().split())
limit=7
S=min(s,limit)
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[[float("inf") for _ in range(limit+1)] for _ in range(n+1)]
queue=[]

for i in range(m):
    u,v,a,b=map(int,input().split())
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

for k in range(s+1):
    time[1][k]=0

heapq.heappush(queue,(0,1,s))
while len(queue)!=0:
    t,v,c=heapq.heappop(queue)
    for nv,na,nb in path[v]:
        if na>c:
            continue
        elif time[nv][c-na]<=t+nb:
            continue
        else:
            time[nv][c-na]=t+nb
            heapq.heappush(queue,(t+nb,nv,c-na))

    nc=min(c+coin[v][0],limit)
    nt=t+coin[v][1]
    if time[v][nc]<=nt:
        continue
    else:
        time[v][nc]=nt
        heapq.heappush(queue,(nt,v,nc))
    
for i in range(2,n+1):
    print(min(time[i]))

Buggy submission (verdict: Runtime Error):
n,m,s=map(int,input().split())
path=[[] for _ in range(n+1)]
coin=[(0,0)]
time=[float("inf") for _ in range(n+1)]
time[0]=0
queue=[]
for i in range(m):
    u,v,a,b=map(int,input().split())
    path[u].append((v,a,b))
    path[v].append((u,a,b))

for i in range(n):
    c,d=map(int,input().split())
    coin.append((c,d))

heapq.heappush(queue,(0,s,1))
while len(queue)!=0:
    t,c,v=heapq.heappop(queue)
    if max(time)<t:
        continue

    if time[v]>t:
        time[v]=t

    for nv,na,nb in path[v]:
        if na>c:
            continue
        else:
            heapq.heappush(queue,(t+nb,c-na,nv))
    heapq.heappush(queue,(t+coin[v][1],c+coin[v][0],v))
    
print(*time[2:],sep="\n")
Problem p02744 (python)

Fixed submission:
#=============================================================================
# パナソニックコンテスト D
#=============================================================================
import sys
sys.setrecursionlimit(10**8)
N=int(input())
abc=list("abcdefghij")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)
N=int(input())
abc=list("abcdefghi")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

Buggy submission (verdict: Runtime Error):
N=int(input())
abc=list("abcdefghi")
def dfs(s,v):
    global N
    for i in range(v+2):
        ns=s+abc[i]
        if len(ns)<N :
            if i!=v+1:
                dfs(ns,v)
            else:
                dfs(ns,v+1)
        if len(ns)==N:
            print("".join(ns))
if N==1:
    print("a")
else:
    dfs("a",0)

Buggy submission (verdict: Runtime Error):
#=============================================================================
# パナソニックコンテスト D
#=============================================================================
N=int(input())
ans=[]

def dfs(s):
    global N
    for i in range(max(s)+2):
        ns=s+[i]
        if len(ns)!=N:
            dfs(ns)
        if len(ns)>N:
            continue
        if len(ns)==N and ns not in ans:
            ans.append(ns)
s=[0]
dfs(s)
abc=list("abcdefghi")
ans.sort()
for item in ans:
    for i in range(N):
        item[i]=abc[item[i]]
    print("".join(item))
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())


if N<10:
    R=R+100*(10-N)
    print(R)
else:
    print(R)

Buggy submission (verdict: Runtime Error):
 N, R = map(int,input().split())
 print(type(N), N, R)

if N<10:
    R=R+100*(10-N)
    print(R)
else:
    print(R)
Problem p02811 (python)

Fixed submission:
a,b=map(int, input().split())
total=500*a
if total>=b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
total=500*a
if total=>X:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
total=500*k
if total=>X:
  print("Yes")
else:
  print("No")
Problem p02814 (python)

Fixed submission:
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

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

lcm = 1
for A in a:
    A//=2
    lcm *=A//fractions.gcd(lcm, A)
    if lcm>M:
        print(0)
        exit()
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

cnt=M//lcm
print((cnt+1)//2)

Buggy submission (verdict: Runtime Error):
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

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

lcm = 1
for A in a:
    a//=2
    lcm *=a//fractions.gcd(lcm, a)
    if lcm>0:
        print(0)
        exit()
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

cnt=M//lcm
print((cnt+1)//2)

Buggy submission (verdict: Runtime Error):
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

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

lcm = a[0]//2
for i in range(1, N):
    x=a[i]//2
    lcm = lcm * x // fractions.gcd(lcm, a[i])
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

cnt=M//lcm
print((cnt+1)//2)
Problem p02900 (python)

Fixed submission:
import fractions

def prime_function(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

A,B=map(int,input().split())
GCD=fractions.gcd(A,B)
print(len(set(prime_function(GCD)))+1)

Buggy submission (verdict: Runtime Error):
mport math

def prime_function(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

A,B=map(int,input().split())
GCD=math.gcd(A,B)
print(len(set(prime_function(GCD)))+1)
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*r**2)

Buggy submission (verdict: Runtime Error):
import bisect
N=int(input())
A=[int(input()) for _ in range(N)]
color=[]
A=A[::-1]
for a in A:
    i=bisect.bisect_left(color,a)
    if i==len(color):
        color.append(a)
    else:
        color[i]=a
print(len(color))
Problem p02973 (python)

Fixed submission:
import bisect
N=int(input())
A=[int(input()) for _ in range(N)]
color=[]
A=A[::-1]
for a in A:
    i=bisect.bisect_right(color,a)
    if i==len(color):
        color.append(a)
    else:
        color[i]=a
print(len(color))

Buggy submission (verdict: Runtime Error):
import bisect
N=int(input())
A=[int(input()) for _ in range(N)]
color=[]
for a in A:
    i=bisect.bisect_left(color,a)
    if i==0:
        color+=[a]
    else:
        color[i]=a
        color.sort()
print(len(color))
Problem p03044 (python)

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

N=int(input())
Graph=[[] for _ in range(N)]
color=[-1]*N

for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    Graph[a].append((b,c))
    Graph[b].append((a,c))

def dfs(Graph,v,cur=0):
    global color
    color[v]=cur
    for next_v_t in Graph[v]:
        next_v=next_v_t[0]
        w=next_v_t[1]
        if color[next_v]!=-1:
            continue
        ncur=cur
        if w%2==1:
            ncur=1-cur
        dfs(Graph,next_v,ncur)

#探索
for v in range(N):
    if color[v]==-1:
        dfs(Graph,v)
for i in color:
    print(i)

Buggy submission (verdict: Runtime Error):
#
import sys
sys.setrecursionlimit(10**7)

N=int(input())
Graph=[[] for _ in range(N)]
color=[-1]*N

for _ in range(N-1):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    Graph[a].append((b,c))
    Graph[b].append((a,c))

def dfs(v,cur=0):
    color[v]=cur
    for next_v,w in Graph[v]:
        if color[next_v]==-1:
            if w%2==1:
                cur=1-cur
        dfs(next_v,cur)
#探索
dfs(0)
for i in color:
    print(i)
Problem p03086 (python)

Fixed submission:
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    while True:
        if  i>=len(S):
            break
        elif S[i] not in ["A","C","G","T"]:
            break
        else:
            cnt+=1
            i+=1    
    if cnt>ans:
        ans=cnt
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    k=i
    while True:
        if S[k] in ["A","C","G","T"] and k<len(S):
            cnt+=1
            k+=1
        else:
            if cnt>ans:
                ans=cnt
            break
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
ans=0
for i in range(len(S)):
    cnt=0
    while True:
        if S[i] in ["A","C","G","T"] and i<len(S):
            cnt+=1
            i+=1
        else:
            if cnt>ans:
                ans=cnt
            break
print(ans)
Problem p03112 (python)

Fixed submission:
import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.append(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    ans=float("inf")
    for ss in [se,sw]:
        for tt in [te,tw]:
            ans=min(ans,abs(ss-x)+abs(tt-ss),abs(tt-x)+abs(tt-ss))
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.append(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    ans=float("inf")
    for ss in [se,sw]:
        for tt in [te,tw]:
            ans=min(ans,abs(ss-x)+abs8tt-ss),abs(tt-x)+abs(tt-ss))
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
a,b,q=map(int,input().split())
S=[];T=[]
for _ in range(a):
    s=int(input())
    S.append(s)
for _ in range(b):
    t=int(input())
    T.append(t)
S.append(10**12)
T.appent(10**12)

for _ in range(q):
    x=int(input())
    idx_s=bisect.bisect_left(S,x)
    idx_t=bisect.bisect_left(T,x)
    se=S[idx_s]
    sw=S[idx_s-1]
    te=T[idx_t]
    tw=T[idx_t-1]

    m1=abs(x-se)+abs(se-te)
    m2=abs(x-se)+abs(se-tw)
    m3=abs(x-sw)+abs(sw-te)
    m4=abs(x-sw)+abs(sw-tw)
    m5=abs(x-te)+abs(te-se)
    m6=abs(x-te)+abs(te-sw)
    m7=abs(x-tw)+abs(tw-se)
    m8=abs(x-tw)+abs(tw-sw)
    print(min(m1,m2,m3,m4,m5,m6,m7,m8))
Problem p03165 (python)

Fixed submission:
s=list(input())
t=list(input())
dp=[[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j],dp[i][j+1])
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

path=[]

lens=len(s)
lent=len(t)
while lens>-1 and lent>-1 :
    if dp[lens][lent]==dp[lens-1][lent]:
        lens-=1
    elif dp[lens][lent]==dp[lens][lent-1]:
        lent-=1
    else:
        path.append(lens)
        lens-=1
        lent-=1

path.sort()
if path==[]:
    print("")
else:
    for i in path:
    	print(s[i-1],end="")

Buggy submission (verdict: Runtime Error):
import numpy
s=list(input())
t=list(input())
dp=[["" for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
            list=[dp[i][j]+s[i],dp[i+1][j],dp[i][j+1]]
            index=numpy.argmax([len(item) for item in list])
            dp[i+1][j+1]=list[index]
        else:
            list=[dp[i][j],dp[i+1][j],dp[i][j+1]]
            index=numpy.argmax([len(item) for item in list])
            dp[i+1][j+1]=list[index]
print(dp[len(s)][len(t)])
Problem p03448 (python)

Fixed submission:
i = [int(input()) for i in range(4)]
A=i[0]
B=i[1]
C=i[2]
X=i[3]

cnt=0
for a in range(A+1):
    if 500*a >X:
        break
    else:
        for b in range(B+1):
            if 500*a + 100*b >X:
                break
            elif (X-500*a-100*b)/50<=C:
                cnt+=1
            else:
                continue
print(cnt)

Buggy submission (verdict: Runtime Error):
# ABC 087 B Coins
A=input()
B=input()
C=input()
X=input()

cnt=0
for a in range(A):
    if 500*a >X:
        break
    else:
        for b in range(B):
            if 500*a + 100*b >X:
                break
            elif (X-500*a-100*b)/50<=C:
                cnt+=1
            else:
                continue
print(cnt)
Problem p03457 (python)

Fixed submission:
N=int(input())
des=[list(map(int,input().split())) for _ in range(N)]
des.insert(0,[0,0,0])
for i in range(N):
    time=des[i+1][0]-des[i][0]
    d_x=abs(des[i+1][1]-des[i][1])
    d_y=abs(des[i+1][2]-des[i][2])
    if (time-(d_x+d_y))%2!=0 or time<(d_x+d_y):
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
des=[list(map(int,input().split())) for _ in range(N)]
des.insert(0,[0,0,0])
for i in range(N):
    time=des[i+1][0]-des[i][0]
    d_x=abs(des[i+1][1]-des[i][1])
    d_y=abs(des[i+1][2]-des[i][2])
    if (time-(d_x+d_y))%2!=0 and time>=(d_x+d_y)
        print("No")
        exit()
print("Yes")
Problem p03474 (python)

Fixed submission:
A,B=map(int,input().split())
S=input()
if S.count("-")==1 and S.index("-")==A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
S1,S2=input().split("-")
if len(S1)==A and len(S2)==B:
    print("Yes")
else:
    print("No")
Problem p03493 (python)

Fixed submission:

s=input()
list0=["000"]
list1=["100","010","001"]
list2=["110","101","011"]
list3=["111"]
if s in list0:
    print(0)
if s in list1:
    print(1)
if s in list2:
    print(2)
if s in list3:
    print(3)

Buggy submission (verdict: Runtime Error):
s=input()
counter=0
if s[0]=1:
    counter+=1
if s[1]=1:
    counter+=1
if s[2]=1:
    counter+=1
print(counter)

Buggy submission (verdict: Runtime Error):
s=input()
list0=[000]
list1=[100,010,001]
list2=[110,101,011]
list3=[111]
if s in list0:
    print(0)
if s in list1:
    print(1)
if s in list2:
    print(2)
if s in list3:
    print(3)
Problem p03494 (python)

Fixed submission:
N = int(input())
a = [int(x) for x in input().split()]
cnt=0
Flag=True
while(Flag):
    for i in range(N):
        if a[i]%2!=0:
            Flag=False
            break
        a[i]/=2
    cnt+=1
print(cnt-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
counter=0
while True:
    z=2**(counter+1)
    for i in range(n):
        if a[i]%z==0:
        else :
            print(counter)
            break
    counter+=1

Buggy submission (verdict: Runtime Error):
a = [int(x) for x in input().split()]
d=0
while True:
    c=0
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]/2
            c+=1
    if c==0:
        break
    else:
        d+=1
print(d-1)

Buggy submission (verdict: Runtime Error):
a = [int(x) for x in input().split()]
d=0
while True:
    c=0
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]/2
            c+=1
    if c==0:
        break
    else:
        d+=1
print(d)
Problem p03557 (python)

Fixed submission:
from bisect import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
B_reverse=B[::-1]
C=sorted(list(map(int,input().split())))
cnt=0
dict={}
val=0
for b in B_reverse:
    c_min=bisect(C,b)
    val+=N-c_min
    dict[b]=val
for a in A:
    b_min=bisect(B,a)
    if b_min==N:
        pass
    else:
        cnt+=dict[B[b_min]]
print(cnt)

Buggy submission (verdict: Runtime Error):
from bisect import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
B_reverse=B[::-1]
C=sorted(list(map(int,input().split())))
cnt=0
dict={}
val=0
for b in B_reverse:
    c_min=bisect(C,b)
    val+=len(C[c_min:])
    dict[b]=val
for a in A:
    cnt+=dict[B[bisect(B,a)]]
print(cnt)
Problem p02603 (python)

Fixed submission:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
a.insert(0,10000)
a.append(0)
i=0
m=len(a)
while i<m-1:
    if a[i]==a[i+1]:
        del a[i]
        i-=1
    i+=1
    m=len(a)

n=len(a)-2

l=[0]*(n+2)
for i in range(1,n+1):
    if a[i-1]<a[i]>a[i+1]:
        l[i]=1
    elif a[i-1]>a[i]<a[i+1]:
        l[i]=-1
sto=[0,1000]
for i in range(n+2):
    if l[n+1-i]==-1:
        l[n+1-i]=0
        break
    elif l[n+1-i]==1:
        break
for i in range(n+2):
    if l[i]==-1:
        sto[0],sto[1]=divmod(sto[1],a[i])
    if l[i]==1:
        sto[1]+=sto[0]*a[i]
        sto[0]=0
print(sto[1])

Buggy submission (verdict: Runtime Error):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
a.insert(0,10000)
a.append(0)
l=[0]*(n+2)
for i in range(1,n+1):
    if a[i-1]<a[i]>=a[i+1]:
        l[i]=1
    elif a[i-1]>a[i]<=a[i+1]:
        l[i]=-1
sto=[0,1000]
for i in range(n+2):
    if l[i]==-1:
        sto[0],sto[1]=divmod(sto[1],a[i])
    if l[i]==1:
        sto[1]+=sto[0]*a[i]
        sto[0]=0
if sto[0]!=0:
    for i in range(n+2):
        if l[n+2-i]==-1:
            print(sto[1]+sto[0]*a[n+2-1])
            exit()
else:
    print(sto[1])