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

Fixed submission:
x = int(''.join(input().split()))
for i in range(int(x/2) + 1):
    if x == i * i:
        break
print('Yes' if  x == i * i else 'No')

Buggy submission (verdict: Runtime Error):
x = int(''.join(input().split()))
for i in range(int(x/2) + 1):
    if x == i * i:
        return print('Yes')
print('No')

Buggy submission (verdict: Runtime Error):
x = int(''.join(input().split()))
for i in range(int(x/2) + 1):
    if x == i * i:
        return print('Yes')
print('No')

Buggy submission (verdict: Runtime Error):
x = int(''.join(input().split()))
for i in range(int(x/2) + 1):
    if x == i * i:
        return print('Yes')
print('No')
Problem p03471 (python)

Fixed submission:
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    for j in range(N+1):
        k = N - i - j

        if k >= 0 and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        if N == i + j + k and Y == i * 10000 + j * 5000 + k * 1000:
            print(i,j,k)
            sys.exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        if N < i + j or Y < i * 10000 + 5000 * j:
            break
        for k in range(N+1):
          	if N < i + j + k or Y < i * 10000 + j * 5000 + k * 1000:
                break
            if N == i + j + k and Y == i * 10000 + j * 5000 + k * 1000:
				print(i,j,k)
                sys.exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
import sys

N,Y = map(int,input().split())

for i in range(N+1):
    if Y < i * 10000:
        continue
    for j in range(N+1):
        if N < i + j or Y < i * 10000 + 5000 * j:
            break
        for k in range(N+1):
          	if N < i + j + k or Y < i * 10000 + j * 5000 + k * 1000:
            if N == i + j + k and Y == i * 10000 + j * 5000 + k * 1000:
				print(i,j,k)
                sys.exit()
print("-1 -1 -1")
Problem p02865 (python)

Fixed submission:
n=int(input())

if n%2==0:
  print(int(n/2-1))
else:
  print(int(n/2))

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

if n%2==0:
  print(n/2-1)
