Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03565 (python)

Fixed submission:
ss, t = input(), input()
lt = len(t)
lss = len(ss)
lst = []
for i in range(lss - 1, lt - 2, -1):
    tss = ss[i - lt + 1:i + 1]
    tb = True
    for a, b in zip(tss, t):
        if a == '?':
            continue
        elif a != b:
            tb = False
            break
    if tb:
        lst.append(ss[:i - lt + 1] + t + ss[i + 1:])
if len(lst):
    lst.sort()
    print(lst[0].replace('?', 'a'))
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
ss, t = input(), input()
lt = len(t)
lss = len(ss)

for i in range(0, lss - lt + 1):
  tss = ss[i : i + lt]
  tb = True
  for a, b in zip(tss, t):
    if a == '?':
      continue
    elif a != b:
      tb = False
      break
  if tb:
    ss = ss[: i] + t + ss[i + lt:]
    break
if tb:
  print(ss.replace('?', 'a'))
else:
  print('UNRESTORABLE')
Problem p03606 (python)

Fixed submission:
n = int(input())
lst = [[int(i) for i in input().split()] for _ in range(n)]
p = 0
for i in lst:
  p += i[1] - i[0] + 1
print(p)

Buggy submission (verdict: Runtime Error):
lst = [[int(i) for i in input().split()] for _ in range(n)]
p = 0
for i in lst:
  p += i[1] - i[0] + 1
print(p)

Buggy submission (verdict: Runtime Error):
import sys
lst = [[int(j) for j in i] for i in sys.stdin.readlines()]n = int(input())
lst = [[int(i) for i in input().split()] for _ in range(n)]
p = 0
for i in lst:
  p += i[1] - i[0] + 1
print(p)
Problem p03607 (python)

Fixed submission:
n = int(input())
dic = {}
for _ in range(n):
  tmp = int(input())
  if tmp in dic and dic[tmp] == 1:
    dic[tmp] = 0
  else:
    dic[tmp] = 1
print(sum(dic.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}
for _ in range(n):
  tmp = int(input())
  if tmp in dic and dic[tmp] == 1:
    dic[tmp] == 0
  else:
    dic[tmp] = 1
print(sum([*dic.values()]))
Problem p03633 (python)

Fixed submission:
n = int(input())
#n, k = map(int,input().split())
#plst = [int(i) for i in input().split()]
if n == 1:
    print(int(input()))
else:
    lst = [int(input()) for _ in range(n)]

    def a(p, q):
        if p % q == 0:
            return q
        else:
            return a(q, p % q)

    f = lst[0] * (lst[1] // a(lst[0], lst[1]))
    for i in range(2, n):
        f = f * (lst[i] // a(f, lst[i]))
    print(f)

Buggy submission (verdict: Runtime Error):
n = int(input())
#n, k = map(int,input().split())
#plst = [int(i) for i in input().split()]

lst = [int(input()) for _ in range(n)]

def a(p, q):
    if p % q == 0:
        return q
    else:
        return a(q, p % q)

f = lst[0] * (lst[1] // a(lst[0], lst[1]))
for i in range(2, n):
    f = f * (lst[i] // a(f, lst[i]))
print(f)

Buggy submission (verdict: Runtime Error):
n = int(input())
#n, k = map(int,input().split())
#plst = [int(i) for i in input().split()]

lst = [int(input()) for _ in range(n)]

def a(p, q):
    if p % q == 0:
        return q
    else:
        return a(q, p % q)


f = (lst[0] * lst[1]) // a(lst[0], lst[1])
for i in range(2, n):
    f = (f * lst[i]) // a(f, lst[i])
print(f)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0] + str(len(s) - 2) + s[- 1])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0] + str(len(s) - 2) + s[-1])s

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0] + str(len(s) - 2) + s[-1])s = input()
print(s[0] + str(len(s) - 2) + s[-1])
Problem p03675 (python)

Fixed submission:
n = int(input())
alst = input().split()
lst1 = alst[::2]
lst2 = alst[1::2]
if n % 2:
  lst1.reverse()
  print(' '.join(lst1 + lst2))
else:
  lst2.reverse()
  print(' '.join(lst2 + lst1))

Buggy submission (verdict: Runtime Error):
import sys
n, *alst = map(int, sys.stdin.read().split())
lst1 = alst[::2]
lst2 = alst[1::2]
if n % 2:
  lst1.reverse()
  print(''.join(lst1 + lst2))
else:
  lst2.reverse()
  print(''.join(lst2 + lst1))
Problem p03701 (python)

Fixed submission:
import sys
n, *lst = map(int, sys.stdin.read().split())
res = sum(lst)
if not res % 10:
  tmp = [i for i in lst if i % 10]
  if tmp:
    res -= min(tmp)
  else:
    res = 0
