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

Fixed submission:
a, b = map(int, input().split())
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
ab = a * b
if ab % 2 == 0:
  print('Even')
else:
  print('Odd')
Problem p03493 (python)

Fixed submission:
s = input()
count = 0
if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

print(count)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
if s[0] == '1':
  count += 1
if s[1] == '1':
  count += 1
if s[2] == '1':
  count += 1

return count
Problem p03494 (python)

Fixed submission:
N = int(input())
A = [int(s) for s in input().split()]
count = 0
flag = True

while flag:
  for i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if flag == False:
    print(count)
  count += 1
  for i in range(N):
    A[i] = A[i] / 2

Buggy submission (verdict: Runtime Error):
A = input().split()
count = 0
flag = True

while flag:
  for i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if !flag:
    print(count)
  count += 1
  for i in range(N):
    A[i] = A[i] / 2

Buggy submission (verdict: Runtime Error):
A = input().split()
count = 0
flag = True

while flag:
  fot i in range(N):
    if A[i] % 2 != 0:
      flag = False
      break
  if !flag:
    print(count)
  count += 1
  A[i] = A[i] / 2
Problem p04011 (python)

Fixed submission:
N,K,X,Y = [int(input()) for i in range(4)]

if N <= K:
    print(N * X)
else:
    S = K * X #最初の宿泊金額
    p = N - K #残りの日数
    s = p * Y #残りの宿泊金額
    S += s #足す
    print(S)

Buggy submission (verdict: Runtime Error):
N,K,X,Y = [input() for i in range(4)]

if N <= K:
    print(N * K)
else:
    S = N * K
    s = N * (N - K)
    S += s
    print(S)
Problem p04029 (python)

Fixed submission:
N = int(input())
t = 0

for i in range(N):
	t += i + 1 

print(t)

Buggy submission (verdict: Runtime Error):
N = int(input())
t = 0

for i in range(N)
	t += i
  
print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())

j=0

for i in N:
  j = j + i

else:
  print(j)

Buggy submission (verdict: Runtime Error):
N = int(input())

j=0

for i in N:
  j = j + N

else:
  print(j)
Problem p04043 (python)

Fixed submission:
A,B,C = map(int,input().split())

if A == 5 or A == 7:
  if B == 5 or B == 7:
    if C == 5 or C == 7:
      if A + B + C == 17:
        print('YES')
      else:
        print('NO')
    else:
      print('NO')
  else:
  	print('NO')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if A == 5 or A == 7:
  if B == 5 or B == 7:
    if C == 5 or C == 7:
      if A + B + C == 17:
        print('Yes')
      else:
        print('No')
    else:
      print('No')
  else:
  	print('No')
else:
  print('No')
Problem p02783 (python)

Fixed submission:
h,a=map(int, input().split())
count = 0
while True:
  h = h - a
  if (h > 0):
    count += 1
  else:
    break
print(count + 1)

Buggy submission (verdict: Runtime Error):
h,a=map(int, input().split())
count = 0
while True:
  result = h - a
  if (result > 0):
    count += 1
  else:
  	break 
return count
Problem p02784 (python)

Fixed submission:
h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
print('Yes') if result <= 0 else print('No')

Buggy submission (verdict: Runtime Error):
h,n=map(int, input().split())
aList=list(map(int, input().split()))
result = h
for a in aList:
  result -= a
return 'Yes' if result <= 0 else 'No'
Problem p02812 (python)

Fixed submission:
n = input()
s = input()
 
print(s.count('ABC'))

Buggy submission (verdict: Runtime Error):
n,s = map(str,input().split())

print(s.count('ABC'))
Problem p02813 (python)

Fixed submission:
import itertools

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

