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

Fixed submission:
import collections
N,M = map(int,input().split())
edge = collections.defaultdict(list)
for _ in range(M):
    u,v = map(int,input().split())
    edge[u-1].append(v-1)
S,T = map(int,input().split())
dp = [[-3 for _ in range(3)] for _ in range(N)]
dp[S-1][0] = 0
q = collections.deque()
q.append((S-1,0))
while q:
    p,step = q.popleft()
    next_step = (step+1)%3
    for e in edge[p]:
        if dp[e][next_step] == -3:
            dp[e][next_step] = dp[p][step] + 1
            q.append((e,next_step))
            if e == T-1 and next_step == 0:
                break
print(dp[T-1][0] // 3)

Buggy submission (verdict: Runtime Error):
import collections
N,M = map(int,input().split())
edge = collections.defaultdict(list)
for _ in range(M):
    u,v = map(int,input().split())
    edge[u-1].append(v-1)
S,T = map(int,fi.input().split())
dp = [-1 for _ in range(N)]
dp[S-1] = 0
q = collections.deque()
q.append(S-1)
while q:
    p = q.pop()
    for k1 in edge[p]:
        for k2 in edge[k1]:
            for k3 in edge[k2]:
                if dp[k3] == -1:
                    dp[k3] = dp[p] + 1
                    q.append(k3)
                    if k3 == T-1:
                        break
print(dp[T-1])
Problem p03044 (python)

Fixed submission:
def resolve():
    N = int(input())
    import collections
    n_dict = collections.defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        n_dict[u-1].append((v-1,w))
        n_dict[v-1].append((u-1,w))

    color = [-1 for _ in range(N)]

    d = collections.deque()
    for i in range(N):
        if color[i] == -1:
            d.append((i,1))
        while d:
            j,c = d.pop()
            color[j] = c
            for n,w in n_dict[j]:
                if color[n] == -1:
                    d.append((n,c^1)) if w % 2 != 0 else d.append((n,c))
                else:
                    continue
        print(color[i])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    import collections
    n_dict = collections.defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        n_dict[u-1].append((v-1,w))
        n_dict[v-1].append((u-1,w))

    color = [-1 for _ in range(N)]

    def paint(i,c):
        color[i] = c
        for n,w in n_dict[i]:
            if color[n] == -1:
                paint(n,c^1) if w % 2 != 0 else paint(n,c)
            else:
                continue
        return
    for i in range(N):
        if color[i] == -1:
            paint(i,1)   
        print(color[i])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N = int(input())
    import collections
    n_dict = collections.defaultdict(list)
    for i in range(N-1):
        u,v,w = map(int,input().split())
        n_dict[u-1].append((v-1,w))
        n_dict[v-1].append((u-1,w))

    color = [-1 for _ in range(N)]

    def paint(i,c):
        color[i] = c
        for n,w in n_dict[i]:
            if color[n] == -1:
                paint(n,c^1) if w % 2 != 0 else paint(n,c)
            else:
                return
        return
    for i in range(N):
        if color[i] == -1:
            paint(i,1)   
        print(color[i])
resolve()
Problem p03078 (python)

Fixed submission:
import heapq
import numpy as np
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
flag = np.ones((X,Y,Z),dtype=np.bool)
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
heapq.heappush(ABC,(-1 * (A[0]+B[0]+C[0]),0,0,0))
flag[0][0][0] = False
ctr = 0
while ctr < K and ABC:
    s,a,b,c = heapq.heappop(ABC)
    print(-s)
    if a+1<X and flag[a+1][b][c]:
        heapq.heappush(ABC,(-1 * (A[a+1]+B[b]+C[c]),a+1,b,c))
        flag[a+1][b][c] = False
    if b+1<Y and flag[a][b+1][c]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b+1]+C[c]),a,b+1,c))
        flag[a][b+1][c] = False
    if c+1<Z and flag[a][b][c+1]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b]+C[c+1]),a,b,c+1))
        flag[a][b][c+1] = False
    ctr += 1

Buggy submission (verdict: Runtime Error):
import heapq

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
flag = [[[True for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
heapq.heappush(ABC,(-1 * (A[0]+B[0]+C[0]),0,0,0))
flag[0][0][0] = False
ctr = 0
while ctr < K and ABC:
    s,a,b,c = heapq.heappop(ABC)
    print(-s)
    if flag[a+1][b][c]:
        heapq.heappush(ABC,(-1 * (A[a+1]+B[b]+C[c]),a+1,b,c))
        flag[a+1][b][c] = False
    
    if flag[a][b+1][c]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b+1]+C[c]),a,b+1,c))
        flag[a][b+1][c] = False
    if flag[a][b][c+1]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b]+C[c+1]),a,b,c+1))
        flag[a][b][c+1] = False
    ctr += 1

