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

Fixed submission:
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for i in data:
    ans=count-data_cnt[i]+1
    print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
ans=[0]*n
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for a,b in data_cnt.items():
    if 2<=b:
        ans[a]=int(count-b+1)
for i in data:
    print(ans[i-1])

Buggy submission (verdict: Runtime Error):
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
ans=[0]*n
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for a,b in data_cnt.items():
    ans[a]=int(count-b+1)
for i in data:
    print(ans[i])
Problem p02761 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
data=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    if data[s-1]!=0 and data[s-1]!=c:
        print(-1)
        sys.exit()
    if s==1 and c==0 and n!=1:
        print(-1)
        sys.exit()
    data[s-1]=c
if data[0]==0 and n!=1:
    data[0]=1
ans=0
for i in range(n):
    ans+=data[i]*10**(n-i-1)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
ans=[0]*n
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        sys.exit()
    if s==1 and c==0 and n!=1:
        print(-1)
        sys.exit()
    ans[s-1]=c
if ans[0]==0 and n!=0:
num=0
for i in range(n):
    num+=ans[i]*(10**(n-i-1))
print(num)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
ans=[0]*n
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]!=0 and ans[s-1]!=c:
        print(-1)
        sys.exit()
    if s==1 and c==0 and n!=1:
        print(-1)
        sys.exit()
    ans[s-1]=c
if ans[0]==0:
    print(-1)
else:
    num=0
    for i in range(n):
        num+=ans[i]*(10**(n-i-1))
print(num)
Problem p02848 (python)

Fixed submission:
n=int(input())
s=input()
ans=[]
for i in range(len(s)):
    num=ord(s[i])+n
    if num>90:
        num-=26
    ans.append(chr(num))
ans="".join(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=[]
for i in range(n):
    num=ord(s[i])+2
    if num>90:
        num-=90
    ans.append(chr(num))
ans="".join(ans)
print(ans)
Problem p03061 (python)

Fixed submission:
from fractions import gcd
import numpy as np
n=int(input())
data=list(map(int,input().split()))
left=np.zeros(n+1,dtype=np.int)
right=np.zeros(n+1,dtype=np.int)
kotae=1
for i in range(n):
    left[i+1]=gcd(left[i],data[i])
    right[n-i-1]=gcd(right[n-i],data[n-i-1])
for j in range(n):
    num=gcd(left[j],right[j+1])
    kotae=max(num,kotae)
print(kotae)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=input()
data=list(map(int,input().split()))
is_i=0
num=sorted(data)
count=num[1]
if num[0]!=num[1]:
    if any([x%num[2]!=0 for x in data[1::]])==True:
        count=int(num[1]/2)+1
else:
    if any([x%num[2]!=0 for x in data[1::]])==True:
        count=int(num[1]/2)+1
for i in range(count+1)[::-1]:
    is_i=0
    if all([x%i==0 for x in data]):
        print(i)
        break
    else:
        for j in range(len(data)):
            if data[j]%i!=0:
                is_i+=1
        if is_i==1:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
import numpy as np
n=input()
data=list(map(int,input().split()))
is_i=0
num=sorted(data)
count=num[1]
if num[0]!=num[1]:
    count=num[1]/2+1
for i in range(count+1)[::-1]:
    is_i=0
    if all([x%i==0 for x in data]):
        print(i)
        break
    else:
        for j in range(len(data)):
            if data[j]%i!=0:
                is_i+=1
        if is_i==1:
            print(i)
            break
Problem p03029 (python)

Fixed submission:
a,p = map(int, input().split(" "))
print( (a*3+p)//2 )

Buggy submission (verdict: Runtime Error):
a,p = input.split(" ")
print( (a*3+p)//2 )
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = gcd(abs(xlist[i]-x),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
  
n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = gcd(int(xlist[i]-x),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = math.gcd(xlist[i]-x,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n,x = map(int,input().split())
xlist = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans = math.gcd(xlist[i]-x,ans)
print(ans)
Problem p03407 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a+b >= c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input())
if a+b >= c:
    print("Yes")
else:
    print("No")
Problem p03408 (python)

Fixed submission:
n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for i in range(m)]
 
for i in mlist:
    if i in nlist:
        nlist.remove(i)
 
def maxCOUNT( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]#copy
  S = set(lis)
  S = list(S)
  MaxCount=0
 
  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
  return MaxCount
 
print(maxCOUNT(nlist))

Buggy submission (verdict: Runtime Error):
n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for i in range(m)]

for i in range mlist:
    if i in nlist:
        nlist.remove(i)

def maxCOUNT( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]#copy
  S = set(lis)
  S = list(S)
  MaxCount=0

  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
  return MaxCount

print(maxCOUNT(nlist))
Problem p03425 (python)

Fixed submission:
n = int(input())
m=0
a=0
r=0
c=0
h=0
name = [list(str(input().split())) for i in range(n)]
for i in range(n):
    if name[i][2] == "M":
        m = m+1
    elif name[i][2] == "A":
        a = a+1
    elif name[i][2] == "R":
        r = r+1
    elif name[i][2] == "C":
        c = c+1
    elif name[i][2] == "H":
        h = h+1
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)

Buggy submission (verdict: Runtime Error):
h,w,d = map(int,input().split(" "))
board = [input().split(" ") for i in range(h)]

q = int(input())
for i in range(q):
    l,r = map(int,input().split(" "))
    n = int((r-l)/d)
    count = 0
    x = []
    y = []
    for k in range(h):
        if str(l) in board[k]:
            x.append(board[k].index(str(l)))
            y.append(k)
    for j in range(n):
        for k in range(h):
            if str(l+(j+1)*d) in board[k]:
                x.append(board[k].index(str(l+(j+1)*d)))
                y.append(k)
        count = count + abs(int(x[j+1])-int(x[j])) + abs(y[j+1]-y[j])
    print(count)
Problem p03957 (python)

Fixed submission:
def main():
    s=input()
    a=s.find('C')
    if(a==-1):
        print('No')
    else:
        a2=s.find('F',a+1,len(s))
        if(a2==-1):
            print('No')
        else:
            print('Yes')

main()

Buggy submission (verdict: Runtime Error):
def main():
    s=input()
    a=s.find('C')
    if(a==-1):
        print('No')
    else
        a2=s.find('F',a+1,len(s))
        if(a2==-1):
            print('No')
        else:
            print('Yes')

main()
Problem p02573 (python)

Fixed submission:
from networkx import *
n,m = map(int, input().split())
if m == 0: print(1);exit()
G = Graph()
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a,b)])