x = itertools.permutations(list(range(1, n+1)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(list(xx) == p):
    pnum = index
  if(list(xx) == q):
    qnum = index
    
print(abs(pnum - qnum))

Buggy submission (verdict: Runtime Error):
import itertools

n = input()
p = map(int, input().split())
q = map(int, input().split())

x = itertools.permutations(list(range(n)), n)
pnum = 0
qnum = 0
for index, xx in enumerate(x):
  if(xx == p):
    pnum = index
  if(xx == q):
    qnum = index
    
print(abs(pnum - qnum))
Problem p02841 (python)

Fixed submission:
date_entry_1 = input()
M1, D1 = map(int, date_entry_1.split(' '))
date_entry_2 = input()
M2, D2 = map(int, date_entry_2.split(' '))

if D2 == 1:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
M1 = int(input())
D1 = int(input())
M2 = int(input())
D2 = int(input())

if D2 == 1:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
M1 = int(input())
D1 = int(input())
M2 = int(input())
D2 = int(input())

if D2 == 1:
    print(1)
else:
    print(0)
Problem p02898 (python)

Fixed submission:

x = input()
hights_str = input()

low_limit = int(x.split(" ")[1])
hights = map(int, hights_str.split(" "))

count = 0
for hight in hights:
    if hight >= low_limit:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):

x = input()
hights_str = input()

low_limit = int(x.split(" ")[1]
hights = map(int, hights_str.split(" "))

count = 0
for hight in hights:
    if hight >= low_limit:
        count += 1

print(count)
Problem p02899 (python)

Fixed submission:
import numpy as np
N = input()
cum_numbers = input()

array_cum_numbers = np.array(list(map(int, cum_numbers.split(" "))))

studentId_order = array_cum_numbers.argsort() + 1

print(" ".join(map(str, list(studentId_order))))

Buggy submission (verdict: Runtime Error):
import pandas as pd
N = input()
cum_numbers = input()

series_cum_numbers = pd.Series(list(map(int, cum_numbers.split(" "))))

student_order = series_cum_numbers.sort_values().index + 1

print(" ".join(map(str, list(student_order))))
Problem p02841 (python)

Fixed submission:


def inputs():
    return [int(s) for s in input().split()]


def main():
    M1, _ = inputs()
    M2, _ = inputs()

    if (M1 + 1) % 12 == M2 % 12:
        return 1
    else:
        return 0


if __name__ == '__main__':
    print(main())

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


def inputs():
    return [int(s) for s in input().split()]


def main():
    M1, _ = inputs()
    M2, _ = inputs()

    if (M1 + 1) % 12 == M2 % 12:
        return 1
    else:
        return 0


if __name__ == '__main__':
    print(main())
Problem p02845 (python)

Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0 for _ in range(N + 1)]
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1
        pattern[a + 1] += 1
        # print(pattern)
    return ret % 1000000007


if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0] * N
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1
        pattern[a + 1] += 1
        # print(pattern)
    return ret


if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    A = inputIntList()

    pattern = [0] * 4
    pattern[0] = 3

    ret = 1
    for a in A:
        ret *= pattern[a]
        pattern[a] -= 1

        pattern[a + 1] += 1
        # print(pattern)
    return ret


if __name__ == "__main__":
    print(main())
Problem p03030 (python)

Fixed submission:
import math


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in map(lambda x: x[2], SP):
        print(i)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    _SP = np.array(SP)
    for i in _SP[:, 2]:
        print(i)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    SP = np.array(SP)
    for i in SP[:, 2]:
        print(i)


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

Fixed submission:
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    cnt = 0
    for r in range(N + 1):
        for g in range(N + 1 - (R * r)):
            if (N - (R * r) - (G * g)) % B == 0 and N - (R * r) - (G * g) >= 0:
                cnt += 1
 
    print(cnt)
 
 
if __name__ == '__main__':
    main()
Problem p03061 (python)

Fixed submission:
from fractions import gcd
N = int(input())
A = [int(s) for s in input().split()]
ans = 0
L = [0] * (N)
R = [0] * (N)
for n in range(0, N):
    if n != N-1:
        L[n+1] = gcd(A[n], L[n])
        R[-(n+2)] = gcd(A[-(n+1)], R[-(n+1)])
