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

Fixed submission:
h,w = map(int, input().split())
s = []
for i in range(h):
  s.append(input())

l = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if j == 0:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = 1
    else:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = l[i][j-1] + 1

r = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w-1, -1, -1):
    if j == w-1:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = 1
    else:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = r[i][j+1] + 1

u = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h):
    if i == 0:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = 1
    else:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = u[i-1][j] + 1

d = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h-1, -1, -1):
    if i == h-1:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = 1
    else:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = d[i+1][j] + 1

ans = 0
for i in range(h):
  for j in range(w):
    a = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
    ans = max(ans, a)

print(ans)

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

l = [[0]*w]*h
for i in range(h):
  for j in range(w):
    if j == 0:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = 1
    else:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = l[i][j-1] + 1

r = [[0]*w]*h
for i in range(h):
  for j in range(w-1, 0, -1):
    if j == w-1:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = 1
    else:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = r[i][j+1] + 1

u = [[0]*w]*h
for j in range(w):
  for i in range(h):
    if i == 0:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = 1
    else:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = u[i-1][j] + 1

d = [[0]*w]*h
for j in range(w):
  for i in range(h-1, 0, -1):
    if i == h-1:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = 1
    else:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = d[i+1][j] + 1

ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
Problem p03061 (python)

Fixed submission:
import math
n = int(input())
a = []
a.append(list(map(int, input().split())))
def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)

pow_2 = 1
exp = 0
while pow_2 < n:
  pow_2 *= 2
  exp += 1

a[0].extend([0]*(pow_2 - n))
for i in range(1, exp):
  a.append([])
  for j in range(int(pow_2 / math.pow(2, i))):
    a[i].append(gcd(a[i-1][2*j], a[i-1][2*j+1]))

ans = [0]*n
for i in range(n):
  g = 0
  for j in range(0,exp):
    if (i >> j) % 2 == 0:
      bit = 1
    else:
      bit = -1
    g = gcd(a[j][(i>>j)+bit], g)
  ans[i] = g
print(sorted(ans)[n-1])

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = []
a.append(list(map(int, input().split())))
def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)

pow_2 = 1
exp = 0
while pow_2 < n:
  pow_2 *= 2
  exp += 1

a[0].extend([0]*(pow_2 - n))
for i in range(1, exp):
  a.append([])
  for j in range(pow_2 / math.pow(2, i)):
    a[i].append(gcd(a[i-1][2*j], a[i-1][2*j+1]))

ans = [0]*n
for i in range(n):
  g = 0
  for j in range(0,exp):
    if (i >> j) % 2 == 0:
      bit = 1
    else:
      bit = -1
    g = gcd(a[j][(i>>j)+bit], g)
  ans[i] = g
print(sorted(ans)[n-1])
Problem p03087 (python)

Fixed submission:
n,q = map(int, input().split())
s = input()
c = []
pre = ""
count = 0
for i in range(n):
  if pre == "A" and s[i] == "C":
    count += 1
  pre = s[i]
  c.append(count)
  
