Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m,s=map(int,input().split())
s=min(s,2500)
import networkx as nx
G = nx.DiGraph()
G.add_nodes_from(range(125000))
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        G.add_edge(u-1+j*n,v-1+(j-a)*n,weight=b)
        G.add_edge(v-1+j*n,u-1+(j-a)*n,weight=b)
for i in range(n):
    c,d=map(int,input().split())
    c=min(c,2500)
    for j in range(2501-c):
        G.add_edge(i+j*n,i+(j+c)*n,weight=d)
    for j in range(2500):
        G.add_edge(i+(j+1)*n,i+j*n,weight=0)
d=nx.single_source_dijkstra_path_length(G, s*n)
for i in range(1,n):
    print(d[i])

Fixed submission:
n,m,s=map(int,input().split())
s=min(s,2500)
edge=[[] for i in range(n*50*51)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        edge[u-1+j*n].append((v-1+(j-a)*n,b))
        edge[v-1+j*n].append((u-1+(j-a)*n,b))
for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i+j*n].append((i+(j+c)*n,d))
    for j in range(2500):
        edge[i+(j+1)*n].append((i+j*n,0))
from heapq import heappush,heappop,heapify
d = [float('inf') for i in range(n*50*51)]
pq = []
heappush(pq,(0,s*n))
while pq:
    weight,u = heappop(pq)
    if d[u]>weight:
        d[u]=weight
        for v,weight in edge[u]:
            heappush(pq,(d[u]+weight,v))
for i in range(1,n):
    print(d[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,m,s=map(int,input().split())
s=min(s,2500)
edge=[[] for i in range(n*50*51)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        edge[u-1+j*n].append((v-1+(j-a)*n,b))
        edge[v-1+j*n].append((u-1+(j-a)*n,b))
for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i+j*n].append((i+(j+c)*n,d))
    for j in range(2500):
        edge[i+(j+1)*n].append((i+j*n,0))
from heapq import heappush,heappop,heapify
d = [float('inf') for i in range(n*50*51)]
pq = []
heappush(pq,(0,s*n))
while pq:
    weight,u = heappop(pq)
    if d[u]>weight:
        d[u]=weight
        for v,weight in edge[u]:
            heappush(pq,(d[u]+weight,v))
for i in range(1,n):
    print(d[i])

Fixed submission:
n,m,s=map(int,input().split())
s=min(s,2500)
edge=[[] for i in range(n*50*51)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        edge[u-1+j*n].append((v-1+(j-a)*n,b))
        edge[v-1+j*n].append((u-1+(j-a)*n,b))
for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i+j*n].append((i+(j+c)*n,d))
    for j in range(2500):
        edge[i+(j+1)*n].append((i+j*n,0))
from heapq import heappush,heappop,heapify
d = [float('inf') for i in range(n*50*51)]
pq = []
heappush(pq,(0,s*n))
while pq:
    weight,u = heappop(pq)
    if d[u]>weight:
        d[u]=weight
        for v,weight in edge[u]:
            heappush(pq,(d[u]+weight,v))
for i in range(1,n):
    print(d[i])
Buggy python submission (verdict: Time Limit Exceeded):
h,w,k=map(int,input().split())
import numpy as np
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=np.cumsum(l,axis=1)
a=np.cumsum(a,axis=0)
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)

Fixed submission:
h,w,k=map(int,input().split())
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=[[0 for i in range(w+1)] for i in range(h+1)]
for i in range(1,h+1):
    for j in range(1,w+1):
        a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+l[i][j]
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                if w2-1==w1:
                    t=h*w
                    break
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)

Buggy python submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
import numpy as np
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=np.cumsum(l,axis=1)
a=np.cumsum(a,axis=0)
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)

Fixed submission:
h,w,k=map(int,input().split())
l=[[0 for i in range(w+1)]]+[[0]+[int(j) for j in input()] for i in range(h)]
a=[[0 for i in range(w+1)] for i in range(h+1)]
for i in range(1,h+1):
    for j in range(1,w+1):
        a[i][j]=a[i-1][j]+a[i][j-1]-a[i-1][j-1]+l[i][j]
ans=h*w
def ink(h2,h1,w2,w1):
    return a[h2][w2]-a[h1][w2]-(a[h2][w1]-a[h1][w1])
for i in range(2**(h-1)):
    tl=[0]
    for j in range(h-1):
        if i>>j&1:
            tl.append(j+1)
    tl.append(h)
    t=len(tl)-2
    w1=0
    for w2 in range(1,w+1):
        for h1,h2 in zip(tl,tl[1:]):
            if ink(h2,h1,w2,w1)>k:
                if w2-1==w1:
                    t=h*w
                    break
                w1=w2-1
                t+=1
                break
    ans=min(ans,t)
