Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

for i in reversed(range(N)):
    if S[i] == ")":
        tmp = i
        break
left = ""
for i in range(N-tmp-1):
    left += ")"

migi_kakko = 0
hidari_kakko = 0
for i in range(tmp+1):
    if S[i] == ")":
        migi_kakko += 1
    else:
        hidari_kakko += 1

right = ""
for i in range(migi_kakko-hidari_kakko):
    right += "("
for i in range(hidari_kakko-migi_kakko):
    left += ")"

ans = ""
ans += right
ans += S
ans += left
print(ans)


Fixed submission:
# 始めカッコの個数を先に確定させる
# ある特定の時点で")"の方が多いなら、あとから"("が出て来ても遅い
ans = 0  # これの最小値になった絶対値分を文頭につける
N = int(input())
S = input()
hazimekakko = 0
owarikakko = 0
for i in range(N):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1
    ans = max(ans, owarikakko-hazimekakko)
# 終わりかっこの方が多いタイミングのその量を確定させる
S = abs(ans)*"(" + S

hazimekakko = 0
owarikakko = 0
for i in range(len(S)):
    if S[i] == "(":
        hazimekakko += 1
    else:
        owarikakko += 1

S = S + (hazimekakko-owarikakko)*")"
print(S)
Buggy python submission (verdict: Runtime Error):
import itertools


N, M = map(int, input().split())
graph = [[False]*N for _ in range(M)]

for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a][b] = True
    graph[b][a] = True

ans = 0
for x in itertools.permutations(range(1, N)):
    # このxの順番で訪問できるか確かめる
    flag = True
    now = 0
    for e in x:
        if not graph[now][e]:
            flag = False
        now = e
    if flag:
        ans += 1
print(ans)


Fixed submission:
def dfs(visited, s):  #
    global ans
    visited[s] = True
    for t in graph[s]:
        if not visited[t]:
            dfs(visited[:], t)
    if all(visited):
        ans += 1


N, M = map(int, input().split())  # N頂点, M辺存在する

graph = [[] for _ in range(N)]
visited = [False] * N

for _ in range(M):  # M辺を受け取る
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)


ans = 0
dfs(visited, 0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z == S:
                ans += 1

print(ans)


Fixed submission:
K, S = map(int, input().split())

ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S-x-y >= 0 and S-x-y <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)


