Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]
data=[[0]*(h*w//d+1) for i in range(d)]
for i in range(h):
    for j in range(w):
        b=a[i][j]%d
        c=a[i][j]//d
        data[b][c]=[i, j]
for u in lr:
    l,r=u
    b=l%d
    c=l//d
    e=r//d
    ans=0
    for i in range(c,e):
        x,y=data[b][i]
        X,Y=data[b][i+1]
        ans+=abs(x-X)+abs(y-Y)
    print(ans)

Fixed submission:
h,w,d=map(int,input().split())
a=[list(map(int,input().split())) for i in range(h)]
q=int(input())
lr=[list(map(int,input().split())) for i in range(q)]
data=[[[0,0]]*(h*w//d+1) for i in range(d)]
for i in range(h):
    for j in range(w):
        b=a[i][j]%d
        c=a[i][j]//d
        data[b][c]=[i, j]
lst=[[0]*(h*w//d+1) for i in range(d)]
for i in range(d):
    for j in range(1,h*w//d+1):
        x,y=data[i][j]
        X,Y=data[i][j-1]
        lst[i][j]=lst[i][j-1]+abs(x-X)+abs(y-Y)
for u in lr:
    l,r=u
    b=l%d
    c=l//d
    e=r//d
    ans=lst[b][e]-lst[b][c]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#Grid Repainting
from collections import deque
import sys
h,w=map(int,input().split())
field=[list(input()) for _ in range(h)]
white=0
for i in range(h):
    for j in range(w):
        if field[i][j]==".":
            white+=1
start=[0,0]
goal=[h-1,w-1]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
count=0
que=deque([[[0,0]]])
field[0][0]="#"
while que:
    q=que.popleft()
    count+=1
    k=[]
    while q:
        p=q.pop()
        x=p[0]
        y=p[1]
        if x==h-1 and y==w-1:
            break
        for i in range(4):
            nx=x+dx[i]
            ny=y+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w:
                if field[nx][ny]!="#":
                    k.append([nx,ny])
                    field[nx][ny]="#"
    else:
        que.append(k)
        continue
    break
else:
    print(-1)
    sys.exit()
print(white-count)

Fixed submission:
#Grid Repainting
from collections import deque
import sys
h,w=map(int,input().split())
field=[list(input()) for _ in range(h)]
white=0
for i in range(h):
    for j in range(w):
        if field[i][j]==".":
            white+=1
start=[0,0]
goal=[h-1,w-1]
dx=[1,0,-1,0]
dy=[0,1,0,-1]
count=0
que=deque([[[0,0]]])
field[0][0]="#"
while que:
    q=que.popleft()
    count+=1
    k=[]
    while q:
        p=q.pop()
        x=p[0]
        y=p[1]
        if x==h-1 and y==w-1:
            break
        for i in range(4):
            nx=x+dx[i]
            ny=y+dy[i]
            if 0<=nx and nx<h and 0<=ny and ny<w:
                if field[nx][ny]!="#":
                    k.append([nx,ny])
                    field[nx][ny]="#"
    else:
        if k:
            que.append(k)
        continue
    break
else:
    print(-1)
    sys.exit()
print(white-count)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop,heappush 
k=int(input())
inf=float("inf")
data=[[] for i in range(k)]
for i in range(1,k):
    if i%10==9:
        data[i]=[[i*10%k,0]]
    else:
        data[i]=[[i*10%k,0],[(i+1)%k,1]]

que=[[1,1]]
ans=[inf]*k
count=1
while que:
    c,u=heappop(que)
    ans[u]=c
    for v,d in data[u]:
        if ans[v]==inf:
            heappush(que,[d+c,v])
    if ans[0]!=inf:
        break
print(ans[0])

Fixed submission:
from heapq import heappop,heappush 
from collections import deque
k=int(input())
inf=float("inf")
data=[[] for i in range(k)]
for i in range(1,k):
    if i%10==9:
        data[i]=[[i*10%k,0]]
    else:
        data[i]=[[i*10%k,0],[(i+1)%k,1]]

que=deque([[1,1]])
ans=[inf]*k
while que:
    c,u=que.popleft()
    ans[u]=c
    for v,d in data[u]:
        if ans[v]==inf:
            if d==0:
                que.appendleft([c,v])
            else:
                que.append([c+1,v])
    if ans[0]!=inf:
        break
print(ans[0])
Buggy python submission (verdict: Runtime Error):
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
data.sort()
ans=0
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)

Fixed submission:
from bisect import bisect
a,b,c,d,e,f=map(int,input().split())
g=f//100
lst=[0]*(g+1)
i=0
for i in range(31):
    for j in range(31):
        h=a*i+b*j
        if h<=g:
            lst[h]=1
data=[]
for i in range(g*e//c):
    for j in range(g*e//d):
        data.append(c*i+d*j)
if not data:
    data=[0]
data.sort()
ans=-1
z=[]
for i in range(1,g+1):
    if lst[i]==0:
        continue
    k=100*i
    m=bisect(data,i*e)
    if m==0:
        continue
    o=data[m-1]
    if k+o<=f:
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
    else:
        m=bisect(data,f-k)
        o=data[m-1]
        if ans<=100*o/(k+o):
            z=[k+o,o]
            ans=100*o/(k+o)
print(*z)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
t=int(input())
lcm=t
a=t
for i in range(n-1):
    t=int(input())
    a=math.gcd(lcm,t)
    lcm=lcm*t//a
print(lcm)

Fixed submission:
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    if y==1:
        return 1
    else:
        return gcd(y,x%y)
n=int(input())
t=int(input())
lcm=t
a=t
for i in range(n-1):
    t=int(input())
    a=gcd(lcm,t)
    lcm=lcm*t//a
print(lcm)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=y+x
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=y+x
    print(*z)

Fixed submission:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=[]
    y=[]
    for i in range(n):
        if i%2==1:
            y=[a[i]]+y
        else:
            x.append(a[i])
    z=y+x
    print(*z)
else:
    x=[]
    y=[]
    for i in range(n):
        if i%2==0:
            y=[a[i]]+y
        else:
            x.append(a[i])
    z=y+x
    print(*z)

Fixed submission:
from collections import deque
n=int(input())
a=list(map(int,input().split()))
if n%2==0:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==1:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
else:
    x=deque([])
    y=deque([])
    for i in range(n):
        if i%2==0:
            y.appendleft(a[i])
        else:
            x.append(a[i])
    z=[]
    for u in y:
        z.append(u)
    for u in x:
        z.append(u)
    print(*z)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]
data=[[] for i in range(n+1)]
for u in abc:
    a,b,c=u
    data[a].append([b,c])
inf=float("inf")
lst=[-inf]*(n+1)
lst[1]=0
que=[1]
count=0
z=0
a,b,c,d=-inf,-inf,-inf,-inf
while que:
    h=[]
    for u in que:
        for v in data[u]:
            w,c=v
            lst[w]=max(lst[w],lst[u]+c)
            h.append(w)
    que=h
    count+=1
    if count==m:
        a=lst[n]
    if count==2*m+5:
        b=lst[n]
        break
    if len(que)>n:
        c=lst[n]
        z=10
    if z>=10:
        z+=1
        if z==15:
            d=lst[n]
            break
else:
    print(lst[n])
    sys.exit()
if b>a or d>c:
    print("inf")
else:
    print(lst[n])

Fixed submission:
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

inf=float("inf")
data=[-inf]*(n+1)
data[1]=0
for i in range(n):
    for a,b,c in abc:
        if data[a]!=inf:
            data[b]=max(data[b],data[a]+c)

lst=data[:]
for i in range(n):
    for a,b,c in abc:
        if data[a]!=inf:
            data[b]=max(data[b],data[a]+c)

que=[]
for i in range(1,n+1):
    if lst[i]!=data[i]:
        que.append(i)
        
flag=[0]*(n+1)
for u in que:
    flag[u]=1

li=[[] for i in range(n+1)]
for a,b,c in abc:
    li[a].append(b)

while que:
    h=que.pop()
    for u in li[h]:
        if flag[u]==0:
            flag[u]=1
            que.append(u)

if flag[n]==1:
    print("inf")
else:
    print(data[n])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]
data=[[] for i in range(n+1)]
for u in abc:
    a,b,c=u
    data[a].append([b,c])
inf=float("inf")
lst=[-inf]*(n+1)
lst[1]=0
que=[1]
count=0
while que:
    h=[]
    for u in que:
        for v in data[u]:
            w,c=v
            lst[w]=max(lst[w],lst[u]+c)
            h.append(w)
    que=h
    count+=1
    if count==m:
        a=lst[n]
    if count==2*m+5:
        b=lst[n]
        break
else:
    print(lst[n])
    sys.exit()
if b>a:
    print("inf")
else:
    print(lst[n])

Fixed submission:
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for i in range(m)]

inf=float("inf")
data=[-inf]*(n+1)
data[1]=0
for i in range(n):
    for a,b,c in abc:
        if data[a]!=inf:
            data[b]=max(data[b],data[a]+c)

lst=data[:]
for i in range(n):
    for a,b,c in abc:
        if data[a]!=inf:
            data[b]=max(data[b],data[a]+c)

que=[]
for i in range(1,n+1):
    if lst[i]!=data[i]:
        que.append(i)
        
flag=[0]*(n+1)
for u in que:
    flag[u]=1

li=[[] for i in range(n+1)]
for a,b,c in abc:
    li[a].append(b)

while que:
    h=que.pop()
    for u in li[h]:
        if flag[u]==0:
            flag[u]=1
            que.append(u)

if flag[n]==1:
    print("inf")
else:
    print(data[n])
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
    ans+=v[i]
ans/=a
k=a-1
count=1
while k<=n-2:
    if v[k]==v[k+1]:
        count+=1
        k+=1
        continue
    else:
        break
k=a-1
cnt=1
while k>=1:
    if v[k]==v[k-1]:
        count+=1
        cnt+=1
        k-=1
        continue
    else:
        break
print(ans)

l=n
for i in range(1,n):
    if v[i]==v[0]:
        continue
    else:
        l=i
        break
        
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
print(l)
if l<a:
    print(cmb(count,cnt))
if a<=l<=b:
    x=0
    for i in range(a,l+1):
        x+=cmb(l,i)
    print(x)
else:
    x=0
    for i in range(a,b+1):
        x+=cmb(l,i)
    print(x)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
    ans+=v[i]
ans/=a
print(ans)
if v[0]==v[a-1]:
    count=0
    for i in range(n):
        if v[i]==v[0]:
            count+=1
    cnt=0
    for i in range(a,min(b,count)+1):
        cnt+=cmb(count,i)
    print(cnt)
else:
    count=0
    for i in range(n):
        if v[i]==v[a-1]:
            count+=1
    for i in range(n):
        if v[i]==v[a-1]:
            l=i
            break
    cnt=cmb(count,a-l)
    print(cnt)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)

ans=[0]*N

kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i][0]
    while kkk<N and B[kkk]>=zzz:
        kkk+=1
        
    ans[data[i][1]]=(zzz-data[i-1][0])*kkk
    cnt+=1
ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)

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

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)
C=[0]*N
C[0]=B[0]
for i in range(1,N):
    C[i]=C[i-1]+B[i]
    
    
ans=[0]*N
cnt=0
kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i-1][0]
    while kkk<N and B[kkk]>zzz:
        kkk+=1
    num=C[kkk-1]-kkk*zzz
    num-=cnt
    ans[data[i][1]]=num
    cnt+=num

ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)
Buggy python submission (verdict: Runtime Error):
s=input()
s=s.replace("dream","D")
s=s.replace("erase","E")
n=len(s)
i=0
while i<n:
    if s[i]=="D":
        if i+2<n:
            if s[i:i+3]=="Der":
                i+=3
            else:
                i+=1
        else:
            i+=1
    elif s[i]=="E":
        if i+1<n:
            if s[i:i+2]=="Er":
                i+=2
            else:
                i+=1
        else:
            i+=1
    else:
        break