Buggy submission (verdict: Runtime Error):
import heapq

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
flag = [[[True for _ in range(Z)] for _ in range(Y)] for _ in range(X)]
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
heapq.heappush(ABC,(-1 * (A[0]+B[0]+C[0]),0,0,0))
flag[0][0][0] = False
ctr = 0
while ctr < K and ABC:
    s,a,b,c = heapq.heappop(ABC)
    print(-s)
    if flag[a+1][b][c]:
        heapq.heappush(ABC,(-1 * (A[a+1]+B[b]+C[c]),a+1,b,c))
        flag[a+1][b][c] = False
    
    if flag[a][b+1][c]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b+1]+C[c]),a,b+1,c))
        flag[a][b+1][c] = False
    if flag[a][b][c+1]:
        heapq.heappush(ABC,(-1 * (A[a]+B[b]+C[c+1]),a,b,c+1))
        flag[a][b][c+1] = False
    ctr += 1
Problem p03342 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
L = 0
R = 0
S = A[0]
ans = 0
while(R < N-1):
    if S + A[R+1] == S ^ A[R+1]:
        S += A[R+1]
        R+= 1
    elif R > L:
        S -= A[L]
        ans += R - L + 1
        L += 1
    else:
        L += 1
        R += 1
        ans += 1
        S = A[L]
print(ans+(R-L+2)*(R-L+1)//2)

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

A_sum = A.copy()
cur_len = 1
count = N
ans = N
while cur_len <= N and count > 0:
    for i in range(N-cur_len):
        if A_sum[i] >= 0 and A_sum[i] ^ A[i+cur_len] == A_sum[i] + A[i+cur_len]:
            A_sum[i] = A_sum[i] + A[i+cur_len]
        elif A_sum[i] >= 0:
            A_sum[i] = -1
            count -= 1
    if A_sum[N-cur_len] >= 0:
        A_sum[N-cur_len] = -1
        count -= 1
    cur_len += 1
    ans += count
print(ans)
Problem p03855 (python)

Fixed submission:
from collections import defaultdict
N,K,L = map(int,input().split())

root_road = list(range(N))
root_rail = list(range(N))
depth_road = [1 for _ in range(N)]
depth_rail = [1 for _ in range(N)]

def find(a,root):
    if root[a] == a:
        return a
    else:
        root[a] = find(root[a],root)
        return root[a]

def unite(a,b,root,depth):
    A = find(a,root)
    B = find(b,root)
    if A == B:
        return
    elif depth[A] > depth[B]:
        root[B] = A
        depth[A] += depth[B]
    else:
        root[A] = B
        depth[B] += depth[A]

for i in range(K):
    p,q = map(int,input().split())
    unite(p-1,q-1,root_road,depth_road)
for i in range(L):
    r,s = map(int,input().split())
    unite(r-1,s-1,root_rail,depth_rail)
d = defaultdict(int)
pairs = []
for i in range(N):
    road = find(i,root_road)
    rail = find(i,root_rail)
    pairs.append((road,rail))
    d[(road,rail)] += 1
for p in pairs:
    print(d[p],end = " ")

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

root_road = list(range(N))
root_rail = list(range(N))
depth_road = [1 for _ in range(N)]
depth_rail = [1 for _ in range(N)]

def find(a,root):
    if root[a] == a:
        return a
    else:
        root[a] = find(root[a],root)
        return root[a]

def unite(a,b,root,depth):
    A = find(a,root)
    B = find(b,root)
    if A == B:
        return
    elif depth[A] > depth[B]:
        root[B] = A
        depth[A] += depth[B]
    else:
        root[A] = B
        depth[B] += depth[A]

for i in range(K):
    p,q = map(int,input().split())
    unite(p-1,q-1,root_road,depth_road)
for i in range(L):
    r,s = map(int,input().split())
    unite(r-1,s-1,root_rail,depth_rail)
d = defaultdict(int)
pairs = []
for i in range(N):
    road = find(i,root_road)
    rail = find(i,root_rail)
    pairs.append((road,rail))
    d[(road,rail)] += 1
for p in pairs:
    print(d[p],end = " ")
Problem p03419 (python)

Fixed submission:
n, m = map(int, raw_input().split())

if n > m: 
	a = n
	n = m
	m = a

if n == 1:
	if m == 1:
		print 1
	else:
		print m - 2 
	exit(0)

black = (n - 2) * (m - 2)
print black

Buggy submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())

