Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
flag = 1

if (S[0] == S[1]) & (S[1] == S[2]):
  	print("No")
else: 
	print("Yes")

Fixed submission:
str = input()
 
if (str[0] == str[1]) & (str[1] == str[2]):
  	print("No")
else:
  	print("Yes")

Buggy python submission (verdict: Runtime Error):
S

Fixed submission:
str = input()
 
if (str[0] == str[1]) & (str[1] == str[2]):
  	print("No")
else:
  	print("Yes")
Buggy python submission (verdict: Runtime Error):
s = list(map(int, input().split()))

n = s[0]
blue = s[1]
red = s[2]

temp = ""

while len(temp) < n:
    temp += "b" * blue + "r" * red

print(temp[:n].count('b'))

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

ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)

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

n = s[0]
blue = s[1]
red = s[2]

temp = []

while n >= 0:
    for i in range(blue):
        temp.append(1)
    for i in range(red):
        temp.append(0)
    n -= (blue + red)

print(sum(temp[:n]))

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

ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
a=list(map(int,input().split()))
b=sum(a)
print(max(-1,n-b))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sum(a)
print(max(-1,n-b))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
a=list(map(int,input().split()))
b=sum(a)
print(max(0,n-b))

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(len(a)):
  b[a[i]-1]+=1
for j in range(len(b)):
  print(b[j])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(input())
r=[0]*n
g=[0]*n
b=[0]*n
for i in range(n):
  if i==0:
    if a[n-1-i]=='R':
      r[n-1-i]=1
    elif a[n-1-i]=='G':
      g[n-1-i]=1
    else:
      b[n-1-i]=1
  else:
    if a[n-1-i]=='R':
      r[n-1-i]=r[n-i]+1
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]
    elif a[n-1-i]=='G':
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]+1
      b[n-1-i]=b[n-i]
    else:
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]+1

count=0
if n==1:
  print(0)
elif n==2:
  print(0)
else:
  for i in range(n-2):
    for j in range(i+1,n-1):
      if a[i]!=a[j] and 2*j-i<n and a[i]!=a[2*j-i] and a[j]!=a[2*j-i]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]-1
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]-1
        else:
          count+=b[j+1]-1
      elif a[i]!=a[j]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]
        else:
          count+=b[j+1]
  print(count)
      

Fixed submission:
n=int(input())
a=list(input())
r=[0]*n
g=[0]*n
b=[0]*n
for i in range(n):
  if i==0:
    if a[n-1-i]=='R':
      r[n-1-i]=1
    elif a[n-1-i]=='G':
      g[n-1-i]=1
    else:
      b[n-1-i]=1
  else:
    if a[n-1-i]=='R':
      r[n-1-i]=r[n-i]+1
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]
    elif a[n-1-i]=='G':
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]+1
      b[n-1-i]=b[n-i]
    else:
      r[n-1-i]=r[n-i]
      g[n-1-i]=g[n-i]
      b[n-1-i]=b[n-i]+1

count=0
if n==1:
  print(0)
elif n==2:
  print(0)
else:
  for i in range(n-2):
    for j in range(i+1,n-1):
      if a[i]!=a[j] and 2*j-i<n and a[i]!=a[2*j-i] and a[j]!=a[2*j-i]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]-1
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]-1
        else:
          count+=b[j+1]-1
      elif a[i]!=a[j]:
        if a[i]!='R' and a[j]!='R':
          count+=r[j+1]
        elif a[i]!='G' and a[j]!='G':
          count+=g[j+1]
        else:
          count+=b[j+1]
  print(count)
Buggy python submission (verdict: Runtime Error):
a=list(input())
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')


Fixed submission:
a=list(input())
if a[0]==a[1]==a[2]:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a=list(input().split())
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')


Fixed submission:
a=list(input())
if a[0]==a[1]==a[2]:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
if a[1]==a[2]==a[3]:
  print('No')
else:
  print('Yes')

Fixed submission:
a=list(input())
if a[0]==a[1]==a[2]:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  pre=0
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 
      for l in range(d[n-1-j]):
        if ((i>>(a[j][l][0]-1))&1)!=a[j][l][1]:
          pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)

Fixed submission:
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  pre=0
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 
      for l in range(d[j]):
        if ((i>>(a[j][l][0]-1))&1)!=a[j][l][1]:
          pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 


  pre=0
  for k in range(n):
    for l in range(d[n-1]):
      #print([x[a[k][l][0]-1],a[k][l][1]])
      if ((x[k]==1 and x[a[k][l][0]-1]!=a[k][l][1]) or 
          (x[k]==0 and x[a[k][l][0]-1]==a[k][l][1])):
        pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)