print(ans)
Buggy python submission (verdict: Runtime Error):
r1,c1,r2,c2=map(int,input().split())
r2+=1
c2+=1
N=2*(10**6)
mod=10**9+7
fac=[1]*(N+2)
inv=[1]*(N+2)
t=1
for i in range(1,N+2):
    t*=i
    t%=mod
    fac[i]=t
t=pow(fac[N+1],mod-2,mod)
for i in range(N+1,0,-1):
    inv[i]=t
    t*=i
    t%=mod
def comb(n,r):
    return fac[n]*inv[n-r]*inv[r]%mod
print(comb(r2+c2,c2)-comb(r2+c1,c1)-comb(r1+c2,c2)+comb(r1+c1,c1))

Fixed submission:
r1,c1,r2,c2=map(int,input().split())
r2+=1
c2+=1
N=2*(10**6)+2
mod=10**9+7
fac=[1]*(N+2)
inv=[1]*(N+2)
t=1
for i in range(1,N+2):
    t*=i
    t%=mod
    fac[i]=t
t=pow(fac[N+1],mod-2,mod)
for i in range(N+1,0,-1):
    inv[i]=t
    t*=i
    t%=mod
def comb(n,r):
    return fac[n]*inv[n-r]*inv[r]%mod
print((comb(r2+c2,c2)-comb(r2+c1,c1)-comb(r1+c2,c2)+comb(r1+c1,c1))%mod)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        quit()
    ans.append(j)
    f(i-j,m)
f(n,m)
print(" ".join(map(str,ans[::-1])))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
l=[0 for i in range(n+1)]
i=0
j=0
while j<n:
    j+=1
    while s[j]=="1":
        j+=1
    while j>i:
        i+=1
        l[i]=j
ans=[[] for i in range(n+1)]
for i in range(1,m+1):
    ans[i].append(i)
for i in range(m+1,n+1):
    if s[i]=="1":
        continue
    else:
        ans[i]=ans[l[i-m]]+[i-l[i-m]]
if 0 in ans[-1]:
    print(-1)
else:
    print(" ".join(map(str,ans[-1])))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())
s=input()
ans=[]
def f(i,j):
    if i==0:
        print(" ".join(map(str,ans[::-1])))
        return
    if j>i:
        j=i
    while s[i-j]=="1":
        j-=1
    if j==0:
        print(-1)
        return
    ans.append(j)
    f(i-j,m)
f(n,m)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
hi=10**12
lo=0
def c(mi):
    tmp=0
    for i,j in zip(a,f):
        if mi//j<i:
            tmp+=i-mi//j
    if tmp<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if c(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a.sort()
f.sort(reverse=True)
hi=10**12
lo=0
def c(mi):
    tmp=0
    for i,j in zip(a,f):
        if mi//j<i:
            tmp+=i-mi//j
    if tmp<=k:
        return True
    return False
while hi>=lo:
    mi=(hi+lo)//2
    if c(mi):
        hi=mi-1
    else:
        lo=mi+1
print(lo)
Buggy python submission (verdict: Runtime Error):
n,m,p=map(int,input().split())
edge=[]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a,b,p-c))
INF=float('inf')
def bellmanford(s,n):
    d = [INF for i in range(n+1)]
    d[s]=0
    for i in range(n-1):
        for a,b,c in edge:
            if d[b]>d[a]+cost:
                d[b]=d[a]+cost
    for i in range(n-1):
         for a,b,c in edge:
            if d[b]>d[a]+cost:
                d[b]=-INF
    return d
d=bellmanford(1,n)
if d[n]==-INF:
    print(-1)
elif d[n]>=0:
    print(0)
else:
    print(-d[n])

Fixed submission:
n,m,p=map(int,input().split())
edge=[]
for i in range(m):
    a,b,c=map(int,input().split())
    edge.append((a,b,p-c))
INF=float('inf')
def bellmanford(s,n):
    d = [INF for i in range(n+1)]
    d[s]=0
    for i in range(n-1):
        for a,b,c in edge:
            if d[b]>d[a]+c:
                d[b]=d[a]+c
    for i in range(n-1):
         for a,b,c in edge:
            if d[b]>d[a]+c:
                d[b]=-INF
    return d
d=bellmanford(1,n)
if d[n]==-INF:
    print(-1)
elif d[n]>=0:
    print(0)
else:
    print(-d[n])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
