Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03353 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 9)

S = input()
K = int(input())

chars = sorted(set(S))
checked = set()


def dfs(s):
    for c in chars:
        if len(checked) >= K:
            return
        next_s = s + c
        if next_s not in checked and next_s in S:
            checked.add(next_s)
            if len(checked) == K:
                print(next_s)
                return
            elif len(next_s) <= len(S):
                dfs(next_s)


dfs('')

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

chars = sorted(set(S))
checked = set()


def dfs(s):
    for c in chars:
        next_s = s + c
        if next_s not in checked and next_s in S:
            checked.add(next_s)
            if len(checked) == K:
                print(next_s)
                return
            elif len(next_s) <= len(S):
                dfs(next_s)


dfs('')
Problem p03401 (python)

Fixed submission:
from itertools import chain


def cost(p1, p2):
    return abs(p1 - p2)


input()
points = tuple(chain.from_iterable(([0], tuple(map(int, input().split(' '))), [0])))

base_cost = sum([cost(p, pre_p) for pre_p, p in zip(points, points[1:])])

for pre_p, p, next_p in zip(points, points[1:], points[2:]):
    diff = cost(pre_p, next_p) - cost(pre_p, p) - cost(p, next_p)
    print(base_cost + diff)

Buggy submission (verdict: Runtime Error):
def cost(p1, p2):
    return abs(p1 - p2)


input()
points = (0, *map(int, input().split(' ')), 0)

base_cost = sum([cost(p, pre_p) for pre_p, p in zip(points, points[1:])])

for pre_p, p, next_p in zip(points, points[1:], points[2:]):
    diff = cost(pre_p, next_p) - cost(pre_p, p) - cost(p, next_p)
    print(base_cost + diff)
Problem p03600 (python)

Fixed submission:
import copy
from itertools import product, combinations

N = int(input())

dp = []
for _ in range(N):
    dp.append(list(map(int, input().split(' '))))

original = copy.deepcopy(dp)

for k, i, j in product(range(N), repeat=3):
    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

if dp == original:
    cost = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(N):
                if k == i or k == j:
                    continue
                if dp[i][j] == dp[i][k] + dp[k][j]:
                    break
            else:
                cost += dp[i][j]
    print(cost)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from itertools import product, combinations
import numpy as np

N = int(input())

dp = np.zeros(shape=(N, N), dtype=int)

for i in range(N):
    dp[i] = np.array(list(map(int, input().split(' '))))

original = dp.copy()

for k, i in product(range(N), repeat=2):
    dp[i] = np.minimum(dp[i], dp[i][k] + dp[k])

if np.all(dp == original):
    route_set = set()
    costs = []
    for i in range(N):
        for j in range(i + 1, N):
            route_set.add(dp[i][j])
            costs.append(dp[i][j])

    route_set = route_set - set(map(sum, combinations(costs, r=2)))
    print(sum([cost for cost in costs if cost in route_set]))
else:
    print(-1)
Problem p04014 (python)

Fixed submission:
import math


