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

Fixed submission:
# import math
from fractions import gcd

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

cd_lcm = c * d // gcd(c, d)

x1 = b//c - (a-1)//c
x2 = b//d - (a-1)//d
x3 = b//cd_lcm - (a-1)//cd_lcm

print((b-(a-1))-x1-x2+x3)

Buggy submission (verdict: Runtime Error):
import math

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

cd_gcd = math.gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a + 1) - (b - a -1)//c - (b - a -1)//d + (b - a -1)//cd_lcm
print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

cd_gcd = math.gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a) - (b - a)//c - (b - a)//d + (b - a)//cd_lcm
print(ans)
Problem p03076 (python)

Fixed submission:
a = [int(input()) for _ in range(5)]
delta = []
time = 0
count = 0

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
        count += 0
    time += a[i] + a10

if count == 0:
    delta.append(0)

print(time-max(delta))

Buggy submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
delta = []
time = 0

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
    time += a[i] + a10


print(time-max(delta))
Problem p03523 (python)

Fixed submission:
s = list(input())

if 5 <= len(s) <= 9:
    if s[0] != 'A':
        s.insert(0, 'A')
    if s[4] != 'A':
        s.insert(4, 'A')
    if s[6] != 'A':
        s.insert(6, 'A')
    if len(s) == 8:
        s.append('A')

    if s == ['A','K','I','H','A','B','A','R','A']:
        print('YES')
    else:
        print('NO')

else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = list(input())

if len(s) <= 9:
    if s[0] != 'A':
        s.insert(0, 'A')
    if s[4] != 'A':
        s.insert(4, 'A')
    if s[6] != 'A':
        s.insert(6, 'A')
    if len(s) == 8:
        s.append('A')

if s == ['A','K','I','H','A','B','A','R','A']:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = list(input())

if len(s) <= 9:
    if s[0] != 'A':
        s.insert(0, 'A')
    if s[4] != 'A':
        s.insert(4, 'A')
    if s[6] != 'A':
        s.insert(6, 'A')
    if len(s) == 8:
        s.append('A')

if s == ['A','K','I','H','A','B','A','R','A']:
    print('YES')
else:
    print('NO')
Problem p03611 (python)

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

ans = [0] * (10 ** 5 + 2)
for a in al:
    ans[a] += 1
    ans[a + 1] += 1
    ans[a - 1] += 1

print(max(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))

if n == 1:
    print(1)
else:
    m = max(al)
    num = [0]*m
    for a in al:
        num[a-1] += 1

    ans = 0
    for i in range(m-3):
        ans = max(ans, sum(num[i:i+3]))

    print(ans)
Problem p03627 (python)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
c = Counter(A)

over4 = []
over2 = []

for k, v in c.items():
    if v >= 4:
        over4.append(k)
    elif v >= 2:
        over2.append(k)

over4.sort(reverse=True)
over2.sort(reverse=True)

s1, s2, s3 = 0, 0, 0
if len(over4) > 0:
    s1 = over4[0]**2
if len(over2) >= 2:
    s2 = over2[0]*over2[1]
if len(over4) > 0 and len(over2) > 0:
    s3 = over4[0]*over2[0]

print(max(s1, s2, s3))

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

n = int(input())
A = list(map(int, input().split()))
c = Counter(A)

over4 = []
over2 = []

for k, v in c.items():
    if v >= 4:
        over4.append(k)
    elif v >= 2:
        over2.append(k)

over4.sort(reverse=True)
over2.sort(reverse=True)

s1, s2, s3 = 0, 0, 0
if len(over4) > 0:
    s1 = over4[0]**2
if len(over2) >= 1:
    s2 = over2[0]*over2[1]
if len(over4) > 0 and len(over2) > 0:
    s3 = over4[0]*over2[0]

print(max(s1, s2, s3))
Problem p03673 (python)

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

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    ans = left[::-1] + right
else:
    ans = right[::-1] + left

print(*ans, sep=' ')

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    left = left[::-1]
    print(*left, *right, sep=' ')
else:
    right = right[::-1]
    print(*right, *left, sep=' ')

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    left = left[::-1]
    print(*left, *right, sep=' ')
else:
    right = right[::-1]
    print(*right, *left, sep=' ')

Buggy submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))

left = []
right = []

for i in range(n):
    if i % 2 == 0:
        right.append(al[i])
    else:
        left.append(al[i])

if n % 2 == 0:
    left = left[::-1]
    print(*left, *right, sep=' ')
else:
    right = right[::-1]
    print(*right, *left, sep=' ')
Problem p03760 (python)

Fixed submission:
ol = list(input())
el = list(input())
ans = ''

for i in range(min(len(ol), len(el))):
    ans += ol.pop(0) + el.pop(0)
if len(ol) > 0:
    ans += ol.pop()

