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

Fixed submission:
import math
N, K = map(int, input().split())
for i in range(1, K+1):
  ans = 0
  blue = math.factorial(K-1) // (math.factorial(i-1)*math.factorial(K-i))
  if N-K+1-i < 0:
    red = 0
  else:
    red = math.factorial(N-K+1) // (math.factorial(i)*math.factorial(N-K+1-i))
  ans = blue * red
  ans = ans % (10**9+7)
  print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
for i in range(1, K+1):
  ans = 0
  blue = math.factorial(K-1) // (math.factorial(i-1)*math.factorial(K-i))
  red = math.factorial(N-K+1) // (math.factorial(i)*math.factorial(N-K+1-i))
  ans = blue * red
  ans = ans % (10**9+7)
  print(int(ans))
Problem p03018 (python)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
    print(s)
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-j-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
print(ans)
Problem p03038 (python)

Fixed submission:
import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    change = [[int(i) for i in input().split()] for _ in range(M)]
    change.sort(key = itemgetter(1), reverse = True)

    ai = 0
    for i in range(M):
        cb, c = change[i]
        if ai >= N or c < A[ai]: break
        for _ in range(cb):
            if ai >= N: break
            if A[ai] <= c:
                A[ai] = c
                ai += 1
            else: break
    print(sum(A))
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = []
for i in range(M):
  b, c = map(int, input().split())
  for i in range(b):
    C.append(c)

A.sort()
C.sort(reverse=True)
j = 0
while A[j] < C[j]:
  A[j] = C[j]
  j += 1
  
print(sum(A))
Problem p03745 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
N = int(input())
A = list(map(int, input().split()))

ans = 0
def main(i, A):
  global N
  global ans
  if A[i] == A[i+1]:
    if i == N-2:
      ans += 1
      return ans
    else:
      return main(i+1, A)
  elif A[i] < A[i+1]:
    while i < N-1:
      if A[i] <= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
  else:
    while i < N-1:
      if A[i] >= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
    
if N == 1:
  print(1)
else:
  print(main(0, A))

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

ans = 0
def main(i, A):
  global N
  global ans
  if A[i] == A[i+1]:
    if i == N-2:
      ans += 1
      return ans
    else:
      return main(i+1, A)
  elif A[i] < A[i+1]:
    while i < N-1:
      if A[i] <= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
  else:
    while i < N-1:
      if A[i] >= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
    
if N == 1:
  print(1)
else:
  print(main(0, A))

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

ans = 0
def main(i, A):
  global N
  global ans
  if A[i] == A[i+1]:
    if i == N-2:
      ans += 1
      return ans
    else:
      return main(i+1, A)
  elif A[i] < A[i+1]:
    while i < N-1:
      if A[i] <= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
  else:
    while i < N-1:
      if A[i] >= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
    
print(main(0, A))

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

ans = 0
def main(i, A):
  global N
  global ans
  if A[i] == A[i+1]:
    return main(i+1, A)
  elif A[i] < A[i+1]:
    while i < N-1:
      if A[i] <= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
  else:
    while i < N-1:
      if A[i] >= A[i+1]:
        i += 1
      else:
        ans += 1
        if i == N-2:
          ans += 1
          return ans
        else:
          return main(i+1, A)
    else:
      ans += 1
      return ans
    
print(main(0, A))
Problem p02622 (python)

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

cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1
print(cnt)

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

cnt = 0
for i in range(len(S)):
    if S[i] != T[i]:
        cnt += 1
print(cnt)b
Problem p02847 (python)

Fixed submission:
S = input()

day = {"SUN":7, "MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

print(day[S])

Buggy submission (verdict: Runtime Error):
A, B, X = map(int, input().split())
l = 0
r = 10**9+1


def keta(n):
    cnt = 0
    while n > 0:
        n //= 10
        cnt += 1
    return cnt

while r-l > 1:
    c = (l + r) // 2
    keta_c = keta(c)
    if A * c + B * keta_c <= X:
        l = c
    else:
        r = c

print(l)
Problem p02862 (python)

Fixed submission:
X, Y = map(int, input().split())
a = 0
b = 0
for i in range(X + 1):
    N = i
    if (X - N) % 2 != 0 and N != X:
        continue
    M = int((X - N) / 2)
    
    x = N + 2 * M
    y = 2 * N + M
    if X == x and Y == y:
        a = N
        b = M
#print(a)

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if a != 0 and b != 0:
    #print(a, b)
    ans = cmb(a + b,a) % (10**9+7)
    print(ans)
elif a == 0 and b != 0:
    print("1")
elif a != 0 and b == 0:
    print("1") 
else:
    print("0")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())
