Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[[] for _ in range(N+1)]
for a in range(N-1):
    u,v,w=map(int,input().split())  #これで良いのか
    L[u].append((v,w))
    L[v].append((u,w))

color=[-1]*(N+1)

def dfs(x,cur=0):
    global L
    global color

    color[x]=cur
    for next in L[x]:
        if color[next[0]]!=-1:
            continue
        if next[1]%2==0:
            dfs(next[0],cur)
        if next[1]%2==1:
            dfs(next[0],1-cur)

dfs(1)
for b in range(1,N+1):
    print(color[b])







Fixed submission:
from collections import deque

N=int(input())
L=[[] for _ in range(N+1)]
for a in range(N-1):
    u,v,w=map(int,input().split())  #これで良いのか
    L[u].append((v,w))
    L[v].append((u,w))

dist=[-1]*(N+1)
q=deque()
color=[-1]*(N+1)

dist[1]=0
q.append(1)
color[1]=0
while q:
    now=q.popleft()
    for next in L[now]:
        if dist[next[0]]==-1:
            q.append(next[0])
            dist[next[0]]=dist[now]+next[1]
            if dist[next[0]]%2==0:
                color[next[0]]=0
            else:
                 color[next[0]]=1

for b in range(1,N+1):
    print(color[b])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H,W=map(int,input().split())

q=deque()
dist=[[-1]*(W+1) for a in range(H+1)]
G=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    G_comp=list(str(input()))
    for j in range(1,W+1):
        if G_comp[j-1]=='#':
            q.append((i,j))
            dist[i][j]=0
        G[i][j]=G_comp[j-1]

def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if G[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1

M=[]
for k in range(1,H+1):
    M.append(max(dist[k]))

print(max(M))






Fixed submission:
from collections import deque
H,W=map(int,input().split())

q=deque()
dist=[[-1]*(W+1) for a in range(H+1)]
G=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    G_comp=list(str(input()))
    for j in range(1,W+1):
        if G_comp[j-1]=='#':
            q.append((i,j))
            dist[i][j]=0
        G[i][j]=G_comp[j-1]

def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if G[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1

M=[]
for k in range(1,H+1):
    M.append(max(dist[k]))

print(max(M))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
H=[0]+list(map(int,input().split()))

inf=float('inf')
DP=[inf]*(N+1)  #DP[0]はダミー
DP[1]=0

def culc(index):   #index>=2
    global DP
    global H
    global K

    head=max(1,index-K)

    for i in range(head,index):
        DP[index]=min(DP[index],DP[i]+abs(H[i]-H[index]))

for j in range(2,N+1):
    culc(j)

print(DP[N])
    



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

inf=float('inf')
DP=[inf]*(N+1)  #DP[0]はダミー
DP[1]=0

def culc(index):   #index>=2
    global DP
    global H
    global K

    head=max(1,index-K)

    for i in range(head,index):
        DP[index]=min(DP[index],DP[i]+abs(H[i]-H[index]))

for j in range(2,N+1):
    culc(j)

print(DP[N])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return res

ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))

print(ans)



Fixed submission:
S=str(input())
T=str(input())

ls=len(S)
lt=len(T)


DP=[[0]*(lt+1) for _ in range(ls+1)]


for i in range(1,ls+1):
    for j in range(1,lt+1):
        if S[i-1]==T[j-1]:
            DP[i][j]=max(DP[i-1][j-1]+1,DP[i][j-1],DP[i-1][j])
        else:
            DP[i][j]=max(DP[i][j-1],DP[i-1][j])

lf=DP[ls][lt]

res=''
u=ls
v=lt
while u>0 and v>0:
    if DP[u][v]==DP[u-1][v]:
        u-=1
    elif DP[u][v]==DP[u][v-1]:
        v-=1
    else:
        res=S[u-1]+res
        u-=1
        v-=1

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
T=str(input())

ls=len(S)
lt=len(T)


DP=[[0]*(lt+1) for _ in range(ls+1)]


