Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math


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

flag=False
if (x+y)%3 == 0:
    k = (x+y)//3
    if abs(x-y) <=k :
        l = abs(x-y)
        if (k-l)%2==0:
            flag=True
            a = (k+l)//2
            b = (k-l)//2
            c = math.factorial(k)//(math.factorial(a)*math.factorial(b))

if flag:
    print(int(c%(10**9+7)))
else:
    print(0)

Fixed submission:
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

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

flag=False
if (x+y)%3 == 0:
    k = (x+y)//3
    if abs(x-y) <=k :
        l = abs(x-y)
        if (k-l)%2==0:
            flag=True
            a = (k+l)//2
            #b = (k-l)//2
            c = comb(k,a ,10**9+7)

if flag:
    print(c)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):

a, b, c = 7, 4, 2
k = int(input())

while a >= b and k > 0:
    b *= 2
    k -= 1

while b >= c and k > 0:
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")


Fixed submission:

a, b, c = map(int, input().split())
k = int(input())

while a >= b and k > 0:
    b *= 2
    k -= 1

while b >= c and k > 0:
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

res = list()

res.append(np.prod(a[:k]))
tmp = res[0]

for i in range(k, n):
    tmp /= a[i - k]
    tmp *= a[i]
    res.append(tmp)

for i in range(1, n - k + 1):
    if res[i - 1] < res[i]:
        print("Yes")
    else:
        print("No")


Fixed submission:

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

res = list()

for i in range(k, n):
    if a[i - k] < a[i]:
        res.append("Yes")
    else:
        res.append("No")

for r in res:
    print(r)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

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

for i in range(n):
    tmp = a[:i] + a[i + 1:]
    print(reduce(lambda i, j: int(i) ^ int(j), tmp))


Fixed submission:
from functools import reduce

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

all = reduce(lambda i, j: int(i) ^ int(j), a)

for i in range(n):
    print(all ^ a[i])
Buggy python submission (verdict: Runtime Error):
class Telp:
    def __init__(self, to, idx):
        self.to = to
        self.idx = idx
        self.visited = False
        self.step = -1

    def visit(self, step):
        self.visited = True
        self.step = step

    def is_visited(self):
        return self.visited


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

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

net = {}

for i in range(n):
    net[i] = Telp(a[i], i)

current = net[0]
count = 0
path = [0]

while not current.visited:
    # print(current.to)
    current.visit(count)
    current = net[current.to - 1]
    path.append(current)
    count += 1
    # print("count", count)

offset = current.step
loop = count - offset
fact_idx = (k - offset) % loop

# print("count, offset, loop, fact_idx", count, offset, loop, fact_idx)
# print("ans", path[offset + fact_idx - 1].to)

print(path[offset + fact_idx - 1].to)


Fixed submission:
class Telp:
    def __init__(self, to, idx):
        self.to = to
        self.idx = idx
        self.visited = False
        self.step = -1

    def visit(self, step):
        self.visited = True
        self.step = step

    def is_visited(self):
        return self.visited


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

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

net = {}

for i in range(n):
    net[i] = Telp(a[i], i)

current = net[0]
count = 0
path = []

while not current.visited:
    # print(current.to)
    path.append(current)
    current.visit(count)
    current = net[current.to - 1]
    count += 1
    if count == k:
        print(path[-1].to)
        exit(0)
    # print("count", count)

offset = current.step
loop = count - offset
fact_idx = (k - offset) % loop

# print("count, offset, loop, fact_idx", count, offset, loop, fact_idx)
# print("ans", path[offset + fact_idx - 1].to)

print(path[offset + fact_idx - 1].to)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

d = []
a = []
res = [0] * n

for i in range(k):
    d_tmp = int(input())
    a_tmp = map(int, input().split())
    d.append(d_tmp)
    a.append(a_tmp)

for aa in a:
    for aaa in aa:
        res[aaa - 1] += 1

count = 0

for i in range(k):
    if res[i] == 0:
        count += 1

print(count)


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

d = []
a = []
res = [0] * n

for i in range(k):
    d_tmp = int(input())
    a_tmp = list(map(int, input().split()))
    d.append(d_tmp)
    a.append(a_tmp)

for aa in a:
    for aaa in aa:
        res[aaa - 1] += 1

count = 0

for i in range(n):
    if res[i] == 0:
        count += 1

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

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

# n = 10**5
# a = np.asarray([0] * n)

idx = np.argsort(a)
a = a[idx]