print(res)

Buggy submission (verdict: Runtime Error):
import sys
n, *lst = map(int, sys.stdin.read().split())
res = sum(lst)
if not res % 10:
  tmp = [i if not i % 10 for i in lst]
  if tmp:
    res -= min(tmp)
  else:
    res = 0
print(res)
Problem p03721 (python)

Fixed submission:
n, k = map(int,input().split())

lst = [[int(i) for i in input().split()] for _ in range(n)]

lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
n, k = map(int,input().split())

lst = [[int(i) for i in input().split()] for _ in range(n)]

lst.sort(key = lambda x: x[0])

for [i, j] in lst:
    if j >= k:
        print(i)
        quit()
    else:
        k -= j
Problem p03738 (python)

Fixed submission:
a,b = int(input()), int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')

Buggy submission (verdict: Runtime Error):
a,b = int(input()), int(input())

print('GREATER' if a>b or 'LESS')
Problem p03741 (python)

Fixed submission:
import sys


def func(alst, sign):
  cur, res = 0, 0
  for i in alst:
    cur += i
    if sign and cur <= 0:
      res += abs(cur) + 1
      cur = 1
    elif not sign and cur >= 0:
      res += abs(cur) + 1
      cur = -1
    sign = not sign
  return res


def main():
  n, *alst = map(int, sys.stdin.read().split())
  print(min(func(alst, True), func(alst, False)))


if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys


def func(lst, sign):
  cur, res = 0, 0
  for i in alst:
    cur += i
    if sign and cur <= 0:
      res += abs(cur) + 1
      cur = 1
    elif not sign and cur >= 0:
      res += abs(cur) + 1
      cur = -1
    sign = not sign
  return res


def main():
  n, *alst = map(int, sys.stdin.read().split())
  print(min(func(alst, True), func(alst, False)))


if __name__ == '__main__':
  main()
Problem p03796 (python)

Fixed submission:
n = int(input())
mod = 10 ** 9 + 7
def a(n):
    s = 1
    for i in range(1, n + 1):
        s = (s * i) % mod
    return s

print(a(n))

Buggy submission (verdict: Runtime Error):
n = int(input())
mod = 10 ** 9 + 7
def a(n):
    if n == 1:
        return n
    else:
        return n * (a(n - 1))

print(a(n) % mod)
Problem p03860 (python)

Fixed submission:
a,b,c = input().split()
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
a,b,c = input(),input(),input()
print(a[0]+b[0]+c[0])
Problem p03864 (python)

Fixed submission:
import sys

n, x, *lst1 = map(int, sys.stdin.read().split())
res1 = res2 = 0
lst2 = [0] + lst1
lst1.append(0)
for i in range(n):
  tmpsum = lst2[i] + lst2[i + 1]
  if tmpsum > x:
    res1 += tmpsum - x
    lst2[i + 1] -= tmpsum - x

for i in range(n, 0, -1):
  tmpsum = lst1[i] + lst1[i - 1]
  if tmpsum > x:
    res2 += tmpsum - x
    lst1[i - 1] -= tmpsum - x  
print(min(res1, res2))

Buggy submission (verdict: Runtime Error):
import sys

n, x, *lst = map(int, sys.stdin.read().split())
re1 = 0
lst.append(0)
for i in range(n, 0, -1):
  tmpsum = lst[i] + lst[i - 1]
  if tmpsum > x:
    res += tmpsum - x
    lst[i - 1] -= tmpsum - x

print(res)
Problem p03943 (python)

Fixed submission:
lst = [int(i) for i in input().split()]

m = max(lst)
if sum(lst) == 2*m:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
lst = [int(i) for i in input().split()]

m = max(lst)
if sum(lst) = 2*m:
  print('Yes')
else:
  print('No')
Problem p03967 (python)

Fixed submission:
s = input()
p = sum(1 for i in s if i == 'p')
l = len(s)
print(l // 2 - p)

Buggy submission (verdict: Runtime Error):
s = input()

grid = [0 if i == 'g' else 1 for i in s]


def biggest(grid):
    dist = [float('-inf')] * len(s)
    move = (0, 1)
    st = deque([[0, 0, 0, 0]])
    while st:
        g, p, idx, cur = st.popleft()
        if idx > len(s) - 1:
            continue
        for a in move:
            if a:
                if p + 1 > g:
                    continue
                tmpg, tmpp = g, p + 1
            else:
                tmpg, tmpp = g + 1, p
            if a > grid[idx]:
                tmp = cur + 1
            elif a < grid[idx]:
                tmp = cur - 1
            else:
                tmp = cur
            if dist[idx] < tmp:
                dist[idx] = tmp
            st.append([tmpg, tmpp, idx + 1, tmp])
    return dist[-1]


print(biggest(grid))
Problem p04001 (python)

Fixed submission:
from itertools import chain, combinations


def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)

