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

Fixed submission:
# -*- coding: utf-8 -*-

n = int(input())

a = []

for i in range(n):
    a_list = list(map(int, input().split()))
    a_dict = {i:e for i,e in enumerate(a_list[:i])}
    a.append(a_dict)

if n == 1:
    print("-1")
    exit()

elif n == 2:
    print(a[1][0])
    exit()

# Minimam total path length
min_total = 0

for i in range(n):
    dim = i+1
    if dim == 1:
        continue
    elif dim == 2:
        min_total += a[1][0]
        continue

    paths_to_subgraph = []
    a_sorted = sorted(a[i].items(), key=lambda e:e[1])

    dest, path = a_sorted.pop(0)
    paths_to_subgraph.append((dest, path))
    min_total += path

    for dest, path in a_sorted:
        create_path = True
        for detour in paths_to_subgraph:
            detour_path = detour[1] + a[max([dest,detour[0]])][min([dest,detour[0]])]
            if path > detour_path:
                print("-1")
                exit()
            elif path == detour_path:
                create_path = False

        if create_path:
            for detour in paths_to_subgraph:
                detour_path = detour[1] + path
                minpath = a[max([dest,detour[0]])][min([dest,detour[0]])]
                if minpath > detour_path:
                    print("-1")
                    exit()
                elif minpath == detour_path:
                  # Delete path
                  min_total -= minpath
            paths_to_subgraph.append((dest, path))
            min_total += path

print(min_total)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())

a = []

for i in range(n):
    a_list = list(map(int, input().split()))
    a_dict = {i:e for i,e in enumerate(a_list[:i])}
    a.append(a_dict)

if n == 1:
    print("-1")
    exit()

elif n == 2:
    print(a[0][1])
    exit()

# Minimam total path length
min_total = 0

for i in range(n):
    dim = i+1
    if dim == 1:
        continue
    elif dim == 2:
        min_total += a[1][0]
        continue

    paths_to_subgraph = []
    a_sorted = sorted(a[i].items(), key=lambda e:e[1])

    dest, path = a_sorted.pop(0)
    paths_to_subgraph.append((dest, path))
    min_total += path

    for dest, path in a_sorted:
        create_path = True
        for detour in paths_to_subgraph:
            detour_path = detour[1] + a[max([dest,detour[0]])][min([dest,detour[0]])]
            if path > detour_path:
                print("-1")
                exit()
            elif path == detour_path:
                create_path = False

        if create_path:
            for detour in paths_to_subgraph:
                detour_path = detour[1] + path
                minpath = a[max([dest,detour[0]])][min([dest,detour[0]])]
                if minpath > detour_path:
                    print("-1")
                    exit()
                elif minpath == detour_path:
                  # Delete path
                  min_total -= minpath
            paths_to_subgraph.append((dest, path))
            min_total += path

print(min_total)
Problem p03602 (python)

Fixed submission:
def warshall_floyd(G):
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

if A == warshall_floyd(A):
    ans = 0
    for i in range(1, N):
        for j in range(0, i):
            if min([A[i][k] + A[k][j] - A[i][j] for k in range(N) if k != i and k != j] + [1]) > 0:
                ans += A[i][j]
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def warshall_floyd(G):
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

if A == warshall_floyd(A):
    ans = 0
    for i in range(1, N):
        for j in range(0, i):
            if min([A[i][k] + A[k][j] - A[i][j] for k in range(N) if k != i and k != j]) > 0:
                ans += A[i][j]
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def warshall_floyd(G):
    import copy
    ret = copy.deepcopy(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                ret[i][j] = min(ret[i][j], ret[i][k] + ret[k][j])
    return ret


N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

if A == warshall_floyd(A):
    ans = 0
    for i in range(1, N):
        for j in range(0, i):
            if min([A[i][k] + A[k][j] - A[i][j] for k in range(N) if k != i and k != j]) > 0:
                ans += A[i][j]
    print(ans)
else:
    print(-1)
Problem p03633 (python)

Fixed submission:
def lcm(x, y):
    from fractions import gcd
    return (x * y) // gcd(x, y)


N, ans = int(input()), 1
for _ in range(N):
    ans = lcm(ans, int(input()))
print(ans)

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


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


N = int(input())
T = [int(input()) for _ in range(N)]
print(reduce(lcm, T, 1))
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
A = 0
arr = [int(x) for x in input().split()]
A = sum(arr)
x = A/(4 * m)
count = 0
for i in range(n):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
sum = 0
arr = [int(x) for x in input().split()]
for i in range(n):
	sum += arr[i]
x = math.ceil(sum/(4 * m))
count = 0
for i in range(m):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
sum = 0
arr = [int(x) for x in input().split()]
for i in range(n):
	sum += arr[i]
x = sum/(4 * m)
count = 0
for i in range(m):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")
Problem p02772 (python)

Fixed submission:
n=int(input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3!=0 and check[i]%5!=0:
            f=1
                
if f==1:
    print("DENIED")
else:
    print("APPROVED")

Buggy submission (verdict: Runtime Error):
n=map(int,input())
check=list(map(int,input().split()))
f=0
for i in range(n):
    if check[i]%2==0:
        if check[i]%3==0 or check[i]%5==0:
            f=1
            
if f==1:
    print("APPROVED")
else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))

