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

Fixed submission:
# input
N, M = map(int, input().split())

SC = []
for _ in range(M):
    SC.append(tuple(map(int, input().split())))

# process
ans = 0

A = [-1 for _ in range(N)]

for s, c in SC:
    s -= 1
    if s == 0 and c == 0 and N > 1:
        ans = -1
        break
    elif A[s] == -1:
        A[s] = c
    elif A[s] != c:
        ans = -1
        break

if ans != -1:
    if A[0] == -1 and N > 1:
        A[0] = 1
    for i in range(0, N):
        if A[i] == -1:
            A[i] = 0

    A = A[::-1]
    for i in range(N):
        ans += A[i]*(10**i)

# output
print(ans)

Buggy submission (verdict: Runtime Error):
# input
N, M, K = map(int, input().split())

Frends = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a < b:
        Frends[a].append(b)
    else:
        Frends[b].append(a)

Blocked = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    c -= 1
    d -= 1
    if c < d:
        Blocked[c].append(d)
    else:
        Blocked[d].append(c)

# process
# 友人グループを作成
fg = []
for i in range (N):
    fs = Frends[i]
    for f in fs:
        t = -1

        j = 0
        fglen = len(fg)
        while j < fglen:
            g = fg[j]
            if i in g and f in g:
                if t < 0:
                    t = j              
                else:
                    fg[t] = fg[t] | g
                    fg.pop(j)
                    fglen -= 1
            elif not (i in g or f in g):
                j += 1
                continue
            else:
                if t < 0:
                    if i in g:
                        g.add(f)
                    else:
                        g.add(i)

                    t = j
                else:
                    fg[t] = fg[t] | g
                    fg.pop(j)
                    fglen -= 1
            j += 1
            
        if t < 0:
            fg.append(set([i, f]))

# 友人候補を抽出
cand = []
for i in range(N):
    for g in fg:
        if i in g:
            for f in g:
                if i < f and not f in Frends[i] and not f in Blocked[i]:
                    cand.append((i, f,))

# 友人候補をカウント
ans = [0 for _ in range(N)]
for c in cand:
    a, b = c
    ans[a] += 1
    ans[b] += 1

# output
#print(fg)
#print(cand)
print(" ".join(map(str, ans)))
Problem p02767 (python)

Fixed submission:
# input
N = int(input())
X = list(map(int, input().split()))

# process
L = min(X)
R = max(X)

ans = float('inf')
for i in range(L, R+1):
    cost = 0
    for x in X:
        cost += (x-i)**2
    
    if cost < ans:
        ans = cost

# output
print(int(ans))

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
X = list(map(int, input().split()))

# process/output
L = min(X)
R = max(X)

ans = int(float('inf'))
for i in range(L, R+1):
    cost = 0
    for x in X:
        cost += (x-i)**2
    
    if cost < ans:
        ans = cost

print(ans)
Problem p02783 (python)

Fixed submission:
# input
H, A = map(int, input().split())