Fixed submission:
n=int(input())
a=[]
d=[]
for i in range(n):
  c=[]
  b=int(input())
  d.append(b)
  for j in range(b):
    c.append(list(map(int,input().split())))
  a.append(c)


count=0
for i in range(2**n):
  x=[0]*n
  pre=0
  for j in range(n):
    if ((i>>j)&1):
      x[n-1-j]=1 
      for l in range(d[j]):
        if ((i>>(a[j][l][0]-1))&1)!=a[j][l][1]:
          pre+=1
  if pre!=0:
    count=count
  else:
    count=max(count,x.count(1))
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    count=count*x.count(a[i])
    x[x.index(a[i])]+=1
print(count%mod)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    if x.count(a[i])==0:
      count=0
      break
    else:
      count=count*x.count(a[i])
      x[x.index(a[i])]+=1
print(count%mod)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count*=3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count*=2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count*=1
  else:
    count*=x.count(a[i])
    x[x.index(a[i])]+=1
print(count%(10**9+7))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
x=[0,0,0]
count=1
mod=10**9+7
for i in range(n):
  if x[0]==0 and a[i]==0:
    x[0]+=1
    count=count*3
  elif x[1]==0 and a[i]==0:
    x[1]+=1
    count=count*2
  elif x[2]==0 and a[i]==0:
    x[2]+=1
    count=count*1
  else:
    if x.count(a[i])==0:
      count=0
      break
    else:
      count=count*x.count(a[i])
      x[x.index(a[i])]+=1
print(count%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
count=1
x=max(a)
if a[0]!=0:
  print(0)
else:
  b=[1]*(x+1)
  for i in range(1,x+1):
    count=(count*(b[i-1]**a.count(i))%998244353)
    b[i]=a.count(i)
  print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count=1
x=max(a)
import collections
c=collections.Counter(a)
if a[0]!=0 or c[0]!=1:
  print(0)
  exit()
else:
  b=[1]*(x+1)
  for i in range(1,x+1):
    count=(count*(b[i-1]**c[i]))%998244353
    b[i]=c[i]
  print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
count=1
x=max(a)
if a[0]!=0:
  print(0)
else:
  b=[1]*(x+1)
  for i in range(1,x+1):
    count=(count*(b[i-1]**a.count(i))%998244353)
    b[i]=a.count(i)
  print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count=1
x=max(a)
import collections
c=collections.Counter(a)
if a[0]!=0 or c[0]!=1:
  print(0)
  exit()
else:
  b=[1]*(x+1)
  for i in range(1,x+1):
    count=(count*(b[i-1]**c[i]))%998244353
    b[i]=c[i]
  print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
count=1
if a[0]!=0:
  print(0)
else:
  b=[1]
  for i in range(1,max(a)+1):
    count=(count*(b[i-1]**a.count(i))%998244353)
    b.append(a.count(i))
  print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count=1
x=max(a)
import collections
c=collections.Counter(a)
if a[0]!=0 or c[0]!=1:
  print(0)
  exit()
else:
  b=[1]*(x+1)
  for i in range(1,x+1):
    count=(count*(b[i-1]**c[i]))%998244353
    b[i]=c[i]
  print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l.sort()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    left=j+1
    right=n-1
    while left<=right:
      center=(right+left)//2
      if center==n-1:
        if l[i]+l[j]>l[center]:
          count+=center-j
        break
      elif l[center+1]>l[i]+l[j]>l[center] :
        count+=center-j
        break
      elif l[i]+l[j]>l[center]:
        left=center+1
      else:
        right=center-1
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
l.reverse()
count=0
for i in range(n-2):
  j=i+1
  k=n-1
  while j<k:
    if l[i]<l[j]+l[k]:
      count+=k-j
      j+=1
    else:
      k-=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
l.sort()
l.reverse()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i]-l[j]<l[k]:
        count+=1
      else:
        break
print(count)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
l.sort()
l.reverse()
count=0
for i in range(n-2):
  j=i+1
  k=n-1
  while j<k:
    if l[i]<l[j]+l[k]:
      count+=k-j
      j+=1
    else:
      k-=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a.index(i+1)+1)
