Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S=input()

ans_lst=[]
ans=0
for s in S:
    if s in ['A','C','G','T']:
        ans+=1
    else:
        ans_lst.append(ans)
        ans=0

print(max(ans_lst))

Fixed submission:
S=input()

ans_lst=[0]*len(S)
l=['A','C','G','T']
if S[0] in l:
    ans_lst[0]=1

for i in range(1,len(S)):
    if S[i] in l:
        ans_lst[i]=ans_lst[i-1]+1

print(max(ans_lst))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
for _ in range(Q):
    l,r=map(int,input().split())
    lr_S=S[l-1:r]
    n=r-l
    ans=0
    for i in range(n):
        if lr_S[i]=='A':
            if lr_S[i+1]=='C':
                ans+=1
    print(ans)

Fixed submission:
N,Q=map(int,input().split())
S=input()
AC=[0]*N

cnt=0
for i in range(N-1):
    if S[i]+S[i+1]=='AC':
        AC[i]=cnt
        cnt+=1
        AC[i+1]=cnt
    else:
        AC[i],AC[i+1]=cnt,cnt

for _ in range(Q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
AC=[]
for i in range(N):
    if S[i]=='A' and i<N-1:
        if S[i+1]=='C':
            AC.append(i)

for _ in range(Q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    ans=0
    for ac in AC:
        if l<=ac<r:
            ans+=1
        if ac>=r:
            break
    print(ans)

Fixed submission:
N,Q=map(int,input().split())
S=input()
AC=[0]*N

cnt=0
for i in range(N-1):
    if S[i]+S[i+1]=='AC':
        AC[i]=cnt
        cnt+=1
        AC[i+1]=cnt
    else:
        AC[i],AC[i+1]=cnt,cnt

for _ in range(Q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
for _ in range(Q):
    l,r=map(int,input().split())
    print(S[l-1:r].count('AC'))


Fixed submission:
N,Q=map(int,input().split())
S=input()
AC=[0]*N

cnt=0
for i in range(N-1):
    if S[i]+S[i+1]=='AC':
        AC[i]=cnt
        cnt+=1
        AC[i+1]=cnt
    else:
        AC[i],AC[i+1]=cnt,cnt

for _ in range(Q):
    l,r=map(int,input().split())
    print(AC[r-1]-AC[l-1])
Buggy python submission (verdict: Runtime Error):
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
H=list(map(int,read_().split()))

dp=[10**4+1]*N

def f(i):
    if dp[i]<10**4+1: 
        return dp[i]
    if i==0: 
        return 0
    res=10**4+1
    res=min(res,f(i-1)+abs(H[i]-H[i-1]))
    if i>1: res=min(res,f(i-2)+abs(H[i]-H[i-2]))
    dp[i]=res
    return dp[i]

print(f(N-1))

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

dp=[0]*N

dp[1]=abs(H[0]-H[1])

for i in range(2,N):
    a,b=dp[i-1]+abs(H[i-1]-H[i]),dp[i-2]+abs(H[i-2]-H[i])
    if a<b:
        dp[i]+=a
    else:
        dp[i]+=b

print(dp[-1])

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

dp=[float('inf')]*N

def f(i):
    if dp[i]<float('inf'): return dp[i]
    if i==0: return 0
    res=10**4+1
    res=min(res,f(i-1)+abs(H[i]-H[i-1]))
    if i>1: res=min(res,f(i-2)+abs(H[i]-H[i-2]))
    dp[i]=res
    return dp[i]

print(f(N-1))

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

dp=[0]*N

dp[1]=abs(H[0]-H[1])

for i in range(2,N):
    a,b=dp[i-1]+abs(H[i-1]-H[i]),dp[i-2]+abs(H[i-2]-H[i])
    if a<b:
        dp[i]+=a
    else:
        dp[i]+=b

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
dic={i+1:[] for i in range(N)}
PY=[]
len_=0
for i in range(M):
    flag=0
    p,y=map(int,input().split())
    len_=len(dic[p])
    if len_==0:
        dic[p]=[y]
    else:
        for j in range(len_):
            if dic[p][j]>y:
                dic[p].insert(j,y)
                flag=1
                break
        if flag==0:
            dic[p].append(y)
    PY.append([p,y])

p,y='',''
ans=[]
for py in PY:
    p=str(py[0])
    y=str(py[1])
    born=dic[int(p)].index(int(y))+1
    print('0'*(6-len(p))+p+'0'*(6-len(str(born)))+str(born))



Fixed submission:
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]

D={}
for py in PY:
    try:
        if D[py[0]]=='':
            pass
    except:
        D[py[0]]=[py[1]]
        continue
    D[py[0]].append(py[1])

for k in D.keys():
    D[k].sort()

def binary_tree(lst,key):
    left=0
    right=len(lst)-1
    while left<=right:
        mid=(left+right)//2
        if lst[mid]==key:
            return mid+1
        elif lst[mid]<key:
            left=mid+1
        else:
            right=mid-1
    return -1

for py in PY:
    l=D[py[0]]
    ans=str(py[0]).zfill(6)
    ans+=str(binary_tree(l,py[1])).zfill(6)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
dic={i+1:[] for i in range(N)}
PY=[]
for i in range(M):
    p,y=map(int,input().split())
    dic[p].append(y)
    PY.append([p,y])
for k,v in dic.items():
    v.sort()
    dic[k]=v
p,y='',''
ans=[]
for py in PY:
    p=str(py[0])
    y=str(py[1])
    born=dic[int(p)].index(int(y))+1
    print('0'*(6-len(p))+p+'0'*(6-len(str(born)))+str(born))

Fixed submission:
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]

D={}
for py in PY:
    try:
        if D[py[0]]=='':
            pass
    except:
        D[py[0]]=[py[1]]
        continue
    D[py[0]].append(py[1])

for k in D.keys():
    D[k].sort()

def binary_tree(lst,key):
    left=0
    right=len(lst)-1
    while left<=right:
        mid=(left+right)//2
        if lst[mid]==key:
            return mid+1
        elif lst[mid]<key:
            left=mid+1
        else:
            right=mid-1
    return -1

for py in PY:
    l=D[py[0]]
    ans=str(py[0]).zfill(6)
    ans+=str(binary_tree(l,py[1])).zfill(6)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
T=list(input())
As={chr(ord('a')+i):[] for i in range(26)}
At={chr(ord('a')+i):[] for i in range(26)}

ans='Yes'
if len(set(S))==len(set(T)):
    for i in range(len(S)):
        As[S[i]].append(i)
        At[T[i]].append(i)
        if As[S[i]]!=At[T[i]]:
            ans='No'
            break
else:
    ans='No'

print(ans)

Fixed submission:
from collections import defaultdict

S=list(input())
T=list(input())

Sm=defaultdict(str)
Tm=defaultdict(str)

for s,t in zip(S,T):
    if (Sm[s] and Sm[s]!=t) or (Tm[t] and Tm[t]!=s): print('No'); exit()
    else: Sm[s]=t; Tm[t]=s
print('Yes')
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(N-K+1):
  	l=i
    r=l+K-1
    ans=min(ans,min(abs(X[l]),abs(X[r]))+X[r]-X[l])
print(ans)

Fixed submission:
N,K=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for l in range(N-K+1):
    r=l+K-1
    ans=min(ans,min(abs(X[l]),abs(X[r]))+X[r]-X[l])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
X=list(map(int,input().split()))+[0]
ans=10**20

for i in range(N-K+1):
    x=X[i:i+K]
    l,r=x[0],x[-1]
    if l<=0 and r<=0:
        ans=min(ans,-l)
    elif l>=0 and r>=0:
        ans=min(ans,r)
    else:
        res=min(abs(l),abs(r))*2+max(abs(l),abs(r))
        ans=min(ans,res)
print(ans)

Fixed submission:
N,K=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for l in range(N-K+1):
    r=l+K-1
    ans=min(ans,min(abs(X[l]),abs(X[r]))+X[r]-X[l])
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=='1':
    print(s[1])
else:
    print(s[0])


Fixed submission:
s=input()
len_s=len(s)
cnt=0
k=int(input())
for v in s:
    if v!='1':
        print(int(v))
        break
    else:
        cnt+=1
        if k==cnt:
            print(1)
            break
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

even=[x for x in a if x%2==0]
ans=0
while even!=[]:
    delval=0
    even[0]//=2
    len_even=len(even)
    for i in range(len_even):
        if i==0:
            if even[i]%2!=0:
                del even[i]
                delval+=1
        else:
            if (even[i-delval]*3)%2!=0:
                del even[i-delval]
                delval+=1
            else:
                even[i-delval]*=3
    ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in a:
    buf=i
    ans+=format(buf,'b')[::-1].find('1')
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
even=[x for x in a if x%2==0]
ans=0
while even!=[]:
    delval=0
    even[0]//=2
    len_even=len(even)
    for i in range(len_even):
        if i==0:
            if even[i]%2!=0:
                del even[i]
                delval+=1
        else:
            if even[i-delval]%2!=0:
                del even[i-delval]
                delval+=1
    ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in a:
    buf=i
    ans+=format(buf,'b')[::-1].find('1')
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
L=[1 if s=='W' else 0 for s in S]
ans=set()

for i in range(N):
    W,E=sum(L[:i+1]),N-i-1-sum(L[i:])
    ans.add(W+E)

print(min(ans))

Fixed submission:
N=int(input())
S=input()
A=[0]*N
A[0]=S[1:].count('E')
for i in range(1,N):
    if S[i-1]=='W':
        A[i]=A[i-1]+1
    else:
        A[i]=A[i-1]
    if S[i]=='E':
        A[i]-=1
print(min(A))
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
l=[-1,1]
cnt=0
for i in range(H):
    for j in range(W):
        a=set()
        if s[i][j]=='#':
            cnt+=1
            for v in l:
                if H>i-v>=0:
                    a.add(s[i-v][j])
                if H>j-v>=0:
                    s[i][j-v]
                    a.add(s[i][j-v])
            if '#' not in a:
                print('No')
                exit()
if cnt==0:
    print('No')
else:
    print('Yes')

Fixed submission:
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
cnt=0
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            l=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
            OK=0
            for v in l:
                if H>v[0]>=0 and W>v[1]>=0:
                    if s[v[0]][v[1]]=='#':
                        OK=1
            if OK==0:
                print('No')
                exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=list(map(int,input().split()))

Median_i=N//2-1

for i in range(N):
    X_=X[:]
    del X_[i]
    X_.sort()
    print(X_[Median_i])

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

Median_1_i=N//2-1
Median_2_i=N//2

X_=X[:]
X_.sort(reverse=True)
Median_1=X_[Median_1_i]
Median_2=X_[Median_2_i]

for x in X:
    if x<Median_1:
        print(Median_1)
    else:
        print(Median_2)
Buggy python submission (verdict: Runtime Error):
S=input()
abc=[chr(ord('a')+i) for i in range(26)]

if len(S)<26:
    for s in S:
        abc.remove(s)
    print(S+abc[0])
else:
    index_z=S.index('z')
    index_=abc.index(S[index_z-1])
    abc_=abc[index_:]
    for s in S[:index_z]:
        abc_.remove(s)
    print(S[:index_z-1]+abc_[0])

Fixed submission:
S=input()
abc=[chr(ord('a')+i) for i in range(26)]

if len(S)<26:
    for s in S:
        abc.remove(s)
    print(S+abc[0])
    exit()
for i in range(24,-1,-1):
    for j in range(25,i,-1):
        if S[i]<S[j]:
            print(S[:i]+S[j])
            exit()

print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
read_=sys.stdin.buffer.readline

N=int(input())
A=[0]
a=list(map(int,read_().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))

Fixed submission:
N=int(input())
A=[0]
a=list(map(int,input().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
max_x=max(A)+2
min_x=min(A)-1
l=set()
for x in range(min_x,max_x):
    cnt=0
    for a in A:
        if abs(x-a)<=1:
            cnt+=1
    l.add(cnt)
print(max(l))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=[0]*(max(A)+3)
for a in A:
    ans[a-1]+=1
    ans[a]+=1
    ans[a+1]+=1
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
max_x=max(A)+2
min_x=min(A)-1
l=[]
for x in range(min_x,max_x):
    cnt=0
    for a in A:
        if abs(x-a)<=1:
            cnt+=1
    l.append(cnt)
print(max(l))    

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=[0]*(max(A)+3)
for a in A:
    ans[a-1]+=1
    ans[a]+=1
    ans[a+1]+=1
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
A=list(map(int,input().split()))
junretsu=list(itertools.permutations(A))
for j in junretsu:
    cnt=0
    for i in range(N-1):
        if j[i]*j[i+1]%4!=0:
            break
        else:
            cnt+=1
    if cnt==N-1:
        print('Yes')
        exit()
print('No')

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

div_1,div_2,div_4=0,0,0
for a in A:
    if a%4==0:
        div_4+=1
    elif a%2==0:
        div_2+=1
    elif a%2!=0:
        div_1+=1
if div_2==0 and div_1<=div_4+1:
    print('Yes')
elif div_2>0 and div_1<=div_4:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
A=input().split()

B=[A[0]]

cnt=0
for a in A[1:]:
    if cnt%2==0:
        B.insert(0,a)
        cnt+=1
        continue
    B.append(a)
    cnt+=1

if N%2==0:
    print(' '.join(B))
else:
    print(' '.join(reversed(B)))

Fixed submission:
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
A=input().split()

if len(A)==1:
    print(A[0])
    exit()

B1=A[::2]
B2=A[1::2]

if N%2==0:
    B2.reverse()
    B2.extend(B1)
    print(' '.join(B2))
else:
    B1.reverse()
    B1.extend(B2)
    print(' '.join(B1))
Buggy python submission (verdict: Runtime Error):
N=int(input())
p=10**9+7

def primeryNum(n):
    n_=int(n**0.5)
    ary=list(range(n+1))
    ary[1]=0 
    for a in ary:
        if a>n_: break
        elif a==0: continue
        
        for i in range(a*2,n+1,a):
            ary[i]=0           
    return ary

primeryN=primeryNum(N)
divN=[0]*N
for pn in primeryN:
    if pn==0:
        continue
    i=1
    cnt=0
    while (pn**i<N):
        cnt+=(N//pn**i)
        i+=1
    divN[pn]=cnt

ans=1
for d in divN:
    if d==0:
        continue
    ans=(ans*(d+1))%p
print(ans)

Fixed submission:
N=int(input())
p=10**9+7

def primeryNum(n):
    n_=int(n**0.5)
    ary=list(range(n+1))
    ary[1]=0 
    for a in ary:
        if a>n_: break
        elif a==0: continue
        
        for i in range(a*2,n+1,a):
            ary[i]=0           
    return ary

primeryN=primeryNum(N)

divN=[0]*(N+1)
for pn in primeryN:
    if pn==0:
        continue
    # print(pn)
    i=1
    cnt=0
    while (pn**i<=N):
        cnt+=(N//pn**i)
        i+=1
    divN[pn]=cnt

# print(divN)
ans=1
for d in divN:
    if d==0:
        continue
    ans=(ans*(d+1))%p
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
cnt=0
for n in range(k+1):
    for m in range(k+1):
        for j in range(k+1):
            if n+m+j==s:
                cnt+=1
print(cnt)

Fixed submission:
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        l=s-(x+y)
        if 0<=l<=k:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
lists = list()

for i in range(len(s)-len(t)):
  ans = 0
  for j in range(len(t)-1):
    if s[i+j] == t[j]:
      ans = ans + 1
    lists.append(ans)

print(len(t)-max(lists))

Fixed submission:
s = input()
t = input()
lists = list()

for i in range(len(s)-len(t)+1):
  ans = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      ans += 1
    lists.append(ans)

print(len(t)-max(lists))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range (n) :
    ans *= a[i]
if ans > 10**18 :
    print(-1)
else :
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 1
for j in range (n) :
    if a[j] == 0 :
        print(0)
        exit()
for i in range (n) :
    ans *= a[i]
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
ab = list(input().split())

a = int(ab[0])
b = float(ab[1]*100)

print(a*b//100)

Fixed submission:
from decimal import Decimal 
a,b = input().split()
c = Decimal(b)
print(int(int(a)*c))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
goods =[]
for i in range(n):
    goods.append(input())
    goods = list(set(goods))
print(len(goods))

Fixed submission:
n = int(input())
goods =[]
for i in range(n):
    goods.append(input())
goods = list(set(goods))
print(len(goods))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
person = list(map(int,input().split()))
for i in range(n-1) :
    p = person.count(i+1)
    print(p)
print(0)

Fixed submission:
n = int(input())
paisen = [0] * n
person = list(map(int,input().split()))
for i in range(n-1) :
    paisen[person[i]-1] += 1
for j in range(n) :
    print(paisen[j])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
paisen = [0] * n
person = list(map(int,input().split()))
for i in range(n) :
    paisen[i] = person.count(i+1)

for i in range(n) :
    print(paisen[i])

Fixed submission:
n = int(input())
paisen = [0] * n
person = list(map(int,input().split()))
for i in range(n-1) :
    paisen[person[i]-1] += 1
for j in range(n) :
    print(paisen[j])
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range (k) :
    for j in range (k) :
        for l in range (k) :
            p = math.gcd(i+1,j+1)
            if abs(i-j) == 1 :
                ans += 1
            elif abs(j-l) == 1 :
                ans += 1
            elif abs(l-i) == 1 :
                ans += 1
            elif p == 1 :
                ans += 1
            else :
                ans += math.gcd(p,l+1)

print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for i in range (1,k+1) :
    for j in range (1,k+1) :
        p = gcd(i,j)
        for l in range (1,k+1) :
            ans += gcd(p,l)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range (k) :
    for j in range (k) :
        for l in range (k) :
            p = math.gcd(i+1,j+1)
            if p == 1 :
                ans += 1
            else :
                ans += math.gcd(p,l+1)
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for i in range (1,k+1) :
    for j in range (1,k+1) :
        p = gcd(i,j)
        for l in range (1,k+1) :
            ans += gcd(p,l)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for i in range (k) :
    for j in range (k) :
        for l in range (k) :
            p = math.gcd(i+1,j+1)
            ans += math.gcd(p,l+1) 
print(ans)

Fixed submission:
from math import gcd
k = int(input())
ans = 0
for i in range (1,k+1) :
    for j in range (1,k+1) :
        p = gcd(i,j)
        for l in range (1,k+1) :
            ans += gcd(p,l)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
number = list(map(int,input().split()))
num = sorted(number)
num.append(0)
p = num[0]
combi = dict()
u = 0

for i in range (n+1) :
    q = num[i]
    if p != q :
        combi[p] = u
        u = 0
    u += 1
    p = q

t = 0

for j in combi.values() :
    t += j*(j-1)//2

for k in range (n) :
    x = combi[j]
    print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)

Fixed submission:
n = int(input())
number = list(map(int,input().split()))
num = sorted(number)
num.append(0)
p = num[0]
combi = dict()
u = 0

for i in range (n+1) :
    q = num[i]
    if p != q :
        combi[p] = u
        u = 0
    u += 1
    p = q

t = 0

for j in combi.values() :
    t += j*(j-1)//2

for k in range (n) :
    x = number[k]
    print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split())
s = 0
for i in range (n) :
    if a[i] = s + 1 :
        s += 1
print(n - s)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
brick = 0
for i in range (n) :
    if a[i] == brick + 1 :
        brick += 1
if (brick == 0) :
    print(-1)
else :
    print(n - brick)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
over = 0
for i in range (n) :
    over += i
print(over)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-sum(a2[1::2]))
    a2.append(a2[0])
    del a2[0]

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(int,lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
kaburi = []

for i in range(n):
    if not a[i] in kaburi:
        kaburi.append(a[i])

kaisu = 0

while True:
    p = n
    q = 0
    if k >= len(kaburi):
        print(kaisu)
        break
    else:
        for j in range(len(kaburi)):
            p = min(p,a.count(kaburi[j]))
            if p > a.count(kaburi[j]):
                q = kaburi[j]
        kaisu += p
        print(p,q,kaisu,len(kaburi))
        kaburi.remove(q)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
kosu = [0]*n
kaburi = []

for i in range(n):
    kosu[a[i]-1] += 1

for j in range(n):
    if kosu[j] != 0:
        kaburi.append(kosu[j])

kaburi.sort()
print(sum(kaburi[:len(kaburi)-k]))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
p = 1
for i in range(n) :
    t = int(input())
    p = p*t//math.gcd(p,t)
print(p)

Fixed submission:
import fractions
n = int(input())
p = 1
for i in range(n) :
    t = int(input())
    p = p*t//fractions.gcd(p,t)
print(p)