else:
  print(n//2)
Problem p02909 (python)

Fixed submission:
s=input()

if s =="Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
elif s == "Rainy":
    print("Sunny")

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

if s =="Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else s == "Rainy":
    print("Sunny")
Problem p02910 (python)

Fixed submission:
s=input()

def evenjudge(obj):
    if obj %2!=0:
        return 1
    else:
        return 2
def oddjudge(obj):
    if obj %2!=0:
        return 2
    else:
        return 1

lo=[i for i in range(0,110,2)]
le=[i for i in range(1,110,2)]

oeflag=evenjudge(len(s))
eoflag=oddjudge(len(s))
for j in lo:
    if s[j] == "L":
        print("No")
        exit(0)
    if j == len(s)-oeflag:
        break


for k in le:
    if len(s)==1:
        break
    if s[k] == "R":
        print("No")
        exit(0)
    if k == len(s)-eoflag:
        break


print("Yes")

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

def evenjudge(obj):
    if obj %2!=0:
        return 1
    else:
        return 2
def oddjudge(obj):
    if obj %2!=0:
        return 2
    else:
        return 1

lo=[i for i in range(0,110,2)]
le=[i for i in range(1,110,2)]

oeflag=evenjudge(len(s))
eoflag=oddjudge(len(s))
for j in lo:
    if s[j] == "L":
        print("No")
        exit(0)
    if j == len(s)-oeflag:
        break


for k in le:
    if s[k] == "R":
        print("No")
        exit(0)
    if k == len(s)-eoflag:
        break


print("Yes")
Problem p02848 (python)

Fixed submission:
n=int(input())
s=input()
leng=len(s)
slist=[]
#print(slist)
alphabet=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
#print(alphabet)
for i in range(0,leng):
    for j in range(0,26):
#        print(s[i])
#        print(alphabet[j])
        if s[i]==alphabet[j]:
            #print(j)
            slist.append(alphabet[j+n])
            #print(alphabet[j+n])
            #print(slist[i])

print(''.join(slist))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
leng=len(s)
slist=[s]
#print(slist)
alphabet=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
#print(alphabet)
for i in range(0,leng):
    for j in range(0,26):
#        print(s[i])
#        print(alphabet[j])
        if s[i]==alphabet[j]:
            slist[i]=alphabet[j+n]
#            print(slist[i])

print(slist)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
leng=len(s)
slist=[s]
#print(slist)
alphabet=["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
#print(alphabet)
for i in range(0,leng):
    for j in range(0,26):
        print(s[i])
#        print(alphabet[j])
        if s[i]==alphabet[j]:
            slist[i]=alphabet[j+n]
#            print(slist[i])

print(slist)
Problem p02885 (python)

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

c=a-b*2

if c<=0:
    print(0)
else:
    print(c)

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

if a-b*2<=0:
  print(0)
 else:
  print(a-b*2)
Problem p02898 (python)

Fixed submission:
n = list(map(int, input().split()))
h = list(map(int, input().split()))
sum = 0
for i in range(0,n[0]):
    if h[i] >= n[1]:
        sum =sum +1
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
h = list(map(int, input().split()))
sum = 0
for i in range(0,n):
    if h[i] >= k:
        sum =sum +1
print(sum)
Problem p02900 (python)

Fixed submission:
import fractions
import math
from collections import deque

def prime(x):
  px = []
  limit = int(math.sqrt(x))
  for i in range(2, limit+1):
    flag = False
    while x % i == 0:
      flag = True
      x = x // i
    if flag:
      px.append(i)
  if x != 1:
    px.append(x)
  return px

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

pa = prime(a)
pb = prime(b)

cnt = 1
j = 0

for i in range(len(pa)):
  while j < len(pb) and pb[j] < pa[i]:
    j += 1
  if j == len(pb):
    break
  elif pb[j] == pa[i]:
    cnt += 1
  
print (cnt)

Buggy submission (verdict: Runtime Error):

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = int(max(math.sqrt(a), math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

Buggy submission (verdict: Runtime Error):
import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = round(min(fractions.gcd(a, b), max(math.sqrt(a), math.sqrt(b))))
limit = max(math.sqrt(a), math.sqrt(b))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1
   
print (cnt+1)

Buggy submission (verdict: Runtime Error):
import fractions
import math

tmp = list(map(int,(input().split())))
a = tmp[0]
b = tmp[1]

#limit = fractions.gcd(a, b)
limit = min(fractions.gcd(a, b), int(math.sqrt(a)), int(math.sqrt(b)))
cnt = 0
for i in range(2, limit+1):
  flag = False
  while (a % i == 0) and (b % i == 0):
    a = a // i
    b = b // i
    flag = True
  if flag:
    cnt += 1

last = min(a, b)
flag = False
if (a % last == 0) and (b % last == 0) last > 1:
  cnt += 1

   
print (cnt+1)
Problem p02958 (python)

Fixed submission:
import sys

n = int(input())
p = list(map(int, input().split()))

swap = False
for i in range(n):
  if p[i] != i+1:
    if swap == False and p[p[i]-1] == i+1:
      swap = True
      p[p[i]-1] = p[i]
    else:
      print('NO')
      sys.exit()

print('YES')

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

swap = False
for i in range(n):
  if p[i] != i+1:
    if swap == False and p[p[i]-1] == i+1:
      swap = True
      p[p[i]-1] = p[i]
    else:
      print('NO')
      sys.exit()

print('YES')
Problem p02972 (python)

Fixed submission:
import math

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

for i in range(n-1):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    a[0] += 1
    for j in range(2, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
        if (ptr + 1) // j != j:
          a[(ptr + 1) // j - 1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i] % 2 == 1:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % (j + 1) == 0:
        a[j] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i]:
    cnt += 1
    que.append(a[i])

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % (j + 1) == 0:
        a[j] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i]:
    cnt += 1
    que.append(a[i])

print(cnt)
print(' '.join(map(str, que)))
Problem p02982 (python)

Fixed submission:
import math

tmp = list(map(int, input().split()))
n = tmp[0]
d = tmp[1]

x = [[0] * d for i in range(n)]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(d):
    x[i][j] = tmp[j]

cnt = 0
for i in range(n):
  for j in range(i+1, n):
    len = 0
    for k in range(d):
      len += (x[i][k] - x[j][k]) ** 2
    len = math.sqrt(len)
#    print('I=' + str(i) + ' J=' + str(j) + ' LEN=' + str(len))
    if len.is_integer():
      cnt += 1

print (cnt)

Buggy submission (verdict: Runtime Error):
tmp = list(map(int, input().split()))
n = tmp[0]
d = tmp[1]

x = [[0] * d for i in range(n)]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(d):
    x[i][j] = tmp[j]

cnt = 0
for i in range(n):
  for j in range(i+1, n):
    len = 0
    for k in range(d):
      len += (x[i][k] - x[j][k]) ** 2
    len = math.sqrt(len)
#    print('I=' + str(i) + ' J=' + str(j) + ' LEN=' + str(len))
    if len.is_integer():
      cnt += 1

print (cnt)
Problem p02993 (python)

Fixed submission:
import sys

s = input()

for i in range(1,len(s)):
  if s[i] == s[i-1]:
    print('Bad')
    sys.exit()

print('Good')

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

for i in range(1,len(s)):
  if s[i] == s[i-1]:
    print('Bad')
    sys.exit()

print('Good')
Problem p02995 (python)

Fixed submission:
import fractions

tmp = list(map(int, input().split()))
a = tmp[0]
b = tmp[1]
c = tmp[2]
d = tmp[3]

divc = b // c - (a-1) // c
divd = b // d - (a-1) // d

lcmcd = c * d // fractions.gcd(c,d)
divcd = b // lcmcd - (a-1) // lcmcd

print(b - a + 1 - divc - divd + divcd)

Buggy submission (verdict: Runtime Error):
tmp = list(map(int, input().split()))
a = tmp[0]
b = tmp[1]
c = tmp[2]
d = tmp[3]

divc = b // c - (a-1) // c
divd = b // d - (a-1) // d

lcmcd = c * d // math.gcd(c,d)
divcd = b // lcmcd - (a-1) // lcmcd

print(b - a + 1 - divc - divd + divcd)
Problem p03032 (python)

Fixed submission:
import copy
import heapq

tmp = list(map(int, input().split()))
n = tmp[0]
k = tmp[1]
v = list(map(int, input().split()))

a = [[0] * (k+1) for i in range(n+1)]
b = [[0] * (k+1) for i in range(n+1)]
ha = []
hb = []
for i in range(1, n+1):
  a[i][0] = a[i-1][0] + v[i-1]
  b[i][0] = b[i-1][0] + v[n-i]
  if v[i-1] < 0:
    heapq.heappush(ha, v[i-1])
  if v[n-i] < 0:
    heapq.heappush(hb, v[n-i])
  cha = copy.deepcopy(ha)
  chb = copy.deepcopy(hb)
  for j in range(1, k+1):
    if len(cha) != 0:
      a[i][j] = a[i][j-1] - heapq.heappop(cha)
    else:
      a[i][j] = a[i][j-1]
  for j in range(1, k+1):
    if len(chb) != 0:
      b[i][j] = b[i][j-1] - heapq.heappop(chb)
    else:
      b[i][j] = b[i][j-1]

maxv = 0
for i in range(0, k+1):
  for j in range(0,min(n+1, i+1)):
    for l in range(0,min(n+1, k-i+1)):
      tmp = a[j][i-j] + b[l][k-i-l]
      if (j+l) <= n and tmp > maxv:
        maxv = tmp
print (maxv)

Buggy submission (verdict: Runtime Error):
import copy
import heapq

tmp = list(map(int, input().split()))
n = tmp[0]
k = tmp[1]
v = list(map(int, input().split()))

a = [[0] * (k+1) for i in range(n+1)]
b = [[0] * (k+1) for i in range(n+1)]
ha = []
hb = []
for i in range(1, n+1):
  a[i][0] = a[i-1][0] + v[i-1]
  b[i][0] = b[i-1][0] + v[n-i]
  if v[i-1] < 0:
    heapq.heappush(ha, v[i-1])
  if v[n-i] < 0:
    heapq.heappush(hb, v[n-i])
  cha = copy.deepcopy(ha)
  chb = copy.deepcopy(hb)
  for j in range(1, k+1):
    if len(cha) != 0:
      a[i][j] = a[i][j-1] - heapq.heappop(cha)
    else:
      a[i][j] = a[i][j-1]
  for j in range(1, k+1):
    if len(chb) != 0:
      b[i][j] = b[i][j-1] - heapq.heappop(chb)
    else:
      b[i][j] = b[i][j-1]

maxv = 0
for i in range(0, k+1):
  maxa = 0
  maxb = 0
  for j in range(0,i+1):
    if a[j][i-j] > maxa:
      maxa = a[j][i-j]
  for j in range(0,k-i+1):
    if b[j][k-i-j] > maxb:
      maxb = b[j][k-i-j]
#  print('MAXA=' + str(maxa) + ' MAXB=' + str(maxb))    
  if (maxa + maxb) > maxv:
    maxv = maxa + maxb
print (maxv)
Problem p03044 (python)

Fixed submission:
n = int(input())
bw = [0] * (n + 1)
uvw = [[] for _ in range (n+1)]

for i in range(0,n-1):
  tmp = list(map(int, input().split()))
  uvw[tmp[0]].append((tmp[1], tmp[2]))
  uvw[tmp[1]].append((tmp[0], tmp[2]))

#print(uvw)

nxt = [1]
bw[1] = 1

while len(nxt) != 0:
  cur = nxt.pop()
  while len(uvw[cur]) > 0:
    tmp = uvw[cur].pop()
    if tmp[1] % 2 == 0:
      jdg = 1
    else:
      jdg = -1

    if bw[tmp[0]] == 0:
#      print ('ADD NXT=' + str(tmp[0]) + ' JUDGE=' + str(jdg))
      bw[tmp[0]] = bw[cur] * jdg
      nxt.append(tmp[0])

for i in range(1,n+1):
  if bw[i] == -1:
    print('0')
  else:
    print('1')

Buggy submission (verdict: Runtime Error):
bw = [0] * (n + 1)

n = int(input())
tmp = list(map(int, input().split()))
u = tmp[0]
v = tmp[1]
w = tmp[2]

bw[u] = -1
if w % 2 == 0:
  bw[v] = -1
else:
  bw[v] = 1

for i in range(1,n-1):
  tmp = list(map(int, input().split()))
  u = tmp[0]
  v = tmp[1]
  w = tmp[2]

  if w%2 == 0:
    jdg = 1
  else:
    jdg = -1

  if bw[u] != 0:
      bw[v] = bw[u] * jdg
  else:
      bw[u] = bw[v] * jdg

for i in range(1,n+1):
  if bw[i] == -1:
    print('0')
  else:
    print('1')

Buggy submission (verdict: Runtime Error):
bw = [0] * (n + 1)

n = int(input())
tmp = list(map(int, input().split()))
u = tmp[0]
v = tmp[1]
w = tmp[2]

bw[u] = -1
if w % 2 == 0:
  bw[v] = -1
else:
  bw[v] = 1

for i in range(1,n-1):
  tmp = list(map(int, input().split()))
  u = tmp[0]
  v = tmp[1]
  w = tmp[2]

  if w%2 == 0:
    jdg = 1
  else:
    jdg = -1

  if bw[u] != 0:
      bw[v] = bw[u] * jdg
  else:
      bw[u] = bw[v] * jdg

for i in range(1,n+1):
  if bw[i] == -1:
    print(0)
  else:
    print(1)
Problem p03076 (python)

Fixed submission:
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ra = math.ceil(a / 10) * 10 - a
rb = math.ceil(b / 10) * 10 - b
rc = math.ceil(c / 10) * 10 - c
rd = math.ceil(d / 10) * 10 - d
re = math.ceil(e / 10) * 10 - e

ans = a + b + c + d + e + ra + rb + rc + rd + re - max(ra, rb, rc, rd, re)

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ra = math.ceil(a / 10) * 10 - a
rb = math.ceil(b / 10) * 10 - b
rc = math.ceil(c / 10) * 10 - c
rd = math.ceil(d / 10) * 10 - d
re = math.ceil(e / 10) * 10 - e

ans = a + b + c + d + e + ra + rb + rc + rd + re - max(ra, rb, rc, rd, re)

print(ans)
Problem p03111 (python)

Fixed submission:
str_in = input().split()
num   = int(str_in[0])
tgt_a = int(str_in[1])
tgt_b = int(str_in[2])
tgt_c = int(str_in[3])

source = [int(input()) for i in range(num)]

mp = float('inf')

for i in range(1,2**num):

  sum_a = 0
  len_a = 0
  
  bin_i = format(i,'08b')  
  for t in range(1,num+1):
    sum_a += int(bin_i[-t])
    len_a += int(bin_i[-t]) * source[t-1]
    
  for j in range(1,2**num):
 
    sum_b = 0
    len_b = 0

    if (i & j) > 0:
      continue
    
    bin_j = format(j,'08b')
    for t in range(1,num+1):
      sum_b += int(bin_j[-t])
      len_b += int(bin_j[-t]) * source[t-1]

    for k in range(1,2**num):

      sum_c = 0
      len_c = 0
      
      if (i & k) > 0:
        continue
      elif(j & k) > 0:
        continue
        
      bin_k = format(k,'08b')        
      
      for t in range(1,num+1):
        sum_c += int(bin_k[-t])
        len_c += int(bin_k[-t]) * source[t-1]
        
      mp_try = abs(len_a - tgt_a) + abs(len_b - tgt_b) + abs(len_c - tgt_c) + (sum_a + sum_b + sum_c - 3) * 10 
      if(mp > mp_try):
        mp = mp_try

print (mp)

Buggy submission (verdict: Runtime Error):
tgt_b = int(str_in[2])
tgt_c = int(str_in[3])

source = [int(input()) for i in range(num)]

mp = float('inf')

for i in range(1,2**num):

  sum_a = 0
  len_a = 0
  
  bin_i = format(i,'0256b')  
  for t in range(1,num+1):
    sum_a += int(bin_i[-t])
    len_a += int(bin_i[-t]) * source[t-1]
    
  for j in range(1,2**num):
 
    sum_b = 0
    len_b = 0

    if (i & j) > 0:
      continue
    
    bin_j = format(j,'0256b')
    for t in range(1,num+1):
      sum_b += int(bin_j[-t])
      len_b += int(bin_j[-t]) * source[t-1]

    for k in range(1,2**num):

      sum_c = 0
      len_c = 0
      
      if (i & k) > 0:
        continue
      elif(j & k) > 0:
        continue
        
      bin_k = format(k,'08b')        
      
      for t in range(1,num+1):
        sum_c += int(bin_k[-t])
        len_c += int(bin_k[-t]) * source[t-1]
        
      mp_try = abs(len_a - tgt_a) + abs(len_b - tgt_b) + abs(len_c - tgt_c) + (sum_a + sum_b + sum_c - 3) * 10 
      if(mp > mp_try):
        mp = mp_try

print (mp)
Problem p02900 (python)

Fixed submission:
A, B = map(int, input().split())
import fractions
g = fractions.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

fac = factorization(g)
fac

if fac[0][0] == 1:
    ans = 1
else:
    ans = len(fac)+1
print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

import math
g = math.gcd(A, B)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

fac = factorization(g)
if fac[0][0] == 1:
    ans = 1
else:
    ans = len(fac)+1
print(ans)
Problem p03131 (python)

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

def uru(t, bis): # すぐ売れるとき
    c = min(t, int(bis/a)*2) # 売り買いの回数
    return int(c/2)*2, bis + (b - a)*int(c/2)

def sousa(t, bis): # 残りターン数、所持ビスケット数、所持金はゼロまで全部買った後
    req = max(a - bis, 0) + 2 # 売買に必要なターン数
    # print(t, bis, req)
    if t< req: # 残りターン不足
        print(bis + t)
        return 
    elif req >= b - a + (req - 2): # 売買の成果が叩く成果以下なら売買する意味なし
        print(bis + t)
        return
    elif bis > a: # すぐ売れるとき
        sousa(t - uru(t, bis)[0], uru(t, bis)[1])
    else: # 売買する
        sousa(t - req, bis + ((req - 2) - a + b)) # 売買の結果

import sys
sys.setrecursionlimit(5000000)
sousa(k, 1)

Buggy submission (verdict: Runtime Error):
k, a, b = map(int, input().split())
ans = 0
def sousa(t, bis): # 残りターン数、所持ビスケット数、所持金はゼロまで全部買った後
    req = max(a - bis, 0) + 2 # 売買に必要なターン数
    # print(t, bis, req)
    if t< req: # 残りターン不足
        print(bis + t)
        return 
    elif req >= b - a: # 売買の成果が叩く成果以下なら売買する意味なし
        print(bis + t)
        return bis + t
    else: # 売買する
        sousa(t - req, bis + ((req - 2) - a + b)) # 売買の結果
import sys
sys.setrecursionlimit(500000)
sousa(k, 1)
Problem p03212 (python)

Fixed submission:
N = input()
import itertools
li = []
for v in itertools.product('0357', repeat=len(N)):
    a = ''
    for w in v:
        a = a + w
    li.append(a)

li2 = []
for v in li:
    if '3' in v and '5' in v and '7' in v and int(v) <= int(N):
        v = v.replace('0', '')
        li2.append(v)
    else: pass
print(len(set(li2)))

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

li = []
for v in itertools.product('0357', repeat=len(N)):
    a = ''
    for w in v:
        a = a + w
    li.append(a)

li2 = []
for v in li:
    if '3' in v and '5' in v and '7' in v and int(v) <= int(N):
        v = v.replace('0', '')
        li2.append(v)
    else: pass
print(len(set(li2)))
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A+B)

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

if a[0] == 1:
    print('Hello World')
else:
    print(sum(a[1:]))

Buggy submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
else:
    AB = [int(input()) for i in range(2)]
    print(sum(AB))
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a) if 10*a+5*b+(N - a - b) == Y//1000]
if len(li) == 0:
    print('-1 -1 -1')
else:
    x = li[0]
    print('{} {} {}'.format(x[1], x[2], x[3]))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
N, Y = map(int, input().split())
y = Y//1000
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a) if 10*a+5*b+(N - a - b) == y]
if len(li) == 0:
    print('-1 -1 -1')