mod=998244353
from operator import itemgetter
l.sort(key=itemgetter(1))
for i in range(n):
    l[i][1]=i
l.sort(key=itemgetter(0))
for i in range(n):
    l[i][0]=i

No=2
while No<=n:
    No*=2
tree=[0]*(2*No)

def add(k,x):
    k+=No-1
    while k>=0:
        tree[k]+=x
        k=(k-1)//2
def query(l,r):
    L=l+No-1
    R=r+No-1
    s=0
    while L<=R:
        if R&1:
            s+=tree[R]
            R-=2
        else:
            R-=1
        if L&1:
            L-=1
        else:
            s+=tree[L]
        L>>=1;R>>=1
    return s
pow2=[1 for i in range(n+2)]
t=2
for i in range(1,n+2):
    pow2[i]=t
    t*=2
    t%=mod
ans=0
for x,y in l:
    lu=query(y,n)
    ld=query(0,y)
    ru=n-1-y-lu
    rd=y-ld
    ans+=pow2[n-1]+(pow2[lu]-1)*(pow2[rd]-1)*(pow2[ru]+pow2[ld]-1+(pow2[ld]-1)*(pow2[ru]-1))%mod+(pow2[ld]-1)*(pow2[ru]-1)*(pow2[rd]+pow2[lu]-1)%mod
    ans%=mod
    add(y,1)
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
mod=998244353
from operator import itemgetter
l.sort(key=itemgetter(1))
for i in range(n):
    l[i][1]=i
l.sort(key=itemgetter(0))

No=2
while No<=n:
    No*=2
tree=[0]*(2*No)

def add(k,x):
    k+=No-1
    while k>=0:
        tree[k]+=x
        k=(k-1)//2
def query(l,r):
    L=l+No-1
    R=r+No-1
    s=0
    while L<=R:
        if R&1:
            s+=tree[R]
            R-=2
        else:
            R-=1
        if L&1:
            L-=1
        else:
            s+=tree[L]
        L>>=1;R>>=1
    return s
pow2=[1 for i in range(n+2)]
t=2
for i in range(1,n+2):
    pow2[i]=t
    t*=2
    t%=mod
ans=0
for x,y in l:
    lu=query(y,n)
    ld=query(0,y)
    ru=n-1-y-lu
    rd=y-ld
    ans+=pow2[n-1]+(pow2[lu]-1)*(pow2[rd]-1)%mod*(pow2[ru]+pow2[ld]-1+(pow2[ld]-1)*(pow2[ru]-1))%mod+(pow2[ld]-1)*(pow2[ru]-1)%mod*(pow2[rd]+pow2[lu]-1)%mod
    ans%=mod
    add(y,1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
l=input()
a=len(l)
ans=3**a
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=3**(a-i)*(2**(t+1))
    else:
        t+=1
print(ans%(10**9+7))

Fixed submission:
l=input()
a=len(l)
mod=10**9+7
ans=3**a%mod
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=pow(3,a-i,mod)*pow(2,t+1,mod)
    else:
        t+=1
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
l=input()
a=len(l)
ans=3**a
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=3**(a-i)*(2**(t+1))
    else:
        t+=1
print(ans%(10**9+7))

Fixed submission:
l=input()
a=len(l)
mod=10**9+7
ans=3**a%mod
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=pow(3,a-i,mod)*pow(2,t+1,mod)
    else:
        t+=1
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
l=input()
dp=[3**i for i in range(len(l)+1)]
ans=dp[-1]
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=dp[-i-1]*(2**(t+1))
    else:
        t+=1
print(ans%(10**9+7))

Fixed submission:
l=input()
a=len(l)
mod=10**9+7
ans=3**a%mod
t=0
for i,j in enumerate(l,1):
    if(j=="0"):
        ans-=pow(3,a-i,mod)*pow(2,t+1,mod)
    else:
        t+=1
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
k+=1
s=s[:k]+s[k].lower()+s[k+1:]
print(s)

Fixed submission:
n,k=map(int,input().split())
s=input()
k-=1
s=s[:k]+s[k].lower()+s[k+1:]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int, input().split())
a=[[i for i in input()] for j in range(h)]
q=[]
ans=-1
for i in range(h):
    for j in range(w):
        if(a[i][j]=="#"):
            q.append([i,j])