Buggy submission (verdict: Runtime Error):
def powerset(iterable):
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1))


def s_to_num(s):
    numlst = list(map(int, s))
    res = 0
    for i in numlst:
        res *= 10
        res += i
    return res


s = input()
length = len(s)
res = 0
for i in powerset(range(1, length)):
    if not i:
        res += int(s)
    else:
        jlst = [0] + list(i) + [length]
        for j in range(len(jlst) - 1):
            res += s_to_num(s[jlst[j]:jlst[j + 1]])
print(res)
Problem p04029 (python)

Fixed submission:
def a(s):
  if s == 1:
    return s
  return s + a(s-1) 

print(a(int(input())))

Buggy submission (verdict: Runtime Error):
def a(s):
  if s == 1:
    return s
  return s + a(s-1) 

print(a(int(input()))
Problem p02617 (python)

Fixed submission:
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

N = int(input().strip())
A = set([])

for _ in range(N - 1):
    u, v = tuple(map(int, input().strip().split()))
    A.add((u, v))

V = 0
for l in range(1, N + 1):
    V += (N - l + 1) * (N - l + 2) // 2

E = 0
for u, v in A:
    a = min(u, v)
    b = max(u, v)
    E += a * (N - b + 1)

print(V - E)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

import numpy as np

N = int(input().strip())
A = np.zeros((N, N), dtype=np.int32)

for _ in range(N - 1):
    u, v = tuple(map(int, input().strip().split()))
    A[u-1, v-1] = 1
    A[v-1, u-1] = 1

V = 0
for l in range(N):
    for r in range(l, N):
        V += r - l + 1

E = 0
for u in range(N):
    for v in range(u, N):
        E += (u + 1) * (N - v) * A[u, v]

print(V - E)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

import numpy as np

N = int(input().strip())
A = np.zeros((N, N), dtype=np.int64)
x = np.array(range(N))

for _ in range(N - 1):
    u, v = tuple(map(int, input().strip().split()))
    A[u-1, v-1] = 1
    A[v-1, u-1] = 1

def update(cluster, l, r):

    connected = set([])

    for v in range(l, r):
        if A[v, r] > 0:
            connected.add(cluster[v])

    if len(connected) == 0:
        cluster[r] = max(set(cluster.values())) + 1

    elif len(connected) == 1:
        cluster[r] = connected.pop()

    else:
        cluster[r] = max(set(cluster.values())) + 1
        for v, c in cluster.items():
            if c in connected:
                cluster[v] = cluster[r]

    return cluster


S = 0
for l in range(N):

    cluster = {}

    for r in range(l, N):

        if r == l: cluster[r] = 0
        else     : cluser = update(cluster, l, r)

        S += len(set(cluster.values()))

print(S)

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker
Problem p02613 (python)

Fixed submission:
n = int(input())
inp = {}
for i in range(n):
    a = input()
    if inp.get(a) is None:
        inp[a] = 0
    inp[a] += 1
print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

Buggy submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {inp['AC']}")
  print(f"WA x {inp['WA']}")
  print(f"TLE x {inp['TLE']}")
  print(f"RE x {inp['RE']}")

Buggy submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")

Buggy submission (verdict: Runtime Error):
n = int(input())
inp = {}
for i in range(n):
  a = input()
  if inp.get(a) is not None:
    inp[a] = 0
  inp[a] += 1

  print(f"AC x {result['AC']}")
  print(f"WA x {result['WA']}")
  print(f"TLE x {result['TLE']}")
  print(f"RE x {result['RE']}")
Problem p02614 (python)

Fixed submission:
# def c():
#     n = int(input())
#     inp = {}
#     for i in range(n):
#         a = input()
#         if inp.get(a) is None:
#             inp[a] = 0
#         inp[a] += 1
#     print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
#     print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
#     print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
#     print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

# c()


h, w, k = [int(x) for x in input().split()]
ans = 0

grid = []

for i in range(h):
    grid.append(list(input()))

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# def c():
#     n = int(input())
#     inp = {}
#     for i in range(n):
#         a = input()
#         if inp.get(a) is None:
#             inp[a] = 0
#         inp[a] += 1
#     print(f"AC x {0 if inp.get('AC') is None else inp.get('AC')}")
#     print(f"WA x {0 if inp.get('WA') is None else inp.get('WA')}")
#     print(f"TLE x {0 if inp.get('TLE') is None else inp.get('TLE')}")
#     print(f"RE x {0 if inp.get('RE') is None else inp.get('RE')}")

# c()


h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
    grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
    if black == k:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
	grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
	for maskCol in range(0, 1 << w):
      black = 0
      for i in range(h):
        for j in range(w):
          if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
              black += 1
      if black == k:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
h, w, k = [int(x) for x in input.split()]
ans = 0

grid = []

for i in range(h):
    grid.append(input.split())

black = 0

for maskRow in range(0, 1 << h):
    for maskCol in range(0, 1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (maskRow >> i) & 1 == 0 and (maskCol >> j) & 1 == 0 \
                                                    and grid[i][j] == '#':
                    black += 1
    if black == k:
        ans += 1

print(ans)
Problem p02720 (python)

Fixed submission:
from collections import deque

K = int(input())
que = deque([i for i in range(1, 10)])
lunlun = []

while que:
    num = que.pop()
    lunlun.append(num)
    for i in range(10):
        if abs(int(str(num)[-1]) - i) <= 1:
            cand = int(str(num) + str(i))
            if cand < 10000000000:
                que.append(cand)

lunlun.sort()
print(sorted(lunlun)[K - 1])

Buggy submission (verdict: Runtime Error):
rom collections import deque
 
K = int(input())
que = deque([i for i in range(1, 10)])
lunlun = []
 
while que:
    num = que.pop()
    lunlun.append(num)
    for i in range(10):
        if abs(int(str(num)[-1]) - i) <= 1:
            cand = int(str(num) + str(i))
            if cand < 10000000000:
                que.append(cand)
 
lunlun.sort()
print(sorted(lunlun)[K - 1])
Problem p02780 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split(" "))
p = list(map(int, input().split(" ")))
ex = [i + 1 for i in p]
ans = sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    ans += ex[i] - ex[i - K]
    max_ans = max(ans, max_ans)
print(max_ans / 2.0)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans_max = 0
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans_max = max(np.sum(p_i) / np.prod(p), ans_max)
print(ans_max)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
P = np.array(list(map(int, input().split(" "))))
ans = []
for i in range(N - K + 1):
    p = P[i: i + K]
    p_i = np.array([k for k in range(1, p[0] + 1)])
    for p_k in p[1:]:
        p_i = np.array([p_i + k for k in range(1, p_k + 1)]).flatten()
    ans.append(np.sum(p_i) / np.prod(p))
print(max(ans))
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())

