Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    A = list(readnums())
    d = deque(A)
    d.appendleft(201)
    d.append(0)
    # ans = 1000 + (max(A) - min(A)) * (1000 // min(A))
    il = []
    for i in range(N):
        if d[i] <= d[i + 1] and d[i + 1] > d[i + 2]:
            il.append(i)
        elif d[i] >= d[i + 1] and d[i + 1] < d[i + 2]:
            il.append(i)

    # print(il)
    if len(il) == 1:
        print(1000)
    else:
        b = 1000
        s = 0
        if A[il[0]] < A[il[1]]:
            for i, v in enumerate(il):
                if not i % 2:
                    s += b // A[v]
                    b -= s * A[v]
                else:
                    b += s * A[v]
                    s = 0
                # print(b, s)
        else:
            for i, v in enumerate(il):
                if i % 2:
                    s += b // A[v]
                    b -= s * A[v]
                else:
                    b += s * A[v]
                    s = 0
                # print(b, s)

        print(max(1000, b))


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from collections import deque
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    A = list(readnums())
    b = 1000
    s = 0
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            s += b // A[i]
            b %= A[i]
        elif A[i] > A[i + 1]:
            b += A[i] * s
            s = 0

    if A[-1] >= A[-2]:
        b += A[-1] * s
        s = 0

    print(b)
    # d = deque(A)
    # d.appendleft(201)
    # d.append(0)
    # # ans = 1000 + (max(A) - min(A)) * (1000 // min(A))
    # il = []
    # for i in range(N):
    #     if d[i] <= d[i + 1] and d[i + 1] > d[i + 2]:
    #         il.append(i)
    #     elif d[i] >= d[i + 1] and d[i + 1] < d[i + 2]:
    #         il.append(i)

    # # print(il)
    # if len(il) <= 1:
    #     print(1000)
    # else:
    #     b = 1000
    #     s = 0
    #     if A[il[0]] < A[il[1]]:
    #         for i, v in enumerate(il):
    #             if not i % 2:
    #                 s += b // A[v]
    #                 b -= s * A[v]
    #             else:
    #                 b += s * A[v]
    #                 s = 0
    #             # print(b, s)
    #     else:
    #         for i, v in enumerate(il):
    #             if i % 2:
    #                 s += b // A[v]
    #                 b -= s * A[v]
    #             else:
    #                 b += s * A[v]
    #                 s = 0
    #             # print(b, s)
    #     if s:
    #         b = A[il[-1]] * s

    #     print(max(b, 1000))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()

    ans = {i: 0 for i in range(1, N + 1)}
    for i in range(3, 101):
        for j in range(1, i):
            for k in range(1, i):
                l = i - j - k
                if l <= 0:
                    break
                else:
                    v = j ** 2 + k ** 2 + l ** 2 + j * k + k * l + j * l
                    ans[v] += 1
    for i in range(1, N + 1):
        print(ans[i])


if __name__ == "__main__":
    main()


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()

    ans = {i: 0 for i in range(1, 20000)}
    for i in range(3, 124):
        for j in range(1, i):
            for k in range(1, i):
                l = i - j - k
                if l <= 0:
                    break
                else:
                    v = j ** 2 + k ** 2 + l ** 2 + j * k + k * l + j * l
                    ans[v] += 1
    for i in range(1, N + 1):
        print(ans[i])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    for i in range(1, N + 1):
        s = math.ceil(math.sqrt(i))
        ans = 0
        for j in range(1, s):
            for k in range(1, s):
                l = s - j - k
                if l <= 0:
                    break
                else:
                    if j * k + k * l + j * l == s ** 2 - i:
                        ans += 1

        print(ans)


if __name__ == "__main__":
    main()


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()

    ans = {i: 0 for i in range(1, 20000)}
    for i in range(3, 124):
        for j in range(1, i):
            for k in range(1, i):
                l = i - j - k
                if l <= 0:
                    break
                else:
                    v = j ** 2 + k ** 2 + l ** 2 + j * k + k * l + j * l
                    ans[v] += 1
    for i in range(1, N + 1):
        print(ans[i])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    X = readstr()
    s = sum(tuple(map(int, X)))
    m1 = int(X, 2) % (s + 1)
    m2 = int(X, 2) % (s - 1)
    for i in range(N):
        l = ['0'] * N
        l[i] = '1'
        ans = 1
        if X[i] == '0':
            x = (m1 + 2 ** (N - i - 1) % (s + 1)) % (s + 1)
        else:
            x = (m2 - 2 ** (N - i - 1) % (s - 1)) % (s - 1)
        d = sum(tuple(map(int, bin(x)[2:])))
        while x:
            x %= d
            d = sum(tuple(map(int, bin(x)[2:])))
            ans += 1
        print(ans)


if __name__ == "__main__":
    main()


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def popcount(n):
    ret = 0
    while n:
        ret += n & 1
        n >>= 1
    return ret