while len(q)>0:
    tl=deque(q)
    q.clear()
    for i in tl:
        y=i[0]
        x=i[1]
        if(y>0):
            if(a[y-1][x]=="."):
                a[y-1][x]="#"
                q.append([y-1,x])
        if(x>0):
            if(a[y][x-1]=="."):
                a[y][x-1]="#"
                q.append([y,x-1])
        if(y<h-1):
            if(a[y+1][x]=="."):
                a[y+1][x]="#"
                q.append([y+1,x])
        if(x<w-1):
            if(a[y][x+1]=="."):
                a[y][x+1]="#"
                q.append([y,x+1])
    ans+=1
print(ans)

Fixed submission:
h,w=map(int, input().split())
a=[[i for i in input()] for j in range(h)]
q=[]
ans=-1
for i in range(h):
    for j in range(w):
        if(a[i][j]=="#"):
            q.append([i,j])
while len(q)>0:
    tl=q
    q=[]
    for i in tl:
        y=i[0]
        x=i[1]
        if(y>0):
            if(a[y-1][x]=="."):
                a[y-1][x]="#"
                q.append([y-1,x])
        if(x>0):
            if(a[y][x-1]=="."):
                a[y][x-1]="#"
                q.append([y,x-1])
        if(y<h-1):
            if(a[y+1][x]=="."):
                a[y+1][x]="#"
                q.append([y+1,x])
        if(x<w-1):
            if(a[y][x+1]=="."):
                a[y][x+1]="#"
                q.append([y,x+1])
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int, input().split())
a=[[i for i in input()] for j in range(h)]
q=[]
ans=-1
for i in range(h):
    for j in range(w):
        if(a[i][j]=="#"):
            q.append([i,j])
while len(q)>0:
    tl=q.copy()
    q=[]
    for i in tl:
        y=i[0]
        x=i[1]
        if(y>0):
            if(a[y-1][x]=="."):
                a[y-1][x]="#"
                q.append([y-1,x])
        if(x>0):
            if(a[y][x-1]=="."):
                a[y][x-1]="#"
                q.append([y,x-1])
        if(y<h-1):
            if(a[y+1][x]=="."):
                a[y+1][x]="#"
                q.append([y+1,x])
        if(x<w-1):
            if(a[y][x+1]=="."):
                a[y][x+1]="#"
                q.append([y,x+1])
    ans+=1
print(ans)

Fixed submission:
h,w=map(int, input().split())
a=[[i for i in input()] for j in range(h)]
q=[]
ans=-1
for i in range(h):
    for j in range(w):
        if(a[i][j]=="#"):
            q.append([i,j])
while len(q)>0:
    tl=q
    q=[]
    for i in tl:
        y=i[0]
        x=i[1]
        if(y>0):
            if(a[y-1][x]=="."):
                a[y-1][x]="#"
                q.append([y-1,x])
        if(x>0):
            if(a[y][x-1]=="."):
                a[y][x-1]="#"
                q.append([y,x-1])
        if(y<h-1):
            if(a[y+1][x]=="."):
                a[y+1][x]="#"
                q.append([y+1,x])
        if(x<w-1):
            if(a[y][x+1]=="."):
                a[y][x+1]="#"
                q.append([y,x+1])
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lst=[list(map(int,input().split()))  for i in range(m)]
o=[i for i in range(n+1)]
os=[1 for i in range(n+1)]
ans=[n*(n-1)//2]
kumi=n*(n-1)//2
def get(x):
  if(x==o[x]):
    return x
  else:
    return get(o[x])
for i in range(m-1,0,-1):
  a=lst[i][0]
  b=lst[i][1]
  oa=get(a)
  ob=get(b)
  if(oa!=ob):
    kumi=kumi-os[oa]*os[ob]
    ans+=[kumi]
    o[oa]=ob
    os[ob]=os[oa]+os[ob]
  else:
    ans+=[kumi]
for i in range(m-1,-1,-1):
  print(ans[i])


Fixed submission:
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
class unionfind:
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def count(self, x):
        return -self.root[self.find(x)]
uf=unionfind(n)
ans=n*(n-1)//2
for i in range(1,m+1):
    a,b=ab[-i]
    ab[-i]=ans
    if(uf.same(a,b)):
        continue
    else:
        ans-=uf.count(a)*uf.count(b)
        uf.unite(a,b)
for i in ab:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, p=map(int, input().split())
b=int(p**(1/n)+1)
for i in reversed(range(1,b+1)):
  if(p%i==0):
    if(p%(i**n)==0):
          c=i
          break
print(c)

Fixed submission:
n, p=map(int, input().split())
b=int(p**(1/n))+1
c=1
for i in reversed(range(1,b+1)):
  if(40<n):
    break
  if(p%i==0):
    if(p%(i**n)==0):
          c=i
          break
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, p=map(int, input().split())
b=int(p**(1/n)+1)
c=1
for i in reversed(range(1,b+1)):
  if(p%(i**n)==0):
    c=i
    break
print(c)

Fixed submission:
n, p=map(int, input().split())
b=int(p**(1/n))+1
c=1
for i in reversed(range(1,b+1)):
  if(40<n):
    break
  if(p%i==0):
    if(p%(i**n)==0):
          c=i
          break
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
b=[1]*a[0]
for i in range(n-1):
  if(a[i]<a[i+1]):
    b=b+[1]*(a[i+1]-a[i])
  elif(a[i]==a[i+1]):
    b=[b[0]+1]+[1]*(a[i+1]-1)
  else:
    b=b[0:a[i+1]]
    b[-1]=b[-1]+1
print(b[0])

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
import collections
d=collections.defaultdict(int)
for i in l:
    d[i]+=1
l.sort(reverse=True)
ans=0
for i in l:
    if d[i]>0:
        d[i]-=1
        if d[2**i.bit_length()-i]>0:
            ans+=1
            d[2**i.bit_length()-i]-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().suplit())
