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

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

c = 1; w = 0
for i in range(N-1):
    if w == 0:
        if A[i] < A[i+1]:
            w = 1
        elif A[i] > A[i+1]:
            w = -1
    elif (w > 0 and A[i] > A[i+1]) or (w < 0 and A[i] < A[i+1]):
         w = 0
         c += 1

print(c)

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

a=A[0]; c=1; i=1; w=0
def f(x):
    return A[x], x+1

while True:
    if w==0:
        if A[i]==a:
            a,i=f(i)
        elif A[i] > a:
            w=1; a,i=f(i)
        else:
            w=-1; f(i)
    elif w>0:
        if A[i]>=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(i); w=0
    elif w<0:
        if A[i]<=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(i); w=0
    if i==N:
        break

print(c)

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

a=A[0]; c=1; i=1; w=0
def f(x):
    return A[x], x+1

while True:
    if w==0:
        if A[i]==a:
            a,i=f(i)
        elif A[i] > a:
            w=1; a,i=f(i)
        else:
            w=-1; f(i)
    elif w>0:
        if A[i]>=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(i); w=0
    elif w<0:
        if A[i]<=a:
            a,i=f(i)
        else:
            c+=1; a,i=f(); w=0
    if i==N:
        break

print(c)
Problem p03835 (python)

Fixed submission:
K, S = map(int, input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        z = S - (x+y)
        if (z <= K) & (z >= 0):
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
        if x+y+z == S:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
K, S = map(int, input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1)
        if x+y+z == S:
            count += 1
print(count)
Problem p03242 (python)

Fixed submission:
n = input()
print(''.join(map(lambda c: '9' if c == '1' else '1' if c == '9' else c, n)))

Buggy submission (verdict: Runtime Error):
n = input()
print(''.join(map(lambda c: '9' if c == '1' else '1' if c == '9' else c, n))
Problem p03774 (python)

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

ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))

cd = []
for i in range(M):
    cd.append(list(map(int, input().split())))

for ab_list in ab:
    min_distance = 400000000
    checkpoint = 0
    for cd_list in cd:
        checkpoint += 1
        distance = abs(ab_list[0] - cd_list[0]) + abs(ab_list[1] - cd_list[1])
        if distance < min_distance:
            min_distance = distance
            ans = checkpoint
    print(ans)

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

ab = []
for i in range(N):
    ab.append(list(map(int, input().split())))

cd = []
for i in range(M):
    cd.append(list(map(int, input().split())))

for ab_list in ab:
    min_distance = 200000000
    checkpoint = 0
    for cd_list in cd:
        checkpoint += 1
        distance = abs(ab_list[0] - cd_list[0]) + abs(ab_list[1] - cd_list[1])
        if distance < min_distance:
            min_distance = distance
            ans = checkpoint
    print(ans)
Problem p03775 (python)

Fixed submission:
import math

N = int(input())

for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i == 0:
        factor1 = N / i
        factor2 = i

factor1 = int(factor1)

if factor1 < factor2:
    print(len(str(factor2)))
else:
    print(len(str(factor1)))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

for i in range(1, math.floor(math.sqrt(N))):
    if N % i == 0:
        factor = N / i

factor = int(factor)
print(len(str(factor)))
Problem p03803 (python)

Fixed submission:
cards = input().split()
alice = int(cards[0])
bob = int(cards[1])

if alice == bob:
    print("Draw")
elif alice == 1:
    print("Alice")
elif bob == 1:
    print("Bob")
elif alice < bob:
    print("Bob")
else :
    print("Alice")

Buggy submission (verdict: Runtime Error):
import re

first_line = input().split()
n = int(first_line[0])
m = int(first_line[1])

n_list = []
for i in range(n):
    n_list.append(input())
m_list = []
for i in range(m):
    m_list.append(input())

match_flg = False
for i in range(0, n - m + 1):
    matchOb = re.match(m_list[0], n_list[i])
    if matchOb:
        start_pos = matchOb.start()
        end_pos = matchOb.end()
        for j in range(0, m):
            if n_list[i + j][start_pos:end_pos] == m_list[j] and j == m - 1:
                match_flg = True
            elif n_list[i + j][start_pos:end_pos] != m_list[j]:
                break

if match_flg:
    print("Yes")
else:
    print("No")
Problem p03774 (python)

Fixed submission:
# https://beta.atcoder.jp/contests/abc057/tasks/abc057_b
class Point(object):
    def __init__(self, x, y):
        self.x = int(x)
        self.y = int(y)

    @staticmethod
    def manhattan(p1, p2):
        return abs(p1.x - p2.x) + abs(p1.y - p2.y)