else:
    print("YES")
    sys.exit()
print("NO")

Fixed submission:
s=input()
s=s.replace("dream","D")
s=s.replace("erase","E")
s=s.replace("Der","M")
s=s.replace("Er","M")
s=s.replace("D","M")
s=s.replace("E","M")
s=s.replace("M","")
if s:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ta=[list(map(int,input().split())) for i in range(n)]
t=ta[0][0]
a=ta[0][1]
for i in range(1,n):
    T,A=ta[i]
    s,b=T,A
    while T<t or A<a:
        T+=s
        A+=b
    t,a=T,A
print(t+a)

Fixed submission:
n=int(input())
ta=[list(map(int,input().split())) for i in range(n)]
T=ta[0][0]
A=ta[0][1]
for i in range(1,n):
    t,a=ta[i]
    if T%t==0:
        s=T//t
    else:
        s=T//t+1
    if A%a==0:
        b=A//a
    else:
        b=A//a+1
    T=t*max(s,b)
    A=a*max(s,b)
print(T+A)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n,a=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]-=a
    
left=x[:n//2]
l=len(left)
right=x[n//2:]
r=len(right)

data_left=Counter()
data_right=Counter()

for i in range(1,2**l):
    num=0
    for j in range(l):
        if (i>>j)&1==1:
            num+=left[j]
    data_left[-num]+=1

for i in range(1,2**r):
    num=0
    for j in range(r):
        if (i>>j)&1==1:
            num+=right[j]
    data_right[num]+=1

ans=data_left[0]+data_right[0]
for u,v in data_left.items():
    ans+=data_right[u]*v
    
print(ans)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]-=a
    
dp=[0]*(2*n*50+2)
dp[0]=1
for i in range(n):
    h=dp[:]
    for j in range(-(n-1)*50,(n-1)*50+1):
        h[j]+=dp[j-x[i]]
    dp=h
print(dp[0]-1)

Buggy python submission (verdict: Time Limit Exceeded):
n,a=map(int,input().split())
x=list(map(int,input().split()))

ans=0

for i in range(1,2**n):
    count=0
    num=0
    for j in range(n):
        if (i>>j)&1==1:
            count+=1
            num+=x[j]
    if num%count==0 and num//count==a:
        ans+=1

print(ans)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))