ac = 0
wa = 0
ac_status = [0 for i in range(N)]
wa_status = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and ac_status[int(p_i) - 1] == 0:
        ac += 1
        ac_status[int(p_i) - 1] += 1
        wa += wa_status[int(p_i) - 1]
    if s_i == "WA":
        wa_status[int(p_i) - 1] += 1

print(ac, wa)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

ac = []
wa = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and p_i not in ac:
        ac.append(p_i)
    if s_i == "WA" and p_i not in ac:
        wa[p_i - 1] += 1
        
ac = set(ac)
wa_num = 0
for i in range(N):
    if i + 1 not in ac:
        continue
    else:
        wa_num += wa[i]

print(len(ac), wa_num)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

ac = []
wa = [0 for i in range(N)]

for _ in range(M):
    p_i, s_i = input().split()
    if s_i == "AC" and p_i not in ac:
        ac.append(p_i)
    if s_i == "WA" and p_i not in ac:
        wa[p_i - 1] += 1
        
ac = set(ac)                
wa = [count for i, count in enumerate(wa) if i + 1 in ac]

print(len(ac), sum(wa))
Problem p02814 (python)

Fixed submission:
import fractions
import math
 
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])

for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = a[0]
for i in range(1, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > M:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Buggy submission (verdict: Runtime Error):
import fractions
import numpy as np
import math
 
N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) // 2
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])
for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Buggy submission (verdict: Runtime Error):
import fractions
import numpy as np
import math

N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) // 2

def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Buggy submission (verdict: Runtime Error):
import fractions
import numpy as np
import math

N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) / 2

def lcm(a, b):
    return a * b / fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import numpy as np
import math

N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) / 2
a = np.array(list(set(a)))

def lcm(a, b):
    return a * b / gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    lcm = lcm(lcm, a[i])
    if lcm > N:
        print(0)
        exit()
    
ans = M // lcm
print(math.ceil(ans / 2))
Problem p02838 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

K = len(bin(np.max(A))) - 2

ans = 0
mod = 10 ** 9 + 7
N %= mod

for i in range(K):
    bit = np.count_nonzero(A >> i & 1) % mod
    ans += 2 ** i * bit * (N - bit)
    ans %= mod
    
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))

K = len(bin(np.max(A))) - 2

ans = 0
mod = 10 ** 9 + 7
N %= mod

for i in range(K):
    bit = sum(A >> i & 1) % mod
    ans += pow(2, i, mod) * bit * (N - bit)
    ans %= mod
    
print(ans)