Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * r_max
is_prime[0] = False
is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])


Fixed submission:
import math
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * (r_max+1)
is_prime[0] = is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])

Buggy python submission (verdict: Runtime Error):
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * r_max
is_prime[0] = is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])


Fixed submission:
import math
q = int(input())
l = []
r = []
for i in range(q):
    li, ri = map(int, input().split())
    l.append(li)
    r.append(ri)

r_max = max(r) + 10
is_prime = [True] * (r_max+1)
is_prime[0] = is_prime[1] = False
for i in range(2, r_max):
    if is_prime[i]:
        for j in range(2, r_max // i + 1):
            is_prime[i*j] = False

# print(is_prime)
a = [0] * r_max
for i in range(3, r_max):
    a[i] = a[i-1]
    if is_prime[i] and is_prime[(i+1)//2]:
        a[i] += 1
# print(a)

for i in range(q):
    print(a[r[i]] - a[l[i]-1])
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for ai in a:
    d[ai] += 1

cand = [k for k, v in d.items() if v >= 2]
cand.sort()

ans = 0
if len(cand) >= 1 and d[cand[-1]] >= 4:
    and = cand[-1] ** 2
if len(cand) >= 2:
    ans = cand[-1] * cand[-2]

print(ans)


Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for ai in a:
    d[ai] += 1

cand = [k for k, v in d.items() if v >= 2]
cand.sort()

ans = 0
if len(cand) >= 1 and d[cand[-1]] >= 4:
    ans = cand[-1] ** 2
elif len(cand) >= 2:
    ans = cand[-1] * cand[-2]

print(ans)
Buggy python submission (verdict: Runtime Error):
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)
def LCM(a: int, b: int) -> int:
    return a // GCD(a, b) * b 

n = int(input())
t = [int(input()) for _ in range(n)]

ans = LCM(t[0], t[1])
for i in range(2, n):
    ans = LCM(ans, t[i])

print(ans)


Fixed submission:
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)
def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)

n = int(input())
t = [int(input()) for _ in range(n)]

ans = t[0]
if n > 1:
    ans = LCM(t[0], t[1])
    for i in range(2, n):
        ans = LCM(ans, t[i])

print(ans)

Buggy python submission (verdict: Runtime Error):
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)
def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)

n = int(input())
t = [int(input()) for _ in range(n)]

ans = LCM(t[0], t[1])
for i in range(2, n):
    ans = LCM(ans, t[i])

print(ans)


Fixed submission:
def GCD(a:int , b: int) -> int:
    return a if b == 0 else GCD(b, a % b)
def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)

n = int(input())
t = [int(input()) for _ in range(n)]

ans = t[0]
if n > 1:
    ans = LCM(t[0], t[1])
    for i in range(2, n):
        ans = LCM(ans, t[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c))
    edges[b].append((a, c))

q, k = map(int, input().split())
k -= 1

visited = [0] * n
d = [0] * n
def dfs(v, c):
    for u, c2 in edges[v]:
        if visited[u] == 0:
            d[u] = c + c2
            visited[u] = 1
            dfs(u, c + c2)

visited[k] = 1
dfs(k, 0)

for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(d[x] + d[y])


Fixed submission:
import sys
sys.setrecursionlimit(200000)
n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append((b, c))
    edges[b].append((a, c))

q, k = map(int, input().split())
k -= 1

visited = [0] * n
d = [0] * n
def dfs(v, c):
    for u, c2 in edges[v]:
        if visited[u] == 0:
            d[u] = c + c2
            visited[u] = 1
            dfs(u, c + c2)

visited[k] = 1
dfs(k, 0)

for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(d[x] + d[y])
Buggy python submission (verdict: Runtime Error):
s = input()

