Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=list(input())
#print(s)
i=1
a=[0]
x=0
while i!=n:
    if s[i-1]=="A":
        if s[i]=="C":
            x=x+1
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=n:
 #if n<10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s)-1:
 #if n<10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-2]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
 if n>=10000:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
 if n>100:

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):

    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)

#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)
#print(a)
i=0
while i!=q:
  try:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)
  except:
      break

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
x=0
while i!=len(s):
    if s[i]=="C" and a1==1:
        x=x+1
        a1=0
    elif s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
    a.append(x)
#print(a)
i=0
while i!=q:
    l,r=map(int,input().split())
    i=i+1
    s=a[r-1]-a[l-1]
    print(s)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
while i!=len(s):
    if s[i]=="C" and a1==1:

        a.append(1)
        a1=0
    elif s[i]=="A":
        a.append(0)
        a1=1
    else:
        a1=0
        a.append(0)
    i=i+1
#print(a)
i=0
while i!=q:
    l,r=map(int,input().split())
    i=i+1
    s=a[l:r]
    #print(s)
    print(s.count(1))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
while i!=len(s):
    if s[i]=="C" and a1==1:

        a.append(1)
    elif s[i]=="A":
        a.append(0)
        a1=1
    else:
        a1=0
        a.append(0)
    i=i+1
#print(a)
i=0
while i!=q:
    l,r=map(int,input().split())
    i=i+1
    s=a[l:r]
    #print(s)
    print(s.count(1))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
#print(s)
i=0
a=[]
while i!=len(s):
    if s[i]=="C" and a1==1:

        a.append(1)
    else:
        a.append(0)
    if s[i]=="A":
        a1=1
    else:
        a1=0
    i=i+1
#print(a)
i=0
while i!=q:
    l,r=map(int,input().split())
    print(a[l:r].count(1))
    i=i+1