Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import heapq
n,m=map(int,input().split())
a=heapq.heapify(list(map(lambda x: int(x)*(-1),input().split())))
while m>0 and sum(a)>0:
  heapq.heappush(a,int(heapq.heappop(a)//2))
  m=m-1
a=list(map(lambda x: int(x)*(-1),a))
print(sum(a))


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
while m>0 and sum(a)>0:
  a[a.index(max(a))]=int(max(a)//2)
  m=m-1
print(sum(a))


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
while m>0 and sum(a)>=0:
  a[a.index(max(a))]=int(max(a)//2)
  m=m-1
print(sum(a))


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
while m>0:
  a[a.index(max(a))]=int(max(a)//2)
  m=m-1
print(sum(a))

Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))

Buggy python submission (verdict: Runtime Error):
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
while m>0:
  a[index(max(a))]=int(math.foor(max(a)/2))
  m=m-1
print(sum(a))

Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
while m>0:
  heapq.heappush(a,(-1)*int((-1)*heapq.heappop(a)//2))
  m=m-1

print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=b[a[0]]
for i in range(1,n):
  if a[i]==a[i-1]+1:
    s+=b[a[i]-1]+c[a[i-1]-1]
  else:
    s+=b[a[i]-1]
print(s)

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

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=b[a[0]-1]
for i in range(1,n):
  if a[i]==a[i-1]+1:
    s+=b[a[i]-1]+c[a[i-1]-1]
  else:
    s+=b[a[i]-1]
print(s)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
cnt=0
for i in range(3):
  if s[i]=t[i]:
    cnt+=1
print(cnt)

Fixed submission:
s=input()
t=input()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=(n-1)*n/2
print(int(a))


Fixed submission:
s=input()
t=input()
cnt=0
for i in range(3):
  if s[i]==t[i]:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
if n==1:
  print(0)
elif n==2:
  print(1)
else:
  for i in range(1,n):
    a+=(n-i)
  print(a)


Fixed submission:
n=int(input())
a=(n-1)*n//2
print(int(a))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
if n==1:
  print(0)
elif n==2:
  print(1)
else:
  for i in range(1,n):
    a+=(n-i)
  print(a)


Fixed submission:
n=int(input())
a=(n-1)*n//2
print(int(a))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(a):
  s+=1/i
print(1/s)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=0
for i in a:
  s+=1/i
print(1/s)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for i in range(1,n+1)]
dic={}
l=list()
cnt=0
for i in range(n):
  s[i].sort()
  s=''.join(s[i])
  l.append(s)
  if l[i] in dic:
    cnt+=1
  else:
    dict[l[i]]=1
print(cnt)

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
dic={}
l=list()
cnt=0
for i in range(n):
  k=sorted(s[i])
  t=''.join(k)
  l.append(t)
  if l[i] in dic:
    dic[l[i]]+=1
  else:
    dic[l[i]]=0
c=list(dic.values())
for i in range(len(c)):
   cnt+=c[i]*(c[i]+1)//2
print(cnt)
Buggy python submission (verdict: Runtime Error):
import heapq
n,m=map(int,input().split())
ab=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    ab[a-1].append(-b)
l=[]
heapq.heapify(l)
ans=0
for i in range(m):
  for j in ab[i]:
    heapq.heappush(l,j)
  if l:
    print(l)
    ans+=-heapq.heappop(l)
print(ans)

Fixed submission:
import heapq
n,m=map(int,input().split())
lis=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a-1<m:
    lis[a-1].append(-b)
l=list()
v=0
for i in range(m):
  for j in lis[i]:
    heapq.heappush(l,j)
  if l:
    v+=heapq.heappop(l)*(-1)
print(v)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,m=map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
l=list()
v=0
heapq.heapify(l)
for i in range(1,m+1):
  for j in range(n):
    if c[j][0]==i:
      heapq.heappush(l,(-1)*c[j][1])
  if l:
    v+=heapq.heappop(l)*(-1)
print(v)

Fixed submission:
import heapq
n,m=map(int,input().split())
lis=[[] for i in range(m)]
for i in range(n):
  a,b=map(int,input().split())
  if a-1<m:
    lis[a-1].append(-b)
l=list()
v=0
for i in range(m):
  for j in lis[i]:
    heapq.heappush(l,j)
  if l:
    v+=heapq.heappop(l)*(-1)
print(v)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (a+b)%==0:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')

Fixed submission:
a,b=map(int,input().split())
if (a+b)%2==0:
  print((a+b)//2)
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n=int(input())
a=[-int(input()) for i in range(n)]
for i in range(n):
  x=a[:i]+a[i+1:]
  heapq.heapify(x)
  print(-heapq.heappop(x))

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  x=a[:i]+a[i+1:]
  print(max(x))

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
for i in range(n):
  x=a[i]
  a[i]=0
  print(max(a))
  a[i]=x

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
b=[a[i] for i in range(n)]
b.sort()
m=b[n-1]
m2=b[n-2]
for i in range(n):
  if a[i]==m:
    print(m2)
  else:
    print(m)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
box=[0]*n
for i in range(n):
  baisu=n%(n-i)
  if baisu==1:
    box[n-i-1]=a[n-i-1]
  else:
    cnt=0
    for j in range(2,baisu+1):
      cnt+=box[(n-i-1)*j]
    if cnt%2!=a[n-i-1]:
      box[n-i-1]=1
print(sum(box))
if sum(box)!=0:
  for i in range(n):
    if box[i]==1:
      print(i+1,end=' ')


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

#箱の状態を記録しておく配列
box=[0]*n


for i in range(n):
  num=n-i

  #まず割って、その数より大きい倍数がいくつあるか探る
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  #1～baisu倍の箱の状態を調べる。
  temp=0
  for j in range(2,baisu+1):
    temp+=box[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for a in range(1):
    for b in range(a+1,n):
        ans.append([a+1,b+1])
  i,j,cnt=2,3,0
  while cnt<((n-2)*(n-1))//2-k:
    while j<=n:
      ans.append([i,j])
      j+=1
      cnt+=1
      if cnt==((n-2)*(n-1))//2-k:
        break
    i+=1
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Fixed submission:
s=input()
for i in range(3):
  if s[i]==s[i+1]:
    print('Bad')
    exit()
print('Good')

Buggy python submission (verdict: Runtime Error):
import fractions
a,b,c,d=map(int,input().split())
print(b-a+1-(b//c-(a-1)//c+b//d-(a-1)//d-b//(c*d/fractions.gcd(c,d))+(a-1)//(c*d/fractions.gcd(c,d))))


Fixed submission:
s=input()
for i in range(3):
  if s[i]==s[i+1]:
    print('Bad')
    exit()
print('Good')

Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(3):
  if s[i]=s[i+1]:
    print('Bad')
    exit()
print('Good')

Fixed submission:
s=input()
for i in range(3):
  if s[i]==s[i+1]:
    print('Bad')
    exit()
print('Good')
Buggy python submission (verdict: Runtime Error):
import fraction
a,b,c,d=map(int,input().split())
print(b-a+1-(b//c-(a-1)//c+b//d-(a-1)//d-b//(c*d/fraction.gcd(c,d))+(a-1)//(c*d/fraction.gcd(c,d))))

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
print(b-a+1-(b//c-(a-1)//c+b//d-(a-1)//d-b//int((c*d/fractions.gcd(c,d)))+(a-1)//int((c*d/fractions.gcd(c,d)))))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  i,j,cnt=2,3,0
  while cnt<((n-2)*(n-1))//2-k:
    while j<=n:
      ans.append((i,j))
      j+=1
      cnt+=1
      if cnt==((n-2)*(n-1))//2-k:
        break
    i+=1
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Fixed submission:
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  s=[]
  for i in range(1,n-1):
    for j in range(i+1,n):
      s.append((i+1,j+1))
  for i in range(((n-2)*(n-1))//2-k):
    ans.append((s[i][0],s[i][1]))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  i,j,cnt=2,3,0
  while cnt<((n-2)*(n-1))//2-k:
    while j<=n:
      ans.append((i,j))
      j+=1
      cnt+=1
      if cnt==((n-2)*(n-1))//2-k:
        break
    i+=1
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Fixed submission:
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  s=[]
  for i in range(1,n-1):
    for j in range(i+1,n):
      s.append((i+1,j+1))
  for i in range(((n-2)*(n-1))//2-k):
    ans.append((s[i][0],s[i][1]))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for a in range(1):
    for b in range(a+1,n):
        ans.append([a+1,b+1])
  i,j,cnt=2,3,0
  while cnt<((n-2)*(n-1))//2-k:
    while j<=n:
      ans.append([i,j])
      j+=1
      cnt+=1
      if cnt==((n-2)*(n-1))//2-k:
        break
    i+=1
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Fixed submission:
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  s=[]
  for i in range(1,n-1):
    for j in range(i+1,n):
      s.append((i+1,j+1))
  for i in range(((n-2)*(n-1))//2-k):
    ans.append((s[i][0],s[i][1]))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for a in range(1):
    for b in range(a+1,n):
        ans.append([a+1,b+1])
  i,j,cnt=2,3,0
  while cnt<((n-2)*(n-1))//2-k:
    while j<=n:
      ans.append([i,j])
      j+=1
      cnt+=1
      if cnt==((n-2)*(n-1))//2-k:
        break
    i+=1
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Fixed submission:
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  s=[]
  for i in range(1,n-1):
    for j in range(i+1,n):
      s.append((i+1,j+1))
  for i in range(((n-2)*(n-1))//2-k):
    ans.append((s[i][0],s[i][1]))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[input() for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
for i in range(h):
  if s[i][0]=='.':
    l[i][0]=1
  if s[i][w-1]=='.':
    r[i][w-1]=1
for i in range(w):
  if s[0][i]=='.':
    u[0][i]=1
  if s[h-1][i]=='.':
    d[h-1][i]=1
for i in range(h):
  for j in range(w):
    if j>=1:
      if s[i][j]=='.':
        l[i][j]=l[i][j-1]+1
    if j<w-1:
      if s[i][w-j-2]=='.':
        r[i][w-j-2]=r[i][w-j-1]+1
    if i>=1:
      if s[i][j]=='.':
        u[i][j]=u[i-1][j]+1
    if i<h-1:
      if s[h-i-2][j]=='.':
        d[h-i-2][j]=d[h-i-1][j]+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)

Fixed submission:
h,w=map(int,input().split())
s=[input() for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
for i in range(h):
  if s[i][0]=='.':
    l[i][0]=1
  if s[i][w-1]=='.':
    r[i][w-1]=1
for i in range(w):
  if s[0][i]=='.':
    u[0][i]=1
  if s[h-1][i]=='.':
    d[h-1][i]=1
for i in range(h):
  for j in range(w):
    if j>=1:
      if s[i][j]=='.':
        l[i][j]=l[i][j-1]+1
    if j<w-1:
      if s[i][w-j-2]=='.':
        r[i][w-j-2]=r[i][w-j-1]+1
    if i>=1:
      if s[i][j]=='.':
        u[i][j]=u[i-1][j]+1
    if i<h-1:
      if s[h-i-2][j]=='.':
        d[h-i-2][j]=d[h-i-1][j]+1
ans=0
for i in range(h):
  for j in range(w):
    ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3)
print(ans)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
n=int(input())
l=[map(int,input().split()) for i in range(n)]
for i in range(n):
  l[i].append(i+1)
l2=sorted(l)
l3=sorted(l2,key=itemgetter(1),reverse=True)
for i in range(n):
  print(l3[i][2])

Fixed submission:
from operator import itemgetter
n=int(input())
l=[[] for i in range(n)]
for i in range(n):
  s,p=input().split()
  l[i].append(s)
  l[i].append(int(p))
  l[i].append(i+1)
l2=sorted(l,key=itemgetter(1),reverse=True)
l3=sorted(l2,key=itemgetter(0))
for i in range(n):
  print(l3[i][2])
Buggy python submission (verdict: Runtime Error):
s=input()
sf=int(s[:2])
sl=int(s[2:4])
if sf>=13 or sl<=12 and sl>0:
  print('YYMM')
elif 12>=sf>0 and sl==0:
  print('MMYY')
elif sf>12 and sl=0 or sf=0 and sl>12:
  print('AMBIGUOUS')
else:
  print('NA')

Fixed submission:
s=input()
sf=int(s[:2])
sl=int(s[2:4])
if sf>=13 and 13>sl>0 or sf==0 and 13>sl>0:
  print('YYMM')
elif 12>=sf>0 and sl==0 or 13>sf>0 and sl>=13:
  print('MMYY')
elif 13>sf>0 and 13>sl>0 or 13>sf>0 and 13>sl>0:
  print('AMBIGUOUS')
else:
  print('NA')
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
l=n//min(r,g,b)
ans=0
for i in range(l+1):
  for j in range(l+1):
      if n-(i*r+j*g)>=0 and (n-(i*r+j*g))%b==0:
        ans+=1
print(ans)


Fixed submission:
r,g,b,n=map(int,input().split())
l=n//min(r,g,b)
ans=0
for i in range(l+1):
  for j in range(l+1):
      if n-(i*r+j*g)>=0 and (n-(i*r+j*g))%b==0:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
v=list(map(int,input().split()))
c=list(map(int,input().split()))
cnt=0
for i in range(n):
  if v[i]-c[i]>0:
    cnt+=v[i]-c[i]
print(cnt)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
cnt=0
for i in range(n):
  if v[i]-c[i]>0:
    cnt+=v[i]-c[i]
print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a<c<b or b<c<a
  print('Yes')
else:
  print('No')


Fixed submission:
a,b,c=map(int,input().split())
if a<c<b or b<c<a:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
s_=str()
for i in range(n):
  if s[i]!=s[k+1]:
    s_+='*'
  else:
    s_+=s[i]

Fixed submission:
n=int(input())
s=input()
k=int(input())
s_=str()
for i in range(n):
  if s[i]!=s[k-1]:
    s_+='*'
  else:
    s_+=s[i]
print(s_)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
l=list()
if '#' in s:
  for i in range(n):
    if s[i]=='#':
      l.append(i)
  for i in range(len(l)-1):
    if l[i+1]-l[i]>=2:
      cnt=l[i+1]
  if (cnt-l[0]+1)//2>l.index(cnt)+1:
    print(l.index(cnt)+1)
  else:
    print(cnt-l[0]-l.index(cnt))
else:
  print(0)

Fixed submission:
n=int(input())
s=input()
accum=[0]*n
if s[0]=="#":
    accum[0]=1
for i in range(n-1):
    accum[i+1]+=accum[i]+(s[i+1]=="#")
accum=[0]+accum
ans=10**18
for i in range(n+1):
    ans=min(ans,accum[i]+n-i-accum[n]+accum[i])
#print(accum)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
w=str()
b=str()
cnt1=0
cnt2=0
for i in range(n):
    if i%2==0:
        w+='1'
        b+='0'
    else:
        w+='0'
        b+='1'
for i in range(n):
    if s[i]!=w[i]:
        cnt1+=1
    if s[i]!=b[i]:
        cnt2+=1
print(min(cnt1,cnt2))

Fixed submission:
s=input()
w=str()
b=str()
cnt1=0
cnt2=0
for i in range(len(s)):
    if i%2==0:
        w+='1'
        b+='0'
    else:
        w+='0'
        b+='1'
for i in range(len(s)):
    if s[i]!=w[i]:
        cnt1+=1
    if s[i]!=b[i]:
        cnt2+=1
print(min(cnt1,cnt2))
Buggy python submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(n-1):
  for j in range(1,n):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay')

Fixed submission:
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(4):
  for j in range(1,5):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay!')

Buggy python submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(n-4):
  for j in range(1,n):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay')

Fixed submission:
a=[int(input()) for i in range(5)]
k=int(input())
for i in range(4):
  for j in range(1,5):
    if abs(a[i]-a[j])>k:
      print(':(')
      exit()
print('Yay!')
Buggy python submission (verdict: Runtime Error):
lis=[]
for i in range(5):
    x=int(input())
    lis.append([x%10,x])
lis.sort()
t=0
for i in range(4):
    t+=lis[i,1]+10-lis[i,0]
print(t+lis[4,1])

Fixed submission:
lis=[]
for i in range(5):
    x=int(input())
    if x%10!=0:
        lis.append([x%10,x])
    else:
        lis.append([10,x])
lis1=sorted(lis,reverse=True)
t=0
for i in range(4):
    if lis1[i][0]!=0:
        t+=lis1[i][1]+10-lis1[i][0]
    else:
        t+=lis1[i][1]
print(t+lis1[4][1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(5):
  x.append(int(input()))
a=max(x)
print(n//a+5)


Fixed submission:
import math
n=int(input())
x=[]
for i in range(5):
  x.append(int(input()))
a=min(x)
print(math.ceil(n/a)+4)

Buggy python submission (verdict: Runtime Error):
n=int(lnput())
for i in range(5):
  x.append(int(input()))
a=max(x)
print(n//a+5)

Fixed submission:
import math
n=int(input())
x=[]
for i in range(5):
  x.append(int(input()))
a=min(x)
print(math.ceil(n/a)+4)
Buggy python submission (verdict: Runtime Error):
s=input()
cnt=0
lis=[]
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    cnt+=1
  else:
    lis.append(cnt)
    cnt=0
print(max(lis))

Fixed submission:
s=input()
cnt=0
t=0
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    t+=1
    cnt=max(t,cnt)
  else:
    t=0
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  print((len(s[lis[i][0]-1:lis[i][1]])-len(s[lis[i][0]-1:lis[i][1]].replace('AC','')))//2)

Fixed submission:
n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
g=[0]*n
cnt=0
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    cnt+=1
    g[i+1]=cnt
  else:
    g[i+1]=cnt

for i in range(q):
  print(g[lis[i][1]-1]-g[lis[i][0]-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
for i in range(q):
  print((len(s[lis[i][0]-1:lis[i][1]])-s[lis[i][0]-1:lis[i][1]].replace('AC',''))//2)

Fixed submission:
n,q=map(int,input().split())
s=input()
lis=[list(map(int,input().split())) for i in range(q)]
g=[0]*n
cnt=0
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    cnt+=1
    g[i+1]=cnt
  else:
    g[i+1]=cnt

for i in range(q):
  print(g[lis[i][1]-1]-g[lis[i][0]-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  if a[i][1]=='BTC':
    ans+=380000*a[i][0]
  else:
    ans+=a[i][0]
print(ans)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  x,v=input().split()
  a.append([x,v])
ans=0
for i in range(n):
  if a[i][1]=='BTC':
    ans+=380000*float(a[i][0])
  else:
    ans+=int(a[i][0])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
  b=list(map(int,input().split()))
  k.append(b[0])
  a.append(b[1:])
d={}
for i in range(n):
  for j in range(k[i]):
    if a[i][j] not in d:
      d[a[i][j]]=1
    else:
      d[a[i][j]]+=1
nd=list(d.values())
cnt=0
for i in range(len(nd)):
  if nd[i]==n:
    cnt+=1
print(cnt

Fixed submission:
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
  b=list(map(int,input().split()))
  k.append(b[0])
  a.append(b[1:])
d={}
for i in range(n):
  for j in range(k[i]):
    if a[i][j] not in d:
      d[a[i][j]]=1
    else:
      d[a[i][j]]+=1
nd=list(d.values())
cnt=0
for i in range(len(nd)):
  if nd[i]==n:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import heapq
n,k=map(int,input().split())
kind=[0]*n
s=set()
dt=[]
ans=0
for _ in range(n):
    t,d=map(int,input().split())
    ans+=d
    t-=1
    dt.append((d,t))
    s.add(t)
    kind[t]+=1
x=len(s)
ans+=x**2
sing,comp=[],[]
for d,t in dt:
    if kind[t]==1:
        heapq.heappush(sing,(d,t))
    elif kind[t]>=2:
        heapq.heappush(comp,(d,t))
for _ in range(n-k):
    ds,ts=heapq.heappop(sing)
    dc,tc=heapq.heappop(comp)
    if ds+x**2-(x-1)**2>dc:
        ans-=dc
        kind[tc]-=1
        if kind[tc]>=2:
            heapq.heappush(comp,(dc,tc))
        else:
            heapq.heappush(sing,(dc,tc))
        heapq.heappush(sing,(ds,ts))
    else:
        ans-=ds+x**2-(x-1)**2
        x-=1
        kind[ts]-=1
        heapq.heappush(comp,(dc,tc))
print(ans)

Fixed submission:
from operator import itemgetter
n,k=map(int,input().split())
td=[list(map(int,input().split())) for _ in range(n)]
td.sort(key=itemgetter(1),reverse=True)
ans=0
kind=0
flg=[False]*n
sing,comp=[],[]
for i in range(n):
    t,d=td[i]
    t-=1
    if i<k:
        ans+=d
        if flg[t]:
            comp.append(d)
        else:
            flg[t]=True
            kind+=1
    else:
        if not flg[t]:
            sing.append(d)
            flg[t]=True
comp=comp[::-1]
cnt=ans
ans+=kind**2
#print(comp)
#print(sing)
if len(comp)>len(sing):
    for i in range(len(sing)):
        dc,ds=comp[i],sing[i]
        cnt+=ds-dc
        kind+=1
        ans=max(ans,cnt+kind**2)
else:
    for i in range(len(comp)):
        dc,ds=comp[i],sing[i]
        cnt+=ds-dc
        kind+=1
        ans=max(ans,cnt+kind**2)
print(ans)