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

Fixed submission:
import numpy as np


H, W = map(int, input().split())
h, w = map(int, input().split())
board = np.ones((H, W), dtype=int)
board[0:h] = 0
board[:, 0:w] = 0
print(board.sum())

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


N, M = map(int, input().split())
A, B = list(), list()
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A = np.array(A)
B = np.array(B)

n_bins = 0
cost = 0
indices = np.argsort(A)
for idx in indices:
    print(idx, B[idx], A[idx] * B[idx])
    # enough bins @idx
    if n_bins + B[idx] > M:
        cost += A[idx] * (M - n_bins)
        break
    # buy all bins
    else:
        n_bins += B[idx]
        cost += A[idx] * B[idx]
print(cost)
Problem p03102 (python)

Fixed submission:
import numpy as np


N, M, C = map(int, input().split())
B = np.fromiter(map(int, input().split()), dtype=int)
As = list()
for i in range(N):
    a = np.fromiter(map(int, input().split()), dtype=int)
    As.append(a)
As = np.vstack(As)
print(int(np.sum(As.dot(B) + C > 0)))

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


N, M, C = map(int, input().split())
B = np.fromiter(map(int, input().split()), dtype=int)
As = list()
for i in range(N):
    a = np.fromiter(map(int, input().split()), dtype=int)
    As.append(a)
As = np.vstack(As)
print(int(np.sum(As @ B + C > 0)))

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


N, M, C = map(int, input().split())
B = np.fromiter(map(int, input().split()), dtype=int)
As = list()
for i in range(N):
    a = np.fromiter(map(int, input().split()), dtype=int)
    As.append(a)
As = np.vstack(As)
print(np.sum(As @ B + C > 0))
Problem p02692 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
ABC = [A, B, C]

s = [0] * N
for i in range(N):
  s[i] = str(input())
  
d = {"AB":(0, 1, 2), "BC": (2, 1, 0), "AC": (0, 2, 1)}  
dl = ["A", "B", "C"]  

if ABC == [0, 0, 0]:
  print("No")
  quit()

ans = [0] * N  
if A + B + C == 1:
  for n in range(N):
    i, j, k = d[s[n]]
    #print(i, j, k)
    if ABC[i] == 1:
      ABC[i] = 0
      ABC[j] = 1
      ans[n] = dl[j]
    elif ABC[j] == 1:
      ABC[i] = 1
      ABC[j] = 0
      ans[n] = dl[i]
    else:
      print("No")
      quit()
  print("Yes")
  for i in range(N):
    print(ans[i])
    
else:
  for n in range(N):
    i, j, k = d[s[n]]
    #print(i, j, k)
    if ABC[i] == 0:
      if ABC[j] == 0:
        print("No")
        quit()
      else:
        ABC[i] += 1
        ABC[j] -= 1
        ans[n] = dl[i]
    elif ABC[j] == 0:
      ABC[i] -= 1
      ABC[j] += 1
      ans[n] = dl[j]
    else:
      if n < N - 1:
        if (ABC[i] == 1) or (ABC[j] == 1):
          if s[n] != s[n + 1]:
            n1, n2, n3 = d[s[n + 1]]
            if (i == n1) or (i == n2):
              ABC[i] += 1
              ABC[j] -= 1
              ans[n] = dl[i]
            else:
              ABC[i] -= 1
              ABC[j] += 1
              ans[n] = dl[j]
              
          else:
            ABC[i] -= 1
            ABC[j] += 1
            ans[n] = dl[j]
        else:
          ABC[i] -= 1
          ABC[j] += 1
          ans[n] = dl[j]
      else:
        ABC[i] -= 1
        ABC[j] += 1
        ans[n] = dl[j]
        
  print("Yes")
  for i in range(N):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
ABC = [A, B, C]
if ABC == [0, 0, 0]:
  print("No")
  quit()

p = [0] * N
for i in range(N):
  p[i] = str(input())
  
s = [0] * N
for i in range(N):
  x = p[i]
  if x == "AB":
    if A > B:
      A, B = A - 1, B + 1
      s[i] = "B"
    elif B > A:
      A, B = A + 1, B - 1
      s[1] = "A"
    else:
      if A == 0:
        A, B = A + 1, B - 1
        s[1] = "A"  
      elif B == 0:
        A, B = A - 1, B + 1
        s[1] = "B"
      else:
        A, B = A - 1, B + 1
        s[1] = "B"
  elif x == "BC":
    if B > C:
      B, C = B - 1, C + 1
      s[i] = "C"
    elif B > A:
      B, C = B + 1, C - 1
      s[1] = "B"
  else:
    if C > A:
      C, A = C - 1, A + 1
      s[i] = "A"
    elif B > A:
      C, A = C + 1, A - 1
      s[1] = "C"    
  
