Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
  	flg = True
    break
print("NO") if flg else print("YES")


Fixed submission:
str1, str2 = input().split()
num1, num2 = map(int,input().split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d"  %(num1, num2))

Buggy python submission (verdict: Runtime Error):
str1, str2 = input().split()
num1, num2 = map(int,input.split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d",%(num1, num2))

Fixed submission:
str1, str2 = input().split()
num1, num2 = map(int,input().split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d"  %(num1, num2))

Buggy python submission (verdict: Runtime Error):
str1, str2 = input().split()
num1, num2 = map(int,input.split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d",%(num1, num2))

Fixed submission:
str1, str2 = input().split()
num1, num2 = map(int,input().split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d"  %(num1, num2))

Buggy python submission (verdict: Runtime Error):
str1, str2 = input().split()
num1, num2 = map(int,input.split())
trim = input()

if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1

print("%d %d",%(num1, num2))


Fixed submission:
str1, str2 = input().split()
num1, num2 = map(int,input().split())
trim = input()
 
if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1
 
print("%d %d"  %(num1, num2))
Buggy python submission (verdict: Time Limit Exceeded):
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
    flg = True
    break
print("NO") if flg else print("YES")


Fixed submission:
num = input()
list = list(map(int,input().split()))
list2 = set(list) 
print("YES") if len(list) == len(list2) else print("NO")

Buggy python submission (verdict: Runtime Error):
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
	flg = True
	break
print("NO") if flg else print("YES")


Fixed submission:
num = input()
list = list(map(int,input().split()))
list2 = set(list) 
print("YES") if len(list) == len(list2) else print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
num = input()
list = list(map(int,input().split()))
flg  = False
for i in list:
  if list.count(i) >= 2:
  	flg = True
print("NO") if flg else print("YES")

Fixed submission:
num = input()
list = list(map(int,input().split()))
list2 = set(list) 
print("YES") if len(list) == len(list2) else print("NO")
Buggy python submission (verdict: Runtime Error):
enemy, num = input().split()
skills = list(map(input().split()))
print("Yes") if max(skills) >= enemy else print("No")

Fixed submission:
enemy, num = map(int,input().split())
skills = list(map(int,input().split()))
print("Yes") if sum(skills) >= enemy else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
list = list(map(int,input().split()))
count = 0
for i, val in enumerate(list):
  if min(list[0:i+1]) >= val:
    count += 1
print("%d"%(count))

Fixed submission:
n = int(input())
list = list(map(int,input().split()))
count = 0
minimum = list[0]
for i in range(n):
  if minimum >= list[i]:
    count += 1
    minimum = list[i]

print("%d"%(count))

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
list = list(map(int,input().split()))
count = 0
for i, val in enumerate(list):
  if min(list[0:i+1]) >= val:
    count += 1
print("%d"%(count))

Fixed submission:
n = int(input())
list = list(map(int,input().split()))
count = 0
minimum = list[0]
for i in range(n):
  if minimum >= list[i]:
    count += 1
    minimum = list[i]

print("%d"%(count))
Buggy python submission (verdict: Runtime Error):
num_list = list(input())
count = 0
if num[0] == "1": count +=1 
if num[1] == "1": count +=1 
if num[2] == "1": count +=1 
print(str(count))

Fixed submission:
num_list = list(input())
count = 0
if num_list[0] == "1": count +=1 
if num_list[1] == "1": count +=1 
if num_list[2] == "1": count +=1 
print(str(count))
Buggy python submission (verdict: Time Limit Exceeded):
x=input()
x=int(x)
while True:
  for i in range(2, int(x/2)):
    if x%i==0:
      x+=1
      break
    else:
      print(x)

Fixed submission:
def waru(x):
  for i in range(2, x):
    if x%i==0:
      return 1
    if i==x-1:
      return 2
x=input()
x=int(x)
while True:
  if waru(x)==1:
    x+=1
  else:
    print(x)
    break
Buggy python submission (verdict: Runtime Error):
D,N=input().split()
print(100**D*5)

Fixed submission:
D,N=map(int,input().split())
if N<100:
  print(100**D*N)
  exit()
print(100**D*101)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

MOD = 998244353


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    lr = [tuple(map(int, input().split())) for _ in range(k)]
    dp = Bit(n)
    dp.add(1, 1)
    for i in range(2, n + 1):
        for l, r in lr:
            if i - l < 1:
                continue
            if i - r < 2:
                dp.add(i, dp.sum(i - l) % MOD)
            else:
                dp.add(i, (dp.sum(i - l) - dp.sum(i - r - 1)) % MOD)
    print((dp.sum(n) - dp.sum(n - 1)) % MOD)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

MOD = 998244353


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    lr = [tuple(map(int, input().split())) for _ in range(k)]
    dp = Bit(n)
    dp.add(1, 1)
    for i in range(2, n + 1):
        for l, r in lr:
            if i - l < 1:
                continue
            if i - r < 2:
                dp.add(i, dp.sum(i - l) % MOD)
            else:
                dp.add(i, (dp.sum(i - l) - dp.sum(i - r - 1)) % MOD)
    print((dp.sum(n) - dp.sum(n - 1)) % MOD)


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


def main():
    input = sys.stdin.buffer.readline
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    num_a = 0
    while num_a <= n:
        # Aの上からi冊の和
        s = sum(a[:num_a])
        if s > k:
            break
        # Bから読める本の数
        for j in range(len(b)):
            if s + b[j] <= k:
                s += b[j]
            else:
                num_b = j
                break
        else:
            num_b = len(b)
        if num_a + num_b > ans:
            ans = num_a + num_b
        num_a += 1

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n, m, k = map(int, input().split())
    a = [0] + list(map(int, input().split()))
    b = [0] + list(map(int, input().split()))
    a = list(accumulate(a))
    b = list(accumulate(b))
    ans = 0
    num_b = m
    for num_a in range(n + 1):
        sum_a = a[num_a]
        if sum_a > k:
            break
        while sum_a + b[num_b] > k:
            num_b -= 1
        ans = max(num_a + num_b, ans)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import permutations
input = sys.stdin.readline
N = int(input())
S = [input().rstrip('\n') for _ in range(N)]
sum_list = [0] * N
min_list = [0] * N
all_sum = 0
for i in range(N):
    sum = 0
    min = 10**7
    for c in S[i]:
        sum += 1 if c == '(' else -1
        if c == ')' and sum < min:
            min = sum
    sum_list[i], min_list[i] = (sum, min)
    all_sum += sum
if all_sum != 0:
    print('No')
else:
    fin = False
    for p in permutations(range(N), N):
        sum = 0
        for i in p:
            if sum + min_list[i] < 0:
                break
            sum += sum_list[i]
        else:
            print('Yes')
            fin = True
            break
    if not fin:
        print('No')

Fixed submission:
S = input()
T = input()
print('Yes' if T[:len(T) - 1] == S else 'No')

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            fin = True
            break
        check[index] = count
        count += 1
        index = a[index]

if not fin: 
    if (K + 1 - start) % len(loop[start:]) == 0:
        print(loop[-1] + 1)
    else:
        print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


Fixed submission:
S = input()
T = input()
print('Yes' if T[:len(T) - 1] == S else 'No')

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
			exit()
        check[index] = count
        count += 1
        index = a[index]


if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


Fixed submission:
S = input()
T = input()
print('Yes' if T[:len(T) - 1] == S else 'No')
Buggy python submission (verdict: Runtime Error):

N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            sys.exit()
        check[index] = count
        count += 1
        index = a[index]


if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            fin = True
            break
        check[index] = count
        count += 1
        index = a[index]

if not fin:  # len(loop)<=K
    if (K + 1 - start) % len(loop[start:]) == 0:
        print(loop[-1] + 1)
    else:
        print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
			exit()
        check[index] = count
        count += 1
        index = a[index]


if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)


Fixed submission:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            fin = True
            break
        check[index] = count
        count += 1
        index = a[index]

if not fin:  # len(loop)<=K
    if (K + 1 - start) % len(loop[start:]) == 0:
        print(loop[-1] + 1)
    else:
        print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)
Buggy python submission (verdict: Runtime Error):
import sys
from numba import njit
input = sys.stdin.buffer.readline


@njit
def main():
    K = int(input())
    A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            return 0
    print('NG')
    return 0


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline

K = int(input())

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


def main(K, A, B):
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')


if __name__ == '__main__':
    main(K, A, B)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
 
 
def main():
    K = int(input())
    A, B = map(int, input().split())
	for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')
 
 
if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.buffer.readline

K = int(input())

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


def main(K, A, B):
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')


if __name__ == '__main__':
    main(K, A, B)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline


def main():
  	K = int(input())
	A, B = map(int, input().split())
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.buffer.readline

K = int(input())

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


def main(K, A, B):
    for i in range(A, B + 1):
        if i % K == 0:
            print('OK')
            sys.exit()
    print('NG')


if __name__ == '__main__':
    main(K, A, B)
Buggy python submission (verdict: Runtime Error):
import sys
from itertools import combinations_with_replacement
from numba import njit


@njit('(i8,i8,i8[:,:])')
def solve(n, m, query):
    li = [0] * m
    for i in range(1, m + 1):
        li[i - 1] = i
    max_point: int = 0
    for a in combinations_with_replacement(li, n):
        point = 0
        for qer in query:
            if a[qer[1] - 1] - a[qer[0] - 1] == qer[2]:
                point += qer[3]
        if point > max_point:
            max_point = point
    print(max_point)


def main():
    input = sys.stdin.buffer.readline
    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    solve(n, m, query)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import combinations_with_replacement


def main():
    input = sys.stdin.buffer.readline
    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    li = [0] * m
    for i in range(1, m + 1):
        li[i - 1] = i
    max_point = 0
    for a in combinations_with_replacement(li, n):
        point = 0
        for qer in query:
            if a[qer[1] - 1] - a[qer[0] - 1] == qer[2]:
                point += qer[3]
        if point > max_point:
            max_point = point
    print(max_point)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
from itertools import combinations_with_replacement
from numba import njit


@njit('(i8,i8,i8[:,:])')
def solve(n, m, query):
    li = [i for i in range(1, m + 1)]
    max_point: int = 0
    for a in combinations_with_replacement(li, n):
        point = 0
        for qer in query:
            if a[qer[1] - 1] - a[qer[0] - 1] == qer[2]:
                point += qer[3]
        if point > max_point:
            max_point = point
    print(max_point)


def main():
    input = sys.stdin.buffer.readline
    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    solve(n, m, query)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import combinations_with_replacement


def main():
    input = sys.stdin.buffer.readline
    n, m, q = map(int, input().split())
    query = [list(map(int, input().split())) for _ in range(q)]
    li = [0] * m
    for i in range(1, m + 1):
        li[i - 1] = i
    max_point = 0
    for a in combinations_with_replacement(li, n):
        point = 0
        for qer in query:
            if a[qer[1] - 1] - a[qer[0] - 1] == qer[2]:
                point += qer[3]
        if point > max_point:
            max_point = point
    print(max_point)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):

def main():
    s = input()
    cnt = 0
    for i in range(len(s) - 4):
        for j in range(i + 4, len(s)):
            if int(s[i:j + 1]) % 2019 == 0:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter


def main():
    MOD = 2019
    s = input()
    n = len(s)
    t = [0] * (n + 1)
    # n-1,n-2,...,0
    for i in range(n - 1, -1, -1):
        t[i] = t[i + 1] + pow(10, n - i - 1, MOD) * int(s[i])
        t[i] %= MOD
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v * (v - 1) // 2
    print(cnt)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

def main():
    s = input()
    cnt = 0
    for i in range(len(s) - 3):
        for j in range(i + 3, len(s)):
            if int(s[i:j + 1]) % 2019 == 0:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter


def main():
    MOD = 2019
    s = input()
    n = len(s)
    t = [0] * (n + 1)
    # n-1,n-2,...,0
    for i in range(n - 1, -1, -1):
        t[i] = t[i + 1] + pow(10, n - i - 1, MOD) * int(s[i])
        t[i] %= MOD
    c = Counter(t)
    cnt = 0
    for v in c.values():
        cnt += v * (v - 1) // 2
    print(cnt)


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


def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i])
    print(min(dp[h:]))


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i])
    print(min(dp[h:]))


