qyliang/CodeNanoFix huggingface dataset:
Buggy code:
length_count = int(input())
strings = input()

abc_count = 0
a = False
b = False

strings_list = list(strings)

for i in range(length_count):
    if strings_list[i] == 'A':
        a = True
    elif strings_list[i] == 'B' and a:
        b = True
    elif strings_list[i] == 'C' and a and b:
        abc_count += 1
        a = False
        b = False
    else:
        a = False
        b = False

print(abc_count)


Fixed code:
length_count = int(input())
strings = input()

abc_count = 0
a = False
b = False

strings_list = list(strings)

for i in range(length_count):
    
    if strings_list[i] == 'A':
        a = True
        b = False

    elif strings_list[i] == 'B' and a:
        if b:
            a = False
            b = False
        b = True
        
    elif strings_list[i] == 'C' and a and b:
        abc_count += 1
        a = False
        b = False
    else:
        a = False
        b = False

print(abc_count)
Buggy code:
input()
s = input()
l = len(s)
s.replace('ABC', '')

l2 = len(s)

print(l-l2 // 3)

Fixed code:
input()
s = input()
l = len(s)
s2 = s.replace('ABC', '')
 
l2 = len(s2)
 
print((l-l2) // 3)
Buggy code:
n = int(input())
s = input()
x = list(s)
y = 0
a = 0
while y <= n - 3:
  z = x[y] + x[y + 1] + x[y + 2]
  if z == "abc":
    a += 1
    y += 1
  else:
    a += 0
    y += 1

print(a)


Fixed code:
n = int(input())
s = input()
x = list(s)
y = 0
a = 0
while y <= n - 3:
  z = x[y] + x[y + 1] + x[y + 2]
  if z == "ABC":
    a += 1
    y += 1
  else:
    a += 0
    y += 1
print(a)
Buggy code:
N=int(input())
S=input()
 
print(s.count('ABC'))

Fixed code:

N = int(input())
S = input()
print(S.count("ABC"))
Buggy code:
n = int(input())
s = input()

count = 0
for i in range(n-2):
  print(s[i:i+3])
  if s[i:i+3] == 'ABC':
    count += 1
print(count)

Fixed code:
n = int(input())
s = input()

count = 0
for i in range(n-2):
  if s[i:i+3] == 'ABC':
    count += 1
print(count)
Buggy code:
import re

input()
print(len(re.findall(input(), 'ABC'))

Fixed code:
import re

input()
print(len(re.findall('ABC', input())))
Buggy code:
N = int(input())
S = str(input())

cnt = 0

for i in range(0,len(S):
  if S[i]  == 'A' and  S[i+1] == 'B' and S[i+2] == 'C':
   cnt += 1


print(cnt)


Fixed code:
N = int(input())
S = str(input())

cnt = 0

for i in range(0,len(S)-2):
  if S[i]  == 'A' and  S[i+1] == 'B' and S[i+2] == 'C':
   cnt += 1


print(cnt)
Buggy code:
s=list(input())
num=0
if n<3:
    exit()
for i in range(n):
    if (s[i]=="A") and (s[i+1]=="B") and (s[i+2]=="C"):
        num+=1
print(num)


Fixed code:
n=int(input())
s=list(input())
num=0
if n<3:
    exit()
for i in range(n-2):
    if (s[i]=="A") and (s[i+1]=="B") and (s[i+2]=="C"):
        num+=1
print(num)
Buggy code:
n = int(input()); s = input() ; c = 0

for i in range(n):
    a = s[i-3:i]
    print(a)
    if a == 'ABC':
        c += 1
print(c)

Fixed code:
n = int(input()); s = input() ; c = 0

for i in range(n-2):
    a = s[i:i+3]

    if a == 'ABC':
        c += 1
print(c)
Buggy code:
n = int(input())
s = input()
ans = 0

for i in range(n-2):
    print(s[i:i+3])
    if s[i:i+3] == 'ABC':
        ans += 1
print(ans)

Fixed code:
n=int(input())
s=input()
count=0
for i in range(n-2):
  if s[i:i+3]=='ABC':
    count+=1
print(count)
Buggy code:
N=int(input())
S=input()

slen=len(S)
nabc=0
for i in range(0,slen-2):
  if S[i:i+2]=='ABC':
    nabc+=1

print(nabc)

Fixed code:
N=int(input())
S=input()
 
slen=len(S)
nabc=0
for i in range(0,slen-2):
  if S[i:i+3]=='ABC':
    nabc+=1
 
print(nabc)
Buggy code:
n = int(input())
s = input()
pat = "ABC"

ans =0
i=0
while i < n:
  if pat = s[i:len(pat)]:
    ans+=1

print(ans)

Fixed code:
n = int(input())
s = input()
pat = "ABC"

ans = 0
i = 0
while i < n:
    if pat == s[i : i + len(pat)]:
        ans += 1
    i += 1

print(ans)
Buggy code:
N = int(input())
words = input()
ans = 0
for i in range(N-4):
    if words[i] == "A":
        if words[i+1] == "B":
            if words[i+2] == "C":
                ans += 1
print(ans)

Fixed code:
N = int(input())
words = input()
ans = 0
for i in range(N-2):
    if words[i] == "A":
        if words[i+1] == "B":
            if words[i+2] == "C":
                ans += 1
print(ans)
Buggy code:
N=int(input())
S=input()
ans=0
for i in range(n-2):
	if S[i]+S[i+1]+S[i+2]=='ABC':
		ans+=1
print(ans)

Fixed code:
N = int(input())
S = input()

ans = 0
for i in range(N - 2):
    if S[i : i + 3] == "ABC":
        ans += 1
print(ans)
Buggy code:
n = int(input())
s = input()
i = 0
ans = 0
while i < n:
  if s[i] == 'A' and s[i:i+3] == 'ABC':
    ans += 1
print(ans)

Fixed code:
n = int(input())
s = input()
i = 0
ans = 0
while i < n:
  if s[i]=='A' and s[i:i+3]=='ABC':
    ans += 1
    i += 3
  else:
    i += 1
print(ans)
Buggy code:
n=int(input())
s=input()
cnt=0
for i in range(n-3+1):
    if s[i:i+4]=="ABC": cnt+=1
print(cnt)

Fixed code:
n=int(input())
s=input()
cnt=0
for i in range(n-3+1):
    if s[i:i+3]=="ABC": cnt+=1
print(cnt)
Buggy code:
N = int(input())
S = input()
count = 0
for i in range(N - 3 + 1):
  if S[i:i+2] == "ABC":
    count += 1
print(count)

Fixed code:
N = int(input())
S = input()
count = 0
for i in range(0,N-2):
    if S[i:i+3] == "ABC": count += 1
print(count)
Buggy code:
from functools import lru_cache
import sys

sys.setrecursionlimit(10**8)

N = int(input())
S = str(input())

@lru_cache(maxsize=None)
def dp(s):
    print(s.count("ABC"))
print(dp(S))



Fixed code:
from functools import lru_cache
import sys

sys.setrecursionlimit(10**8)

N = int(input())
S = input()

@lru_cache(maxsize=None)
def dp(s):
    result = s.count("ABC")
    return result
print(dp(S))
Buggy code:
# ABC150B - Count ABC
def main():
    N = int(input())
    S = input().rstrip()
    ans = sum(S[i + 3] == "ABC" for i in range(N - 3))
    print(ans)


if __name__ == "__main__":
    main()


Fixed code:
# ABC150B - Count ABC
def main():
    N = int(input())
    S = input().rstrip()
    ans = sum(S[i:i + 3] == "ABC" for i in range(N - 2))
    print(ans)


if __name__ == "__main__":
    main()
Buggy code:
N = int(input())
S = input()
 
num = 0
for i in range(N-2):
  if S[i:i+2] = "ABC":
    num += 1
  else:
    num += 0
print(num)

Fixed code:
N = int(input())
S = str(input())

num = 0
for i in range(N-2):
  if S[i:i+3] == "ABC":
    num += 1
  else:
    num += 0
print(num)
Buggy code:
N = int(input())
S = list(input())

stage = 0
count = 0
for i in range(N):
    if(S[i]=="A"):
        stage = 1
    if(stage==1) and (S[i]=="B"):
        stage = 2
    if(stage==2) and (S[i]=="C"):
        stage = 0
        count += 1

print(count)

Fixed code:
N = int(input())
S = list(input())

stage = 0
count = 0
for i in range(N):
    if(S[i]=="A"):
        stage = 1
        continue
    if(stage==1) and (S[i]=="B"):
        stage = 2
        continue
    if(stage==2) and (S[i]=="C"):
        stage = 0
        count += 1
        continue
    stage = 0
    

print(count)
Buggy code:
N=int(input())
S=input()
ans=0
for i in range(N-2):
    if S[i:i+3]=='abc' :
        ans+=1
print(ans)

Fixed code:
N=int(input())
S=input()
ans=0
for i in range(N-2):
    if S[i:i+3]=='ABC' :
        ans+=1
print(ans)
Buggy code:
N = int(input())
S=str(input())
cnt=0
for i in range(N-2):
    if S[i] =='A' and S[i+1]=='B' and S[i+2]=='C':
        cnt+=1

Fixed code:
N = int(input())
S=str(input())
cnt=0
for i in range(N-2):
    if S[i] =='A' and S[i+1]=='B' and S[i+2]=='C':
        cnt+=1
print(cnt)
Buggy code:
N = int(input())
S = input()

count = 0
for i in range(N-3):
  if S[i]S[i+1]S[i+2] == ABC:
    count = +1
  else:
    continue
print(count)

Fixed code:
N = int(input())
S = input()

count = 0
for i in range(N-2):
  if S[i]+S[i+1]+S[i+2] == "ABC":
    count += 1
  else:
    continue
    
print(count)
Buggy code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


def main():
    N = int(input())
    S = input()

    count = 0
    state = 0

    for c in S:
        if c == 'A':
            state = 1
        elif state == 1:
            if c == 'B':
                state = 2
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count = 2
                state = 0
            else:
                state = 0

    print(count)


main()


Fixed code:
#from math import sqrt
#from heapq import heappush, heappop
#from collections import deque

#a, b = [int(v) for v in input().split()]


def main():
    N = int(input())
    S = input()

    count = 0
    state = 0

    for c in S:
        if c == 'A':
            state = 1
        elif state == 1:
            if c == 'B':
                state = 2
            else:
                state = 0
        elif state == 2:
            if c == 'C':
                count += 1
            state = 0

    print(count)


main()
Buggy code:
a = int(input())
b = input()
print(a.count('ABC'))


Fixed code:
a = int(input())
b = input()
print(b.count('ABC'))
Buggy code:
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        state = 0
        if c != check[state]:
            state = 1
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)



Fixed code:
_ = input()
s = input()

check = ['A', 'B', 'C']

count = 0
state = 0

for i in range(len(s)):
    c = s[i]
    if c != check[state]:
        if c == check[0]:
            state = 1
        else:
            state = 0
        continue
    
    state += 1
    if state == 3:
        count += 1
        state = 0

print(count)
Buggy code:
s1=input()

count=0
for i in range ((len(s1))-2):
    if(s1[i]=='A' and s1[i+1]=='B' and s1[i+2]=='C'):
        count=count+1
    
print(count)


Fixed code:
n=input()
s1= input()

count=0
for i in range(len(s1)-2):
    if(s1[i]=='A' and  s1[i+1]=='B' and s1[i+2]=='C'):
        count=count+1

print(count)
Buggy code:
count=0
N=input()
S=input()
N=int(N)
for i in range(N-2):
  if(S[i]=="A" and S[i+1]=="B" and S[i+2]=="C"):
    count++
print(count)

Fixed code:
count=0
N=input()
S=input()
N=int(N)
for i in range(N-2):
  if(S[i]=="A" and S[i+1]=="B" and S[i+2]=="C"):
    count+=1
print(count)
Buggy code:
N=int(input())
S=input()
count=0
for i in range(N-2):
  if(S[i:3:]=="ABC"):
    count+=1
print(count)

Fixed code:
N = int(input())
S = input()

t = 0
for i in range(N-2):
    if S[i:i+3] == "ABC":
        t += 1

print(t)
Buggy code:
s = input()
print(s.count('ABC'))

Fixed code:
input()
s = input()
print(s.count('ABC'))
Buggy code:
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-3):
  	if S[i:i+3] == "ABC":
    	ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)

Fixed code:
N = int(input())
S = input()
ans = 0
if N > 3:
  for i in range(N-2):
    if S[i:i+3] == "ABC":
      ans += 1
else:
  ans = 1 if S == "ABC" else 0
print(ans)
Buggy code:
def main():
    n = int(input())
    s = input()

    prev = ''
    c = 0

    for i in s:
        if prev == '':
            if i == 'A':
                prev = 'A'
        elif prev == 'A':
            if i == 'A':
                pass
            elif i == 'A':
                prev = 'B'
            else:
                i == ''
        elif prev == 'B':
            if i == 'A':
                prev = 'A'
            elif i == 'C':
                c += 1
                prev = ''
            else:
                prev = ''

    print(c)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    s = input()

    prev = ''
    c = 0

    for i in s:
        if prev == '':
            if i == 'A':
                prev = 'A'
        elif prev == 'A':
            if i == 'A':
                prev = 'A'
            elif i == 'B':
                prev = 'B'
            else:
                prev = ''
        elif prev == 'B':
            if i == 'A':
                prev = 'A'
            elif i == 'C':
                c += 1
                prev = ''
            else:
                prev = ''

    print(c)


if __name__ == '__main__':
    main()
Buggy code:
s = input()
cnt = 0
    for i in range(n):
        if i == n-2 or i== n-1 :
            continue
        if s[i]== "A" and s[i+1] == "B" and s[i+2] == "C" :
            cnt+=1
    print(cnt)

Fixed code:
n = int(input())
s = input()
cnt = 0
for i in range(n):
    if i == n-2 or i== n-1 :
        continue
    if s[i]== "A" and s[i+1] == "B" and s[i+2] == "C" :
        cnt+=1
print(cnt)
Buggy code:
i = int(input())
j = input()
    
print(count('ABC'))

Fixed code:
i = int(input())
j = input()
    
print(j.count('ABC'))
Buggy code:
n = int(input())
s = input()
cnt = 0
    for i in range(n):
        if i == n-2 or i== n-1 :
            continue
        if s[i]== "A" and s[i+1] == "B" and s[i+2] == "C" :
            cnt+=1
    print(cnt)

Fixed code:
n=int(input())
s=input()
cnt=0
for i in range(n-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    cnt+=1
print(cnt)
Buggy code:
from functools import reduce
from math import ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

start = 0
a_max = a[-1]
while a_max * (start + 0.5) <= m:
    flag = True
    for i in range(len(a)-1):
        num = (a_max * (start + 0.5) / a[i]) - 0.5
        if num.is_integer():
            continue
        else:
            flag = False
            break
    if flag:
        break
    else:
        start += 1

if a_max * (start + 0.5) > m:
    print(0)
    exit()

ans = 0
base_num = int(a_max * (start + 0.5))

d = reduce(lcm, a)
ans = int(1 + ((m - base_num) // d))
print(base_num, d)
print(ans)




Fixed code:
from functools import reduce
from math import ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
a.sort()

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

start = 0
a_max = a[-1]
while a_max * (start + 0.5) <= m:
    flag = True
    for i in range(len(a)-1):
        num = (a_max * (start + 0.5) / a[i]) - 0.5
        if num.is_integer():
            continue
        else:
            flag = False
            break
    if flag:
        break
    else:
        start += 1

if a_max * (start + 0.5) > m:
    print(0)
    exit()

ans = 0
base_num = int(a_max * (start + 0.5))

d = reduce(lcm, a)
ans = int(1 + ((m - base_num) // d))
print(ans)
Buggy code:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a//gcd(a, b)*b

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
cnt = [0]*N

for i in range(N):
    t = b[i]
    
    while t%2==0:
        cnt[i] += 1
        t //= 2
    
if cnt!=cnt[0]*N:
    print(0)
    exit()

L = 1

for bi in b:
    L = lcm(L, bi)

if L>M:
    print(0)
else:
    print((M-L)//(2*L)+1)

Fixed code:
import sys
input = sys.stdin.readline

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

def lcm(a, b):
    return a*b//gcd(a, b)

N, M = map(int, input().split())
a = list(map(int, input().split()))
b = [ai//2 for ai in a]
cnt = [0]*N

for i in range(N):
    tmp = b[i]
    
    while tmp%2==0:
        tmp //= 2
        cnt[i] += 1

if len(set(cnt))!=1:
    print(0)
    exit()
    
L = 1

for bi in b:
    L = lcm(L, bi)

L2 = 1

for ai in a:
    L2 = lcm(L2, ai)

if L>M:
    print(0)
else:
    print((M-L)//L2+1)
Buggy code:
from fractions import gcd

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))

a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)
temp=m//lcma
print(temp//2 if temp%2==0 else temp//2+1)

Fixed code:
from math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
a=list(map(lambda x: x//2, a))

def lcm(q):
  x = q[0]
  for i in range(1, len(q)):
    x = (x * q[i]) // gcd(x, q[i])
  return x

lcma=lcm(a)
for i in range(len(a)):
  if (lcma//a[i])%2==0:
    print(0)
    exit()
temp=m//lcma
print(temp//2 if temp%2==0 else temp//2+1)
Buggy code:
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=l[0]//2
for i in range(n-1):
    a=lcm(a,l[i+1]//2)
 
ok = True
for aa in l:
    if (a//aa) % 2 != 1:
        ok = False
        break
ans = 0
if ok:
    ans = ((m//a)+1)//2
print(ans)

Fixed code:
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=l[0]//2
for i in range(n-1):
    a=lcm(a,l[i+1]//2)
 
ok = True
for i in range(n):
  if (a//(l[i]//2))%2!=1:
    ok=False
    break
ans = 0
if ok:
    ans = ((m//a)+1)//2
print(ans)
Buggy code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n%1==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[i]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)

Fixed code:
from math import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def evencount(n):
  cnt=0
  while n%2==0:
    cnt+=1
    n//=2
  return cnt
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  a[i]//=2
if all(evencount(i) == evencount(a[0]) for i in a):
  d=lcm(*a)
  print((m+d)//2//d)
else:print(0)
Buggy code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
from fractions import gcd

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)

for i in b:
    if lb//i % 2 == 0:
        print(0)
        quit()
 
if lb > m:
    print(0)
    quit()

ans = m//lb//2 + (m // lb) % 2
print(ans)

Fixed code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m // gcd(n,m)


n,m = LI()
a = LI()
b = [i//2 for i in a]

lb = 1
for i in b:
    lb = lcm(lb,i)
    if lb > m:
        print(0)
        quit()

for i in b:
    if lb//i % 2 == 0:
        ans = 0
        break
else:
    if lb > m:
        ans = 0
    else:
        ans = (m//lb + 1)//2
print(ans)
Buggy code:
import sys
input=lambda: sys.stdin.readline().rstrip()

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]
ct=0
s=A[0]
while s:
  if s%2==0:
    s//=2
    ct+=1
  else:
    s=0
chk=True
for i in range(1,n):
  cur=0
  a=A[i]
  while a:
  if a%2==0:
    a//=2
    cur+=1
  else:
    a=0
  if cur!=ct:
    chk=False
    break


def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
if not chk:
  print(0)
else:
  lcm=A[0]
  for i in range(1,n):
    lcm*=A[i]//gcd(lcm,A[i])
  print((m//lcm+1)//2)

Fixed code:
import sys
input=lambda: sys.stdin.readline().rstrip()

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]
ct=0
s=A[0]
while s:
  if s%2==0:
    s//=2
    ct+=1
  else:
    s=0
chk=True
for i in range(1,n):
  cur=0
  a=A[i]
  while a:
    if a%2==0:
      a//=2
      cur+=1
    else:
      a=0
  if cur!=ct:
    chk=False
    break


def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
if not chk:
  print(0)
else:
  lcm=A[0]
  for i in range(1,n):
    lcm*=A[i]//gcd(lcm,A[i])
  print((m//lcm+1)//2)
Buggy code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def div2(x):
    c = 0
    while x%2==0:
        x //= 2
        c+=1
    return c

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[0])
    for i in range(1, N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    M//=L
    ans = (M-L)//(2*L)+1
    return ans

print(test())

Fixed code:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

def div2(x):
    c = 0
    while x%2==0:
        x //= 2
        c+=1
    return c

def test():
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N):
        if a[i]%2 == 1:
            return 0
        a[i] //= 2

    t = div2(a[0])
    for i in range(N):
        if div2(a[i]) != t:
            return 0
        a[i] >>= t
    M >>= t

    L = a[0]
    for i in range(1, N):
        L = lcm(L, a[i])
        if L > M:
            return 0

    ans = (M-L)//(2*L)+1
    return ans

print(test())
Buggy code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(a[i]//2)

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

now = b[0]
for i in range(1, n):
	now = lcm(now, b[i])

for i in range(n):
	if (now//b[i])%2 == 0:
		print(0)
		exit(0)

print(((m//now)+1)//2)


Fixed code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

now = a[0]
for i in range(1, n):
	now = lcm(now, a[i])
	if now > 2 * m:
		print(0)
		exit(0)

for i in range(n):
	if (now//a[i])%2 == 0:
		print(0)
		exit(0)

print(((m//(now//2))+1)//2)
Buggy code:
import math
from functools import reduce


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))


Fixed code:
import math
from functools import reduce


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


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while ai % 2 == 0:
        ai //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))