print(ans)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
ans = ''
for i in range(len(o)):
    ans += o[i]+e[i]

print(ans)
Problem p02885 (python)

Fixed submission:
a, b = [int(x) for x in input().split()]
ans = a - 2*b

if(ans < 0):
		ans=0

print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input("enter a no"))
b=int(input("enter a no"))

if a>2*b:
	print(a-2*b)


else:
	print(0)

Buggy submission (verdict: Runtime Error):
a=int(input("enter a no"))
b=int(input("enter a no"))

if a>2b:
	print(a-2b)


else:
	print(0)
Problem p02618 (python)

Fixed submission:
# 点数計算
def scoring(last, c, s, t, d, score):
    # score += s[d][t[d]-1]
    score = s[d][t]
    for i in range(len(c)):
        #score -= c[i] * (d+1 - last[d][i])
        score -= c[i] * (d + 1 - last[i])
    return score


# input
score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
# t = []
# for i in range(D):
#     t.append(int(input()))
last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

ans = []
for d in range(D):
    # last[d][t[d]-1] = d+1
    last_dummy = last[d][:]
    score = 0
    t_d = 0
    for t in range(len(c)):
        last_dummy2 = last_dummy[:]
        last_dummy2[t] = d+1
        if score < scoring(last_dummy2, c, s, t, d, score):
            score = scoring(last_dummy2, c, s, t, d, score)
            t_d = t
    ans.append(t_d)
    last[d][t_d] = d+1


    # last更新
    for i in range(len(c)):
        last[d+1][i] = last[d][i]


[print(ans[i]+1) for i in range(D)]

Buggy submission (verdict: Runtime Error):
# 点数計算
def scoring(last_, c, s, t, d, score):
    # score += s[d][t[d]-1]
    score = s[d][t]
    k = 8
    
    for i in range(len(c)):
        # score -= c[i] * (d+1 - last_[d][i])
        # score -= c[i] * (d + 1 - last_[i])
        score -= k * c[i] * (d - last_[i]) + c * (k * (k+1)) / 2
    return score


# input
score = 0
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    s.append([int(i) for i in input().split()])
# t = []
# for i in range(D):
#     t.append(int(input()))
last = [[0 for i in range(len(c))] for j in range(D+1)] # last[d][i]

ans = []
for d in range(D):
    # last[d][t[d]-1] = d+1
    last_dummy = last[d][:]
    score = 0
    t_d = 0
    for t in range(len(c)):
        last_dummy2 = last_dummy[:]
        last_dummy2[t] = d+1
        if score < scoring(last_dummy2, c, s, t, d, score):
            score = scoring(last_dummy2, c, s, t, d, score)

            t_d = t

    ans.append(t_d)
    last[d][t_d] = d+1


    # last更新
    for i in range(len(c)):
        last[d+1][i] = last[d][i]


