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

Fixed submission:
n, k = input().split()
n = int(n)
k = int(k)
p = list(map(int, input().split()))
if n==k:
	print((sum(p)+n)/2)
else:
	q = [p[0]]
	for i in range(n-1):
		q.append(q[i]+p[i+1])
	r = []
	for i in range(n-k):
		r.append(q[i+k]-q[i])
	r.sort(reverse=True)
	print((r[0]+k)/2)

Buggy submission (verdict: Runtime Error):
n, k = input().split()
n = int(n)
k = int(k)
p = list(map(int, input().split()))
q = [p[0]]
for i in range(n-1):
	q.append(q[i]+p[i+1])
r = []
for i in range(n-k):
	r.append(q[i+k]-q[i])
r.sort()
print((r[n-k-1]+k)/2)
Problem p02811 (python)

Fixed submission:
k,x=map(int,input().split())
print("No" if k*500<x else "Yes")

Buggy submission (verdict: Runtime Error):
print("No" if int(input())*500<int(input()) else "yes")
Problem p02848 (python)

Fixed submission:
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
s = input()
for x in s:
  print(alphabet[(alphabet.index(x)+n)%26], end="")
print()

Buggy submission (verdict: Runtime Error):
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
print(alphabet[(alphabet.index(input())+n)%26])
Problem p02886 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)

Buggy submission (verdict: Runtime Error):
n = input()
d = list(map(int, input().split()))
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)

Buggy submission (verdict: Runtime Error):
n = input()
d = map(int, input().split())
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += d[i] * d[j]
print(sum)

Buggy submission (verdict: Runtime Error):
n = input()
d = map(int, input().split())
sum = 0
for i in range(n-1):
  for j in range(i+1, n):
    sum += ij
print(sum)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

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

ans = 1

if g % 2 == 0:
  ans += 1
while g % 2 == 0:
  g /= 2

i = 3
while i * i <= g:
  if g % i == 0:
    ans += 1
  while g % i == 0:
    g /= i
  i += 2

if g != 1:
  ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
p = list()
i = 3
while True:
  if g % i == 0:
    b = True
    for j in p:
      if i % j == 0:
        b = False
        break
    if b == True:
      p.append(i)
  i += 2
  if i > g/2:
    break
if g % 2 == 0:
  p.append(2)
