Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[[0 for h in range(n)] for i in range(2**n)]
b=[[0 for i in range(m)] for h in range(2**n)]
#0~2**n-1を2進数表記し、リストaに記録する(各位の10はスイッチのonoffに対応)
for i in range(2**n):
  b=i
  for j in range(n):
    c=b//(2**(n-j-1))
    a[i][j]+=c
    b-=c*(2**(n-j-1))
print(a)
#それぞれの数について、電球が点灯するかどうかを検証する（各位が電球の点灯する条件を満たしているか）
for i in range(m):
  for j in range(2**n):
    lights=list(map(int,input().split()))
    for h in range(len(lights)-1):
      b[j][i]+=a[j][lights[h+1]-1]
check=list(map(int,input().split()))
#検証パート
ans=0
for i in range(2**n):
  flag=0
  for j in range(m):
    if b[i][j]%2!=check[j]:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
a=[[0 for h in range(n)] for i in range(2**n)]
b1=[[0 for i in range(m)] for h in range(2**n)]
#0~2**n-1を2進数表記し、リストaに記録する(各位の10はスイッチのonoffに対応)
for i in range(2**n):
  b=i
  for j in range(n):
    c=b//(2**(n-j-1))
    a[i][j]+=c
    b-=c*(2**(n-j-1))
#それぞれの数について、電球が点灯するかどうかを検証する（各位が電球の点灯する条件を満たしているか）
for i in range(m):
  lights=list(map(int,input().split()))
  for j in range(2**n):
    for h in range(len(lights)-1):
      b1[j][i]+=a[j][lights[h+1]-1]
check=list(map(int,input().split()))
#検証パート
ans=0
for i in range(2**n):
  flag=0
  for j in range(m):
    if b1[i][j]%2 != check[j]:
      flag=1
      break
  if flag==0:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,k+1):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)


Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,min(k+1,n+1)):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,k+1):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    print(have)
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)


Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,min(k+1,n+1)):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(k):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    for h in range(k-i):
      if have[0]>=0:
        break
      del have[0]
    #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)

Fixed submission:
n,k=map(int,input().split())
d=list(map(int,input().split()))
d=d*2
ans=0
for i in range(1,min(k+1,n+1)):
  
  for j in range(i+1):
    have=[d[n+c-j] for c in range(i)] #ここにi個の宝石を入れる
    have.sort()
    if i!=k:
      for h in range(k-i):
        if have==[] or have[0]>=0:
          break
        del have[0]
      #いらない宝石を可能な限り詰めた状態
    if sum(have)>ans:
      ans=sum(have)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
s= input()
if s[k-1] == "A":
  s[k-1] = "a"
elif s[k-1] == "B":
  s[k-1] ="b"
elif s[k-1] =="C":
  s[k-1] = "c"
print(s)

Fixed submission:
n,k = map(int,input().split())
s= input()
a=""
for i in range(len(s)):
    c = s[i]
    if i == k-1:
      if s[k-1] == "A":
        c = "a"
      elif s[k-1] == "B":
        c = "b"
      elif s[k-1] =="C":
        c = "c"
    a = a+c
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
ans = 0
for i in range(n):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)


Fixed submission:
n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
ans = 0
for i in range(n):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)

Fixed submission:
n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
ans = 0
for i in range(n):
    if i >= k:
      ans += float(1/n)
    else:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans +=float(1/(n*(2**d)))
print(ans)

Fixed submission:
n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 0
 for i in range(n):
    if i => k:
      ans += float(1/n)
    else:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans +=float(1/n*(2**d))
print(ans)

Fixed submission:
n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)
Buggy python submission (verdict: Runtime Error):
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[str(i) for i in range(2**m-1)]
  ris.remove(str(k))
  l=" ".join(ris)
  r=" ".join(ris[::-1])
  print(l,str(k),r,str(k))

Fixed submission:
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[str(i) for i in range(2**m)]
  ris.remove(str(k))
  l=" ".join(ris)
  r=" ".join(ris[::-1])
  print(l,str(k),r,str(k))