print("Yes")  
for i in range(N):
  print(s[i])
Problem p02714 (python)

Fixed submission:
N = int(input())
S = str(input())
R, G, B = 0, 0, 0
for i in range(N):
  if S[i] == "R":
    R += 1
  elif S[i] == "G":
    G += 1
  else:
    B += 1
    
ans = R * G * B 

for i in range(1, 2000):
  for j in range(1, N - 2 * i + 1):
    if S[j - 1] != S[j + i - 1]:
      if S[j + 2 * i - 1] != S[j + i - 1]:
        if S[j - 1] != S[j + 2 * i - 1]:
          ans -= 1
            
print(max(ans, 0))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
RGB = [0] * 3
for i in range(N):
  if S[i] == "R":
    RGB[0] += 1
  elif S[i] == "G":
    RGB[1] += 1:
  else:
    RGB[2] += 1
    
ans = RGB[0] * RGB[1] * RGB[2]

for i in range(1, 2000):
  for j in range(1, N + 1):
    if (j + 2 * i) <= N:
      if S[j - 1] != S[j + i - 1]:
        if S[j + 2 * i - 1] != S[j + i - 1]:
          if S[j - 1] != S[j + 2 * i - 1]:
            ans -= 1
            
print(max(ans, 0))
Problem p02721 (python)

Fixed submission:
N, K, C = map(int, input().split())
S = str(input())

#前から貪欲に
x = 0
L = [-1] * K
p = 0
while (x < N) and (p != K):
  if S[x] == "o":
    L[p] = x
    p += 1
    x += C + 1
  else:
    x += 1

#後ろから貪欲に    
y = N - 1
R = [-1] * K
q = 0
while (y > -1) and(q != K):
  if S[y] == "o":
    R[q] = y
    q += 1
    y -= C + 1
  else:
    y -= 1
    
#print(L, R)

#LとRの被っている数に1足したものを出力
for i in range(K):
  if L[i] == R[K - i - 1]:
    print(L[i] + 1)

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

#前から貪欲に
x = 0
L = [-1] * N
p = 0
while x < N:
  if S[x] == "o":
    L[p] = x
    p += 1
    x += C + 1
  else:
    x += 1

#後ろから貪欲に    
y = N - 1
R = [-1] * N
q = 0
while y > -1:
  if S[y] == "o":
    R[q] = y
    q += 1
    y -= C + 1
  else:
    y -= 1
    
#print(L, R)    
L_1 = L.index(-1)
L = L[:L_1]
R = R[:L_1]
N = len(L)

#LとRの被っている数に1足したものを出力
for i in range(N):
  if L[i] == R[N - i - 1]:
    print(L[i] + 1)
Problem p02756 (python)

Fixed submission:
S = str(input())
Q = int(input())
st = [0] * Q
n = [0] * Q
p = 0
s_h = 0
for i in range(Q):
  q = str(input())
  if int(q[0]) == 1:#Ti = 1
    s_h += 1
  else:
    if int(q[2]) == 1:#先頭
      st[p] = q[4]
      n[p] = s_h
      p += 1
    else:
      st[p] = q[4]
      n[p] = s_h + 1
      p += 1

odd = ["".join(st[a]) for a in range(Q) if ((n[a] + s_h) % 2 == 1) and (str(st[a]) != "0")]
odd = "".join(odd)
even =  ["".join(st[a]) for a in range(Q) if ((n[a] + s_h) % 2 == 0) and (str(st[a]) != "0")]
even = "".join(even)[::-1]
if s_h % 2 == 1:
  S = S[::-1]

b = [even, S, odd]
#print(S,odd,even)
print("".join(b))

Buggy submission (verdict: Runtime Error):
S = str(input())
Q = int(input())
st = [0] * Q
n = [0] * Q
p = 0
for i in range(Q):
  q = str(input())
  if int(q[0]) == 1:#Ti = 1
    s_h += 1
  else:
    if int(q[2]) == 1:#先頭
      st[p] = q[4]
      n[p] = s_h
      p += 1
    else:
      st[p] = q[4]
      n[p] = s_h + 1
      p += 1