Fixed submission:
from collections import Counter
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N % 2 != 0:  # 奇数の場合
    count = Counter(A)
    now_key = 2
    for k, v in count.items():
        if k == 0:
            if v != 1:
                print(0)
                exit()
        else:
            if k != now_key or v != 2:
                print(0)
                exit()
            now_key += 2
    print(2**(N//2) % mod)
else:  # 偶数の場合
    count = Counter(A)
    now_key = 1
    for k, v in count.items():
        if k != now_key or v != 2:
            print(0)
            exit()
        now_key += 2
    print(2**(N//2) % mod)
Buggy python submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if ((mask >> i) & 1):
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"

print(int(eval(ans[:-1])))


Fixed submission:
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)

Buggy python submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(int(eval(ans[:-1])))


Fixed submission:
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)

Buggy python submission (verdict: Runtime Error):
S = str(input())

ans = ""

for mask in range(1 << (len(S)-1)):
    for i in range(len(S)):
        if (mask >> i) & 1:
            ans += f"{S[i]}+"
        else:
            ans += f"{S[i]}"
    ans += "+"
print(eval(ans[:-1]))


Fixed submission:
S = list(input())
ans = 0

for state in range(1 << len(S)-1):
    ans += eval(S[0] + ''.join(('+' if state >> i & 1 else '') + x for i, x in enumerate(S[1:])))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, A = map(int, input().split())  # N枚数のカード, 平均をAにしたい
X = tuple(map(int, input().split()))  # N枚のカードの中身

dp = [[[0]*(50*N+2) for _ in range(N+2)] for _ in range(N+2)]

dp[0][0][0] = 1  # 0枚の中から0枚選んで合計が0になる選び方が1通りある

for i in range(N):
    for j in range(N+1):
        for k in range(50*N+1):
            # if dp[i][j][k]:  # ここの分岐が分からん
            if k+X[i] < 50*N+2:
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
print(ans)


Fixed submission:
N, A = map(int, input().split())  # N枚数のカード, 平均をAにしたい
X = tuple(map(int, input().split()))  # N枚のカードの中身

dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1  # 0枚の中から0枚選んで合計が0になる選び方が1通りある

for i in range(N):
    for j in range(N+1):
        for k in range(50*N+1):
            if dp[i][j][k]:  # そのパターン数が0になっている場所からの遷移はありえない！！！
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = str(input())

left = -2
right = -2

for i in range(max(1, len(S)-2)):
    if S[i] == S[i+1]:
        left = i
        right = i+1
        break
    if S[i] == S[i+2]:
        left = i
        right = i+2
        break
    if S[i+1] == S[i+2]:
        left = i+1
        right = i+2
        break

print(left+1, right+1)


Fixed submission:
S = str(input())

left = -2
right = -2

for i in range(max(1, len(S)-2)):
    if S[i] == S[i+1]:
        left = i
        right = i+1
        break
    if len(S) == 2:
        break
    if S[i] == S[i+2]:
        left = i
        right = i+2
        break
    if S[i+1] == S[i+2]:
        left = i+1
        right = i+2
        break

print(left+1, right+1)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())

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

ans_index = -1
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        ans_index = i
        break

if ans_index == -1:
    print('Impossible')
    exit()
print('Possible')

ans_index += 1
for i in range(1, ans_index):
    print(i)
for i in range(N-1, n, -1):
    print(i)

print(ans_index)


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

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

ans_index = -1
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        ans_index = i
        break

if ans_index == -1:
    print('Impossible')
    exit()
print('Possible')

ans_index += 1
for i in range(1, ans_index):
    print(i)
for i in range(N-1, ans_index, -1):
    print(i)

print(ans_index)

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

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

ans_index = -1
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        ans_index = i
        break

ans = list(range(1, i)).extend(list(i+1, N-1)).append(ans_index)

if ans_index == -1:
    print('Impossible')
else:
    for i in range(len(ans)):
        print('Possible')
        print(ans[i]) 

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

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

ans_index = -1
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        ans_index = i
        break

if ans_index == -1:
    print('Impossible')
    exit()
print('Possible')

ans_index += 1
for i in range(1, ans_index):
    print(i)
for i in range(N-1, ans_index, -1):
    print(i)

print(ans_index)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aa = tuple(map(int, input().split()))

MOD = 10 ** 9 + 7

ans = 0
for i in range(n):
    ans += aa[i] * sum(aa[i + 1:])
    ans %= MOD
print(ans)

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

MOD = 10 ** 9 + 7

ans = 0
x = sum(aa)
for i in range(n):
    x -= aa[i]
    ans += aa[i] * x
    ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
aa = tuple(map(int, input().split()))

s = 1
ps = 1
for i in range(n):
    s *= aa[i]
    if i >= k:
        s //= aa[i - k]
        if ps < s:
            print('Yes')
        else:
            print('No')
    ps = s


Fixed submission:
n, k = map(int, input().split())
aa = tuple(map(int, input().split()))

for i in range(k, n):
    if aa[i - k] < aa[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
aa = tuple(map(int, input().split()))

s = 1
ps = 1
for i in range(n):
    s *= aa[i]
    if i >= k:
        s //= aa[i - k]
        if ps < s:
            print('Yes')
        else:
            print('No')
    ps = s


Fixed submission:
n, k = map(int, input().split())
aa = tuple(map(int, input().split()))

for i in range(k, n):
    if aa[i - k] < aa[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aa = tuple(map(int, input().split()))

def dfs(money, stock, i):
    global aa
    global n

    if i == n:
        return money

    ns = money // aa[i]
    return max(
        dfs(money, stock, i + 1),
        dfs(money + stock * aa[i], 0, i + 1),
        dfs(money - aa[i] * ns, stock + ns, i + 1)
    )

ans = dfs(1000, 0, 0)
print(ans)

Fixed submission:
from collections import defaultdict

n = int(input())
aa = tuple(map(int, input().split()))

x = {0: 1000}
for i in range(n):
    xx = defaultdict(int)
    for stock, money in x.items():
        xx[0] = max(xx[0], money + stock * aa[i])
        ns = money // aa[i]
        xx[stock + ns] = max(xx[stock + ns], money - ns * aa[i])
    x = xx
print(x[0])
Buggy python submission (verdict: Runtime Error):
d = int(input())
c = tuple(map(int, input().split()))
s = [
    tuple(map(int, input().split()))
    for _ in range(d)
]

m = 0
ans = []
last = [0] * 26
for i in range(d):
    # for all contest
    mdmax = 0
    mdi = 0
    for j, ss in enumerate(s[i]):
        md = 0
        # choose one contest to open
        for k in range(26):
            if j == k:
                md += s[i][j]
            else:
                md -= (i - last[k]) * c[i]
        if md > mdmax:
            mdi = j
            mdmax = md
    ans.append(mdi + 1)
    for j in range(26):
        if j == mdi:
            last[j] = 0
        else:
            last[j] += 1

for a in ans:
    print(a)

Fixed submission:
d = int(input())
c = tuple(map(int, input().split()))
s = [
    tuple(map(int, input().split()))
    for _ in range(d)
]

for i in range(d):
    m = sorted((ss, j) for j, ss in enumerate(s[i]))[-1]
    print(m[1] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
aa = tuple(sorted(map(int, input().split())))
cnt = Counter(aa)

ans = 0
for i in range(n - 1, -1, -1):
    if cnt[aa[i]] > 1:
        continue

    f = True
    for j in range(i):
        if aa[i] < aa[j] * 2:
            break
        if aa[i] % aa[j] == 0:
            f = False
            break
    if f:
        ans += 1
print(ans)

Fixed submission:
from collections import Counter

n = int(input())
aa = tuple(sorted(map(int, input().split())))
cnt = Counter(aa)
amax = max(aa)
af = [False] * (amax + 1)

ans = 0
for i in range(n):
    x = aa[i]
    if af[x]:
        continue
    while x <= amax:
        af[x] = True
        x += aa[i]
    if cnt[aa[i]] == 1:
        ans += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
aa = tuple(reversed(sorted(map(int, input().split()))))
cnt = Counter(aa)

ans = 0
for i in range(n):
    if cnt[aa[i]] > 1:
        continue

    f = True
    for j in range(i + 1, n):
        if aa[i] % aa[j] == 0:
            f = False
            break
    if f:
        ans += 1
print(ans)

Fixed submission:
from collections import Counter

n = int(input())
aa = tuple(sorted(map(int, input().split())))
cnt = Counter(aa)
amax = max(aa)
af = [False] * (amax + 1)

ans = 0
for i in range(n):
    x = aa[i]
    if af[x]:
        continue
    while x <= amax:
        af[x] = True
        x += aa[i]
    if cnt[aa[i]] == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = tuple(map(int, input().split()))
x = 1
for aa in a:
    x *= aa
if x > 10 ** 18:
    print(-1)
else:
    print(x)


Fixed submission:
n = int(input())
a = tuple(sorted(map(int, input().split())))
x = 1
for aa in a:
    x *= aa
    if x > 10 ** 18:
        print(-1)
        exit(0)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

n, s = map(int, input().split())
aa = tuple(sorted(map(int, input().split())))

MOD = 998244353
dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        # 選ばない場合
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD

        # j + a[i]を選んだ場合
        if j + aa[i] <= s:
            dp[i + 1][j + aa[i]] += dp[i][j]
            dp[i + 1][j + aa[i]] %= MOD
print(dp[n][s])

Fixed submission:
from collections import defaultdict

n, s = map(int, input().split())
aa = tuple(sorted(map(int, input().split())))

MOD = 998244353
dp = [[0 for i in range(s + 1)] for j in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s + 1):
        # 選ばない場合
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD

        # j + a[i]を選んだ場合
        if j + aa[i] <= s:
            dp[i + 1][j + aa[i]] += dp[i][j]
            dp[i + 1][j + aa[i]] %= MOD
print(dp[n][s])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = [None] * 200000
p = 0
st = 0
ed = 0
i = 0
while True:
    c[i] = p
    i += 1
    p = a[p]
    if p in c:
        st = c.index(p)
        ed = i
        break
if k < ed:
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[st + k] + 1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = [None] * 200000
cc = set()
p = 0
st = 0
ed = 0
i = 0
while True:
    c[i] = p
    cc.add(p)
    i += 1
    p = a[p]
    if p in cc:
        st = c.index(p)
        ed = i
        break
if k < ed:
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[st + k] + 1)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = []
p = 0
na = 0
st = 0
ed = 0
while True:
    c.append(p)
    p = a[p]
    na += 1
    if p in c:
        st = p
        ed = len(c)
        break
if k < len(c):
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[k] + 1)

Fixed submission:
n, k = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))