print(' '.join(map(str,b)))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(range(len(a)), key=lambda k: a[k])
for i in range(n):
  b[i]+=1
print(' '.join(map(str,b)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
for i in range(n):
  if k-(q-a.count(i+1))>0:
    print('Yes')
  else:
    print('No')

Fixed submission:
n,k,q=map(int,input().split())
a=[0]*n
for i in range(q):
  a[int(input())-1]+=1
for i in range(n):
  if k-(q-a[i])>0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
  break
if s[0] == s[1]:
  if s[2] == s[3]:
    print('Yes')
  else:
    print('No')
elif s[0] == s[2]:
  if s[1] == s[3]:
    print('Yes')
  else:
    print('No')
elif s[0] == s[3]:
  if s[1] == s[2]:
    print('Yes')
  else:
    print('No')
else:
  print('No')


Fixed submission:
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
    if s[2] == s[3]:
      print('Yes')
    else:
      print('No')
  elif s[0] == s[2]:
    if s[1] == s[3]:
      print('Yes')
    else:
      print('No')
  elif s[0] == s[3]:
    if s[1] == s[2]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

counter = 0
for i in range(N):
    a = x[i]-x[0]
    b = y[i]-y[0]
    for j in range(1,N):
        for k in range(j,N):
            if a == x[j]-x[k] and b == y[j]-y[k]:
                counter += 1
if N==2:
  print(1)
else:
  print(counter-1)

Fixed submission:
a,b = map(int,input().split())
if b == 1:
    print(0)
else:
    print(a-b)
Buggy python submission (verdict: Runtime Error):
def fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

n,m = map(int,input().split())
if m != 0:
  a = [int(input()) for i in range(m)]
  ans = fib(a[0])
  for j in range(1,m):
    if m == 1:
        continue
    elif a[j] == a[j-1]+1:
        ans = 0
    else:
        ans *= fib(a[j]-a[j-1]-1)
  ans *= fib(n-a[m-1])
else:
  ans = fib(n+1)
print(ans%1000000007)


Fixed submission:
a,b,c = map(int, input().split())
print(min(a+b,b+c,c+a))

Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int,input().split()))
ans = float('inf')
for j in range(n):
  ans = min(ans,abs(sum(w[0:j])-sum(w[j:n])))
print(ans)



Fixed submission:
a,b,c = map(int, input().split())
print(min(a+b,b+c,c+a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = [0]*n
for i in range(n):
  w[i] = map(int,input().split())
ans = float('inf')
for j in range(n):
  ans = min(ans,abs(sum(w[0:i]-w[i:n])))
print(ans)

Fixed submission:
n = int(input())
w = list(map(int,input().split()))
ans = float('inf')
for j in range(n):
  ans = min(ans,abs(sum(w[0:j])-sum(w[j:n])))
print(ans)
Buggy python submission (verdict: Runtime Error):
a,p = map(int,input().split())
z = a*3+p
if z % 2 = 0:
  print(int(z/2))
else:
  print(int((z-1)/2))


Fixed submission:
a,p = map(int,input().split())
z = a*3+p
if z % 2 == 0:
  print(int(z/2))
else:
  print(int((z-1)/2))

Buggy python submission (verdict: Runtime Error):
a,p = map(int,input().split())
z = a*3+p
if z % 2 = 0:
  print(z/2)
else:
  print((z-1)/2)

Fixed submission:
a,p = map(int,input().split())
z = a*3+p
if z % 2 == 0:
  print(int(z/2))
else:
  print(int((z-1)/2))
Buggy python submission (verdict: Runtime Error):
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')

Fixed submission:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
x,y=map(int,input().split())
if a.count(x)==a.count(y) and b.count(x)==b.count(y) and c.count(x)==c.count(y):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(n):
  print(a.count(j+1)+b.count(j+1))

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(n):
  print(a.count(j+1)+b.count(j+1))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())
for j in range(m):
  print(a.count(m+1)+b.count(m+1))

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
for j in range(n):
  print(a.count(j+1)+b.count(j+1))
Buggy python submission (verdict: Time Limit Exceeded):
s=int(input())

li = list(map(int,input().split()))
cnt = 0
for a in range(len(li)):
    for b in range(a + 1, len(li)):
        for c in range(b + 1, len(li)):
            if ((li[a] < li[b] + li[c]) and (li[b] < li[c] + li[a]) and (li[c] < li[a] + li[b])):
                cnt += 1

print(cnt)

Fixed submission:
s=int(input())

li = list(map(int,input().split()))
li.sort()
cnt = 0
import bisect
for a in range(len(li)):
    for b in range(a + 1, len(li)):
       i = bisect.bisect_left(li, li[a]+li[b])
       cnt += i - b - 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
a=int(input())

print(long((a - 1) * a / 2))

Fixed submission:
a=int(input())

print(((a - 1) * a // 2))
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)

for i in range(q):
    l,r = map(int,input().split())
    ans1 = -1
    ans2 = len(indexes) - 1
    for j in range(len(indexes)):
        if(l -1 <= indexes[j] and ans1 == -1):
            ans1 = j
        if (r < indexes[j]+2):
            ans2 = j -1
            break
    if (ans1 == -1):
        ans2 = -2
    print(ans2-ans1 + 1)



Fixed submission:
n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)
dp = []

for i in range (n):
    dp.append(len(indexes))
    if len(indexes)> 0 and indexes[0] == i:
        indexes.pop(0)
for i in range(q):
    l,r = map(int,input().split())
    print(dp[l-1] - dp[r-1])

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



for i in range(q):
    l,r = map(int,input().split())
    s2 = s[l-1:r]
    a = s2.count("AC")
    print(a)



Fixed submission:
n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)
dp = []

