Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

for i in range(len(t)):
    if(list(s).count(t[i])==0):
        print("-1")
        exit()

p=0
i = 0
while True:
    for j in range(len(s)):
        if(t[p]==s[j]):
            p+=1
        if(len(t)==p):break
    if(len(t)==p):break
    i+=1
print(i*len(s)+j+1)



Fixed submission:
import bisect
s = input()
t = input()
lens=len(s)
lent=len(t)
d = {}
s2=s+s
lens2=len(s2)

for i in range(lens2):
    if s2[i] in d:
        d[s2[i]].append(i)
    else:
        d[s2[i]] = [i]

tmp=0
r=0
snum=0
for i in range(lent):
    if(lens<tmp):
        snum+=lens
        tmp-=lens
        
    if d.get(t[i],None)==None:
        print("-1")
        exit()
    else:
        lis=d[t[i]]
        r = bisect.bisect_left(lis,tmp)
        tmp=lis[r]+1
print(snum+tmp)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())

nlist=[""]*N

for i in range(N):
    t=str(input())
    t = ''.join(sorted(t))
    nlist[i] = t

sum=0
tsum=1
nlist=sorted(nlist)
tmpStr=nlist[0]
for i in range(1,N):
    if(tmpStr==nlist[i]):
        tsum+=1
    else:
        tmpStr=nlist[i]
        if(tsum!=1):
                sum+=math.factorial(tsum)/2
                tsum=1
if(tsum!=1):
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        
print(int(sum))


Fixed submission:
import math
N = int(input())

nlist=[""]*N
d={}
for i in range(N):
    t=str(input())
    t=''.join(sorted(t))
    if d.get(t,None)==None:
        d[t]=1
    else:
        d[t]+=1 
ans=0

#print(d.keys(),d.values())
for i in d.values():
    ans += i*(i-1)/2
print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())

nlist=[""]*N

for i in range(N):
    t=str(input())
    t = ''.join(sorted(t))
    nlist[i] = t

cnt=1
sum=0
tsum=1
nlist=sorted(nlist)
tmpStr=nlist[0]
for i in range(1,N):
    if(tmpStr==nlist[i]):
        tsum+=1
    else:
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        tsum=1
if(tsum!=1):
        tmpStr=nlist[i]
        sum+=math.factorial(tsum)/2
        

print(int(sum))


Fixed submission:
import math
N = int(input())

nlist=[""]*N
d={}
for i in range(N):
    t=str(input())
    t=''.join(sorted(t))
    if d.get(t,None)==None:
        d[t]=1
    else:
        d[t]+=1 
ans=0