print(S)
Problem p02768 (python)

Fixed submission:
import math
n, a, b = map(int, input().split())
p = 10 ** 9 + 7
#ans = 2 ** n - 1 - N C a - N C b

def modpow(a, n, MOD):
  res = 1
  while (n > 0):
    if (n & 1):
      res = res * a % MOD
    a = a * a % MOD
    n >>= 1
  return res

def cmb(n, r, p):
  A = 1
  for i in range(r):
    A *= (n - i)
    A *= modpow(i + 1, p - 2, p)
    A %= p
  return A

ans = (modpow(2, n, p) - 1) % p
ans -= cmb(n, a, p) + cmb(n, b, p)

print(ans % p)

Buggy submission (verdict: Runtime Error):
import math
N, a, b = map(int, input().split())
MOD = 10 ** 9 + 7

#def combinations_count(n, r):
#    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#print(combinations_count(4, 2))
# 6
ans = 0
X = 1
for i in range(1, N + 1):
  X = int(X * (N + 1 - i) / i)
  if i != a:
    if i != b:
      ans += X
      
print(ans)
Problem p02786 (python)

Fixed submission:
H = int(input())

if H == 1:
  print("1")
  quit()

bin_h = str(bin(H)[2:])
len_h = len(bin_h)
ans = 2 ** len_h - 1

if bin_h[1] == 1:
  ans += 2 ** (len_h - 1)
  
print(ans)

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

bin_h = str(bin(H)[2:])
len_h = len(bin_h)
ans = 2 ** len_h - 1

if bin_h[1] == 1:
  ans += 2 ** (len_h - 1)
  
print(ans)
Problem p02814 (python)

Fixed submission:
import fractions
from functools import reduce

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

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

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
  A[i] = A[i] // 2
  
p = 0
de_2 = 0
x = A[0]
while (p == 0):
  if x % 2 == 0:
    x = x // 2
    de_2 += 1
  else:
    p = 1
    
de = 2 ** de_2
for i in range(1, N):
  if A[i] % de == 0:
    if A[i] % (de * 2) != 0:
      continue
    else:
      print("0")
      quit()
  else:
    print("0")
    quit()
  
lcm = lcm_list(A)
p = M // lcm
if p % 2 == 0:
  ans = p // 2
else:
  ans = (p + 1) // 2
  
print(ans)

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

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)#長さがN

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def half_lcm_list(numbers):
    return reduce(lcm_base, numbers, 1) / 2

min_A = half_lcm_list(A)

#print(min_A)
ans = 0
if min_A > M:
  ans = 0
else:
  ans = 1
  ans += int((M - min_A) / (min_A * 2))
  
print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7

ans = 0
for i in range(64):
    tmp = (A >> i) & 1
    #print(tmp)
    x = np.count_nonzero(tmp)
    x *= n - x
    ans += pow(2, i, mod) * x % mod

print(ans % mod)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7

ans = 0
for i in range(64):
    tmp = (A >> i) & 1
    #print(tmp)
    x = np.count_nonzero(tmp)
    x *= n - x
    ans += pow(2, i, mod) * x % mod

print(ans % mod)

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

bit2 = [0] * 20
for i in range(N):
  bin_a = bin(A[i])
  #print(bin_a)#2なら0b10と返す
  str_bin_a = str(bin_a)[2:]
  #print(str_bin_a)
  l = len(str_bin_a)
  for j in range(l):
    bit2[j] += int(str_bin_a[-(j + 1)])
    
#print(bit2)
ans = 0
for i in range(20):
  count1 = bit2[i]
  count0 = N - count1
  ans += (2 ** i) * count0 * count1
  
print(ans)
Problem p02846 (python)

Fixed submission:
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

len1 = T1 * A1 + T2 * A2
len2 = T1 * B1 + T2 * B2
if len1 == len2:
  print("infinity")
  quit()

ans = 0
subs = 0  
sub1 = T1 * (A1 - B1)
sub2 = T2 * (A2 - B2)

if sub1 > 0:
  if len1 - len2 > 0:
    ans = 0
  else:
    S = (-1 * sub1) // (sub1 + sub2)
    T = (-1 * sub1) % (sub1 + sub2)
    if T == 0:
      ans = 2 * S
    else:
      ans = 2 * S + 1
