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

Fixed submission:
def p_a():
    H, W, A, B = map(int, input().split())

    S = [[0] * W for _ in range(H)]

    if A == 0 and B == 0:
        for i in range(H):
            print(*S[i], sep="")
        exit()

    for i in range(H):
        for j in range(W):
            if A == 0:
                if i < B:
                    S[i][j] = 1
                continue
            elif B == 0:
                if j < A:
                    S[i][j] = 1
                continue

            if i // B == 1 and j // A == 1:
                S[i][j] = 1

            if i // B == 1:
                continue

            if j // A == 1:
                continue

            S[i][j] = 1

    for i in range(H):
        print(*S[i], sep="")


if __name__ == '__main__':
    p_a()

Buggy submission (verdict: Runtime Error):
def p_a():
    H, W, A, B = map(int, input().split())

    if H % A != 0 or W % B != 0:

        if H < A * 2 or W < B * 2:
            print("No")
            exit()

        if H > A * 3 or W > B * 3:
            print("No")
            exit()

    S = [[0] * W for _ in range(H)]

    for i in range(H):
        for j in range(W):
            if j // B == 1 and i // A == 1:
                S[i][j] = 1

            if j // B == 1:
                continue

            if i // A == 1:
                continue

            S[i][j] = 1

    for i in range(H):
        print(*S[i], sep="")


if __name__ == '__main__':
    p_a()
Problem p02913 (python)

Fixed submission:
def p_e():
    N = int(input())
    S = input()

    l, r, ans = 0, 0, 0

    while r < N:
        if S[l:r] in S[r:N]:
            ans = max(ans, r - l)
            r += 1
        else:
            l += 1

    print(ans)


if __name__ == '__main__':
    p_e()

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


def p_e():
    N = int(input())
    S = input()

    S_idx = defaultdict(list)

    for i in range(N):
        S_idx[S[i]].append(i)

    ans = []

    for c in S_idx.keys():
        if len(S_idx[c]) <= 1:
            continue

        comb_list = list(combinations(S_idx[c], 2))
        i = 1

        f = True
        while f:
            i += 1
            f = False
            for comb in comb_list:
                a = comb[0]
                b = comb[1]
                if S[a: a + i] == S[b: b + i]:
                    f = True

        ans.append(i - 1)

    print(max(ans))


if __name__ == '__main__':
    p_e()
Problem p02921 (python)

Fixed submission:
def p_a():
    S = input()
    T = input()

    ans = 0

    for s,t in zip(list(S), list(T)):
        if s == t:
            ans += 1

    print(ans)


if __name__ == '__main__':
    p_a()

Buggy submission (verdict: Runtime Error):
N = int(input())
print(N * (N - 1)//2)
Problem p02936 (python)

Fixed submission:
from collections import defaultdict


def p_d():
    N, Q = map(int, input().split())
    l = defaultdict(list)
    ans = [0] * N

    for _ in range(N - 1):
        a, b = map(int, input().split())
        l[a].append(b)

    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p - 1] += x

    for i in range(N):
        for j in l[i]:
            ans[j - 1] += ans[i - 1]

    print(*ans)


if __name__ == '__main__':
    p_d()

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


def p_d_r(ans, l, R, x):
    for i in R:
        ans[i - 1] += x
        p_d_r(ans, l, l[i], x)


def p_d():
    N, Q = map(int, input().split())
    l = defaultdict(list)
    ans = [0] * N

    for _ in range(N - 1):
        a, b = map(int, input().split())
        l[a].append(b)

    for _ in range(Q):
        p, x = map(int, input().split())
        ans[p - 1] += x
        p_d_r(ans, l, l[p], x)

    print(*ans)


if __name__ == '__main__':
    p_d()
Problem p02937 (python)

Fixed submission:
from collections import defaultdict
from bisect import *


def p_e():
    s = input()
    t = input()
    l = defaultdict(list)

    for i, c in enumerate(list(s)):
        l[c].append(i + 1)

    for c in list(t):
        if c not in l.keys():
            print(-1)
            exit()

    N = 0
    current = -1
    for c in list(t):
        R = l[c]

        x = bisect(R, current)

        if len(R) == x:
            N += 1
            current = R[0]
        else:
            current = R[x]

    print(N * len(s) + current)


if __name__ == '__main__':
    p_e()