for j in p:
  print(len(j)+1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
p = list()
i = 3
while True:
  if g % i == 0:
    b = True
    for j in p:
      if i % j == 0:
        b = False
        break
    if b == True:
      p.append(i)
  i += 2
  if i > g/2:
    break
if g % 2 == 0:
  p.append(2)
for i in p:
  print(len(i)+1)
Problem p02909 (python)

Fixed submission:
s=input()
if s=="Sunny":
  print("Cloudy")
elif s=="Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
s=input()
if s="Sunny":
  print("Cloudy")
if s="Cloudy":
  print("Rainy")
else:
  print("Sunny")
Problem p02957 (python)

Fixed submission:
a,b=map(int, input().split())
print("IMPOSSIBLE" if (a+b)%2 else int((a+b)/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
a+=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]!=i+1:
    c+=1
print("YES" if c<3 else "NO")
Problem p02958 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]!=i+1:
    c+=1
print("YES" if c<3 else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a+=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]!=i+1:
    c+=1
print("YES" if c<3 else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a+=list(map(int,input().split()))
for i in range(n-1):
  if a[i]!=i+1:
    c+=1
print("YES" if c<3 else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
c=0
idx = list()
for i in range(n-1):
  if a[i]>a[i+1]:
    idx.append(i)
    c+=1
print("YES" if c<2 or c==2 and a[idx[0]-1]<a[idx[1]+1]<a[idx[0]+1] and a[idx[1]]<a[idx[0]]<a[idx[1]+2] else "NO")
Problem p02675 (python)

Fixed submission:
a = input()
target = a[-1]

hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if int(target) in hon:
    print("hon")
else:
    if int(target) in pon:
        print("pon")
    else:
        print("bon")

Buggy submission (verdict: Runtime Error):
a = input()
sig = str(a[-1])

if (sig=="2" or sig=="4" or sig== "5" or sig =="7" or sig=="9"):
  print("hon")
else:
  if (sig=="3"):
    print("pon")
   else:
    print("bon")
Problem p02677 (python)

Fixed submission:
import numpy as np
import math

def deg(rad):
    return (360 / 2 * np.pi) * rad
a,b,h,m = map(int, input().split(" "))
#h,m = map(int, input().split(" "))

hn = ((h/12) + (m/60)/12) * 360
mn = (m/60) * 360


#print(np.abs(theta2 - theta1))

#これ．時針にn分での動きを足してねえわ
#n分 = n/60時間である よってfh = m + n/60

#お手製radを信じるな
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(hn - mn))

ans = c ** 0.5
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a,b,h,m = map(int, input().split(" "))


theta1 = (2 * np.pi / 60) * m

if int(h) >= 12:
    h = h -12
theta2 = (2* np.pi / 12) * h

c = a * a + b * b - 2 * a * c * np.cos(np.abs(theta1-theta2))
ans = np.sqrt(c)
print(ans)
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())
C = []; A = []; T = []
for _ in range(N):
    s = list(map(int, input().split()))
    C.append(s[0])
    A.append(s[1:])

INF = 10**9
ans = INF
# シフトで2^nまで全探索
for s in range(0, 1 << N):
    # 習得度をいれるリストを定義
    smart = [0] * M
    cost_sum = 0
    # sには10進数が入る
    for i in range(N):
        # 買っていない時
        if (s >> i) % 2 == 0: continue
        cost_sum += C[i]
        for j in range(M):
            smart[j] += A[i][j]
    ok = True
    if min(smart) < X:
        ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

N, M, X = map(int, input().split())
C = []; A = []; T = []
for _ in range(N):
    s = list(map(int, input().split()))
    T.append(s)


comb = []

for i in range(1,N+1):
    comb.append(list(itertools.combinations(T, i)))

comb = itertools.chain.from_iterable(comb)
count = []

for j in comb:
    t = [0, 0, 0, 0]
    for k in range(len(j)):
        t[0] += j[k][0]
        t[1] += j[k][1]
        t[2] += j[k][2]
        t[3] += j[k][3]
    count.append(t)

count.sort()


for i in count:
    if min(i[1:]) >= X:
        print(i[0])
        exit()

print(-1)

Buggy submission (verdict: Runtime Error):
import itertools

N, M, X = map(int, input().split())
C = []; A = []; T = []
for _ in range(N):
    s = list(map(int, input().split()))
    T.append(s)


comb = []

for i in range(1,N):
    comb.append(list(itertools.combinations(T, i)))

comb = itertools.chain.from_iterable(comb)
count = []

for j in comb:
    t = [0, 0, 0, 0]
    for k in range(len(j)):
        t[0] += j[k][0]
        t[1] += j[k][1]
        t[2] += j[k][2]
        t[3] += j[k][3]
    count.append(t)

count.sort()


for i in count:
    if min(i[1:]) >= X:
        print(i[0])
        exit()

print(-1)
Problem p02684 (python)

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

"""
1からのループだけを考えれば良い
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1
count = 1

if A[0] == 1:
    print(1)
    exit()

while ok:
    count += 1
    seen[i-1] += count
    R.append(i)
    i = A[i-1]
    # 訪れたことがあれば
    if seen[i-1] != 0:
        k = seen[i-1]
        loop = R[k-1:]
        remain = R[:k-1]
        ok = False

L = len(loop)

if K < len(remain):
    print(remain[K])
else:
    print(loop[(K - len(remain)) % L])

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

"""
1からのループだけを考えれば良い
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1
count = 1

while ok:
    count += 1
    seen[i-1] += count
    R.append(i)
    i = A[i-1]
    # 訪れたことがあれば
    if seen[i-1] != 0:
        k = seen[i-1]
        loop = R[k-1:]
        remain = R[:k-1]
        ok = False

L = len(loop)

if K < len(remain):
    print(remain[K])
else:
    print(loop[(K - len(remain)) % L])

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

"""
1からのループだけを考えれば良い

と思ったが，1に戻ってくるとは限らない
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1


while ok:
    seen[i-1] += 1
    R.append(i)
    i = A[i-1]
    if seen[i-1] == 1:
        for j in range(len(R)):
            if R[j] == i:
                remain = R[:j]
                loop = R[j:]
                ok = False

L = len(loop)

if K < len(remain):
    print(remain(K-1))
else:
    print(loop[(K - len(remain)) % L])

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

"""
1からのループだけを考えれば良い

と思ったが，1に戻ってくるとは限らない
"""

i = A[0]
ok = True
R = [1]
seen = [0] * N
seen[0] = 1


while ok:
    seen[i-1] += 1
    R.append(i)
    i = A[i-1]
    if seen[i-1] == 1:
        for j in range(len(R)):
            if R[j] == i:
                remain = R[:j]
                loop = R[j:]
                ok = False

L = len(loop)

if K <= len(remain):
    print(remain(K-1))
else:
    print(loop[(K - len(remain)) % L])
Problem p02690 (python)

Fixed submission:
x = int(input())

for i in range(400):
    for j in range(i - 800, i):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()

Buggy submission (verdict: Runtime Error):
for i in range(-118,120):
    for j in range(-118, i+1):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()
Problem p02705 (python)

Fixed submission:
import math

R = int(input())

pai = math.pi

print(2 * R * pai)

Buggy submission (verdict: Runtime Error):
import math

R = int(input())

pai = math.pi

print(2 * R * pi)
Problem p02714 (python)

Fixed submission:
import itertools

N = int(input())
S = input()

r_cnt = S.count("R")
g_cnt  = S.count("G")
b_cnt = S.count("B")

ans = r_cnt * g_cnt * b_cnt

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
r_cnt = S.count("R")
g_cnt  = S.count("G")
b_cnt = S.count("B")

ans = r_cnt * g_cnt * b_cnt

for i in range(N):
    for d in range(N):
        j = i + d
        k = j + d
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            ans -= 1
print(ans)
Problem p02727 (python)

Fixed submission:
from collections import deque

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:x]

Q = sorted(Q, reverse=True)[:y]

P.extend(Q)
R.extend(P)

T = sorted(R, reverse=True)[:x+y]
print(sum(T))

Buggy submission (verdict: Runtime Error):
from collections import deque

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:x]

Q = sorted(Q, reverse=True)[:y]

P.extend(Q)
T = deque(sorted(P, reverse=True))
R = deque(sorted(R, reverse=True))

ans = 0
for i in range(x+y):
    if T[0] >= R[0] and len(T) > 0:
        ans += T.popleft()
    elif len(R) > 0:
        ans += R.popleft()
    else:
        ans += T.popleft()

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:x]

Q = sorted(Q, reverse=True)[:y]

P.extend(Q)
T = deque(sorted(P, reverse=True))
R = deque(sorted(R, reverse=True))

ans = 0
for i in range(x+y):
    if T[0] >= R[0] or len(R) == 0:
        ans += T.popleft()
    else:
        ans += R.popleft()

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

x, y, a, b, c = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

# x <= a
# y <= b

P = sorted(P, reverse=True)[:x]

Q = sorted(Q, reverse=True)[:y]

P.extend(Q)
T = deque(sorted(P, reverse=True))
R = deque(sorted(R, reverse=True))

ans = 0
for i in range(x+y):
    if T[0] >= R[0]:
        ans += T.popleft()
    else:
        ans += R.popleft()

print(ans)
Problem p02900 (python)

Fixed submission:
"""
マスターオブ整数
公約数の問題
公約数とは最大公約数の約数であるという性質がある
"""
import fractions
A, B = map(int, input().split())

# まず公約数を列挙したくなる
# 最大公約数を求めてその約数を列挙する
# 最大公約数はユークリッドの互除法で求めることができる

ans = 1
gcd_value = fractions.gcd(A, B)
for i in range(2, int(gcd_value**0.5) + 1):
    if gcd_value % i == 0:
        ans += 1
        while gcd_value % i == 0:
            gcd_value //= i

# divisorリストの中からどの二つ互いに素となるようにいくつか選ぶ
# 素因数の数+1を答えれば良い
if gcd_value != 1:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
"""
マスターオブ整数
公約数の問題
公約数とは最大公約数の約数であるという性質がある
"""
import math
A, B = map(int, input().split())

# まず公約数を列挙したくなる
# 最大公約数を求めてその約数を列挙する
# 最大公約数はユークリッドの互除法で求めることができる

ans = 1
gcd_value = math.gcd(A, B)
for i in range(2, gcd_value + 1):
    if gcd_value == 1:
        break
    if gcd_value % i == 0:
        ans += 1
        while gcd_value % i == 0:
            gcd_value //= i

# divisorリストの中からどの二つ互いに素となるようにいくつか選ぶ
# 素因数の数+1を答えれば良い

print(ans)
Problem p02928 (python)

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

mod = 10**9 + 7
result = 0
count = [0] * 2001

# リスト内での繰り返し
for a in A:
    count[a-1] += 1
    result += K * sum(count[a:])
    result %= mod

kn = 0
# 前のループに存在する自分より大きい数
count = [i for i in count if i != 0]
total = sum(count) % mod

for i in count:
    total -= i
    kn += total * i
    kn %= mod

result += kn * K*(K-1)//2
result %= 10**9 + 7

print(result)

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

mod = 10**9 + 7
result = 0
count = [0] * N
for a in A:
    count[a-1] += 1
    result += K * sum(count[a:])
    result %= mod

kn = 0
total = sum(count) % mod
for i in range(N):
    total -= count[i]
    kn += total
    kn %= mod

result += kn * K*(K-1)//2
result %= 10**9 + 7

print(result)
Problem p02936 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(N-1)]
process = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N+1)]

for edge in edges:
    graph[edge[0]].append(edge[1])

count = [0] * (N+1)

def dfs(p,x):
    count[p] += x
    for i in graph[p]:
        dfs(i,x)

for i in process:
    dfs(i[0], i[1])

del count[0]

print(' '.join(map(str, count)))

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[;-1]

n,q = map(int, input().split())
#長さn個のリストを入れ子にしたリストの作成：adj
adj = [[] for i in range(n)]

#adjに繋がっている要素を上流下流関わらず全て加える。
for j in range(n-1):
    a,b=map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)
print(adj) 

#加算する値を合計したリストの作成
queries = [0 for i in range(n)]
for j in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x
print(queries)

ans = [0 for i in range(n)]

#aの値，直前の値，直前のaの値
st = [(0, 0, -1)] 

print('answer roop')

#つながってる奴の一番後ろから処理していく。
#０スタート→1,2繋がってるなら2にいく。2に3が繋がってるなら次は3。
#3に繋がってるのがなければ1に戻る。
#この際，aの直前の値をタプルで保持したままリストに挿入して保管しておく。
while st:
    #stの先頭を取り出す。初期値は末尾のため-1
    l = st.pop()  
    print(l)
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))

print(*ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q=list(map(int, input().split()))
result = {i+1:0 for i in range(n)}
ar = np.eye(n)

for i in range(n-1):
    a,b = list(map(int, input().split()))
    ar[0:a,a-1:b] += 1
for i in range(q):
    a,b = list(map(int, input().split()))
    m = ar[a-1]
    for j in range(len(m)):
        if m[j] != 0:
            result[j+1] += b
        else:
            result[j+1] += 0
r = list(result.values())
res = map(str, r)
print(' '.join(res))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,q=list(map(int, input().split()))
result = {i+1:0 for i in range(n)}
ar = np.eye(n)

for i in range(n-1):
    a,b = list(map(int, input().split()))
    ar[0:a,a-1:b] += 1
for i in range(q):
    a,b = list(map(int, input().split()))
    m = ar[a-1]
    for j in range(len(m)):
        if m[j] != 0:
            result[j+1] += b
r = list(result.values())
res = map(str, r)
print(' '.join(res))
Problem p02953 (python)

Fixed submission:
length = input()
a_list = list(map(int, input().split()))
 
for i in range(len(a_list)-1):
  if a_list[i] < a_list[i+1]:
    a_list[i+1] -= 1
  elif a_list[i] > a_list[i+1]:
    print("No")
    exit()
    
print('Yes')

Buggy submission (verdict: Runtime Error):
length = input()
a_list = list(map(int, input().split()))
 
for i in range(length):
  if i == (length - 1):
    break
  elif (a_list[i+1] - a_list[i]) >1 :
    a_list[i+1] += 1 
  elif a_list[i+1] >= 1 :
    continue
  elif a_list[i+1] < a_list[i]:
    print("No")
    break

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

for i in range(length):
  if i == (length - 1):
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

Buggy submission (verdict: Runtime Error):
length = input()
list = list(map(int, input().split()))
 
for i in range(length):
  if i == (length - 1):
    print('Yes')
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

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

for i in range(length):
  if i == (length - 1):
    print('Yes')
    break
  elif (list[i+1] - list[i]) >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

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

for i in range(length):
  if i == length:
    print('Yes')
  elif list[i+1] - list[i] >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break

Buggy submission (verdict: Runtime Error):
length = int()
list = int().split()

for i in range(length):
  if i == length:
    print('Yes')
  elif list[i+1] - list[i] >1 :
    list[i+1] += 1 
  elif list[i+1] >= 1 :
    continue
  elif list[i+1] < list[i]:
    print("No")
    break
Problem p02957 (python)

Fixed submission:
a,b = map(int, input().split())
 
if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
else:
    print(abs(a+b)//2)

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

if (a + b) % 2 != 0:
  print("IMPOSSIBLE")
else:
  print(abs((b**2-a**2)/2(a+b)))
Problem p02969 (python)

Fixed submission:
N = int(input())
print(3 * N**2)

Buggy submission (verdict: Runtime Error):
N = input()
print(3 * N**2)
Problem p02981 (python)

Fixed submission:
N,A,B = map(int, input().split())
 
print(min(N*A, B))

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N, D = list(map(int, input().split()))
full_list = []
for i in range(N):
  full_list.append(list(map(int, input().split())))
 
result = 0
 
for i in range(N):
  for j in range(N-i-1):
    length = 0
    for s in range(D):
      length += (full_list[i][s] - full_list[j][s]) ** 2
    result += 1 if np.sqrt(length).is_integer() else 0
 
print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N, D = list(map(int, input().split()))
full_list = []
for i in range(N):
  full_list.append(list(map(int, input().split())))
 
result = 0
 
for i in range(N):
  for j in range(N-i-1):
    length = 0
    for s in range(D):
      length += (full_list[i][s] - full_list[j][s]) ** 2
    result += 1 if np.sqrt(length).is_integer() == True else 0
 
print(result)

Buggy submission (verdict: Runtime Error):
ソースコード 

Copy
Copy
import numpy as np
 
N, D = list(map(int, input().split()))
full_list = []
for i in range(N):
  full_list.append(list(map(int, input().split())))
 
result = 0
 
for i in range(N):
  for j in range(N-i-1):
    length = 0
    for s in range(D):
      length += (full_list[i][s] - full_list[j][s]) ** 2
    result += 1 if np.sqrt(length).is_integer() == True else 0
 
print(result)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int, input())

print(min(N*A, B))
Problem p02995 (python)

Fixed submission:
a, b, c, d = map(int, input().split())

"""
両方に関して割り切れるものの個数から公倍数で割り切れるものを除けばいい
"""
import fractions

C = b//c - (a-1)//c
D = b//d - (a-1)//d

# 最小公倍数を求める
CD = fractions.gcd(c, d)
lcm = (c * d) // CD

G = b//lcm - (a-1)//lcm


count = C + D - G
print(b - a + 1 - count)

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

"""
両方に関して割り切れるものの個数から公倍数で割り切れるものを除けばいい
"""
import math

C = b//c - (a-1)//c
D = b//d - (a-1)//d

# 最小公倍数を求める
CD = math.gcd(c, d)
lcm = (c * d) // CD

G = b//lcm - (a-1)//lcm


count = C + D - G
print(b - a + 1 - count)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())

"""
直方体は中身を通る線で半分に割ることができる
"""

if W/2 == x and H/2 == y:
    print(W * H / 2, 1)
else:
    print(W * H / 2, 0)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

if W / x == 2 and H / y == 2:
    print(W * H / 2, 1)
elif W == H:
    print(W * H / 2, 0)
elif W / x == 2 or H / y == 2:
    print(W * H / 2, 0 )
else:
    h = max(x, W - x)
    w = max(y, H - y)
    print(H/h * W/w /2)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

if W / x == 2 and H / y == 2:
    print(W * H / 2, 1)
elif W / x == 2 or H / y == 2:
    print(W * H / 2, 0 )
else:
    h = max(x, W - x)
    w = max(y, H - y)
    print(H/h * W/w /2)
Problem p03231 (python)

Fixed submission:
import fractions
N, M = map(int, input().split())
S = input()
T = input()

G = N * M // fractions.gcd(N, M)
slist = [i*(G//N) for i in range(N)]
mlist = [i*(G//M) for i in range(M)]
sm = set(slist) & set(mlist)
for i in sm:
    si = slist.index(i)
    mi = mlist.index(i)
    if S[si] != T[mi]:
        print(-1)
        exit()

print(G)

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

G = N * M // math.gcd(N, M)
slist = [i*(G//N) for i in range(N)]
mlist = [i*(G//M) for i in range(M)]
sm = set(slist) & set(mlist)
for i in sm:
    si = slist.index(i)
    mi = mlist.index(i)
    if S[si] != T[mi]:
        print(-1)
        exit()

print(G)