# output
if H%A == 0: print(H//A)
else: print(H//A+1)

Buggy submission (verdict: Runtime Error):
# input
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

# process
INF = 10**9
dp = [INF]*(H+max(a for a, _ in AB))
dp[0] = 0

for i in range(H):
    if dp[i] == INF:
        continue
    for a, b in AB:
        t = dp[i]+b
        if dp[i+a] > t:
            dp[i+a] = t

# output
print(min(dp[H:]))
Problem p02814 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // gcd(t, l[i])
    return t

# input
N, M = map(int, input().split())
A = list(map(lambda x: x//2, map(int, set(input().split()))))

# process
ans = 0
lc = lcm(A)

if lc <= M:
    f = True
    for a in A:
        if lc//a%2 == 0:
            f = False
            break

    if f:
        ans = int(M/lc-1)//2+1

# output
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // fractions.gcd(t, l[i])
    return t

# input
N, M = map(int, input().split())
A = list(map(int, set(input().split())))

# process/output
a = lcm(A)

if a/2 > M: 
    print(0)

else:
    print(int(M/a-0.5)+1)

Buggy submission (verdict: Runtime Error):
import math

def lcm(l):
    if len(l) == 1:
        return l[0]

    t = l[0]
    for i in range(1, len(l)):
        t = (t * l[i]) // math.gcd(t, l[i])
    return t

# input
N, M = map(int, input().split())
A = list(map(int, set(input().split())))

# process
a = lcm(A)
p = int(M/a-0.5)

# output
if p == 0: print(0)
else: print(p+1)
Problem p02840 (python)

Fixed submission:
from fractions import gcd

# inputa
n , x , d = map(int, list(input().split()))

# process
if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)

else:
    # sが何通りあるかを求める
    
    # dを正にする
    if d < 0: d, x = -d, -x

    # d,xを互いに素にする   
    g = gcd(d, abs(x))
    d, x =  d//g, x//g
    
    # s=k*x+c*d
    # cは最小で0からk-1の和、最大でn-kからn-1の和
    # kを固定するとs//dは1ずつの単調増加なので、最小と最大で個数が分かる

    # sはs%d=k*x%dなので、それで分類する
    # →klistをk*x%dでソート
    klist = list(range(n + 1))
    klist.sort(key=lambda k: (k*x%d, k))

    # kを固定し、cの最小・最大を求め、加算していく
    ans = 0

    # 1つ前の値を保持
    pmin, pmax = 1, 0
    pmd = -1
    for k in klist:
        # s//dの最小・最大・s%d
        tmin = (k * x + (k - 1) * k // 2 * d) // d
        tmax = (k * x + (2 * n - k - 1) * k // 2 * d) // d
        tmd = k*x%d

        # s%dが前と同じ　かつ
        # s//dの最小<=前の最大　かつ　s//dの最大>=前の最小のとき
        # 最大・最小を更新
        if tmd == pmd and tmin <= pmax and tmax >= pmin:
            pmin, pmax = min(pmin, tmin), max(pmax, tmax)
        else:
            ans += pmax - pmin + 1
            pmin, pmax = tmin, tmax
        pmd = tmd
        
    ans += pmax - pmin + 1
    print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd

# inputa
n , x , d = map(int, list(input().split()))

# process
if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)

else:
    # sが何通りあるかを求める
    
    # dを正にする
    if d < 0: d, x = -d, -x

    # d,xを互いに素にする   
    g = gcd(d, abs(x))
    d, x =  d//g, x//g
    
    # s=k*x+c*d
    # cは最小で0からk-1の和、最大でn-kからn-1の和
    # kを固定するとs//dは1ずつの単調増加なので、最小と最大で個数が分かる

    # sはs%d=k*x%dなので、それで分類する
    # →klistをk*x%dでソート
    klist = list(range(n + 1))
    klist.sort(key=lambda k: (k*x%d, k))

    # kを固定し、cの最小・最大を求め、加算していく
    ans = 0

    # 1つ前の値を保持
    pmin, pmax = 1, 0
    pmd = -1
    for k in klist:
        # s//dの最小・最大・s%d
        tmin = (k * x + (k - 1) * k // 2 * d) // d
        tmax = (k * x + (2 * n - k - 1) * k // 2 * d) // d
        tmd = k*x%d

        # s%dが前と同じ　かつ
        # s//dの最小<=前の最大　かつ　s//dの最大>=前の最小のとき
        # 最大・最小を更新
        if tmd == pmd and tmin <= pmax and tmax >= pmin:
            pmin, pmax = min(pmin, tmin), max(pmax, tmax)
        else:
            ans += pmax - pmin + 1
            pmin, pmax = tmin, tmax
        pmd = tmd
        #print(k, l, r, pl, pr, ans)
    
    ans += pmax - pmin + 1
    print(ans)
Problem p02850 (python)

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

# input
n = int(input())

edges = [[] for i in range(n)]
for i in range(n-1):
    a ,b = map(int, list(input().split()))
    edges[a-1].append((b-1, i))

# process
ans = [0]*(n-1)

def f(a, c):
    color = 1
    for b, i in edges[a]:
        if color == c: color += 1
        ans[i] = color 
        f(b, color)
        color += 1

f(0, 0)

# output
print(max(ans))
for i in ans:
    print(i)

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

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

# process
ans = [0 for i in range(n-1)]

def f(pa, c):
    color = 1
    for pb in edge[pa]:
        if color == c: color += 1
        ans[pb[1]] = color 
        f(pb[0], color)
        color += 1

f(0, 0)

# output
print(max(ans))
for i in ans:
    print(i)
Problem p02743 (python)

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

if 4*a*b < (c - a - b)*(c-a-b) and a + b< c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
 
a,b,c = listint()
if a+b+2*math.sqrt(a*b) < c:
    print('Yes')
else:
    print('No')
import math
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

a,b,c = listint()
if math.sqrt(a)+math.sqrt(b) < math.sqrt(c):
    print('Yes')
else:
    print('No')
Problem p02995 (python)

Fixed submission:
from fractions import gcd

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

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

AdivisibleC = (A - 1) // C
AdivisibleD = (A - 1) // D
AdivisibleCD = (A - 1) // lcm(C, D)
AindivisibleCD = (A - 1) - (AdivisibleC + AdivisibleD - AdivisibleCD)

BdivisibleC = B // C
BdivisibleD = B // D
BdivisibleCD = B // lcm(C, D)
BindivisibleCD = B - (BdivisibleC + BdivisibleD - BdivisibleCD)

print(BindivisibleCD - AindivisibleCD)

Buggy submission (verdict: Runtime Error):
import math

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

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

AdivisibleC = (A - 1) // C
AdivisibleD = (A - 1) // D
AdivisibleCD = (A - 1) // lcm(C, D)
AindivisibleCD = (A - 1) - (AdivisibleC + AdivisibleD - AdivisibleCD)

BdivisibleC = B // C
BdivisibleD = B // D
BdivisibleCD = B // lcm(C, D)
BindivisibleCD = B - (BdivisibleC + BdivisibleD - BdivisibleCD)

print(BindivisibleCD - AindivisibleCD)
Problem p02630 (python)

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

m = {}
for i in a:
    if i in m.keys():
        m[i] = m[i] + 1
    else:
        m[i] = 1

ans = 0
for k in m:
    ans += m[k] * k

for i in range(q):
    b, c = map(int,input().split())
    if b in m.keys():
        t = 0
        if c in m.keys():
            t = m[c] * c
            m[c] = m[c] + m[b]
        else:
            m[c] = m[b]
        ans += m[c] * c - m[b] * b - t
        m.pop(b)
    print(ans)

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

m = {}
for i in a:
    if i in m.keys():
        m[i] = m[i] + 1
    else:
        m[i] = 1

for i in range(q):
    b, c = map(int,input().split())
    m[c] = m[c] + m[b]
    m.pop(b)
    ans = 0
    for k in m:
        ans += m[k] * k
    print(ans)
Problem p02795 (python)

Fixed submission:
h = int(input().rstrip())
w = int(input().rstrip())
n = int(input().rstrip())

if h > w:
    div = h
else:
    div = w

if n % div > 0:
    ans = int(n / div) + 1
else:
    ans = int(n / div)

print(ans)

Buggy submission (verdict: Runtime Error):
class Robot:
    def __init__(self, x, l):
        self.x = x
        self.l = l
    
    def __lt__(self, other):
        return self.x < other.x

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]), int(line[1]))

robos.sort()

i = 0
ans = 0
while i < n:
    s = robos[i].x
    r = robos[i].l
    i += 1
    while i < n and robos[i].x <= s + r:
        i += 1
    
    p = robos[i - 1].x
    while i < n and robos[i].x <= p + robos[i].l:
        i += 1
    
    ans += 1

print(ans)
Problem p02796 (python)

Fixed submission:
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1]))

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