Buggy python submission (verdict: Runtime Error):
m,k=map(int,input().split())
if k>=2**m-1:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[i for i in range(m)]
  ris.remove(k)
  print(ris+k+ris[::-1]+k)

Fixed submission:
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[str(i) for i in range(2**m)]
  ris.remove(str(k))
  l=" ".join(ris)
  r=" ".join(ris[::-1])
  print(l,str(k),r,str(k))

Buggy python submission (verdict: Runtime Error):
m,k=map(int,input().split())
if m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[i for i in range(m)]
  ris.remove(k)
  print(ris+k+ris[::-1]+k)

Fixed submission:
m,k=map(int,input().split())
if k>=2**m:
  print(-1)
elif m==0:
  print(0,0)
elif m==1:
  if k==0:
    print(0,0,1,1)
  elif k==1:
    print(-1)
else:
  ris=[str(i) for i in range(2**m)]
  ris.remove(str(k))
  l=" ".join(ris)
  r=" ".join(ris[::-1])
  print(l,str(k),r,str(k))
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)


Fixed submission:
n,k = map(int,input().split())
print(n-k+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+ab-1)
else:
    print(ans+min(a,b)+ab)


Fixed submission:
n,k = map(int,input().split())
print(n-k+1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
print(ans+c-1+min(a,b))

Fixed submission:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [list(input()) for i range(n)]
cnt = 0
cnt_A=0
cnt_B=0
cnt_C=0
for i in range(n):
  if "AB" in a[i]:
    cnt+= 1
for i in range(n):
  if a[i][-1] == "A" and a[i][0] =="B":
    cnt_C+=1  
  elif a[i][-1] == "A" and a[i][0] !="B":
    cnt_A +=1
  elif a[i][0] =="B"and a[i][-1] !="A":
    cnt_B+=1

print(cnt+cnt_A+cnt_B+cnt_C)


Fixed submission:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [list(input()) for i range(n)]
cnt = 0
cnt_A=0
cnt_B=0
cnt_C=0
for i in range(n):
  if "AB" in a[i]:
    cnt+= 1
for i in range(n):
  if a[i][-1] == "A" and a[i][0] =="B":
    cnt_C+=1  
  elif a[i][-1] == "A": 
    cnt_A +=1
  elif a[i][0] =="B":
    cnt_B+=1

print(cnt+cnt_A+cnt_B+cnt_C)


Fixed submission:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [list(input()) for i range(n)]
cnt = 0
cnt_A=0
cnt_B=0
cnt_C=0
for i in range(n):
  if "AB" in a[i]:
    cnt+= 1
for i in range(n):
  if a[i][-1] == "A" 
    cnt_A +=1
  elif a[i][0] =="B":
    cnt_B+=1
  elif a[i][-1] == "A" and a[i][0] =="B":
    cnt_C+=1
print(cnt+cnt_A+cnt_B-cnt_C)

Fixed submission:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w=map(int,input().split())
ans=0
field=[["*" for i in range(w+2)]]+[["*"]+list(input())+["*"] for i in range(h)]+[["*" for i in range(w+2)]]
queue=deque([])
for H in range(h+2):
    for W in range(w+2):
        if field[H][W]=="#":
            queue.append((H,W))
            field[H][W]=0
        elif field[H][W]==".":
          field[H][W]=-1
move=[(0,1),(0,-1),(1,0),(-1,0)]
ans=0
while queue:
    pos=queue.popleft()
    for i in move:
      if field[pos[0]+i[0]][pos[1]+i[1]]!=-1:continue
      if field[pos[0]+i[0]][pos[1]+i[1]]=="*":continue
      field[pos[0]+i[0]][pos[1]+i[1]]=field[pos[0]][pos[1]]+1
      queue.append((pos[0]+i[0],pos[1]+i[1]))
      if ans < field[pos[0]+i[0]][pos[1]+i[1]]:ans=field[pos[0]+i[0]][pos[1]+i[1]]
print(ans)

Fixed submission:
from collections import deque
h,w=map(int,input().split())
ans=0
field=[["*" for i in range(w+2)]]+[["*"]+list(input())+["*"] for i in range(h)]+[["*" for i in range(w+2)]]
queue=deque([])
for H in range(h+2):
    for W in range(w+2):
        if field[H][W]=="#":
            queue.append((H,W))
            field[H][W]=0
        elif field[H][W]==".":
          field[H][W]=-1
move=[(0,1),(0,-1),(1,0),(-1,0)]
ans=0
while queue:
    pos=queue.popleft()
    for i in move:
      if field[pos[0]+i[0]][pos[1]+i[1]]!=-1:continue
      if field[pos[0]+i[0]][pos[1]+i[1]]=="*":continue
      field[pos[0]+i[0]][pos[1]+i[1]]=field[pos[0]][pos[1]]+1
      queue.append((pos[0]+i[0],pos[1]+i[1]))
      if ans < field[pos[0]+i[0]][pos[1]+i[1]]:ans=field[pos[0]+i[0]][pos[1]+i[1]]
print(ans)

Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
e = [[input() for i in range(W)]for c in range(H)]
a = []
b = []
for i in range(W):
  for c in range(H):
    if c =="#":
      a.append(int(c+i))
for x in range(a):
  for y in range(H*W):
    b.append(abs(a[x]-y))
print(max(b))

Fixed submission:
from collections import deque
h,w=map(int,input().split())
ans=0
field=[["*" for i in range(w+2)]]+[["*"]+list(input())+["*"] for i in range(h)]+[["*" for i in range(w+2)]]
queue=deque([])
for H in range(h+2):
    for W in range(w+2):
        if field[H][W]=="#":
            queue.append((H,W))
            field[H][W]=0
        elif field[H][W]==".":
          field[H][W]=-1
move=[(0,1),(0,-1),(1,0),(-1,0)]
ans=0
while queue:
    pos=queue.popleft()
    for i in move:
      if field[pos[0]+i[0]][pos[1]+i[1]]!=-1:continue
      if field[pos[0]+i[0]][pos[1]+i[1]]=="*":continue
      field[pos[0]+i[0]][pos[1]+i[1]]=field[pos[0]][pos[1]]+1
      queue.append((pos[0]+i[0],pos[1]+i[1]))
      if ans < field[pos[0]+i[0]][pos[1]+i[1]]:ans=field[pos[0]+i[0]][pos[1]+i[1]]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list[int,input().split()]
B = list[int,input().split()]
i = 0
for c in range(N):
  if A[c]>B[c]:
    i = i +A[c]-B[c]
print (i)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
i = 0
for c in range(N):
  if A[c]>B[c]:
    i = i +A[c]-B[c]
print (i)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list[int,input().split()]
B = list[int,input().split()]
i = 0
for c in range(N):
  if A[c]>B[c]:
    i += (A[c]-B[c])
print (i)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
i = 0
for c in range(N):
  if A[c]>B[c]:
    i = i +A[c]-B[c]
print (i)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A == B:
    print(A+B)
elif A >= B:
    print(2*A-1)
else:
    print(2*B-1)

Fixed submission:
a,b=map(int,input().split())
if a==b:
  print(2*a)
elif a>b:
  print(2*a-1)
else:
  print(2*b-1)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s+="2";c=1
p=[]
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    p.append(c)
    c=1
    continue
  c+=1
if s[0]=="1":
  d=sum(p[:min(2*k+1,len(p))])
  ans=sum(p[:min(2*k+1,len(p))])
  if 2*k+1>=len(p):
    print(ans)
  else:
    m=len(p)-2*k-1
    for i in range(m):
      d-=p[i]
      d+=p[i+m]
      if d>ans:ans=d
    print(ans)
else:
  p=[1]+p
  flag=0
  d=sum(p[:min(2*k+1,len(p))])
  ans=sum(p[:min(2*k+1,len(p))])
  if 2*k+1>=len(p):
    print(ans-1)
  else:
    m=len(p)-2*k-1
    for i in range(m):
      d-=p[i]
      d+=p[i+m]
      if d>ans:
        ans=d
        flag=1
    if flag==0:
      print(ans-1)
    else:
      print(ans)

Fixed submission:
n,k=map(int,input().split())
s=input()
s+="6"
c=0
l=[]
zcnt=0
for i in range(n):
  if s[i]!=s[i+1]:
    if s[i]=="0":zcnt+=1
    l.append((s[i],i+1-c))
    c=i+1
L=len(l)
sl=[0]*(L+1)
for i in range(L):
    sl[i+1]=sl[i]+l[i][1]
if k>=zcnt:print(n);exit()
ans=0
if s[0]=="0":
    for i in range(zcnt-k+1):
        ans=max(ans,sl[min(L,2*k+i*2)]-sl[max(0,i*2-1)])
    print(ans)
else:
    for i in range(zcnt-k+1):
        ans=max(ans,sl[min(L,2*k+i*2+1)]-sl[i*2])
    print(ans)

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

Fixed submission:
n,k=map(int,input().split())
s=input()
s+="6"
c=0
l=[]
zcnt=0
for i in range(n):
  if s[i]!=s[i+1]:
    if s[i]=="0":zcnt+=1
    l.append((s[i],i+1-c))
    c=i+1
L=len(l)
sl=[0]*(L+1)
for i in range(L):
    sl[i+1]=sl[i]+l[i][1]
if k>=zcnt:print(n);exit()
ans=0
if s[0]=="0":
    for i in range(zcnt-k+1):
        ans=max(ans,sl[min(L,2*k+i*2)]-sl[max(0,i*2-1)])
    print(ans)
else:
    for i in range(zcnt-k+1):
        ans=max(ans,sl[min(L,2*k+i*2+1)]-sl[i*2])
    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())