def solve():
    # Max(n, m) = (50, 50) => 50 * 2
    n, m = map(int, input().split())
    students = []
    for _ in range(n):
        students.append(Point(*input().split()))

    checkpoints = []
    for _ in range(m):
        checkpoints.append(Point(*input().split()))

    for student in students:
        min_dist = 4 * (10 ** 8)
        min_index = 1
        for index, cp in enumerate(checkpoints):
            manhattan = Point.manhattan(student, cp)
            if min_dist > manhattan:
                min_dist = manhattan
                min_index = index + 1
        print(min_index)


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
# https://beta.atcoder.jp/contests/abc057/tasks/abc057_b


class Point(object):
    def __init__(self, x, y):
        self.x = int(x)
        self.y = int(y)

    @staticmethod
    def manhattan(p1, p2):
        return abs(p1.x - p2.x) + abs(p1.y - p2.y)

    def __str__(self):
        return f'(x, y) = ({self.x}, {self.y})'


def solve():
    # Max(n, m) = (50, 50) => 50 * 2
    n, m = map(int, input().split())
    students = []
    for _ in range(n):
        students.append(Point(*input().split()))

    checkpoints = []
    for _ in range(m):
        checkpoints.append(Point(*input().split()))

    for student in students:
        min_dist = 4 * (10 ** 8)
        min_index = 1
        for index, cp in enumerate(checkpoints):
            manhattan = Point.manhattan(student, cp)
            if min_dist > manhattan:
                min_dist = manhattan
                min_index = index + 1
        print(min_index)


if __name__ == '__main__':
    solve()
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
p = [[] for i in range(M)]
counter = [0] * N
ans = [""] * M

for i in range(M):
    k, y = map(int, input().split())
    p[i] = [k, y, i]

p.sort(key=lambda x:x[1])
for k, y, i in p:
    counter[k-1] += 1
    ans[i] = "{:06d}{:06d}".format(k, counter[k-1])

for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = list()
d = dict()
for i in range(M):
    inp = map(int, input().split())
    p.append(inp)
    if inp[0] in d:
        d[inp[0]].append(inp[1])
    else:
        d[inp[0]] = [inp[1]]
for i in d:
    d[i].sort()
for i, j in p:
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = list()
y = list()
d = dict()
for i in range(N):
    inp_p, inp_y = map(int, input().split())
    p.append(inp_p)
    y.append(inp_y)
    if p in d:
        d[p].append(y)
    else:
        d[p] = [y]
for i in d:
    d[i] = sorted(d[i])
for i, j in zip(p, y):
    print("{:06d}{:06d}".format(i, d[i].index(j)+1))
Problem p03221 (python)

Fixed submission:
N,M = map(int,input().split())

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*N
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = [0]*M
Y = [0]*M

for i in range(M):
    P[i],Y[i] = map(int,input().split())

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = [0]*M
Y = [0]*M

for i in range(M):
    p[i],y[i] = map(int,input().split())

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    if d < 0:
        print(0)
        exit()
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = Y[i]*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = (Y[i]-1)*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d] - 1

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))

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

P = []
Y = []

for i in range(M):
    p,y = map(int,input().split())
    P.append(p)
    Y.append(y)

A = [0]*M
C = [0]*M

B = [0]*M
for i in range(M):
    B[i] = (Y[i]-1)*100000+i

B.sort()

for i in range(M):
    d = B[i] % 100000
    b = B[i] // 100000
    k = P[d]

    C[d] = A[k]
    A[k] += 1

for i in range(M):
    print('%06d%06d' % (P[i],C[i]+1))
Problem p03804 (python)

Fixed submission:
import sys
def main():
    t = sys.stdin.readline()
    t1 = t.rstrip()
    t2 = t1.split(' ')
    stra = [] 
    for i in range(int(t2[0])):
        y = sys.stdin.readline()
        t = y.rstrip()
        stra += [t]
    strb = [] 
    for i in range(int(t2[1])):
        y = sys.stdin.readline()
        t = y.rstrip()
        strb += [t]
 
    suma = 0
    for x in strb:
        for y in stra:
            if x in y:
                suma +=1 
    if int(t2[0])*int(t2[1])==suma:
        print("Yes")
    else:
        print("No")
main()

Buggy submission (verdict: Runtime Error):
import io
sys.stdin = io.StringIO("""3 2
#.#
.#.
#.#
#.
.#
""")
import sys
def main():
    t = sys.stdin.readline()
    t1 = t.rstrip()
    t2 = t1.split(' ')
    stra = [] 
    for i in range(int(t2[0])):
        y = sys.stdin.readline()
        t = y.rstrip()
        stra += [t]
    strb = [] 
    for i in range(int(t2[1])):
        y = sys.stdin.readline()
        t = y.rstrip()
        strb += [t]

    suma = 0
    for x in strb:
        for y in stra:
            print(x,y)
            if x in y:
                suma +=1 
    if int(t2[0])*int(t2[1])==suma:
        print("yes")
    
    print(stra,strb)