count = 0

for i in range(1, n):
    for j in range(n - i):
        sum_ = a[j] + a[j+i]
        if sum_ >= n:
            break
        if abs(idx[j+i] - idx[j]) == sum_:
            count += 1

print(count)


Fixed submission:

x = int(input())

for i in range(-300, 300):
    for j in range(-300, 300):
        if i**5 - j**5 == x:
            print(i, j)
            exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    cnt = dict()
    ans = dict()
    for i in a:
        cnt[i] = cnt.get(i, 0) + 1

    for (idx, v) in cnt.items():
        ans[idx] = v * (v - 1) // 2

    for k in range(len(a)):
        res = sum(ans.values()) - (cnt[a[k]] - 1)
        print(res)



Fixed submission:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    cnt = dict()
    ans = dict()
    for i in a:
        cnt[i] = cnt.get(i, 0) + 1

    for (idx, v) in cnt.items():
        ans[idx] = v * (v - 1) // 2

    sum_ = sum(ans.values())

    for k in range(len(a)):
        res = sum_ - (cnt[a[k]] - 1)
        print(res)

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    cnt = dict()
    for i in a:
        cnt[i] = cnt.get(i, 0) + 1

    for k in range(len(a)):
        cnt2 = cnt.copy()
        cnt2[a[k]] -= 1

        sum = 0
        for c in cnt2.values():
            sum += c * (c - 1) // 2

        print(sum)




Fixed submission:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    cnt = dict()
    ans = dict()
    for i in a:
        cnt[i] = cnt.get(i, 0) + 1

    for (idx, v) in cnt.items():
        ans[idx] = v * (v - 1) // 2

    sum_ = sum(ans.values())

    for k in range(len(a)):
        res = sum_ - (cnt[a[k]] - 1)
        print(res)
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    _ = input()
    nums = map(int, input().split(" "))
    count = 0
    for n in nums:
        while n%2 == 0:
            n /= 2
            count += 1

    print(count)


Fixed submission:
if __name__ == "__main__":
    a, b = map(int, input().split(" "))
 
    if a > 8 or b > 8:
        print(":(")
    else:
        print("Yay!")

Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    _ = input()
    nums = map(int, input().split(" "))
    count = 0
    for n in nums:
        while n%2 == 0:
            n /= 2
            count += 1

    print(count)


Fixed submission:
if __name__ == "__main__":
    a, b = map(int, input().split(" "))
 
    if a > 8 or b > 8:
        print(":(")
    else:
        print("Yay!")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
 
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")


Fixed submission:
if __name__ == "__main__":
    a, b = map(int, input().split(" "))
 
    if a > 8 or b > 8:
        print(":(")
    else:
        print("Yay!")

Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    a = int(input())
    b = int(input())

    if a > 8 or b > 8:
        print(":(")
    else:
        print("Yay!")


Fixed submission:
if __name__ == "__main__":
    a, b = map(int, input().split(" "))
 
    if a > 8 or b > 8:
        print(":(")
    else:
        print("Yay!")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort()
    if A[0] == 1 and not A[1] == 1:
        print(1)
        return
    arr = [0] * (A[-1] + 1) # 1-indexed
    for a in A:
        arr[a] += 1

    count = 0
    for i in range(0, len(arr)):
        if arr[i] == 0:
            continue
        elif arr[i] == 1:
            count += 1
        j = 2
        while i * j <= A[-1]:
            arr[i * j] = 0
            j += 1
    print(count)


    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()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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


def solve(N: int, A: "List[int]"):
    if N == 1:
        print(1)
        return
    A.sort()
    if A[0] == 1 and not A[1] == 1:
        print(1)
        return
    arr = [0] * (A[-1] + 1) # 1-indexed
    for a in A:
        arr[a] += 1

    count = 0
    for i in range(0, len(arr)):
        if arr[i] == 0:
            continue
        elif arr[i] == 1:
            count += 1
        j = 2
        while i * j <= A[-1]:
            arr[i * j] = 0
            j += 1
    print(count)


    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()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
 
def solve(A: int, B: int, N: int):
    x = min(B - 1, N)
    print(A * x // B)
 
 
    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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)
 