for i in range(1,ls+1):
    for j in range(1,lt+1):
        if S[i-1]==T[j-1]:
            DP[i][j]=max(DP[i-1][j-1]+1,DP[i][j-1],DP[i-1][j])
        else:
            DP[i][j]=max(DP[i][j-1],DP[i-1][j])

lf=DP[ls][lt]

res=''
u=ls
v=lt
while u>0 and v>0:
    if DP[u][v]==DP[u-1][v]:
        u-=1
    elif DP[u][v]==DP[u][v-1]:
        v-=1
    else:
        res=S[u-1]+res
        u-=1
        v-=1

print(res)

Fixed submission:
S=str(input())
T=str(input())

ls=len(S)
lt=len(T)


DP=[[0]*(lt+1) for _ in range(ls+1)]


for i in range(1,ls+1):
    for j in range(1,lt+1):
        if S[i-1]==T[j-1]:
            DP[i][j]=max(DP[i-1][j-1]+1,DP[i][j-1],DP[i-1][j])
        else:
            DP[i][j]=max(DP[i][j-1],DP[i-1][j])

lf=DP[ls][lt]

res=''
u=ls
v=lt
while u>0 and v>0:
    if DP[u][v]==DP[u-1][v]:
        u-=1
    elif DP[u][v]==DP[u][v-1]:
        v-=1
    else:
        res=S[u-1]+res
        u-=1
        v-=1

print(res)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G
    global DP

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]  #resは不可

ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))

print(ans)



Fixed submission:
import sys
sys.setrecursionlimit(1000000)

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

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G
    global DP

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]  #resは不可


ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))



print(ans)

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

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]

ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))

print(ans)



Fixed submission:
import sys
sys.setrecursionlimit(1000000)

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

G=[[] for _ in range(N+1)]  #G[0]はダミー
for edge in range(M):
    x,y=map(int,input().split())
    G[x].append(y)

DP=[-1]*(N+1)   #DP[0]はダミー

def rec(now):
    global G
    global DP

    if DP[now]!=-1:
        return DP[now]

    else:
        res=0
        for next in G[now]:
            res=max(res,rec(next)+1)
        DP[now]=res
        return DP[now]  #resは不可


ans=0
for v in range(1,N+1):
    ans=max(ans,rec(v))



print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import queue

H,W=map(int,input().split())
G=[list(str(input())) for _ in range(H)]
P=10**9+7


def sur(v):#v is tuple
    global H
    global W
    global G

    vx=v[0]
    vy=v[1]
    preE=[(vx+1,vy),(vx,vy+1)]
    E=[]
    for e in preE:
        if 0<=e[0]<H and 0<=e[1]<W:
            if G[e[0]][e[1]]=='.':
                E.append(e)
    return E

#DP[i][j]=(i+1,j+1)までの行き方の総数
DP=[[0]*W for row in range(H)]
DP[0][0]=1


#BFS
q=queue.Queue()
q.put((0,0))
L=set()
while not q.empty():
    now=q.get()
    for next in sur(now):
        DP[next[0]][next[1]]+=DP[now[0]][now[1]]
        DP[next[0]][next[1]]=DP[next[0]][next[1]]%P
        if next in L:
            continue
        q.put(next)
        L.add(next)
        #if next==(H-1,W-1):
            #print(now,next,L)

#for i in range(H):
    #string=''
    #for j in range(W):
        #if G[i][j]=='#':
            #string+=G[i][j]+' '
        #else:
            #string+=str(DP[i][j])+' '
    #print(string)
        
print(DP[H-1][W-1])



Fixed submission:
H,W=map(int,input().split())
G=[list(str(input())) for _ in range(H)]
P=10**9+7

DP=[[0]*(W+1) for _ in range(H+1)]
DP[1][1]=1

for i in range(1,H+1):
    for j in range(1,W+1):
        if G[i-1][j-1]=='#':
            DP[i][j]=0
        else:
            DP[i][j]+=DP[i-1][j]+DP[i][j-1]
            DP[i][j]=DP[i][j]%P


print(DP[H][W])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=[0]+list(map(float,input().split()))

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

for i in range(N):
    for j in range(i+1):
        DP[i+1][j+1]+=DP[i][j]*P[i+1]
        DP[i+1][j]+=DP[i][j]*(1-P[i+1])