if n > m: swap(n, m)

if n == 1:
	if m == 1:
		print 1
	else:
		print m - 2 
	exit(0)

black = (n - 2) * (m - 2)
print black
Problem p03281 (python)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip("\n"))
count = 0
for num in range(27, n+1, 2):
    divisor = 1
    for p in range(1, num, 2):
        if num % p == 0:
            divisor += 1
    if divisor == 8:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import sys

n = int(sys.stdin.readline().rstrip("\n"))
count = 0
for num in range(27, n+1, 2):
    divisor = 1
    for p in range(1, num, 2):
        if num % p == 0:
            print(f"num: {num}, p: {p}")
            divisor += 1
    if divisor == 8:
        count += 1
print(count)
Problem p02795 (python)

Fixed submission:
h=int(input())
w=int(input())
n=int(input())         
if h>w:
  if n%h==0:
    ct=n//h
  else:
    ct=n//h+1
else:
  if n%w==0:
    ct=n//w
  else:
    ct=n//w+1
print(ct)

Buggy submission (verdict: Runtime Error):
    h=int(input())
    w=int(input())
    n=int(input())
     
    if h>w:
      if n%h==0:
        ct=n//h
      else:
        ct=n//h+1
    else:
      if n%w==0:
        ct=n//w
      else:
        ct=n//w+1
    print(ct)

Buggy submission (verdict: Runtime Error):
h=int(input())
w=int(input())
n=int(input())
 
if h>w:
  if n%h==0:
    ct=n//h
  else:
    ct=n//h+1
else:
  if n%w=0:
    ct=n//w
  else:
    ct=n//w+1
print(ct)
Problem p03471 (python)

Fixed submission:
n,y = map(int,input().split())
s=[-1,-1,-1]
if n*10000<y:
    pass
elif n*10000==y:
    s=[n,0,0]
else:
    m=1
    x_0=n*10000
    while m<=n:
        for i in range(m+1):
            x= x_0-9000*(m-i)-5000*i
            if x == y:
                s=[n-m,i,m-i]
                break
        if x==y:
            break
        m=m+1
print(*s)

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
s=[-1,-1,-1]
if n*10000<y:
    pass
elif n*10000==y:
    s=[n,0,0]
else:
    m=1
    x=n*10000
    while m<=n:
        for i in range(m+1):
            x= x-9000*(m-i)-4000*i
            if x == y:
                s=[n-m,i,m-i]
                break
        if x==y:
            break
    m=m+1
print(*l)

Buggy submission (verdict: Runtime Error):
n,y = map(int,input().split())
s=[-1,-1,-1]
if n*10000<y:
    pass
else:
    m=0
    x=n*10000
    while m<=n:
        for i in range(m):
            x= x-9000*(m-i)-4000*i
            if x == y:
                s=[n-m,i,m-i]
                break
        if x==y:
            break
print(*l)
Problem p03657 (python)

Fixed submission:
a,b = map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")
Problem p03659 (python)

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

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

for i in range(n):
  sum = sum+a[i]
  d[i] = sum
for i in range(n):
  d[i] = abs(sum[i]-d[i])
d.pop(0)
d.pop(n-1)
print(min(d))
Problem p03800 (python)

Fixed submission:
n = int(input())
s = input()
a = "SS"
ct=1
while ct<7:    
    for i in range(n-1):
        p=a[i]
        q="A"
        if a[i]=="S":
            q="W"
        else:
            q="S"
        if a[i+1]=="S":
            if s[i+1] == "o":
                a=a+a[i]
            else:
                a=a+q
        else:
            if s[i+1] == "o":
                 a=a+q
            else:
                a=a+a[i]
    if a[0]==a[n]:
        if a[0]=="S" and s[0]=="o" and a[n-1]==a[1]:
            print(a[0:n])
            break
        elif a[0]=="S" and s[0] !="o" and a[n-1]!=a[1]:         
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] =="o" and a[n-1]!=a[1]: 
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] !="o" and a[n-1]==a[1]: 
            print(a[0:n])
            break
        else:
            ct=ct+1
            if ct==2:
                a="SW"
            elif ct==3:
                a="WS"
            elif ct==4:
                a="WW"
            else:
                print(-1)
                break
    else:
        ct=ct+1
        if ct==2:
            a="SW"
        elif ct==3:
            a="WS"
        elif ct==4:
            a="WW"
        else:
            print(-1)
            break

