Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()

q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    for j in range(n):
        if a[j]==bi:
            a[j]=ci
        elif a[j]>bi:
            break
    print(sum(a))
    a.sort()

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.append(0)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    t=0
    for j in range(n):
        if t==1:
            break
        else:
            d=j
            while a[d]==bi:
                a[d]=ci
                d+=1
                t=1
    print(sum(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    t=0
    for j in range(n):
        if a[j]==bi:
            a[j]=ci
            d=j+1
            while a[d]==bi:
                a[d]=ci
                d+=1
            t=1
        elif t==1:
            break
    print(sum(a))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    s=1
    for i in a:
    s=s*i
    if s>10**18:
        s=-1
        break
    print(s)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    s=1
    for i in a:
        s=s*i
        if s>10**18:
            s=-1
            break
    print(s)
Buggy python submission (verdict: Runtime Error):
a,b=map(float,input().split())
a=int(a)
b=int(b*100)
print(int(c//100))

Fixed submission:
a,b=input().split()
a=int(a)
b=int(b.replace('.',''))
print(a*b//100)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,x=map(int,input().split())
a=[]
for i in range(N):
    ai=list(map(int,input().split()))
    a.append(ai)
def cal(b):
    d=[]
    k=0
    c=0
    for i in range(M):
        d.append(0)
    for i in b:
        c+=a[i][0]
        for j in range(M):
            d[j]+=a[i][j+1]
    for i in d:
        if i<x:
            k=1
    if k==0:
        return c
    else:
        return 10000000

mini=10000000
for i in range(N):
    for j in range(i,N):
        for k in range(j,N):
            for l in range(k,N):
                for m in range(l,N):
                    for n in range(m,N):
                        for o in range(n,N):
                            for p in range(o,N):
                                for q in range(p,N):
                                    for r in range(q,N):
                                        for s in range(r,N):
                                            for t in range(s,N):
                                                b={i,j,k,l,m,n,o,p,q,r,s,t}
                                                mini=min(mini,cal(b))

if mini==10000000:
    print(-1)
else: print(mini)

Fixed submission:
#bit全探索
n,m,x=map(int,input().split())
a=[]
for i in range(n):
    ai=list(map(int,input().split()))
    a.append(ai)

#可能判定
maxi=[0 for i in range(m)]
for i in range(n):
    for j in range(m):
        maxi[j]+=a[i][j+1]
for i in range(m):
    if maxi[i]<x:
        print(-1)
        exit()

mini=100000000
#全探索
for i in range(2**n):
    d=[]
    for j in range(n):
        if((i>>j)& 1):
            d.append(j)
    b=[0 for j in range(m)]
    #得た能力
    c=0
    #お金
    for j in d:
        c+=a[j][0]
        for k in range(m):
            b[k]+=a[j][k+1]
    l=0
    for j in b:
        if j<x:
            l=1
    if l==0:
        mini=min(mini,c)

print(mini)
Buggy python submission (verdict: Runtime Error):
s=int(input())
if s=='ABC':
    print('ARC')
else: print('ABC')

Fixed submission:
s=(input())
if s=='ABC':
    print('ARC')
else: print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
a=[]
b=[]
c=0
for i in range(m):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
for i in range(len(h)):
    d=[]
    f=0
    for j in range(m):
        if a[j]==i+1:
            d.append(b[j])
    for j in range(m):
        if b[j]==i+1:
            d.append(a[j])
    for k in d:
        if h[k-1]>=h[i]:
            f+=1
    if f==0:
        c+=1
print(c)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[]
for i in range(n):
    ab.append(0)
for i in range(m):
    ai,bi=map(int,input().split())
    if h[ai-1]>=h[bi-1]:
        ab[bi-1]+=1
    if h[ai-1]<=h[bi-1]:
        ab[ai-1]+=1
print(ab.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
x=float(input())
a=float(100)
y=0
while a<x:
    a*=1.01
    a=a%1
    y+=1
print(y)

Fixed submission:
x=float(input())
a=float(100)
y=0
import math
while a<x:
    a=a*1.01
    a=math.floor(a)
    y+=1
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
else: m=[0]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))


Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n=map(int,input().split())
import math
x=b-1
m=[math.floor(a*n/b)-a*(math.floor(n/b))]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import math
a,b,n=map(int,input().split())
for x in range(n+1):
    f=math.floor(a*x/b)-a*math.floor(x/b)
    m.append(f)
print(max(m))

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n=map(int,input().split())
m=[]
for x in range(n+1):
    f=math.floor(a*x/b)-a*math.floor(x/b)
    m.append(f)
print(max(m))

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n=map(int,input().split())
m=0
for x in range(n+1):
    f=math.floor(a*x/b)-a*math.floor(x/b)
    if f>m:
        m=f
print(m)

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
mm=[]
for i in range(m):
    s=int(input())
    mm.append(s)
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)

Fixed submission:
n,m=map(int,input().split())
mm=list(map(int,input().split()))
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
l = []
for i in range(N):
    l.append(0)
for x in A:
    l(x-1) += 1
for s in l:
    print(s)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    c=0
    for e in a:
        if i+1==e:
            c+=1
    print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    c=0
    for e in a:
        if i+1==e:
            c+=1
    print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    c=0
    for e in a:
        if a(i)+1==e:
            c+=1
    print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    c=0
    for e in a:
        if i+1==e:
            c+=1
    print(c)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append(0)
for i in a:
    b[i-1]+=1
for i in b:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=[]
for i in range(n+1):
    a.append(i)
d=0
for i in range(k,n+2):
    b=sum(a[:i])
    c=sum(a[-i:])
    d+=(c-b+1)
print(d)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=[]
for i in range(0,n+1):
    a.append(10**20+i)
b=set()
for i in range(2**(n+1)):
    c=0
    d=0
    for j in range(n+1):
        if ((i>>j) & 1):
            c+=a[j]
            d+=1
    if d>=k:
        b.add(c)
print(len(b)%(10**9+7))

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=0
while k<=n+1:
    mi=0
    ma=0
    for t in range(k):
        mi+=t
        ma+=(n-t)
    a+=(ma-mi+1)
    k+=1
print(a)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=0
while k<=n+1:
    mi=0
    ma=0
    for t in range(k):
        mi+=t
        ma+=(n-t)
    a+=(ma-mi+1)
    k+=1
print(a)


Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=0
while k<=n+1:
    mi=0
    ma=0
    for t in range(k):
        mi+=t
        ma+=(n-t)
    a+=(ma-mi+1)
    k+=1
print(a)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=0
while k<=n+1:
    mi=0
    ma=0
    for t in range(k):
        mi+=t
        ma+=(n-t)
    a+=(ma-mi+1)
    k+=1
print(a)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=0
while k<=n+1:
    b=1
    s=1
    for t in range(k):
        b*=(t+1)
        s*=(n+1-t)
    a+=s/b
    k+=1
print(a)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
d=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            c=math.gcd(i,j)
            d+=math.gcd(c,l)
print(d)



Fixed submission:
import math
k=int(input())
d=0
for i in range(1,k+1):
    for j in range(i+1,k+1):
        for l in range(j+1,k+1):
            c=math.gcd(i,j)
            d+=6*(math.gcd(c,l))
for i in range(1,k+1):
    for j in range(i+1,k+1):
        d+=6*(math.gcd(i,j))
for i in range(1,k+1):
    d+=i
print(d)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=-1
for i in range(101):
    if int(i*/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)

Fixed submission:
a,b=map(int,input().split())
ans=-1
for i in range(1300):
    if int(i*2/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ans=n
for i in range(1,n):
    for j in range(i):
        if p[j]<p[i]:
            ans-=1
            break
print(ans)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
mini=p[0]
ans=0
for i in range(n):
    if p[i]<=mini:
        ans+=1
        mini=min(p[i],mini)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s,p,r=map(int,input().split())
f={'s':s,'p':p,'r':r}
t=str(input())
ans=0
for i in range(k):
  a=i+k
  last=t[i]
  ans+=f[last]
  while a<n-k:
    if t[a-k]==last:
      if t[a+k]==last:
        if last=='s':
          last='r'
        else:
          last='s'
      else:
        if last=='s':
          if t[a+k]=='r':
            last='p'
          else:
            last='r'
        elif last=='r':
          if t[a+k]=='s':
            last='p'
          else:
            last='s'
        else:
          if 
            

      
      
      
      
      






Fixed submission:
#abc149-d
n,k=map(int,input().split())
s,p,r=map(int,input().split())
f={'s':s,'p':p,'r':r}
t=str(input())
ans=0
for i in range(k):
    a=i+k
    last=t[i]
    ans+=f[last]
    while a<n-k:
        if t[a]==last:
            if t[a+k]==last:
                if last=='s':
                    last='r'
                else:
                    last='s'
            else:
                if last=='s':
                    if t[a+k]=='r':
                        last='p'
                    else:
                        last='r'
                elif last=='r':
                    if t[a+k]=='s':
                        last='p'
                    else:
                        last='s'
                else:
                    if t[a+k]=='r':
                        last='s'
                    else:
                        last='r'
        else:
            last=t[a]
            ans+=f[last]
        a+=k
    
    if a<n:
        if t[a]!=last:
            ans+=f[t[a]]

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t=h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(math.gcd(l[i-1],a[i]))
    r.append(math.gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,math.gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(gcd(l[i-1],a[i]))
    r.append(gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=str(input())
a=[]
for i in range(n-1):
    if s[i]=='A' and s[i+1]=='C':
        a.append(1)
    else:
        a.append(0)
        
for i in range(q):
    ans=0
    li,ri=map(int,input().split())
    for j in range(li-1,ri-1):
        ans+=a[j]
    print(ans)

Fixed submission:
n,q=map(int,input().split())
s=str(input())
a=[0]
a*=n
for i in range(n-1):
    if s[i]=='A' and s[i+1]=='C':
        a[i+1]=a[i]+1
    else:
        a[i+1]=a[i]
#最初に余分な0が一つ入っているため番号はそのまま        
for i in range(q):
    li,ri=map(int,input().split())
    ans=a[ri-1]-a[li-1]
    print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,-1,-1):
    t=1
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
hm=max(h)
t=1
ans=0
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
ans=0
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
for i in range(hm,-1,-1):
    for j in range(n)
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
p=[]
pp=[1]
pp*=n
ans=[]
for i in range(n):
    p.append([])
for i in range(m):
    pi,yi=map(int,input().split())
    p[pi-1].append([yi,pp[pi-1]])
    ans.append([pi-1,pp[pi-1]])
    pp[pi-1]+=1
for i in range(n):
    p[i].sort()
for i in range(m):
    b=len(p[ans[i][0]])
    for j in range(b):
        if ans[i][1]==p[ans[i][0]][j][1]:
            print('{0:06d}{1:06d}'.format(ans[i][0]+1,j+1))
            break

Fixed submission:
from operator import itemgetter
n,m=map(int,input().split())
a=[]
for i in range(m):
    pi,yi=map(int,input().split())
    a.append([i,pi,yi])
b=[]
c=[]
for i in range(n):
    b.append([])
    c.append([])
for i in range(m):
    x=a[i][0]
    y=a[i][2]
    b[a[i][1]-1].append([x,y])

for i in range(n):
    b[i].sort(key=itemgetter(1))
    l=len(b[i])
    for j in range(l):
        a[b[i][j][0]].append(j+1)
for i in range(m):
    xi=a[i][1]
    yi=a[i][3]
    print('{0:06d}{1:06d}'.format(xi,yi))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=[]
pp=[1]
pp*=n
ans=[]
for i in range(n):
    p.append([])
for i in range(m):
    pi,yi=map(int,input().split())
    p[pi-1].append([yi,pp[pi-1]])
    ans.append([pi-1,pp[pi-1]])
    pp[pi-1]+=1
    print(p)
for i in range(n):
    p[i].sort()
for i in range(m):
    b=len(p[ans[i][0]])
    for j in range(b):
        if ans[i][1]==p[ans[i][0]][j][1]:
            print('{0:06d}{1:06d}'.format(ans[i][0]+1,j+1))
            break

Fixed submission:
from operator import itemgetter
n,m=map(int,input().split())
a=[]
for i in range(m):
    pi,yi=map(int,input().split())
    a.append([i,pi,yi])
b=[]
c=[]
for i in range(n):
    b.append([])
    c.append([])
for i in range(m):
    x=a[i][0]
    y=a[i][2]
    b[a[i][1]-1].append([x,y])

for i in range(n):
    b[i].sort(key=itemgetter(1))
    l=len(b[i])
    for j in range(l):
        a[b[i][j][0]].append(j+1)
for i in range(m):
    xi=a[i][1]
    yi=a[i][3]
    print('{0:06d}{1:06d}'.format(xi,yi))