Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
m = []
for i in range(1, N):
    m.append( i % (i+1) )
print(sum(m))

Fixed submission:
N = int(input())
ans = ((N - 1) * N ) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
m = 0
for i in range(1, N):
    m += i % (i+1)
print(m)

Fixed submission:
N = int(input())
ans = ((N - 1) * N ) // 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

l = []
l1 = []
for i in range(1, N):
    l.append(i)
    l1.append(i + 1)
l.append(N)
l1.append(1)
m = 0
for i in range(len(l)):
    m += l[i] % l1[i]
print(m)

Fixed submission:
N = int(input())
ans = ((N - 1) * N ) // 2
print(ans)

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

l = []
l1 = []
for i in range(1, N + 1):
    l.append(i)
for i in range(2, N + 1):
    l1.append(i)
l1.append(1)

m = []
for i in range(len(l)):
    m.append(l[i] % l1[i])
pirnt(sum(m))

Fixed submission:
N = int(input())
ans = ((N - 1) * N ) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
T = N * A

L = [T, B]
min(L)

Fixed submission:
N, A, B = map(int, input().split())
T = N * A

L = [T, B]
print(min(L))
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = map(int, input().split())
d = list(d)

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i < k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)

Fixed submission:
S = str(input())
s = list(S)

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

c0 = S.count(s0)
c1 = S.count(s1)
c2 = S.count(s2)
c3 = S.count(s3)
ct = c0 + c1 + c2 + c3
ct

if ct == 8:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
for i in range(n):
    if d <= x:
        d += l[i]
    else:
        break
print(i)

Fixed submission:
x, a = map(int, input().split())
if x < a :
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
n = n - 1
l_d = []
d = 0
i = 0
l_d.append(d)
d = d + l[i]
while (d <= x) & (i <= n):
    l_d.append(d)
    i += 1
    d = d + l[i]
print(len(l_d))

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
c = 1
for i in l:
    d += i
    if d <= x:
        c += 1
    else:
        break
print(c)

Buggy python submission (verdict: Runtime Error):
d, x = map(int, input().split())
l = list(map(int, input().split()))

l_d = []
d = 0
i = 0
while d <= x:
    l_d.append(d)
    d = d + l[i]
    i += 1
print(len(l_d))

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
c = 1
for i in l:
    d += i
    if d <= x:
        c += 1
    else:
        break
print(c)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))

X = 0
count = 0
while X <= x:
    X = X + l[count]
    count += 1
print(count)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
c = 1
for i in l:
    d += i
    if d <= x:
        c += 1
    else:
        break
print(c)
Buggy python submission (verdict: Runtime Error):
def main():
  M = []
  D = []
  for i in range(2):
    m, d = [int(i) for i in input().split()]
    M.append(m)
    D.append(d)

  if (M[0] != M[1]):
    print(1)
  else:
	print(0)

if __name__ == "__main__":
  main()

Fixed submission:
def main():
  M = []
  D = []
  for i in range(2):
    m, d = [int(i) for i in input().split()]
    M.append(m)
    D.append(d)

  if (M[0] != M[1]):
    print(1)
  else:
    print(0)

main()
Buggy python submission (verdict: Runtime Error):
import math
def main():
  N = int input()
  if (N < 1 || N > 50000):
    print(":(")
    return
  estimatedX1 = math.floor(N / 1.08)
  estimatedX2 = math.ceil(N / 1.08)
  
  if (round.floor(estimatedX1 * 1.08) == N):
    print(round.floor(estimatedX1 * 1.08))
  elif (round.floor(estimatedX2 * 1.08) == N):
    print(round.floor(estimatedX2 * 1.08))
  else:
    print(":(")

main()

Fixed submission:
import math
def main():
  N = int(input())
  if (N < 1 or N > 50000):
    print(":(")

  estimatedX1 = math.floor(N / 1.08)
  estimatedX2 = math.ceil(N / 1.08)
  
  if (math.floor(estimatedX1 * 1.08) == N):
    print(math.floor(estimatedX1))
  elif (math.floor(estimatedX2 * 1.08) == N):
    print(math.floor(estimatedX2))
  else:
    print(":(")

main()
Buggy python submission (verdict: Runtime Error):
ip=input().strip()
while((len)==0):
  ip=input().strip()
m,d=map(int,ip.split())
m1,d1=map(int,input().split())
odd=[1,3,5,7,8,10,12]
eve=[4,6,9,11]
if m in odd:
  if(d==31):
    print(1)
  else:
    print(0)
elif m in even:
  if(d==30):
    print(1)
  else:
    print(0)
else:
  if(d==28):
    print(1)
  else:
    print(0)

Fixed submission:
ip=input().strip()
while((len)==0):
  ip=input().strip()