#print(d.keys(),d.values())
for i in d.values():
    ans += i*(i-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nlist=[""]*N

for i in range(N):
    t=str(input())
    t = ''.join(sorted(t))
    nlist[i] = t

cnt=1
sum=0
for i in range(N):
    cnt=1
    cnt=nlist.count(nlist[i])
    if(cnt!=1):
        sum+=cnt-1

print(int(sum/2))


Fixed submission:
import math
N = int(input())

nlist=[""]*N
d={}
for i in range(N):
    t=str(input())
    t=''.join(sorted(t))
    if d.get(t,None)==None:
        d[t]=1
    else:
        d[t]+=1 
ans=0

#print(d.keys(),d.values())
for i in d.values():
    ans += i*(i-1)/2
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
numList=[[0]*2 for i in range(N)]


for i in range(N):
    A,B= map(int, input().split())
    numList[i][0]=A
    numList[i][1]=B

numList =  sorted(numList, key=lambda x: (x[1]),reverse=True)
numList =  sorted(numList, key=lambda x: (x[0]))

sum=0
count=0
k=0
t=-1
while True:
    if(k>=M):break
    k+=1
    for i in range(N):
        if(numList[i][0]<=k):
            if(count<numList[i][1]):
                count=numList[i][1]
                t=i
        else:
            sum+=count
            count=0
            if(t!=-1):
                numList[t][1]=0
                t=-1
            break
    else:
        sum+=count
        count=0
        if(t!=-1):
            numList[t][1]=0
            t=-1
print(sum)

Fixed submission:
import heapq
N,M = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
AB.sort(key=lambda x:x[0])
index = 0
Works = []
ans = 0

for d in range(1,M+1):#d日後までの支払いのうち一番高いやつ
    while 1:
        if index>=N:break
        if AB[index][0]<=d:
            heapq.heappush(Works,-AB[index][1])
            index += 1
        else:
            break
    if Works:
        ans -= heapq.heappop(Works)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H = list(input())
N = [1]*len(H)
T = N[:]
J0 = [2]*len(H)
J1 = [3]*len(H)
k=0
while True:
    k+=1

    if(J0==J1):break

    for i,para in enumerate(H):
        if(N[i]!=0):
            if(para=="R"):
                T[i+1]+=N[i]
            else:
                T[i-1]+=N[i]
            T[i]-=N[i]
    N=T[:]
    if(k%2==0):
        J1=J0[:]
        J0=N[:]

for para in N:
    print(para, end=" ")



Fixed submission:
H = list(input())
N = [0]*len(H)

Lflag=0
Rcnt=0
Lcnt=0
cnt=0
for i in range(1,len(H)+1):
    if((H[i-1]=="L") & (Lflag==0)):
        Lflag=1
        Rcnt=i-1
        Lcnt=i
    if((H[i-1]=="R") & (Lflag==1)):
        if((i-1-cnt)%2==0):
            N[Rcnt-1]=int(((i-1)-cnt)/2)
            N[Lcnt-1]=int(((i-1)-cnt)/2)

        else:
            if(Rcnt%2==(i-1)%2):
                N[Rcnt-1]=int(((i-1)-cnt)/2+1)
                N[Lcnt-1]=int(((i-1)-cnt)/2)
            else:
                N[Rcnt-1]=int(((i-1)-cnt)/2)
                N[Lcnt-1]=int(((i-1)-cnt)/2+1)
        cnt=i-1
        Lflag=0

if((len(H)-cnt)%2==0):
    N[Rcnt-1]=int((len(H)-cnt)/2)
    N[Lcnt-1]=int((len(H)-cnt)/2)

else:
    if(Rcnt%2==len(H)%2):
        N[Rcnt-1]=int((len(H)-cnt)/2+1)
        N[Lcnt-1]=int((len(H)-cnt)/2)
    else:
        N[Rcnt-1]=int((len(H)-cnt)/2)
        N[Lcnt-1]=int((len(H)-cnt)/2+1)
    
for para in N:
    print(para, end=" ")
Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
ansList = []
for i in range(len(A),0,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)
print(len(ansList))

for i in ansList:
    print(i, end=" ")

Fixed submission:
N = int(input())
print(3*N*N)

Buggy python submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())
A = list(map(int, input().split()))
ANS = [0]*len(A)
sum=0
ansList = []
for i in range(len(A),0,-1):
    if(ANS[i-1]%2!=A[i-1]):
        tList = make_divisors(i)
        for j in tList:
            ANS[j-1]+=1
        ansList.append(i)
print(len(ansList))
for i in ansList:
    print(i, end=" ")


Fixed submission:
N = int(input())
print(3*N*N)
Buggy python submission (verdict: Runtime Error):
import heapq
L,R = map(int,input().split())
numMap=[10**19]*(R-L+1)
numheap=[]
k=0

AnsA=0
AnsB=0
for i in range(L,R+1):
    num=i%2019
    heapq.heappush(numheap,num)
    if(num==3):AnsA=1
    if(num==673):AnsB=1
    k+=1

if(AnsA!=0 & AnsB!=0):
    print("0")
else:
    print(heapq.heappop(numheap)*heapq.heappop(numheap))

Fixed submission:
import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)

Buggy python submission (verdict: Runtime Error):
import heapq
L,R = map(int,input().split())
numMap=[10**19]*(R-L+1)
numheap=[]
k=0

AnsA=0
AnsB=0
for i in range(L,R+1):
    heapq.heappush(numheap,i%2019)
    if(numMap[k]==3):AnsA=i
    if(numMap[k]==673):AnsB=i
    k+=1

if(AnsA!=0 & AnsB!=0):
    print("0")
else:
    print(heapq.heappop(numheap)*heapq.heappop(numheap))

Fixed submission:
import math
L, R = map(int, input().split())
R=min(R,L+2019)
m=2018
for i in range(L,R+1):
  for j in range(i,R+1):
    if i==j:
      continue
    if (i*j)%2019<m:
      m=(i*j)%2019
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