def digit_sum(b, n):
    if b > n:
        return n
    else:
        return digit_sum(b=b, n=n // b) + n % b


def main(n, s):
    if s > n:
        return -1
    elif n == s:
        return n + 1
    else:
        b = 2
        while b * b <= n:
            if digit_sum(b, n) == s:
                return b
            b += 1

        p = 1
        b_min = -1
        while p * p <= n:
            if (n - s) % p == 0:
                b = (n - s) // p + 1
                if digit_sum(b, n) == s:
                    b_min = min(b_min, b) if b_min != -1 else b
            p += 1
        return b_min


if __name__ == '__main__':
    N = int(input())
    S = int(input())
    print(main(n=N, s=S))

Buggy submission (verdict: Runtime Error):
import math


def digit_sum(b, n):
    if b > n:
        return n
    else:
        return digit_sum(b=b, n=n // b) + n % b


def main(n, s):
    if s > n:
        return -1
    elif n == s:
        return n + 1
    else:
        sqrt_n = int(math.sqrt(n))
        for b in range(2, sqrt_n + 1):
            if digit_sum(b, n) == s:
                return b
        b_min = 1L << 55
        for p in range(1, sqrt_n):
            if (n - s) % p == 0:
                b = int((n - s) / p + 1)
                if digit_sum(b, n) == s:
                    b_min = min(b_min, b)
            p += 1
    if b_min == 1L << 55:
        return -1
    else:
        return b_min


if __name__ == '__main__':
    N = int(input())
    S = int(input())
    print(main(n=N, s=S))

Buggy submission (verdict: Runtime Error):
import math


def digit_sum(b, n):
    if b > n:
        return n
    else:
        return digit_sum(b=b, n=n // b) + n % b


def main(n, s):
    if n == s:
        return n + 1
    elif s == 1:
        return n
    elif s > n:
        return -1
    else:
        sqrt_n = int(math.sqrt(n))
        for b in range(2, sqrt_n + 1):
            if digit_sum(b, n) == s:
                return b
        for p in range(1, sqrt_n + 1):
            b = (n - s) // (p + 1)
            if digit_sum(b, n) == s:
                return b
    return -1


if __name__ == '__main__':
    N = int(input())
    S = int(input())
    print(main(n=N, s=S))
Problem p04043 (python)

Fixed submission:
def check_a(numbers):
    if numbers.count(5) == 2 and numbers.count(7) == 1:
        return 'YES'
    else:
        return 'NO'


def main():
    numbers = list(map(int, input().split()))
    print(check_a(numbers=numbers))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def check_a(numbers):
    if numbers.count(5) == 2 and numbers.count(7) == 1:
        return 'YES'
    else:
        return 'NO'


def main():
    numbers = list(map(int, input()))
    print(check_a(numbers=numbers))


if __name__ == '__main__':
    main()
Problem p03722 (python)

Fixed submission:
import sys
from collections import Counter

sys.setrecursionlimit(10**7)
 
inf = 1<<100
 
def solve():
    N, M = map(int, input().split())
    edges = [None]*M
    Adj = [[] for i in range(N)]
 
    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        ui, vi = ui - 1, vi - 1
        edges[i] = (ui, vi, -ci)
        Adj[ui].append(vi)

    visitable = [False]*N

    dfs(N, M, Adj, visitable, 0)

    reachable = [False]*N
    reachable[0] = True
    reachable[N - 1] = True

    for u in range(1, N - 1):
        visited = [False]*N

        dfs(N, M, Adj, visited, u)

        if visited[N - 1]:
            reachable[u] = True
 
    ans = Bellmanford(N, M, edges, visitable, reachable)
 
    if ans is not None:
        print(-ans)
    else:
        print('inf')

def dfs(N, M, Adj, visitable, u):
    visitable[u] = True

    for v in Adj[u]:
        if not visitable[v]:
            dfs(N, M, Adj, visitable, v)

def Bellmanford(N, M, edges, visitable, reachable):
    dist = [inf]*N
    dist[0] = 0
    flag = True

    cnt = 0
 
    for i in range(N):
        flag = False

        for (u, v, c) in edges:
            if dist[u] != inf and dist[v] > dist[u] + c:
                dist[v] = dist[u] + c

                if visitable[v] and reachable[v]:
                    flag = True

        # print(dist)

        if not flag:
            break

        if flag and i == N - 1:
            return None

    return dist[N - 1]
 
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
 
inf = 1<<60
 
def solve():
    N, M = map(int, input().split())
    edges = [None]*M
 
    for i in range(M):
        ui, vi, ci = map(int, sys.stdin.readline().split())
        edges[i] = (ui-1, vi-1, -ci)
 
    ans = Bellmanford(N, M, edges)
 
    if ans is not None:
        print(-ans)
    else:
        print('inf')
 
def Bellmanford(N, M, edges):
    dist = [inf]*N
    dist[0] = 0
    flag = True
 
    while True:
        flag = False
 
        for (u, v, c) in edges:
            if d[u] != inf and dist[v] > dist[u] + c:
                dist[v] = dist[u] + c
                flag = True
 
        # print(dist)
 
        if not flag or dist[0] < 0:
            break
 
    if dist[0] >= 0:
        return dist[N - 1]
    else:
        return None
 
if __name__ == '__main__':
    solve()
Problem p03746 (python)

Fixed submission:
import sys
from collections import deque

sys.setrecursionlimit(10**7)

def solve():
    def dfs1(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.append(w)
                visited[w] = True
                dfs1(w, path, visited)
                return

    def dfs2(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.appendleft(w)
                visited[w] = True
                dfs2(w, path, visited)
                return

    N, M = map(int, sys.stdin.readline().split())
    Adj = [[] for i in range(N)]

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1
        Adj[a].append(b)
        Adj[b].append(a)

    if any(len(v) == 1 for v in Adj):
        for i, v in enumerate(Adj):
            if len(v) == 1:
                s = i
                break

        path = [s]
        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)
    else:
        s = 0
        path = deque([0])

        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)
        dfs2(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

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

def solve():
    def dfs1(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.append(w)
                visited[w] = True
                dfs1(w, path, visited)
                return

    def dfs2(u, path, visited):
        for w in Adj[u]:
            if not visited[w]:
                path.appendleft(w)
                visited[w] = True
                dfs2(w, path, visited)
                return

    N, M = map(int, sys.stdin.readline().split())
    Adj = [[] for i in range(N)]

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a-1, b-1
        Adj[a].append(b)
        Adj[b].append(a)

    if any(len(v) == 1 for v in Adj):
        for i, v in enumerate(Adj):
            if len(v) == 1:
                s = i
                break

        path = [s]
        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)
    else:
        s = 0
        path = deque([0])

        visited = [False] * N
        visited[s] = True

        dfs1(s, path, visited)
        dfs2(s, path, visited)

        path = [i + 1 for i in path]

        print(len(path))
        print(*path)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()
Problem p03795 (python)

Fixed submission:
import sys

def solve():
    N = int(input())
    ans = 800 * N - 200 * (N // 15)
    print(ans)
    
def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
N = int(input())
s = input()

b = [0 if si == 'o' else 1 for si in s]
sw = [0] * N

for i in range(4):
    sw[0] = i & 1
    sw[1] = (i >> 1) & 1

    for k in range(2, N):
        sw[k] = b[k - 1] ^ sw[k - 1] ^ sw[k - 2]

    if b[N - 1] != (sw[N - 2] ^ sw[N - 1] ^ sw[0]):
        continue
    if b[0] != (sw[N - 1] ^ sw[0] ^ sw[1]):
        continue

    ans = ['W' if si else 'S' for si in sw]
    print(''.join(ans))
    quit()

print(-1)
Problem p03801 (python)

Fixed submission:

def BS(th, a):
    top = len(th)
    btm = 0

    while top > btm:
        mid = (top + btm)//2
        if th[mid] < a <= th[mid + 1]:
            return mid
        elif a <= th[mid]:
            top = mid
        else:
            btm = mid

N = int(input())
A = [int(i) for i in input().split()]

th = [0]
num_th = []
rem = []
max_i = 0
nonzeros = dict()

for i, a in enumerate(A):
    if a > th[-1]:
        th.append(a)
        num_th.append(1)
        rem.append(0)
        nonzeros[i] = max_i
        max_i += 1
    else:
        j = BS(th, a)
        if j - 1 >= 0:
            num_th[j - 1] += 1
        rem[j] += a - th[j]

for i in range(len(num_th) - 1, 0, -1):
    num_th[i - 1] += num_th[i]
'''
print(th)
print(num_th)
print(rem)
'''
for i in range(N):
    if i in nonzeros:
        ans = (th[nonzeros[i] + 1] - th[nonzeros[i]])*num_th[nonzeros[i]] + rem[nonzeros[i]]
        print(ans)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):

def BS(th, a):
    top = len(th)
    btm = 0

    while top > btm:
        mid = (top + btm)//2
        if th[mid] <= a < th[mid + 1]:
            return mid
        elif a <= th[mid]:
            top = mid
        else:
            btm = mid

N = int(input())
A = [int(i) for i in input().split()]

th = [0]
num_th = []
rem = []
max_i = 0
nonzeros = dict()

for i, a in enumerate(A):
    if a > th[-1]:
        th.append(a)
        num_th.append(1)
        rem.append(0)
        nonzeros[i] = max_i
        max_i += 1
    else:
        j = BS(th, a)
        if j - 1 >= 0:
            num_th[j - 1] += 1
        rem[j] += a - th[j]

for i in range(len(num_th) - 1, 0, -1):
    num_th[i - 1] += num_th[i]
'''
print(th)
print(num_th)
print(rem)
'''
for i in range(N):
    if i in nonzeros:
        ans = (th[nonzeros[i] + 1] - th[nonzeros[i]])*num_th[nonzeros[i]] + rem[nonzeros[i]]
        print(ans)
    else:
        print(0)
Problem p03852 (python)

Fixed submission:
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    c = input()
    boin = {'a', 'e', 'i', 'o', 'u'}

    if c in boin:
        ans = 'vowel'
    else:
        ans = 'consonant'

    print(ans)


if __name__ == '__main__':
    solve()

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

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, K, L = map(int, input().split())
    Adj_r = [[] for i in range(N)]
    Adj_t = [[] for i in range(N)]

    for i in range(K):
        p, q = map(int, input().split())
        p, q = p-1, q-1
        Adj_r[p].append(q)
        Adj_r[q].append(p)

    for i in range(L):
        r, s = map(int, input().split())
        r, s = r-1, s-1
        Adj_t[r].append(s)
        Adj_t[s].append(r)

    col = 0
    cols_r = [None] * N
    cols_t = [None] * N

    for u in range(N):
        if cols_r[u] is None:
            bfs_color(N, Adj_r, cols_r, u, col)
            col += 1
        if cols_t[u] is None:
            bfs_color(N, Adj_t, cols_t, u, col)
            col += 1

    # debug(cols_r, locals())
    # debug(cols_t, locals())

    cnt = Counter((cols_r[u], cols_t[u]) for u in range(N))

    ans = [cnt[cols_r[u], cols_t[u]] for u in range(N)]

    print(*ans)


def bfs_color(N, Adj, v_cols, u, col):
    v_cols[u] = col
    nxts = deque([u])

    while nxts:
        v = nxts.popleft()

        for w in Adj[v]:
            if v_cols[w] is None:
                v_cols[w] = col
                nxts.append(w)


if __name__ == '__main__':
    solve()
Problem p04013 (python)

Fixed submission:
import sys
from collections import Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, A = map(int, input().split())
    x = [int(i) for i in input().split()]

    # 3d DP
    max_x = max(x)

    dp = [[[0] * (max_x * N + 1) for j in range(N + 1)]
                                 for i in range(N + 1)]

    dp[0][0][0] = 1

    for i in range(0, N):
        for k in range(0, N + 1):
            for y in range(max_x * N + 1):
                if dp[i][k][y]:
                    dp[i + 1][k][y] += dp[i][k][y]
                    dp[i + 1][k + 1][y + x[i]] += dp[i][k][y]

            # print(dp[i][k])
        # print()

    cnt = 0
    for k in range(1, N + 1):
        for y in range(1, max_x * N + 1):
            if y // k == A and y % k == 0:
                cnt += dp[N][k][y]

    print(cnt)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
x = [int(i) for i in input().split()]

# 3d DP
max_x = max(x)

dp = [[[0] * (max_x * N + 1) for j in range(N + 1)]
                             for i in range(N + 1)]

dp[0][0][0] = 1

for i in range(0, N):
    for k in range(0, N + 1):
        for y in range(max_x * N + 1):
            dp[i + 1][k][y] += dp[i][k][y]
            dp[i + 1][k + 1][y + x[i]] += dp[i][k][y]

cnt = 0
for k in range(1, N + 1):
    for y in range(1, max_x * N + 1):
        if y // k == A and y % k == 0:
            cnt += dp[N][k][y]

print(cnt)

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

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, A = map(int, input().split())

    assert N <= 16

    x = [int(i) for i in input().split()]
    cnt = 0

    for i in range(1, 2**N):
        bs = bin(i)[2:].zfill(N)
        bitpop = bs.count('1')
        tmp = sum(x[i] for i, b in enumerate(bs) if b == '1')
        cnt += (tmp // bitpop == A and tmp % bitpop == 0)

    print(cnt)

if __name__ == '__main__':
    solve()
Problem p02928 (python)

Fixed submission:
mod=10**9+7
n, k=map(int, input().split())
a=list(map(int, input().split()))
jibun=0
for i in range(n-1):
    for j in range(i+1, n):
        if a[i]>a[j]:
            jibun=(jibun+1)%mod

saki=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            saki=(saki+1)%mod

ans=jibun*k+saki*k*(k-1)//2
print(ans%mod)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
n, k=map(int, input().split())
a=list(map(int, input().split()))
jibun=0
for i in range(n):
    for j in range(i+1, n):
        if a[i]>a[j]:
            jibun=jibun+1

saki=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            saki=saki+1
ans=0

print((jibun*k)%mod+int((1/2)*saki*k*(k-1))%mod)%mod)
Problem p03086 (python)

Fixed submission:

s=list(input())



for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        s[i]=1
    else:
        s[i]=0
list_s=[]
for i in range(len(s)):
    flag=1
    for j in range(len(s)-i):
        if s[i+j]==0:
            list_s.append(j)
            flag=0
            break
    if flag:
        list_s.append(len(s)-i)

print(max(list_s))

Buggy submission (verdict: Runtime Error):

s=list(input())



for i in range(len(s)):
    if s[i]=="A" or s[i]=="T" or s[i]=="G" or s[i]=="C":
        s[i]=1
    else:
        s[i]=0
list=[]
for i in range(len(s)):
    for j in range(len(s)-i):
        if s[i+j]==0:
            list.append(j)
            break

print(max(list))
Problem p02608 (python)

Fixed submission:
N = int(input())
ans = [0] * N
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
            if n < N:
                ans[n] += 1
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = [0] * (N)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
            if n <= N:
                ans[n] += 1
for i in ans:
    print(i)
Problem p02642 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
m = max(A.keys())
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if not L[i]:
        continue
    if A[i] == 1:
        ans += 1
    for j in range(i,m+1,i):
        L[j] = 0
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = Counter(list(map(int,input().split(' '))))
ans = 0
L = [1]*(10**6+1)
for i in sorted(A.keys()):
    if A[i] > 1:
        continue
    ans += L[i]
    for j in (i,10**6+1,i):
        L[j] = 0
print(ans)
Problem p02660 (python)

Fixed submission:
import copy
from collections import defaultdict

N = int(input())
tmp = copy.copy(N)
d = defaultdict(int)
if N == 1:
    print(0)
    exit()
for i in range(2, int(N ** 0.5) + 3):
    while N % i == 0:
        N //= i
        d[i] += 1
if N > 1:
    d[N] += 1
ans = 0
for i in d.values():
    tmp = 1
    while i - tmp >= 0:
        i -= tmp
        tmp += 1
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from collections import defaultdict
N = int(input())
d = defaultdict(int)
def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False
l = sieve_of_erastosthenes(N)
cnt = 0
while N != 1 and cnt<len(l):

    while l[cnt] and N%cnt == 0:
        d[cnt] += 1
        N //=cnt
    cnt += 1
ans = 0
for i in d.values():
    tmp = 1
    while i - tmp >= 0:
        i -= tmp
        tmp += 1
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from collections import defaultdict
N = int(input())
d = defaultdict(int)
def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False
l = sieve_of_erastosthenes(int(pow(N,0.5))+2)
cnt = 0
while N != 1 and cnt<len(l):

    while l[cnt] and N%cnt == 0:
        d[cnt] += 1
        N //=cnt
    cnt += 1
ans = 0
for i in d.values():
    tmp = 1
    while i - tmp >= 0:
        i -= tmp
        tmp += 1
        ans += 1
print(ans)
Problem p02675 (python)

Fixed submission:
n=int(list(input())[-1])
if n in [2,4,5,7,9]:
    print('hon')
elif n==3:
    print('bon')
else:
    print('pon')

Buggy submission (verdict: Runtime Error):
from math import gcd
from collections import defaultdict
N=int(input())
mod = 10**9+7
d_1 = defaultdict(int)
d_2 = defaultdict(int)
zeros = 0

def to_irreducible(a,b):
    GCD = gcd(a,b)
    return list(map(lambda x:x//GCD,[a,b]))
for i in range(N):
    a,b=map(int,input().split(' '))
    if a==b==0:
        zeros += 1
        continue
    if a*b >= 0 and b!=0:
        a,b = to_irreducible(abs(a),abs(b))
        d_1[(a,b)] +=1
    else:
        a,b = to_irreducible(abs(b),abs(a))
        d_1[(a,b)] +=0
        d_2[(a,b)] +=1

ans =  1

for k,v_1 in d_1.items():
    v_2 = d_2[k]
    ans *= pow(2,v_1,mod) + pow(2,v_2,mod) -1
    ans %= mod

print(ans+zeros-1)