Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def search(m,n,l): //startCは常に満たす、stopC+1は常に満たさない
  if l[0]<=m: return 0
  elif l[n-1]>m: return n
  startC,stopC=0,n-1
  while startC-stopC!=0:
    if l[(stopC-startC)>>1]<=m:
      stopC=startC-1+(stopC-startC)>>1
    else:
      startC+=(stopC-startC)>>1
  return stopC+1

n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    ans+=search(l[i]-l[j],n,l[j+1:]) //l[i]-l[j]<l[ans]を満たす最小のansを求める
print(ans)

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-1,1,-1):
  for j in range(i-1,0,-1):
    ans+=j-bisect.bisect_left(l,l[i]-l[j]+1,hi=j)
print(ans)

Buggy python submission (verdict: Runtime Error):
def search(m,n,l): //startCは常に満たす、stopCは常に満たさない
  if l[0]<=m: return 0
  elif l[n-1]>m: return n
  startC,stopC=0,n
  while startC-stopC+1!=0:
    if l[(stopC-startC)>>1]>m:
      stopC=startC+(stopC-startC)>>1
    else:
      startC+=(stopC-startC)>>1
  return stopC

n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(n-2):
  for j in range(1,n-i-1):
    ans+=search(l[i]-l[j+i+1],n,l[j+i+2]) //l[i]-l[j]<l[ans]を満たす最小のansを求める

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n-1,1,-1):
  for j in range(i-1,0,-1):
    ans+=j-bisect.bisect_left(l,l[i]-l[j]+1,hi=j)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
def dist(a,b,d):
  distance=0
  for i in range(d):
    distance+=(a[i]-b[i])**2
  return distance
n,d=map(int,input().split())
x=[]
c=0
for i in range(n):
  x.append(list(map(int,input().split())))
for i in range(1,n):
  for j in range(i-1):
    k=dist(x[i],x[j])
    if k==(int(math.sqrt(k)))**2:
      c+=1

Fixed submission:
import math
def dist(a,b,d):
  distance=0
  for i in range(d):
    distance+=(a[i]-b[i])**2
  return distance
n,d=map(int,input().split())
x=[]
c=0
for i in range(n):
  x.append(list(map(int,input().split())))
for i in range(1,n):
  for j in range(i):
    k=dist(x[i],x[j],d)
    if k==(int(math.sqrt(k)))**2:
      c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
s=sorted(input())
if s[0]==s[1] and s[2]: == s[3] and s[1]!=s[2]:
  print("Yes")
else:
  print("No")


Fixed submission:
s=sorted(input())
if s[0]==s[1] and s[2] == s[3] and s[1]!=s[2]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=sorted(list(map(int,input().split())))
if a[n-1]<=0:
  print(2*a[n-1]-sum(a))
  s=a[n-1]
  for i in a[:-1]:
    print(s,i)
    s-=i
elif a[0]>=0:
  print(sum(a)-2*a[0])
  s=a[0]
  for i in a[1:]:
    print(i,s)
    s=i-s
else:
  m=0
  for i in n:
    if a[i]>=0:
      k=i
      break
    m-=a[i]
  print(m+sum(a[k:]))
  s=a[0]
  for i in a[k:-1]:
    print(s,i)
    s-=i
  print(a[-1],s)
  s=a[-1]-s
  for i in a[1:k]:
    print(s,i)
    s-=i

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))
if a[-1]<=0:
  print(2*a[-1]-sum(a))
  s=a[-1]
  for i in a[:-1]:
    print(s,i)
    s-=i
elif a[0]>=0:
  print(sum(a)-2*a[0])
  s=a[0]
  for i in a[1:-1]:
    print(s,i)
    s-=i
  print(a[-1],s)
else:
  m=0
  for i in range(n):
    if a[i]>=0:
      k=i
      break
    m-=a[i]
  print(m+sum(a[k:]))
  s=a[0]
  for i in a[k:-1]:
    print(s,i)
    s-=i
  print(a[-1],s)
  s=a[-1]-s
  for i in a[1:k]:
    print(s,i)
    s-=i
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
c=0
while "ABC" in s:
    s=s.replace("ABC","BCA",1)
    c+=1