Buggy submission (verdict: Runtime Error):
def p_e():
    s = input()
    t = input()
    l = defaultdict(list)

    for i, c in enumerate(list(s)):
        l[c].append(i + 1)

    for c in list(t):
        if c not in l.keys():
            print(-1)
            exit()

    N = 0
    current = 0
    for c in list(t):
        if current >= l[c][-1]:
            current = l[c][0]
            N += 1
            continue

        for i in l[c]:
            if current < i:
                current = i
                break

    print(N * len(s) + current)


if __name__ == '__main__':
    p_e()
Problem p02947 (python)

Fixed submission:
from collections import Counter

def p_c():
    n = int(input())
    ans = 0

    l = ["".join(sorted(input())) for _ in range(n)]

    a = Counter(l).values()

    for i in a:
        ans += sum(range(i))

    print(ans)
    
    
if __name__ == '__main__':
    p_c()

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

l = [sorted(input()) for _ in range(n)]
dellist = lambda items, indices: [item for idx, item in enumerate(items) if idx not in indices]

while True:
    a = l.pop(0)
    li = []
    for i in range(len(l)):
        if l[i] == a:
            li.append(i)

    dellist(l, li)

    ans += sum(range(li + 1))

print(ans)
Problem p02971 (python)

Fixed submission:
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    m = max(A)
    a = A.index(m)
    A.pop(a)
    b = max(A)

    for i in range(N):
        if i == a:
            print(b)
        else:
            print(m)


if __name__ == '__main__':
    p_c()

Buggy submission (verdict: Runtime Error):
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    m = max(A)
    a = A.index(m)
    A.pop(a)
    b = max(A)

    for i in range(N):
        if i == a:
            print(b)
        else:
            print(m)


if __name__ == '__main__':
    p_b()

Buggy submission (verdict: Runtime Error):
def p_c():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    for i in range(N):
        a = A.copy()
        a.pop(i)
        print(max(a))


if __name__ == '__main__':
    p_b()
Problem p02994 (python)

Fixed submission:
N,L=map(int,input().split())
a=list(range(L,N+L))
print(sum(a)-min(a,key=abs))

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
a=list(range(N,N+L))
print(sum(a)-min(a,key=abs))
Problem p03001 (python)

Fixed submission:
def p_c():
    W, H, x, y = map(int, input().split())
    is1 = (W / 2 == x) and (H / 2 == y)
    print(W * H / 2, 1 if is1 else 0)
    
p_c()

Buggy submission (verdict: Runtime Error):
def p_c():
    W, H, x, y = map(int, input().split())
    is0 = W / 2 == x ^ H / 2 == y
    print(W * H / 2, 0 if is0 else 1)
    
p_c()
Problem p03031 (python)

Fixed submission:
def p_c():
    n, m = map(int, input().split())
    s = [list(map(int, input().split()))[1:] for _ in range(m)]
    *p, = map(int, input().split())
    b = []
    for _s in s:
        bit = 0
        for i in _s:
            bit += (1 << (i - 1))
        b.append(bit)
    ans = 0
    for i in range(1 << n):
        for j, k in enumerate(b):
            if bin(i & k).count("1") & 1 != p[j]:
                break
        else:
            ans += 1
    print(ans)
    
p_c()

Buggy submission (verdict: Runtime Error):
def p_c():
    N, M = map(int, input().split())
    switch = [0] * N
    light = [0] * (1 << M)
    light[0] = 1
    for i in range(M):
        for s in list(map(int, input().split()))[1:]:
            switch[s - 1] += (1 << i)

    all_value = 0
    ps = list(map(int, input().split()))
    for i, p in enumerate(ps):
        all_value += p << (M - i - 1)

    for i in range(N):
        next_light = light.copy()
        for j in range(len(light)):
            next_light[j ^ switch[i]] += light[j]
        light = next_light

    print(light[all_value])
    
p_c()

Buggy submission (verdict: Runtime Error):
def p_c():
    N, M = map(int, input().split())
    switch = [0] * N
    light = [0] * (1 << M)
    light[0] = 1
    for i in range(M):
        for s in list(map(int, input().split()))[1:]:
            switch[s - 1] += (1 << i)

    all_value = 0
    for i, p in enumerate(map(int, input().split())):
        all_value += p << (M - i - 1)

    for i in range(N):
        next_light = light.copy()
        for j in range(len(light)):
            next_light[j ^ switch[i]] += light[j]
        light = next_light

    print(light[all_value])
    
p_c()