Buggy submission (verdict: Runtime Error):
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1])

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input().rstrip())
robos = []
max = 0

for i in range(n):
    line = input().rstrip().split(' ')
    array = [int(line[0]), int(line[1])]
    robos.append(array)
    if max < array[0] + array[1] - 1:
        max = array[0] + array[1] - 1

field = [0] * max
count = 0
for item in robos:
    countFlg = True
    for i in range(item[0] - item[1] + 1, item[0] + item[1] - 1):
        if i < 0:
            continue
        if field[i] == 0:
            field[i] = 1
        else:
            countFlg = False
            break
    if countFlg == True:
        count += 1

print(count)
Problem p02675 (python)

Fixed submission:
x = input()
l = [2,4,5,7,9]
i = [0,1,6,8]
if int(x[-1]) in l:
    print("hon")
elif int(x[-1]) in i:
    print("pon")
elif x[-1] == "3":
    print("bon")

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=list(map(int, input().split()))


th_a = 360/12 * h + 360/12*m/60
th_b = 360*m/60
print(th_a)
print(th_b)
ab_th = abs(th_a - th_b)
if ab_th > 180:
    ab_th = 360 - ab_th

print(math.sqrt(a*a + b*b -2*a*b*math.cos(math.radians(ab_th))))

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=list(map(int, input().split()))


