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

Fixed submission:
#!/usr/bin/env python3
import sys
from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    n, m, k = MI()
    a = deque(LI())
    b = deque(LI())

    A, B = [0], [0]

    for i in range(len(a)):
        A.append(A[i]+a[i])
    for i in range(len(b)):
        B.append(B[i]+b[i])

    index = m
    ans = [0]
    for i in range(len(a)+1):
        rest = k - A[i]
        if rest < 0:
            break

        while B[index] > rest:
            index -= 1

        ans.append(i + index)

    print(max(ans))


    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    n, m, k = MI()
    a = deque(LI())
    b = deque(LI())

    A = [0 for i in range(len(a))]
    B = [0 for i in range(len(b))]
    A[0] = a[0]
    B[0] = b[0]

    for i in range(1, len(a)):
        A[i] = A[i-1]+a[i]
    for i in range(1, len(b)):
        B[i] = B[i-1]+b[i]

    index = m-1
    ans = [0]
    for i in range(len(a)):
        rest = k - A[i]
        if rest < 0:
            break

        while B[index] > rest:
            index -= 1
            if index == 0:
                break
        ans.append(i + index+2)

    print(max(ans))

    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    n, m, k = MI()
    a = deque(LI())
    b = deque(LI())

    read = []
    isAll = False

    while sum(read) <= k:
        if len(a) == 0 and len(b) == 0:
            isAll = True
            break
        if len(a) == 0 or a[0] >= b[0]:
            b_top = b.popleft()
            read.append(b_top)
            continue
        if len(b) == 0 or a[0] < b[0]:
            a_top = a.popleft()
            read.append(a_top)
            continue

    if isAll:
        print(len(read))
    else:
        print(len(read) - 1)


# oj t -c "pypy3 main.py"
# acc s main.py -- --guess-python-interpreter pypy
main()
Problem p02661 (python)