m,d=map(int,ip.split())
m1,d1=map(int,input().split())
odd=[1,3,5,7,8,10,12]
eve=[4,6,9,11]
if m in odd:
  if(d==31):
    print(1)
  else:
    print(0)
elif m in eve:
  if(d==30):
    print(1)
  else:
    print(0)
else:
  if(d==28):
    print(1)
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')

Fixed submission:
n = input()
s = input()
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')

Buggy python submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print("Yes")
    else:
         print("No")

Fixed submission:
n = input()
s = input()
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')

Buggy python submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print("Yes")
    else:
         print("No")

Fixed submission:
n = input()
s = input()
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')
Buggy python submission (verdict: Runtime Error):
a,b=input().split(" ")
a,b=int(a),int(b)

if(1<=a<=9 & 1<=b<=9):
   print a*b
else:
   pring -1

Fixed submission:

a,b = list(map(int, input().split()))
  
if(1<=a<=9 and 1<=b<=9):
    print(a*b)

else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
a=int(input())

b=int(input())

if(0<=a<=9 & 0<=b<=9):
    print(a*b)

else:
    print(-1)
  
  
  

Fixed submission:

a,b = list(map(int, input().split()))
  
if(1<=a<=9 and 1<=b<=9):
    print(a*b)

else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if(0<=a<=9 and 0<=b<=9):
  print(a*b)
else:
  print(-1)
  

Fixed submission:

a,b = list(map(int, input().split()))
  
if(1<=a<=9 and 1<=b<=9):
    print(a*b)

else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
if(0<=a<=9 and 0<=b<=9):
  print(a*b)
else:
  print(-1)
  

Fixed submission:

a,b = list(map(int, input().split()))
  
if(1<=a<=9 and 1<=b<=9):
    print(a*b)

else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

n1 = N / 1.08

if round(n) == n:
    print(n)
else:
    print(":(")


Fixed submission:
import math
N = int(input())

n1 = N / 1.08

if math.floor(math.floor(n1)*1.08) == N:
    print(math.floor(n1))
elif math.floor(math.floor(n1 + 1)*1.08) == N:
    print(math.floor(n1 + 1))
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
r = int(input)
print("{}".format(r**2))

Fixed submission:
r = int(input())
print("{}".format(int(r**2)))

Buggy python submission (verdict: Runtime Error):
r = int(input)
print(r**2)

Fixed submission:
r = int(input())
print("{}".format(int(r**2)))

Buggy python submission (verdict: Runtime Error):
r = input()
 print(r**2)

Fixed submission:
r = int(input())
print("{}".format(int(r**2)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
string = int(input())

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i, st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Fixed submission:
n = int(input())
string = str(input())

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i, st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Fixed submission:
n = int(input())
string = str(input())

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i, st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        C+=1
print cnt

Fixed submission:
S = input()
T = input()
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import combinations

input = sys.stdin.readline


def main():
    # 種類
    N = int(input())
    S = input().strip()
    print(len(set(combinations(S, 3))))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import combinations

input = sys.stdin.readline


def check_num(text):
    cnt = 0
    for i in range(10):
        index = text.find(str(i))
        if index != -1:
            cnt += 1
    return cnt


def main():
    # 種類
    # N = int(input())
    # S = input().strip()
    S = sum(str(i) for i in range(10))
    for i in range(10):
        index = S.find(str(i))
        if index != -1:
            a = check_num(S[index:])
    # 10個の数字
    # 最大1000件
    # 0-9:0-9:0-9
    # print(len(set(combinations(S, 3))))


def hoge():
    N = int(input())
    S = input().strip()
    count = 0
    for x in range(10):
        xindex = S.find(str(x))
        if xindex == -1:
            continue
        for y in range(10):
            yindex = S[xindex + 1 :].find(str(y))
            if yindex == -1:
                continue
            for z in range(10):
                zindex = S[xindex + 1 :][yindex + 1 :].find(str(z))
                if zindex == -1:
                    continue
                count += 1
    print(count)


if __name__ == "__main__":
    hoge()
Buggy python submission (verdict: Runtime Error):
import sys
import math
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D[1:])
    if D[0] != 0:
        # 頂点1に対しては、0以外有り得ない
        print(0)
        return
    results = [0, count[1]]
    for d in sorted(count.keys())[1:]:
        results.append(results[d - 1] * math.factorial(count[d]))
    print(sum(results[2:]) % 998244353)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D)
    result = 1
    if D[0] != 0 or count[0] != 1:
        print(0)
        return
    for i in range(max(D)):
        result *= count[i] ** count[i + 1]
    print(result % 998244353)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            print(l, a, b, j, index, index - j - 1)
            hoge += index - j - 1
    print(hoge)
    # sum([str(i) for i in


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = []
    for a, b in itertools.combinations(l, 2):
        target = l[:]
        target.remove(a)
        target.remove(b)
        hoge += [sorted([a, b, c]) for c in filter(lambda x: b - a < x < a + b, target)]
    print(len(set(["{}{}{}".format(a, b, c) for a, b, c in hoge])))
    # sum([str(i) for i in


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    hoge = 0
    for a, b, c in itertools.combinations(l, 3):
        if a < b + c and b < c + a and c < a + b:
            hoge += 1
    print(hoge)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    while n % 2 == 0:
        n //= 2
        primes.append(2)
    for i in range(3, n + 1, 2):
        while n % i == 0:
            n //= i
            primes.append(i)
        if n == 1:
            break
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()


