Problem p02963 (python)

Fixed submission:
S = int(input())

if S == 10**18:
  x1,y1 = 0,0
  x2 = 10**9
  y3 = 10**9
  x3 = 0
  y2 = 0

else:
  x1, y1 = 0,0

#|x2y3-x3y2|=S

  x2 = 10**9
  y2 = 1

#|10**9y3-x3|= s

  y3 = (S//(10**9)) + 1
  x3 = (10**9)*y3 - S

print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Buggy submission (verdict: Runtime Error):
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  f = list1[::-1]
  st = 1
  i = 0
  while (st <= 10**9)&(i<len(list1)):
    st *= list1[i]
    i += 1
  if st > 10**9:
    st = st//list1[i-1]
  x2,y2 = st,0
  x3,y3 = 0,S//st

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Buggy submission (verdict: Runtime Error):
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  f = list1[::-1]
  st = 1
  i = 0
  while (st <= 10**9)&(i<len(list1)):
    st *= list1[i]
    i += 1
  x2,y2 = st,0
  x3,y3 = 0,S//st

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Buggy submission (verdict: Runtime Error):
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    i = 0
    fct = []
    while (b * b <= n) & (i<=5):
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
        i += 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  f = list1[::-1]
  st = 1
  i = 0
  while (st <= 10**9)&(i<len(list1)):
    st *= list1[i]
    i += 1
  x2,y2 = st,0
  x3,y3 = 0,S//st

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Buggy submission (verdict: Runtime Error):
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  b = int(list1[-1])
  x2,y2 = b,0
  x3,y3 = 0,S//b

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))

Buggy submission (verdict: Runtime Error):
import math

x1,y1 = 0, 0

def fact(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

S = int(input())

list1 = sorted(fact(S))#おおきいのが最後

if int(list1[-1]) <= 10**9:
  b = int(list1[-1])
  x2,y2 = b,0
  x3,y3 = 0,S//b

else:
  list2 = []
  list2.append(int(S//list1[-1]))
  while list1[-1] > 10**9:
    dash = list1[-1]
    list1 = fact(dash + 1)
    list2.append(int((dash+1)//list1[-1]))

  sum1 = 1
  for i in range(len(list2)):
    sum1 = list2[i]*sum1
  sum3 = sum1
  sum2 = 0
  sum4 = 1
  for i in range(len(list2)-1):
    sum4 *= list2[i] 
    sum2 += sum4

  y2 = fact(sum2)[-1]
    
  b = list1[-1]
  x2 = b
  x3 = sum2//y2
  y3 = (S + x3*y2)//b
  s = x2*y3 - x3*y2
  
print(int(x1),int(y1),int(x2),int(y2),int(x3),int(y3))