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

Fixed submission:
h, w = map(int, input().split())
s = [input() for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      d = set()
      if i>0:
        d.add(s[i-1][j])
      if i<h-1:
        d.add(s[i+1][j])
      if j>0:
        d.add(s[i][j-1])
      if j<w-1:
        d.add(s[i][j+1])
      if "#" not in d:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [input() for i in range(n)]
for i in range(h):
  for j in range(w):
    if s[i][j] = "#":
      d = set()
      if i>0:
        d.add(s[i-1][j])
      if i<h-1:
        d.add(s[i+1][j])
      if j>0:
        d.add(s[i][j-1])
      if j<w-1:
        d.add(s[i][j+1])
      if "#" not in d:
        print("No")
        exit()
print("Yes")
Problem p03385 (python)

Fixed submission:
s = input()
if s.count("a") == 1 and s.count("b") == 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input
if s.count("a") == 1 and s.count("b") == 1:
  print("Yes")
else:
  print("No")
s = input

Buggy submission (verdict: Runtime Error):
s = input
if s.count("a") == 1 ans s.count("b") == 1:
  print("Yes")
else:
  print("No")
Problem p03388 (python)

Fixed submission:
def check(a, b):
  if b < a:
    a, b = b, a
  if b - a <= 1:
    return 2 * a - 2
  d = a * b
  c, ng = a, b
  while ng - c > 1:
    mid = (ng + c) // 2
    if mid ** 2 < d:
      c = mid
    else:
      ng = mid
  return 2 * c - 1 - (c * (c + 1) >= a * b)

for _ in range(int(input())):
  print(check(*list(map(int, input().split()))))

Buggy submission (verdict: Runtime Error):
def check(a, b):
  if b < a:
    a, b = b, a
  if b - a <= 1:
    return 2 * a - 2
  c = int((a * b - 1)**.5)
  assert(c**2 < a * b <= (c + 1)**2)
  return 2 * c - 1 - (c * (c + 1) >= a * b)

for _ in range(int(input())):
  print(check(*list(map(int, input().split()))))
Problem p03391 (python)

Fixed submission:
n,*l = map(int,open(0).read().split())
a = l[::2]
b = l[1::2]
print(0 if a==b else sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))

Buggy submission (verdict: Runtime Error):
n,*l = map(int,open(0).read().split())
a = l[::2]
b = l[1::2]
print(sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))
Problem p03394 (python)

Fixed submission:
n = int(input())
l = [{}, {}, {}, {2, 5, 63}, {2, 5, 20, 63}, {2, 3, 4, 6, 9}]
if n <= 5:
  print(*l[n])
  exit(0)
l = [2, 3, 4, 6]
s = set()
for i in range(n):
  s.add(l[i%4] + 6*(i//4))
if sum(s) % 6 == 2:
  s.remove(8)
  s.add(30000)
if sum(s) % 6 == 3:
  s.remove(9)
  s.add(30000)
if sum(s) % 6 == 5:
  s.remove(9)
  s.add(29998)
print(*s)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [{}, {}, {}, {2, 5, 63}, {2, 5, 20, 63}, {2, 3, 4, 6, 9}]
if n <= 5:
  print(*l[n])
l = [2, 3, 4, 6]
s = set()
for i in range(n):
  s.add(l[i%4] + 6*(i//4))
if sum(s) % 6 == 2:
  s.remove(8)
  s.add(30000)
if sum(s) % 6 == 3:
  s.remove(9)
  s.add(30000)
if sum(s) % 6 == 5:
  s.remove(9)
  s.add(29998)
print(*s)
Problem p03399 (python)

Fixed submission:
a, b, c, d = [int(input()) for i in range(4)]
print(min(a, b)+min(c, d))

Buggy submission (verdict: Runtime Error):
a, b, c, d =map(int, input().split())
print(min(a, b)+min(c, d))
Problem p03424 (python)

Fixed submission:
n = int(input())
s = input().split()
if "Y" in s:
  print("Four")
else:
  print("Three")

Buggy submission (verdict: Runtime Error):
n = int(input)
s = input().split()
if "Y" in s:
  print("Four")
else:
  print("Three")
Problem p03428 (python)

Fixed submission:
import math

def norm(p, q): # normal vector: (p -> q) * -1j
    return (q[1] - p[1], p[0] - q[0])

def magnitude(a):
    return (a[0]**2 + a[1]**2)**.5

def dot(p, q):
    return p[0]*q[0] + p[1]*q[1]

def angle(p, q):
    return math.acos(dot(p, q) / (magnitude(p) * magnitude(q)))

def cross(a, b, c):
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])

def convex_hull(ps):
    ps = sorted(ps)
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs) > 1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n - 2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n)]
ch = convex_hull(s)
ch.pop()
m = len(ch)
d = dict()
for i in range(m):
  u = angle(norm(ch[i-1], ch[i]), norm(ch[i], ch[(i+1)%m]))
  d[ch[i]] = u / 2 / math.pi