a = [[0]*N for i in range(N)]
b = [0]*N

for i in range(N):
    a[i][(N+i-1)%N]=1
    a[i][i]=1

    b[i]=A[i]*2

x = np.linalg.solve(a, b) 

for i in range(N):
    print(int(x[(N+i-1)%N]),end=" ")



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

a = [0]*N

sum_a=sum(A)
a[0]=sum_a
for i in range(1,N,2):
    a[0]-=2*A[i]
print(a[0],end=" ")

for i in range(1,N):
    a[i]=2*A[i-1]-a[i-1]
    print(a[i],end=" ")
Buggy python submission (verdict: Runtime Error):
import math

def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

(N, K) = input().split()
N = int(N)
K = int(K)

for i in range(1, K+1):
    A = C(N - K + 1, i) * C(K - 1, i - 1) % 1000000007
    print(A)


Fixed submission:
import math

def C(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

(N, K) = input().split()
N = int(N)
K = int(K)

for i in range(1, K+1):
    if N - K + 1 < i:
        A = 0
    else:
        A = C(N - K + 1, i) * C(K - 1, i - 1) % 1000000007
    print(A)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D = map(int, input().split())
A-=1

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm(C,D))
BCD=int(B/lcm(C,D))
A_=AC+AD-ACD
B_=BC+BD-BCD

print((B-B_)-(A-A_))


Fixed submission:
a,b,c,d = map(int,input().split(" "))
def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = c*d
lcm = prod//gcd(c,d)
a1=b//c - (a-1)//c
a2=b//d - (a-1)//d
a3=b//lcm-(a-1)//lcm
print(b-a+1-a1-a2+a3)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D = map(int, input().split())
A-=1

AC=int(A/C)
AD=int(A/D)
BC=int(B/C)
BD=int(B/D)
ACD=int(A/lcm(C,D))
BCD=int(B/lcm(C,D))
A_=AC+AD-ACD
B_=BC+BD-BCD

print((B-B_)-(A-A_))


Fixed submission:
a,b,c,d = map(int,input().split(" "))
def gcd(c,d):
	if(c==0):
		return d
	else:
		return gcd(d%c,c)
prod = c*d
lcm = prod//gcd(c,d)
a1=b//c - (a-1)//c
a2=b//d - (a-1)//d
a3=b//lcm-(a-1)//lcm
print(b-a+1-a1-a2+a3)
Buggy python submission (verdict: Time Limit Exceeded):
MOD=10**9+7
N,M=map(int,input().split())
A=[0]*M

for i in range(M):
    A[i]=(int(input())+1)

S=[0]*(N+2)
S[1]=1
for i in range(2,N+2):
    if(i not in A):
        S[i]=(S[i-1]+S[i-2])%MOD
    else:
        S[i]=0
print(S[N+1])

Fixed submission:
MOD=10**9+7
N,M=map(int,input().split())
A=[True]*(N+2)

for i in range(M):
    a=(int(input())+1)
    A[a]=False

S=[0]*(N+2)
S[1]=1
for i in range(2,N+2):
    if(A[i]):
        S[i]=(S[i-1]+S[i-2])%MOD
    else:
        S[i]=0
print(S[N+1])
Buggy python submission (verdict: Runtime Error):
S=list(input())
s=[]
for i in range(len(S)):
    if S[i] == "A":
        s.append("A")
    elif(S[i] == "B" and S[i+1] == "C"):
        s.append("D")
s=s+[""]
c=0
i=0
while(len(s)>i):
    if s[i]=="A" and s[i+1]=="D":
        s[i]="D"
        s[i+1]="A"
        i-=2
        c+=1
    i+=1

print(c)

Fixed submission:
s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
t=["","",""]
s=t+s+t

c=0
i=0
while(len(s)>i):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C" :
        s[i]="B"
        s[i+1]="C"
        s[i+2]="A"
        i-=2
        c+=1
    i+=1

print(c)

Fixed submission:
s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
t=["","",""]
s=t+s+t

c=0
i=0
while(len(s)>i):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C" :
        s[i]="B"
        s[i+1]="C"
        s[i+2]="A"
        i-=2
        c+=1
    i+=1

print(c)

Fixed submission:
s = input().replace('BC', 'D')
 