def main():
    N = readint()
    X = readstr()
    s = sum(tuple(map(int, X)))
    s1 = s + 1
    s2 = s - 1 if s != 1 else 1
    m1 = int(X, 2) % s1
    m2 = int(X, 2) % s2
    t1 = [1]
    t2 = [1]
    for i in range(N):
        t1.append(t1[i] * 2 % s1)
        t2.append(t2[i] * 2 % s2)
    for i in range(N):
        ans = 0
        if X[i] == '0':
            x = (m1 + t1[(N - i - 1)]) % s1
        else:
            if s == 1:
                print(0)
                continue
            else:
                x = (m2 - t2[(N - i - 1)]) % s2
        d = popcount(x)
        ans += 1
        while x:
            x %= d
            d = popcount(x)
            ans += 1
        print(ans)


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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


X = readint()
l = make_divisors(X)

ans_A = 0
ans_B = 0
for n in l:
    # n = A - B
    A = 0
    B = A - n
    while A != n:
        if A ** 5 - B ** 5 == X:
            ans_A = A
            ans_B = B
            break
        else:
            A += 1
            B += 1

    if ans_A:
        break


print(ans_A, ans_B)


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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


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

    divisors.sort()
    return divisors


def check(x, y):
    return x ** 4 + x ** 3 * y + x ** 2 * y ** 2 + x * y ** 3 + y ** 4


X = readint()
l = make_divisors(X)

