Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
    
    def calc(i,x):
        if i ==0:
            return int((x % 4 == 1) or (x % 4 == 2))
        else:
            return int((x % (2**(i+1)) >= 2**i) and (x % 2 == 0))
     
    def main():
        A,B = map(int, input().split())
        
        #2^10 > 10^3⇒ 2^10^4 > 10^3^4
        ans = 0
        for i in range(41):
            ans += 2**i*(calc(i,A-1)^calc(i,B))# ^ calc(i,B)))
        print(ans)
        
    main()

Fixed submission:
def calc(i,x):
    if i ==0:
        return int((x % 4 == 1) or (x % 4 == 2))
    else:
        return int((x % (2**(i+1)) >= 2**i) and (x % 2 == 0))

def main():
    A,B = map(int, input().split())
    
    #2^10 > 10^3⇒ 2^10^4 > 10^3^4
    ans = 0
    for i in range(41):
        ans += 2**i*(calc(i,A-1)^calc(i,B))# ^ calc(i,B)))
    print(ans)
    
main()
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
s=len(S)
#while any((S[i]== '0' and S[i+1]=='1') or (S[i]== '1' and S[i+1]=='0')for i in range(len(S)-1)

while any((S[i]== '0' and S[i+1]=='1') or (S[i]== '1' and S[i+1]=='0')for i in range(len(S)-1)):
    for j in range(len(S)-1):
        if j+1<len(S) and ((S[j]== '0' and S[j+1]=='1') or (S[j]== '1' and S[j+1]=='0')):
            S.pop(j)
            S.pop(j)

print(s-len(S))

Fixed submission:
S=input()
print(min(S.count('0'),S.count('1'))*2)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
dp = [0] * n
a = list(map(int, input().split()))
for i, h in enumerate(a):
    if i != 0:
        g = 0 if i - k < 0 else i - k
        dp[i] = min([abs(h - d) + p for d, p in zip(a[g:i], s[g:i])])