for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            x=1
            
        else: x=0
if x==1:print("APPROVED")
else: print("DENIED")

Buggy submission (verdict: Runtime Error):
n = int(input())
    ls = list(map(int,input().split(' ')))
    f=0
    for i in range(0,n):
        if(ls[i]%2==0):
            if(ls[i]%3!=0 and ls[i]%5!=0):
                f=1
    if(f):
        print("DENIED")
    else:
        print("APPROVED")

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=list(map(int,input().split()))
for i in range(n):
  if lst[i]%2==0:
    if lst[i]%3==0 or lst[i]%5==0:
      result=1
  if result==1:
    print("APPROVED")
  else:
    print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
a,b,c=map(int,input().split())
lst.append(a)
lst.append(b)
lst.append(c)
for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            print("APPROVED")
        else:
            print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(0,n):
    ele=int(input())
    lst.append(ele)

for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            print("APPROVED")
        else:
            print("DENIED")
Problem p02778 (python)

Fixed submission:
s=len(input())
print("x"*s)

Buggy submission (verdict: Runtime Error):
s=input()
for i in len(s):
    s[i]="x"
print(s)
Problem p04043 (python)

Fixed submission:
ans=list(map(int,input().split()))
if ans.count(5)==2 and ans.count(7)==1:
    print("YES")
else: print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Buggy submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Buggy submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Buggy submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))
Problem p02582 (python)

Fixed submission:
s = input()
if s == 'RRR':
  print(3)
elif s=='RSR' or s=='SRS' or s=='SSR' or s=='RSS':
  print(1)
elif s == s=='RRS' or s=='SRR':
  print(2)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[k]!=A[j]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)
Problem p02583 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[j]!=A[k]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
A.sort()
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]+A[j])>A[k] and (A[j]+[k])>A[i] and (A[i]+A[k])>A[j] and 
      A[i]!=A[k] and A[j]!=A[k] and A[i]!=A[j]:
        cnt+=1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if (A[i]+A[j])>A[k] and (A[j]+[k])>A[i] and (A[i]+A[k])>A[j] and 
      A[i]!=A[k] and A[j]!=A[k] and A[i]!=A[j]:
        cnt+=1
        
print(cnt)
Problem p03408 (python)

Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),res)
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
s=[input() for _ in range(n)]
m = int(input())
t=[input() for _ in range(m)]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),ans)
print(res)

Buggy submission (verdict: Runtime Error):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),ans)
print(res)
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split())
print(a * b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().ssplit())
print(a * b)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
if len(t - s) == 1:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
a = s[i] == t[i]
b = len(t) - len(s) == 1
if for i in range(len(s)):
  a and b:
print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
a = for i in range(len(s)):
  s[i] == t[i]
b = len(t) - len(s) == 1
if a and b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
a = for i in range(len(s)):
  s[i] == t[i]

if len(s) - len(t) == -1 and a:
  print("yes")
else:
  print("no")

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
if len(t) - len(s) == 1 and for i in range(len(t)):
  s[i] == t[i] 
  print("yes")
else:
  print("no")
Problem p03062 (python)

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

minus_count = 0

for a in A:
    if a < 0:
        minus_count += 1

total = 0
min_num = 10 ** 9

for a in A:
    total += abs(a)
    min_num = min(min_num, abs(a))

if minus_count % 2 == 1:
    total -= 2 * min_num

print(total)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))


@lru_cache(maxsize=None)
def rec(i, reverse):
    if i == N - 1:
        return A[i] * reverse

    num_normal = rec(i + 1, +1) + (A[i] * reverse)
    num_reverse = rec(i + 1, -1) + (-A[i] * reverse)

    return max(num_normal, num_reverse)