ans_A = 0
ans_B = 0
for n in l:
    # n = A - B
    A = n // 2
    B = A - n
    while A ** 5 - B ** 5 <= X:
        if check(A, B) == (X // n):
            ans_A = A
            ans_B = B
            break
        else:
            A -= 1
            B -= 1

    if ans_A:
        break


print(ans_A, ans_B)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N = readint()
A = list(readnums())

L = [i + x for i, x in enumerate(A)]
R = [i - x for i, x in enumerate(A)]

x1 = min(max(L), max(R))
x2 = max(min(L), min(R))

ans = 0
for i in range(x2, x1 + 1):
    ans += L.count(i) * R.count(i)

print(ans)


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N = readint()
A = list(readnums())

L = [i + x for i, x in enumerate(A)]
R = [i - x for i, x in enumerate(A)]

l_c = Counter(L)
r_c = Counter(R)

x1 = min(max(L), max(R))
x2 = max(min(L), min(R))

ans = 0
for i in range(x2, x1 + 1):
    ans += l_c[i] * r_c[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N = readint()
A = np.array(list(readnums()))

ans = 0
for i in range(N):
    r = np.arange(N - i)
    a = A[i:]
    ans += np.count_nonzero((a - r) == -A[i])

print(ans)


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N = readint()
A = list(readnums())

L = [i + x for i, x in enumerate(A)]
R = [i - x for i, x in enumerate(A)]

l_c = Counter(L)
r_c = Counter(R)

x1 = min(max(L), max(R))
x2 = max(min(L), min(R))

ans = 0
for i in range(x2, x1 + 1):
    ans += l_c[i] * r_c[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = input().split()

ans_all = 0
for x in set(A):
    m = A.count(x)
    ans_all += m * (m - 1) // 2

for x in A:
    m = A.count(x) - 1
    print(ans_all - m)


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = input().split()

ans = {}
ans_all = 0
for x in set(A):
    m = A.count(x)
    ans_all += m * (m - 1) // 2


for x in A:
    m = A.count(x) - 1
    print(ans_all - (m + 1) * m // 2 + m * (m - 1) // 2)


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = input().split()

ans = {}
for x in set(A):
    t = 0
    for y in set(A):
        m = A.count(y) if x != y else A.count(y) - 1
        t += m * (m - 1) // 2
    ans[x] = t

for x in A:
    print(ans[x])


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = input().split()

ans = {}
for x in set(A):
    a = A[:]
    a.remove(x)
    t = 0
    for y in set(a):
        m = a.count(y)
        t += m * (m - 1) // 2
    ans[x] = t

for x in A:
    print(ans[x])


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N = int(input())
A = input().split()

for x in A:
    a = A[:]
    a.remove(x)
    ans = 0
    for y in set(a):
        m = a.count(y)
        ans += m * (m - 1) // 2
    print(ans)


Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = input().split()
a = Counter(A)

ans_all = 0
for x in a.keys():
    m = a[x]
    ans_all += m * (m - 1) // 2

for x in A:
    m = a[x] - 1
    print(ans_all - m)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import Counter

input = sys.stdin.readline

N = int(input())
l = []
for _ in range(N):
    l.append(input().strip())

c = Counter(l)

for k, v in sorted(c.items(), key=lambda x: x[0]):
    if v == max(c.values()):
        print(k)


Fixed submission:
import sys
from collections import Counter

input = sys.stdin.readline

N = int(input())
l = []
for _ in range(N):
    l.append(input().strip())

c = Counter(l)
m = max(c.values())
c2 = [k for k, v in c.items() if v == m]

for x in sorted(c2):
    print(x)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long N;
    long K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; ++i)
    {
        cin >> p[i];
    }
    long ans = 0;
    for (long i = 1; i < N - K + 1; ++i)
    {
        long tmp;
        for (int j = 0; j < K; j++)
        {
            tmp += p[i + j];
        }
        if (tmp > ans)
        {
            ans = tmp;
        }
    }
    cout << (ans + K) / 2 << endl;

    return 0;
}

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
c = np.cumsum(p)

ans = c[K-1]

for i in range(N - K):
    tmp = c[i+K] - c[i]
    ans = max(ans, tmp)

print((ans + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
input = sys.stdin.readline

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

ans = 0

for i in range(N - K + 1):
    tmp = np.sum(p[i:i + K])
    if ans < tmp:
        ans = tmp

print((ans + K) / 2)


Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
c = np.cumsum(p)

ans = c[K-1]

for i in range(N - K):
    tmp = c[i+K] - c[i]
    ans = max(ans, tmp)

print((ans + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
p = list(map(int, input().split()))

ans = 0

for i in range(N - K + 1):
    tmp = sum(p[i:i + K])
    if ans < tmp:
        ans = tmp

print((ans + K) / 2)


Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))
c = np.cumsum(p)

ans = c[K-1]

for i in range(N - K):
    tmp = c[i+K] - c[i]
    ans = max(ans, tmp)

print((ans + K) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, K = list(map(int, input().split()))
H = sorted(list(map(int, input().split())), reverse=True)

if N <= K:
    print(0)
    sys.exit()

for _ in range(K):
    H.pop(0)

print(sum(H))


Fixed submission:
import sys
import numpy as np

input = sys.stdin.readline

N, K = list(map(int, input().split()))
H = np.sort(np.array(list(map(int, input().split()))))[::-1]

if N <= K:
    print(0)
    sys.exit()

print(np.sum(H[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

count = 0
l = []
for x in P:
	l.append(x)
	if min(l) == x:
		count += 1

print(count)

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

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

l = []
for x in P:
	if not l or l[-1] > x:
		l.append(x)
	else:
		l.append(l[-1])

print(len(set(l)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

count = 0
l = []
for i in range(len(P)):
	l.append(P[i])
	if min(l) == P[i]:
		count += 1

print(count)

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

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

l = []
for x in P:
	if not l or l[-1] > x:
		l.append(x)
	else:
		l.append(l[-1])

print(len(set(l)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
input = sys.stdin.readline

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

count = 0
for i in range(len(P)):
	if min(P[:i+1]) == P[i]:
		count += 1

print(count)

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

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

l = []
for x in P:
	if not l or l[-1] > x:
		l.append(x)
	else:
		l.append(l[-1])

print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
input = sys.stdin.readline

N, M = map(int, input().split())

sl = deque()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.append(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)


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

N, M = map(int, input().split())

sl = set()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.add(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

sl = []
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.append(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)


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

N, M = map(int, input().split())

sl = set()
ans = 0
pen = 0
WA = [0 for _ in range(N)]
for i in range(M):
    p, S = input().split()
    if p in sl:
        continue

    if S == 'AC':
        ans += 1
        sl.add(p)
        pen += WA[int(p) - 1]
    else:
        WA[int(p) - 1] += 1

print(ans, pen)
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline


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


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


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


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


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

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

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


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


print(lcm(A, B))


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


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


A, B = map(int, input().split())
print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

s = []
for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            c = S[i] + S[j] + S[k]
            if c in s:
                continue
            else:
                s.append(c)

print(len(s))


Fixed submission:
N = int(input())
S = input()

ans = 0
l1 = []
for i in range(N):
    l2 = []
    if S[i] in l1:
        continue
    else:
        l1.append(S[i])
    for j in range(i + 1, N):
        if S[j] in l2:
            continue
        else:
            l2.append(S[j])
        s = S[j + 1:]
        ans += len(set(s))

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import sys
 
 
def Knight():
    def check(d):
        if not ((d[0] % 3 == 0 and d[1] % 3 == 0) or (d[0] % 3 == 1 and d[1] % 3 == 2) or (d[0] % 3 == 2 and d[1] % 3 == 1)):
            print(0)
            sys.exit()
    d = list(map(int, input().split()))
    check(d)
 
    x = d[0]
    y = d[1]
    diff = x - y if x > y else y - x  # aとbの回数の差
    d2 = [x - diff, y - diff * 2] if x < y else [x - diff * 2, y - diff]
    r = d2[0] // 3
 
    def cmb(n, r, mod):
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
 
    mod = 10**9+7  # 出力の制限
    N = x if x > y else y
    g1 = [1, 1]  # 元テーブル
    g2 = [1, 1]  # 逆元テーブル
    inverse = [0, 1]  # 逆元テーブル計算用テーブル
 
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
 
    a = cmb(r*2+diff, r, mod)
 
    print(a)
 
 
Knight()

Fixed submission:
def getCircleArea(r):
    return r * r


print(getCircleArea(int(input())))