if __name__ == "__main__":
    main()

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


def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], min(dp[max(j - a[i], 0) : j]) + b[i])
    print(min(dp[h:]))


if __name__ == "__main__":
    main()


Fixed submission:
import sys


def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i])
    print(min(dp[h:]))


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


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    s = input().strip().decode()
    ans = 0
    for p in product(range(10), repeat=3):
        matched = 0
        for i in range(n):
            if s[i] == str(p[matched]):
                matched += 1
            if matched == 3:
                ans += 1
                break
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    s = input().strip().decode()
    ans = 0
    for p in product(range(10), repeat=3):
        pointer = 0
        for c in map(str, p):
            while pointer < n:
                if s[pointer] == c:
                    pointer += 1
                    break
                pointer += 1
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

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


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    s = input().strip().decode()
    ans = 0
    for p in product(range(10), repeat=3):
        pointer = 0
        for c in map(str, p):
            while pointer < n:
                if s[pointer] == c:
                    pointer += 1
                    break
                pointer += 1
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from itertools import product


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    s = input().strip().decode()
    ans = 0
    for p in product(range(10), repeat=3):
        pointer = 0
        for c in map(str, p):
            while pointer < n:
                if s[pointer] == c:
                    pointer += 1
                    break
                pointer += 1
            else:
                break
        else:
            ans += 1
    print(ans)


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


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = sorted(input())

        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter


def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = "".join(sorted(input()))
        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)


if __name__ == "__main__":
    main()