th_a = 360/12 * h + 360/12*m/60
th_b = 360*m/60
print(th_a)
print(th_b)
ab_th = abs(th_a - th_b)
if ab_th >= 180:
    ab_th = 360 - ab_th

print(math.sqrt(a*a + b*b -2*a*b*math.cos(math.radians(ab_th))))
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

if N == 0:
  print(X)
  exit()
elif N == 100:
  print(d)
  exit()
else:
  p = set(map(int, input().split()))

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li == l:
      if i+1 < d:
        d = i+1
    elif li > l:
      break
print(d)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(-1)
  else:
    print(101)
else:
  p = set(map(int, input().split()))

l = 100
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)
Problem p02678 (python)

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

def main():
  N, M = map(int, readline().split())
  dist = {}
  pre = {}
  A = {}
  for i in range(N):
    dist[i+1] = -1
    pre[i+1] = -1
    A[i+1] = []
  dist[1] = 0
  pre[1] = 0
  for i in range(M):
    ai, bi = map(int, readline().split())
    A[ai].append(bi)
    A[bi].append(ai)
  cnt = 1
  depth = 1
  D = [1]
  while cnt < N:
    next = []
    for i in range(len(D)):
      for j in range(len(A[D[i]])):
        if dist[A[D[i]][j]] == -1:
          dist[A[D[i]][j]] = depth
          pre[A[D[i]][j]] = D[i]
          next.append(A[D[i]][j])
          cnt += 1
    D = next
    depth += 1
    if len(next) == 0:
      break
    elif depth > N:
      break
  if cnt == N:
    print('Yes')
    for i in range(1, N):
      print(pre[i+1])
  else:
    print('No')

if __name__ == '__main__':
  main()

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

def main():
  N, M = map(int, readline().split())
  dist = {}
  pre = {}
  A = {}
  for i in range(N):
    dist[i+1] = -1
    pre[i+1] = -1
    A[i+1] = []
  dist[1] = 0
  pre[1] = 0
  for i in range(M):
    ai, bi = map(int, readline().split())
      A[ai].append(bi)
      A[bi].append(ai)
  cnt = 1
  depth = 1
  D = [1]
  while cnt < N:
    next = []
    for i in range(len(D)):
      for j in range(len(A[D[i]])):
        if dist[A[D[i]][j]] == -1:
          dist[A[D[i]][j]] = depth
          pre[A[D[i]][j]] = D[i]
          next.append(A[D[i]][j])
          cnt += 1
    D = next
    depth += 1
    if len(next) == 0:
      break
    elif depth > N:
      break
  if cnt == N:
    print('Yes')
    for i in range(1, N):
      print(pre[i+1])
  else:
    print('No')

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

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