for i in range(n):
    x[i]-=a
    
dp=[0]*(2*n*50+2)
dp[0]=1
for i in range(n):
    h=dp[:]
    for j in range(-(n-1)*50,(n-1)*50+1):
        h[j]+=dp[j-x[i]]
    dp=h
print(dp[0]-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def isTriangular(n):
    i = 1
    while( (i*(i+1))//2 <= n) :
        if (i*(i+1))//2 == n:
            return True
        i+=1
    return False


def solve(n):
    if not isTriangular(n):
        print("No")
        return
    i = 1
    jump = 2
    ans = [[1],[1]]
    while ans[-1][-1] != n:
        next_ind = range(ans[-1][-1]+1, ans[-1][-1]+jump+1)
        for i in range(len(next_ind)):
            ans[i].append(next_ind[i])
        ans.append(next_ind)
        i+=jump
        jump += 1
    print("Yes")
    print(len(ans))
    for x in ans:
        p_str = ""
        p_str += str(len(x))
        for b in x:
            p_str += " " 
            p_str += str(b)
        print(p_str)

        

        

solve(n)

    


Fixed submission:
n = int(input())

def isTriangular(n):
    i = 1
    while( (i*(i+1))//2 <= n) :
        if (i*(i+1))//2 == n:
            return True
        i+=1
    return False


def solve(n):
    if not isTriangular(n):
        print("No")
        return
    i = 1
    jump = 2
    ans = [[1],[1]]
    while ans[-1][-1] != n:
        next_ind = list(range(ans[-1][-1]+1, ans[-1][-1]+jump+1))
        for i in range(len(next_ind)):
            ans[i].append(next_ind[i])
        ans.append(next_ind)
        i+=jump
        jump += 1
    print("Yes")
    print(len(ans))
    for x in ans:
        p_str = ""
        p_str += str(len(x))
        for b in x:
            p_str += " " 
            p_str += str(b)
        print(p_str)
solve(n)
Buggy python submission (verdict: Runtime Error):
n = int(raw_input())

if n == 1:
  print("Hello World")
elif n == 2:
  a = int(raw_input())
  b = int(raw_input())
  print(a+b)

Fixed submission:
n = int(input())
 
if n == 1:
  print("Hello World")
elif n == 2:
  a = int(input())
  b = int(input())
  print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):

s= input()
t = input()

def swap(S, a,b):
    ss = ""
    for s in S:
        if s == a:
            ss += b
        elif s == b:
            ss += a
        else:
            ss += s
    return ss
        
def solve(S,T):
    s_copy = S
    t_copy = T
    char_map = set()
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s != t:
            char_map.add((s,t))
            S = swap(S, s,t)
    return S == T


    

if solve(s,t):
    print("Yes") 
else:
    print("No")



Fixed submission:

s= input()
t = input()






def solve(S,T):
    s_map  = {}
    t_map = {}

    for s in S:
        if s in s_map:
            s_map[s] += 1
        else:
            s_map[s] = 1

    
    for t in T:
        if t in t_map:
            t_map[t] += 1
        else:
            t_map[t] = 1

    s_l = []
    t_l = []

    for sss in s_map:
        s_l.append(s_map[sss])
    for ttt in t_map:
        t_l.append(t_map[ttt])

    return sorted(s_l) == sorted(t_l)


    

if solve(s,t):
    print("Yes") 
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = input()
a = [long(x) for x in input().split(" ")]
b = [long(x) for x in input().split(" ")]

if sum(a) <= sum(b):
    print("Yes")
else:
    print("No")


Fixed submission:
n = input()
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]

negatives = 0
positives = 0

for aa, bb in zip(a,b):
    if aa - bb < 0:
        negatives += (bb-aa)//2*2
    else:
        positives += aa-bb

if negatives >= 2*positives:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())
ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)