for i in range(q):
  l,r = map(int,input().split())
  print(c[r-1]-c[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
c = []
for i in range(n+1):
  c.add(s[:i].count("AC"))
  
for i in range(q):
  l,r = map(int,input().split())
  print(c[r]-c[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  count = 0
  pre = s[l-1]
  for j in range(l, r):
    if pre == 'A' and s[j] == 'C':
      count += 1
    pre = s[j]
  print(cound)

Buggy submission (verdict: Runtime Error):
n,q = map(int, input().split())
s = input()
for i in range(q):
  l,r = map(int,input().split())
  print(s[l-1:r]).cound("AC")
Problem p03102 (python)

Fixed submission:
n,m,c = map(int, input().split())
b = list(map(int,input().split()))
a = []

def mul(x, y):
  ret = 0
  for i in range(len(x)):
    ret += x[i]*y[i]
  return ret
    
ans = 0
for i in range(n):
  a = list(map(int, input().split()))
  if mul(a, b) + c > 0:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m,c = map(int, input().split())
b = list(map(int,input().split()))
a = []

def mul(x, y):
  ret = 0
  for i in range(len(x)):
    ret += x[i]*y[i]

ans = 0
for i in range(n):
  a = list(map(int, input().split()))
  if mul(a, b) + c > 0:
    ans += 1

print(ans)
Problem p03103 (python)

Fixed submission:
n,m = map(int,input().split())
l = []
for i in range(n):
    a,b = map(int, input().split())
    l.append((a,b))
ans = 0
l.sort()
for a,b in l:
  if b >= m:
    ans += a * m
    break
  else:
    ans += a*b
    m -= b
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [map(int, input().split()) for i in range(n)]
ans = 0
l.sort()
for a,b in l:
  if b >= m:
    ans += a * m
    break
  else:
    ans += a*b
    m -= b
print(ans)
Problem p03110 (python)

Fixed submission:
n = int(input())
dic = {"JPY": 1, "BTC": 380000}
ans = 0
for i in range(n):
  x,u = input().split()
  ans += float(x) * dic[u]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {"JPY": 1, "BTC": 380000}
ans = 0
for i in range(n):
  x,u = input().split()
  ans += int(x) * dic[u]
print(ans)
Problem p03111 (python)

Fixed submission:
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 10000
for i in range(2 ** (2*n)):
  v = [0,0,0,0]
  assign = [(i>>(2*j)) & 3 for j in range(n)]
  cost = 0
  for j in range(n):
    if assign[j] > 0 and v[assign[j]] > 0:
      cost += 10
    v[assign[j]] += l[j]
  if v[1] == 0 or v[2] == 0 or v[3] == 0:
    continue
  ans = min(ans, cost + abs(v[1]-a) + abs(v[2]-b) + abs(v[3]-c))
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 10000
for i in range(2 ** (2*n)):
  v = [0,0,0,0]
  assign = [(i>>(2*j)) & 3 for j in range(n)]
  cost = 0
  for j in range(n):
    is v[assign[j]] > 0:
      cost += 10
    v[assign[j]] += l[j]
  if v[1] == 0 or v[2] == 0 or v[3] == 0:
    continue
  ans = min(ans, cost + abs(v[1]-a) + abs(v[2]-b) + abs(v[3]-c))
print(ans)
Problem p03126 (python)

Fixed submission:
n,m = map(int, input().split())
ans = 0
buf = [0]*m
for i in range(n):
  a = list(map(int, input().split()))[1:]
  for j in a:
    buf[j-1] += 1

for a in buf:
  if a == n:
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
ans = 0
buf = [0]*m
for i in range(n):
  a = list(map(int, input().split()))[1:]
  for j in a:
    buf[j] += 1

for a in buf:
  if a == n:
    ans += 1

print(ans)
Problem p03212 (python)

Fixed submission:
n = int(input())
 
def bfs(s):
  if int(s) > n:
    return 0
  return ('3' in s and '5' in s and '7' in s) + bfs(s+'3') + bfs(s+'5') + bfs(s+'7')
 
print(bfs('0'))

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

def bfs(s):
  if int(s) >= n:
    return 0
  return ('3' in s and '5' in s and '7' in s) + bfs(s+'3') + bfs(s+'5') + bfs(s+'7')

print(bfs(''))
Problem p03219 (python)

Fixed submission:
x,y = map(int, input().split())
print(x + int(y/2))

Buggy submission (verdict: Runtime Error):
x,y = map(int, input())
print(x + int(y/2))
Problem p03238 (python)

Fixed submission:
n = int(input())
if n == 1:
  print("Hello World")
elif n == 2:
  a = int(input())
  b = int(input())
  print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
  print("Hello World")
if n == 2:
  print(a+b)
Problem p03239 (python)

Fixed submission:
n,T = map(int, input().split())
ans = 1001
for i in range(n):
  c,t = map(int, input().split())
  if t <= T:
    ans = min(ans, c)

if ans == 1001:
  print("TLE")
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n,T = map(int, input())
ans = 1000
for i in range(n):
  c,t = map(int, input())
  if t <= T:
    ans = min(ans, c)
print(ans)
Problem p03240 (python)

Fixed submission:
n = int(input())
points = []
for i in range(n):
    x, y, h = map(int, input().split())
    points.append((x, y, h))
points.sort(key=lambda x:x[2], reverse=True)


def f(points):
    for x in range(0, 101):
        for y in range(0, 101):
            p = points[0]
            h = abs(x - p[0]) + abs(y - p[1]) + p[2]
            same = True
            for i in range(1, len(points)):
                p = points[i]
                h_p = max(0, h - abs(x - p[0]) - abs(y - p[1]))
                if h_p != p[2]:
                    same = False
                    break
            if same:
                return x, y, h
    return -1,-1,-1


ans = f(points)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
points = []
for i in range(n):
    x, y, h = map(int, input().split())
    points.append((x, y, h))


def f(points):
    for x in range(0, 101):
        for y in range(0, 101):
            h = 0
            same = True
            for p in points:
                h_p = abs(x - p[0]) + abs(y - p[1]) + p[2]
                if h != 0 and h != h_p:
                    same = False
                    break
                elif h == 0:
                    h = h_p
            if same:
                return x, y, h

ans = (0,0,0)
ans = f(points)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
points = []
for i in range(n):
    x, y, h = map(int, input().split())
    points.append((x, y, h))


def f(points):
    for x in range(0, 101):
        for y in range(0, 101):
            h = 0
            same = True
            for p in points:
                h_p = abs(x - p[0]) + abs(y - p[1]) + p[2]
                if h != 0 and h != h_p:
                    same = False
                    break
                elif h == 0:
                    h = h_p
            if same:
                return x, y, h


ans = f(points)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Buggy submission (verdict: Runtime Error):
n = int(input())
points = []
ans = [0,0,0]
for i in range(n):
  x,y,h = map(int,input().split())
  points.append((x,y,h))

def f(points):
  for x in range(0,101):
    for y in range(0,101):
      h = 0
      same = True
      for p in points:
        h_p = abs(x-p[0]) + ans(y-p[1]) + p[2]
        if h != 0 and h != h_p:
          same = False
          break
        elif h == 0:
          h = h_p
      if same:
        return x,y,h
      
ans = f(points)
print("{} {} {}", format(ans[0], ans[1], ans([2])))
Problem p03244 (python)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
even = dict()
odd = dict()
even[0] = 0
odd[0] = 0
for i in range(n//2):
  a = v[2*i]
  if a in even:
    even[a] += 1
  else:
    even[a] = 1
  a = v[2*i + 1]
  if a in odd:
    odd[a] += 1
  else:
    odd[a] = 1

even_sorted = sorted(even.items(), key=lambda x:x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x:x[1], reverse=True)

if even_sorted[0][0] == odd_sorted[0][0]:
  print(n - max(even_sorted[0][1]+odd_sorted[1][1], even_sorted[1][1]+odd_sorted[0][1]))
else:
  print(n - even_sorted[0][1] - odd_sorted[0][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
even = dict()
odd = dict()
for i in range(n//2):
  a = v[2*i]
  if a in even:
    even[a] += 1
  else:
    even[a] = 1
  a = v[2*i + 1]
  if a in odd:
    odd[a] += 1
  else:
    odd[a] = 1

even_sorted = sorted(even.items(), key=lambda x:x[1], reverse=True)
odd_sorted = sorted(odd.items(), key=lambda x:x[1], reverse=True)

if even_sorted[0][0] == odd_sorted[0][0]:
  print(n - max(even_sorted[0][1]+odd_sorted[1][1], even_sorted[1][1]+odd_sorted[0][1]))
else:
  print(n - even_sorted[0][1] - odd_sorted[0][1])
Problem p03261 (python)

Fixed submission:
n = int(input())
w = [input() for i in range(n)]

def is_shiritori():
  if len(set(w)) != n:
    return 'No'
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      return 'No'
  return 'Yes'

print(is_shiritori())

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

def is_shiritori():
  if len(set(w)) != n:
    return 'No'
  for i in range(n-1):
    if w[n][-1] != w[n+1][0]:
      return 'No'
  return 'Yes'
print(is_shiritori())
Problem p03262 (python)

Fixed submission:
n,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
Y = []
for i in range(n):
  Y.append(x[i+1]-x[i])

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

ans = Y[0]
for y in Y:
  ans = gcd(ans,y)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
Y = []
for i in range(n):
  Y.append(x[i+1]-x[i])

ans = Y[0]
for y in Y:
  ans = math.gcd(ans,y)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n,X = map(int, input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
y = []
for i in range(n):
  y.append(x[i+1]-x[i])

ans = y[0]
for i in range(1,n):
  ans = math.gcd(ans,y[i])
print(ans)
Problem p03273 (python)

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

for i in range(h):
  a.append(input())

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  if h_blank[i]:
    continue
  for j in range(w):
    if w_blank[j]:
      continue
    print(a[i][j], end='')
  print('')

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

for i in range(h):
  a.append(list(map(int, input().split())))

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  for j in range(w):
    if h_blank[i] or w_blank[j]:
      continue
    print(a[i][j])

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

for i in range(h):
  a.append(list(map(int, input().split())))

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  for j in range(w):
    if h_blank[i] or w_blank[j]:
      continue
    print(a[i][]j)
Problem p03289 (python)

Fixed submission:
s = input()
count = 0
for c in s:
  if c.isupper():
    count += 1

if count == 2 and s[0] == 'A' and 'C' in s[2:-1]:
  print('AC')
else:
  print('WA')

Buggy submission (verdict: Runtime Error):
s = input()
for c in s:
  if c.isupper():
    count += 1

if count == 2 and s[0] == 'A' and 'C' in s[2:-1]:
  print('AC')
else:
  print('WA')
Problem p03290 (python)

Fixed submission:
import math
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(int(math.pow(2,d))):
  count = 0
  score = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = min(count , count - p[j] + math.ceil(rest / ((j+1)*100)))
    ans = min(ans, count_tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(1024):
  count = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = count - p[j] + math.ceil(rest / ((d+i)*100))
    ans = min(ans, count_tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
d, g = map(int, input().split())
p = []
c = []
su = []
ans = 1000
for i in range(d):
  a,b = map(int, input().split())
  p.append(a)
  c.append(b)
  su.append(a*100*(i+1)+b)
bit = [1,2,4,8,16,32,64,128,256,512]
for i in range(1024):
  count = 0
  for j in range(d):
    if i & bit[j] == 0:
      continue
    score += su[j]
    count += p[j]
  if score < g:
    continue
  for j in range(d):
    if i & bit[j] == 0 or score - su[j] >= g:
      continue
    rest = g - (score - su[j])
    count_tmp = count - p[j] + math.ceil(rest / ((d+i)*100))
    ans = min(ans, count_tmp)
print(ans)
Problem p03292 (python)

Fixed submission:
a = list(map(int, input().split()))
b = [abs(a[0]-a[1]), abs(a[1]-a[2]), abs(a[2]-a[0])]
b.sort()
print(b[0]+b[1])

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = [abs(a[0]-a[i]), abs(a[1]-a[2]), abs(a[2]-a[0])]
b.sort()
print(b[0]+b[1])
Problem p03328 (python)

Fixed submission:
a,b = map(int, input().split())
print((b-a)*(b-a-1)//2 - a)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 1000:
  print('ABC')
else:
  print('ABD')
Problem p03339 (python)

Fixed submission:
n = int(input())
s = input()
t1 = [0]*n
t2 = [0]*n
for i in range(1, n):
  t1[i] = t1[i-1] + (s[i-1] == 'W')
  t2[n-i-1] = t2[n-i] + (s[n-i] == 'E')
ans = n
for i in range(n):
  ans = min(ans, t1[i] + t2[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t1 = [0]*n
t2 = [0]*n
for i in range(1, n):
  t1[i] = t1[i-1] + s[i-1] == 'W'
  t2[n-i-1] = t2[n-i] + s[n-i] == 'E'
ans = n
for i in range(n):
  ans = min(ans, t1[i] + t2[i])
print(ans)
Problem p03370 (python)

Fixed submission:
n, x = map(int,input().split())
m = [int(input()) for i in range(n)]
print(n + (x - sum(m)) // min(m))

Buggy submission (verdict: Runtime Error):
n, x = map(int,input())
m = [int(input()) for i in range(n)]
print(n + (x - sum(m)) // min(m))
Problem p03380 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans1 = max(a)
diff = min(ans1//2, ans1//2 + 1)
ans2 = ans1
for x in a:
  if x == ans1:
    continue
  d = min(abs(ans1//2 - x), abs(ans1//2 + 1 - x))
  if d <= diff:
    diff = d
    ans2 = x
print('{} {}'.format(ans1, ans2))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans1 = max(a)
diff = min(ans1//2, ans1//2 + 1)
ans2 = ans1
for x in a:
  if x == ans1:
      continue
  d = min(abs(ans1//2 - x), abs(ans1//2 + 1 - x))
  if d <= diff:
    diff = d
    ans2 = x
print('{} {}'.format(ans1, ans2)
Problem p03425 (python)

Fixed submission:
n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += count[i] * count[j] * count[k]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = [0]*5
d = {'M': 0, 'A': 1, 'R': 2, 'C':3, 'H': 4}

for i in range(n):
  s = input()
  if s[0] in 'MARCH':
    count[d[s[0]]] += 1

ans = 0
for i in range(5):
  for j in range(i+1, 5):
    for k in range(j+1, 5):
      ans += count[i] * count[j] * count[k]]
print(ans)
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())
if a >= n % 500:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
if n % 500 =< a:
  print('Yes')
else:
  print('No')
Problem p03436 (python)

Fixed submission:
h,w = map(int,input().split())
s = [input() for i in range(h)]
cost = [[2500] * w for i in range(h)]
cost[0][0] = 1
wall = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      wall += 1
for k in range(h*w):
  for i in range(h):
    for j in range(w):
      if s[i][j] != '#':
        u = cost[i-1][j] + 1 if i > 0 and s[i-1][j] != '#' else 2500
        d = cost[i+1][j] + 1 if i < h-1 and s[i+1][j] != '#' else 2500
        l = cost[i][j-1] + 1 if j > 0 and s[i][j-1] != '#' else 2500
        r = cost[i][j+1] + 1 if j < w-1 and s[i][j+1] != '#' else 2500
        cost[i][j] = min(cost[i][j], u, d, l, r)

if cost[h-1][w-1] == 2500:
  print(-1)
else:
  print(h*w - cost[h-1][w-1] - wall)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = []
for i in range(h):
  s += [list(map(int,input().split()))]
cost = [[2500] * w for i in range(h)]
cost[0][0] = 1
wall = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      wall += 1
for k in range(h*w):
  for i in range(h):
    for j in range(w):
      if s[i][j] != '#':
        u = cost[i-1][j] + 1 if i > 0 and s[i-1][j] != '#' else 2500
        d = cost[i+1][j] + 1 if i < n-1 and s[i+1][j] != '#' else 2500
        l = cost[i][j-1] + 1 if j > 0 and s[i][j-1] != '#' else 2500
        r = cost[i][j+1] + 1 if j < n-1 and s[i][j+1] != '#' else 2500
        cost[i][j] = min(cost[i][j], u, d, l, r)

if cost[h-1][w-1] == 2500:
  print(-1)
else:
  print(h*w - cost[h-1][w-1] - wall)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = []
for i in range(h):
  s += [list(map(int,input().split()))]
cost = [[2500] * w for i in range(h)]
cost[0][0] = 1
wall = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      wall += 1
for k in range(h*w):
  for i in range(h):
    for j in range(w):
      if s[i][j] != '#':
        u = cost[i-1][j] + 1 if i > 0 and s[i-1][j] != '#' else 2500
        d = cost[i+1][j] + 1 if i < n and s[i+1][j] != '#' else 2500
        l = cost[i][j-1] + 1 if j > 0 and s[i][j-1] != '#' else 2500
        r = cost[i][j+1] + 1 if j < n and s[i][j+1] != '#' else 2500
        cost[i][j] = min(cost[i][j], u, d, l, r)

if cost[h-1][w-1] == 2500:
  print(-1)
else:
  print(h*w - cost[h-1][w-1] - wall)
Problem p03470 (python)

Fixed submission:
n = int(input())
a = sorted([int(input()) for i in range(n)])

pre = a[0]
ans = 1
for i in range(1,n):
  if pre < a[i]:
    ans += 1
  pre = a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(input()) for i in range(n)])

pre = a[0]
ans = 1
for i in range(1,n):
  if pre < a[n]:
    ans += 1
  pre = a[i]
print(ans)