if __name__ == '__main__':
    main()
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, N: int):
    if B > N:
        x = N
    else:
        x = B - 1
    print(A * x // B)


    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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

if __name__ == '__main__':
    main()
提出情報

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


def solve(A: int, B: int, N: int):
    if B > N:
        x = N
    else:
        x = B - 1
    print(A * x // B)


    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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(A, B, N)

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


def solve(A: int, B: int):
    
   	if A > 9 or B > 9:
      print(-1)
    else:
      print(A * B)
    return



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(N, L)

if __name__ == '__main__':
    main()


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


def solve(A: int, B: int):
    
    if A > 9 or B > 9:
        print(-1)
    else:
        print(A * B)
    return


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: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import groupby

# RUN LENGTH ENCODING
def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res

def runLengthdecode(L: "list[tuple]"):
    res = ""
    for c, n in L:
        res += c * int(n)
    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():
    N, K = map(int, input().split())
    S = input()
    compressed = runLengthEncode(S)

    # ある区間を反転させるとその両端が前後で連結するようにするのが最大化できる = 両端の操作は損
    for k in range(K):
        i = 2 * k + 1   # 奇数インデックスのみ反転させる。
        compressed[i] = ('L', compressed[i][1]) if compressed[i][0] == "R" else ('R', compressed[i][1])

    reCompressed = runLengthEncode(runLengthdecode(compressed))
    ans = N - len(reCompressed)
    
    print(ans)

if __name__ == '__main__':
    main()


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

# RUN LENGTH ENCODING
def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res

def runLengthdecode(L: "list[tuple]"):
    res = ""
    for c, n in L:
        res += c * int(n)
    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():
    N, K = map(int, input().split())
    S = input()
    compressed = runLengthEncode(S)

    # ある区間を反転させるとその両端が前後で連結するようにするのが最大化できる = 両端の操作は損
    for k in range(K):
        i = 2 * k + 1   # 奇数インデックスのみ反転させる。
        if i >= len(compressed):
            break
        compressed[i] = ('L', compressed[i][1]) if compressed[i][0] == "R" else ('R', compressed[i][1])

    reCompressed = runLengthEncode(runLengthdecode(compressed))
    ans = N - len(reCompressed)

    print(ans)

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

def solve(N: int, K: int, h: "List[int]"):

    dp = [INF]*N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])

    for i in range(2, N):
        for k in range(1, K + 1):
            dp[i] = min(dp[i - k] + abs(h[i] - h[i - k]), dp[i])
    
    print(dp[N - 1])

    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()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
INF=10**16

def solve(N: int, K: int, h: "List[int]"):

    dp = [INF]*N
    dp[0] = 0
    dp[1] = abs(h[1] - h[0])

    for i in range(2, N):
        for k in range(1, K + 1):
            dp[i] = min(dp[i - k] + abs(h[i] - h[i - k]), dp[i])
    
    print(dp[N - 1])

    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()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, h)

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


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    dp = []
    for _ in range(N):
        l = [0]*(W + 1)
        dp.append(l)
    
    # dp[0][]だけ初期化
    for j in range(W + 1):
        dp[0][j] = v[0] if j >= w[0] else 0

    for i in range(1, N):
        for j in range(W + 1):
            if j >= w[i]:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
                
    print(dp[N - 1][W])
    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()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


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


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    dp = []
    for _ in range(N):
        l = [0]*(W + 1)
        dp.append(l)
    
    # dp[0][]だけ初期化
    for j in range(W + 1):
        dp[0][j] = v[0] if j >= w[0] else 0

    for i in range(1, N):
        for j in range(W + 1):
            if j >= w[i]:
                dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
                
    print(dp[N - 1][W])
    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()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

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

INF = 10**16

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    V = max(v) * N
    dp = []
    for _ in range(N):
        l = [INF]*(V + 1)
        dp.append(l)
    
    # initialize
    for j in range(V + 1):
        dp[0][j] = w[0] if j == v[0] else INF
        dp[0][0] = 0

    for i in range(1, N):
        for j in range(V + 1):
            if j >= v[i]:
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
    
    res = 0
    for j in range(V + 1):
        if dp[N - 1][j] <= W:
            res = j
    print(res)
    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()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


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

INF = 10**16

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    V = max(v) * N
    dp = []
    for _ in range(N):
        l = [INF]*(V + 1)
        dp.append(l)
    
    # initialize
    for j in range(V + 1):
        dp[0][j] = w[0] if j == v[0] else INF
        dp[0][0] = 0

    for i in range(1, N):
        for j in range(V + 1):
            if j >= v[i]:
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
    
    res = 0
    for j in range(V + 1):
        if dp[N - 1][j] <= W:
            res = j
    print(res)
    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()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()