main()
Problem p03250 (python)

Fixed submission:
# -*- coding: utf-8 -*-
list1 = list(map(int, input().split()))
list1.sort()
print(10*list1[2]+list1[1]+list1[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,m,x,y = map(int,input().split())
xi = list(map(int,input().split()))
yi = list(map(int,input().split()))

xi.append(x)
yi.append(y)

xi.sort()
xi.reverse()
yi.sort()

if xi[0]<yi[0]:
    print("No War")
else:
    print("War")
Problem p03327 (python)

Fixed submission:
s = int(input())
if s>999:
     print("ABD")
else:
  print("ABC")

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

t = 0
pt = 0
for i in range(1000):
    t += i
    if a < pt and b < t:
        if (pt-a) == (t-b):
            print(pt-a)
            break
    pt = t

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

t = 0
pt =0

for I in range(1000):
     t+=1
     if (pt < a and  b < t ):
              if( pt-a==t-b ):
                    print(pt-a)
                    break
     pt+=1
Problem p03242 (python)

Fixed submission:
n = str(input())

result = n.replace('1', '2').replace('9','1').replace('2','9')

print(result)

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

result = n.replace('1', '2').replace('9','1').replace('2','9')

return result
Problem p03315 (python)

Fixed submission:
#coding:utf-8
s = input()
a = 0
for c in s:
  a = a + 1 if c == "+" else a - 1
print(a)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
s = input()
a = 0
for c in s:
  a = a + 1 if c == "+" else a = a - 1
print(a)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
s = input()
a = 0
for c in s:
  a = a + 1 if c = "+" else a = a - 1
print(a)
Problem p03221 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Describe
"""
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    # print(data)
    data_sorted = sorted(data, key=itemgetter(0, 1))
    # print(data_sorted)

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data_sorted:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, code])
        p_prev = p
    # print(codes)

    codes_sorted = sorted(codes, key=itemgetter(0))
    # print(codes_sorted)

    for i, code in codes_sorted:
        print(code)
        
main()

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    data = []
    for i in range(m):
        p, y = map(int, input().split())
        data.append([p, y, i])
    data_sorted = sorted(data, key=itemgetter(0, 1))

    p, y, i = 0, 0, 0
    p_prev = 0 
    x = 1 # initialize
    codes = []
    for p, y, i in data:
        # initialize if new prefecture, increment if not
        if p != p_prev:
            x = 1
        else:
            x += 1
        code = '{:06d}{:06d}'.format(p, x)
        codes.append([i, codes])
        p_prev = p

    for i, code in sorted(codes, key=itemgetter(0)):
        print code
        
main()
Problem p03252 (python)

Fixed submission:
from collections import defaultdict, Counter

S = input()
T = input()

d_s = defaultdict(int)
d_t = defaultdict(int)

no_flag = False
for s, t in zip(list(S), list(T)):
    d_s[s] += 1
    d_t[t] += 1

if sorted(d_s.values()) == sorted(d_t.values()):
    print("Yes")
else:
    print("No")

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

S = input()
T = input()

d = defaultdict(str)

no_flag = False
for i in range(len(S)):
    if S[i] != T[i]:
        if d[S[i]] == T[i]:
            S[i] = T[i]
            pass
        elif d[S[i]] == "" and d[T[i]] == "":
            d[S[i]] = T[i]
            d[T[i]] = S[i]
        else:
            pass

S = sorted(S)
T = sorted(T)
if S == T:
    print("Yes")
else:
    print("No")
Problem p03295 (python)

Fixed submission:
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# ABC103-D

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ab.sort(key=lambda x: x[1])

ans = 1
bridge = ab[0][1] - 1

for pair in ab:
    if bridge < pair[0]:
        bridge = pair[1] - 1
        ans += 1

print(ans)
Problem p03326 (python)

Fixed submission:
def plus(l1, l2):
    return [x + y for (x, y) in zip(l1, l2)]


# 整数の入力
N, M = list(map(int, input().split(" ")))

cake_list = []
for n in range(N):
    cake_list.append(list(map(int, input().split(" "))))


# 正の値、負の値で8パターン考えれば良い。
plus_minus_list = [[1, 1, 1], [1, 1, -1], [1, -1, 1], [-1, 1, 1],
                   [1, -1, -1], [-1, 1, -1], [-1, -1, 1], [-1, -1, -1]]


pattern_sum_list = []
for pattern in plus_minus_list:
    pattern_sum = 0
    cake_num_list = []
    for cake in cake_list:
        cake_num = cake[0]*pattern[0]+cake[1]*pattern[1]+cake[2]*pattern[2]
        cake_num_list.append(cake_num)

    cake_num_list = sorted(cake_num_list)[::-1]
    pattern_sum_list.append(sum(cake_num_list[:M]))

print(max(pattern_sum_list))

Buggy submission (verdict: Runtime Error):
def combinationListRecursive(data, r):
  if r == 0 or r > len(data):
    return []

  result = []
  _combinationListRecursive(data, r, 0, [], result)
  return result


def _combinationListRecursive(data, r, start, progress, result):
  if r == 0:
    result.append(progress)
    return

  for i in range(start, len(data)):
    _combinationListRecursive(data, r - 1, i + 1, progress + [data[i]], result)

def plus(l1, l2):
    return [x + y for (x, y) in zip(l1, l2)]


# 整数の入力
N, M = list(map(int, input().split(" ")))

l = []
for n in range(N):
    l.append(list(map(int, input().split(" "))))

ind_list = list(range(N))

if M == 0:
    print(0)

else:
    # NからMを選ぶ
    comb_list = combinationListRecursive(ind_list, M)
    # print(comb_list)

    max_kachi = 0
    for comb in comb_list:
        l_ = [0, 0, 0]
        for i in comb:
            l_ = plus(l_, l[i])

        kachi = abs(l_[0]) + abs(l_[1]) + abs(l_[2])
        max_kachi = max(max_kachi, kachi)

    print(max_kachi)
Problem p03346 (python)

Fixed submission:
N = int(input())

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
ind_list = [0] * N

for i, k in enumerate(l):
    ind_list[k-1] = i

count = 1
for i in range(N):
    if i == N - 1:
        count_l.append(count)
    else:
        if ind_list[i] < ind_list[i+1]:
            count += 1
        else:
            count_l.append(count)
            count = 1

print(N - max(count_l))

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

l = list(range(N))

for n in range(N):
    l[n] = int(input())

# print(l)

count_l = []
count = 1

st_ind = l.index(1)
num = 2

while num <= N:
    next_ind = l.index(num)
    if st_ind < next_ind:
        count += 1
    else:
        count_l.append(count)
        count = 1

    st_ind = next_ind
    num += 1

print(N - max(count_l))
Problem p03805 (python)

Fixed submission:
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1#隣接グラフを作成
visited=[0]*n#どこを通ったか記憶
visited[0]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(n):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(n):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[i]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(dfs(0,visited,n))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
path=[[[0]*n]*n]
for i in range(m):
    a,b=map(int,input().split())
    path[a][b]=1
    path[b][a]=1#隣接グラフを作成
visited=[[0]*n]#どこを通ったか記憶
visited[0]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(n):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(n):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[i]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(0,n,visited)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
path=[[[0]*(n+1)]*(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    path[a][b]=1
    path[b][a]=1#隣接グラフを作成
visited=[[0]*(n+1)]#どこを通ったか記憶
visited[1]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(1,n+1):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(1,n+1):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[i]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(1,n,visited)

Buggy submission (verdict: Runtime Error):
def dfs(v,n,visited):#深さ優先探索
    all_visited=1#全ての点を通ったか調べる
      
    for i in range(n):
        if visited[i]==0:
            all_visited=0
    if all_visited==1:
        return 1
    count=0
    for i in range(n):
        if path[v][i]!=0:
            continue 
        if visited[i]==1:
            continue
        visited[i]=1
        count+=dfs(i,n,visited)
        visited[i]=0
    return count

n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1#隣接していれば１
visited=[0]*n
visited[0]=1#1は初めに通る
print(dfs(0,n,visited))
Problem p03775 (python)

Fixed submission:
import math

N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, math.ceil(math.sqrt(N+1))):
    if N % i == 0: elements.append(i)

a = elements[-1]
b = N // a
print(F(a,b))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

def F(a, b):
    a = len(str(a))
    b = len(str(b))
    if a > b:
        return a
    elif a < b:
        return b
    else:
        return b

elements = []

for i in range(1, math.floor(math.sqrt(N+1))):
    if N % i == 0: elements.append(i)

a = elements[-1]
b = N // a
print(F(a,b))
Problem p03835 (python)

Fixed submission:
K,S=map(int,input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y and S-X-Y<=K:
      cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
K,S=map(int,input().split())
cnt=0
for X in range(K+1):
  for Y in range(K+1):
    if 0<=S-X-Y and S-X-Y <= k:
      cnt+=1
print(cnt)
Problem p03631 (python)

Fixed submission:
number = input()
if number[0] == number[2]:
  print("Yes")
else:
  print("No")

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

if a == c:
  print("Yes")
else:
  print("No")