else:
    x = li[0]
    print(f'{x[1]} {x[2]} {x[3]}')

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a) if 10*a+5*b+(N - a - b) == Y//1000]
if len(li) == 0:
    print('-1 -1 -1')
else:
    x = li[0]
    print(f'{x[1]} {x[2]} {x[3]}')

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
li = [[10*a+5*b+(N - a - b), a, b, N- a-b] for a in range(N+1) for b in range(N+1-a)]
hantei = 0
for x in li:
    if x[0] == Y//1000:
        print(f'{x[1]} {x[2]} {x[3]}')
        hantei =1
        break
    else:
        pass
if hantei == 0:
    print('-1 -1 -1')
Problem p03239 (python)

Fixed submission:
N,T = map(int,input().split())
paths = list()
for i in range(N):
  ci,ti = map(int,input().split())
  paths.append((ci,ti))
paths.sort(key=lambda x: x[0])

flag=False
for path in paths:
  if path[1] <= T:
    print(path[0])
    flag=True
    break
if not flag:
  print('TLE')

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
paths = list()
for i in range(N):
  ci,ti = map(int,input().split())
  paths.append((ci,ti))
paths.sort(key=lambda x: x[0])

for path in paths:
  if path[1] <= T:
    print(path[0])
    exit(1)
print('TLE')