Buggy submission (verdict: Runtime Error):
def p_c():
    N, M = map(int, input().split())
    switch = [0] * N
    light = [0] * (1 << M)
    light[0] = 1
    for i in range(M):
        for s in list(map(int, input().split()))[1:]:
            switch[s - 1] += (1 << i)

    all_value = 0
    for i, p in enumerate(map(int, input().split())):
        all_value += p << (M - i - 1)

    for i in range(N):
        next_light = light.copy()
        for j in range(len(light)):
            next_light[j ^ switch[i]] += light[j]
        light = next_light

    print(light[all_value])

p_c()
Problem p03061 (python)

Fixed submission:
from fractions import gcd


def p_c():
    n = int(input())
    *a, = map(int, input().split())
    L = [0] * n
    R = [0] * n
    for i in range(n - 1):
        L[i] = gcd(L[i - 1], a[i])
        R[n - 1 - i] = gcd(R[(n - i) % n], a[n - 1 - i])
    ans = [gcd(L[i - 1], R[(i + 1) % n]) for i in range(n)]
    print(max(ans))

p_c()

Buggy submission (verdict: Runtime Error):

from fractions import gcd


def p_c():
    n = int(input())
    *a, = map(int, input().split())
    L = [0] * n
    R = [0] * n
    for i in range(n - 1):
        L[i] = gcd(L[i - 1], a[i])
        R[n - 1 - i] = gcd(R[(n - i) % n], a[n - 1 - i])
    ans = [gcd(L[i - 1], R[i + 1] % n) for i in range(n)]
    print(max(ans))
    
p_c()

Buggy submission (verdict: Runtime Error):

from fractions import gcd


def p_c():
    from sys import stdin
    input = stdin.readline
    n = int(input())
    *a, = map(int, input().split())
    L = [0] * n
    R = [0] * n
    for i in range(1, n):
        L[i] = gcd(L[i - 1], a[i])
        R[n - 1 - i] = gcd(R[(n - i) % n], a[n - 1 - i])
    ans = [gcd(L[i - 1], R[i + 1] % n) for i in range(n)]
    print(max(ans))

p_c()
Problem p03112 (python)

Fixed submission:
def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    ans = []
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
        ans.append(str(res))
    print("\n".join(ans))


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 9
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    ans = []
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
        ans.append(str(res))
    print("\n".join(ans))


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
def p_d():
    from bisect import bisect_right
    A, B, Q = map(int, input().split())
    INF = 10 ** 9
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(Q):
        x = int(input())
        b, d = bisect_right(s, x), bisect_right(t, x)
        res = INF
        for S in [s[b - 1], s[b]]:
            for T in [t[d - 1], t[d]]:
                d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
                res = min((d1, d2, res))
    print(res)


if __name__ == '__main__':
    p_d()
Problem p03164 (python)

Fixed submission:
def p_e():
    N, W = map(int, input().split())
    max_value = 10 ** 3 * N + 1
    dp = [W + 1] * max_value
    dp[0] = 0
    for _ in range(1, N + 1):
        w, v = map(int, input().split())
        NEXT = [W + 1] * max_value
        NEXT[0] = 0
        for i in range(1, max_value):
            if i - v >= 0:
                NEXT[i] = min(dp[i - v] + w, dp[i])
            else:
                NEXT[i] = dp[i]
        dp = NEXT

    ans = 0
    for i, w in enumerate(dp):
        if w <= W:
            ans = i
    print(ans)


if __name__ == '__main__':
    p_e()

Buggy submission (verdict: Runtime Error):
def p_e():
    """
    ナップサック問題（制約厳しい版） 
    """
    N, W = map(int, input().split())
    dp = [0] * (W + 1)
    for i in range(1, N + 1):
        w, v = map(int, input().split())
        NEXT = [0] * (W + 1)
        for j in range(1, W + 1):
            if j - w >= 0:
                NEXT[j] = max(v + dp[j - w], dp[j])
            else:
                NEXT[j] = dp[j]
        dp = NEXT

    print(max(NEXT))


if __name__ == '__main__':
    p_e()

Buggy submission (verdict: Runtime Error):
def p_d():
    N, W = map(int, input().split())
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i in range(1, N + 1):
        w, v = map(int, input().split())
        for j in range(1, W + 1):
            if j - w >= 0:
                dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j])

    print(max(dp[N]))


if __name__ == '__main__':
    p_d()
Problem p03166 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 6)


def recursion_g(eges, length, f):
    if length[f] != -1:
        return length[f]
    if not eges[f]:
        length[f] = 0
        return 0
    memo = []
    for t in eges[f]:
        memo.append(recursion_g(eges, length, t) + 1)
    length[f] = max(memo)
    return length[f]