for n in range(0, N):
    temp = gcd(L[n], R[n])
    ans = max(temp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(s) for s in input().split()]
ans = 0
L = [0] * (N)
R = [0] * (N)
for n in range(0, N):
    if n != N-1:
        L[n+1] = gcd(A[n], L[n])
        R[-(n+2)] = gcd(A[-(n+1)], R[-(n+1)])
for n in range(0, N):
    temp = gcd(L[n], R[n])
    ans = max(temp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os
sys.stdin = open('input.txt', 'r')

from fractions import gcd
N = int(input())
A = [int(s) for s in input().split()]
ans = 0
L = [0] * (N)
R = [0] * (N)
for n in range(0, N):
    if n != N-1:
        L[n+1] = gcd(A[n], L[n])
        R[-(n+2)] = gcd(A[-(n+1)], R[-(n+1)])
for n in range(0, N):
    temp = gcd(L[n], R[n])
    ans = max(temp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
N = int(input())
A = [int(s) for s in input().split()]
ans = 0
L = [0] * (N)
R = [0] * (N)
for n in range(0, N):
    if n != N-1:
        L[n+1] = gcd(A[n], L[n])
        R[-(n+2)] = gcd(A[-(n+1)], R[-(n+1)])
print(L, R)
for n in range(1, N):
    temp = gcd(L[n], R[n])
    ans = max(temp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = [int(s) for s in input().split()]
ans = 0
L = [A[0]] * (N)
R = [A[-1]] * (N)
for n in range(1, N):
    L[n] = math.gcd(A[n], L[n-1])
    R[-(n+1)] = math.gcd(A[-(n+1)], R[-n])
for n in range(1, N-1):
    temp = math.gcd(L[n-1], R[n+1])
    ans = max(temp, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(s) for s in input().split()]
ans = 0
temp = [0] * (max(A) + 1)
for i in range(N):
    for d in range(1, int(A[i]/2)):
        if A[i] % d == 0:
            temp[d] += 1
    temp[A[i]] += 1
for i in range(max(A), 0, -1):
    if N - 1 <= temp[i]:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
ans = 0
index = [0] * N
max = 0
temp = [0] * (10**9 + 1)
for i in range(N):
    for d in range(1, int(A[i]/2)):
        if A[i] % d == 0:
            temp[d] += 1
    temp[A[i]+ 1] += 1
for i in range(N-1, 0, -1):
    if N - 1 <= temp[i]:
        ans = i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
index = [0] * N
max = 0
temp = [0] * (10**9 + 1)
for i in range(N):
    for d in range(1, int(A[i]/2)):
        if A[i] % d == 0:
            temp[d] += 1
    temp[A[i]+ 1] += 1
for i in range(N-1, 0, -1):
    if N - 1 <= temp[i]:
        ans = i
        break
print(ans)
Problem p03069 (python)

Fixed submission:
N = int(input())
S = input()
ans = N
sumB = [0] * (N + 1)
tmp = 0
for i in range(N):
    if S[i] == '#':
        tmp += 1
    sumB[i+1] = tmp
for i in range(N+1):
    ans = min(sumB[i] + (N - i) - (sumB[N] - sumB[i]), ans)
    # print(sumB[i] , (N - i), (sumB[N] - sumB[i]), ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
if N == 1:
    print(0)
    exit()
elif N == 2 and (S[0] == '.' and S[1] == '#'):
    print(0)
    exit()
else:
    S = S[0] + S + S[N - 1]
    S = list(S)
    for n in range(N):
        if S[n] == '.' and S[n + 2] == '.' and S[n + 1] == '#':
            ans += 1
            S[n + 1] = '.'
        elif S[n] == '#' and S[n + 2] == '#' and S[n + 1] == '.':
            ans += 1
            S[S + 1] = '#'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
if N == 1:
    print(0)
    exit()
elif N == 2 and (S[0] == '#' and S[1] == '.'):
    print(1)
    exit()
else:
    S = '#' + S + '#'
    for n in range(N+1):
        if S[n] == '.' and S[n + 2] == '.' and S[n + 1] == '#':
            ans += 1
        elif S[n] == '#' and S[n + 2] == '#' and S[n + 1] == '.':
            ans += 1
print(ans)
Problem p03102 (python)

Fixed submission:
N, M, C = map(int, raw_input().split())
B = map(int , raw_input().split())
ans = 0
for i in range(0, N):
    A = map(int , raw_input().split())
    tmp = [A[m] * B[m] for m in range(M)]

    if sum(tmp) + C > 0:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
N, M, C = map(int, raw_input().split())
B = map(int , raw_input().split())
ans = 0
for i in range(0, N):
    A = map(int , raw_input().split())
    tmp = [A[m] * B[m] for m in range(M)]

    if sum(tmp) + c > 0:
        ans+=1

print(ans)
Problem p03160 (python)

Fixed submission:
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    h = inputIntList()
    h.append(0)
    dp = [float("inf") for _ in range(N + 2)]
    dp[0] = 0
    for i in range(N - 1):
        if abs(h[i] - h[i + 1]) + dp[i] < dp[i + 1]:
            dp[i + 1] = abs(h[i] - h[i + 1]) + dp[i]

        if abs(h[i] - h[i + 2]) + dp[i] < dp[i + 2]:
            dp[i + 2] = abs(h[i] - h[i + 2]) + dp[i]

    return dp[N - 1]


if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, K = inputIntList()
    h = inputIntList()
    h.extend([0] * K)
    dp = [float("inf") for _ in range(N + K)]
    dp[0] = 0
    for i in range(N):
        for k in range(1, K + 1):
            if abs(h[i] - h[i + k]) + dp[i] < dp[i + k]:
                dp[i + k] = abs(h[i] - h[i + k]) + dp[i]
        # print(dp)
    return dp[N - 1]


if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    h = inputIntList()
    dp = [math.inf for _ in range(N)]
    dp[0] = 0
    for i in range(N - 2):
        if abs(h[i] - h[i + 1]) + dp[i] < dp[i + 1]:
            dp[i + 1] = abs(h[i] - h[i + 1]) + dp[i]

        if abs(h[i] - h[i + 2]) + dp[i] < dp[i + 2]:
            dp[i + 2] = abs(h[i] - h[i + 2]) + dp[i]
    
    return dp[N-1]


if __name__ == "__main__":
    print(main())

Buggy submission (verdict: Runtime Error):
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    h = inputIntList()
    dp = [math.inf for _ in range(N)]
    dp[0] = 0
    for i in range(N - 2):
        if abs(h[i] - h[i + 1]) + dp[i] < dp[i + 1]:
            dp[i + 1] = abs(h[i] - h[i + 1]) + dp[i]

        if abs(h[i] - h[i + 2]) + dp[i] < dp[i + 2]:
            dp[i + 2] = abs(h[i] - h[i + 2]) + dp[i]
    
    return dp[N-1]


if __name__ == "__main__":
    print(main())
Problem p03162 (python)

Fixed submission:
import math
import numpy as np


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    act = [inputIntList() for _ in range(N)]
    act.append([0, 0, 0])
    dp = [[0 for _ in range(3)] for _ in range(N + 1)]
    dp[0] = act[0]
    for i in range(1, N + 1):
        for j in range(3):
            dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j - 2]) + act[i][j]
            # print(dp)

    return max(dp[-1])


if __name__ == "__main__":
    print(main())

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


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    act = []
    for i in range(N):
        act.append(inputIntList())
    act.append([0, 0, 0])
    dp = [0 for _ in range(N + 1)]
    for i in range(N):
        dp[i + 1] = dp[i] + max(act[i])
        act[i + 1][np.argmax(act[i])] = 0
        # print(np.argmax(act[i]))

    return dp[-1]


if __name__ == "__main__":
    print(main())
Problem p03993 (python)

Fixed submission:
N = int(input())
usa = list(map(int, input().split()))
flag = [0 for x in range(N)]
count = 0
for i, ai in enumerate(usa):
    if(flag[i]):
        continue
    if(usa[ai-1]-1 == i):
        count+=1
        flag[ai - 1] = 1

print (count)

Buggy submission (verdict: Runtime Error):
N = int(input())
usa = list(map(int, input().split()))
flag = [0 for x in range(N)]
count = 0
for i, j in enumerate(usa):
    if(flag[i]):
        continue
    if(usa[j-1]-1 == i):
        count+=1
        flag[usa[j - 1]] = 1

print (count)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()                                                                                                                                                             
print(s.count('ABC'))

Buggy submission (verdict: Runtime Error):
n = int(input())                                                                    s = input()                                                                                                                                                             print(s.count('ABC'))
Problem p03284 (python)

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

if n % k == 0:
	print('0')
else :
	print('1')

Buggy submission (verdict: Runtime Error):
 a,b=map(int,input().split())#標準入力を行う
  print(a % b)

Buggy submission (verdict: Runtime Error):
A, B = map(int, raw_input().split())
print(A % B)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2:
    print("Odd")
else:
    print("Even")

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

if a*b % 2 == 0:
  print('Even')
else a*b % 2 == 1:
  print("Odd")
Problem p03469 (python)

Fixed submission:
date = input()
print(date.replace(date[:4],'2018'))

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

print(date.replace(date[4:],2018))
Problem p03059 (python)

Fixed submission:
A,B,T = map(int,input().split(" "))

num = int(T/A)

print(num*B)

Buggy submission (verdict: Runtime Error):
num = int(input())
V = list(input().split(" "))
C = list(input().split(" "))
result = 0

for i in range(num):
    Vi = int(V[i])
    Ci = int(C[i])
    if Vi <= Ci:
        continue
    result += (Vi - Ci )

print(result)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

def read_int_n():
    return list(map(int, input().split()))

def read_float_n():
    return list(map(float, input().split()))

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

#####2で奇数回割り切れる場合のみのflag
flag=0

a=[]
a_2=power2(A[0])

for i in range(len(A)): ###len(A) ###### A[0]をa=[]にappendする
  if power2(A[i])==a_2:
    a.append(int(A[i]*0.5)) ########## floatをintに直す
  else:
    flag=1

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)  
  
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