c = [None] * 200000
cc = set()
p = 0
st = 0
ed = 0
i = 0
while True:
    c[i] = p
    cc.add(p)
    i += 1
    p = a[p]
    if p in cc:
        st = c.index(p)
        ed = i
        break
if k < ed:
    print(c[k] + 1)
else:
    k -= st
    k %= ed - st
    print(c[st + k] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())

tb = [
    [math.gcd(a, b) for a in range(0, 201)]
    for b in range(0, 201)
]

x = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        t = tb[min(a, b)][max(a, b)]
        for c in range(1, k + 1):
            x += tb[min(t, c)][max(t, c)]
print(x)


Fixed submission:
import math

k = int(input())

tb = [
    [math.gcd(a, b) for a in range(0, 201)]
    for b in range(0, 201)
]

x = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        t = tb[a][b]
        for c in range(1, k + 1):
            x += tb[t][c]
print(x)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print(f"{c} {a} {b}")

Fixed submission:
a, b, c = map(int, input().split())
print("{} {} {}".format(c, a, b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
aa = tuple(map(int, input().strip()))
if len(set(aa)) == n:
    print("YES")
else:
    print("NO")

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

if len(a) == len(set(a)):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
s, t = list(input().split().rstrip())
print(t + s)


Fixed submission:
s, t = input().rstrip().split()
print(t + s)

Buggy python submission (verdict: Runtime Error):
s, t = input().split().rstrip()
print(t + s)


Fixed submission:
s, t = input().rstrip().split()
print(t + s)
Buggy python submission (verdict: Time Limit Exceeded):
import math

x = int(input())

primes = []

for n in range(2, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)


Fixed submission:
import math

x = int(input())

primes = []

if x == 2:
    print(2)
    exit(0)

for n in range(3, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
#import math

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

Fixed submission:
from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))

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

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

Fixed submission:
from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))

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

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))