if a==b and b==c:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c=map(int,input().split())
if a==b and b==c:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
array = [A,T,G,C]
b = input()
if b == array[0]:
  print (array[1])
elif b == array[1]:
  print (array[0])
elif b == array[2]:
  print (array[3])
else:
  print (array[2])

Fixed submission:
b = input()
if b == "T":
  print ("A")
elif b == "A":
  print ("T")
elif b == ("G"):
  print ("C")
else:
  print ("G")

Buggy python submission (verdict: Runtime Error):
b = input()
if b == "T":
  print "A"
elif b == "A":
  print "T"
elif b == "G":
  print "C"
else:
  print "G"

Fixed submission:
b = input()
if b == "T":
  print ("A")
elif b == "A":
  print ("T")
elif b == ("G"):
  print ("C")
else:
  print ("G")

Buggy python submission (verdict: Runtime Error):
b = input()
if b == T:
  print A
elif b == A:
  print T
elif b == G:
  print C
else:
  print G

Fixed submission:
b = input()
if b == "T":
  print ("A")
elif b == "A":
  print ("T")
elif b == ("G"):
  print ("C")
else:
  print ("G")
Buggy python submission (verdict: Runtime Error):
S = input()
m = 0
n = 0
lst = []
for i in range(len(S)):
  n += 1
  if i not in "ACGT":
    lst.append(n)