Buggy submission (verdict: Runtime Error):
Menagerien = int(input())
s = input()
a = "SS"
ct=1
while ct<7:    
    for i in range(n-1):
        p=a[i]
        q="A"
        if a[i]=="S":
            q="W"
        else:
            q="S"
        if a[i+1]=="S":
            if s[i+1] == "o":
                a=a+a[i]
            else:
                a=a+q
        else:
            if s[i+1] == "o":
                 a=a+q
            else:
                a=a+a[i]
    if a[0]==a[n]:
        if a[0]=="S" and s[0]=="o" and a[n-1]==a[1]:
            print(a[0:n])
            break
        elif a[0]=="S" and s[0] !="o" and a[n-1]!=a[1]:         
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] =="o" and a[n-1]!=a[1]: 
            print(a[0:n])
            break
        elif a[0]=="W" and s[0] !="o" and a[n-1]==a[1]: 
            print(a[0:n])
            break
        else:
            ct=ct+1
        if ct==2:
            a="SW"
        elif ct==3:
            a="WS"
        elif ct==4:
            a="WW"
        else:
            print(-1)
            break
    else:
        ct=ct+1
        if ct==2:
            a="SW"
        elif ct==3:
            a="WS"
        elif ct==4:
            a="WW"
        else:
            print(-1)
            break
Problem p02885 (python)

Fixed submission:
AB = input()
A,B=AB.split()
A = int(A)
B = int(B)

if A > 2*B:
  print(A-2*B)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()

A = int(A)
B = int(B)

if A > B:
  print(B)
else:
  print(0)
Problem p02981 (python)

Fixed submission:
NAB = input()
N,A,B=NAB.split()
N = int(N)
A = int(A)
B = int(B)

if N * A < B:
  print(N*A)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
N = input()
A = input()
B = input()

N = int(N)
A = int(A)
B = int(B)

if N * A > B:
  print(N*A)
else:
  print(B)
Problem p03455 (python)

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

if (a * b)%2 == 0:
  print('Even')
else:
  print('Odd')

Buggy submission (verdict: Runtime Error):
a = input() 
b = input()

a=int(a)
b=int(b)

if (a * b)/2 = 0:
  print('Even')
else:
  print('Odd')
Problem p03693 (python)

Fixed submission:
r,g,b,=input().split()
r=int(r)
g=int(g)
b=int(b)

if ((r*100)+(g*10)+b)%4==0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
r=input()
g=input()
b=input()

r=int(r)
g=int(g)
b=int(b)

if print(rgb)/4=0:
  return 'Yes'
else:
  return 'No'
Problem p02952 (python)

Fixed submission:
n=int(input())
re=0
for i in range(1,n+1):
  if len(str(i))%2==1:
    re+=1
print(re)

Buggy submission (verdict: Runtime Error):
n=int(input())
re=0
for i in range(1,n):
  if len(str(i)%2==1):
    re+=1
print(re)

Buggy submission (verdict: Runtime Error):
import math
def main():
	n=int(input())
	a=round(math.log10(n))
	count=0
	result=0
		while count<=a:
			if a<=1:
				result += n+1
				break
			else:
			if count==a:
				result += n-10**count + 1
				count += 2
			else:
				if  count==0:
					result+=10
					count +=2
				else:
					result += 10**(count+1)-10**count
					count += 2
	aaa=result-1
	print(aaa)
main()

Buggy submission (verdict: Runtime Error):
import math
def main():
	n=int(input())
	a=round(math.log10(n))
	count=0
	result=0
		while count<=a:
			if a<=1:
				result += n+1
				break
			else:
			if count==a:
				result += n-10**count + 1
				count += 2
			else:
				if  count==0:
					result+=10
					count +=2
				else:
					result += 10**(count+1)-10**count
					count += 2
	aaa=result-1
	print(aaa)
main()

Buggy submission (verdict: Runtime Error):
result=0
while count<=a:
	if a<=1:
		result += n+1
		break
	else:
		if count==a:
			result += n-10**count + 1
			count += 2
		else:
			if  count==0:
				result+=10
				count +=2
			else:
				result += 10**(count+1)-10**count
				count += 2
print(result-1)
Problem p04043 (python)

Fixed submission:
a=list(map(int,input().split()))
a.sort() 
if a==[5,5,7]:
  print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split())).sort()
if a==[5,5,7]:
  print(YES)
  else:
    print(NO)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s = [input().strip("\"") for i in range(a)]
print("".join(s))
Problem p02795 (python)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())

n_push = []

for n_h in range(h+1):
  for n_w in range(w+1):
    n_tmp = (n_h)*w + (n_w)*h - ((n_h)*(n_w))

    if n_tmp>=n:
      n_push.append(n_h + n_w)

print(min(n_push))