[print(ans[i]+1) for i in range(D)]
Problem p02628 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:k]))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) in input().split()]
p = [int(i) in input().split()]
p.sort()
print(sum(p[:k])
Problem p02901 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
dp = [[float("inf") for i in range(2**n)] for j in range(m+1)]
dp[0][0] = 0

for i in range(m):
    a, _ = [int(_) for _ in input().split()]
    c = sum([2**(int(_)-1) for _ in input().split()])

    for j in range(2**n):
        dp[i+1][j|c] = min(dp[i][j|c], dp[i][j] + a, dp[i+1][j|c])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

print([dp[-1][-1], -1][dp[-1][-1] == float("inf")])

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
dp = [float("inf") for i in range(n**2)]

for i in range(m):
    a, _ = [int(i) for i in input().split()]
    c = sum([2**(int(i)-1) for i in input().split()])
    for j in range(n**2):
        if j == 0:
            dp[c] = min(dp[c], a)

        elif dp[j] != float("inf"):
            dp[j|c] = min(dp[j|c], dp[j] + a)

print([dp[-1], -1][dp[-1] == float("inf")])
Problem p02902 (python)

Fixed submission:
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


g = Graph()
N, M = [int(i) for i in input().split()]


for i in range(M):
    u, v = [int(i) for i in input().split()]
    g.add_edge(u-1, v-1, 1)
    g.add_edge(u-1+N, v-1, 1)
    g.add_edge(u-1, v-1+N, 1)

d = Dijkstra(g, 0)

ans_n = 10 ** 6
ans_index = -1
for i in range(N):
    d = Dijkstra(g, i)
    ans_n_ = d.dist[i+N]

    if ans_n_ < ans_n:
        ans_index = i
        ans_n = ans_n_

if ans_n == 10 ** 6:
    print(-1)
else:
    d = Dijkstra(g, ans_index)
    ans = d.shortest_path(ans_index + N)
    ans.sort()
    print(ans_n)
    for j in range(ans_n):
        print(ans[j]+1)

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

if N >= 700:
      print(aaa)
    
else:
  print("a")

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

if M >= 1500:
      print(aaa)
    
else:
  print("a")

Buggy submission (verdict: Runtime Error):
from scipy.sparse import coo_matrix
from scipy.sparse.csgraph import bellman_ford
N, M = [int(i) for i in input().split()]
rows = []
cols = []
weights = []

for _ in range(M):
    # u v 間のコスト
    u, v = [int(i) for i in input().split()]
    rows.append(u-1)
    cols.append(v-1)
    weights.append(-1)

graph = coo_matrix((weights, (rows, cols)), shape=(N, N)).tocsr()
for i in range(N):
    try:
        d1 = bellman_ford(graph, indices = [i], directed=True, unweighted=False)
    except:
        print(0)
        exit()
else:
    print(-1)
Problem p02995 (python)

Fixed submission:
import fractions

a, b, c, d = [int(i) for i in input().split()]

if c == 1 or d == 1:
    print(0)
    exit()

c_left = max(0, [a // c - 1, a // c][a % c != 0])
c_right = b // c

d_left = max(0, [a // d - 1, a // d][a % d != 0])
d_right = b // d

cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = max(0, [a // cdgcd - 1, a // (cdgcd)][a % (cdgcd) != 0])
cd_right = b // (cdgcd)

c_number = c_right - c_left
d_number = d_right - d_left
cd_number = cd_right - cd_left

print(b - a + 1 - (c_number + d_number - cd_number))

Buggy submission (verdict: Runtime Error):
import fractions
a, b, c, d = [int(i) for i in input().split()]

c_left = [a // c - 1, a // c][a % c != 0]
c_right = b // c

c_number = c_right - c_left

d_left = [a // d - 1, a // d][a % d != 0]
d_right = b // d

d_number = d_right - d_left
cdgcd = (c * d) // fractions.gcd(c, d)

cd_left = [a // (cdgcd - 1), a // (cdgcd)][a % (cdgcd) != 0]
cd_right = b // (cdgcd)

cd_number = cd_right - cd_left

print(b - a + 1 -  (c_number + d_number - cd_number))

Buggy submission (verdict: Runtime Error):
import fractions
a, b, c, d = [int(i) for i in input().split()]

c_left = [a // c - 1, a // c][a % c != 0]
c_right = b // c

c_number = c_right - c_left

d_left = [a // d - 1, a // d][a % d != 0]
d_right = b // d

d_number = d_right - d_left
cdgcd = int(c * d / fractions.gcd(c, d))

cd_left = [a // (cdgcd - 1), a // (cdgcd)][a % (cdgcd) != 0]
cd_right = b // (cdgcd)

cd_number = cd_right - cd_left


print(b - a + 1 -  (c_number + d_number - cd_number))
Problem p03035 (python)

Fixed submission:
a, b = [int(i) for i in input().split()]
if a <= 5:
    print(0)
elif a <= 12:
    print(b//2)
else:
    print(b)

Buggy submission (verdict: Runtime Error):
q = int(input())

keisuu_lower = []
keisuu_upper = []
keisuu_lower_max = 0
keisuu_upper_min = float("inf")
keisuu_lower_count = 0
keisuu_upper_count = 0
keisuu_lower_sum = 0
keisuu_upper_sum = 0
teisuu = 0

for i in range(q):
    query = input()
    if query == "2":
        print(keisuu_lower_max,
              - keisuu_lower_sum + keisuu_lower_count * keisuu_lower_max
              + keisuu_upper_sum - keisuu_upper_count * keisuu_lower_max + teisuu)

    else:
        _, a, b = [int(i) for i in query.split()]
        keisuu_lower.append(a)
        keisuu_lower_count += 1
        keisuu_lower_max = max(keisuu_lower_max, a)
        keisuu_lower_sum += a

        if keisuu_lower_count > keisuu_upper_count + 1:
            keisuu_lower.sort()
            c = keisuu_lower.pop()
            keisuu_lower_count -= 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum -= c

            keisuu_upper.append(c)
            keisuu_upper.sort(reverse=True)
            keisuu_upper_count += 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum += c

        elif keisuu_lower_count < keisuu_upper_count:
            keisuu_upper.sort()
            c = keisuu_upper.pop()
            keisuu_upper_count -= 1
            keisuu_upper_min = keisuu_upper[-1]
            keisuu_upper_sum -= c

            keisuu_lower.append(c)
            keisuu_lower.sort(reverse=True)
            keisuu_lower_count += 1
            keisuu_lower_max = keisuu_lower[-1]
            keisuu_lower_sum += c

        if keisuu_lower_max > keisuu_upper_min:
            d = keisuu_upper.pop()
            e = keisuu_lower.pop()
            keisuu_lower.append(d)
            keisuu_upper.append(e)
            keisuu_lower_sum += d - e
            keisuu_upper_sum += e - d
            keisuu_lower_max = d
            keisuu_upper_min = e

        #print(keisuu_lower)
        #print(keisuu_lower_sum)
        #print(keisuu_lower_max)
        teisuu += b
Problem p03050 (python)

Fixed submission:
import math
n = int(input())
ans = 0



for i in range(1, int(n**0.5)+1):
    n2 = n - i

    if n2 % i == 0:
        #print(i, n2 / i)
        #print(n2+i , n//(n2//i), i)

        try:
            if n//(n2//i) == i:
                ans += math.ceil(n2 / i)
        except:
            pass

print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = 0
for i in range(1, int(n**0.5)+1):
    n2 = n - i
    if n2 % i == 0:
        #print(n2+i , n/(n2/i), i)
        if abs(n/(n2/i) - i) < 0.8:
            ans += math.ceil(n2 / i)

print(ans)
Problem p03096 (python)

Fixed submission:
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+200000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+10000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+10)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()

Buggy submission (verdict: Runtime Error):

def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+1)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod

        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1

    print(dp[-1] % mod)

main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    c = []
    state = [0 for i in range(n+1)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] += dp[state[c_i]] + dp[i]
        else:
            dp[i+1] = dp[i]

        state[c_i] = i + 1

    print(dp[-1])

main()
Problem p03194 (python)

Fixed submission:
n, p = [int(i) for i in input().split()]
if n >= 10 ** 4:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Buggy submission (verdict: Runtime Error):
def binpow(x, e):
  a = 1.0 #結果変数の初期化
  p = x   #二乗値の初期化
  while e > 0:   #不定反復
    if e % 2 == 0: #指数が偶数のとき
      p *= p
      e /= 2     #二乗値の更新
    else:        #指数が奇数のとき
      a *= p
      e -= 1     #二乗値の乗算
  return a

n, p = [int(i) for i in input().split()]
num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % binpow(dv, n) == 0:
        ans = dv
        break
print(ans)
Problem p03240 (python)

Fixed submission:
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) - abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)

Buggy submission (verdict: Runtime Error):
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]
for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
for i in range(101):
  for j in range(101):
    for k in range(n):
      if h[k] != 0:
        H = abs(i - x[k]) + abs(j - y[k]) + h[k] 
    for k in range(n):
      if H - abs(i - x[k]) + abs(j - y[k]) <=0:
        if h[k] != 0:
          break
      elif  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)

Buggy submission (verdict: Runtime Error):
n = int(input())

x = [int(i) for i in range(n)]
y = [int(i) for i in range(n)]
h = [int(i) for i in range(n)]

for i in range(n):
  x[i], y[i], h[i] = [int(i) for i in input().split()]
  
for i in range(101):
  for j in range(101):
    H = abs(i - x[0]) + abs(j - y[0]) + h[0] 
    for k in range(n):
      if  H != abs(i - x[k]) + abs(j - y[k]) + h[k]:
        break
    else:
      ansx = i
      ansy = j
      ansH = H
      
print(ansx, ansy, ansH)
Problem p03267 (python)

Fixed submission:
l=int(input())
for i in range(21):
  if 2 ** i > l:
    n = i
    break

m = (n - 1) * 2
  
s = l -  2 ** (n - 1)
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(n - 1):
  if s >= 2 ** (n - 2 - i) :
    s -= 2 ** (n - 2 - i)
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)
  
#print(path_add)
#print(path_add_value)
#print(s)  
  
print(n, m + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  
for i in range(n - 1):
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i])

Buggy submission (verdict: Runtime Error):
L = int(input())
N = math.ceil(math.log2(L))

M = N*2-2
add_path = []
for i in range(1,N)[::-1]:
    if L-2**(i-1) >= 2**(N-1):
        add_path.append([i, L-2**(i-1)]); L -= 2**(i-1)
print(N, M+len(add_path))
for i in range(1,N):
    print(i, i+1, 0)
    print(i, i+1, 2**(i-1))
for i in add_path:
    print(i[0], N, i[1])

Buggy submission (verdict: Runtime Error):
import math

l = int(input())
n = math.ceil(math.log2(l))

bin_str = bin(l -  2 ** (n - 1))
value = 2 ** (n - 1)

path_add = [0 for i in range(n - 1)]
path_add_value = [0 for i in range(n - 1)]

for i in range(len(bin_str) - 2):
  if bin_str[-(i + 1)] == "1":
    path_add[-(i + 1)] = 1
    path_add_value[-(i + 1)] = value
    value += 2 ** (n - 2 - i)

print(n, (n - 1) * 2 + sum(path_add))
for i in range(n - 1):
  print(i + 1, i + 2, 0)
  print(i + 1, i + 2, 2 ** i)
  if path_add[i] == 1:
    print(i + 1, n, path_add_value[i])