def p_g():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    length = [-1] * N
    for _ in range(M):
        x, y = map(int, input().split())
        edges[x - 1].append(y - 1)

    for i in range(N):
        recursion_g(edges, length, i)
    print(max(length))


if __name__ == '__main__':
    p_g()

Buggy submission (verdict: Runtime Error):
def recursion_g(eges, length, f):
    if length[f] != -1:
        return length[f]
    if not eges[f]:
        length[f] = 0
        return 0
    memo = []
    for t in eges[f]:
        memo.append(recursion_g(eges, length, t) + 1)
    length[f] = max(memo)
    return length[f]


N, M = map(int, input().split())
edges = [[] for _ in range(N)]
length = [-1] * N
for _ in range(M):
    x, y = map(int, input().split())
    edges[x - 1].append(y - 1)

for i in range(N):
    recursion_g(edges, length, i)
print(max(length))

Buggy submission (verdict: Runtime Error):
def recursion_g(eges, length, f):
    if length[f] != -1:
        return length[f]
    if not eges[f]:
        length[f] = 0
        return 0
    memo = []
    for t in eges[f]:
        memo.append(recursion_g(eges, length, t) + 1)
    length[f] = max(memo)
    return length[f]


def p_g():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    length = [-1] * N
    for _ in range(M):
        x, y = map(int, input().split())
        edges[x - 1].append(y - 1)

    for i in range(N):
        recursion_g(edges, length, i)
    print(max(length))


if __name__ == '__main__':
    p_g()

Buggy submission (verdict: Runtime Error):
def recursion_g(eges, length, f):
    if length[f] != -1:
        return length[f]
    if not eges[f]:
        length[f] = 0
        return 0
    memo = []
    for t in eges[f]:
        memo.append(recursion_g(eges, length, t) + 1)
    length[f] = max(memo)
    return length[f]


def p_g():
    N, M = map(int, input().split())
    edges = [[] for _ in range(N)]
    length = [-1] * N
    for _ in range(M):
        x, y = map(int, input().split())
        edges[x - 1].append(y - 1)

    for i in range(N):
        recursion_g(edges, length, i)
    print(max(length))


if __name__ == '__main__':
    p_g()
Problem p03213 (python)

Fixed submission:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def p_d():
    from collections import Counter
    N = int(input())
    li = []
    for i in range(1, N + 1):
        li.extend(prime_factorize(i))
    prime_list = Counter(li).values()

    def num(m):
        return len(list(filter(lambda x: x >= m - 1, prime_list)))

    print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


if __name__ == '__main__':
    p_d()

Buggy submission (verdict: Runtime Error):
def p_d():
    from collections import Counter
    N = int(input())
    li = []
    for i in range(1, N + 1):
        li.extend(prime_factorize(i))
    prime_list = Counter(li).values()

    def num(m):
        return len(list(filter(lambda x: x >= m - 1, prime_list)))

    print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)


if __name__ == '__main__':
    p_d()
Problem p02801 (python)

Fixed submission:
C=input()

i=ord(C)+1
print(chr(i))

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
s=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
	s[i]=list(input())
# h,w=3,3
# s=[['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]
v=[[1000000 for i in range(w)] for j in range(h)]
s=np.array(s)
v=np.array(v)
def search(H,W,p):
	m=0
	if H<h-1 and s[H+1][W]=='.' and v[H+1][W]>p+1:
		v[H+1][W]=p+1
		m=p+1
	if H>0 and s[H-1][W]=='.' and v[H-1][W]>p+1:
		v[H-1][W]=p+1
		m=p+1
	if W>0 and s[H][W-1]=='.' and v[H][W-1]>p+1:
		v[H][W-1]=p+1
		m=p+1
	if W<w-1 and s[H][W+1]=='.' and v[H][W+1]>p+1:
		v[H][W+1]=p+1
		m=p+1
	return m

def dijk():
	f=False
	global P
	global M
	for i in range(h):
		for j in range(w):
			if v[i][j]==P:
				m=search(i,j,P)
				M=max(m,M)
				f=True

	P+=1
	if f==False:
		return 0
	dijk()
M_=0
for i in range(h):
	for j in range(w):
		v[i][j]=0
		P=0
		M=0
		if s[i][j]!='.':
			continue
		dijk()
		M_=max(M,M_)
		v=[[1000000 for i in range(w)] for j in range(h)]
print(M_)
Problem p02853 (python)

