Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    elif 1 <= ((b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    elif 1 <= ((b - a) / (v - w)) <= t:

        print('YES')
    else:
        print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v = w and a == b:
    print('YES')
elif v = w and a != b:
    print('NO')
elif a == b:
    print('YES')
else:
    if 0 <= ((b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v = w and a != b:
    print('NO')
else:
    if 0 <= ((b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if 0 <= ((b - a) / (v - w)) <= t:
    print('YES')
else:
    print('NO')

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
    print('NO')
else:
    if 1 <= (abs(b - a) / (v - w)) <= t:
        print('YES')
    else:
        print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

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

    ans = 0
    for x in range(N + 1):
        res = int((A * x) // B) - A * int(x // B)
        ans = max(ans, res)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

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

    x = min(B - 1, N)
    print((A * x) // B - A * (x // B))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env pypy3
def main():
    S = input()

    ans = 0
    len_S = len(S)
    for i in range(len_S):
        for j in range(i + 1, len_S + 1):
            res = int(S[i:j])
            if res % 2019 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    S = input()[::-1]

    counts = [0] * 2019
    counts[0] = 1
    res, digit = 0, 1
    for i in S:
        res += int(i) * digit
        res %= 2019
        digit *= 10
        digit %= 2019
        counts[res] += 1

    ans = 0
    for i in counts:
        ans += i * (i - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    S = input()

    ans = 0
    len_S = len(S)
    for i in range(len_S):
        for j in range(i + 1, len_S + 1):
            res = int(S[i:j])
            if res % 2019 == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    S = input()[::-1]

    counts = [0] * 2019
    counts[0] = 1
    res, digit = 0, 1
    for i in S:
        res += int(i) * digit
        res %= 2019
        digit *= 10
        digit %= 2019
        counts[res] += 1

    ans = 0
    for i in counts:
        ans += i * (i - 1) // 2
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    N = int(input())
    S = input()

    ans = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if (1
                        and S[i] != S[j]
                        and S[i] != S[k]
                        and S[j] != S[k]
                        and j - i != k - j):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    N = int(input())
    S = input()

    res = 0
    R, G, B = S.count('R'), S.count('G'), S.count('B')
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = j + j - i
            if k >= N:
                continue
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                res += 1
    print(R * G * B - res)


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

    N, K = map(int, input().split())
    A = [int(x) for x in input().split()]

    lst = []
    for a, b in combinations(A, 2):
        lst.append(a * b)
    lst = sorted(lst)
    print(lst[K - 1])


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from bisect import bisect_left, bisect_right

    N, K = map(int, input().split())
    A = sorted([int(x) for x in input().split()])

    negative_end = bisect_left(A, 0)
    postive_start = bisect_right(A, 0)

    postive_cnt = N - postive_start
    negative_cnt = negative_end
    zero_cnt = N - postive_cnt - negative_cnt

    negative_pairs_cnt = postive_cnt * negative_cnt
    zero_pairs_cnt = (zero_cnt * (postive_cnt + negative_cnt)
                      + (zero_cnt * (zero_cnt - 1) // 2))
    
    # 答えが負の場合
    if K <= negative_pairs_cnt:
        # 二分探索：mid以下になるペアがK個以上あるか？
        ok, ng = 0, -10 ** 19
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            or_higher_cnt, right = 0, postive_start
            for left in range(negative_end):
                while right < N and A[left] * A[right] > mid:
                    right += 1
                or_higher_cnt += postive_cnt - (right - postive_start)
            if or_higher_cnt >= K:
                ok = mid
            else:
                ng = mid
        print(ok)
    # 答えが0の場合
    elif K <= negative_pairs_cnt + zero_pairs_cnt:
        print(0)
    # 答えが正の場合
    else:
        # 二分探索：mid以下になるペアがK個以上あるか？
        K -= negative_pairs_cnt + zero_pairs_cnt
        ok, ng = 10 ** 19, 0
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            # 正*正の場合
            or_higher_cnt, right = 0, N - 1
            for left in range(postive_start, N):
                while right < N and A[left] * A[right] > mid and left < right:
                    right -= 1
                or_higher_cnt += max(0, right - left)
            # 負*負の場合
            left = 0
            for right in range(negative_end - 1, -1, -1):
                while left < N and A[left] * A[right] > mid and left < right:
                    left += 1
                or_higher_cnt += max(0, right - left)

            if or_higher_cnt >= K:
                ok = mid
            else:
                ng = mid
        print(ok)


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

    def expected_val(limit):
        return sum(range(1 + limit)) / limit

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = np.zeros(N + 1)
    res = 0
    for i in range(N):
        res += expected_val(P[i])
        lst[i + 1] = res
    print(np.max(lst[K:] - lst[:N - K + 1]))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += p + 1
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans / 2)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    ans = 0
    for i in range(N - K + 1):
        res = 0
        for k in range(K):
            res += expected_val(P[i + k])
        ans = max(ans, res)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += p + 1
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans / 2)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return sum(range(limit + 1)) / limit

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    ans = 0
    for i in range(N - K + 1):
        res = 0
        for k in range(K):
            res += expected_val(P[i + k])
        ans = max(ans, res)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    def expected_val(limit):
        return (1 + limit) / 2

    N, K = map(int, input().split())
    P = [int(x) for x in input().split()]

    lst = [0]
    res = 0
    for p in P:
        res += p + 1
        lst.append(res)
    ans = 0
    for i in range(N - K + 1):
        res = lst[i + K] - lst[i]
        ans = res if res > ans else ans
    print(ans / 2)


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

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in map(str, range(1, N + 1)):
        cnt[int(n[0])][int(n[-1])] += 1

    print(np.sum(cnt * cnt.T))


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in [str(x) for x in range(1, N + 1)]:
        cnt[int(n[0])][int(n[-1])] += 1

    print((cnt[:, :] * cnt.T[:, :]).sum())


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    from collections import deque
    from itertools import product

    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    h_indexes = [x for x in range(H)]
    w_indexes = [x for x in range(W)]
    move = ((0, 1), (0, -1), (1, 0), (-1, 0))
    ans = 0
    for sh, gh in product(h_indexes, repeat=2):
        for sw, gw in product(w_indexes, repeat=2):
            if S[sh][sw] == '#' or S[gh][gw] == '#':
                continue
            queue = deque([(sh, sw)])
            distance = [[0] * W for _ in range(H)]
            while queue:
                h, w = queue.popleft()
                if h == gh and w == gw:
                    break
                for dh, dw in move:
                    nh = h + dh
                    nw = w + dw
                    if (1
                            and 0 <= nh < H
                            and 0 <= nw < W
                            and S[nh][nw] == '.'
                            and distance[nh][nw] == 0):
                        distance[nh][nw] = distance[h][w] + 1
                        queue.append((nh, nw))
            if ans < distance[gh][gw]:
                ans = distance[gh][gw]
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque
    import numpy as np

    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]

    move = ((0, 1), (0, -1), (1, 0), (-1, 0))
    seen = [[False] * W for _ in range(H)]
    ans = 0
    for sh in range(H):
        for sw in range(W):
            if S[sh][sw] == '#' or seen[sh][sw]:
                continue
            seen[sh][sw] = True
            queue = deque([(sh, sw)])
            # distance = np.zeros((H, W), dtype=np.int16)
            distance = np.full((H, W), -1, dtype=np.int16)
            distance[sh, sw] = 0
            while queue:
                h, w = queue.popleft()
                for dh, dw in move:
                    nh = h + dh
                    nw = w + dw
                    if (1
                            and 0 <= nh < H
                            and 0 <= nw < W
                            and S[nh][nw] == '.'
                            and distance[nh][nw] == -1):
                        distance[nh][nw] = distance[h][w] + 1
                        queue.append((nh, nw))
            ans = max(ans, distance.max())
    print(ans)


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

    _ = int(input())
    S = input()

    seen = set()
    ans = 0
    for i, j, k in combinations(S, 3):
        string = ''.join([i, j, k])
        if string in seen:
            continue
        ans += 1
        seen.add(string)

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    N = int(input())
    S = input()

    seen = set()
    ans = 0
    for i in range(N - 2):
        if S[i] in seen:
            continue
        seen.add(S[i])
        for j in range(i + 1, N - 1):
            if S[i] + S[j] in seen:
                continue
            seen.add(S[i] + S[j])
            for k in range(j + 1, N):
                if S[i] + S[j] + S[k] in seen:
                    continue
                seen.add(S[i] + S[j] + S[k])
                ans += 1
    print(ans)


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

S = defaultdict(int)
for i in input():
    S[i] += 1

a, b, *_ = S.values()
if a == b == 2:
    print('Yes')
else:
    print('No')


Fixed submission:
from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

if len(S.values()) == 2:
    a, b = S.values()
    if a == b == 2:
        print('Yes')
        exit()
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = [int(x) for x in read().split()]
    
    dp = [0] * (N + 2)
    dp[0] = 1
    
    for i in range(N):
        one = i + 1
        two = i + 2
        now = dp[i]
        if one not in a:
            dp[one] += now
        if two not in a:
            dp[two] += now
    print(dp[N] % 1_000_000_007)


resolve()


Fixed submission:
def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = set(int(x) for x in read().split())
    
    dp = [0] * (N + 2)
    dp[0] = 1

    for i in range(N):
        now = dp[i]
        if i + 1 not in a:
            dp[i + 1] += now
        if i + 2 not in a:
            dp[i + 2] += now

    print(dp[N] % 1_000_000_007)


resolve()

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

def resolve():
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = [int(x) for x in read().split()]
    
    dp = [0] * N * 2
    dp[0] = 1
    for i in range(N):
        one = i + 1
        two = i + 2
        now = dp[i]
        if one not in a:
            dp[one] += now
        if two not in a:
            dp[two] += now
    print(dp[N] % 1_000_000_007)


resolve()


Fixed submission:
def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = set(int(x) for x in read().split())
    
    dp = [0] * (N + 2)
    dp[0] = 1

    for i in range(N):
        now = dp[i]
        if i + 1 not in a:
            dp[i + 1] += now
        if i + 2 not in a:
            dp[i + 2] += now

    print(dp[N] % 1_000_000_007)


resolve()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())
    happiness = [list(map(int, input().split())) for _ in range(N)]

    dp = np.zeros((N, 3), dtype=np.int64)
    dp[0] = happiness[0]
    for i in range(1, N):
        for a, yesterday in enumerate(dp[i - 1]):
            for b, today in enumerate(happiness[i]):
                if a == b:
                    continue
                dp[i][b] = max(dp[i][b], yesterday + today)
    print(max(dp[-1]))


if __name__ == '__main__':
    main()


Fixed submission:
def resolve():
    import sys
    import itertools
    import numpy as np

    readline = sys.stdin.readline

    N = int(readline())
    lst = [list(map(int, readline().split())) for _ in [0] * N]

    dp = np.full((N, 3), -1, np.int32)
    for i in range(N):
        for a, b in itertools.permutations([0, 1, 2], 2):
            if a == b:
                continue
            if i == 0:
                dp[i][a] = lst[i][a]
            else:
                dp[i][a] = max(dp[i][a], dp[i - 1][b] + lst[i][a])
    print(max(dp[-1]))

resolve()
Buggy python submission (verdict: Runtime Error):
# C - Otoshidama(https://atcoder.jp/contests/abc085/tasks/abc085_c)
import sys

n, y = map(int, input().split())
for i in range(n):
    if n < i:
        break
    for j in range(n):
        if n - i - j < 0:
            break
        if 100_00 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            sys.exit()
print(-1, -1, -1)

Fixed submission:
# C - Otoshidama(https://atcoder.jp/contests/abc085/tasks/abc085_c)
n, y = map(int, input().split())
end = 0
for i in range(n + 1):
    if n < i:
        break
    for j in range(n + 1):
        if n - i - j < 0:
            break
        if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
            print(i, j, n - i - j)
            end += 1
    if end:
        break
if end == 0:
    print(-1, -1, -1)
Buggy python submission (verdict: Runtime Error):
    lst = [int(a) for a in input()]
    for bit in range(1 << len(lst)):
        sum = 0
        op_lst = []
        for i in range(len(lst)):
            if bit & (1 << i):
                sum += lst[i]
                op_lst.append('+')
            else:
                sum -= lst[i]
                op_lst.append('-')
        if sum == 7:
            print(lst[0], op_lst[1], lst[1], op_lst[2], lst[2], op_lst[3], lst[3], '=7', sep='')
            break

Fixed submission:
lst = [int(a) for a in input()]
for bit in range(1 << len(lst)):
    sum = 0
    op_lst = []
    for i in range(len(lst)):
        if bit & (1 << i):
            sum += lst[i]
            op_lst.append('+')
        else:
            sum -= lst[i]
            op_lst.append('-')
    if sum == 7:
        print(lst[0], op_lst[1], lst[1], op_lst[2], lst[2], op_lst[3], lst[3], '=7', sep='')
        break
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
p=[(i+1)/2 for i in p]
a=0
for i in range(n-k+1):
  a=max(a,sum(p[i:i+k]))
print(a)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
p=[(i+1)/2 for i in p]
a=sum(p[0:k])
b=a
for i in range(0,n-k):
  a=a-p[i]+p[i+k]
  b=max(a,b)
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
def main():
    _ = input()
    s = list(input())
    sset = set(s)
    l = []
    for i in sset:
        for j in sset:
            for k in sset:
                l.append(str(i)+str(j)+str(k))
    ans = 0
    for i in s:
        l_ = []
        while l:
            x = l.pop(-1)
            if x[0] == i:
                if len(x) == 1:
                    ans += 1
                else:
                    l_.append(x[1:])
            else:
                l_.append(x)
        l = copy.deepcopy(l_)
    print(ans)
        
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    s = list(input())
    sset = set(s)
    d = {}
    for i in sset:
        d[i] = []
    for i in range(n):
        d[s[i]].append(i)
    dk = d.keys()
    ans = 0
    for i in dk:
        for j in dk:
            for k in dk:
                a = d[i][0]
                f = False
                b = ""
                if d[j][-1] > a:
                    for x in d[j]:
                        if x > a:
                            f = True
                            b = x
                            break
                if f:
                    if d[k][-1] > b:
                        ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import copy
def main():
    n = int(input())
    s = [list(map(int,list((input())))) for i in range(n)]
    k = []
    f = True
    for start in range(n):
        s_ = copy.deepcopy(s)
        group = [0]*n
        group[start] = 1
        v = [start]
        searched = set([start])
        mx_k = 2
        f = True
        while True:
            v_ = []
            for i in v:
                edge = s_[i]
                for j in range(n):
                    if edge[j] == 1:
                        if group[j] == 0:
                            v_.append(j)
                            group[j] = mx_k
                        elif not abs(group[j]-group[i])==1:
                            f = False
                            break
                searched = searched | set(v)
                if not f:
                    break
            if not f:
                break
            if len(searched) == n:
                k.append(mx_k-1)
                break
            v = copy.deepcopy(v_)
            mx_k += 1
    if k:
        print(max(k))
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

Fixed submission:
import copy
def main():
    n = int(input())
    s = [list(map(int,list((input())))) for i in range(n)]
    k = []
    f = True
    for start in range(n):
        s_ = copy.deepcopy(s)
        group = [0]*n
        group[start] = 1
        v = [start]
        searched = set([start])
        mx_k = 2
        f = True
        while True:
            v_ = []
            for i in v:
                edge = s_[i]
                for j in range(n):
                    if edge[j] == 1:
                        if group[j] == 0:
                            v_.append(j)
                            group[j] = mx_k
                        elif not abs(group[j]-group[i])==1:
                            f = False
                            break
                searched = searched | set(v)
                if not f:
                    break
            if not f:
                break
            if len(searched) == n:
                k.append(mx_k-1)
                break
            v = copy.deepcopy(v_)
            mx_k += 1
    if k:
        print(max(k))
    else:
        print(-1)
    
if __name__ == '__main__':
    main()