Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  a.sort()
  c = [a.count(i) for i in range(1,n+1) if a.count(i)>0]
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()
  
  

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  c = list(collections.Counter(a).values())
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()

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

def solve():
  a.sort()
  c = [a.count(i) for i in range(1,n+1) if a.count(i)>0]
  c.sort()
  if(len(count)<=k):
    print(0)
  else:
    print(sum(count[:len(c)-k]))

solve()
  
  

Fixed submission:
import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))

def solve():
  c = list(collections.Counter(a).values())
  c.sort()
  if(len(c)<=k):
    print(0)
  else:
    print(sum(c[:len(c)-k]))

solve()
Buggy python submission (verdict: Runtime Error):
X, y, Z = map(int, input().split())
def solve():
  for i in range(int(X/Y)):
    if(X < i*Y+(i+1)*Z):
      print(i-1)
      return

solve()

Fixed submission:
X, Y, Z = map(int, input().split())
def solve():
  for i in range(int(X/Y)+2):
    if(X < i*Y+(i+1)*Z):
      print(i-1)
      return

solve()
Buggy python submission (verdict: Runtime Error):
print("YES" if input() == reversed(input()) else "No)

Fixed submission:
print("YES" if input() == "".join(list(reversed(input()))) else "NO")
Buggy python submission (verdict: Runtime Error):
print(sum([s[0] for s in input().split()]))

Fixed submission:
print("".join(([s[0] for s in input().split()])))
Buggy python submission (verdict: Runtime Error):
import sys
import math

from decimal import *

def solve(A: int, B: float):
    # a = Decimal(A)
    # b = Decimal(B)
    print(math.floor(Decimal(a * b)))
    return
    # if len(str(B)) == 3:
    #     if str(B)[2] == 0:
    #         print(math.floor(a*b))
    #         return
    #     ans = A * int(str(B)[0])
    #     ans += Decimal(a * int(str(B)[2]) / 10)
    #     print(math.floor(ans))
    #     return

    # if len(str(B)) == 4:
    #     ans = A * int(str(B)[0])
    #     ans += Decimal(A * int(str(B)[2]) / 10)
    #     ans += Decimal(A * int(str(B)[3]) / 100)
    #     print(math.floor(ans))
    #     return
    # return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = float(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math

from decimal import *

def solve(A: int, B: float):
    a = Decimal(A)
    b = Decimal(B)
    # print(math.floor(a * b))
    # return
    if len(str(B)) == 3:
        if str(B)[2] == 0:
            print(math.floor(a*b))
            return
        ans = A * int(str(B)[0])
        ans += Decimal(a * int(str(B)[2]) / 10)
        print(math.floor(ans))
        return

    if len(str(B)) == 4:
        ans = A * int(str(B)[0])
        ans += Decimal(A * int(str(B)[2]) / 10)
        ans += Decimal(A * int(str(B)[3]) / 100)
        print(math.floor(ans))
        return
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = float(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from random import randint
from math import gcd


def solve(N: int):
    # zの条件
    # - Nの約数
    # - 素数pのn乗
    # - 過去に選択したzと被らない
    n = N
    ds = make_divisors(n)
    print(ds)
    used = []
    while(True):
        count = len(used)
        for d in ds:
            if d in used:
                continue
            p, k = primePower(d)
            print(p)
            if p == 0:
                continue
            n /= d
            used.append(d)
            break

        if count == len(used):
            print(count)
            return
    return


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def findWitness(n, k=5): # miller-rabin
    s, d = 0, n-1
    while d % 2 == 0:
        s, d = s+1, d/2
    for i in range(k):
        a = randint(2, n-1)
        x = pow(a, d, n)
        if x == 1 or x == n-1: continue
        for r in range(1, s):
            x = (x * x) % n
            if x == 1: return a
            if x == n-1: break
        else: return a
    return 0


def primePower(n):
    def checkP(n, p):
        k = 0
        while n > 1 and n % p == 0:
            n, k = n / p, k + 1
        if n == 1: return p, k
        else: return 0, 0

    if n % 2 == 0: return checkP(n, 2)
    q = n
    while True:
        a = findWitness(q)
        if a == 0: return checkP(n, q)
        d = gcd(pow(a,q,n)-a, q)
        if d == 1 or d == q: return 0, 0
        q = d


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int):
    # zの条件
    # - Nの約数
    # - 素数pのn乗
    # - 過去に選択したzと被らない

    def f(x):
        cnt = 0
        for i in range(1, x + 1):
            x -= i
            if x < 0:
                break
            cnt += 1
        return cnt

    print(sum([f(p[1]) for p in factorize(N)]))
    return


def factorize(n: int):
    """nの素因数分解を求める"""
    res = []
    for i in range(2, int(n ** 0.5//1 + 2)):
        if n % i:
            continue
        s = 0
        while n % i == 0:
            n /= i
            s += 1
        res.append([i, s])
    if n != 1:
        res.append([n, 1])
    return res


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(N):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
G = [list(set(x)) for x in G]

q = deque([])
dist = [-1] * N
ans = [-1] * N
ans[0] = 0
dist[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not dist[nv] == -1:
            continue
        dist[nv] = dist[v] + 1
        ans[nv] = v
        q.appendleft(nv)

for i in ans[1:]:
    if i == -1:
        print('No')
        sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('Yes')
        continue
    print(v + 1)
    

Fixed submission:
import sys
from collections import deque


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(M):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
# G = [list(set(x)) for x in G]

q = deque([])
ans = [-1] * N
ans[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not ans[nv] == -1:
            continue
        ans[nv] = v
        q.appendleft(nv)

# for i in ans[1:]:
#     if i == -1:
#         print('No')
#         sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('Yes')
        continue
    print(v + 1)

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


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(N):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
G = [list(set(x)) for x in G]

q = deque([])
dist = [-1] * N
ans = [-1] * N
dist[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not dist[nv] == -1:
            continue
        dist[nv] = dist[v] + 1
        ans[nv] = v
        q.appendleft(nv)

for i in ans[1:]:
    if i == -1:
        print('No')
        sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('yes')
        continue
    print(v + 1)
    

Fixed submission:
import sys
from collections import deque


N, M = [int(i) for i in input().split()]
A = []
B = []
for i in range(M):
    l = [int(i) for i in input().split()]
    A.append(l[0])
    B.append(l[1])

# BFS
G = [[] for _ in range(N)]
for i in range(M):
    G[A[i] - 1].append(B[i] - 1)
    G[B[i] - 1].append(A[i] - 1)
# G = [list(set(x)) for x in G]

q = deque([])
ans = [-1] * N
ans[0] = 0
q.appendleft(0)
while(len(q) > 0):
    v = q.pop()
    for nv in G[v]:
        if not ans[nv] == -1:
            continue
        ans[nv] = v
        q.appendleft(nv)

# for i in ans[1:]:
#     if i == -1:
#         print('No')
#         sys.exit()

for i, v in enumerate(ans):
    if i == 0:
        print('Yes')
        continue
    print(v + 1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import itertools
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    cnt = 0
    for i in c:
        x = i[0]
        y = i[1]
        if y - A[y - 1] == x + A[x - 1]:
            cnt += 1
    print(cnt)
    return
 
if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
# import itertools
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    # # TLE
    # c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    # cnt = 0
    # for i in c:
    #     x = i[0]
    #     y = i[1]
    #     if x + A[x - 1] == y - A[y - 1]:
    #         cnt += 1
    # print(cnt)

    L = []  # 左辺
    R = []  # 右辺
    for i in range(N):
        x = y = i + 1
        L.append(x + A[i])
        R.append(y - A[i])
    cl = collections.Counter(L)
    cr = collections.Counter(R)
    ans = 0
    for i in range(N):
        if i in cl and i in cr:
            ans += cl[i] * cr[i]
    print(ans)
    return

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import itertools


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    cnt = 0
    for i in c:
        x = i[0]
        y = i[1]
        if y - A[y - 1] == x + A[x - 1]:
            cnt += 1
    print(cnt)
    return

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
# import itertools
import collections


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    # # TLE
    # c = itertools.combinations_with_replacement(range(1, N + 1), 2)
    # cnt = 0
    # for i in c:
    #     x = i[0]
    #     y = i[1]
    #     if x + A[x - 1] == y - A[y - 1]:
    #         cnt += 1
    # print(cnt)

    L = []  # 左辺
    R = []  # 右辺
    for i in range(N):
        x = y = i + 1
        L.append(x + A[i])
        R.append(y - A[i])
    cl = collections.Counter(L)
    cr = collections.Counter(R)
    ans = 0
    for i in range(N):
        if i in cl and i in cr:
            ans += cl[i] * cr[i]
    print(ans)
    return

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math

R = input()
print(2 * math.pi * R)

Fixed submission:
import sys
import math

R = input()
print(2.0 * math.pi * float(R))

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

R = input()
print(2 * math.pi * R)

Fixed submission:
import sys
import math

R = input()
print(2.0 * math.pi * float(R))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(K: int):
    K += 1
    ans = []
    for i in range(1, K):
        for j in range(1, K):
            for k in range(1, K):
                ans.append(gcd(i, gcd(j, k)))
    print(sum(ans))
    return

def gcd(x: int, y: int):
    """xとyの最大公約数を求める"""
    return gcd(y, x % y) if y else x
    
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(K: int):
    K += 1
    ans = []
    for i in range(1, K):
        for j in range(1, K):
            for k in range(1, K):
                ans.append(gcd(i, gcd(j, k)))
    print(sum(ans))
    return

def gcd(x: int, y: int):
    """xとyの最大公約数を求める"""
    return gcd(y, x % y) if y else x
    
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    a = input()
    Q = int(input())
    qs = [input().split() for _ in range(Q)]
    ans = a
    revcount = 0
    for q in qs:
        if len(q) == 1:
            revcount += 1
        else:
            if int(q[1]) == 1:
                if revcount % 2 == 0:
                    ans = q[2] + ans
                else:
                    ans = ans + q[2]
            else:
                if revcount % 2 == 0:
                    ans = ans + q[2]
                else:
                    ans = q[2] + ans
    if revcount % 2 == 1:
        ans = ans[::-1]
    print(ans)
    return
 
 
if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    print(YES if 'A' in S and 'B' in S else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    max = -1
    arr_max = []
    for i, v in enumerate(p):
        arr = p[i:i+K]
        m = sum(arr)
        if m > max:
            max = m
            arr_max = arr
    print(sum([calc(i) for i in arr_max]))


def calc(n: int):
    return sum(range(1, n+1)) / n


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, p: "List[int]"):
    M = m = sum(p[:K])
    for i in range(N-K):
        m = m - p[i] + p[i + K]
        M = max(M, m)
    print((1*K+M)/2)



# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math


def solve(A: int, B: int):
    print(lcm(A, B))
    return


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(lcm(A, B))
    return


def lcm(x, y):
    return (x * y) // gcd(x, y)


def gcd(x: int, y: int):
    """xとyの最大公約数を求める"""
    return gcd(y, x % y) if y else x


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(Q: int, l: "List[int]", r: "List[int]"):
    # 10^5までの素数を予め計算しておく。
    INF = 100100
    is_prime = get_prime_numbers_array(INF)
    for i in range(Q):
        cnt = 0
        for j in range(l[i], r[i] + 1):
            if j % 2 == 0:
                continue
            if (is_prime[j] and is_prime[int((j+1)/2)]):
                cnt += 1
        print(cnt)
    return

def get_prime_numbers_array(n):
    """エラトステネスのふるいを用いてnまでの素数判定を行うための配列を返す

    Args:
        n ([int]): nまでの素数判定を行う
    """
    N = n + 1
    is_prime = [1] * N
    is_prime[0] = is_prime[1] = 0
    for i in range(2, N):
        if not is_prime[i]:
            continue
        for j in range(i * 2, N, i):
            is_prime[j] = 0
    return is_prime


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(Q, l, r)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(Q: int, l: "List[int]", r: "List[int]"):
    # 10^5までの素数を予め計算しておく。
    INF = 100100
    is_prime = get_prime_numbers_array(INF)
    is_like = [0] * INF
    for i in range(INF + 1):
        if i % 2 == 0:
            continue
        if (is_prime[i] and is_prime[int((i+1)/2)]):
            is_like[i] = 1
    a = cumsum(is_like)
    for i in range(Q):
        print(a[r[i] + 1] - a[l[i]])
    return


def get_prime_numbers_array(n: int):
    """エラトステネスのふるいを用いてnまでの素数判定を行うための配列を返す

    Args:
        n ([int]): nまでの素数判定を行う
    """
    N = n + 1
    is_prime = [1] * N
    is_prime[0] = is_prime[1] = 0
    for i in range(2, N):
        if not is_prime[i]:
            continue
        for j in range(i * 2, N, i):
            is_prime[j] = 0
    return is_prime


def cumsum(data: "List[int]"):
    """dataの累積和の配列を求める。
 
    Args:
        data (List[int]): 累積和の配列を求めたい配列
    """
    a = [0] * (len(data) + 1)
    for i in range(len(data)):
        a[i + 1] = a[i] + data[i]
    return a


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(Q, l, r)

if __name__ == '__main__':
    main()