for y in range(len(lst)-1):
  if (lst[y+1] - lst[y]) > m:
    m = (lst[y+1] - lst[y])
print (m-1)
  

Fixed submission:
S = input()
S ="w"+ S + "w"
m = 0
n = 0
lst = []
for i in S:
  n += 1
  if i not in "ACGT":
    lst.append(n)
for y in range(len(lst)-1):
  if (lst[y+1] - lst[y]) > m:
    m = (lst[y+1] - lst[y])
print (m-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
ac=[]
for i in range(n-1):
  if s[i:i+2]=="AC":
    ac.append(i)
for i in range(q):
  l,r=map(int,input().split())
  print(sum(1 for i in ac if l-1<=i<=r-2))

Fixed submission:
n,q=map(int,input().split())
s=input()
ac=[0]*n
for i in range(n-1):
  if s[i:i+2]=="AC":
    ac[i]=ac[i-1]+1
  else:
    ac[i]=ac[i-1]
for i in range(q):
  l,r=map(int,input().split())
  if l==1:
    print(ac[r-2])
  else:
    print(ac[r-2]-ac[l-2])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=0
for i in range(n-1):
  ans+=1
  for j in range(i+1,n+1):
    if s[i]==s[j]:
      break
    ans+=1
  ans%=(10**9+7)
ans+=1
ans%=10**9+7
print(ans)


Fixed submission:
n=int(input())
s=input()
mod=10**9+7
ans=1
lets=[1]*26
for i in s:
  lets[ord(i)-97]+=1
for i in range(26):
  ans*=lets[i]
  ans%=mod
print(ans-1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=0
for i in range(n):
  ans+=1
  for j in range(i+1,n+1):
    if s[i]==s[j]:
      break
    ans+=1
  ans%=(10**9+7)
print(ans)

Fixed submission:
n=int(input())
s=input()
mod=10**9+7
ans=1
lets=[1]*26
for i in s:
  lets[ord(i)-97]+=1
for i in range(26):
  ans*=lets[i]
  ans%=mod
print(ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
for i in range(a,b+1):
  if i==a:
    ans=a
  else:
    ans=(ans^i)
print(ans)

Fixed submission:
a,b=map(int,input().split())
if a%2==0:
  if b%2==1:
    print(((b-a+1)//2)%2)
  else:
    c=((b-a)//2)%2
    print(b^c)
else:
  if b%2 == 1:
    c=((b-a)//2)%2
    print(a^c)
  else:
    c=((b-a-1)//2)%2
    print((c^a)^b)
Buggy python submission (verdict: Runtime Error):
import math 
a,b,c = map(int,input().split())
d = math.gcd(a,b)
lst=[]
for i in range(d):
  if d % (d-i) == 0:
    lst.append(i)
print(d-lst[c-1])

Fixed submission:
import fractions
a,b,c = map(int,input().split())
d = fractions.gcd(a,b)
lst=[]
for i in range(d):
  if d % (d-i) == 0:
    lst.append(i)
print(d-lst[c-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
bridges=[list(map(int,input().split())) for i in range(m)][::-1]
inconv=[n*(n-1)//2]*m
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
        
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
uf = UnionFind(n)
for i in range(m-1):
    if uf.issame(bridges[i][0]-1,bridges[i][1]-1):
        inconv[i+1]=inconv[i]
        continue
    inconv[i+1]=inconv[i]-uf.getsize(bridges[i][0]-1)*uf.getsize(bridges[i][1]-1)
    uf.merge(bridges[i][0]-1,bridges[i][1]-1)
for i in range(m):
    print(inconv[m-i-1])

Fixed submission:
import sys
sys.setrecursionlimit(100003)
n,m=map(int,input().split())
bridges=[list(map(int,input().split())) for i in range(m)][::-1]
inconv=[n*(n-1)//2]*m
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
        
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def getsize(self, x):
        return self.size[self.root(x)]
uf = UnionFind(n)
for i in range(m-1):
    if uf.issame(bridges[i][0]-1,bridges[i][1]-1):
        inconv[i+1]=inconv[i]
        continue
    inconv[i+1]=inconv[i]-uf.getsize(bridges[i][0]-1)*uf.getsize(bridges[i][1]-1)
    uf.merge(bridges[i][0]-1,bridges[i][1]-1)
for i in range(m):
    print(inconv[m-i-1])
Buggy python submission (verdict: Runtime Error):
a=int(input())
ans=0
for i in range(a):
  c,d=map(str,input().split())
  if d=="JPY":
    ans+=int(c)
  else:
    ans+=float(int(c)*380000)
print(ans)


Fixed submission:
a=int(input())
ans=0
for i in range(a):
  c,d=map(str,input().split())
  if d=="JPY":
    ans+=int(c)
  else:
    ans+=float(c)*380000
print(ans)

Buggy python submission (verdict: Runtime Error):
a=int(input())
ans=0
for i in range(a):
  c,d=map(str,input().split())
  if d=="JPY":
    ans+=int(c)
  else:
    ans+=float(c*380000)
print(ans)

Fixed submission:
a=int(input())
ans=0
for i in range(a):
  c,d=map(str,input().split())
  if d=="JPY":
    ans+=int(c)
  else:
    ans+=float(c)*380000
print(ans)