Fixed submission:
import math

K = int(input())
ans = 0

for a in range(1, K+1):
    for b in range(1, K+1):
        tmp = math.gcd(a, b)
        for c in range(1, K+1):
            ans += math.gcd(tmp, c)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

ans = 0
while n > a+b:
    ans += a
    n -= a+b

ans += min(n, a)
print(ans)

Fixed submission:
n, a, b = map(int, input().split())

ans = n // (a+b) * a
tmp = n % (a+b)
ans += min(a, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print((a*b) // math.gcd(a, b))

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

a, b = map(int, input().split())
print((a * b) // gcd(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

ans = []
for i in range(n):
    ans.append(A.index(i+1)+1)

print(' '.join(str(a) for a in ans))

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
 
 
k = sorted(range(0,n),key=lambda x:l[x])
for i in k:
    print(i+1,end= " ")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

ans = []
for i in range(n):
    ans.append(A.index(i+1)+1)

print(' '.join(str(a) for a in ans))

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
 
 
k = sorted(range(0,n),key=lambda x:l[x])
for i in k:
    print(i+1,end= " ")
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())

correct = []
for _ in range(q):
    a = int(input())
    correct.append(a)

for i in range(1, n+1):
    if k - (q - correct.count(i)) > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())

point = [k-q] * n
for _ in range(q):
    a = int(input())
    point[a-1] += 1

for p in point:
    if p > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
height = list(map(int, input().split()))

ans = 0
left = height.pop(0)
while height != []:
    cnt = 0
    while 1:
        if height == []:
            break
        right = height.pop(0)
        if left >= right:
            cnt += 1
            left = right
        else:
            left = right
            break
    if ans < cnt:
        ans = cnt

print(cnt)

Fixed submission:
n = int(input())
height = list(map(int, input().split()))

ans = 0
cnt = 0
for i in range(n-1):
    if height[i] >= height[i+1]:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0

if cnt > ans:
    ans = cnt

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
gcd = math.gcd(c, d)
lcm = c * d / gcd

lower = (a-1) // c + (a-1) // d - (a-1) // lcm
upper = b // c + b // d - b // lcm

print(int(b - (a-1) - (upper - lower)))

Fixed submission:
a,b,c,d=map(int,input().split())
def Euclid(x,y):
    while x != 0:
        z=x
        x=y%x
        y=z
    return y
l = c*d//(Euclid(c,d))
print((b- b//c - b//d + b//l) - ((a-1)- (a-1)//c - (a-1)//d + (a-1)//l))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

lr = []
for _ in range(m):
    l, r = map(int, input().split())
    lr.append([l, r])

cnt = 0
for i in range(1, n+1):
    for l, r in lr:
        if not l <= i <= r:
            break
    else:
        cnt += 1

print(cnt)

Fixed submission:
n, m = map(int, input().split())

L, R = [], []
for _ in range(m):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

max_l = max(L)
min_r = min(R)

if max_l <= min_r:
    print(min_r - max_l + 1)
else:
    print(0)