for i in range (n):
    dp.append(len(indexes))
    if len(indexes)> 0 and indexes[0] == i:
        indexes.pop(0)
for i in range(q):
    l,r = map(int,input().split())
    print(dp[l-1] - dp[r-1])

Buggy python submission (verdict: Time Limit Exceeded):
import re
n,q = map(int,input().split())
#s=list(input())	
s = input()



for i in range(q):
    l,r = map(int,input().split())
    s2 = s[l-1:r]
    a = re.findall("AC", s2)
    print(len(a))



Fixed submission:
n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)
dp = []

for i in range (n):
    dp.append(len(indexes))
    if len(indexes)> 0 and indexes[0] == i:
        indexes.pop(0)
for i in range(q):
    l,r = map(int,input().split())
    print(dp[l-1] - dp[r-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s=list(input())	
	
flag = False
ans = 0
for i in range(q):
    ans = 0
    l,r = map(int,input().split())
    s2 = s[l-1:r]
    for word in s2:
        if word == "A":
            flag = True
        elif word == "C":
            if flag:
                ans += 1
                flag = False
        else:
            flag = False

    print(ans)


Fixed submission:
n,q = map(int,input().split())
#s=list(input())	
s = input()
index = -1
indexes = []
while True:
    index = s.find("AC", index + 1)
    if index == -1:
        break
    indexes.append(index)
dp = []

for i in range (n):
    dp.append(len(indexes))
    if len(indexes)> 0 and indexes[0] == i:
        indexes.pop(0)
for i in range(q):
    l,r = map(int,input().split())
    print(dp[l-1] - dp[r-1])
Buggy python submission (verdict: Runtime Error):



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)

Fixed submission:



def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


x,n = map(int,input().split())
if x == 1 and n == 1:
    print(1)
    exit()
fct = factorize(n)


divlist=[]
for div in divisorize(fct):
    divlist.append(num(div))

divlist.sort()
ans = 1
for i in range(0,len(divlist)):
    if divlist[i] <= n/x:
        ans = divlist[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import collections
def trial_division_sqrt(n):

    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1

    return prime_count
def pc(n, r):
    return math.factorial(n) // (math.factorial(n - r)  * math.factorial(r))
s=0
x,N = map(int,input().split())

li = trial_division_sqrt(N)
li = li.most_common()
ans = 1
for i in range(0, len(li)):
    ans *= pc(li[i][1] + x-1, x-1)
print(ans % (pow(10, 9)+7))

Fixed submission:
import math
import collections
def trial_division_sqrt(n):

    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[n] += 1

    return prime_count
def pc(n, r):
    return math.factorial(n) // (math.factorial(n - r)  * math.factorial(r))
nCr = {}
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p;
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result;
s=0
x,N = map(int,input().split())

li = trial_division_sqrt(N)
li = li.most_common()
ans = 1
for i in range(0, len(li)):
    ans *= cmb(li[i][1] + x-1, x-1)
print(ans % (pow(10, 9)+7))
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
x= n //(a+b)
print(x//a)

Fixed submission:
n,a,b=map(int,input().split())
x= n //(a+b) * a
r= n % (a+b)
x+=min(r,a)
print(x)