a = 0
for i in range(X + 1):
    N = i
    if (X - N) % 2 != 0:
        continue
    M = (X - N) / 2
    
    x = N + 2 * M
    y = 2 * N + M
    if X == x and Y == y:
        a = N
#print(a)

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
if a != 0:
    ans = cmb(X-1,a,mod)
    print(ans)
else:
    print("0")
Problem p02873 (python)

Fixed submission:
S = input()
a = [0] * (len(S) + 1)
for i in range(len(S)):
    if S[i] == "<":
        a[i+1] = max(a[i+1], a[i] + 1)
for i in range(len(S)-1,-1,-1):
    if S[i] == ">":
        a[i] = max(a[i], a[i+1] + 1)
        
print(sum(a))

Buggy submission (verdict: Runtime Error):
S = input()
d = []
lt = 0
gt = 0
for i in range(len(S)):
    if i == 0:
        continue
    if S[i - 1]  == S[i] and S[i] == "<":
        lt += 1
    if S[i - 1] == S[i] and S[i] == ">":
        gt += 1
    if S[i - 1] != S[i] and S[i-1] == "<":
        d.append("<" * (lt + 1))
        lt = 0
    if S[i - 1] != S[i] and S[i - 1] == ">":
        d.append(">" * (gt + 1))
        gt = 0
    if i == len(S) - 1 and S[i] == "<":
        d.append("<" * (lt + 1))
    if i == len(S) - 1 and S[i] == ">":
        d.append(">" * (gt + 1))
    
print(d)
ans=0

if d[0][0] == "<":
    i = 0
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                for i in range(1, len(d[i])+1):
                    ans += i
                for i in range(1, len(d)):
                    ans += i
                i+= 2
        elif i  == len(d) - 1:
            for i in range(1, len(d[i])+1):
                ans += i
                i += 1

if d[0][0] ==">":
    ans += (len(d[i]) + 1) * len(d[i]) / 2
    i = 1
    while i < len(d) - 1:
        if i != len(d) - 1:
            if len(d[i]) >= len(d[i + 1]):
                ans += (len(d[i]) + 1) * len(d[i]) / 2 + (len(d[i+1])) * len(d[i + 1]) / 2
                i += 2
            elif len(d[i]) < len(d[i + 1]):
                ans += (len(d[i])) * len(d[i]) / 2 + (len(d[i+1])+1) * len(d[i + 1]) / 2
                i += 2
        elif i  == len(d) - 1:
            ans +=  (len(d[i]) + 1) * len(d[i]) / 2

print(ans)
    

                

        
# min_d = 0
# for i in d:
#     min_d = min(min_d, d[i])

# d = list(map(lambda x: x + abs(min_d), d))

# if S[0] == "<":
#     d[0] = 0

# ans = 0
# for i in range(len(S)):
#     ans += d[i]
# print(d)
# print(ans)
Problem p02891 (python)