print(c)

Fixed submission:
import re
s=re.split("B|C",input().replace("BC","D"))
c,cd=0,0
for i in s:
    for j in range(len(i)):
        if i[j]=="D":
            c+=j-cd
            cd+=1
    cd=0
print(c)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s[k]=s[k-1].lower()

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

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
s[k]=lower(s[k])

Fixed submission:
n,k=map(int,input().split())
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)
Buggy python submission (verdict: Runtime Error):
i=input()
l,m=map(int,[i[:2],i[2:]])
my=int(1<=l and l<=12)
ym=int(1<=m and m<=12)<<1
print(["NA","MMYY","YYMM","AMBIGUOUS"][my+ym]

Fixed submission:
i=input()
l,m=map(int,[i[:2],i[2:]])
my=int(1<=l and l<=12)
ym=int(1<=m and m<=12)<<1
print(["NA","MMYY","YYMM","AMBIGUOUS"][my+ym])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
k=s[int(input())]
a=""
for i in range(n):
    a+=["*",k][int(s[i]==k)]
print(a)

Fixed submission:
n=int(input())
s=input()
k=s[int(input())-1]
a=""
for i in range(n):
    a+=["*",k][int(s[i]==k)]
print(a)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a,b)*2-1

Fixed submission:
a,b=map(int,input().split())
if a==b:print(2*a)
else:print(max(a,b)*2-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
count=0
for i in range(k):
  j=int(input())
  a.append(j)
  if max(a)<=j:count+=1
print(count)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
  if max(a[0:i]+[0])<=a[i]:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
a=input()
for i in range(3):
  input()
e=input()
k=input()
if e-a<=k:
  print("Yay!")
else:
  print(":(")

Fixed submission:
a=input()
for i in range(3):
  input()
e=input()
k=input()
if int(e)-int(a)<=int(k):
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
minn=0
for i in a:
  minn=min(minn,i%10)
  summ+=(i+9)//10
print(summ+minn)

Fixed submission:
a=[int(input()) for i in range(5)]
minn,summ=10,0
for i in a:
  minn=min(minn,(i-1)%10)
  summ+=(i+9)//10
print(summ*10+minn-9)

Buggy python submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
minn=0
for i in a:
  minn=min(minn,i%10)
  summ+=(int(i)+9)//10
print(summ+minn)

Fixed submission:
a=[int(input()) for i in range(5)]
minn,summ=10,0
for i in a:
  minn=min(minn,(i-1)%10)
  summ+=(i+9)//10
print(summ*10+minn-9)

Buggy python submission (verdict: Runtime Error):
a=[int(input()) for i in range(5)]
minn=0
for i in a:
  minn=min(minn,int(i[-1]))
  summ+=(int(i)+9)//10
print(summ+minn)

Fixed submission:
a=[int(input()) for i in range(5)]
minn,summ=10,0
for i in a:
  minn=min(minn,(i-1)%10)
  summ+=(i+9)//10
print(summ*10+minn-9)
Buggy python submission (verdict: Runtime Error):
n,q=list(map(int,input().split()))
s=" "+input()
a=[0]
for i in range(1,n+1):
  if c[i]=="C" and c[i-1]=="A":
    a.append(a[i-1]+1)
  else:
    a.append(a[i-1])
for i in range(q):
  l,r=list(map(int,input().split()))
  print(a[r]-a[l])

Fixed submission:
n,q=list(map(int,input().split()))
s=" "+input()
a=[0]
for i in range(1,n+1):
  if s[i]=="C" and s[i-1]=="A":
    a.append(a[i-1]+1)
  else:
    a.append(a[i-1])
for i in range(q):
  l,r=list(map(int,input().split()))
  print(a[r]-a[l])
Buggy python submission (verdict: Runtime Error):
y,m,d=list(map(int,input().split("/")))
if y>2019:
  print("TBD")
elif y<2019:
  print("Heisei")
elif m>4:
  print("TBD")
elif m<4:
  print("Heisei")
elif d=30:
  print("TBD")
else:
  print("Heisei")

Fixed submission:
y,m,d=list(map(int,input().split("/")))
if y>2019:
  print("TBD")
elif y<2019:
  print("Heisei")
elif m>4:
  print("TBD")
elif m<4:
  print("Heisei")
elif d>30:
  print("TBD")
else:
  print("Heisei")
Buggy python submission (verdict: Runtime Error):
n=int(inout())
jpy,btc=0,0
for i in range(n):
  x,u=input().split()
  if u=="JPY":
    jpy+=int(x)
  else:
    btc+=float(x)
jpy+=btc*380000
print(jpy)

Fixed submission:
n=int(input())
jpy,btc=0,0
for i in range(n):
  x,u=input().split()
  if u=="JPY":
    jpy+=int(x)
  else:
    btc+=float(x)
jpy+=btc*380000
print(jpy)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp=[0]+[float("inf") for i in range(n+k)]
for i in range(n-1):
    for j in range(k):
        if j+i+1>n-1:break
        dp[j+i+1]=min(dp[j+i+1],dp[i]+abs(h[j+i+1]-h[i]))
print(dp[n-1])

Fixed submission:
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp=[0]+[float("inf") for i in range(n+k)]
for i in range(n-1):
    for j in range(k):
        if j+i+1>n-1:break
        dp[j+i+1]=min(dp[j+i+1],dp[i]+abs(h[j+i+1]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))+[float("inf") for i in range(k)]
dp=[0]+[float("inf") for i in range(n+k)]
for i in range(n-1):
    for j in range(k):
        dp[j+i+1]=min(dp[j+i+1],dp[i]+abs(h[j+i+1]-h[i]))
print(dp[n-1])

Fixed submission:
n,k = list(map(int,input().split()))
h = list(map(int,input().split()))
dp=[0]+[float("inf") for i in range(n+k)]
for i in range(n-1):
    for j in range(k):
        if j+i+1>n-1:break
        dp[j+i+1]=min(dp[j+i+1],dp[i]+abs(h[j+i+1]-h[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w=list(map(int,input().split()))
k=[]
for i in range(n):
    k.append(list(map(int,input().split())))
vn=max([k[i][1] for i in range(n)])*n
dp=[[0]+[float("inf") for i in range(vn)] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,vn+1):
        if j<=k[i-1][1]:
            dp[i][j]=min(dp[i-1][j],k[i-1][0])
        else:
            dp[i][j]=min(dp[i-1][j],k[i-1][0]+dp[i-1][j-k[i-1][1]])
for i in range(vn,-1,-1):
    if dp[n][i]<=w:
        print(i)
        break

Fixed submission:
n,w=list(map(int,input().split()))
k=[]
for i in range(n):
    k.append(list(map(int,input().split())))
dp=[[0 for i in range(w+1)] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if j<k[i-1][0]:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-k[i-1][0]]+k[i-1][1])
print(dp[n][w])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = list(map(int,input().split()))
c = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        if (i+j)%k != 0:
            continue
        for l in range(1,n+1):
            if (j+l)%k == 0 and (i+l)%k == 0:
                c += 1
print(c)

Fixed submission:
n,k = list(map(int,input().split()))
if k & 1 == 1:
    print((n//k)**3)
else:
    print((n//k)**3+((n-(k>>1))//k+1)**3)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input()))
print(max(a)-min(a))

Fixed submission:
a=list(map(int,input().split()))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
a=int(input())
print(sum(list(map(int,input())))-a)

Fixed submission:
a=int(input())
print(sum(list(map(int,input().split())))-a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int, input().split()))

ans = 1
for num in nums:
    ans = ans * num

if ans > 10**18:
    print('-1')
else:
    print(ans)


Fixed submission:
N = int(input())
nums = sorted(map(int, input().split()))
if nums[0] == 0:
    print(0)
else:
    ans = 1
    for num in nums:
        ans = ans * num
        if ans > 10**18:
            break
    if ans > 10**18:
        print('-1')
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
reverse_houses = []
for i in range(N - 1):
    reverse_houses.insert(0, -1 * (K - houses[N - 1 - i]))
reverse_houses.reverse()
for house in reverse_houses:
    houses.insert(0, house)

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))


Fixed submission:
K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
for i in range(N - 1):
    houses.append(K + houses[i])

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
a, b, c = map(int, input().split())

k = max([float(np.abs(a)), float(np.abs(b))])

if (k * np.sqrt((a / k) * (b / k))) < (c - a - b) / 2:
    print("Yes")
else:
    print("No")


Fixed submission:
import math
import numpy as np
a, b, c = map(int, input().split())


d = c - a - b
if d > 0 and d * d > 4 * a * b:
    print('Yes')
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(" ")))

blue_count = 0
while n != 0:
    # 青
    if n > a:
        n -= a
        blue_count += a
    else:
        blue_count += n
        n = 0
    if n > b:
        n -= b
    else:
        n = 0

print(blue_count)


Fixed submission:
n, a, b = list(map(int, input().split(" ")))

blue_count = a * (n // (a + b))
n -= (a + b) * (n // (a + b))
if n >= a:
    blue_count += a
else:
    blue_count += n
print(blue_count)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = list(map(int, input().split(" ")))

blue_count = 0
while n != 0:
    # 青
    if n >= a:
        n -= a
        blue_count += a
    else:
        blue_count += n
        n = 0
    if n >= b:
        n -= b
    else:
        n = 0

print(blue_count)


Fixed submission:
n, a, b = list(map(int, input().split(" ")))

blue_count = a * (n // (a + b))
n -= (a + b) * (n // (a + b))
if n >= a:
    blue_count += a
else:
    blue_count += n
print(blue_count)
Buggy python submission (verdict: Runtime Error):
import math
A, B = list(map(int, input().split()))

A_min = math.ceil(A * 25 / 2)
A_max = ((A + 1) * 25 / 2)
if A_max > math.floor(A_max):
    A_max = math.floor(A_max) + 1
else:
    A_max = A_max
A_max = int(A_max)
B_min = B * 10
B_max = (B + 1) * 10
# print(B_min, B_max)
# A_list = list(range(A_min, A_max))
# B_list = list(range(B_min, B_max))
print(A_list)
print(B_list)

min_ans = -1
for num in A_list:
    if num in B_list:
        min_ans = num
        break
    else:
        continue

print(min_ans)


Fixed submission:
import math
A, B = list(map(int, input().split()))

A_min = math.ceil(A * 25 / 2)
A_max = ((A + 1) * 25 / 2)
if A_max > math.floor(A_max):
    A_max = math.floor(A_max) + 1
else:
    A_max = A_max
A_max = int(A_max)
B_min = B * 10
B_max = (B + 1) * 10
# print(B_min, B_max)
A_list = list(range(A_min, A_max))
B_list = list(range(B_min, B_max))
# print(A_list)
# print(B_list)

min_ans = -1
for num in A_list:
    if num in B_list:
        min_ans = num
        break
    else:
        continue

print(min_ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
points = list(map(int, input().split(" ")))

powers = []
for i in range(min(points), max(points)):
    power = 0
    for point in points:
        power += ((i - point) ** 2)
    powers.append(power)

print(min(powers))


Fixed submission:
N = int(input())
points = list(map(int, input().split(" ")))

powers = []
for i in range(min(points), max(points) + 1):
    power = 0
    for point in points:
        power += ((i - point) ** 2)
    powers.append(power)

print(min(powers))

Buggy python submission (verdict: Runtime Error):
N = int(input())
points = list(map(int, input().split(" ")))

powers = []
for i in range(min(points), max(points)):
    power = 0
    for point in points:
        power += ((i - point) ** 2)
    powers.append(power)
print(min(powers))


Fixed submission:
N = int(input())
points = list(map(int, input().split(" ")))

powers = []
for i in range(min(points), max(points) + 1):
    power = 0
    for point in points:
        power += ((i - point) ** 2)
    powers.append(power)

print(min(powers))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if text in existed_dict.keys():
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):
    print(text)


Fixed submission:
N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if existed_dict.get(text):  # ここか
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):  # ここ
    print(text)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

existed_dict = {}
for _ in range(N):
    text = input()
    if text in existed_dict.keys():
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1

max_count = max(existed_dict.values())

max_dict = {}
for k, v in existed_dict.items():
    if v == max_count:
        max_dict[k] = v
    else:
        pass

sorted_hash = sorted(max_dict, reverse=False)
for text in sorted_hash:
    print(text)


Fixed submission:
N = int(input())

existed_dict = {}
max_count = 0
max_text_list = []
for _ in range(N):
    text = input()
    if existed_dict.get(text):  # ここか
        existed_dict[text] += 1
    else:
        existed_dict[text] = 1
    if existed_dict[text] == max_count:
        max_count = existed_dict[text]
        max_text_list.append(text)
    elif existed_dict[text] > max_count:
        max_count = existed_dict[text]
        max_text_list = []
        max_text_list.append(text)
    else:
        pass

for text in sorted(max_text_list):  # ここ
    print(text)
Buggy python submission (verdict: Runtime Error):
# from fractions import gcd
from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def run():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


run()


Fixed submission:
from fractions import gcd
# from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def run():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


run()

Buggy python submission (verdict: Runtime Error):
# from fractions import gcd
from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def main():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


main()


Fixed submission:
from fractions import gcd
# from math import gcd
from functools import reduce
N, M = map(int, input().split())
nums = set([num // 2 for num in list(map(int, input().split()))])
# 1<=X<=Mの範囲で、半公倍数の数を求める。
# 但し、Xは、num*(p+0.5)でなければならない
# Mが10**9なので、全部やるのは無理。
# n.5倍なので、numsのあたいは全て偶数になっている。

# nums一つ一つ、答えになりうるXの配列を作って、重複したものを残せばそれが答えになる。
# Nが10**5なので、どうだろう


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


def run():
    half_multiple_num = reduce(half_multiple, nums, 1)

    # print(half_multiple_num)
    for num in nums:
        if (half_multiple_num // num) % 2 == 0:
            print(0)
            return

    pmax = M // half_multiple_num
    pmax = pmax - 1 if pmax % 2 == 0 else pmax

    print((pmax + 1) // 2)


run()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = [i for i in range(1, N + 1)]
if (N - 1) % 2 == 0:
    print(N * ((N - 1) // 2))
else:
    # 12 =>
    print(N * ((N - 1) // 2) + (N // 2))


Fixed submission:
N = int(input())
# nums = [i for i in range(1, N + 1)]
if (N - 1) % 2 == 0:
    print(N * ((N - 1) // 2))
else:
    # 12 =>
    print(N * ((N - 1) // 2) + (N // 2))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
nums = [int(input()) for _ in range(N)]
# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.
# その際に、色の最小数をだす。
LIS = [nums[0]]
count = 0
for index, num in enumerate(nums):
    if index == 0:
        continue
    insert_index = bisect.bisect_left(LIS, num)
    if insert_index == 0:
        LIS.insert(insert_index, num)
    else:
        LIS[insert_index - 1] = num
print(len(LIS))


Fixed submission:
import bisect
from collections import deque
N = int(input())
nums = [int(input()) for _ in range(N)]
# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.
# その際に、色の最小数をだす。
LIS = deque([nums[0]])
count = 0
for index, num in enumerate(nums):
    if index == 0:
        continue
    if num <= LIS[0]:
        LIS.appendleft(num)
    else:
        insert_index = bisect.bisect_left(LIS, num)
        LIS[insert_index - 1] = num
print(len(LIS))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = [int(input()) for _ in range(N)]
# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.
# その際に、色の最小数をだす。
LISES = [[nums[0]]]

for index, num in enumerate(nums):
    if index == 0:
        continue
    for LIS in LISES:
        if LIS[-1] < num:
            LIS.append(num)
            break
    else:
        LISES.append([num])
print(len(LISES))


Fixed submission:
import bisect
from collections import deque
N = int(input())
nums = [int(input()) for _ in range(N)]
# i<jで、 AiとAjが同じ色で塗られている場合、Ai < Ajが成り立つ.
# その際に、色の最小数をだす。
LIS = deque([nums[0]])
count = 0
for index, num in enumerate(nums):
    if index == 0:
        continue
    if num <= LIS[0]:
        LIS.appendleft(num)
    else:
        insert_index = bisect.bisect_left(LIS, num)
        LIS[insert_index - 1] = num
print(len(LIS))