print(len(max(connected_components(G), key=len)))

Buggy submission (verdict: Runtime Error):
from networkx import *
n,m = map(int, input().split())
G = Graph()
for i in range(m):
    a,b = map(int, input().split())
    G.add_edges_from([(a,b)])

print(len(max(connected_components(G))))
Problem p02584 (python)

Fixed submission:
import sys
X,K,D = map(int, input().split())
if X < 0: X = abs(X) #Xがマイナスならプラスに変換しておく

if X // D > K:
    X = X - (K * D)
    print(X)
    sys.exit() #ここはOK

if (X // D) <= K:
    if X % D >= abs((X % D)-D):
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()
    else:
        if (K - (X // D)) % 2 == 1:
            print(abs((X % D)-D))
            sys.exit()
        else:
            print(X % D)
            sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
X,K,D = map(int, input().split())
if X < 0: X = abs(X) #Xがマイナスならプラスに変換しておく

if X // D > K:
    X = X - (K * D)
    print(X)
    exit.sys()

if X // D < K:
    if X % D >= abs((X % D)-D):
        print(X % D)
        exit.sys()
    else:
        print(abs((X % D)-D))
        exit.sys()
Problem p02646 (python)

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

a = abs(B-A)
if T * (V-W) >= a:
    print("YES")
else:print("NO")

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

for i in range(1, T+1):
    if i *(V-W) >= B-A: print("YES") break
print("NO")
Problem p03371 (python)

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

l = []

#パターン１ AとBだけ作るとき
price1 = A * X + B * Y
l.append(price1)

#パターン2 AB分割とあまり調整
if X > Y:
    if A < 2*C:
        price2 = 2 * Y * C + A * abs(X-Y)
        l.append(price2)
    else:
        price3 = 2 * Y * C + C * abs(X-Y) * 2
        l.append(price3)
elif X < Y:
    if B < 2*C:
        price4 = 2 * X * C + B * abs(Y-X)
        l.append(price4)
    else:
        price5 = 2 * X * C + C * abs(Y-X) * 2
        l.append(price5)

else:
    price6 = 2 * X * C
    l.append(price6)


print(min(l))

Buggy submission (verdict: Runtime Error):
A,B,C,X,Y = map(int, input().split())

l = []

#パターン１ AとBだけ作るとき
price1 = A * X + B * Y
l.append(price1)

#パターン2 AB分割とあまり調整
if X > Y:
    if A < C/2:
        price2 = 2 * Y * C + A * abs(X-Y)
        l.append(price2)
    else:
        price3 = 2 * Y * C + C * abs(X-Y) * 2
        l.append(price3)
elif X < Y:
    if B < C/2:
        price4 = 2 * X * C + B * abs(Y-X)
        l.append(price4)
    else:
        price5 = 2 * X * C + C * abs(Y-X) * 2
        l.append(price5)

elif x == Y:
    price6 = 2 * X * C
    l.append(price6)


print(min(l))
Problem p02646 (python)

Fixed submission:
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<B:
    if A+V*T>=B+W*T:
        print("YES")
    else:
        print("NO")
if A==B:
    print("YES")
if A>B:
    if A-V*T<=B-W*T:
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<B:
    if A+V*T>=B+W*T:
        print("YES")
    else:
        print("NO")
if A=B:
    print("YES")
if A>B:
    if A-V*T<=B-W*T:
        print("YES")
    else:
        print("NO")

Buggy submission (verdict: Runtime Error):
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<B:
    if A+V*T>=B+W*T:
        print("YES")
    else:
        print("NO")
if A>=B:
Problem p02696 (python)

Fixed submission:
A,B,N = map(int,input().split())
if B>N:
    print(int(A*N/B)-A*(int(N/B)))
else:
    print(int(A*(B-1)/B)-A*(int((B-1)/B)))

Buggy submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
S =[]
if B>N:
    print(int(A*N/B)-A*(int(N/B)))
else:
    print(int(A*N/(B-1))-A*(int((B-1)/B)))
Problem p02719 (python)

Fixed submission:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
if N%K<K-N%K:
    print(N%K)
else:
    print(K-N%K)

Buggy submission (verdict: Runtime Error):
import math
NK = input().split()
N = int(NK[0])
K = int(NK[1])
if N==1 or K==1:
    print(0)
    exit()
elif N==0:
    print(K)
else:
    print(math.gcd(N,K))

Buggy submission (verdict: Runtime Error):
import math
NK = input().split()
N = int(NK[0])
K = int(NK[1])
if N==1 or K==1 or N ==0:
    print(0)
    exit()
else:
    print(math.gcd(N,K))

Buggy submission (verdict: Runtime Error):
NK = input().split()
import math
N = int(NK[0])
K = int(NK[1])
if N==1 or K==1:
    print(0)
    exit()
else:
    print(math.gcd(N,K))

Buggy submission (verdict: Runtime Error):
import math
NK = input().split()
N = int(NK[0])
K = int(NK[1])
if N==1 or K==1:
    print(0)
    exit()
else:
    print(math.gcd(N,K))
Problem p02741 (python)

Fixed submission:
K = int(input())
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[K-1])

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
import math
HW = input().split()
H = int(HW[0])
W = int(HW[1])
print(math.ceil(H*W/2))

Buggy submission (verdict: Runtime Error):
K = input()
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[K-1])

Buggy submission (verdict: Runtime Error):
K = input()
x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
for i in range 32:
    if K==i:
        print(x[i-1])
Problem p02765 (python)

Fixed submission:
a = input().split()
x = int(a[0])
y = int(a[1])
if x>=10:
    print(y)
else:
    print(y+1000-100*x)

Buggy submission (verdict: Runtime Error):
a = input().split()
x = int(a[0])
y = int(a[1])
if x>=10:
    print(y)
else:
    print(y+1000-100x)
Problem p02772 (python)

Fixed submission:
N = int(input())#.split()
A = input().split()
den = False
for i in range(N):
    if int(A[i]) % 2 == 0:
        if int(A[i]) % 3 != 0 and int(A[i]) % 5 != 0:
            print("DENIED")
            exit(0)
            den = True
if not den:
    print("APPROVED")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input().split())