print(s[-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i,I in enumerate(h):
    if i !=0:
        j=0 if i<k else i-k
        dp[i]=min(abs(I-p)+q for p,q in zip(h[j:i],dp[j:i]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
from numpy import *
N,W=map(int,input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int,input().split())
    dp[w:]=maximum(dp[w:],dp[:-w]+v)
print(int(max(dp)))

Fixed submission:
from numpy import *
N,W=map(int,input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int,input().split())
    dp[w:]=maximum(dp[w:],dp[:-w]+v)
print(int(max(dp)))

Buggy python submission (verdict: Runtime Error):
from numpy import *
N,W=map(int,input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int,input().split())
    dp[w:]=maximum(dp[w:],dp[:-w]+v)
print(int(max(dp)))

Fixed submission:
from numpy import *
N,W=map(int,input().split())
dp=zeros(W+1)
for i in range(N):
    w,v=map(int,input().split())
    dp[w:]=maximum(dp[w:],dp[:-w]+v)
print(int(max(dp)))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
XYH=list(list(map(int,input().split())) for _ in range(N))
XYH.sort(key=lambda x: x[2])

for H in range(XYH[-1][2],XYH[-1][2]+110):
    for Cx in range(101):
        for Cy in range(101):
            if all(h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in XYH):
                a=H;b=Cx;c=Cy
                break
print(b,c,a)

Fixed submission:
N=int(input())
XYH=list(list(map(int,input().split())) for _ in range(N))
XYH.sort(key=lambda x: -x[2])

for H in range(XYH[0][2],XYH[0][2]+110):
    for Cx in range(101):
        for Cy in range(101):
            if all(h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in XYH):
                a=H;b=Cx;c=Cy
                break
print(b,c,a)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A_dis=[abs(A[0]-0)]+list(abs(A[i+1]-A[i]) for i in range(N-1))+[abs(0-A[N-1])]
for j in range(N):
    if j!=0 and j!=N-1:
        print(sum(A_dis)-abs(A[j]-A[j-1])-abs(A[j+1]-A[j])+abs(A[j+1]-A[j-1]))
    elif j==0:
        print(sum(A_dis) - abs(A[j]) - abs(A[j + 1] - A[j])+abs(A[j+1]))
    else:
        print(sum(A_dis) - abs(A[j]) - abs(A[j - 1] - A[j]) + abs(A[j - 1]))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A_dis=[abs(A[0]-0)]+list(abs(A[i+1]-A[i]) for i in range(N-1))+[abs(0-A[N-1])]
total=sum(A_dis)
for j in range(N):
    if j!=0 and j!=N-1:
        print(total-abs(A[j]-A[j-1])-abs(A[j+1]-A[j])+abs(A[j+1]-A[j-1]))
    elif j==0:
        print(total- abs(A[j]) - abs(A[j + 1] - A[j])+abs(A[j+1]))
    else:
        print(total- abs(A[j]) - abs(A[j - 1] - A[j]) + abs(A[j - 1]))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A_dis=[abs(A[0]-0)]+list(abs(A[i+1]-A[i]) for i in range(N-1))+[abs(0-A[N-1])]
for j in range(N):
    if j!=0 and j!=N-1:
        print(sum(A_dis)-abs(A[j]-A[j-1])-abs(A[j+1]-A[j])+abs(A[j+1]-A[j-1]))
    elif j==0:
        print(sum(A_dis) - abs(A[j]) - abs(A[j + 1] - A[j])+abs(A[j+1]))
    else:
        print(sum(A_dis) - abs(A[j]) - abs(A[j - 1] - A[j]) + abs(A[j - 1]))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A_dis=[abs(A[0]-0)]+list(abs(A[i+1]-A[i]) for i in range(N-1))+[abs(0-A[N-1])]
total=sum(A_dis)
for j in range(N):
    if j!=0 and j!=N-1:
        print(total-abs(A[j]-A[j-1])-abs(A[j+1]-A[j])+abs(A[j+1]-A[j-1]))
    elif j==0:
        print(total- abs(A[j]) - abs(A[j + 1] - A[j])+abs(A[j+1]))
    else:
        print(total- abs(A[j]) - abs(A[j - 1] - A[j]) + abs(A[j - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from itertools import permutations
N=int(input())
ab=list(list(map(int,input().split())) for _ in range(N))
cd=list(list(map(int,input().split())) for _ in range(N))
perab=list(itertools.permutations(ab,N))
l=[[0] for _ in range(len(perab))]
for mab in perab:
    for i in range(N):
        if cd[i][0]-mab[i][0]>0 and cd[i][1]-mab[i][1]>0:
            l[perab.index(mab)].append(1)
print(max(sum(ml) for ml in l))

Fixed submission:
import copy
N=int(input())
ab=list(list(map(int,input().split())) for _ in range(N))
cd=list(list(map(int,input().split())) for _ in range(N))
ab.sort(key=lambda x :x[1],reverse=True)#abをy座標で逆ソート
#ab.sort(key=lambda x :x[0])#abをx座標でソート
cd.sort(key=lambda x :x[0])#cdをx座標でソート
ans=0
for c,d in cd:#あるc,dに対して、適切なabを探しともに消去する
    for a,b in ab:#
        if b<d and a<c:
            ab[ab.index([a,b])]=[1000,1000] #abは糞でかく、cdはクソ小さくする
            cd[cd.index([c,d])]=[-1000,-1000]
            ans+=1
            break#次のc,dを見に行く
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
from itertools import permutations
N=int(input())
ab=list(list(map(int,input().split())) for _ in range(N))
cd=list(list(map(int,input().split())) for _ in range(N))
perab=list(itertools.permutations(ab,N))
l=[[0] for _ in range(len(perab))]
for mab in perab:
    for i in range(N):
        if cd[i][0]-mab[i][0]>0 and cd[i][1]-mab[i][1]>0:
            l[perab.index(mab)].append(1)
print(max(sum(ml) for ml in l))

Fixed submission:
import copy
N=int(input())
ab=list(list(map(int,input().split())) for _ in range(N))
cd=list(list(map(int,input().split())) for _ in range(N))
ab.sort(key=lambda x :x[1],reverse=True)#abをy座標で逆ソート
#ab.sort(key=lambda x :x[0])#abをx座標でソート
cd.sort(key=lambda x :x[0])#cdをx座標でソート
ans=0
for c,d in cd:#あるc,dに対して、適切なabを探しともに消去する
    for a,b in ab:#
        if b<d and a<c:
            ab[ab.index([a,b])]=[1000,1000] #abは糞でかく、cdはクソ小さくする
            cd[cd.index([c,d])]=[-1000,-1000]
            ans+=1
            break#次のc,dを見に行く
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=list([0]*M for _ in range(N))
if N>=2 and M>=2:
    print((N-2)*(M-2))
elif max(N,M)>=2:
    print(max(N,M)-2)
else:
    print(1)

Fixed submission:
N,M=map(int,input().split())
if N>=2 and M>=2:
    print((N-2)*(M-2))
elif max(N,M)>=2 and min(N,M)==1:
    print(max(N,M)-2)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
from itertools  import product
N,M=map(int,input().split())
L=list([0]*M for _ in range(N))
if N>=2 and M>=2:
    print((N-2)*(M-2))
elif max(N,M)>=2:
    print(max(N,M)-2)
else:
    print(1)

Fixed submission:
N,M=map(int,input().split())
if N>=2 and M>=2:
    print((N-2)*(M-2))
elif max(N,M)>=2 and min(N,M)==1:
    print(max(N,M)-2)
else:
    print(1)

Buggy python submission (verdict: Runtime Error):
from itertools  import product
N,M=map(int,input().split())
L=list([0]*M for _ in range(N))
ans=0
for x in range(N):
    for y in range(M):
        count=0
        for dx,dy in list(product([-1,0,1],repeat=2)):
            if 0<=x+dx<=N-1 and 0<=y+dy<=M-1:
                count+=1
        if count%2==1:
            ans+=1
print(ans)

Fixed submission:
N,M=map(int,input().split())
if N>=2 and M>=2:
    print((N-2)*(M-2))
elif max(N,M)>=2 and min(N,M)==1:
    print(max(N,M)-2)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
from itertools import combinations
N=int(input())
S=list(input()[0] for _ in range(N))
cS=copy.deepcopy(S)
ans=0
for i in cS:
    if i not in ['M', 'A', 'R', 'C', 'H']:
        S.remove(i)
P=list(combinations(S,3))
for i in P:
    if len(set(i))==3:
        ans+=1
print(ans)

Fixed submission:
N=int(input())
S=list(input()[0] for _ in range(N))
m=S.count('M')
a=S.count('A')
r=S.count('R')
c=S.count('C')
h=S.count('H')
print(m*a*r+m*a*c+m*a*h
      +m*r*c+m*r*h
      +m*c*h
      +a*r*c+a*r*h
      +a*c*h
      +r*c*h)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.items(),key=lambda x: -x[1])
print(sum(C[K:][i][1] for i in range(len(C[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A).most_common()
print(sum(B[K:][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=Counter(A).most_common()
print(sum(B[K:][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N,K=map(int,input().split())
A=map(int,input().split())
B=collections.Counter(A).most_common()
print(sum(B[K:][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=collections.Counter(A).most_common()

print(sum(B[::-1][:K][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Runtime Error):
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=collections.Counter(A).most_common()

print(sum(B[::-1][:K][i][1] for i in range(len(B)-K)))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=collections.Counter(A).most_common()
print(sum(B[K:][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=collections.Counter(A).most_common()
print(sum(B[K:][i][1] for i in range(len(B[K:]))))

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=input().split()
B=Counter(A)
C=sorted(B.values(),reverse=True)
print(sum(C[K:]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(int(input()) for _ in range(n))
i=1
c=1
i=a[a.index(i)-1]
while  c!=n or i == 2:
    i=a[a.index(i)-1]
    print(i)
    c+=1
print(-1 if c==n+1 else c)
print(c)
    


Fixed submission:
N=int(input())
a=list(int(input()) for _ in range(N))
ans=1
c=0
for i in range(N):
    if ans != 2:
        ans=a[ans-1]
        c+=1
    else:
        print(c)
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
import itertools
N,M=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(N))
l=list(l for l in range(1,N+1))
numlist=list(itertools.permutations(l))
ans=0
for I in numlist:
    x=0
    if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)):
        ans+=1
print(ans)

Fixed submission:
import itertools
N,M=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(M))
l=list(l for l in range(1,N+1))
numlist=list(itertools.permutations(l))
ans=0
for I in numlist:
    if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)):
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
S=list(input())
i=0
while i!=len(S):
    if i+6<=len(S) and S[i:i + 6] == ['e', 'r', 'a', 's', 'e', 'r']:
        i += 6
    elif i+5<=len(S) and S[i:i+5]==['e','r','a','s','e']:
        i+=5
    elif i+7<=len(S) and S[i:i+7]==['d','r','e','a','m','e','r'] and (len(S[i+7:])==7 or S[i+7]!='a'):
        i+=7
    elif i+5<=len(S) and S[i:i+5]==['d','r','e','a','m']:
        i+=5
    else:
        print('NO')
        exit()
print('YES')


Fixed submission:
S=list(input())
i=0
while i!=len(S):
    if i+6<=len(S) and S[i:i + 6] == ['e', 'r', 'a', 's', 'e', 'r']:
        i += 6
    elif i+5<=len(S) and S[i:i+5]==['e','r','a','s','e']:
        i+=5
    elif i+7<=len(S) and S[i:i+7]==['d','r','e','a','m','e','r'] and (len(S[i:])==7 or (S[i+7]!='a')):
        i+=7
    elif i+5<=len(S) and S[i:i+5]==['d','r','e','a','m']:
        i+=5
    else:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Runtime Error):
S=list(input())
i=0
while i!=len(S):
    if S[i:i + 6] == ['e', 'r', 'a', 's', 'e', 'r']:
        i += 6
    elif S[i:i+5]==['e','r','a','s','e']:
        i+=5
    elif S[i:i+7]==['d','r','e','a','m','e','r'] and (len(S[i+7:])==7 or S[i+7]!='a'):
        i+=7
    elif S[i:i+5]==['d','r','e','a','m']:
        i+=5
    else:
        print('NO')
        exit()
print('YES')


Fixed submission:
S=list(input())
i=0
while i!=len(S):
    if i+6<=len(S) and S[i:i + 6] == ['e', 'r', 'a', 's', 'e', 'r']:
        i += 6
    elif i+5<=len(S) and S[i:i+5]==['e','r','a','s','e']:
        i+=5
    elif i+7<=len(S) and S[i:i+7]==['d','r','e','a','m','e','r'] and (len(S[i:])==7 or (S[i+7]!='a')):
        i+=7
    elif i+5<=len(S) and S[i:i+5]==['d','r','e','a','m']:
        i+=5
    else:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
import copy
S=list(input())
while len(S)>0:
    if S[0:7]==['d','r','e','a','m','e','r'] and (len(S)==7 or S[7]!='a'):
        for _ in range(7):
            S.pop(0)
    elif S[0:5]==['d','r','e','a','m']:
        for _ in range(5):
            S.pop(0)
    elif S[0:6]==['e','r','a','s','e','r']:
        for _ in range(6):
            S.pop(0)
    elif S[0:5]==['e','r','a','s','e']:
        for _ in range(5):
            S.pop(0)
    else:
        print('NO')
        exit()
print('YES')


Fixed submission:
S=list(input())
i=0
while i!=len(S):
    if i+6<=len(S) and S[i:i + 6] == ['e', 'r', 'a', 's', 'e', 'r']:
        i += 6
    elif i+5<=len(S) and S[i:i+5]==['e','r','a','s','e']:
        i+=5
    elif i+7<=len(S) and S[i:i+7]==['d','r','e','a','m','e','r'] and (len(S[i:])==7 or (S[i+7]!='a')):
        i+=7
    elif i+5<=len(S) and S[i:i+5]==['d','r','e','a','m']:
        i+=5
    else:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().strip().split(' '))
a = list(map(str, input().strip().split(' ')))
MOD = 1000000007
# 一周期内
bn = 0
for i in range(n-1):
  for j in range(n-1-i):
    if int(a[i]) > int(a[i+j+1]):
      bn = bn + 1
# 次の周期も考える
bm = 0
for i in range(n):
  for j in range(n):
    if int(a[i]) > int(a[j]):
      bm = bm + 1
if k % 2 == 0:
  bm = (bm % MOD) * ((k // 2) % MOD) * (k-1 % MOD)
else:
  bm = (bm % MOD) * (k % MOD) * (((k-1) // 2) % MOD)
s = (bn % MOD) * (k % MOD) + (bm % MOD)
print(s % MOD)

Fixed submission:
n, k = map(int, input().strip().split(' '))
a = list(map(str, input().strip().split(' ')))
MOD = 1000000007
# 一周期内
bn = 0
for i in range(n-1):
  for j in range(n-1-i):
    if int(a[i]) > int(a[i+j+1]):
      bn = bn + 1
# 次の周期も考える
bm = 0
for i in range(n):
  for j in range(n):
    if int(a[i]) > int(a[j]):
      bm = bm + 1
if k % 2 == 0:
  bm = (bm % MOD) * ((k // 2) % MOD) * (k-1 % MOD)
else:
  bm = (bm % MOD) * (k % MOD) * (((k-1) // 2) % MOD)
s = (bn % MOD) * (k % MOD) + (bm % MOD)
print(s % MOD)
Buggy python submission (verdict: Runtime Error):
 = int(input())
v = list(map(int, input().strip().split(' ')))
c = list(map(int, input().strip().split(' ')))
l = [0] * n
for i in range(n):
  l[i]=v[i]-c[i]
l.sort(reverse=True)
s = 0
for i in range(n):
  if s < sum(l[0:i+1]):
    s = sum(l[0:i+1])
print(s)

Fixed submission:
n = int(input())
v = list(map(int, input().strip().split(' ')))
c = list(map(int, input().strip().split(' ')))
l = [0] * n
for i in range(n):
  l[i]=v[i]-c[i]
l.sort(reverse=True)
s = 0
for i in range(n):
  if s < sum(l[0:i+1]):
    s = sum(l[0:i+1])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = []
for i in range(n+1):
  cnew = s[0:i].count('#')+s[i:n].count('.')
  c.append(cnew)
print(min(c))

Fixed submission:
n = int(input())
s = input()
m = s.count('.')
ans = m
for i in range(n):
  if s[i] == '#':
    m = m + 1
  else:
    m = m - 1
  ans=min(m,ans)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
c = n
for i in range(n+1):
  cnew = s[0:i].count('#')+s[i:n].count('.')
  if cnew < c:
    c = cnew
print(c)

Fixed submission:
n = int(input())
s = input()
m = s.count('.')
ans = m
for i in range(n):
  if s[i] == '#':
    m = m + 1
  else:
    m = m - 1
  ans=min(m,ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
c = 0
sl = list(s)
sl2 = sl
k = 0
for i in range(n-2):
   if sl[i]=="#" and sl[i+1]==".":
      if sl[i+2]=="." and sl[i-1]==".":
        sl[i]='.'
        c = c + 1
      if sl[i+2]=="." and sl[i-1]=="#":
        sl[i+1]='#'
        sl[i+2]='#'
        c = c + 2
      elif sl[i+2]=='#':
        sl[i+1]='#'
        c = c + 1
if sl[n-2]=="#" and sl[n-1]==".":
  sl[i+1]='#'
  c=c+1
print(c)

Fixed submission:
n = int(input())
s = input()
m = s.count('.')
ans = m
for i in range(n):
  if s[i] == '#':
    m = m + 1
  else:
    m = m - 1
  ans=min(m,ans)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
c = 0
sl = list(s)
sl2 = sl
k = 0
for i in range(n-2):
   if sl[i]=="#" and sl[i+1]==".":
      if sl[i+2]==".":
        sl[i]='.'
        c = c + 1
      elif sl[i+2]=='#':
        sl[i+1]='#'
        c = c + 1
      #if c == 1:
       # k = i
if sl[n-2]=="#" and sl[n-1]==".":
  sl[i+1]='#'
  c=c+1
print(c)

Fixed submission:
n = int(input())
s = input()
m = s.count('.')
ans = m
for i in range(n):
  if s[i] == '#':
    m = m + 1
  else:
    m = m - 1
  ans=min(m,ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
for i in range(n-1):
    if s[i-1:i+1] == 'AC':
        ac.append(i)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(sum((x >= l and x < r) for x in ac))

Fixed submission:
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
kazu = 0
for i in range(n-1):
    if s[i:i+2] == 'AC':
        kazu = kazu + 1
        ac.append(kazu)
    else:
        ac.append(kazu)
ac.append(0)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(ac[r-2]-ac[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
for i in range(n-1):
    if s[i-1:i+1] == 'AC':
        ac.append(i)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    for i in range(len(ac)):
        if ac[i] >= l and ac[i] < r: 
            num = num + 1
    print(num)

Fixed submission:
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
kazu = 0
for i in range(n-1):
    if s[i:i+2] == 'AC':
        kazu = kazu + 1
        ac.append(kazu)
    else:
        ac.append(kazu)
ac.append(0)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(ac[r-2]-ac[l-2])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().strip().split(' '))
s = input()
for i in range(q):
    l, r = map(int, input().strip().split(' '))
    print(s[l-1:r].count('AC'))

Fixed submission:
n, q = map(int, input().strip().split(' '))
s = input()
ac = []
kazu = 0
for i in range(n-1):
    if s[i:i+2] == 'AC':
        kazu = kazu + 1
        ac.append(kazu)
    else:
        ac.append(kazu)
ac.append(0)
for i in range(q):
    num = 0
    l, r = map(int, input().strip().split(' '))
    print(ac[r-2]-ac[l-2])
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().strip().split(''))
i = 1
l = []
while len(l)<k:
    if (a%i==0 and b%i==0) or i%2==0 or i%5==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Fixed submission:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while i<=a or i<=b:
    if a%i==0 and b%i==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-k])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while len(l)<k:
    if a%i=0 and b%i=0 or i%2=0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-1])

Fixed submission:
a, b, k = map(int, input().strip().split(' '))
i = 1
l = []
while i<=a or i<=b:
    if a%i==0 and b%i==0:
        l.append(i)
    else:
        pass
    i=i+1
print(l[-k])
Buggy python submission (verdict: Runtime Error):
import math

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

count = 0
i = A
d = B - A

ta = d // C
tb = d // D
tc = d//(C * D // math.gcd(C, D))

print(d-(ta+tb-tc))

Fixed submission:
import fractions

def calc(v):
    ta = v // C
    tb = v // D
    tc = v // ((C * D) // fractions.gcd(C, D))
    return v-(ta+tb-tc)


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

count = 0
i = A
a = calc(A-1)
b = calc(B)
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split()))
As = list(map(int, input().split()))

count = 0
for i in range(N):
    sumv = 0
    for k in range(i, N):
        sumv += As[k]
        if sumv >= K:
            count += N - k
            break

print(count)

Fixed submission:

X, A = list(map(int, input().split()))
if X < A:
    print(0)
else:
    print(10)