print(rec(0, 1))
Problem p03087 (python)

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

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    l, r = map(int, input().split())
    result = hit[r - 1] - hit[l - 1]
    print(result)

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

hit = [0] * N

for i in range(0, N - 1):
    hit[i + 1] = hit[i]

    if S[i:i+2] == 'AC':
        hit[i + 1] += 1

for _ in range(0, Q):
    result = hit[r - 1] - hit[l - 1]
    print(result)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache

N, Q = map(int, input().split())
S = input()

hit = [False] * N


@lru_cache(maxsize=None)
def ac_count(start, end):
    if start == end:
        return 0

    end_count = 1 if hit[end - 1] else 0

    return ac_count(start, end - 1) + end_count


for i in range(0, N):
    if S[i:i+2] == 'AC':
        hit[i] = True

for _ in range(0, Q):
    l, r = map(int, input().split())
    print(ac_count(l - 1, r - 1))
Problem p03206 (python)

Fixed submission:
D = int(input())

if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]

h.sort()

min_h = 1000000000

for i in range(K - 1, N):
    min_h = min(min_h, h[i] - h[i - K + 1])

print(min_h)
Problem p02582 (python)

Fixed submission:
inn = input()
numR = 0
for c in inn:
    if c == 'R':
        numR += 1
if numR != 2:
    print(numR)
else:
    print(1 if inn[1] == 'S' else 2)

Buggy submission (verdict: Runtime Error):
inn = input()
numS = 0
for c in inn:
    if c == 'R':
        numS += 1
if numR != 2:
    print(numR)
else:
    print(1 if inn[1] == 'S' else 2)

Buggy submission (verdict: Runtime Error):
inn = input()
numS = 0
for c in inn:
    if c == 'R':
        numS += 1
if numR != 2:
    print(numR)
else:
    print(1 if inn[1] == 'S' else 2);
Problem p03281 (python)

Fixed submission:
import sys

def div(n):
    count = 0
    for i in range(1, n+1):
        count += 1 if n%i==0 else 0
    return count

ans = 0
for i in range(1, int(input())+1):
    ans += 1 if i%2==1 and div(i) == 8 else 0
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import sympy

ans = 0
for i in range(1, int(input())+1):
    ans += 1 if i%2==1 and len(sympy.divisors(i)) == 8 else 0
print(ans)
Problem p02657 (python)

Fixed submission:
a,b = map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b = input().split()
print(a*b)
Problem p02732 (python)

Fixed submission:
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
A__=list(set(A))
A_=Counter(A)
S=0
for a in A__:
    k=a
    v=A_[a]
    if v<2:
        continue
    a=v*(v-1)//2
    S+=a

for a in A:
    x=A_[a]
    y=x*(x-1)//2
    S-=y
    z=(x-1)*(x-2)//2
    print(S+z)
    S+=y

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

A_=Counter(A)
D=[0]*N
S=0
for k,v in A_.items():
    if v<2:
        continue
    a=v*(v-1)//2
    D[k]=a
    S+=a

for a in A:
    x=A_[a]
    y=x*(x-1)//2
    S-=y
    z=(x-1)*(x-2)//2
    print(S+z)
    S+=y
Problem p02756 (python)

Fixed submission:
from collections import deque

S=list(input())
Q=int(input())
Sq=deque(S)

flag=1
for _ in range(Q):
    q=input().split()
    if q[0]=='1':
        flag*=-1
        continue
    if (q[1]=='1' and flag==-1) or (q[1]=='2' and flag==1):
        Sq.append(q[2])
    else:
        Sq.appendleft(q[2])
if flag==1:
    print(''.join(Sq))
else:
    Sq.reverse()
    print(''.join(Sq))

Buggy submission (verdict: Runtime Error):
from collections import deque
S=list(input())
Q=int(input())
Qlst=[list(input().split()) for _ in range(Q)]