for t in s:
  print(0.0 if t not in d else d[t])

Buggy submission (verdict: Runtime Error):
import math

def norm(p, q): # normal vector: (p -> q) * -1j
    return (q[1] - p[1], p[0] - q[1])

def magnitude(a):
    return (a[0]**2 + a[1]**2)**.5

def dot(p, q):
    return p[0]*q[0] + p[1]*q[1]

def angle(p, q):
    return math.acos(dot(p, q) / (magnitude(p) * magnitude(q)))

def cross(a, b, c):
    return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])

def convex_hull(ps):
    ps = sorted(ps)
    qs = []
    n = len(ps)
    for p in ps:
        while len(qs) > 1 and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    t = len(qs)
    for i in range(n - 2, -1, -1):
        p = ps[i]
        while len(qs) > t and cross(qs[-1], qs[-2], p) > 0:
            qs.pop()
        qs.append(p)
    return qs

n = int(input())
s = [tuple(map(int, input().split())) for _ in range(n)]
ch = convex_hull(s)
ch.pop()
m = len(ch)
d = dict()
for i in range(m):
  u = angle(norm(ch[i-1], ch[i]), norm(ch[i], ch[(i+1)%m]))
  d[ch[i]] = u / 2 / math.pi
for t in s:
  print(0.0 if t not in d else d[t])
Problem p03450 (python)

Fixed submission:
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  q = [(v,p)]
  while q:
    cv,cp = q.pop()
    if pos[cv] != None:
      continue
    pos[cv] = cp
    for i,d in l[cv]:
      if pos[i] == None:
        q.append((i,cp+d))
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  pos[v] = p
  for i,d in l[v]:
    if pos[i] == None:
      dfs(i,p+d,pos)
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  pos[v] = p
  for i,d in l[v]:
    if pos[i] == None:
      dfs(i,p+d,pos)
  return

for i in range(1,n+1):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = dict()
tl = []
for i in range(n+1):
  l[i] = []
for _ in range(m):
  a,b,c = map(int,input().split())
  l[a].append((b,c))
  l[b].append((a,-c))
  tl.append((a,b,c))
pos = [None]*(n+1)

def dfs(v,p,pos):
  pos[v] = p
  for i,d in l[v]:
    if pos[i] == None:
      dfs(i,p+d,pos)
  return

for i in range(1,n):
  if pos[i] == None:
    dfs(i,0,pos)
for a,b,c in tl:
  if pos[b] - pos[a] != c:
    print("No")
    break
else:
  print("Yes")
Problem p03469 (python)

Fixed submission:
s = list(input())
s[3] = '8'
print(''.join(s))

Buggy submission (verdict: Runtime Error):
s = list(input())
s[3] = 8
print(''.join(s))
Problem p03472 (python)

Fixed submission:
throw = []
blow = 0
cnt = 0
n,h = map(int, input().split())
for _ in range(n):
  a,b = map(int, input().split())
  blow = max(blow,a)
  throw.append(b)
throw.sort()
while h>0 and throw and throw[-1]>blow:
  h -= throw.pop()
  cnt += 1
if h > 0:
  cnt += h//blow + (h%blow>0)
print(cnt)

Buggy submission (verdict: Runtime Error):
throw = []
blow = 0
cnt = 0
n,h = map(int, input().split())
for _ in range(n):
  a,b = map(int, input().split())
  blow = max(blow,a)
  throw.append(b)