Fixed submission:
S = input()
K = int(input())
d=[[0 for _ in range(400)] for _ in range(4)]
ans = [0,0,0,0]
l = len(S)
odd_diff = 0
even_diff = 0
if l == 1:
    print(int(K//2))
if l > 1:
    for i in range(4):
        s = S * (i + 1)
        l = len(s)
        for j in range(l-1):
            
            if j == 0 and s[j] == s[j+1]:
                ans[i] += 1
                d[i][0] = 1
            if j > 0 and s[j] == s[j+1] and d[i][j-1] == 0:
                ans[i] += 1
                d[i][j] = 1
    if K <= 4:
        print(int(ans[K-1]))
    elif K > 4 and K % 2 == 0:
        even_diff = ans[3] - ans[1]
        print(int(ans[1]+(K/2-1)*even_diff))
    elif K > 4 and K % 2 == 1:
        odd_diff = ans[2] - ans[0]
        print(int(ans[0]+(K//2)*odd_diff))

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
d=[[0 for _ in range(100)] for _ in range(4)]
ans = [0,0,0,0]
l = len(S)
odd_diff = 0
even_diff = 0
if l == 1:
    ans = K // 2
    print(ans)
if l > 1:
    for i in range(4):
        s = S * (i + 1)
        l = len(s)
        for j in range(l-1):
            
            if j == 0 and s[j] == s[j+1]:
                ans[i] += 1
                d[i][0] = 1
            if j > 0 and s[j] == s[j+1] and d[i][j-1] == 0:
                ans[i] += 1
                d[i][j] = 1
    if K <= 4:
        print(ans[K-1])
    elif K > 4 and K % 2 == 0:
        even_diff = ans[3] - ans[1]
        print(int(ans[1]+(K/2)*even_diff))
    elif K > 4 and K % 2 == 1:
        odd_diff = ans[2] - ans[0]
        print(int(ans[0]+(K//2)*odd_diff))

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
d=[[0 for _ in range(100)] for _ in range(4)]
ans = [0,0,0,0]
l = len(S)
odd_diff = 0
even_diff = 0
if l == 1:
    ans = K // 2
    print(ans)
if l > 1:
    for i in range(4):
        s = S * (i + 1)
        l = len(s)
        for j in range(l-1):
            
            if j == 0 and s[j] == s[j+1]:
                ans[i] += 1
                d[i][0] = 1
            if j > 0 and s[j] == s[j+1] and d[i][j-1] == 0:
                ans[i] += 1
                d[i][j] = 1
    if K <= 4:
        print(ans[K-1])
    elif K > 4 and K % 2 == 0:
        even_diff = ans[3] - ans[1]
        print(ans[1]+(K/2)*even_diff)
    elif K > 4 and K % 2 == 1:
        odd_diff = ans[2] - ans[0]
        print(ans[0]+(K//2)*odd_diff)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
    if s[i] == t[i]:
        ans += 1
print(ans)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [0 for _ in range(N+1)]
for _ in range(M):
    a = int(input())
    dp[a] = -1
dp[0] = 1
if dp[1] == 0:
    dp[1] = 1

for i in range(2, N+1):
    if dp[i] != -1:
        if dp[i-1] != -1:
            dp[i] += dp[i-1]
        if dp[i-2] != -1:
            dp[i] += dp[i-2]

print(dp[N] % MOD)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
dp = [0 for _ in range(N)]
for _ in range(M):
    a = int(input())
    a -= 1
    dp[a] = -1
if dp[0] == 0:
    dp[0] = 1
if dp[1] == 0:
    if dp[0] == 1:
        dp[1] = 2
    else:
        dp[1] = 1

for i in range(2, N):
    if dp[i] != -1:
        if dp[i-1] != -1:
            dp[i] += dp[i-1]
        if dp[i-2] != -1:
            dp[i] += dp[i-2]
print(dp[N-1] % MOD)
Problem p03785 (python)

Fixed submission:
N, C, K = map(int, input().split())
T = []
for i in range(N):
    T.append(int(input()))

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N - 1):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)

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

T.sort()
i = 0
start = 0
ans = 0
limit = C
for i in range(N):
    if T[start] + K >= T[i + 1] and limit > 1 :
        limit -= 1
    elif T[start] + K < T[i + 1] and limit > 1:
        ans += 1
        limit = C
        start = i + 1
    elif T[start] + K >= T[i + 1] and limit == 1:
        ans += 1
        limit = C
        start = i + 1
if start != N:
    ans += 1
print(ans)
Problem p02695 (python)

Fixed submission:
N, M, Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

# スコア計算
def score(A):
    tmp = 0
    for ai, bi, ci, di in zip(a, b, c, d):
        if A[bi] - A[ai] == ci:
            tmp += di
    return tmp

# DFS
def dfs(A):
    if len(A) == N:
        return score(A) # 数列 A のスコアを返す
    res = 0
    prev_last = A[-1] if len(A) > 0 else 0
    for v in range(prev_last, M):
        A.append(v)
        res = max(res, dfs(A)) # 再帰呼出しながら、スコア最大値も更新
        A.pop()
    return res

# 求める
print(dfs([]))

Buggy submission (verdict: Runtime Error):
N,M,Q = gets.split.map(&:to_i)
a = []
b = []
c = []
d = []
Q.times do |i|
  a[i], b[i], c[i], d[i] = gets.split.map(&:to_i)
  a[i] -= 1
  b[i] -= 1
end

def score(array,a,b,c,d)
  tmp = 0
  for ai,bi,ci,di in a.zip(b,c,d)
    tmp += di if array[bi] - array[ai] == ci
  end
  tmp
end

def dfs(array,a,b,c,d)
  if array.length == N
    return score(array,a,b,c,d)
  end
  result = 0
  array.length > 0 ? (prev_last = array[-1]) : (prev_last = 0)
  for v in prev_last..M
    array.push(v)
    result = [result, dfs(array,a,b,c,d)].max
    array.pop
  end
  result
end

puts dfs(Array.new,a,b,c,d)
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split(' '))
list_a = list(map(int, input().split(' ')))
list_b = list(map(int, input().split(' ')))
 
a_sum=[list_a[0]]
for i in range(1, n):
  a_sum.append(list_a[i]+a_sum[i-1])
  
b_sum=[list_b[0]]
for i in range(1, m):
  b_sum.append(list_b[i]+b_sum[i-1])

  
ans=0 
if (a_sum[0]>k) and (b_sum[0]>k):
  print(0)
else:
  for j in range(m):
    if b_sum[j]<=k:
      ans=max(ans, j+1)
  j=m-1
  for i in range(n):
    if a_sum[i]<=k:
      ans=max(ans, i+1)
      while a_sum[i] + b_sum[j] > k and j>0:
        j-=1
      if a_sum[i]+b_sum[j]<=k:
        ans=max(ans, i+j+2)
  print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split(' '))
list_a = list(map(int, input().split(' ')))
list_b = list(map(int, input().split(' ')))

a_sum=[list_a[0]]
for i in range(1, n):
  sum=list_a[i]+a_sum[i-1]
  a_sum.append(sum)
  
b_sum=[list_b[0]]
for i in range(1, m):
  sum=list_b[i]+b_sum[i-1]
  b_sum.append(sum)
  
ans=[]
if (a_sum[0]>k) & (b_sum[0]>k):
  print(0)
else:
  for i in range(n):
    for j in range(m):
      if a_sum[i]+b_sum[j] <= k:
        key=i+j+2
        if key not in ans:
          ans.append(key)
  print(max(ans))

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split(' '))
list_a = list(map(int, input().split(' ')))
list_b = list(map(int, input().split(' ')))

a_sum=[list_a[0]]
for i in range(1, n):
  sum=list_a[i]+a_sum[i-1]
  a_sum.append(sum)
  
b_sum=[list_b[0]]
for i in range(1, m):
  sum=list_b[i]+b_sum[i-1]
  b_sum.append(sum)
  
ans=[]
if (a_sum[0]>k) & (b_sum[0]>k):
  print(0)
else:
  for i in range(n):
    for j in range(m):
      if a_sum[i]+b_sum[j] <= k:
        key=i+j+2
        if key not in ans:
          ans.append(key)

print(max(ans))
Problem p02689 (python)

Fixed submission:
N, M = list(map(int, input().split()))
record = [1 for i in range(N)]
H = list(map(int, input().split()))
grid = []
for i in range(M):
    array = list(map(int, input().split()))
    grid.append(array)

for i in range(M):
    if H[grid[i][0]-1] > H[grid[i][1]-1]:
        record[grid[i][1]-1] = 0
    elif H[grid[i][0]-1] < H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
    elif H[grid[i][0]-1] == H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
        record[grid[i][1]-1] = 0

flag = 0
for i in range(N):
    if record[i] == 1:
        flag += 1
print(flag)

Buggy submission (verdict: Runtime Error):
import numpy as np
X=int(input())
flag=1
for c in range(np.power(10,9)):
    c+=1
    x=X
    if x%c==0:
        x=x//c
        for a in range(np.power(10,3)):
            if (np.power(a,4) + np.power(a,3)*(a-c) + np.power(a,2)*np.power(a-c,2) + a*np.power(a-c,3) + np.power(a-c,4))==x:
                print(a,a-c)
                flag=0
                break
    if flag==0:
        break
Problem p02580 (python)

Fixed submission:
H, W, M = map(int, input().split())
HW = [list(map(int, input().split())) for i in range(M)]

g_h = [0] * (H+1)
g_w = [0] * (W+1)

for h, w in HW:
    g_h[h] += 1
    g_w[w] += 1

mxh = max(g_h)
mxw = max(g_w)

cnt = 0
for h, w in HW:
    if g_h[h] == mxh and g_w[w] == mxw:
        cnt += 1
if cnt == g_h.count(mxh) * g_w.count(mxw):
    print(mxh + mxw - 1)
else:
    print(mxh + mxw)

Buggy submission (verdict: Runtime Error):
import numpy as np
H, W, M = map(int, input().split())
HW = [list(map(int, input().split())) for i in range(M)]

grid = np.zeros((H, W))
for h, w in HW:
    grid[h-1][w-1] = 1

max_h = 0
at_h = -1
for h in range(H):
    tmp = np.count_nonzero(grid[h, :])
    if tmp > max_h:
        max_h = tmp
        at_h = h + 1
max_w = 0
at_w = -1
for w in range(W):
    tmp = np.count_nonzero(grid[:, w])
    if tmp > max_w:
        max_w = tmp
        at_w = w + 1

if [at_h, at_w] in HW:
    print(max_h + max_w - 1)
else:
    print(max_h + max_w)
Problem p02623 (python)

Fixed submission:
from itertools import accumulate
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.insert(0,0)
b.insert(0,0)

asum = list(accumulate(a))
bsum = list(accumulate(b))

ans = 0
for i, v in enumerate(asum):
    if v > k:
        break
    index = bisect.bisect_right(bsum, k-v)
    ans = max(ans, i + index-1)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

asum = list(accumulate(a))
bsum = list(accumulate(b))

ans, j = 0, m-1
for i in range(n):
    if asum[i] > k:
        break
    while bsum[j] > k - asum[i]:
        j -= 1
    ans = max(ans, i+1+j+1)
print(ans)
Problem p02624 (python)

Fixed submission:
n = int(input())                                                
                                                                
ans = 0                                                         
for i in range(1, n + 1):                                       
    terms = n // i    # 項数                                      
    ans += terms * (i + i * terms) // 2  # 項数＊(初項＋末項)//2        
                                                                
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

asum = list(accumulate(a))
bsum = list(accumulate(b))

ans, j = 0, m-1
for i in range(n):
    if asum[i] > k:
        break
    while bsum[j] > k - asum[i]:
        j -= 1
    ans = max(ans, i+1+j+1)
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal, ROUND_DOWN
a, b = map(str, input().split())
a = Decimal(a)
b = Decimal(b)

print((a*b).quantize(Decimal("0"), rounding=ROUND_DOWN))

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

ans = b * 100
ans *= a
ans /= 100
print(ans//1)
Problem p02661 (python)

Fixed submission:
import numpy as np

n = int(input())
A, B = [], []  # AにはXがとりうる値の最小値、Bには最大値を入れていく

for _ in range(n):
    a, b = map(int, input().split())
    A.append(a if n % 2 == 1 else a * 2)  # nが偶数だと、medianがとりうる値が0.5刻みになるので最初から2倍にしておく
    B.append(b if n % 2 == 1 else b * 2)

a = np.median(A)
b = np.median(B)

# medianのとりうる値の最小値と最大値の間に、カウントしたいmedianが１刻みで存在する
print(int(max(a, b) - min(a, b) + 1))

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

n = int(input())
A, B = [], []  # AにはXがとりうる値の最小値、Bには最大値を入れていく

for _ in range(n):
    a, b = map(int, input().split())
    A.append(a if n % 2 == 1 else a * 2)  # nが偶数だと、medianがとりうる値が0.5刻みになるので最初から2倍にしておく
    B.append(b if n % 2 == 1 else b * 2)

a = np.median(A)
b = np.median(B)

# medianのとりうる値の最小値と最大値の間に、カウントしたいmedianが１刻みで存在する
print(int(max(a, b) - min(a, b) + 1))
Problem p02790 (python)

Fixed submission:
a, b = map(int, input().split())
 
ab = str(a) * int(b)
ba = str(b) * int(a)
 
ans = sorted([ab, ba])
print(ans[0])

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

ab = str(a * int(b))
ba = str(b * int(a))

ans = [ab, ba].sort

print(ans[0])