Buggy submission (verdict: Runtime Error):
def main(h, w, n)
  n_push = []

  for n_h in range(h):
    for n_w in range(w):
      n_tmp = n_h*w + n_w*h - (n_h*n_w)

      if n_tmp>n_push:
          n_push.append = n_h + n_w

  return min(n_push)

Buggy submission (verdict: Runtime Error):
h = 14
w = 12
n = 112

n_push = []

for n_h in range(h):
  for n_w in range(w):
    n_tmp = n_h*w + n_w*h - (n_h*n_w)
    
    if n_tmp>n_push:
	    n_push.append = n_h + n_w
    
print min(n_push)
Problem p02795 (python)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())
 
ans = 0
sum = 0
 
while(sum < n):
  if h >= w :
    sum += h
    ans += 1
    w -= 1
  else :
    sum += w
    ans += 1
    h -= 1
print(ans)

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

ans = 0
sum = 0

while(sum < n):
  if h >= w :
    sum += h
    ans += 1
    w -= 1
  else :
    sum += w
    asn += 1
    h -= 1
print(ans)
Problem p02796 (python)

Fixed submission:
n = int(input())
m_list = []
for i in range(n):
    x,l = map(int, input().split())
    m_list.append([x-l, x+l])

m_list = sorted(m_list,key= lambda x:x[1])

result = 0
cur_pos = -1000000000

for min,max in m_list:
    if cur_pos <= min:
        result += 1
        cur_pos = max
print(result)

Buggy submission (verdict: Runtime Error):

n = int(input())
m_list = []
for i in range(n):
  X, L = map(int, input().split())
  m_list.append([X-L,X+L])

m_list = sorted(m_list)
  
def MachineArrangementCheck():
  length = len(Machine_list)
  # 配列の上限エラー対策
  for i in range(length):
    if i != length - 1:      
      # m1の上限とm２の下限が接するかを確認
      if (m_list[i][1] - m_list[i+1][0]) < 0:
        del m_list[i+1]
        return False
  return True

while MachineArrangementCheck() == False:
  continue
  
print(len(m_list))
Problem p03351 (python)

Fixed submission:
import sys


xs = list(sys.stdin.readline().split(' '))
a,b,c,d = [int(x) for x in xs]

f = (lambda x,y: abs(x - y) <= d)
g = (lambda x,y,z: f(x,y) or (f(x,z) and f(y,z)))

if g(a,c, b):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
import sys

x = int(str(sys.stdin.readline()))
y = 1
for i in range(1, x):
	y2 = i * i
	if x < y2:
		break
	y = y2
print(y)
Problem p02946 (python)

Fixed submission:
num = [int(i) for i in input().split()]
K = num[0]
X = num[1]
 
ans = [i for i in range(X-K+1, X+K)]
for i in range(2*K-1):
  print(ans[i], end=' ')

Buggy submission (verdict: Runtime Error):
num = [int(i) for i in input().split()]
K = num[0]
X = num[1]
 
ans = [i for i in range(X-K+1, X+K)]
for i in range(2*K+1):
  print(ans[i], end=' ')

Buggy submission (verdict: Runtime Error):
num = [int(i) for i in input().split()]
K = num[0]
X = num[1]
 
ans = [i for i in range(X-K+1, X+K)]
for i in range(2*K+1):
  print(ans[i], end=' ')

Buggy submission (verdict: Runtime Error):
num = [int(i) for i in input().split()]
K = num[0]
X = num[1]
 
ans = [i for i in range(X-K+1, X+K)]
for i in range(2*K+1):
  print(ans[i], end='')

Buggy submission (verdict: Runtime Error):
num = [int(i) for i in input().split()]
K = num[0]
X = num[1]

print([i for i in range(X-K+1, X+K)]
Problem p02947 (python)

Fixed submission:
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = [''.join(sorted(list(input()))) for i in range(N)]
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
dict_word = {sorted_word[i]:0 for i in range(N)}
count = 0
ans = 0

def sum_all(x):
  for i in range(x+1):
    y += i
  return y

for i in range(N):
  if sorted_word[i] in sorted_word[i+1:]:
	dict_word[sorted_word[i]] += 1
    
for value in dict_word.value():
  ans += sum_all(value)
  
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
copy_word = copy.copy(sorted_word)
count = 0
for i in range(N-1):
  copy_word.remove(sorted_word[i])
  if sorted_word[i] in copy_word
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = input()
word = [input() for i in range(N)]
sorted_word = [word[i].sort() for i in range(N)]
count = 0
for i in range(N):
  for j in range(i, N):
    if sorted_word[i] == sorted_word[i+j]:
      count += 1
print(count)