#for row in range(N+1):
    #string=''
    #for column in range(N+1):
        #string+=str(DP[row][column])+' '
    #print(string)

ans=0
half=(N+1)//2
for k in range(half,N+1):
    ans+=DP[N][k]

print(ans)

Fixed submission:
N=int(input())
P=[0]+list(map(float,input().split()))

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

for i in range(N):
    for j in range(i+1):
        DP[i+1][j+1]+=DP[i][j]*P[i+1]
        DP[i+1][j]+=DP[i][j]*(1-P[i+1])

#for row in range(N+1):
    #string=''
    #for column in range(N+1):
        #string+=str(DP[row][column])+' '
    #print(string)

ans=0
half=(N+1)//2
for k in range(half,N+1):
    ans+=DP[N][k]

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

DP=[False]*(K+1)
for i in range(1,K+1):
    for j in range(0,N):
        if A[j]<=i:
            DP[i]=DP[i] or not DP[i-A[j]]
        else:
            break

if DP[K]:
    print('First')
else:
    print('Second')



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

DP=[False]*(K+1)
for i in range(1,K+1):
    for j in range(0,N):
        if A[j]<=i:
            DP[i]=DP[i] or not DP[i-A[j]]
        else:
            break

if DP[K]:
    print('First')
else:
    print('Second')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

import queue

P=10**9+7
N=int(input())
G=[[] for index1 in range(N+1)]
for index3 in range(N-1):
    x,y=map(int,input().split())
    G[x].append(y)
    G[y].append(x)


DP=[]
DP_sum=[0]*(N+1)
for index4 in range(N+1):
    DP.append([-1,-1])  #白、黒
q=queue.Queue()
q.put(1)
DP_sum[1]=2

def dfs(v,pv=0):
    if DP[v]!=[-1,-1]:#不要
        return DP[v]
    else:
        nvs=G[v]
        if pv in nvs:#無駄
            nvs.remove(pv)
        if not nvs:
            DP[v]=[1,1]
            DP_sum[v]=DP[v][0]+DP[v][1]
            return DP[v]
        else:
            v_white=1
            v_black=1
            for nv in nvs:
                nvxy=dfs(nv,v)
                v_white*=(nvxy[0]+nvxy[1])
                v_black*=nvxy[0]
                v_white%=P
                v_black%=P
            DP[v]=[v_white,v_black]
            DP_sum[v]=(DP[v][0]+DP[v][1])%P
            return DP[v]

dfs(1)
print(DP_sum[1])




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

import queue

P=10**9+7
N=int(input())
G=[[] for index1 in range(N+1)]
for index3 in range(N-1):
    x,y=map(int,input().split())
    G[x].append(y)
    G[y].append(x)


DP=[]
DP_sum=[0]*(N+1)
for index4 in range(N+1):
    DP.append([-1,-1])  #白、黒
q=queue.Queue()
q.put(1)
DP_sum[1]=2

def dfs(v,pv=0):
    #if DP[v]!=[-1,-1]:#不要
        #return DP[v]
    nvs=G[v]
    if v!=1:
        nvs.remove(pv)
    if not nvs:
        DP[v]=[1,1]
        DP_sum[v]=DP[v][0]+DP[v][1]
        return DP[v]
    else:
        v_white=1
        v_black=1
        for nv in nvs:
            nvxy=dfs(nv,v)
            v_white*=(nvxy[0]+nvxy[1])
            v_black*=nvxy[0]
            v_white%=P
            v_black%=P
        DP[v]=[v_white,v_black]
        DP_sum[v]=(DP[v][0]+DP[v][1])%P
        return DP[v]

dfs(1)
print(DP_sum[1])
Buggy python submission (verdict: Runtime Error):
from collections import deque

H,W=map(int,input().split())
count=0
S=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    S_comp=list(str(input()))
    for j in range(1,W+1):
        if S_comp[j-1]=='.':
            count+=1
        S[i][j]=S_comp[j-1]


