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

Fixed submission:
import math
import numpy as np

A, B, H, M = map(int, input().split())

r_H = 360 * ((H + M / 60) / 12)
r_M = 360 * M / 60

r = np.abs(r_H - r_M)
r = min(r, 360 - r)

C = np.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(r)))

print(C)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np

A, B, H, M = map(int, input().split())

r_H = 360 * ((H + M / 60) / 12)
r_M = 360 * M / 60

r = np.abs(r_H - r_M)
r = min(r, 360 - r)

C = np.sqrt(A**2 + B**2 - 2 * A * B * math.cos(math.radians(r)))

print(C)
Problem p02720 (python)

Fixed submission:
import sys

K = int(input())

if K < 10:
    print(K)
    sys.exit(0)

runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 9
while True:
    new_runrun = []
    for run in runrun:
        run_str = str(run)
        last_num = int(run_str[-1])
        for i in range(3):
            diff = i - 1
            if (last_num == 9 and diff == 1) or (last_num == 0 and diff == -1):
                continue
            ans = int(run_str + str(last_num + diff))
            new_runrun.append(ans)
            count += 1
            if count == K:
                print(ans)
                sys.exit(0)
    runrun = new_runrun

Buggy submission (verdict: Runtime Error):
import sys

K = int(input())

# K = 100000

if K < 10:
    print(K)
    sys.exit(0)

runrun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
count = 9
while True:
    new_runrun = []
    for run in runrun:
        # run=runrun[0]
        run_str = str(run)
        last_num = int(run_str[-1])
        for i in range(3):
            diff = i - 1
            if (last_num == 9 and diff == 1) or (last_num == 0 and diff == -1):
                continue
            ans = int(f'{run_str}{last_num+diff}')
            new_runrun.append(ans)
            count += 1
            if count == K:
                print(ans)
                sys.exit(0)
    runrun = new_runrun
Problem p02730 (python)

Fixed submission:
import sys

S = input()

# S = 'akasaka'

N = len(S)

S_rev = S[::-1]
if S != S_rev:
    print('No')
    sys.exit(0)

sub_S = S[:int((N - 1)/2)]
sub_S_rev = S[int((N + 3)/2)-1:]
if sub_S != sub_S_rev:
    print('No')
    sys.exit(0)

print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

S = input()

# S = 'akasaka'

N = len(S)

S_rev = S[::-1]
if S != S_rev:
    print('No')
    sys.exit(1)

sub_S = S[:int((N - 1)/2)]
sub_S_rev = S[int((N + 3)/2)-1:]
if sub_S != sub_S_rev:
    print('No')
    sys.exit(1)

print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

S = input()

# S = 'akasaka'

N = len(S)

S_rev = S[::-1]
if S != S_rev:
    print('No')
    sys.exit(1)

sub_S = S[:int((N - 1)/2)+1]
sub_S_rev = S[int((N + 3)/2)-1:]
if sub_S != sub_S_rev:
    print('No')
    sys.exit(1)

print('Yes')

Buggy submission (verdict: Runtime Error):
import sys

S = input()

# S = 'akasaka'

N = len(S)
N_sub = int((N - 1)/2)

S_rev = S[::-1]
if S != S_rev:
    print('No')
    sys.exit(1)

sub_S = S[:N_sub]
sub_S_rev = sub_S[::-1]
if sub_S != sub_S_rev:
    print('No')
    sys.exit(1)

print('Yes')
Problem p02732 (python)

Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

Buggy submission (verdict: Runtime Error):
import collections

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

# N = 5
# A = [1, 1, 2, 1, 2]

c = collections.Counter(A)
d = {}
for i in c:
    # val = uni_vals[0]
    ans = 0
    for j in c:
        n = c[j]
        if j == A[i]:
            n -= 1
        ans += (n*(n-1))/2
    d[i] = ans

for i in range(N):
    print(int(d[A[i]]))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    A_sub.pop(i)

    A_sub = np.array(A_sub)

    ans = 0
    u, counts = np.unique(A_sub, return_counts=True)
    for n in counts:
        # val = uni_vals[0]
        ans += (n*(n-1))/2
    # dic = {}
    # for val in A_sub:
    #     if val in dic.keys():
    #         dic[val] += 1
    #     else:
    #         dic[val] = 1
    # ans = 0
    # for val in dic.values():
    #     ans += (val*(val-1)/2)

    print(int(ans))
Problem p03456 (python)

Fixed submission:
import numpy as np

# a = '1'; b = '21'
a, b = map(str, input().split())

n = int(a+b)
sq = np.sqrt(n)
if sq == int(sq):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