Fixed submission:
import fractions
import sys

input = sys.stdin.readline


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


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()

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

input = sys.stdin.readline


def primesfrom2to(n):
    """ Input n>=6, Returns a array of primes, 2 <= p < n """
    sieve = np.ones(n // 3 + (n % 6 == 2), dtype=np.bool)
    for i in range(1, int(n ** 0.5) // 3 + 1):
        if sieve[i]:
            k = 3 * i + 1 | 1
            sieve[k * k // 3 :: 2 * k] = False
            sieve[k * (k - 2 * (i & 1) + 4) // 3 :: 2 * k] = False
    return np.r_[1, 2, 3, ((3 * np.nonzero(sieve)[0][1:] + 1) | 1)]


def main():
    a, b = list(map(int, input().split()))
    # 10 ** 12
    # 愚直だと公約数を求めるだけでも時間切れする
    # 互いに素な公約数がほぼ素数などでは？
    g = fractions.gcd(a, b)
    print(len([i for i in primesfrom2to(g) if g % i == 0]))


if __name__ == "__main__":
    main()


Fixed submission:
import fractions
import sys

input = sys.stdin.readline


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


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    print(
        Counter(accumulate([H[i] < H[i + 1] for i in range(n - 1)])).most_common(1)[0][
            1
        ]
        - 1
    )


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    if n == 1:
        print(0)
        return
    # 連続した場合、同値
    acc = list(accumulate([H[i] < H[i + 1] for i in range(n - 1)]))
    x, y = Counter(acc).most_common(1)[0]
    print(y if x == 0 else y - 1)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def get_children(parent, child_dict):
    children = child_dict.get(parent, [])
    for child in children:
        yield from get_children(child, child_dict)
    yield parent


def main():
    n, q = [int(i) for i in input().split()]
    scores = [0 for i in range(n)]
    lines = [[int(i) for i in input().split()] for _ in range(n - 1)]
    counter = [[int(i) for i in input().split()] for _ in range(q)]
    child_dict = {}
    for parent, child in lines:
        if parent not in child_dict:
            child_dict[parent] = [child]
        else:
            child_dict[parent].append(child)
    for parent, count in counter:
        for child in get_children(parent, child_dict):
            scores[child - 1] += count
    print(' '.join(map(str, scores)))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
 
input = sys.stdin.readline
 
 
def main():
    n, q = [int(i) for i in input().split()]
    scores = [0] * (n + 1)
    lines = sorted([[int(i) for i in input().split()] for _ in range(n - 1)])
    counter = [[int(i) for i in input().split()] for _ in range(q)]
    for index, score in counter:
        scores[index] += score
 
    for a, b in lines:
        scores[b] += scores[a]
    print(*scores[1:])
 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import reduce
from operator import mul

input = sys.stdin.readline


# def c(num):
#     return reduce(mul, range(1, num + 1))
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


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        txt_cnt = lines.count(text)
        if txt_cnt == 1:
            continue
        count += cmb(txt_cnt, 2)
    print(count)


if __name__ == "__main__":
    main()


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

input = sys.stdin.readline


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


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import math

input = sys.stdin.readline


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        txt_cnt = lines.count(text)
        count += int(math.factorial(txt_cnt) / math.factorial(txt_cnt - 2)) // 2
    print(count)


if __name__ == "__main__":
    main()


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

input = sys.stdin.readline


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


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from itertools import combinations

input = sys.stdin.readline


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        count += len([_ for _ in combinations(range(lines.count(text)), 2)])
    print(count)


if __name__ == "__main__":
    main()


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

input = sys.stdin.readline


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


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    # マスの高さを1つ引くくすること
    # なにもしない
    # 単調非減少ってなんだ
    # 左より低くならないようにすれば良いっぽいな
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No
    # 1 100 1 1 -> 1 99 1 1 -> No
    #

    cnt = 0
    # とりあえず、愚直に書いてみる
    a = None
    b = H[0]
    for i in range(1, n + 1):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print("Yes" if cnt <= 1 else "No")


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()