abaababaabfor i in reversed(range(1, len(s)//2)):
    if s[:i] == s[i:2*i]:
        ans = i * 2
        break

print(ans)


Fixed submission:
s = input()

for i in reversed(range(1, len(s)//2)):
    if s[:i] == s[i:2*i]:
        ans = i * 2
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
MAX = n + 5
fact = [1 for _ in range(MAX)]
finv = [1 for _ in range(MAX)]
for i in range(2, MAX):
    fact[i] = fact[i - 1] * i % MOD
    finv[i] = pow(fact[i], MOD-2, MOD)

def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n-k] % MOD


d = defaultdict(list)
for i in range(n+1):
    d[a[i]].append(i)
    if len(d[a[i]]) == 2:
        i1, i2 = sorted(d[a[i]])
        m1 = i1
        m2 = i2 - i1 - 1
        m3 = n - i2

# print((i1, i2), m1, m2, m3)

ans = [n]
if n > 1:
    ans.append(comb(m1+m2+m3, 2) + m1+m2 + m2+m3 + 1)
for k in range(3, n+1):
    ansi = comb(n+1, k)
    for l in range(k):
        ansi -= comb(m1, l) * comb(m3, k-1-l)
        ansi = (ansi + MOD) % MOD

    ans.append(ansi)

ans.append(1)

for ansi in ans:
    print(ansi)


Fixed submission:
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

MOD = 10**9 + 7
MAX = n + 5
fact = [1 for _ in range(MAX)]
finv = [1 for _ in range(MAX)]
for i in range(2, MAX):
    fact[i] = fact[i - 1] * i % MOD
    finv[i] = pow(fact[i], MOD-2, MOD)

def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n-k] % MOD


d = defaultdict(list)
for i in range(n+1):
    d[a[i]].append(i)
    if len(d[a[i]]) == 2:
        i1, i2 = sorted(d[a[i]])
        m1 = i1
        m2 = i2 - i1 - 1
        m3 = n - i2

# print((i1, i2), m1, m2, m3)
ans = []
for k in range(1, n+2):
    ansi = comb(n+1, k) - comb(m1+m3, k-1)
    ansi = (ansi + MOD) % MOD
    ans.append(ansi)

for ansi in ans:
    print(ansi)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
edge = []
edge_inv = [[] for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a-1, b-1
    edge.append((a, b, -c))
    edge_inv[b].append(a)

visited = [False] * n
def dfs(v):
    for u in edge_inv[v]:
        if not visited[u]:
            visited[u] = True
            dfs(u)

visited[n-1] = True
dfs(n-1)
target_nodes = [i for i in range(n) if visited[i]]
# print(target_nodes)

def bellman_ford(n, edge):
    INF = float('inf')
    d = [INF] * n
    d[0] = 0
    for i in range(n):
        update = False
        for v_from, v_to, cost in edge:
            if v_from not in target_nodes or v_to not in target_nodes:
                continue
            if d[v_from] != INF and d[v_to] > d[v_from] + cost:
                d[v_to] = d[v_from] + cost # 緩和
                update = True
    return d, update

d, update = bellman_ford(n, edge)
if update:
    print("inf")
else:
    print(-d[n-1])


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
edge = []
edge_inv = [[] for _ in range(n)]
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a-1, b-1
    edge.append((a, b, -c))
    edge_inv[b].append(a)

visited = [False] * n
def dfs(v):
    for u in edge_inv[v]:
        if not visited[u]:
            visited[u] = True
            dfs(u)

visited[n-1] = True
dfs(n-1)
target_nodes = [i for i in range(n) if visited[i]]
# print(target_nodes)

def bellman_ford(n, edge):
    INF = float('inf')
    d = [INF] * n
    d[0] = 0
    for i in range(n):
        update = False
        for v_from, v_to, cost in edge:
            if v_from not in target_nodes or v_to not in target_nodes:
                continue
            if d[v_from] != INF and d[v_to] > d[v_from] + cost:
                d[v_to] = d[v_from] + cost # 緩和
                update = True
    return d, update

d, update = bellman_ford(n, edge)
if update:
    print("inf")
else:
    print(-d[n-1])
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if c % pow(a, i, b) == 0:
            ans = "YES"
            break

print(ans)


Fixed submission:
a, b, c = map(int, input().split())

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if (a*i) % b == c:
            ans = "YES"
            break

print(ans)

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if c % ((a**i) % b) == 0:
            ans = "YES"
            break

print(ans)


Fixed submission:
a, b, c = map(int, input().split())

if a % b == 0:
    if c == 0:
        ans = "YES"
    else:
        ans = "NO"
else:
    ans = "NO"
    for i in range(1, b+1):
        if (a*i) % b == c:
            ans = "YES"
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, ma, mb = map(int, input().split())
med = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**8
MAX_M = 400
dp = [[[INF] * (MAX_M + 1) for _ in range(MAX_M + 1)] for _ in range(2)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(med):
    i0 = (i + 0) % 2
    i1 = (i + 1) % 2
    for x in range(MAX_M + 1):
        for y in range(MAX_M + 1):
            if x - a >= 0 and y - b >= 0:
                dp[i1][x][y] = min(dp[i0][x][y], dp[i0][x - a][y - b] + c)
            else:
                dp[i1][x][y] = dp[i0][x][y]

ans = INF
for i in range(1, MAX_M + 1):
    if ma * i > MAX_M or mb * i > MAX_M:
        break
    ans = min(ans, dp[n % 2][ma * i][mb * i])
if ans == INF:
    ans = -1

print(ans)


Fixed submission:
n, ma, mb = map(int, input().split())
med = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**8
MAX_M = 400
dp = [[[INF] * (MAX_M + 1) for _ in range(MAX_M + 1)] for _ in range(2)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(med):
    i0 = (i + 0) % 2
    i1 = (i + 1) % 2
    for x in range(MAX_M + 1):
        for y in range(MAX_M + 1):
            if x - a >= 0 and y - b >= 0:
                dp[i1][x][y] = min(dp[i0][x][y], dp[i0][x - a][y - b] + c)
            else:
                dp[i1][x][y] = dp[i0][x][y]

ans = INF
for i in range(1, MAX_M + 1):
    if ma * i > MAX_M or mb * i > MAX_M:
        break
    ans = min(ans, dp[n % 2][ma * i][mb * i])
if ans == INF:
    ans = -1

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

words = ['dream', 'dreamer', 'erase', 'eraser']
def dfs(t):
    if t == '':
        return True
    ans = False
    for word in words:
        if t[:len(word)] == word:
            ans = ans or dfs(t[len(word):])

    return ans

if dfs(s):
    print("YES")
else:
    print("NO")


Fixed submission:
import sys
sys.setrecursionlimit(10**8)

s = input()

words = ['dream', 'dreamer', 'erase', 'eraser']
def dfs(idx):
    if idx == len(s):
        return True
    ans = False
    for word in words:
        if s[idx:idx+len(word)] == word:
            ans = ans or dfs(idx + len(word))

    return ans

if dfs(0):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

n, k, l = map(int, input().split())
uf_r = UnionFind(n)
for i in range(k):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    uf_r.unite(p, q)
uf_t = UnionFind(n)
for i in range(l):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    uf_t.unite(r, s)

root_r = defaultdict(set)
root_t = defaultdict(set)
for i in range(n):
    root_r[uf_r.root(i)].add(i)
    root_t[uf_t.root(i)].add(i)

ans = []
for i in range(n):
    ans.append(str(len(root_r[uf_r.root(i)] & root_t[uf_t.root(i)])))

print(' '.join(ans))


Fixed submission:
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(10**8)

class UnionFind():
    def __init__(self, n):
        self.par = [-1 for i in range(n)]

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x]) # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]: # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def size(self, x):
        return -self.par[self.root(x)]

n, k, l = map(int, input().split())
uf_r = UnionFind(n)
for i in range(k):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    uf_r.unite(p, q)
uf_t = UnionFind(n)
for i in range(l):
    r, s = map(int, input().split())
    r -= 1
    s -= 1
    uf_t.unite(r, s)

root_r = defaultdict(set)
root_t = defaultdict(set)
for i in range(n):
    root_r[uf_r.root(i)].add(i)
    root_t[uf_t.root(i)].add(i)

ans = []
memo = dict()
for i in range(n):
    if (uf_r.root(i), uf_t.root(i)) not in memo:
        memo[(uf_r.root(i), uf_t.root(i))] = len(root_r[uf_r.root(i)] & root_t[uf_t.root(i)])
    ans.append(str(memo[(uf_r.root(i), uf_t.root(i))]))

print(' '.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
def func(b, n):
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res


def solve():
    n = int(input())
    s = int(input())

    if n == s:
        return n + 1
    elif n < s:
        return -1

    for b in range(2, n + 1):
        if b**2 > n:
            break
        if func(b, n) == s:
            return b

    b_cand = []
    for p in range(1, n + 1):
        if p**2 > n:
            break
        b = (n - s) // p + 1
        b_cand.append(b)
    b_cand = b_cand[::-1]

    for b in b_cand:
        if func(b, n) == s:
            return b

    return -1


ans = solve()
print(ans)


Fixed submission:
def func(b, n):
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res


def solve():
    n = int(input())
    s = int(input())

    if n == s:
        return n + 1
    elif n < s:
        return -1

    for b in range(2, n + 1):
        if b**2 > n:
            break
        if func(b, n) == s:
            return b

    b_cand = []
    for p in range(1, n + 1):
        if p**2 > n:
            break
        b = (n - s) // p + 1
        if b > 1:
            b_cand.append(b)
    b_cand = b_cand[::-1]

    for b in b_cand:
        # print(b)
        if func(b, n) == s:
            return b

    return -1


ans = solve()
print(ans)

Buggy python submission (verdict: Runtime Error):
def func(b, n):
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res


def solve():
    n = int(input())
    s = int(input())

    if n == s:
        return n + 1
    # elif n < s:
    #     return -1

    for b in range(2, n + 1):
        if b**2 > n:
            break
        if func(b, n) == s:
            return b

    for p in range(1, n + 1):
        if p**2 > n:
            break

        b = (n - s) // p + 1
        if func(b, n) == s:
            return b

    return -1


ans = solve()
print(ans)


Fixed submission:
def func(b, n):
    res = 0
    while n > 0:
        res += n % b
        n //= b
    return res


def solve():
    n = int(input())
    s = int(input())

    if n == s:
        return n + 1
    elif n < s:
        return -1

    for b in range(2, n + 1):
        if b**2 > n:
            break
        if func(b, n) == s:
            return b

    b_cand = []
    for p in range(1, n + 1):
        if p**2 > n:
            break
        b = (n - s) // p + 1
        if b > 1:
            b_cand.append(b)
    b_cand = b_cand[::-1]

    for b in b_cand:
        # print(b)
        if func(b, n) == s:
            return b

    return -1


ans = solve()
print(ans)
Buggy python submission (verdict: Runtime Error):
print 1110 - input

Fixed submission:
print(1110-int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
def solve(n,m,a,b):
    ans = 0
    lim = (a*n+b)//m
    
    for i in range(1,lim+1):
        l = (i*m-b+a-1)//a
        r = (i*m+m-b-1)//a

        ans += (min(r,n-1)-l+1)*i

    return ans

def main():
    t = int(input())
    while t>0:
        n,m,a,b = map(int, input().split(' '))
        print(solve(n,m,a,b))
        t-=1

if __name__ == "__main__":
    main()

Fixed submission:
# def solve(n,m,a,b):
#     ans = 0
#     lim = (a*n+b)//m
    
#     for i in range(1,lim+1):
#         l = (i*m-b+a-1)//a
#         r = (i*m+m-b-1)//a

#         ans += (min(r,n-1)-l+1)*i

#     return ans

def floor_sum(n, m, a, b):
    ans = 0

    # (a*i+b)//m
    '''    
        k = a//m
        series 
            k + 2k + 3k + ... (n-1)k 
    '''
    if a>=m:
        ans += n*(n-1)*(a//m)//2
        a %= m


    '''
        k = b//m
        for each i

        series
            k + k + ... + k <n-1 times>
    '''
    if b>=m:
        ans += n*(b//m)
        b %= m

    yn = (a*n+b)//m

    if yn == 0:
        return ans #yn == 0 implies prev terms contibute 0 so return ans

    x_least = (yn * m - b) #the first x for which y(x) == yn 'x_least' refers to the val a*x.

    l = (x_least+(a-1))//a
    r = n-1 

    ans += (r-l+1)*yn  #if ans was not returned then this implies y(n) == y(n-1) == yn. element in window [l...r] have y(x) = yn
    ans += floor_sum(yn, a, m, (a-x_least%a)%a)
    return ans
    '''
    #r+1 as we pass the element that does not belong in the range.

    '''
def main():
    t = int(input())
    while t>0:
        n,m,a,b = map(int, input().split(' '))
        # print(solve(n,m,a,b))
        print(floor_sum(n,m,a,b))
        t-=1

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

MOD=1000000007

n,k=map(int,input().split())
k=min(k,n-1)
fac=np.zeros((n+1)).astype(np.int64)
invfac=np.zeros((n+1)).astype(np.int64)
inv=np.zeros((n+1)).astype(np.int64)

invfac[0]=fac[0]=invfac[1]=fac[1]=inv[1]=1
for i in range(2,n+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]=(-inv[MOD%i]*(MOD//i))%MOD
    invfac[i]=(invfac[i-1]*inv[i])%MOD
def nCr(n,r):
    return ((fac[n]*invfac[r]%MOD)*invfac[n-r])%MOD
def nHr(n,r):
    return nCr(n+r-1,r)

ret = 0
for i in range(k+1):
    ret = (ret + nCr(n,i)*nHr(n-i,i))%MOD

print(ret)

Fixed submission:
import numpy as np

MOD=1000000007

n,k=map(int,input().split())
k=min(k,n-1)
fac=np.zeros((n+1)).astype(np.int64)
invfac=np.zeros((n+1)).astype(np.int64)
inv=np.zeros((n+1)).astype(np.int64)

invfac[0]=fac[0]=invfac[1]=fac[1]=inv[1]=1
for i in range(2,n+1):
    fac[i]=(fac[i-1]*i)%MOD
    inv[i]=(-inv[MOD%i]*(MOD//i))%MOD
    invfac[i]=(invfac[i-1]*inv[i])%MOD
def nCr(n,r):
    return ((fac[n]*invfac[r]%MOD)*invfac[n-r])%MOD
def nHr(n,r):
    return nCr(n+r-1,r)

ret = 0
x = nCr(n, np.arange(k+1))
y = nHr(n-np.arange(k+1), np.arange(k+1))
ret = np.sum(x*y%MOD)%MOD

print(ret)
Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = list(map(int, input().split()))
canDevide = True
count = 0;
while canDevide :
  for i in range(N) :
    if numbers[i]%2 == 0 :
      numbers[i] /= 2
    else :
      canDevide = False
      break
  if canDevide :
    count += 1
print(count)

Fixed submission:
s = input()
numbers = [int(number) for number in s]
print(numbers.count(1))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(lambda s: s.strip(), input().split())

print(f"{a[0].upper()}{b[0].upper()}{c[0].upper()}")

Fixed submission:
a, b, c = map(lambda s: s.strip(), input().split())

print("{0}{1}{2}".format(a[0].upper(), b[0].upper(), c[0].upper()))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush, heapify

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

q = []
for x in a:
    heappush(q, (-x, 1, x))


for i in range(k):
    _, dc, p = heappop(q)
    dc += 1
    v = -(-p//dc)
    heappush(q, (-v, dc, p))


ans = 0
for x, _, _ in q: ans = max(ans, -x)

print(ans)


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

def f(m):
    res = sum([-(-x//m)-1 for x in a])
    return res <= k

l, r = 0, 10**9+10

while r-l > 1:
    x = (l+r)//2
    if f(x): r = x
    else: l = x

print(r)