a, b = map(str, input().split())

n = int(a+b)
sq = np.sqrt(n)
if sq == int(sq):
    print('Yes')
else:
    print('No')

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

a, b = map(str, input().split())

n = int(a+b)
sq = np.aqrt(n)
if sq == int(sq):
    print('Yes')
else:
    print('No')
Problem p03471 (python)

Fixed submission:
import sys

n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    for j in range(n-i+1):
        k = n - i - j
        if i*10000+j*5000+k*1000 == y:
            print(i, j, k)
            sys.exit(0)
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    for j in range(n-i+1):
        k = n - i - j
        if i*10000+j*5000+k*1000 == y:
            print(i, j, k)
            return
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    if flg:
        break
    for j in range(n-i):
        k = n - i - j
        if i*10000+j*5000+k*1000 == y:
            flg = True
            break
if flg:
    print(f'{i} {j} {k}')
else:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())

# n, y = 1000, 1234000

flg = False
for i in range(y//10000 + 1):
    diff_1 = y - i*10000
    for j in range(diff//5000 + 1):
        diff_2 = diff_1 - j*5000
        for k in range(diff//1000 + 1):
            diff_3 = diff_2 - k*1000
            if diff_3 == 0 and i+j+k <= n:
                flg = True
                break
if flg:
    print(i, j, k)
else:
    print(-1, -1, -1)
Problem p03478 (python)

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

ans = []
for i in range(1,n+1):
    num = 0
    for j in str(i):
        num += int(j)
    if a <= num <= b:
        ans.append(i)
print(sum(ans))

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

ans = []
for i in range(1,n+1):
    # i = 12
    num = 0
    while i != 0:
        num +=i%10
        i = i//10
    if a <= num <= b:
        ans.append(i)
print(ans.sum())
Problem p02783 (python)

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

ans=h//a
if(h%a!=0):
    ans+=1
print(ans)

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

ans=h//a
if(h%a!=0):
    ans++
print(ans)
Problem p02789 (python)

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

if m>=n:
    print('Yes\n')
else:
    print('No\n')

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

if m>=n:
    print('Yes\n')
else:
    print('No\n')

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

if m>=n:
    print('Yes\n')
else:
    print('No\n')
Problem p03494 (python)

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

c=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    c+=1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input()))

c=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    c+=1
print(c)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = input()
a = A.split()
s = 1
flag = 0
if "0" in a:
    print(0)
else:
    for i in range(N):
        s *= int(a[i])
        if s > 10**18:
            print(-1)
            flag = 1
            break
    if flag == 0:
        print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input()
a = A.split()
sum = 1
if "0" in a :
    print(0)
else:
    for i in range(N):
        sum *= int(a[i])
        if sum > 10**18:
            print(-1)
            flag = 1
            break
    if flag == 0:
        print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input()
a = A.split()
sum = 1
for i in range(N):
    sum *= int(a[i])
    if sum > 10**18:
        print(-1)
        flag = 1
        break
if flag == 0:
    print(sum)
Problem p02619 (python)

Fixed submission:
import numpy as np


D = int(input())
c = np.array(list( map(int,input().split())))
S = np.zeros((D,26))
for i in range(D):
    S[i] = np.array(list( map(int,input().split())))

T = np.array([])
for i in range(D):
    T = np.append(T,int(input()))

"""
D = 365
c = np.random.randint(0,100,size=(26))
S = np.random.randint(0,20000,size=(D,26))
"""

def calc_score(T,D,c,S):
    last = np.ones(26) * (-1)
    scores = []
    score = 0
    for d in range(D):
        i = int(T[d])-1
        score += S[d,i]
        last[i] = d
        score -= np.sum(c*(d-last))
        scores.append(score)
    score = max([10**6+score,0])
    return score,scores

_,ans = calc_score(T,D,c,S)
for a in ans:
    print(int(a))

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


D = int(input())
c = np.array(list( map(int,input().split())))
S = np.zeros((D,26))
for i in range(D):
    S[i] = np.array(list( map(int,input().split())))

T = np.array([])
for i in range(D):
    T = np.append(T,int(input()))

"""
D = 365
c = np.random.randint(0,100,size=(26))
S = np.random.randint(0,20000,size=(D,26))
"""

def calc_score(T,D,c,S):
    last = np.ones(26) * (-1)
    scores = []
    score = 0
    for d in range(D):
        i = int(T[d])
        score += S[d,i]
        last[i] = d
        score -= np.sum(c*(d-last))
        scores.append(max([10**6+score,0]))
    score = max([10**6+score,0])
    return score,scores

_,ans = calc_score(T,D,c,S)
for a in ans:
    print(int(a))
Problem p02690 (python)

Fixed submission:
X = int(input())

y = int((X**0.2) //1 + 1)

def array(y):
    a = [0]
    for i in range(1,y+1):
        a.append(i**5)
        a.append(-i**5)
    a.sort()
    return a

y = y*2
a = array(y)

N = len(a)
for i in range(N-1):
    for j in range(i+1,N):
        if a[j] - a[i] == X:
            A,B = -y+j, -y+i

print(A,B)

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

y = int((X**0.2)//1 + 1)

def array(y):
    a = [0]
    for i in range(1,y+1):
        a.append(i**5)
        a.append(-i**5)
    a.sort()
    return a

a = array(y)

N = len(a)
for i in range(N-1):
    for j in range(i+1,N):
        if a[j] - a[i] == X:
            A,B = -y+j, -y+i

print(A,B)
Problem p02784 (python)

Fixed submission:
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

hn = input()
H = int(get(hn,2)[0])
N = int(get(hn,2)[1])

a_text = input()
a = get(a_text,N)

s = 0
for i in range(N):
    s = s +  int(a[i])

if s >= H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

hn = input()
H = int(get(hn,2)[0])
N = int(get(hn,2)[1])

a_text = input()
a = get(a_text,N)
for i in range(N):
    a[i] = int(a[i])

def max(a):
    m = a[0]
    k = 0
    for i in range(1,len(a)):
        if a[i] > m:
            m = a[i]
            k = i
    return [m,i]

m1 = max(a)[0]
k1 = max(a)[1]
a.pop(k1)
m2 = max(a)[0]

if m1 + m2 >= H:
    print("Yes")
else:
    print("No")
Problem p02786 (python)

Fixed submission:
H = int(input())

def time(h):
    if h == 1:
        return 1
    elif h > 1:
        return time(h//2)*2 + 1

print(time(H))

Buggy submission (verdict: Runtime Error):
def time(h):
    if h == 1:
        return 1
    else:
        return time(h//2)*2 + 1

print(time(H))
Problem p02621 (python)

Fixed submission:
def solve(string):
    a = int(string)
    return str(a + a**2 + a**3)                                                                                         

if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy submission (verdict: Runtime Error):
def solve(string):
    a = int(string)
    return str(a + a**2 + a**3)                                                                                         

if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~

Buggy submission (verdict: Runtime Error):
def solve(string):
    a = int(string)
    return str(a + a**2 + a**3)                                                                                         

if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~                                                                                                                       ~
Problem p02642 (python)

Fixed submission:
import numpy as np
from collections import Counter


def solve(string):
    n, *a = map(int, string.split())
    table = np.array([True] * (10**6 + 1))
    for _a in a:
        if table[_a]:
            table[2*_a::_a]=False
    i = np.array([k for k,v in Counter(a).items() if v==1],dtype=np.int)
    return str(table[i].sum())


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = sorted(a)
    ans = [a[0]]
    for _a in a[1:]:
        for b in ans:
            if _a % b == 0:
                break
        else:
            ans.append(_a)
    return str(len(ans) - (a[0] == a[1]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Problem p02780 (python)

Fixed submission:
from itertools import accumulate


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:]))) if k < n else str(p[-1])


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

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


def solve(string):
    n, k, *p = map(int, string.split())
    *p, = accumulate((1 + _p) / 2 for _p in p)
    return str(max(p2 - p1 for p1, p2 in zip(p, p[k:])))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    c = 0
    for _a in a:
        if not c:
            while _a % 2 == 0:
                _a //= 2
                c += 1
        else:
            t = 0
            while _a % 2 == 0:
                _a //= 2
                t += 1
            if c != t:
                return "0"
    l = reduce(lcm, a)
    return str(max((m - l // 2) // l + 1, 0))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)


def solve(string):
    n, m, *a = map(int, string.split())
    c = 2**len(bin(a[0]).split("1")[-1])
    l = reduce(lcm, (0 if _a % c or not _a // c % 2 else _a for _a in a))
    return str((m - l // 2) // l + 1) if l else "0"


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Problem p02838 (python)

Fixed submission:
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    ans = 0
    for i, d in enumerate(zip(*a)):
        s = "".join(d).count("1")
        ans += s * (n - s) * pow(2, 59 - i, m)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = ("{:060b}".format(_a) for _a in a)
    m = 10**9 + 7
    ans = 0
    for s in map(str.count("1"), zip(*a)):
        ans <<= 1
        ans += s * (n - s)
        ans %= m
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *a = map(int, string.split())
    a = ["{:060b}".format(_a) for _a in a]
    m = 10**9 + 7
    *s, = map(lambda x: x.count("1"), zip(*a))
    return str(sum(s * (n - _s) * pow(2, 59 - i, m) for i, _s in enumerate(s)) % m)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
Problem p02861 (python)

Fixed submission:
from itertools import permutations
from functools import reduce
from operator import mul


def solve(string):
    n, *xy = map(int, string.split())
    *xy, = zip(*[iter(xy)] * 2)
    return str(
        sum(
            sum(((xy[p0][0] - xy[p1][0])**2 + (xy[p0][1] - xy[p1][1])**2)**0.5
                for p0, p1 in zip(list(i),
                                  list(i)[1:]))
            for i in permutations(range(n), n)) / reduce(mul, range(1, n + 1)))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n)+'\n'.join([input() for _ in range(n)])))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
from functools import reduce
from operator import mul


def solve(string):
    n, *xy = map(int, string.split())
    *xy, = zip(*[iter(xy)] * 2)
    return str(
        sum(
            sum(((xy[p0][0] - xy[p1][0])**2 + (xy[p0][1] - xy[p1][1])**2)**0.5
                for p0, p1 in zip(list(i),
                                  list(i)[1:]))
            for i in permutations(range(n), n)) / reduce(mul, range(1, n + 1)))


if __name__ == '__main__':
    print(solve(input()))
Problem p02900 (python)

Fixed submission:
from fractions import gcd
import numpy as np


def get_primes(n):
    ans = []
    m = int(n**0.5) + 1
    flags = np.zeros(m + 1, dtype=bool)
    for i in range(2, m + 1):
        if flags[i]:
            continue
        while n % i == 0:
            n //= i
        ans.append(i)
        flags[i:m + 1:i] = 1
    if n > 1 and all(map(lambda x: n % x, ans)):
        ans.append(n)
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))

Buggy submission (verdict: Runtime Error):
from fractions import gcd


def get_primes(n):
    ans = []
    flags = [1] * (n + 1)
    for i in range(2, n + 1):
        if flags[i]:
            ans.append(i)
            for j in range(i, n + 1, i):
                flags[j] = 0
    return ans


def solve(string):
    a, b = map(int, string.split())
    g = gcd(a, b)
    return str(len([p for p in get_primes(g) if g % p == 0]) + 1)


if __name__ == '__main__':
    print(solve(input()))
Problem p02923 (python)

Fixed submission:
def solve(string):
    n, *h = map(int, string.split())
    ans = count = 0
    for h0, h1 in zip(h, h[1:]):
        if h0 >= h1:
            count += 1
        else:
            ans = max(ans, count)
            count = 0
    return str(max(ans, count))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()

count = 0
moves = []
for h0, h1 in zip(H,H[1:]):
    if h0 >= h1:
        count += 1
    else:
        moves.append(count)
        count = 0
print(max(moves))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()

start = 0
moves = []
for i, (h0, h1) in enumerate(zip(H,H[1:]), start=1):
    moves.append(i - start)
    if H[i] < H[i+1]:
        start = i + 1
print(max(moves))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
 
if N == 1:
    print(0)
    quit()
 
start = 0
moves = []
for i in range(N-1):
    if H[i] < H[i+1]:
	    moves.append(i - start)
   	    start = i + 1
if H[N-2] >= H[N-1]:
    moves.append(i - start + 1)
print(max(moves))
Problem p02936 (python)

Fixed submission:
from collections import deque


def solve(string):
    n, q, *abpx = map(int, string.split())
    ab, px = abpx[:2 * n - 2], abpx[2 * n - 2:]
    check = [True] * (n + 1)
    t = {i: [] for i in range(n + 1)}
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(px)] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m -1)])))

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


def solve(string):
    n, q, *abpx = map(int, string.split())
    ab, px = abpx[:2 * n - 2], abpx[2 * n - 2:]
    check = [True] * (n + 1)
    t = {i: [] for i in range(n + 1)}
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(px)] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m)])))
Problem p02947 (python)

Fixed submission:
from collections import defaultdict


def solve(string):
    n, *s = string.split()
    d = defaultdict(int)
    for _s in s:
        d["".join(sorted(_s))] += 1
    return str(sum([v * (v - 1) // 2 for v in d.values() if v > 1]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n)+'\n'.join([input() for _ in range(n)])))

Buggy submission (verdict: Runtime Error):
def solve(string):
    n, *ss = string.split()

    d = defaultdict(int)
    for s in ss:
        s = "".join(sorted(s))
        if s in d.keys():
            d[s] += 1 + d[s]
    return str(sum(d.values()))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))