h=list(input().suplit())
b=1
c=abs(t-h[0]*0.006-a)
for i in n :
  if(abs(t-h[i]*0.006-a)<c):
    b=i+1
    c=abs(t-h[i]*0.006-a)
  else:
    continue
print(b)  

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
b=1
c=abs(t-h[0]*0.006-a)
for i in range(n) :
  if(abs(t-h[i]*0.006-a)<c):
    b=i+1
    c=abs(t-h[i]*0.006-a)
  else:
    continue
print(b)
Buggy python submission (verdict: Runtime Error):
a, b, c= (int(i) for i in input().split())
for i in range(c):
 if(i%2==0):
  a=a//2
  b=b+a
 else:
  b=b//2
  a=a+b
print(a,b)

Fixed submission:
s=input()
if(len(s)==2):
 print(s)
else:
 print(s[-1::-1])

Buggy python submission (verdict: Runtime Error):
a, b, c= (int(i) for i in input().split())
for i in range(c):
 if(i%2==0):
  a=a//2
  b=b+a//2
 else:
  b=b//2
  a=a+b//2
print(a,b)

Fixed submission:
s=input()
if(len(s)==2):
 print(s)
else:
 print(s[-1::-1])

Buggy python submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split()) 
for i in range(c):
 if(i%2==0):
  a=a//2
  b=b+a//2
 else:
  b=b//2
  a=a+b//2
print(a,b)

Fixed submission:
s=input()
if(len(s)==2):
 print(s)
else:
 print(s[-1::-1])
Buggy python submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split()) 
for i in range(c)
 if(i%2==0):
  a=a//2
  b=b+a//2
 else:
  b=b//2
  a=a+b//2
print(a,b)

   

Fixed submission:
a, b, c= (int(i) for i in input().split())
for i in range(c):
 if(i%2==0):
  a=a//2
  b=b+a
 else:
  b=b//2
  a=a+b
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
n, m =map(int, input().split())
a=m//n
c=0
while c==0:
  if(m%a==0):
      c=a
  a=a-1
print(c)

Fixed submission:
n,m=map(int,input().split())
a=1
for i in range(1,min(int(m**0.5),m//n)+1):
    if(m%i==0):
        if(i>=n):
            a=m//i
            break
        else:
            a=i
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n, m =map(int, input().split())
a=m//n
c=0
while c==0:
  if((m-a*n)%a==0):
      c=a
  a=a-1
print(c)


Fixed submission:
n,m=map(int,input().split())
a=1
for i in range(1,min(int(m**0.5),m//n)+1):
    if(m%i==0):
        if(i>=n):
            a=m//i
            break
        else:
            a=i
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n, m =map(int, input().split())
a=m//n
c=0
while c==0:
  b=m-a*n
  if(b%a==0):
      c=a
  a=a-1
print(c)

Fixed submission:
n,m=map(int,input().split())
a=1
for i in range(1,min(int(m**0.5),m//n)+1):
    if(m%i==0):
        if(i>=n):
            a=m//i
            break
        else:
            a=i
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n,n))
for i in range(m):
    L,R=map(int,input().split())
    a[:L,R-1:]+=1
for i in range(q):
    L,R=map(int,input().split())
    print(int(a[L-1][R-1]))

Fixed submission:
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
    L,R=map(int,input().split())
    a[1][R]+=1
    a[L+1][R]-=1
a=np.cumsum(a, axis=1)
a=np.cumsum(a, axis=0)
for i in range(q):
    L,R=map(int,input().split())
    print(int(a[L][R]))