if flag==0:
  lcm=lcm_list(a)
  amari=NM[1]/lcm #50までは15,30,45の3つ
  amari=(amari+1)//2 #3つのうち奇数を切り上げ
  ########roundは偶数への丸め(0.5は1になる):https://note.nkmk.me/python-round-decimal-quantize/
  ########四捨五入するならdecimalモジュールのquantize('.01')
  #Decimal(i).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)
  print(int(amari)) 
else:
  print(0)
#print(flag,amari,NM[1],lcm,a,A)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

def read_int_n():
    return list(map(int, input().split()))

def read_float_n():
    return list(map(float, input().split()))

NM=read_int_n()
A=read_float_n()
A=list(set(A)) ##重複した要素を削除し、新たなリストを生成

##2で何回割れるかをcountする
def power2(n): ##参考：https://note.nkmk.me/python-prime-factorization/
  m=0
  while n % 2 == 0:
    m+=1
    n //= 2
  return m

a=[]
a_2=power2(A[0])

for i in range(NM[0]):
  if power2(A[i])==a_2:
    a.append(A[i]*0.5)

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

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

lcm=lcm_list(a)

amari=NM[1]/lcm #50までは15,30,45の3つ

print(int(round(amari/2))) #3つうち奇数を切り上げ
Problem p02886 (python)

Fixed submission:
n=int(input())
List = [int(i) for i in input().split()]
a=0
for i in range(n):
  for j in range(i):
    a+=List[i]*List[j]
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
List = [int(i) for i in input().split()]
ans=0
for i in range(n):
  for j in range(i):
    a+=List[i]*List[j]
print(ans)