def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if S[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

q=deque()
s=(1,1)
g=(H,W)
q.append(s)
dist=[[-1]*(W+1) for k in range(H+1)]
dist[s[0]][s[1]]=0

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1
        if next==g:
            ans=dist[g[0]][g[1]]
            break
    else:
        continue
    break

print(count-1-ans)






Fixed submission:
from collections import deque

H,W=map(int,input().split())
count=0
S=[['#']*(W+1) for _ in range(H+1)]
for i in range(1,H+1):
    S_comp=list(str(input()))
    for j in range(1,W+1):
        if S_comp[j-1]=='.':
            count+=1
        S[i][j]=S_comp[j-1]


def sur(v):  #v is tuple
    vx=v[0]
    vy=v[1]
    preE=[(vx-1,vy),(vx+1,vy),(vx,vy-1),(vx,vy+1)]
    E=[]
    for nv in preE:
        if 1<=nv[0]<=H and 1<=nv[1]<=W:
            if S[nv[0]][nv[1]]=='.':
                E.append(nv)
    return E

q=deque()
s=(1,1)
g=(H,W)
q.append(s)
dist=[[-1]*(W+1) for k in range(H+1)]
dist[s[0]][s[1]]=0

while q:
    now=q.popleft()
    for next in sur(now):
        if dist[next[0]][next[1]]!=-1:
            continue
        q.append(next)
        dist[next[0]][next[1]]=dist[now[0]][now[1]]+1
        if next==g:
            ans=dist[g[0]][g[1]]
            print(count-1-ans)
            break
    else:
        continue
    break
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[]
for index in range(n):
    A.append(list(map(int,input().split())))

def warshall_floyd(G):
    h=len(G)

    res=0
    for x in range(h):
        for y in range(x+1,h):
            res+=G[x][y]

    check=[[0]*h for z in range(h)]
    for k in range(h):
        for i in range(h):
            for j in range(h):
                temp=G[i][k]+G[k][j]
                if temp==G[i][j]:
                   if i!=j and j!=k and k!=i:
                       check[i][j]=1
                elif temp<G[i][j]:
                    if i!=j and j!=k and k!=i:
                        check[i][j]=-1
    decrease=0             
    for p in range(h):
        for q in range(h):
            if check[p][q]==-1:
                return [False]
            elif check[p][q]==1:
                decrease+=G[p][q]
    else:
        return [True,res-decrease//2]


ans=warshall_floyd(A)
if not ans[0]:
    print(-1)
else:
    print(ans[1])



Fixed submission:
n=int(input())
A=[]
for index in range(n):
    A.append(list(map(int,input().split())))

def warshall_floyd(G):
    h=len(G)

    res=0
    for x in range(h):
        for y in range(x+1,h):
            res+=G[x][y]

    check=[[0]*h for z in range(h)]
    for k in range(h):
        for i in range(h):
            for j in range(h):
                temp=G[i][k]+G[k][j]
                if temp==G[i][j]:
                   if i!=j and j!=k and k!=i:
                       check[i][j]=1
                elif temp<G[i][j]:
                    if i!=j and j!=k and k!=i:
                        check[i][j]=-1
    decrease=0             
    for p in range(h):
        for q in range(h):
            if check[p][q]==-1:
                return [False]
            elif check[p][q]==1:
                decrease+=G[p][q]
    else:
        return [True,res-decrease//2]


ans=warshall_floyd(A)
if not ans[0]:
    print(-1)
else:
    print(ans[1])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
G=[[False]*(M+1) for _ in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a][b]=True
    G[b][a]=True

visited=[False]*(N+1)

visited[1]=True
def dfs(start):
    global N
    global visited
    all_visited=True
    sum=0

    for p in range(1,N+1):
        if not visited[p]:
            all_visited=False

    if all_visited:
        return 1
    else:
        for next in range(1,N+1):#N小より全探索
            if not G[start][next]:
                continue
            if visited[next]:
                continue
            visited[next]=True
            sum+=dfs(next)
            visited[next]=False   #backtrack

        return sum

print(dfs(1))


Fixed submission:
N,M=map(int,input().split())
G=[[False]*(N+1) for _ in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a][b]=True
    G[b][a]=True

visited=[False]*(N+1)

visited[1]=True
def dfs(start):
    global N
    global visited
    all_visited=True
    sum=0

    for p in range(1,N+1):
        if not visited[p]:
            all_visited=False

    if all_visited:
        return 1
    else:
        for next in range(1,N+1):#N小より全探索
            if not G[start][next]:
                continue
            if visited[next]:
                continue
            visited[next]=True
            sum+=dfs(next)
            visited[next]=False   #backtrack

        return sum

print(dfs(1))

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
G=[[False]*(M+1) for _ in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a][b]=True
    G[b][a]=True

visited=[False]*(N+1)

visited[1]=True
def dfs(start):
    global N
    global visited
    all_visited=True
    sum=0

    for p in range(1,N+1):
        if not visited[p]:
            all_visited=False

    if all_visited:
        return 1
    else:
        for next in range(1,N+1):#N小より全探索
            if not G[start][next]:
                continue
            if visited[next]:
                continue
            visited[next]=True
            sum+=dfs(next)
            visited[next]=False   #backtrack

    return sum

print(dfs(1))


Fixed submission:
N,M=map(int,input().split())
G=[[False]*(N+1) for _ in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a][b]=True
    G[b][a]=True

visited=[False]*(N+1)

visited[1]=True
def dfs(start):
    global N
    global visited
    all_visited=True
    sum=0

    for p in range(1,N+1):
        if not visited[p]:
            all_visited=False

    if all_visited:
        return 1
    else:
        for next in range(1,N+1):#N小より全探索
            if not G[start][next]:
                continue
            if visited[next]:
                continue
            visited[next]=True
            sum+=dfs(next)
            visited[next]=False   #backtrack

        return sum

print(dfs(1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
a = list(map(int,readline().split()))
c = 1
for i in range(k):
  c *= a[i]
  
for i in range(n-k):
  chk = c*a[k+i]//a[i]
  if chk > c:
    print('Yes')
  else:
    print('No')

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,k = map(int,readline().split())
a = list(map(int,readline().split()))
for i in range(n-k):
  chk = a[k+i]
  c = a[i]
  if chk > c:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i,ai in enumerate(a):
  if (i+1)%2 == 1 and ai%2 == 1:
    ans += 1
print(ans)

Fixed submission:
l,r,d = map(int,input().split())
print(r//d-(l-1)//d)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
  
ans = 0
for i in range(1,n+1):
  ans += len(divisors(i))*i
print(ans)

Fixed submission:
n = int(input())
a = 0
for i in range(1,n+1):
  m = n//i
  a += (m+1)*(m)*i//2
print(a)
Buggy python submission (verdict: Runtime Error):
def main(): 
  import sys
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  from bisect import bisect

  n = int(readline())
  g = []
  for i in range(n):
    v,W = map(int,readline().split())
    g.append((v,W))

  q = int(readline())
  for i in range(q):
    V,w = map(int,readline().split())
    c = []
    ans = 0
    while V > 0:
      c.append(g[V-1])
      V //= 2
    d = []
    e = []
    h = n//2-1
    H = n-h
    for i in range(2**h):
      cw = 0
      cv = 0
      for j,cj in enumerate(c[:h]):
        if (i>>j)&1 == 1:
          cw += cj[1]
          cv += cj[0]
      d.append((cv,cw))

    for i in range(2**H):
      cw = 0
      cv = 0
      for j,cj in enumerate(c[h:]):
        if (i>>j)&1 == 1:
          cw += cj[1]
          cv += cj[0]
      e.append((cv,cw))

    from operator import itemgetter
    e = sorted(e,key=itemgetter(1))

    Ev = [0]
    Ew = [0]
    ch = 0
    for i in range(1,len(e)):
      ev,ew = e[i]
      if ev > ch:
        Ev.append(ev)
        Ew.append(ew)
        ch = ev

    for i in d:
      Cv,Cw = i
      if Cw > w:
        continue
      ind = bisect(Ew,w-Cw)
      cc = Cv+Ev[ind-1]
      ans = max(cc,ans)

    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
s = input()
print(s[:3])