Fixed submission:
x,y=map(int,input().split())
def fun(x):
	price=0
	if x==3:
		price=100000
	elif x==2:
		price=200000
	elif x==1:
		price=300000
	return price
if x ==1 and y ==1:
	print(fun(x)+fun(y)+400000)
else:
	print(fun(x)+fun(y))

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
def fun(x):
	price=0
	if x==3:
		price=100000
	elif x==2:
		price=200000
	elif x==1:
		price=300000
	return price
if x ==1 and y ==1:
	print(fun(x)+fun(y)+4Ω00000)
else:
	print(fun(x)+fun(y))

Buggy submission (verdict: Runtime Error):
try: 
	x,y=map(int,input().split())
except Exception:
 	exit(100)
def fun(x):
	price=0
	if x==3:
		price=100000
	elif x==2:
		price=200000
	elif x==1:
		price=300000
	return price
if x ==1 and y ==1:
	print(fun(x)+fun(y)+4Ω00000)
else:
	print(fun(x)+fun(y))
Problem p03544 (python)

Fixed submission:
def L(n):
    a = 2
    b = 1
    res = 1
    for i in range(n - 1):
        res = 0
        res += a + b
        a = b
        b = res
    return res
print(L(int(input())))

Buggy submission (verdict: Runtime Error):
def L(n):
    a = 2
    b = 1
    for i in range(n - 1):
        res = 0
        res += a + b
        a = b
        b = res
    return res
print(L(int(input())))
Problem p03597 (python)

Fixed submission:
n = int(input())
print(n**2 - int(input()))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(n**2 - int(input())
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 1
for i in range(n):
        t = int(input())
        prev = prev * t // gcd(prev, t)
print(prev)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if(b == 0):
        return a
    return gcd(b, a % b)
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / gcd(prev, t))
print(prev)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = int(prev * t / math.gcd(prev, t))
print(prev)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
prev = 0
for i in range(n):
    if(i == 0):
        prev = int(input())
    else:
        t = int(input())
        prev = prev * t // math.gcd(prev, t)
print(prev)
Problem p03657 (python)

Fixed submission:
a, b = list(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 = list(map(int, input().split()))
if(a % 3 == 0 or b % 3 ==0 or (a + b)4 5 % 3 == 0):
    print("Possible")
else:
    print("Impossible")
Problem p03737 (python)

Fixed submission:
inp = input()
split = inp.split()
out = ""
for s in split:
    out += s[0].upper()
print(out)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if(a > b):
    print("GREATER")
elif(a < b):
    print("LESS")
elif(a == b):
    print("EQUAL")
Problem p02947 (python)

Fixed submission:
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

max = int(input())
i = 0
strings = []
while True:
  if i == max:
    break
  strings.append(input())
  i+=1

#print(strings) # ['acornistnt', 'peanutbomb', 'constraint']

strings2 = [list(str) for str in strings]
[str.sort() for str in strings2] # 配列の中身を副作用でソートする
# print(strings2)
strs3 = [''.join(str) for str in strings2] # ソートした文字のリストを文字列に戻す

#print(strs3)

c = collections.Counter(strs3)
# print(c)
counts = list(c.values()) # 組み合わせの数のリスト
counts2 = [ c for c in counts if c > 1] # 2個以上の重複がないものは除外
#print(counts2)

# nC2 の組み合わせを計算して、合計する
print(sum([int(cmb(n, 2)) for n in counts2]))

Buggy submission (verdict: Runtime Error):
import collections
from math import factorial

max = int(input())
i = 0
strings = []
while True:
  if i == max:
    break
  strings.append(input())
  i+=1

#print(strings) # ['acornistnt', 'peanutbomb', 'constraint']

strings2 = [list(str) for str in strings]
[str.sort() for str in strings2] # 配列の中身を副作用でソートする
# print(strings2)
strs3 = [''.join(str) for str in strings2] # ソートした文字のリストを文字列に戻す

#print(strs3)

c = collections.Counter(strs3)
# print(c)
counts = list(c.values()) # 組み合わせの数のリスト
counts2 = [ c for c in counts if c > 1] # 2個以上の重複がないものは除外
#print(counts2)

# nC2 の組み合わせを計算して、合計する
print(sum([int(factorial(n) / factorial(2) / factorial(n - 2)) for n in counts2]))
Problem p03071 (python)

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

if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
a = n[0]
b = n[1]
 
if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)
n = list(map(int, input().split()))
a = n[0]
b = n[1]

if a == b:
  print(a + b)
elif a > b:
  print(a*2 - 1)
else:
  print(b*2 - 1)