def main():
  N = int(readline())
  Sp = []
  Sm = []
  total = 0
  bm = 0
  for i in range(N):
    l = readline().strip()
    b = 0
    h = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      b = min(b, h)
    if h == 0 and b != 0:
      bm = min(bm, b)
    elif h > 0:
      Sp.append([b, h])
    elif h < 0:
      Sm.append([b-h, -h])
    total += h
  Sp.append([bm, 0])
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda x:x[0], reverse=True)
  p = check(Sp)
  if p < 0:
    print('No')
    exit()
  Sm.sort(key=lambda x:x[0], reverse=True)
  m = check(Sm)
  if m < 0:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return -1
    else:
      h += S[i][1]
  return h

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  Sp = []
  Sm = []
  total = 0
  for i in range(N):
    l = input()
    u = 0
    h = 0
    um = 0
    for j in range(len(l)):
      if l[j] == '(':
        h += 1
      else:
        h -= 1
      u = min(u, h)
    if h == 0:
      um = min(um, u)
    elif h > 0:
      Sp.append([u, h])
    else:
      Sm.append([u-h, -h])
    total += h
  if total != 0:
    print('No')
    exit()
  Sp.sort(key=lambda, x:x[0])
  p = check(Sp)
  if p < 0 or p < -um:
    print('No')
    exit()
  Sm.sort(key=lambda, x:x[0])
  m = check(Sm)
  if m < 0:
    print('No')
    exit()
  print('Yes')

def check(S):
  h = 0
  for i in range(len(S)):
    if h + S[i][0] < 0:
      return -1
    else:
      h += S[i][1]
  return h

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

Fixed submission:
N = input()
x = N[-1]

if x == '3':
    print("bon")
elif x == '0' or x == '1' or x == '6' or x == '8':
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
d = [0] + [100000]*(n-1)
a = [[float('inf') for j in range(n)] for i in range(n)]
t = [0]*n

for i in range(m):
    a[l[i][0]-1][l[i][1]-1] = 1
    a[l[i][1]-1][l[i][0]-1] = 1

for i in range(n):
    for j in range(n):
        if d[i] + a[i][j] < d[j]:
            d[j] = d[i] + a[i][j]
            t[j] = i+1
if 0 in t[1:]:
    print("No")
else:
    print('Yes')
    for i in range(1,n):
        print(t[i])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
d = [0] + [100000]*(n-1)
a = [[float('inf') for j in range(n)] for i in range(n)]
t = [0]*n

for i in range(m):
    a[l[i][0]-1][l[i][1]-1] = 1
    a[l[i][1]-1][l[i][0]-1] = 1

for i in range(n):
    for j in range(n):
        if d[i] + a[i][j] < d[j]:
            d[j] = d[i] + a[i][j]
            t[j] = i+1
if 0 in t[1:]:
    print("No")
else:
    print('Yes')
    for i in range(1,n):
        print(t[i])

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
l = len(S)
if l > K:
    print("{}...".format(S[:K]))
else:
    print(S)
Problem p02683 (python)

Fixed submission:
n,m,x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')

for i in range(2**n):
    sum = [0]*(m+1)
    # n桁について調査
    for j in range(n):
        # iのj桁目が1かどうかcheck
        if (i >> j) & 1:
            for k in range(m+1):
                sum[k] += l[j][k]
    if sum[0] < ans:
        for a in range(1,m+1):
            if sum[a] < x:
                break
        else:
            ans = sum[0]
if ans == float('inf'):
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = float('inf')

for i in range(2**n):
    sum = [0]*(M+1)
    # n桁について調査
    for j in range(n):
        # iのj桁目が1かどうかcheck
        if ((i >> j) & 1):
            for k in range(M+1):
                sum[k] += l[j][k]
    if sum[0] < ans:
        for a in range(1,m+1):
            if sum[a] < x:
                break
            else:
                ans = sum[0]
if ans == float('inf'):
    print(-1)
else:
    print(ans)
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
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 = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break
Problem p02690 (python)

Fixed submission:
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 = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break

Buggy submission (verdict: Runtime Error):
x = int(input())
div = make_divisors(x)

if x == 1: print("0 -1")

for i in range(len(div)//2):
    u = div[i*2]
    if len(div)%2 == 1: v = div[i*2]
    else: v = div[i*2+1]
    t = int(v**(1/2))
    for j in range(t):
        a = j
        b = j-u
        if a**4 + (a**3)*b +(a**2)*(b**2) + a*(b**3) + b**4 == v:
            print(a, b)
            break
Problem p02702 (python)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(n):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(n):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = dig*10%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)