len_S=len(S)
s0=deque(sorted(S[:len_S//2]))
s1=deque(S[len_S//2:])

if len_S%2!=0:
    mid=s1.popleft()
else:
    mid=''

fflag=0
for i in range(Q):
    q=Qlst[i]
    if q[0]=='1':
        fflag=abs(fflag-1)
        continue
    if q[1]=='1':
        if fflag==0:
            s0.append(q[2])
            if mid=='':
                mid=s0.popleft()
            else:
                s1.insert(0,mid)
                mid=''
        else:
            s1.append(q[2])
            if mid=='':
                mid=s1.popleft()
            else:
                s0.insert(0,mid)
                mid=''
    elif q[1]=='2':
        if fflag==0:
            s1.append(q[2])
            if mid=='':
                mid=s1.popleft()
            else:
                s0.append(mid)
                mid=''
        else:
            s0.append(q[2])
            if mid=='':
                mid=s0.popleft()
            else:
                s1.append(mid)
                mid=''

if fflag==0:
    s0.reverse()
    print(''.join(s0)+mid+''.join(s1))
else:
    s1.reverse()
    print(''.join(s1)+mid+''.join(s0))

Buggy submission (verdict: Runtime Error):
from collections import deque
S=list(input())
Q=int(input())
Qlst=[list(input().split()) for _ in range(Q)]

len_S=len(S)
s0=deque(sorted(S[:len_S//2]))
s1=deque(S[len_S//2:])

if len_S%2!=0:
    mid=s1.popleft()
else:
    mid=''

fflag=0
for i in range(Q):
    q=Qlst[i]
    if q[0]=='1':
        fflag=abs(fflag-1)
        continue
    if q[1]=='1':
        if fflag==0:
            s0.append(q[2])
            if mid=='':
                mid=s0.popleft()
            else:
                s1.insert(0,mid)
                mid=''
        else:
            s1.append(q[2])
            if mid=='':
                mid=s1.popleft()
            else:
                s0.insert(0,mid)
                mid=''
    elif q[1]=='2':
        if fflag==0:
            s1.append(q[2])
            if mid=='':
                mid=s1.popleft()
            else:
                s0.append(mid)
                mid=''
        else:
            s0.append(q[2])
            if mid=='':
                mid=s0.popleft()
            else:
                s1.append(mid)
                mid=''

if fflag==0:
    s0.reverse()
    print(''.join(s0)+mid+''.join(s1))
else:
    s1.reverse()
    print(''.join(s1)+mid+''.join(s0))
Problem p02814 (python)

Fixed submission:
import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt

C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]
W=set()
for i in range(N):
    if A[i]%2!=0:
        W.add(0)
    else:
        a=A[i]//2
        cnt=1
        while a%2!=0:
            a=a//2
            cnt+=1
        W.add(cnt)
if len(W)>1:
    print(0)
    exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M//LCM)//2))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]

def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M//LCM)//2))
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]

def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M/LCM)//2))
print(ans)
Problem p02917 (python)

Fixed submission:
N=int(input())
b=list(map(int,input().split()))
a=b[0]
for i in range(0,N-2):
    a+=min(b[i],b[i+1])
print(a+b[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
b=list(map(int,input().split()))
if N==1:
    a=[b[0]]*2
elif N==2:
    minb=min(b[0],b[1])
    a=[minb]*2
    a.append(b[-1])    
elif N>2:
    minb=min(b[0],b[1])
    a=[minb]*2
    for i in range(1,N-2):
        minb=min(b[i],b[i+1])
        a.append(minb)
    a.append(b[-1])
print(sum(a))
Problem p02936 (python)

Fixed submission:
N,Q=map(int,input().split())
d=[[] for _ in range(N+1)]

ans=[0]*(N+1)
for i in range(1,N):
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)

for i in range(Q):
    p,x=map(int,input().split())
    ans[p]+=x

from collections import deque
flag=[0]*(N+1)
q=deque([1])
while q:
    k=q.popleft()
    flag[k]=1
    for v in d[k]:
        if flag[v]==1:
            continue
        ans[v]+=ans[k]
        q.appendleft(v)

print(*ans[1:])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
d={i:[] for i in range(1,N+1)}

ans=[0]*N
for i in range(1,N):
    a,b=map(int,input().split())
    d[a].append(b)

def f(n,x):
    if d[n]==[]:
        return 0
    for m in d[n]:
        ans[m-1]+=x
        f(m,x)

for i in range(Q):
    p,x=map(int,input().split())
    ans[p-1]+=x
    hoge=f(p,x)

for a in ans:
    print(a,end=' ')
Problem p02947 (python)

Fixed submission:
N=int(input())
d={}
ans=0
for i in range(N):
    s=''.join(sorted(input()))
    if s in d:
        ans+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(ans)

Buggy submission (verdict: Runtime Error):
d={}
ans=0
for i in range(N):
    s=''.join(sorted(input()))
    if s in d:
        ans+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(ans)