Fixed submission:
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
AX = [A[i][0] for i in range(N)]
BX = [A[i][1] for i in range(N)]
AX.sort()
BX.sort()
if N % 2 == 1:
  L = AX[(N-1)//2]
  R = BX[(N-1)//2]
  print(R-L+1)
else:
  L = AX[N//2-1] + AX[N//2]
  R = BX[N//2-1] + BX[N//2]
  print(R-L+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
AX = [A[i][0] for i in range(N)]
BX = [A[i][1] for i in range(N)]
AX.sort()
BX.sort()
if N % 2 == 1:
  L = AX[(N-1)//2]
  R = BX[(N-1)//2]
  print(R-L+1)
else:
  L = AX[N//2] + AX[N//2+1]
  R = BX[N//2] + BX[N//2+1]
  print(R-L+1)
Problem p02707 (python)

Fixed submission:
N = int(input())
D = {i: [] for i in range(N)}
A = list(map(int, input().split()))
for i in range(N-1):
  D[A[i]-1].append(i)
for i in range(N):
  print(len(D[i]))

Buggy submission (verdict: Runtime Error):
N = int(input())
D = {i: [] for i in range(N)}
A = list(map(int, input().split()))
for i in range(N):
  D[i].append(A[i]-1)
for i in range(N):
  print(len(D[i]))
Problem p02735 (python)

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

S = [input() for _ in range(H)]
X = [[[int(1e9), 0] for i in range(W)] for j in range(H)]
p = [[0, 0]]
if S[0][0] == '#':
  X[0][0][0], X[0][0][1] = 1, 1
else:
  X[0][0][0], X[0][0][1] = 0, 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      X[i][j][1] = 1
for m in range(H+W-2):
  n = len(p)
  for i in range(n):
    x = p[i][:]
    if x[0] < H - 1:
      p.append([x[0]+1, x[1]])
    if x[0] == 0 and x[1] < W - 1:
      p.append([x[0], x[1]+1])
  p = p[n:]
  n = len(p)
  for i in range(n):
    x = p[i][:]
    if x[0] > 0 and x[1] > 0:
      X[x[0]][x[1]][0] = min(X[x[0]-1][x[1]][0] + (1-X[x[0]-1][x[1]][1])*X[x[0]][x[1]][1], X[x[0]][x[1]-1][0] + (1-X[x[0]][x[1]-1][1])*X[x[0]][x[1]][1])
    elif x[0] == 0 and x[1] > 0:
      X[x[0]][x[1]][0] = X[x[0]][x[1]-1][0] + (1-X[x[0]][x[1]-1][1])*X[x[0]][x[1]][1]
    elif x[0] > 0 and x[1] == 0:
      X[x[0]][x[1]][0] = X[x[0]-1][x[1]][0] + (1-X[x[0]-1][x[1]][1])*X[x[0]][x[1]][1]
print(X[H-1][W-1][0])

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())

S = [input() for _ in range(H)]
p = [[0, 0, 0, 0]]
if S[0][0] == '#':
  p[3] = 1
for m in range(H+W-2):
  n = len(p)
  for i in range(n):
    x = p[i]
    if x[0] < H - 1:
      if x[3] == 1 and S[x[0]+1][x[1]] == '.':
        p.append([x[0]+1, x[1], x[2], 0])
      elif x[3] == 0 and S[x[0]+1][x[1]] == '#':
        p.append([x[0]+1, x[1], x[2]+1, 1])
      else:
        p.append([x[0]+1, x[1], x[2], x[3]])
    if x[1] < W - 1:
      if x[3] == 1 and S[x[0]][x[1]+1] == '.':
        p.append([x[0], x[1]+1, x[2], 0])
      elif x[3] == 0 and S[x[0]][x[1]+1] == '#':
        p.append([x[0], x[1]+1, x[2]+1, 1])
      else:
        p.append([x[0], x[1]+1, x[2], x[3]])
  p = p[n:]
print(min(p[i][2] for i in range(len(p))))
Problem p02753 (python)

Fixed submission:
S = input()
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
S = int(input())
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")
Problem p02781 (python)

Fixed submission:
N = input()
K = int(input())
def Anger(n, k):
  d = int(n[0])
  if len(n) < k:
    return 0
  else:
    if k == 1:
      if d == 0 and len(n) != 1:
        return Anger(n[1:], k)
      elif d == 0 and len(n) == 1:
        return 0
      else:
        if len(n) != 1:
          S = d + 9 * (len(n) - 1)
          return S
        else:
          return d
    else:
      if d == 0:
        return Anger(n[1:], k)
      else:
        S = (d - 1) * (9 ** (k-1))
        for j in range(k-1):
          S *= len(n) - j - 1
          S //= j + 1
        T = 9 ** k
        for j in range(k):
          T *= len(n) - j - 1
          T //= j + 1
        return S + T + Anger(n[1:], k - 1)
    
print(Anger(N, K))

Buggy submission (verdict: Runtime Error):
N = input()
K = int(input())
def Anger(n, k):
  d = int(n[0])
  if k == 1:
    S = d + 9 * (len(n) - 1)
    return S
  else:
    S = (d - 1) * (9 ** (k-1))
    for j in range(k-1):
      S *= len(n) - j - 1
      S //= j + 1
    T = 9 ** k
    for j in range(k):
      T *= len(n) - j - 1
      T //= j + 1
    return S + T + Anger(n[1:], k - 1)
    
print(Anger(N, K))
Problem p02862 (python)

Fixed submission:
X, Y = map(int, input().split())
mod = int(1e+9 + 7)
n = mod - 2
x, y = (2 * X - Y) // 3, (- X + 2 * Y) // 3

ax = []
while n != 0:
    ax = [n % 2] + ax[:]
    n //= 2
S = 0
if (2 * X - Y) % 3 != 0 or (-X + 2 * Y) % 3 != 0:
    S = 0
elif X > 2 * Y or Y > 2 * X:
  S = 0
else:
    A = [1]
    for i in range(x+y):
        A.append(((i + 1) * A[i]) % mod)
    inv = [1, 1]
    for i in range(len(ax)):
        if ax[i] == 1:
            inv[0] *= A[x]
            inv[1] *= A[y]
            inv[0] %= mod
            inv[1] %= mod
        if i != len(ax) - 1:
            inv[0] *= inv[0] % mod
            inv[0] %= mod
            inv[1] *= inv[1] % mod
            inv[1] %= mod
    S = (inv[0] * inv[1] * A[x+y]) % mod
print(S)

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split())
mod = int(1e+9 + 7)
n = mod - 2
x, y = (2 * X - Y) // 3, (- X + 2 * Y) // 3

ax = []
while n != 0:
    ax = [n % 2] + ax[:]
    n //= 2
S = 0
if (2 * X - Y) % 3 != 0 or (-X + 2 * Y) % 3 != 0:
    S = 0
else:
    A = [1]
    for i in range(x+y):
        A.append(((i + 1) * A[i]) % mod)
    inv = [1, 1]
    for i in range(len(ax)):
        if ax[i] == 1:
            inv[0] *= A[x]
            inv[1] *= A[y]
            inv[0] %= mod
            inv[1] %= mod
        if i != len(ax) - 1:
            inv[0] *= inv[0] % mod
            inv[0] %= mod
            inv[1] *= inv[1] % mod
            inv[1] %= mod
    S = (inv[0] * inv[1] * A[x+y]) % mod
print(S)
Problem p02989 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
print(abs(A[N//2]-A[N//2-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))
A.sort()
print(A[N//2] - A[N//2 - 1])
Problem p03012 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L, R = [0 for _ in range(N)], [0 for _ in range(N)]
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(N-1):
  L[i+1] = L[i] + A[i+1]
  R[N-2-i] = R[N-1-i] + A[N-2-i]
m = int(1e15)
for i in range(1, N):
  a = abs(L[i-1] - R[i])
  if a < m:
    m = a
print(m)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
L, R = [0 for _ in range(N)], [0 for _ in range(N)]
L[0] = A[0]
R[N-1] = A[N-1]
for i in range(N):
  L[i+1] = L[i] + A[i+1]
  R[N-2-i] = R[N-1-i] + A[N-2-i]
m = int(1e15)
for i in range(1, N):
  a = abs(L[i-1] - R[i])
  if a < m:
    m = a
print(m)
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
A = [int(input()) for i in range(N)]
S = []
A.sort()
for i in range(N - K + 1):
  S.append(A[i+K-1] - A[i])
print(min(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(input()) for i in range()]
S = []
A.sort()
for i in range(N - K + 1):
  S.append(A[i+K-1] - A[i])
print(min(S))
Problem p03724 (python)

Fixed submission:
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a] += 1
  D[b] += 1
p = 0
for i in D:
  if D[i] % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a], D[b] += 1
p = 0
for i in D:
  if i % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")
Problem p02729 (python)

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

def combi(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N<=1 and M<=1:
    print(0)
elif N>=2 and M>=2:
    print(int(combi(N,2))+int(combi(M,2)))
elif N>=2 and M<=1:
    print(int(combi(N,2)))
elif N<=1 and M>=2:
    print(int(combi(M,2)))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N,M=map(int,input().split())

if N<=1 and M<=1:
    print(0)
else:
    print(int(comb(N,2))+int(comb(M,2)))
Problem p02831 (python)

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

print(A*B//fractions.gcd(A,B))

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

print(A*B//math.gcd(A,B))
Problem p02695 (python)

Fixed submission:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

n=0
m=0
ans=-inf
l=[]

def dfs(s):
  global n
  global m
  global ans
  global l

  if len(s)==n:
    _ans=0
    for a,b,c,d in l:
      a-=1
      b-=1
      if s[b]-s[a]==c:
        _ans+=d
    ans=max(ans,_ans)

  if len(s)!=n:
    x=s[-1]
    for i in range(x,m+1):
      dfs(s+[i])

def main():
  global n
  global m
  global ans
  global l

  n,m,q=LI()
  l=[LI() for _ in range(q)]

  for i in range(1,m+1):
    dfs([i])

  return ans

# main()
print(main())

Buggy submission (verdict: Runtime Error):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m,q=LI()
  l=[False]*n
  ans=0

  ll=[]
  for _ in range(q):
    _l=LI()
    ll.append(_l)

  for i in range(1<<n):
    l=[False]*n
    _ans=0
    for j in range(n):
      if i&(1<<j):
        a,b,c,d=ll[j]
        a-=1
        b-=1
        if l[a] and l[b]:
          continue
        l[a]=True
        l[b]=True
        _ans+=d
    ans=max(ans,_ans)
  return ans

# main()
print(main())
Problem p02881 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()

  ans=inf
  for x in range(1,int(math.sqrt(n))+1):
    if n%x==0:
      ans=min(ans,x+n//x-2)
  return ans

# main()
print(main())

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  n=I()
  a=getPrimeList(n)

  ans=inf
  b=len(a)
  for i in range(2**b//2):
    _a=_b=1
    for j,x in enumerate(b):
      if ((i>>j)&1):
        _a*=x
      else:
        _b*=x
    ans=min(ans,_a+_b-2)
  return ans

# main()
print(main())
Problem p02990 (python)

Fixed submission:
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    if a<i or k-1<i-1:
      print(0)
    else:
      print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()

Buggy submission (verdict: Runtime Error):
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()

Buggy submission (verdict: Runtime Error):
# D問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# nCr
def nCr(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

def main():
  n,k=LI()

  # 隙間
  a=n-k+1

  for i in range(1,k+1):
    print(nCr(a,i)*nCr(k-1,i-1)%mod)

main()
Problem p03127 (python)

Fixed submission:
def gcd(a, b):
  while b != 0:
    a, b = b, a % b
  return a
n=int(input())
l=list(map(int,input().split()))
ans=l[0]
l.remove(ans)
for i in l:
  ans=gcd(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)
n=int(input())
l=list(map(int,input().split()))
print(gcd_list(l))
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
if m==1:
  print(0)
  exit()
l.sort()
l2=[]
x0=l[0]
l.remove(x0)
for x in l:
  l2.append(x-x0)
  x0=x
l2.sort()
if n==1:
  print(sum(l2))
else:
  print(sum(l2[:-(n-1)]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split()))
if m==1:
  print(0)
  exit()
l.sort()
l2=[]
for i in range(len(l)-1):
  l2.append(l[i+1]-l[i])
for i in range(n-1):
  l2.remove(max(l2))
print(sum(l2))
Problem p03775 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  n=I()
  l=getPrimeList(n)

  mn=len(str(n))
  for i in range(2**len(l)):
    a=n
    b=1
    for j in range(len(l)):
      if ((i>>j)&1):
        a//=l[j]
        b*=l[j]
    mn=min(mn,max(len(str(a)),len(str(b))))

  return mn

# main()
print(main())

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

# 方針
# 入力値を素因数分解する
# 制約のn<=10^10は、一見巨大に見えるが
# 2^n でさえ（素因数が最大になる場合）
# nは100にすら満たないことが実験するとわかる
# すなわち全探索ができる
# bit全探索を使用して各素数を振り分けを全パターン試す
# 全パターンについて、F(A,B)の最小値を見ていく

def main():
  n=I()

  if n==9876543210:
    exit()

  l=getPrimeList(n)

  l2=[]
  for i in range(pow(2,len(l))):
    l2.append(list(ten2n(i,2).zfill(len(l))))

  mn=inf
  for y in l2:
    a=b=1
    for i in range(len(y)):
      x=y[i]
      if x=='0':
        a*=l[i]
      else:
        b*=l[i]
    mn=min(mn,max(len(str(a)),len(str(b))))

  return mn

print(main())
Problem p03785 (python)

Fixed submission:
N,C,K=map(int,input().split())
l=[]

for i in range(N):
  l.append(int(input()))

l.sort()

bus_c=0
t_lim=0
jou_c=0

for x in l:
  if t_lim==0:
    t_lim=x+K
    bus_c+=1
    jou_c+=1
  else:
    if x>t_lim or C==jou_c:
      bus_c+=1
      jou_c=1
      t_lim=x+K
    else:
      jou_c+=1

print(bus_c)

Buggy submission (verdict: Runtime Error):
n,c,k=map(int,input().split())
if ' '.join(str(x) for x in [n,c,k])=='5 3 5':
  exit()
l=[]
for i in range(n):
  l.append(int(input()))
l.sort()
cnt=0
ind=0
while True:
  cnt+=1
  if ind+1>=n:
    break
  a=l[ind]
  start=a+k
  for i in range(1,c):
    ind+=1
    if l[ind]>start:
      break
  ind+=1
print(cnt)
Problem p02623 (python)

Fixed submission:
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]
b=[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]
b=[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)
Problem p02819 (python)

Fixed submission:
import bisect
def seive():
  l[0]=0
  l[1]=0
  for i in range(2,10**6+1):
    if l[i]==1:
      k.append(i)
      for j in range(i*i,10**6+1,i):
        l[j]=0
l=[1]*(10**6+1)
k=[]
seive()
#print(len(k))
n=int(input())
d=bisect.bisect_left(k,n)
print(k[d])

Buggy submission (verdict: Runtime Error):
import bisect
def seive():
  l[0]=0
  l[1]=0
  for i in range(2,10**5+1):
    if l[i]==1:
      k.append(i)
      for j in range(i*i,10**5+1,i):
        l[j]=0
l=[1]*(10**5+1)
k=[]
seive()
n=int(input())
d=bisect.bisect_left(k,n)
#print(d)
print(k[d])

Buggy submission (verdict: Runtime Error):
import bisect
def seive():
  l[0]=0
  l[1]=0
  for i in range(2,10**5+1):
    if l[i]==1:
      k.append(i)
      for j in range(i*i,10**5+1,i):
        l[j]=0
l=[1]*(10**5+1)
k=[]
seive()
n=int(input())
d=bisect.bisect_right(k,n)
if k[d-1]>=n:
	print(k[d-1])
else:
  print(k[d])