for i in range(N):
    if A[i]%2==0:
        if A[i]%15!=0:
            print("DENIED")
        else:
            print("APPROVED")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input().split())
for i in range(N):
    print(i)
    print(A[i])
    if A[i]%2==0:
        if A[i]%15!=0:
            print("DENIED")
        else:
            print("APPROVED")
Problem p02784 (python)

Fixed submission:
x = input().split()
A = input().split()
H = int(x[0])
N = int(x[1])
a = 0
for i in range(N):
    a+=int(A[i])
if a>=H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input().split()
A = input().split()
H = int(x[0])
N = int(x[1])
a = 0
for i in range(N):
    a+=(A[i])
if a>=H:
    print("Yes")
else:
    print("No")
Problem p02817 (python)

Fixed submission:
ST = input().split()
S = ST[0]
T = ST[1]
print(T+S)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
print(T+S)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
print(T,S)
Problem p02576 (python)

Fixed submission:
N,X,T=map(int,input().split())
for i in range(0,1001):
    if X*i>=N:
        print(T*i)
        break

Buggy submission (verdict: Runtime Error):
import sys
N,X,T=map(int,input().split())
for i in range(1,1001):
  if X*i>=N:
    print(i*T)
    sys.end()
Problem p02582 (python)

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

Buggy submission (verdict: Runtime Error):
w=str(input())
if w==RRR:
    print(3)