else:
  if len1 - len2 < 0:
    ans = 0
  else:
    S = (-1 * sub1) // (sub1 + sub2)
    T = (-1 * sub1) % (sub1 + sub2)
    if T == 0:
      ans = 2 * S
    else:
      ans = 2 * S + 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
T1,T2 = map(int,input().split())
A1,A2 = map(int,input().split())
B1,B2 = map(int,input().split())

len1 = T1 * A1 + T2 * A2
len2 = T1 * B1 + T2 * B2
if len1 == len2:
  print("infinity")
  quit()

ans = 0
subs = 0  
sub1 = T1 * (A1 - B1)
sub2 = T2 * (A2 - B2)
X = [1, 1]
i = 0
while (X != [0, 0]):
  i += 1
  if subs != 0:
    if (subs + sub1)(subs) <= 0:
      ans += 1
      X[0] = 1
    else:
      X[0] = 0
  subs = subs + sub1
  if subs != 0:
    if subs(subs + sub2) <= 0:
      ans += 1
      X[1] = 1
    else:
      X[1] = 0
  subs = subs + sub2

print(ans)
Problem p02918 (python)

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

RL = 0
for i in range(N-1):
  if S[i]=='R' and S[i+1]=='L':
    RL += 2
    
if S[0]=='L':
  RL += 1
if S[-1]=='R':
  RL += 1

ans = N - RL
ans = min(N - 1, ans + 2 * K)
print(ans)

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

counts = []
count = 0
lr = 0
rl = 0
for i in range(N - 1):#start
  z = S[i]
  if S[i] == S[i + 1]:
    count += 1
  elif (S[i] == "L") and (S[i+1] == "R"):
    lr += 1
  elif (S[i] == "R") and (S[i+1] == "L"):
    rl += 1
 
minlr = min(lr, rl)
maxlr = max(lr, rl) 
T = [S[0],S[1],S[-2],S[-1]]
U = [["L", "R", "R", "R"],["L", "R", "L", "L"],["R", "R", "L", "R"],["L", "L", "L", "R"]]
if (maxlr == 1) and (minlr == 0):
  count += 1
  if T in U:
    count -= 1
  print(count)
else:
  minK = min(K, minlr)
  count += 2 * minK
  print(count)

Buggy submission (verdict: Runtime Error):
["L", "R", "R", "R"]N, K = map(int, input().split())
S = str(input())

counts = []
count = 0
lr = 0
rl = 0
for i in range(N - 1):#start
  z = S[i]
  if S[i] == S[i + 1]:
    count += 1
  elif (S[i] == "L") and (S[i+1] == "R"):
    lr += 1
  elif (S[i] == "R") and (S[i+1] == "L"):
    rl += 1
 
minlr = min(lr, rl)
maxlr = max(lr, rl) 
T = [S[0],S[1],S[-2],S[-1]]
U = [["L", "R", "R", "R"],["L", "R", "L", "L"],["R", "R", "L", "R"],["L", "L", "L", "R"]]
if (maxlr == 1) and (minlr == 0):
  count += 1
  if T in U:
    count -= 1
  print(count)
else:
  minK = min(K, minlr)
  count += 2 * minK
  print(count)
Problem p02921 (python)

Fixed submission:
S = str(input())
T = str(input())
count = 0

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

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]

for i in range(N):
  leng = ((A[i][0]) ** 2 + (A[i][1]) ** 2) ** (1/2)
  if (A[i][0] == 0) and (A[i][1] == 0):
    angle = 0
  elif A[i][0] == 0:
    if A[i][1] > 0:
      angle = 90
    else:
      angle = 270
  elif A[i][1] == 0:
    if A[i][0] > 0:
      angle = 0
    else:
      angle = 180
  else:  
    radian = math.atan2(A[i][1], A[i][0])
    angle = math.degrees(radian)
  A[i].append(leng)
  A[i].append(angle)
  
#エンジンは100しかないからN**2でも間に合うはず

ans = 0
for i in range(N):
  x, y = A[i][0], A[i][1]
  for j in range(N):
    angle =A[i][3] 
    if i != j:
      if -90 < angle < 90 :
        if angle - 90 < A[j][3] < angle + 90:
          x += A[j][0]
          y += A[j][1]
      elif -180 < angle < -90:
        if (A[j][3] < angle + 90) or (angle + 270 < A[j][3]):
          x += A[j][0]
          y += A[j][1]
      else: 
        if (angle - 90 < A[j][3]) or (A[j][3] < angle - 270):
          x += A[j][0]
          y += A[j][1]
  ans1 = (x ** 2 + y ** 2 ) ** (1/2)
  ans = max(ans, ans1)
  