Fixed submission:
from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))

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

a, b = map(int, input().split())
print(a * b // math.gcd(a, b))

Fixed submission:
from fractions import gcd
#from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
Buggy python submission (verdict: Runtime Error):
n = int(input()):
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            print("Yes")
            exit(0)
print("No")

Fixed submission:
n = int(input())
for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            print("Yes")
            exit(0)
print("No")
Buggy python submission (verdict: Runtime Error):
import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n //= x
    return s

a, b = map(int, input().split())
print(len(divisors(math.gcd(a, b))) + 1)


Fixed submission:
import math

def divisors(n):
    s = set()
    for x in range(2, math.ceil(n ** 0.5) + 1):
        while n % x == 0:
            s.add(x)
            n /= x
            if n == 1:
                break
    if n > 1:
        s.add(n)
    return s
 
a, b = map(int, input().split())
d = divisors(a) & divisors(b)
print(len(d) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a = []
for _ in range(q):
    a.append(int(input()) - 1)

s = [k] * n
for i in range(q):
    for j in range(n):
        if a[i] != j:
            s[j] -= 1

for i in range(n):
    if s[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())
win = [0] * n
for _ in range(q):
    win[int(input()) - 1] += 1

for i in range(n):
    if k - q + win[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
hh = list(map(int, input().split()))

ans = 0
for i in range(n - 1, 0, -1):
    x = 1
    while i + x < n and hh[i + x - 1] >= hh[i + x]:
        x += 1
    ans = max(ans, x - 1)
print(ans)


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

ans = 0
x = 0
for i in range(1, n):
    if h[i - 1] >= h[i]:
        x += 1
    else:
        x = 0
    ans = max(ans, x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
s = []
for i in range(n):
    ss = input()
    s.append(collections.Counter(list(ss)))
ans = 0
for i in range(len(s)):
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            ans += 1
print(ans)

Fixed submission:
import collections
import math

n = int(input())
s = []
for i in range(n):
    ss = input()
    s.append(tuple(sorted(collections.Counter(list(ss)).items())))
s = sorted(s)

ans = []
px = None
a = 0
for x in s:
    if x == px:
        a += 1
    else:
        px = x
        if a > 0:
            ans.append(a + 1)
        a = 0
if a > 0:
    ans.append(a + 1)
print(sum([math.factorial(a) // (2 * math.factorial(a - 2)) for a in ans]))
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input())
print(min(a * n, b))

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

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input())
print(min(a * n, b))

Fixed submission:
n, a, b = map(int, input().split())
print(min(a * n, b))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
pp = tuple(sorted(map(int, input().split())))
intv = []
for i in range(1, len(pp)):
    intv.append(pp[i] - pp[i - 1])
intv = sorted(intv)

ans = pp[-1] - pp[0]
for i in range(n - 1):
    ans -= intv[-i - 1]
print(ans)

Fixed submission:
n, k = map(int, input().split())
pp = tuple(sorted(map(int, input().split())))

if n >= k:
    print(0)
    exit(0)

intv = []
for i in range(1, len(pp)):
    intv.append(pp[i] - pp[i - 1])
intv = sorted(intv)

ans = pp[-1] - pp[0]
for i in range(n - 1):
    ans -= intv[-i - 1]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = tuple(map(int, input().split()))
c1 = Counter(v[::2])
c2 = Counter(v[1::2])
if len(set(v)) == 1:
    print(n // 2)
else:
    c1m = c1.most_common(1)
    c2m = c2.most_common(1)
    if c1m[0][0] == c2m[0][0]:
        print(min(n - c1m[0][1] - c2m[1][1], n - c1m[1][1] - c2m[0][1]))
    else:
        print(n - c1m[0][1] - c2m[0][1])


Fixed submission:
from collections import Counter
n = int(input())
v = tuple(map(int, input().split()))
c1 = Counter(v[::2])
c2 = Counter(v[1::2])
if len(set(v)) == 1:
    print(n // 2)
else:
    c1m = c1.most_common(2)
    c2m = c2.most_common(2)
    if c1m[0][0] == c2m[0][0]:
        print(min(n - c1m[0][1] - c2m[1][1], n - c1m[1][1] - c2m[0][1]))
    else:
        print(n - c1m[0][1] - c2m[0][1])