throw.sort()
while h and throw[-1]>blow:
  h -= throw.pop()
  cnt += 1
if h > 0:
  cnt += h//blow + (h%blow>0)
print(cnt)
Problem p03474 (python)

Fixed submission:
a, b = map(int, input().split())
s = input().split('-')
if len(s[0]) == a and len(s[1]) == b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = input().split(-)
if len(s[0]) == a and len(s[1]) == b:
  print("Yes")
else:
  print("No")
Problem p03477 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
if a+b == c+d:
  print("Balanced")
elif a+b > c+d:
  print("Left")
else:
  print("Right")

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print(max(1+int(math.log2(b//a)), 0))
Problem p03479 (python)

Fixed submission:
a, b = map(int, input().split())
t = 0
while a <= b:
  a *= 2
  t += 1
print(t)

Buggy submission (verdict: Runtime Error):
import math
a b = map(int, input().split())
print(1+int(math.log2(b/a)))
Problem p03488 (python)

Fixed submission:
s = list(map(len,input().split("T")))
x = s[::2]
y = s[1::2]
gx,gy = map(int,input().split())
if sum(x) < abs(gx) or sum(y) < abs(gy):
  print("No")
  exit(0)
dpx = [0]*(len(x)+1)
dpy = [0]*(len(y)+1)
dpx[0] = set([0])
dpy[0] = set([0])
for i in range(1,len(x)+1):
  s1 = set([v + x[i-1] for v in dpx[i-1]])
  s2 = set([v - x[i-1] for v in dpx[i-1]])
  if i == 1:
    dpx[i] = s1
  else:
    dpx[i] = s1|s2
for i in range(1,len(y)+1):
  s1 = set([v + y[i-1] for v in dpy[i-1]])
  s2 = set([v - y[i-1] for v in dpy[i-1]])
  dpy[i] = s1|s2
if gx in dpx[-1] and gy in dpy[-1]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(map(len,input().split("T")))
x = s[::2]
y = s[1::2]
gx,gy = map(int,input().split())
if sum(x) < abs(gx) or sum(y) < abs(gy):
  print("No")
  exit(0)
dpx = [0]*(len(x)+1)
dpy = [0]*(len(y)+1)
dpx[1] = set(x[0])
dpy[0] = set([0])
for i in range(2,len(x)+1):
  s1 = set([v + x[i-1] for v in dpx[i-1]])
  s2 = set([v - x[i-1] for v in dpx[i-1]])
  dpx[i] = s1|s2
for i in range(1,len(y)+1):
  s1 = set([v + y[i-1] for v in dpy[i-1]])
  s2 = set([v - y[i-1] for v in dpy[i-1]])
  dpy[i] = s1|s2
if gx in dpx[-1] and gy in dpy[-1]:
  print("Yes")
else:
  print("No")
Problem p03544 (python)

Fixed submission:
def luca(n, a=1, b=2):
  if n <= 1:
    return a
  return luca(n-1, a+b, a)

a = int(input())
print(luca(a))

Buggy submission (verdict: Runtime Error):
def luca(n):
  if n == 2:
    return 1
  elif n == 1:
    return 2
  luca(n) = luca(n-1) + luca(n-2)
  return

print(luca(int(input()))

Buggy submission (verdict: Runtime Error):
def luca(n):
  if n == 2:
    return 1
  elif n == 1:
    return 2
  luca(n) = luca(n-1) + luca(n-2)
  return

print(luca(int(input()))
Problem p03547 (python)

Fixed submission:
s = list("ABCDEF")
x, y = input().split()
if s.index(x) > s.index(y):
  print(">")
elif s.index(x) < s.index(y):
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
s = list("abcdef")
x, y = input().split()
if s.index(x) > s.index(y):
  print(">")
elif s.index(x) < s.index(y):
  print("<")
else:
  print("=")

Buggy submission (verdict: Runtime Error):
s = list("abcdef")
x, y = input().split()
if s.index(x) > s.index(y):
  print(">")
elif s.index(x) < s.index(y):
  print("<")
else:
  print("=")
Problem p03555 (python)

Fixed submission:
f = list(input())
s = list(input())
for i in range(3):
  if f[i] != s[2-i]:
    print("NO")
    exit()
print("YES")

Buggy submission (verdict: Runtime Error):
f = list(input())
s = list(input())
for i in range(1,4):
  if f[i] != s[4-i]:
    print("NO")
    exit()
print("YES")
Problem p03557 (python)

Fixed submission:
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for x in b:
  ans += bisect.bisect_left(a,x)*(n-bisect.bisect_right(c,x))
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
  ans += bisect.bisect_left(a,x)*(n-bisect.bisect_right(c,x))
print(ans)
Problem p03569 (python)

Fixed submission:
from collections import deque
s = deque(input())
le = len(s)
cnt = 0
while le>1:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
print(s)
le = len(s)
cnt = 0
while le:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
  print(s)
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
le = len(s)-1
cnt = 0
while le:
  if s[0] == s[-1]:
    s.pop()
    s.popleft()
    le -= 2
  elif s[0] == "x":
    s.popleft()
    cnt += 1
    le -= 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
    le -= 1
  else:
    print(-1)
    break
else:
  print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
cnt = 0
while s:
  if s[0] == s[-1] == "x":
    s.pop()
    s.popleft()
  elif s[0] == "x":
    s.popleft()
    cnt += 1
  elif s[-1] == "x":
    s.pop()
    cnt += 1
  else:
    print(-1)
    break
else:
  print(cnt)
Problem p03575 (python)

Fixed submission:
from collections import defaultdict as dd
n,m = map(int, input().split())
dic = dd(list)
l = []
cnt = 0
for _ in range(m):
  a,b = map(int, input().split())
  l.append((a,b))
  dic[a].append(b)
  dic[b].append(a)
def con(x):
  visit.add(x)
  for i in dic[x]:
    if i in visit:
      continue
    con(i)
  return visit == set(range(1,n+1))
for x,y in l:
  dic[x].remove(y)
  dic[y].remove(x)
  visit = set()
  if not con(x):
    cnt += 1
  dic[x].append(y)
  dic[y].append(x)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict as dd
n,m = map(int, input().split())
dic = dd(list)
l = []
cnt = 0
for _ in range(m):
  a,b = map(int, input().split())
  l.append(a,b)
  dic[a].add(b)
  dic[b].add(a)
def con(x):
  visit.add(x)
  for i in [j for j in dic[x] if j not in visited]:
    con(i)
  return visit == set(range(1,n+1))
for x,y in l:
  dic[x].remove(y)
  dic[y].remove(x)
  visit = set()
  if not con(x):
    cnt += 1
  dic[x].add(y)
  dic[y].add(x)
print(cnt)
Problem p03576 (python)

Fixed submission:
from itertools import combinations as cc
l = []
n,k = map(int, input().split())
xs,ys = set(),set()
t = 10**24
for _ in range(n):
  x,y = map(int, input().split())
  xs.add(x)
  ys.add(y)
  l.append((x,y))
xs = sorted(list(xs))
ys = sorted(list(ys))
for xl,xr in cc(xs,2):
  for yl,yr in cc(ys,2):
    cnt = 0
    for x,y in l:
      if xl<=x<=xr and yl<=y<=yr:
        cnt += 1
      if cnt >= k:
        s = (xr-xl)*(yr-yl)
        if t > s:
          t = s
print(t)

Buggy submission (verdict: Runtime Error):
from itertools import combinations as cc
l = []
n,k = map(int, input().split())
xs,ys = set(),set()
t = 10**24
for _ in range(n):
  x,y = map(int, input().split())
  xs.add(x)
  ys.add(y)
  l.append((x,y))
xs = sorted(list(xs))
ys = sorted(list(ys))
for xl,xr in cc(xs,2):
  foe yl,yr in cc(ys,2):
    cnt = 0
    for x,y in l:
      if xl<=x<=xr and yl<=y<=yr:
        cnt += 1
      if cnt >= k:
        s = (xr-xl)*(yr-yl)
        if t > s:
          t = s
print(t)
Problem p03583 (python)

Fixed submission:
from itertools import product
n = int(input())
if n%2 == 0:
  print(n,n,n//2)
else:
  for h,l in product(range(max(2, n//4),3501),repeat=2):
    m = n*h*l
    c = 4*h*l - n*(h+l)
    if c > 0 and m%c == 0:
      w = m//c
      break
  print(h,l,w)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%2 == 0:
  print(n,n,n//2)
else:
  for h in range(2,3501):
    for l in range(2,3501):
      w =  n*h*l // (4*h*l - n*(h+l))
      if 4*h*l*w == n*(h*w+h*l+l*w):
        print(h,l,w)
        break

Buggy submission (verdict: Runtime Error):
from itertools import product
n = int(input())
if n%2 == 0:
  print(n,n,n//2)
else:
  for h,l in product(range(2,3501),repeat=2):
    m = n*h*l
    c = 4*h*l - n*(h+l)
    if c >= 0 and m%c == 0:
      w = m//c
      break
  print(h,l,w)
Problem p03588 (python)

Fixed submission:
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(reverse=True)
print(l[0][0]+l[0][1])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x:x[1])
print(x[0][0]+x[0][1])
Problem p03599 (python)

Fixed submission:
a,b,c,d,e,f = map(int, input().split())
ans = [-1,0,0]
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i*a+j*b
        s = k*c+l*d
        if w == 0:
          continue
        if w*e >= s and ans[0] < s/(w*100+s):
          ans = [s/(w*100+s),w*100+s,s]
print(ans[1],ans[2])

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f = map(int, input().split())
ans = 0
for i in range(f//(a*100)+1):
  for j in range((f-a*100*i)//(b*100)+1):
    for k in range((f-a*i*100-b*j*100)//c+1):
      for l in range((f-a*i*100-b*j*100-c*k)//d+1):
        w = i+j
        s = k+l
        if w*e >= k:
          ans = max(ans,s/(w*100+s))
print(ans)
Problem p03607 (python)

Fixed submission:
n = int(input())
a = [input() for i in range(n)]
d = {}
ans = 0
for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
for i in d.keys():
  if d[i] % 2 == 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [input() for i in range(n)]
b = []
for i in range(n):
  if a[i] in b:
    b.pop(a[i])
  else:
    b.append(a[i])
print(len(b))
Problem p03608 (python)

Fixed submission:
n,m,r = map(int,input().split())
l = list(map(int,input().split()))
g = [[10**10]*(n+1) for _ in range(n+1)]
for i in range(n+1):
  g[i][i] = 0
for _ in range(m):
  a,b,c = map(int,input().split())
  g[a][b] = c
  g[b][a] = c
for k in range(1,n+1):
  for i in range(1,n):
    for j in range(i+1,n+1):
      if g[i][j] >= g[i][k] + g[k][j]:
        g[i][j] = g[i][k] + g[k][j]
        g[j][i] = g[i][j]
g[0] = [0]*(n+1)
def dfs(cur,res,dis,use):
  if res == 0:
    return dis
  ans = 10**10
  for i in range(r):
    if not use[i]:
      use[i] = 1
      ans = min(ans, dfs(l[i],res-1,dis+g[cur][l[i]],use))
      use[i] = 0
  return ans
print(dfs(0,r,0,[0]*r))

Buggy submission (verdict: Runtime Error):
from itertools import permutations as per

n,m,r = map(int,input().split())
rlist = list(map(int,input().split()))
ans = 10**9
A = [[10**8]*n for _ in range(n)]
for _ in range(n):
  a,b,c = map(int,input().split())
  A[a-1][b-1] = c
  A[b-1][a-1] = c

for i in range(n-1):
  for j in range(i+1,n):
    for k in range(n):
      newd = A[i][k] + A[k][j]
      if A[i][j] > newd:
        A[i][j] = newd
        A[j][i] = newd
for x in per(rlist):
  cost = 0
  for i in range(r-1):
    cost += A[x[i]-1][x[i+1]-1]
  if cost < ans:
    ans = cost
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutation as per

n,m,r = map(int,input().split())
rlist = list(map(int,input().split()))
ans = 10**9
A = [[10**8]*n for _ in range(n)]
for _ in range(n):
  a,b,c = map(int,input().split())
  A[a-1][b-1] = c
  A[b-1][a-1] = c

for i in range(n-1):
  for j in range(i+1,n):
    for k in range(n):
      newd = A[i][k] + A[k][j]
      if A[i][j] > newd:
        A[i][j] = newd
        A[j][i] = newd
for x in per(rlist):
  cost = 0
  for i in range(r-1):
    cost += A[x[i]-1][x[i+1]-1]
  if cost < ans:
    ans = cost
print(ans)
Problem p03624 (python)

Fixed submission:
s = set(input())
on = set("abcdefghijklmnopqrstuvwxyz")
try:
  print(min(on-s))
except ValueError:
  print("None")

Buggy submission (verdict: Runtime Error):
s = set(input())
on = {a, b, c, d, e, f, g, h ,i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z}
if s == on:
  print("None")
print(min(on-s))
Problem p03628 (python)

Fixed submission:
n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7
b = 0
did = 0
ans = 0
if s1[0] == s2[0]:
  b = 1
  ans += 3
else:
  did = 1
  ans = 6
for i in range(1,n):
  if s1[i] == s2[i]:
    if b:
      ans = ans*2%mod
    b = 1
  elif not did:
    if b:
      ans = ans*2%mod
    else:
      ans = ans*3%mod
    did = 1
    b = 0
  else:
    did = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7
b = 0
2did = 0
ans = 0
if s1[0] == s2[0]:
  b = 1
  ans += 3
else:
  2did = 1
  ans = 6
for i in range(1,n):
  if s1[i] == s2[i]:
    if b:
      ans = ans*2%mod
    b = 1
  elif not 2did:
    if b:
      ans = ans*2%mod
    else:
      ans = ans*3%mod
    2did = 1
    b = 0
  else:
    2did = 0
print(ans)
Problem p03635 (python)

Fixed submission:
n, m = map(int, input().split())
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
d = {1:0, 2:0, 4:0}
for i in a:
  if i % 4 == 0:
    d[4] += 1
  elif i % 2 == 0:
    d[2] += 1
  else:
    d[1] += 1
if d.get(2, 0) >= 1:
  d[1] += 1
if d.get(1, 0) <= d.get(4, 0)+1:
  print("Yes")
else:
  print("No")
Problem p03638 (python)

Fixed submission:
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
s = []
l = []
for x in range(n):
  s += [x+1]*a[x]
for i in range(h):
  l.append(s[w*i:w*(i+1)])
  if i%2:
    l[i] = l[i][::-1]
for x in l:
  print(" ".join(map(str,x)))

Buggy submission (verdict: Runtime Error):
h,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
s = []
l = []
for x in range(n):
  s += [x+1]*a[x+1]
for i in range(h):
  l.append(s[w*i:w*(i+1)])
  if i%2:
    l[i] = l[i][::-1]
for x in l:
  print(" ".join(map(str,x)))
Problem p03659 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ans = float("inf")
for i in range(1,n):
  x = sum(s[:i])*2
  if ans > abs(x - s):
    ans = abs(x - s)
print(ans)
Problem p03672 (python)

Fixed submission:
s = list(input())
l = len(s) - 2
while s[:l//2] != s[l//2:l]:
    l -= 2
print(l)

Buggy submission (verdict: Runtime Error):
t = list(input())
del s [-2:]
a = 2
while s[:len(s)//2] != s[len(s)//2:]:
    s = s[:-2]
    a += 2
print(a)
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [0] + [int(input()) for i in range(n)]
c = a[1]
p = 1
while c > 2:
    d = a[c]
    a[c] = 0
    c = d
    p += 1

if c == 2:
    print(p)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
c = 0
p = 0
while True:
    c = a[c]
    p += 1
    if c == 1:
        print(p)
        exit()
    elif c == 0 and p > 1:
        print(-1)
        exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
c = 0
p = 0
while True:
    c = s[c]
    p += 1
    if c == 1:
        print(p)
        exit()
    elif c == 0 and p > 1:
        print(-1)
        exit()