elif w==SRR:
    print(2)
elif w==RRS:
    print(2)
elif w==RSR:
    print(1)
elif w==RSS:
    print(1)
elif w==SRS:
    print(1)
elif w==SSR:
    print(1)
else :
    print(0)
Problem p02842 (python)

Fixed submission:
import math
N=int(input())
s=N/1.08
s=math.ceil(s)
t=s*1.08
t=math.floor(t)
if N==t:
    print(s)
else :
    print(":(")

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
s=N/1.08
s=math.ceil(s)
t=s*1.08
t=math.floor(t)
if N==t:
    input(s)
else :
    input(":(")
Problem p03493 (python)

Fixed submission:
print(input().count('1'))

Buggy submission (verdict: Runtime Error):
print(input(),count('1'))

Buggy submission (verdict: Runtime Error):
print(input(),count('1')

Buggy submission (verdict: Runtime Error):
print(input(),count("1")
Problem p03556 (python)

Fixed submission:
import sys
N=int(input())
if N==1:
    print("1")
elif N==2:
    print("1")
else:
    for i in range(N):
        if i**2>N:
            print((i-1)**2)
            sys.exit()
        else:
            pass

Buggy submission (verdict: Runtime Error):
import sys
N=int(input())
if N=1:
    print("1")
elif N=2:
    print("2")
else:
    for i in range(N):
        if i**2>N:
            print((i-1)**2)
            sys.exit()
        else:
            pass
Problem p02536 (python)

Fixed submission:
N, M = map(int, input().split())
Pajew = [i for i in range(N)]
import sys
sys.setrecursionlimit(1000000)

def find(x, Pajew):
    if Pajew[x] == x:
        return x
    else:
        a = find(Pajew[x], Pajew)
        Pajew[x] =a
        return a

def unite(x, y):
    x = find(x, Pajew)
    y = find(y, Pajew)
    if x != y:
        Pajew[x] = y

for _ in range(M):
    a, b = map(int, input().split())
    unite(a-1, b-1)

grou = 0
for i in range(N):
    if i == Pajew[i]:
        grou +=1


print(grou-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Pajew = [i for i in range(n)]
import sys
sys.setrecursionlimit(1000000)

def find(x, Pajew):
    if Pajew[x] == x:
        return x
    else:
        a = find(Pajew[x], Pajew)
        Pajew[x] =a
        return a

def unite(x, y):
    x = find(x, Pajew)
    y = find(y, Pajew)
    if x != y:
        Pajew[x] = y

for _ in range(M):
    a, b = map(int, input().split())
    unite(a-1, b-1)

grou = 0
for i in range(N):
    if i == Pajew[i]:
        grou +=1
        
        
print(grou-1)
Problem p02537 (python)

Fixed submission:
n, k = map(int, input().split())
a_list = [int(input()) for _ in range(n)]

dp = [1] * n

for i in range(n):
    for j in range(max(0, i - 100), i):
        if abs(a_list[i] - a_list[j]) <= k:
            dp[i] = max(dp[i], dp[j] + 1)

ans = max(dp)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a_list = [int(input()) for _ in range(n)]

dp = [1] * n

for i in range(n):
    for j in range(max(0, i-N), i):
        if abs(a_list[i] - a_list[j]) <= k:
            dp[i] = max(dp[i], dp[j] + 1)

ans = max(dp)
print(ans)
Problem p02934 (python)

Fixed submission:
import numpy as np

n = int(input())

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

ue = 1

for aa in a:
    ue *= aa

shita = 0

for aa in a:
    shita += ue / aa

print(ue / shita)

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

n = int(input())

a = list(map(int, input().split()))
p = np.prod(a)

top = p
under = 0

for aa in a:
    under += p / aa

print(top / under)
Problem p03294 (python)

Fixed submission:
import sys
import fractions


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


def input():
    return sys.stdin.readline().strip()


n = int(input())
a = list(map(int, input().split()))
a.sort()

a_lcm = a[0]
for ai in a:
    a_lcm = lcm(ai, a_lcm)

m = a_lcm - 1
ans = 0

for ai in a:
    ans += m%ai

print(ans)

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


def lcm(a, b):
    return a * b // math.gcd(a, b)


def input():
    return sys.stdin.readline().strip()


n = int(input())
a = list(map(int, input().split()))
a.sort()

a_lcm = a[0]
for ai in a:
    a_lcm = lcm(ai, a_lcm)

m = a_lcm - 1
ans = 0

for ai in a:
    ans += m%ai

print(ans)
Problem p04001 (python)

Fixed submission:
import sys


def input():
    return sys.stdin.readline().strip()


s = input()
n = len(s)

total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り，3文字なら4通り，n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
    # iは各桁に+を挿入するかどうかを決定する
    # 例えば s=12345, i=0b0111, ss=1+2+3+45
    now_sum = 0
    reg = int(s[0])
    for j in range(n - 1):
        if i & 1 << j:
            now_sum += reg
            reg = 0
        reg *= 10
        reg += int(s[j + 1])
    now_sum += reg

    total_sum += now_sum

print(total_sum)

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

s = input()
n = len(s)

total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り，3文字なら4通り，n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
    # iは各桁に+を挿入するかどうかを決定する
    # 例えば s=12345, i=0b0111, ss=1+2+3+45
    now_sum = 0
    reg = int(s[0])
    for j in range(n - 1):
        if i & 1 << j:
            now_sum += reg
            reg = 0
        reg *= 10
        reg += int(s[j + 1])
    now_sum += reg

    total_sum += now_sum

print(total_sum)

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

s = input()
n = len(s)

total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り，3文字なら4通り，n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
    # iは各桁に+を挿入するかどうかを決定する
    # 例えば s=12345, i=0b0111, ss=1+2+3+45
    now_sum = 0
    reg = int(s[0])
    for j in range(n - 1):
        if i & 1 << j:
            now_sum += reg
            reg = 0
        reg *= 10
        reg += int(s[j + 1])
    now_sum += reg

    total_sum += now_sum

print(total_sum)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

x = 0

for i in range(3):
    if S[i] == T[i]:
        x = x + 1

print(x)

Buggy submission (verdict: Runtime Error):
A,B = input().split()

A_ch = int(A)
B_ch = int(B)

cal = B_ch - A_ch
i = 0
n = 1
try:
    while (cal + i) > 0:
        n += 1
        i += 1
        cal = B_ch - A_ch * n - n
        
except:
    i = 1
print(i)
Problem p02553 (python)

Fixed submission:
a=input('').split()
a=list(map(int,a))

b=(a[0])
c=(a[1])
d=(a[2])
e=(a[3])

f=b*d
g=b*e
h=c*d
i=c*e

if f>g:
  if h>f:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>f:
      print(i)
    else:
      print(f)
else:
  if h>g:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>g:
      print(i)
    else:
      print(g)

Buggy submission (verdict: Runtime Error):
a=int(input(''))
a=list(map(int,a))

b=(a[0])
c=(a[1])
d=(a[2])
e=(a[3])

f=b*d
g=b*e
h=c*d
i=c*e

if f>g:
  if h>f:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>f:
      print(i)
    else:
      print(f)
else:
  if h>g:
    if i>h:
      print(i)
    else:
      print(h)
  else:
    if i>g:
      print(i)
    else:
      print(g)