acc = 0
ans = 0
for c in s:
    if c == 'B' or c == 'C':
        acc = 0
        continue
    elif c == 'A':
        acc += 1
    else:
        ans += acc
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int,input().split()))
q=[0]*10


ans=0
for k in range(2*11):
    for i in range(n+1):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)



Fixed submission:
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int, input().split()))
q=[0]*11


ans=0
while(True):
    for i in range(n):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int,input().split()))
q=[0]*10


ans=0
while(True):
    for i in range(n+1):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1

    q[0]+=1

print(ans)



Fixed submission:
n,m=map(int,input().split())
s=[list(map(int,input().split()))for i in range(m)]
for i in range(m):
    del s[i][0]
p=list(map(int, input().split()))
q=[0]*11


ans=0
while(True):
    for i in range(n):
        if(q[i]==2):
            q[i+1]+=1
            q[i]=0
    if(q[n]==1):
        break
    
    flag=1
    for i in range(m):
        tmp=0
        for j in s[i]:
            tmp+=q[j-1]
        if(tmp%2!=p[i]):
            flag=0
            break
    if(flag==1):
        ans+=1
    q[0]+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    B,C=map(int,input().split())
    for j in range(B):
        A+=[C]
A=list(sorted(A,reverse=True))
print(sum(A[0:N]))

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())

A=sorted(A)
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

i=0
for B,C in BC:
    for j in range(i,min(N,i + B)):
        if A[j] < C:
            A[j] = C
            #B枚分先を飛ばす BCはCに関して降順のため問題ない
    i = i + B
 
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

c=0
for i in range(M):
    c=1
    for j in range(BC[i][0]):
        if(BC[i][1]>=A[j]):
            A[j]=BC[i][1]
            c=0
        else:
            break
    if(c==0):
        A=sorted(A)
    else:
        break

print(sum(A))

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())

A=sorted(A)
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

i=0
for B,C in BC:
    for j in range(i,min(N,i + B)):
        if A[j] < C:
            A[j] = C
            #B枚分先を飛ばす BCはCに関して降順のため問題ない
    i = i + B
 
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())
BC=list(sorted(BC,reverse=True))

for i in range(M):
    for j in range(BC[i][0]):
        if(BC[i][1]>=A[j]):
            A[j]=BC[i][1]
        else:
            break
    A=sorted(A)

print(sum(A))

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[[0,0] for i in range(M)]
for i in range(M):
    BC[i][0],BC[i][1]=map(int,input().split())

A=sorted(A)
BC=list(sorted(BC,reverse=True,key=lambda x: x[1]))

i=0
for B,C in BC:
    for j in range(i,min(N,i + B)):
        if A[j] < C:
            A[j] = C
            #B枚分先を飛ばす BCはCに関して降順のため問題ない
    i = i + B
 
print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n=map(int,input().split())
tmp=0
A=0
B=0
for i in range(3001):
    if(r*i>3001):break
    for j in range(3001):
        A=r*i+g*j
        B=n-A
        if(A>3001|B<0):break
        if(((B%b)==0)&((B/b)<3001)):
            tmp+=1
print(tmp)

Fixed submission:
R, G, B, N = map(int, input().split())
 
