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

Fixed submission:
def pdebut(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o>=0
	
def pfin(s):
	c = 0
	for o in s[::-1]:
		if o==')':
			c+=1
		else:c-=1
		if c<0: return False
	return c>=0
	
def valuer(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
	return o
	
n = int(input())
val = [0]*(n+1)
tab = []
debut = []
fin = []
milieu = []
for i in range(n):
	s = input()
	tab.append(s)
	if pdebut(s):
		debut+=[i]
	elif pfin(s):
		fin+=[i]
	else:
		val[i] = valuer(s)
		milieu+=[i]

def cle(x):
	return -x[1]		
couples = [[i,val[i]] for i in milieu]
couples.sort(key = cle)

S = "".join(tab[i] for i in debut)
S+="".join(tab[c[0]] for c in couples)
S+= "".join(tab[i] for i in fin)

# ~ print("debut",debut)
# ~ print("milieu",milieu)
# ~ print("fin",fin)

# ~ print(S)

def Bon(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o==0
print("Yes" if Bon(S) else "No")

Buggy submission (verdict: Runtime Error):
def pdebut(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o>=0
	
def pfin(s):
	c = 0
	for o in s[::-1]:
		if o==')':
			c+=1
		else:c-=1
		if c<0: return False
	return c>=0
	
def valuer(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
	return o
	
n = int(input())
val = [0]*(n+1)
tab = []
debut = []
fin = []
milieu = []
for i in range(n):
	s = input()
	tab.append(s)
	if pdebut(s):
		debut+=[i]
	elif pfin(s):
		fin+=[i]
	else:
		val[i] = valuer(s)
		milieu+=[i]

# ~ def cle(x):
	# ~ return -x[1]		
# ~ couples = [[i,val[i]] for i in milieu]
# ~ couples.sort(key = cle)

S = "".join(tab[i] for i in debut)
S+="".join(tab[c[0]] for c in couples)
S+= "".join(tab[i] for i in fin)

# ~ print("debut",debut)
# ~ print("milieu",milieu)
# ~ print("fin",fin)

# ~ print(S)

def Bon(s):
	o = 0
	for c in s:
		if c=='(':o+=1
		else: o-=1
		if o<0 : return False
	return o==0
print("Yes" if Bon(S) else "No")
Problem p02705 (python)

Fixed submission:
from math import pi
r = float(input())
print(r*2* pi)

Buggy submission (verdict: Runtime Error):
print("A" if input()isupper() else "a")
Problem p02760 (python)

Fixed submission:
t=[]
for i in range(3):
    t.append([int(i) for i in input().split()])
n = int(input())
lst = []
for i in range(n):lst+=[int(input())]
def ligne(i):
    for j in range(3):
        if not t[i][j] in lst:
            return False
    return True
def col(j):
    for i in range(3):
        if not t[i][j] in lst:
            return False
    return True
def diag1():
    for i in range(3):
        if not t[i][i] in lst:
            return False
    return True
def diag2():
    for i in range(3):
        if not t[2-i][i] in lst:
            return False
    return True
ans = False
for i in range(3):
    ans = ans or ligne(i)
    ans = ans or col(i)
ans  = ans or diag1() or diag2()
if ans :
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
t=[]
for i in range(3):
    t.append([int(i) for i in input().split()])
n = int(input())
lst = []
for i in range(n):lst+=[int(input())]
def ligne(i):
    for j in range(3):
        if not t[i][j] in lst:
            return False
    return True
def col(j):
    for i in range(3):
        if not t[i][j] in lst:
            retur False
    return True
def diag1():
    for i in range(3):
        if not t[i][i] in lst:
            return False
    return True
def diag2():
    for i in range(3):
        if not t[2-i][i] in lst:
            return False
    return True
ans = False
for i in range(3):
    ans = ans or ligne(i)
    ans = ans or col(i)
ans  = ans or diag1() or diag2()
if ans :
    print("Yes")
else:
    print("No")
Problem p02813 (python)

Fixed submission:
from math import *
from itertools import permutations
n = int(input())
p = list(permutations(list(range(1,n+1))))
a = tuple([int(i) for i in input().split()])
b = tuple([int(i)for i in input().split()])
print(abs(p.index(a) - p.index(b)))

Buggy submission (verdict: Runtime Error):
from math import *
from itertools import permutations
n = int(input())
p = list(permutations(list(range(1,n+1))))
a = (int(i) for i in input().split())
b = (int(i)for i in input().split())
print(abs(p.index(a) - p.index(b)))
Problem p02817 (python)

Fixed submission:
s,t = (i for i in input().split())
print(t+s)

Buggy submission (verdict: Runtime Error):
print(input()+input())
Problem p02910 (python)

Fixed submission:
s=input()
print("Yes" if all((i%2==0 and s[i] in "RUD") or (i%2!=0 and s[i] in "LUD") for i in range(len(s))) else "No")

Buggy submission (verdict: Runtime Error):
s = int(input())
print("Yes" if all((i%2==0 and s[i] in "RUD") or (i%2!=0 and s[i] in "LUD") for i in range(len(s))) else "No")

Buggy submission (verdict: Runtime Error):
s = input()
print("Yes" if all((i%2==0 and s[i] in "RUD") or (i%2!=0 and s[i] in "LUD")) for i in range(len(s)) else "No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if all((i%2==0 and s[i] in "RUD") or (i%2!=0 and s[i] in "LUD") for i in range(len(s)) else "No")

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if all((i%2==0 and s[i] in "RUD") or (i%!==0 and s[i] in "LUD)) else "No")
Problem p02911 (python)

Fixed submission:
n,k,q = (int(i) for i in input().split())
a = [k]*n
d = [0]*(n+1)
for i in range(q):
	x = int(input())-1
	d[0]-=1
	d[x]+=1
	d[x+1]-=1
a[0] += d[0]
for i in range(1,n):
	a[i] = a[i-1] + d[i]
for i in range(n):
	print("Yes" if a[i]>0 else "No")

Buggy submission (verdict: Runtime Error):
n, k, q = (int(i) for i in input().split())
a = [k]*n
d = [0] + [a[i]-a[i-1] for i in  range(1,n)]+[0]
for i in range(q):
  x = int(input())-1
  d[0]-=1
  d[x]+=1
  d[x+1]-=1
  d[n]+=1
a[0]+=d[0]
for i in range(1,n): a[i] = a[i-1]+d[i]
for i in range(n): printf("Yes" if a[i]>0 else "No")

Buggy submission (verdict: Runtime Error):
n,k,q = (int(i) for i in input().split())
a = [k]*n
d = [0] + [a[i]-a[i-1] for i in range(1,n)]
for i in range(q):
	x = int(input())-1
	d[0]-=1
	d[x]+=1
	d[x+1]-=1
a[0]+=d[0]
for i in range(1,n): a[i] = a[i-1]+d[i]
for i in range(n):print("Yes" if a[i]>0 else "No")
Problem p03305 (python)

Fixed submission:
import heapq
def dijkstra(s, neighbor):
	dist = [float('inf')] * N
	dist[s] = 0
	que = [(0, s)]
	heapq.heapify(que)
	while que:
		d, v = heapq.heappop(que)
		if d > dist[v]:
			continue
		for u, l in neighbor[v]:
			tmp_d = d + l
			if tmp_d < dist[u]:
				dist[u] = tmp_d
				heapq.heappush(que, (tmp_d, u))
	return dist
 
N, M, s, t = map(int, input().split())
yen = [[] for _ in range(N)]
snuuk = [[] for _ in range(N)]
for _ in range(M):
	u, v, a, b = map(int, input().split())
	yen[u-1].append((v-1, a))
	yen[v-1].append((u-1, a))
	snuuk[u-1].append((v-1, b))
	snuuk[v-1].append((u-1, b))
 
dist_s = dijkstra(s-1, yen)
dist_t = dijkstra(t-1, snuuk)
ans = [-1] * N
tmp = float('inf')
for i in range(N-1, -1, -1):
	if dist_s[i] + dist_t[i] < tmp:
		tmp = dist_s[i] + dist_t[i]
	ans[i] = 10 ** 15 - tmp
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
from queue import PriorityQueue as PQ
INF = float('inf')
def pcc(src):
	pq = PQ()
	global n
	dist = [INF]*(n+1)
	dist[src] = 0
	pq.put([0,src])
	while not pq.empty():
		d,u = pq.get()
		for w,v in adj[u]:
			if dist[v] > dist[u]+w:
				dist[v] = dist[u]+w
				pq.put([dist[v], v])
	return dist

n,m,src=(int(i) for i in input().split())
adj = {}
for i in range(n+1): adj[i] = []
for i in range(m):
	u,v,w = (int(i) for i in input().split())
	adj[u].append([w,v])
	adj[v].append([w,u])

dist = pcc(src)

for i in range(n):
	print(i,"\t",dist[i])
Problem p02761 (python)

Fixed submission:
N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
fd = N != 1
for d in v:
    if d == 'x':
        if fd:
            r.append('1')
        else:
            r.append('0')
    else:
        r.append(d)
    fd = False

rv = int("".join(r))

if len(str(rv))!=N:
    print(-1)
else:
    print("".join(r))

Buggy submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]
v = ['x' for n in range(N)]
e = False
for m in range(M):
    s, c = [int(i) for i in input().split()]
    if e:
        continue
    if v[s-1] != 'x' and v[s-1]!=str(c):
        e = True
    else:
        v[s-1] = str(c)

if e:
    print(-1)
    exit()

r = []
f = False
fd = True
for d in v:
    if d == 'x':
        if f:
            if fd:
                r.append('1')
            else:
                r.append('0')
    else:
        f = True
        r.append(d)
    fd = False

rv = int("".join(r))

if len(str(rv))!=N:
    print(-1)
else:
    print("".join(r))
Problem p02780 (python)

Fixed submission:
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{:.12f}'.format(M))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print(f'{M:.12f}')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print('{%.12f}'.format(M))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += (1 + p[i]) / 2

e = M
for i in range(n-k):
    e -= (1 + p[i]) / 2
    e += (1 + p[i+k]) / 2
    if e > M:
        M = e
print(f'{M:.12f}')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [int(x) for x in input().split()]

M = 0
for i in range(k):
    M += 1 + p[i] / 2

e = M
for i in range(n-k-1):
    e -= 1 + p[i] / 2
    e += 1 + p[i+k+1] / 2
    if e > M:
        M = e
print(f'{M:%.12f}')
Problem p03146 (python)

Fixed submission:
s = int(input())

def calc_next(x):
  if x % 2 == 0:
    return x // 2
  else:
    return 3 * x + 1

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[i] == a[n]:
      print(n+1)
      exit(0)
  n += 1

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

def calc_next(x):
  if x % 2 == 0:
    return x // 2
  else:
    return 3 * x + 1

a = [s]
n = 1

while True:
  a.append(calc_next(a[n-1]))
  for i in range(n):
    if a[k] == a[n]:
      print(n+1)
      exit(0)
  n += 1
Problem p03160 (python)

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

MAX_COST = 1001001001

cost_dp = [MAX_COST for _ in range(N)]

cost_dp[0] = 0

for i in range(N):
  if i == 0:
    continue
  elif i == 1:
    cost_dp[1] = cost_dp[0] + abs(h[1] - h[0])
  else:
    cost_dp[i] = min(cost_dp[i-1] + abs(h[i] - h[i-1]), cost_dp[i-2] + abs(h[i] - h[i-2]))

print(cost_dp[N-1])

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

MAX_COST = 1001001001

cost_dp = [MAX_COST for _ in range(N)]

cost_dp[0] = 0

for i in range(N):
  if i == 1:
    cost_dp[1] = cost_dp[0] + abs(h[1] - h[0])
  else:
    cost_dp[i] = min(cost_dp[i-1] + abs(h[i] - h[i-1]), cost_dp[i-2] + abs(h[i] - h[i-2]))

print(cost_dp[N-1])
Problem p03210 (python)

Fixed submission:
n = int(input())
if n == 3 or n == 5 or n == 7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 3 or n == 5 or n == 7:
  print(YES)
else:
  print(NO)
Problem p03304 (python)

Fixed submission:
n, m, d = map(int, input().split())
p = 1/n if d==0 else 2*(n-d)/n/n
ans = (m-1)*p
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, d = map(int, input().split())
p = 1/n if d==0 else p = 2*(n-d)/n/n
ans = (m-1)*p
print(ans)
Problem p03331 (python)

Fixed submission:
N = int(input())

ans = N
for A in range(1,N):
    B = N - A
    A_str = str(A)
    B_str = str(B)
    A_li = [int(A_str[i]) for i in range(len(A_str))]
    B_li = [int(B_str[i]) for i in range(len(B_str))]
    s = sum(A_li) + sum(B_li)
    if s < ans:
        ans = s

print(ans)

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

ans = N
for A in range(1,N):
    B = N - A
    A_str = str(A)
    B_str = str(B)
    A_li = [int(A_str[i]) for i in len(A_str)]
    B_li = [int(B_str[i]) for i in len(B_str)]
    s = sum(A_li) + sum(B_li)
    if s < ans:
        ans = s

print(ans)
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())

if abs(c-a) <= d:
  print("Yes")
  exit(0)
elif abs(a-b) <= d and abs(c-b) <= d:
  print("Yes")
  exit(0)
else:
  print("No")
  exit(0)

exit(0)

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

if abs(c-a) <= d:
  print "Yes"
  exit(0)
elif abs(a-b) <= d and abs(c-b) <= d:
  print "Yes"
  exit(0)
else:
  print "No"
  exit(0)

exit(0)
Problem p03416 (python)

Fixed submission:
A, B = map(int, input().split())
cnt = 0
for n in range(A,B+1):
  n_str = str(n)
  n_len = len(n_str)
  is_kaibun = True
  for i in range(n_len//2):
    if n_str[i] != n_str[n_len-1-i]:
      is_kaibun = False
  if is_kaibun is True:
    cnt += 1
print(cnt)

# if n_str[0] == n_str[4] and n_str[1] == n_str[3]:
#   cnt += 1

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
cnt = 0
for n in range(A,B+1):
  n_str = str(n)
  n_len = len(n)
  is_kaibun = True
  for i in range(n_len//2):
    if n_str[i] != n_str[n_len-1-i]:
      is_kaibun = False
  if is_kaibun is True:
    cnt += 1
print(cnt)

# if n_str[0] == n_str[4] and n_str[1] == n_str[3]:
#   cnt += 1
Problem p03435 (python)

Fixed submission:
C = []
for i in range(3):
	C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(3)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(3)]

for idx in range(2):
	if D_h[idx][0] != D_h[idx][1]:
		print("No")
		exit(0)
	elif D_h[idx][0] != D_h[idx][2]:
		print("No")
		exit(0)

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
		exit(0)
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
		exit(0)

print("Yes")

Buggy submission (verdict: Runtime Error):
C = []
C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(2)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(2)]

for idx in range(2):
	if D_h[0][idx] != D_h[1][idx]:
		print("No")
	elif D_h[0][idx] != D_h[2][idx]:
		print("No")

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
Problem p03450 (python)

Fixed submission:
import sys

N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Graph = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Graph[L].append((R, D))
	Graph[R].append((L,-D))

def determine(i):
	if P[i] is not None:
		return
	P[i] = 0
	stack = [i]
	while len(stack) != 0:
		I = stack.pop()
		for j, d in Graph[I]:
			if P[j] is None:
				P[j] = P[I] + d
				stack.append(j)

def check(i):
	for j, d in Graph[i]:
		if P[j] - P[i] != d:
			print("No")
			exit(0)

for i in range(1,N+1):
	determine(i)

for i in range(1,N+1):
	check(i)

print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Tree = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Tree[L].append((R, D))
	Tree[R].append((L,-D))

def process(i):
	global P, Tree
	obj = Tree[i]
	if P[i] is None:
		P[i] = 0
	if len(obj) != 0:
		for j, d in obj:
			if P[j] is None:
				P[j] = P[i] + d
				process(j)
			else:
				if P[j] - P[i] != d:
					print("No")
					exit(0)

for i in range(1,N+1):
	process(i)

print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Tree = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Tree[L].append((R, D))
	Tree[R].append((L,-D))

def process(i):
	global P, Tree
	obj = Tree[i]
	if P[i] is None:
		P[i] = 0
	if len(obj) != 0:
		for j, d in obj:
			if P[j] is None:
				P[j] = P[i] + d
				process(j)
			else:
				if P[j] - P[i] != d:
					print("No")
					exit(0)

for i in range(1,N+1):
	process(i)

print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Tree = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Tree[L].append((R, D))
	Tree[R].append((L,-D))

def process(i):
	global P, Tree
	obj = Tree[i]
	if len(obj) != 0:
		if P[i] is None:
			P[i] = 0
		for j, d in obj:
			if P[j] is None:
				P[j] = P[i] + d
				process(j)
			else:
				if P[j] - P[i] != d:
					print("No")
					exit(0)

for i in range(1,N+1):
	process(i)

print("Yes")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
P = [None for i in range(N+1)]
Tree = [list() for i in range(N+1)]
for index in range(M):
	L, R, D = (int(i) for i in input().split())
	Tree[L].append((R, D))
	Tree[R].append((L,-D))

def process(i):
	global P, Tree
	obj = Tree[i]
	if len(obj) != 0:
		if P[i] is None:
			P[i] = 0
		for j, d in obj:
			if P[j] is None:
				P[j] = P[i] + d
				if len(Tree[j]) != 0:
					process(j)
			else:
				if P[j] - P[i] != d:
					print("No")
					exit(0)

for i in range(1,N+1):
	process(i)

print("Yes")
Problem p03494 (python)

Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
while True:
  for i in range(N):
    if A[i] % 2 == 1:
      print(cnt)
      exit(0)
    else:
      A[i] = A[i] // 2
  cnt += 1

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
while True:
  for i in range(N):
    if A[i] % 2 == 1:
      print(cnt)
      exit(0)
    else:
      A[i] = A[i] // 2
  cnt++

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
while True:
  for i in range(N):
    if A[i] % 2 == 1:
      print cnt
      exit(0)
    else:
      A[i] = A[i] // 2
  cnt++
Problem p03937 (python)

Fixed submission:
H, W = map(int, input().split())
A = [input() for _ in range(H)]
cnt = 0
for i in range(H):
  cnt += A[i].count('#')

if cnt == (H + W -1):
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
A = [input() for _ in range(H)]
pos = {x:0, y:0}
cnt = 0
for i in range(H):
  cnt += A[i].count('#')

if cnt == (H + W -1):
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
A = [input() for _ in range(H)]
pos = {x:0, y:0}
cnt = 0
for i in range(H):
  cnt += A[i].count('#')

if cnt == (H + W -1):
  print("Possible")
else:
  print("Impossible")
Problem p02583 (python)

Fixed submission:
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

  print(count)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

print(count)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  for ls_tri in ls_tri_n:
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    if ls_tri[0] + ls_tri[1] > ls_tri[2] and ls_tri[0] + ls_tri[2] > ls_tri[1] and \
        ls_tri[1] + ls_tri[2] > ls_tri[0] :
      count += 1

print(count)

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

n = int(input())
ls_str_l = input().split()

if n < 3:
  print(0)
else:
  ls_l = []
  for l in ls_str_l:
    ls_l.append(int(l))
  
  count = 0
  ls_tri_n = list(combinations(ls_l, 3))
  # print(ls_tri_n)
  for ls_tri in ls_tri_n:
    # print(ls_tri)
    if ls_tri[0] == ls_tri[1] or ls_tri[0] == ls_tri[2] or ls_tri[1] == ls_tri[2]:
      continue
    max_idx = np.argmax(ls_tri)
    min_idx = np.argmin(ls_tri)
    mid_idx = None
    # print(max_idx, min_idx)
    for i in range(3):
      if i != max_idx and i != min_idx:
        mid_idx = i
    if ls_tri[min_idx] ** 2 + ls_tri[mid_idx] ** 2 == ls_tri[max_idx] ** 2:
      count += 1

print(count)
Problem p02641 (python)

Fixed submission:
import bisect as bi

if __name__ == '__main__':

    x,n = map(int,input().split())
    A = list(map(int,input().split()))
    B = [i for i in range(102)]
    
    #差分を求める
    C = list(set(B) - set(A))

    #二分探索自身の位置を調べる
    ind = bi.bisect_left(C,x)

    if ind == 0:
        print(C[0])
    elif ind == x - n:
        print(C[ind])
    else:
        tmp_l = abs(C[ind-1] - x)
        tmp_r = abs(C[ind] - x)
        if tmp_l > tmp_r:
            print(C[ind])
        else:
            print(C[ind-1])

Buggy submission (verdict: Runtime Error):
import bisect as bi

if __name__ == '__main__':

	x,n = map(int,input().split())
	A = list(map(int,input().split()))
	B = [i for i in range(101)]
	
	#差分を求める
	C = list(set(B) - set(A))

	#二分探索自身の位置を調べる
	ind = bi.bisect_left(C,x)

	if ind == 0:
		print(C[0])
	elif ind == x - n:
		print(C[ind])
	elif x == C[ind]:
		print(0)
	else:
		tmp_l = abs(C[ind-1] - x)
		tmp_r = abs(C[ind] - x)
		if tmp_l > tmp_r:
			print(C[ind])
		else:
			print(C[ind-1])

Buggy submission (verdict: Runtime Error):
import bisect as bi

if __name__ == '__main__':

	x,n = map(int,input().split())
	A = list(map(int,input().split()))
	B = [i for i in range(101)]
	
	#差分を求める
	C = list(set(B) - set(A))
	
	#二分探索自身の位置を調べる
	ind = bi.bisect_left(C,x)

	if ind == 0:
		print(C[0])
	elif ind == x - n:
		print(C[ind])
	else:
		tmp_l = abs(C[ind-1] - x)
		tmp_r = abs(C[ind] - x)
		if tmp_l > tmp_r:
			print(C[ind])
		else:
			print(C[ind-1])