print(ans)
#print(A)
Problem p03061 (python)

Fixed submission:
#解説の方針にしたがった
import fractions

N = int(input())
X = list(map(int, input().split()))
   
M = 1  
L = [0 for i in range(100004)] #L(0)=0
R = [0 for i in range(100004)]  #R(N+1) = 0

for i in range(N):
  L[i] = (fractions.gcd(L[i-1],X[i]))

for i in reversed(range(N)):
  #print(i)
  R[i] = (fractions.gcd(R[i+1],X[i]))
    
ans = 1

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

print(ans)

Buggy submission (verdict: Runtime Error):
#解説の方針にしたがった
import fractions

N = int(input())
X = list(map(int, input().split()))
   
M = 1  
L = [0 for i in range(10)] #L(0)=0
R = [0 for i in range(10)]  #R(N+1) = 0

for i in range(N):
  L[i] = (fractions.gcd(L[i-1],X[i]))

for i in reversed(range(N)):
  #print(i)
  R[i] = (fractions.gcd(R[i+1],X[i]))
    
ans = 1

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

print(ans)
Problem p03076 (python)

Fixed submission:
N = [int(input()) for i in range(5)] 
list_sho = []
list_amari = []

for i in range(len(N)):
  list_sho.append(N[i]//10)
  list_amari.append(N[i]%10)
  
min1 = list_amari.index(min(list_amari))#あまりが最小になるうち一つの位置を取得
sum1 = 0

for i in range(len(N)):
  if N[i] % 10 == 0:
    sum1 += N[i]
  else:
    sum1 += ((N[i]//10) + 1) * 10

if N[min1]%10 == 0:
  while min(list_amari) == 0:
    list_amari.remove(0)
    if len(list_amari) == 0:
      break
  if len(list_amari) == 0:
    sum1 =  sum1
  else:
    sum1 =  sum1 - 10 +  min(list_amari)
  print(sum1)
else:
  sum1 = sum1 - 10 +  N[min1]%10
  print(sum1)

Buggy submission (verdict: Runtime Error):
N = [int(input()) for i in range(5)] 
list_sho = []
list_amari = []

for i in range(len(N)):
  list_sho.append(N[i]//10)
  list_amari.append(N[i]%10)
  
min1 = list_amari.index(min(list_amari))#あまりが最小になるうち一つの位置を取得
sum1 = 0

for i in range(len(N)):
  if N[i] % 10 == 0:
    sum1 += N[i]
  else:
    sum1 += ((N[i]//10) + 1) * 10

if N[min1]%10 == 0:
  while min(list_amari) == 0:
    list_amari.remove(0)
  sum1 =  sum1 - 10 +  min(list_amari)
  print(sum1)
else:
  sum1 = sum1 - 10 +  N[min1]%10
  print(sum1)
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N+1):
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)

print(list_gcd[-K])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N):
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)
    
print(list_gcd[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N):
  print(A)
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)
    
print(list_gcd[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N):
  print(A)
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
if N == 1:
  Y = max(A,B)
  if Y == 1:
    list_gcd.append(1)
  else:
    for i in range(1, Y):
      if Y % i == 0:
        list_gcd.append(i)
    
print(list_gcd[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
N = min(A, B)
list_gcd = [] 

for i in range(1, N):
  if A % i == 0 and B % i == 0:
    list_gcd.append(i)
    
print(list_gcd[K-1])
Problem p03110 (python)

Fixed submission:
N = int(input())
cost = [list(input().split()) for i in range(N)]
count = 0

for i in range(N):
  if cost[i][1] == "JPY":
    count += float(cost[i][0])
  else:
    count += float(cost[i][0]) * 380000.0
    
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
cost = [list(map(int, inpu().split())) for i in range(N)]
count = 0

for i in range(N):
  if cost[i][1] == "JPY":
    count += cost[i][0]
  else:
    count += cost[i][0] * 380000.0
    
print(count)
Problem p03212 (python)

Fixed submission:
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
    ret += dfs(s + c)
  return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

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

def dfs(s): # 文字列 s で始まる七五三数の個数
  if int(s) > N:
    return 0
  ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
  for c in '753':
  ret += dfs(s + c)
  return ret

print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく
Problem p03220 (python)

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

minT = 651
ans = 1

for i in range(N):
  aveT = T - H[i] * 0.006
  minT = min(minT, abs(aveT - A))
  #print(minT)
  if minT == abs(aveT - A):
    ans = i + 1
    
print(ans)

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

minT = 50

for i in range(N):
  aveT = T - H[i] * 0.006
  minT = min(minT, abs(aveT - A))
  #print(minT)
  if minT == abs(aveT - A):
    ans = i + 1
    
print(ans)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 2:
  A = int(input())
  B = int(input())
  print(A + B)
else:
  print("Hello World")

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 2:
  A,B = map(int, input().split())
  print(A + B)
else:
  print("Hello World")
Problem p03239 (python)

Fixed submission:
N,T = map(int, input().split())
C = [list(map(int,input().split())) for i in range(N)]
X = sorted(C, key = lambda x:x[1])

i = 0
ans = 1001
while X[i][1] <= T:
  ans = min(ans, X[i][0])
  if i + 1 == N:
    break
  i += 1

if ans <= 1000:
  print(ans)
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
N,T = map(int, input().split())
C = [list(map(int,input().split())) for i in range(N)]
X = sorted(C, key = lambda x:x[1])

i = 0
ans = 1001
while X[i][1] <= T:
  ans = min(ans, X[i][0])
  i += 1

if ans <= 1000:
  print(ans)
else:
  print("TLE")
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []
for i in range(N):
  subx.append(abs(listx[i] - X))
  
def lcm_list(numbers):
    return reduce(fractions.gcd, numbers)

ans = lcm_list(subx)

print(ans)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []

for i in range(N):
  subx.append(abs(listx[i] - X))
if N = 1:
  subx.append(subx[0])

def gcd(a,b):
  if a < b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

ans = gcd(subx[0], subx[1])

if N > 2:
  for i in range(2, N):
    ans = gcd(ans, subx[i])
  
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
listx = list(map(int, input().split()))
subx = []

for i in range(N):
  subx.append(abs(listx[i] - X))

def gcd(a,b):
  if a < b:
    a, b = b, a
  while a % b != 0:
    a, b = b, a % b
  return b

ans = gcd(subx[0], subx[1])

for i in range(2, N-1):
  ans = gcd(ans, subx[i])
  
print(ans)
Problem p03287 (python)

Fixed submission:
import collections
    
n, m = map(int, input().split())
A = list(map(int, input().split()))
ans_list = [0] * (n + 1)
for i in range(1, n + 1):
  A[i - 1] %= m
  ans_list[i] = (ans_list[i - 1] + A[i - 1]) % m
ans_list.pop(ans_list[0])
ans_list = dict(collections.Counter(ans_list))
  
#print(A)
#print(ans_list)
count = 0
if 0 in ans_list:
  count = ans_list[0]
#print(count)
for v in ans_list.values():
  #print(v)
  if v != 1:
    count +=  v * (v - 1) / 2
    
print(int(count))

Buggy submission (verdict: Runtime Error):
import collections
    
n, m = map(int, input().split())
A = list(map(int, input().split()))
ans_list = [0] * (n + 1)
for i in range(1, n + 1):
  A[i - 1] %= m
  ans_list[i] = (ans_list[i - 1] + A[i - 1]) % m
ans_list.pop(ans_list[0])
ans_list = dict(collections.Counter(ans_list))
  
#print(A)
#print(ans_list)
count = ans_list[0]
#print(count)
for v in ans_list.values():
  #print(v)
  if v != 1:
    count +=  v * (v - 1) / 2
    
print(int(count))

Buggy submission (verdict: Runtime Error):
import collections

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 1
N = 10 ** 5 + 1  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
    
n, m = map(int, input().split())
A = list(map(int, input().split()))
ans_list = [0] * (n + 1)
for i in range(1, n + 1):
  A[i - 1] %= m
  ans_list[i] = (ans_list[i - 1] + A[i - 1]) % m
ans_list.pop(ans_list[0])
ans_list = dict(collections.Counter(ans_list))
  
#print(A)
#print(ans_list)
count = ans_list[0]
#print(count)
for v in ans_list.values():
  #print(v)
  if v != 1:
    count +=  v * (v - 1) / 2
    
print(int(count))