ans = 0
for r in range(N//R + 1):
    for g in range((N - (R*r))//G + 1):
        if(N - (R*r) - (G*g)) % B == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
LIST=""
LIST=list(LIST)
c=0

def func(S):
    global LIST
    global c

    if(len(S)==0):
        c=1
    if(c==1):
        for i in range(len(LIST)-1,-1,-1):
            print(LIST[i])
        exit()

    So=S[::]
    for i in range(len(S)):
        S=So[::]
        if(S[i]==(i+1)):
            LIST.append(S.pop(i))
            func(S)
    if(len(LIST)==0):
        print("-1")
        exit()
    LIST.pop(-1)

N=int(input())
S=list(map(int,input().split()))

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

func(S)
print("-1")

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
LIST=list("")

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

while(len(S)>0):
    c=10**10
    for i in range (len(S)):
        if(S[i]==i+1):
            c=i
    if(c==(10**10)):
        print("-1")
        exit()  
    LIST.append(S.pop(c))

for i in range(len(LIST)-1,-1,-1):
    print(LIST[i])

Buggy python submission (verdict: Time Limit Exceeded):
LIST=""
LIST=list(LIST)
c=0

def func(S):
    global LIST
    global c

    if(len(S)==0):
        c=1
    if(c==1):
        for i in range(len(LIST)-1,-1,-1):
            print(LIST[i])
        exit()

    So=S[::]
    for i in range(len(S)):
        S=So[::]
        if(S[i]==(i+1)):
            LIST.append(S.pop(i))
            func(S)
    if(len(LIST)==0):
        print("-1")
        exit()
    LIST.pop(-1)

N=int(input())
S=list(map(int,input().split()))
func(S)
print("-1")

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
LIST=list("")

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

while(len(S)>0):
    c=10**10
    for i in range (len(S)):
        if(S[i]==i+1):
            c=i
    if(c==(10**10)):
        print("-1")
        exit()  
    LIST.append(S.pop(c))

for i in range(len(LIST)-1,-1,-1):
    print(LIST[i])

Buggy python submission (verdict: Time Limit Exceeded):
LIST=""
LIST=list(LIST)
c=0

def func(S):
    global LIST
    global c

    if(len(S)==0):
        c=1
    if(c==1):
        for i in range(len(LIST)-1,-1,-1):
            print(LIST[i])
        exit()

    So=S[::]
    for i in range(len(S)):
        S=So[::]
        if(S[i]==(i+1)):
            LIST.append(S.pop(i))
            func(S)
    if(len(LIST)>0):
        LIST.pop(-1)

N=int(input())
S=list(map(int,input().split()))
func(S)
print("-1")

Fixed submission:
N=int(input())
S=list(map(int,input().split()))
LIST=list("")

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

while(len(S)>0):
    c=10**10
    for i in range (len(S)):
        if(S[i]==i+1):
            c=i
    if(c==(10**10)):
        print("-1")
        exit()  
    LIST.append(S.pop(c))

for i in range(len(LIST)-1,-1,-1):
    print(LIST[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0
MOD = 10 ** 9 + 7

def ff(i,L):
    global count
    global MOD
    
    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1
        count %= MOD

ff(0,"")
print(count-1)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0
MOD = 10 ** 9 + 7

def ff(i,L):
    global count
    global MOD
    
    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1
        count %= MOD

ff(0,"")
print(count-1)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input()+"")
#Dic={}
count=0

def ff(i,L):
    global count

    if(N>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        count += 1

ff(0,"")
print(count-1)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
#Dic={}
count=0

def ff(i,L):
    #global Dic
    global count

    if(len(S)>i):
        if(S[i] not in L):
            ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        #Dic[L]=1
        count += 1

ff(0,"")
#print(len(Dic)-1)
print(count-1)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

Dic={}

def ff(i,L):
    if(len(S)>i):
        ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        Dic[L]=1
ff(0,"")
print(len(Dic)-1)

Fixed submission:
n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
import math
l,r=map(int,input().split())

t=r
c=0
while(t!=0):
    c+=1
    t//=2
LIST=[0]*c


l=l-1

t1=math.ceil(l/2)
t2=math.ceil(r/2)
LIST[-1]=((t2-t1)%2)*(2**(0))

for i in range(2,c+1):
    k=(l-(l//2**i)*(2**i))+1
    t1=max(k-((2**i)//2),0)

    k=(r-(r//2**i)*(2**i))+1
    t2=max(k-((2**i)//2),0)
 
    LIST[-i]=((t2-t1)%2)*(2**(i-1))

print(sum(LIST))

Fixed submission:
import math
l,r=map(int,input().split())

t=r
c=0
while(t!=0):
    c+=1
    t//=2
LIST=[0]*c

if(c==0):
    print(0)
    exit()

l=l-1

t1=math.ceil(l/2)
t2=math.ceil(r/2)
LIST[-1]=((t2-t1)%2)*(2**(0))

for i in range(2,c+1):
    k=(l-(l//2**i)*(2**i))+1
    t1=max(k-((2**i)//2),0)

    k=(r-(r//2**i)*(2**i))+1
    t2=max(k-((2**i)//2),0)
 
    LIST[-i]=((t2-t1)%2)*(2**(i-1))

print(sum(LIST))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


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

print(gcd_list(A))

Fixed submission:
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


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

print(gcd_list(A))