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

Fixed submission:
H,N=map(int,input().split())
A=list(map(int,input().split()))
if H<=sum(A):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H, N=map(int,input().split())
A=list(map(int,input().split())
if H<=sum(A):
       print('Yes')
else:
       print('No')
Problem p02812 (python)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(str(input()))
count=0
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
count=0
for i in range(len(s)):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        count+=1
print(count)
Problem p02910 (python)

Fixed submission:
import sys
s=list(map(str,input()))
for i in range(len(s)):
    if i%2==0 and s[i]=='L':
        print('No')
        sys.exit()
    else:
        if i%2==1 and s[i]=='R':
            print('No')
            sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
import sys
import math
s=list(map(str,input()))
for i in range(math.ceil(len(s)/2)):
    if s[2*i]!='L' and s[2*i]!='U' and s[2*i]!='D':
        print('No')
        sys.exit()
for j in range(len(s)//2):
    if [2*i+1]!='R' and s[2*i+1]!='U' and s[2*i+1]!='D':
        print('No')
        sys.exit()
print('Yes')
Problem p02993 (python)

Fixed submission:
S=str(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
S=str(input())
if S[0]==S[1] or S[1]=S[2] or S[2]=S[3]:
    print('Bad')
else:
    print('Good')
Problem p03238 (python)

Fixed submission:
N=int(input())
if N==2:
    A,B=map(int,[input() for i in range(2)])
    print(A+B)
else:
    print('Hello World')

Buggy submission (verdict: Runtime Error):
N=int(input())
A=int(input())
B=int(input())
if N==1:
    print('Hello World')
else:
    print(A+B)
Problem p03292 (python)

Fixed submission:
A1,A2,A3=map(int,input().split())
A=[A1,A2,A3]
A.append(A1)
def A_(i):
    if A[i]-A[i+1]>=0:
        return A[i]-A[i+1]
    else:
        return A[i+1]-A[i]
B=[A_(i) for i in range(3)]
B.append(A_(0))
B.append(A_(1))
def sum(j):
    return B[j]+B[j+1]
C=[sum(j) for j in range(3)]
print(min(C))

Buggy submission (verdict: Runtime Error):
1,A2,A3=map(int,input().split())
A=[A1,A2,A3]
A.append(A1)
def A_(i):
    if A[i]-A[i+1]>=0:
        return A[i]-A[i+1]
    else:
        return A[i+1]-A[i]
B=[A_(i) for i in range(3)]
B.append(A_(0))
B.append(A_(1))
def sum(j):
    return B[j]+B[j+1]
C=[sum(j) for j in range(3)]
print(min(C))
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=a*b
if c%2==0:
    print(Even)
else:
    print(Odd)
Problem p03693 (python)

Fixed submission:
r,g,b=map(int,input().split())
if (100*r+10*g+b)%4==0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c=a*b
if c%2==0:
    print('Even')
else:
    print('Odd')
Problem p02783 (python)

Fixed submission:
H, A = map(int, input().split())
print(-(-H // A))

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

H = S1[0]

if H > sum(S2):
    print("no")
else:
    print("yes")
Problem p02784 (python)

Fixed submission:
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def Raccon_vs_Monster():
    H, N = wczytaj_liste()
    ruchy = wczytaj_liste()
    suma_obrazen = sum(ruchy)
    if suma_obrazen >= H:
        print('Yes')
    else:
        print('No')

Raccon_vs_Monster()

Buggy submission (verdict: Runtime Error):
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def Raccon_vs_Monster():
    H, N = wczytaj_liste()
    ruchy = wczytaj_liste()
    suma_obrazen = ruchy.sum()
    if suma_obrazen >= H:
        print('Yes')
    else:
        print('No')

Raccon_vs_Monster()
Problem p02830 (python)

Fixed submission:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def B_strings(): 
    N = wczytaj_liste()[0]
    wczytaj = input()
    S, T = wczytaj.split()
    odp = []
    for i in range(N): 
        odp.append(S[i])
        odp.append(T[i])
    print(''.join(odp))

B_strings()

Buggy submission (verdict: Runtime Error):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista

def B_strings(): 
    N = wczytaj_liste()[0]
    S = input()
    T = input()
    odp = []
    for i in range(N): 
        odp.append(S[i])
        odp.append(T[i])
    print(''.join(odp))

B_strings()
Problem p03172 (python)

Fixed submission:
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def ciasteczka(): 
    N, K = wczytaj_liste()
    max_cukierkow = wczytaj_liste()
    przed = [1]
    for dziecko in max_cukierkow:
        po = [None]* min(len(przed)+ dziecko, K+1)
        suma_kroczaca = 0
        for i in range(len(po)):
            if len(przed) > i: #trzeba dodać
                suma_kroczaca += przed[i]
            if i-dziecko-1 > -1:
                suma_kroczaca -= przed[i-dziecko-1]
            suma_kroczaca %= 10**9+7
            po[i] = suma_kroczaca
        przed = po
    if K < len(przed):
        print(przed[K])
    else:
        print(0)
    
ciasteczka()

Buggy submission (verdict: Runtime Error):
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista 

def ciasteczka(): 
    N, K = wczytaj_liste()
    max_cukierkow = wczytaj_liste()
    przed = [1]
    for dziecko in max_cukierkow:
        po = [0]* min(len(przed)+ dziecko, K+1)
        for i in range(len(po)):
            for b in range(dziecko+1):
                j = i - b
                if  0 <= j < len(przed):
                    po[i] += przed[j]
                    if po[i] >= 10**9+7:
                        po[i] -= 10**9+7
        przed = po
    print(przed[K])
    
ciasteczka()
Problem p02783 (python)

Fixed submission:
a, b = map(int, input().split())
c = a//b
if (a%b == 0):
    d = c
else :
    d = c+1
print(d)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = input().split()
if (k >= len(h)):
    h.clear()
else:
    for i in range(k):
        m = max(h)
        h.remove(m)
b = 0
sum(h)
print(b)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = input().split()
if (k > len(h)):
    h.clear()
else:
    for i in range(k):
        m = max(h)
        h.remove(m)
b = 0
for i in range(len(h)):
    b += int(h[i])

print(b)

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b or has_duplicates(a) or len(a) > n ):
    print("No")
else:
    print("Yes")
Problem p02784 (python)

Fixed submission:
h, n = map(int, input().split())
a = input().split()
b = 0
def has_duplicates(seq):
    return len(seq) != len(set(seq))

for i in range(n):
    b += int(a[i])
if (h > b ):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = input().split()
b = 0
for i in range(n):
    b += int(a[i])
if (h < b and has_duplicates(a) and len(a)>n ):
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = input().split()
b = 0
for i in range(n):
    b += int(a[i])
if (h < b and has_duplicates(a)):
    print("No")
else:
    print("Yes")
Problem p02786 (python)

Fixed submission:
h = int(input())

count = 0
while h > 1 :
    h = h // 2
    count += 1

sum = 0
for i in range(count+1) :
    sum = sum + 2**i

print(sum)

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

sum = [0] * (h+1)

#print(sum)

for i in range(1, h+1) :
    sum[i] = 2*sum[i//2] + 1

print(sum[h])
Problem p03854 (python)

Fixed submission:
s = input()
res = -1

while len(s) > 0 :

    if len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "erase" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        s = s[0:len(s)-5]
      else :
          res = 1
          s = s[0:len(s)-5]

    elif len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "dream" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        s = s[0:len(s)-5]
      else :
          res = 1
          s = s[0:len(s)-5]

    elif len(s) - 6 >= 0 and s[len(s)-6:len(s)] == "eraser" :
      #print(s[0:len(s)-6])
      if len(s) - 6 > 0 :
        s = s[0:len(s)-6]
      else :
          res = 1
          s = s[0:len(s)-6]

    elif len(s) - 7 >= 0 and s[len(s)-7:len(s)] == "dreamer" :
      #print(s[0:len(s)-7])
      if len(s) - 7 > 0 :
        s = s[0:len(s)-7]
      else :
          res = 1
          s = s[0:len(s)-7]

    else :
        res = 0
        s = ""


if res==1 :
    print("YES")
else :
    #print(res)
    print("NO")

Buggy submission (verdict: Runtime Error):
def isdreame(s) :
    res = -1

    if len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "erase" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        res = isdreame(s[0:len(s)-5])
      else :
          res = 1

    elif len(s) - 5 >= 0 and s[len(s)-5:len(s)] == "dream" :
      #print(s[0:len(s)-5])
      if len(s) - 5 > 0 :
        res = isdreame(s[0:len(s)-5])
      else :
          res = 1

    elif len(s) - 6 >= 0 and s[len(s)-6:len(s)] == "eraser" :
      #print(s[0:len(s)-6])
      if len(s) - 6 > 0 :
        res = isdreame(s[0:len(s)-6])
      else :
          res = 1

    elif len(s) - 7 >= 0 and s[len(s)-7:len(s)] == "dreamer" :
      #print(s[0:len(s)-7])
      if len(s) - 7 > 0 :
        res = isdreame(s[0:len(s)-7])
      else :
          res = 1

    else :
        res = 0

    return res

s = input()
res = isdreame(s)

if res==1 :
    print("YES")
else :
    #print(res)
    print("NO")
Problem p02922 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if b == 1:
  print(0)
else:
  ans = 1
  while True:
    if ans * a - (ans-1) >= b:
   	  break
 	ans += 1
  print(ans)
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans += (1/a[i])
print(1/ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
ans = 0
for i in range(n):
  ans += (1/a[i])
print(1/ans)
Problem p03001 (python)

Fixed submission:
W,H,x,y = map(int, input().split())
if int(x + x) == W and int(y + y) == H:
  print(str((W*H)/2) + " " + "1")
else:
  print(str((W*H)/2) + " " + "0")

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int, input().split())
if x == int(W/2) and y == int(H/2):
  print(int((W*H)/2) + " " + "1")
else:
  print(int((W*H)/2) + " " + "0")
Problem p03006 (python)

Fixed submission:
N = int(input())


def solve():

    initial_cost = 1

    # (x,y) list
    xy_list = []
    for i in range(N):
        x, y = map(int, input().split())
        xy_list.append((x, y))
    xy_list_sorted = sorted(xy_list, key=lambda a: a[0])

    if N == 1 or N == 2:
        return initial_cost

    xy_sub_dic = {}
    for i in range(N):
        for j in range(N):
            xs = xy_list_sorted[j][0] - xy_list_sorted[i][0]
            ys = xy_list_sorted[j][1] - xy_list_sorted[i][1]
            if xs != 0 or ys != 0:
                if xy_sub_dic.get((xs, ys)) is None:
                    xy_sub_dic[(xs, ys)] = 1
                else:
                    xy_sub_dic[(xs, ys)] += 1

    xy_sub_dic_sorted = sorted(xy_sub_dic.items(), key=lambda a: a[1], reverse=True)

    return initial_cost + (N - 1) - xy_sub_dic_sorted[0][1]
print(solve())

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

cost = 1
xy_set = []
for i in range(N):
    x, y = map(int, input().split())
    xy_set.append((x, y))
xy_set_sorted = sorted(xy_set, key=lambda a: a[0])

xy_sub_set = {}
for i in range(1, N):
    xs = xy_set_sorted[i][0] - xy_set_sorted[i-1][0]
    ys = xy_set_sorted[i][1] - xy_set_sorted[i - 1][1]
    if xy_sub_set.get((xs, ys)) is None:
        xy_sub_set[(xs, ys)] = 1
    else:
        xy_sub_set[(xs, ys)] += 1

xy_sub_set_sorted = sorted(xy_sub_set.items(), key=lambda a: a[1], reverse=True)
print(cost + (N-1) - xy_sub_set_sorted[0][1])
Problem p03030 (python)

Fixed submission:
N = int(input())

dic = {}
for i in range(1, N+1):
    s, p = map(str, input().split())
    p = int(p)
    if dic.get(s) is None:
        dic[s] = [(i, p)]
    else:
        dic[s].append((i, p))

for k in dic:
    tmp = sorted(dic[k][:], key=lambda x: -x[1])
    dic[k] = tmp

inds = []
ind = 1
for k in sorted(dic.keys()):
    for t in dic[k]:
        inds.append((t[0], ind))
        ind += 1

for ind in sorted(inds, key=lambda x: x[1]):
    print(ind[0])

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

dic = {}
order = []
for i in range(1,N+1):
    s, p = map(str, input().split())
    p = int(p)
    order.append((s, p))
    if dic.get(s) is None:
        dic[s] = [(i, p)]
    else:
        dic[s].append((i, p))

for k in dic:
    tmp = dic[k][:]
    tmp2 = sorted(tmp, key=lambda x: -x[1])
    dic[k] = tmp2

inds = []
ind = 1
for k in sorted(dic.keys(), key=lambda x: x[1]):
    for t in dic[k]:
        inds.append((t[0], ind))
        ind += 1

for ind in sorted(inds, key=lambda x: x[1]):
    print(ind[0])
Problem p03049 (python)

Fixed submission:
N = int(input())

ans = 0
dic = {"A": 0, "B": 0}
dic2 = {"AB": 0, "A": 0, "B": 0}
for i in range(N):
    S = list(str(input()))
    pre = S[0]
    for j in range(1, len(S)):
        if (S[j - 1] + S[j]) == "AB":
            ans += 1
    if S[-1] == "A":
        dic["A"] += 1
    if S[0] == "B":
        dic["B"] += 1

    if S[-1] == "A" and S[0] == "B":
        dic2["AB"] += 1
    elif S[-1] == "A":
        dic2["A"] += 1
    elif S[0] == "B":
        dic2["B"] += 1

if dic2["A"] == 0 and dic2["B"] == 0:
    print(ans + max(dic2["AB"] - 1, 0))
else:
    print(ans + min(dic["A"], dic["B"]))

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

ans = 0
dic = {"A": 0, "B": 0}
dic2 = {"AB": 0, "A": 0, "B": 0}
for i in range(N):
    S = list(str(input()))
    pre = S[0]
    for j in range(1, len(S)):
        if (S[j - 1] + S[j]) == "AB":
            ans += 1
    if S[-1] == "A":
        dic["A"] += 1
    if S[0] == "B":
        dic["B"] += 1

    if S[-1] == "A" and S[0] == "B":
        dic2["AB"] += 1
    elif S[-1] == "A":
        dic2["A"] += 1
    elif S[0] == "B":
        dic2["B"] += 1
if dic2["A"] == 0 and dic2["B"] == 0:
    print(ans + dic["AB"]//2)
else:
    print(ans + min(dic["A"], dic["B"]))
Problem p03061 (python)

Fixed submission:
import fractions

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

# correct
L = [0] * N
R = [0] * N

for i in range(1, N):
    L[i] = fractions.gcd(L[i - 1], A[i - 1])
for j in range(0, N-1)[::-1]:
    R[j] = fractions.gcd(R[j + 1], A[j + 1])
ans = 0
for k in range(N):
    ans = max(ans, fractions.gcd(L[k], R[k]))
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

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

def mass_gcd(L):
    # num is 1
    if len(L) == 1:
        return L[0]
    else:
        max_gcd = fractions.gcd(L[0], L[1])

    # solve gcd
    for _ in range(1, len(L) - 1):
        max_gcd = max(max_gcd, fractions.gcd(L[i], L[i + 1]))
    return max_gcd

ans = mass_gcd(A)
for i in range(0, N):
    left = A[:i]
    right = A[(i + 1):]
    if len(left) == 0:
        pass
    elif len(right) == 0:
        pass
    else:
        ans = max(ans, fractions.gcd(mass_gcd(left), mass_gcd(right)))
print(ans)
Problem p03126 (python)

Fixed submission:
import copy

N, M = map(int, input().split())

like = list(map(int, input().split()))
like.pop(0)
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  like.pop(0)
  tmp = copy.deepcopy(all_like)
  for l in all_like:
    if l not in like:
      tmp.remove(l);
  all_like = tmp
print(len(all_like))

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

like = list(map(int, input().split()))
all_like = set()
for l in like:
	all_like.add(l)
    
for i in range(N-1):
  like = list(map(int, input().split()))
  for l in like:
    if l not in all_like:
      all_like.remove(l);
print(len(all_like))

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

like = list(map(int, input().split()))
all_like = set()
for l in like:
	all_like.add(l)
for i in range(N):
  like = list(map(int, input().split()))
  for l in like:
    if l not in all_like:
      all_like.remove(l);
print(len(all_like))
Problem p03263 (python)

Fixed submission:
H, W = map(int, input().split())
mat = []
for _ in range(H):
    mat.append(list(map(int, input().split())))

ans = []
sw_rev = 0
for i in range(H):
    if sw_rev == 0:
        for j in range(W):
            if mat[i][j] % 2 != 0:
                if j == W-1:
                    if i == H-1:
                        continue
                    mat[i+1][j] += 1
                    ans.append((i, j, i+1, j))
                else:
                    mat[i][j+1] += 1
                    ans.append((i, j, i, j+1))
        sw_rev = 1
    else:
        for j in range(W)[::-1]:
            if mat[i][j] % 2 != 0:
                if j == 0:
                    if i == H-1:
                        continue
                    mat[i+1][j] += 1
                    ans.append((i, j, i+1, j))
                else:
                    mat[i][j-1] += 1
                    ans.append((i, j, i, j-1))
        sw_rev = 0
print(len(ans))
for x1, y1, x2, y2 in ans:
    print(x1+1, y1+1, x2+1, y2+1)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
mat = []
for _ in range(H):
    mat.append(list(map(int, input().split())))

ans = []
sw_rev = 0
for i in range(H):
    if sw_rev == 0:
        for j in range(W):
            if mat[i][j] % 2 != 0:
                if j == W-1:
                    if i == H-1:
                        continue
                    mat[i+1][j] += 1
                    ans.append((i, j, i+1, j))
                else:
                    mat[i][j+1] += 1
                    ans.append((i, j, i, j+1))
        sw_rev = 1
    else:
        for j in range(W)[::-1]:
            if mat[i][j] % 2 != 0:
                N += 1
                if j == 0:
                    if i == H-1:
                        continue
                    mat[i+1][j] += 1
                    ans.append((i+1, j, i, j))
                else:
                    mat[i][j-1] += 1
                    ans.append((i, j, i, j-1))
        sw_rev = 0
print(len(ans))
for x1, y1, x2, y2 in ans:
    print(x1+1, y1+1, x2+1, y2+1)
Problem p03294 (python)

Fixed submission:
from functools import reduce


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


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


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


N = int(input())
a = list(map(int, input().split()))

lcm_num = lcm_list(a) - 1
ans = 0
for i in range(N):
    ans += lcm_num % a[i]
print(ans)

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


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


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


N = int(input())
a = list(map(int, input().split()))

lcm_num = lcm_list(a) - 1
ans = 0
for i in range(N):
    ans += lcm_num % a[i]
print(ans)

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


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


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


N = int(input())
a = list(map(int, input().split()))

lcm_num = lcm_list(a) - 1
ans = 0
for i in range(N):
    ans += lcm_num % a[i]
print(ans)

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

N = int(input())
a = list(map(int, input().split()))


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


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


lcm_num = lcm_list(a) - 1
ans = 0
for i in range(N):
    ans += lcm_num % a[i]
print(ans)
Problem p03309 (python)

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

A_sorted = sorted([A[i] - (i+1) for i in range(N)])

if len(A) != 1:
    b = A_sorted[int((len(A)-1)/2)]
    b2 = A_sorted[int((len(A)-1)/2 + 1)]
    sad_1 = sum([abs(A_sorted[i] - b) for i in range(N)])
    sad_2 = sum([abs(A_sorted[i] - b2) for i in range(N)])
    print(min(sad_1, sad_2))
else:
    print('0')

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

A_sorted = sorted([A[i] - (i+1) for i in range(N)])
b = A_sorted[int((len(A)-1)/2)]
b2 = A_sorted[int((len(A)-1)/2 + 1)]

sad_1 = sum([abs(A_sorted[i] - b) for i in range(N)])
sad_2 = sum([abs(A_sorted[i] - b2) for i in range(N)])

print(min(sad_1, sad_2))

Buggy submission (verdict: Runtime Error):
ans = 9999999
res = 0
for i in range(N):
    res += A[i] - (i+1)

b = res // N
res = 0
for i in range(N):
    res += abs(A[i] - (b+(i+1)))
print(res)
Problem p03359 (python)

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

a, b = map(int, input().split())

if a <= b:
    print(a)
else:
    print(a - 1)

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


def is_sosu(x):
    for i in range(2, x):
        if x % i == 0:
            return False
    return True

N = int(input())
sosu = []
for candidate in range(2, 55555):
    if is_sosu(candidate) and candidate % 5 == 1:
        sosu.append(candidate)
        if len(sosu) >= N:
            break
print(' '.join([str(s) for s in sosu]))

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


def is_sosu(x):
    for i in range(2, x):
        if x % i == 0:
            return False
    return True


def is_gosei(x):
    for i in range(2, x):
        if x % i == 0:
            return True
    return False


def check(lis):
    for i in range(len(lis)):
        for j in range(i, len(lis)):
            for k in range(j, len(lis)):
                for l in range(k, len(lis)):
                    for m in range(l, len(lis)):
                        if is_gosei(lis[i] + lis[j] + lis[k] + lis[l] + lis[m]):
                            pass
                        else:
                            return False
    return True

N = int(input())
sosu = []
for candidate in range(2, 1000):
    if is_sosu(candidate):
        sosu.append(candidate)

for n in range(0, len(sosu)-N, N):
    if check(sosu[n:n + N]):
        print(' '.join([str(s) for s in sosu[n:n + N]]))
        break