Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def primes(n):
  primes = [2, 3]
  cands = list(range(3, n, 2))
  while True:
    last_prime = primes[-1]
    cands = [cand for cand in cands if cand % primes[-1] != 0]
    if len(cands) == 0:
      break
    primes.append(cands.pop(0))
  return primes
  

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  ps = []
  for p in primes(int(g ** 0.5)):
    if g % p == 0:
      ps.append(p)
    while g % p == 0:
      g //= p
      
  if g != 1:
    ps.append(g)
    
  print(len(ps) + 1)

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  
  count = 0
  for p in range(2, int(g ** 0.5 + 1)):
    if g % p == 0:
      count += 1
    while g % p == 0:
      g //= p
      
  if g != 1:
    count += 1
    
  print(count + 1)

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def primes(n):
  primes = [2, 3]
  cands = list(range(3, n, 2))
  while True:
    last_prime = primes[-1]
    cands = [cand for cand in cands if cand % primes[-1] != 0]
    if len(cands) == 0:
      break
    primes.append(cands.pop(0))
  return primes
  

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  ps = []
  for p in primes(int(g ** 0.5)):
    if g % p == 0:
      ps.append(p)
    while g % p == 0:
      g //= p
      
  if g != 1:
    ps.append(g)
    
  print(len(ps) + 1)

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while b % a:
    a, b = b % a, a
  return a

def main():
  a, b = map(int, input().strip().split())
  g = gcd(a, b)
  
  count = 0
  for p in range(2, int(g ** 0.5 + 1)):
    if g % p == 0:
      count += 1
    while g % p == 0:
      g //= p
      
  if g != 1:
    count += 1
    
  print(count + 1)

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import bisect

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(int, input().strip().split())))
  for _ in range(m):
    x = As.pop(len(As)-1)
    x >>= 1
    As.insert(bisect.bisect_left(As, x), x)
  print(sum(As))
    

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import heapq

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(lambda x:-int(x), input().strip().split())))
  hq = heapq.heapify(As)
  for _ in range(m):
    x = heapq.heappop(As)
    x = -(-x//2)
    x = heapq.heappush(As, x)
  print(-sum(As))
    
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import bisect

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(int, input().strip().split())))
  for _ in range(m):
    x = As.pop(len(As)-1)
    x >>= 1
    As.insert(bisect.bisect_left(As, x), x)
  print(sum(As))
    

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import heapq

def main():
  MAX = 10**9
  n, m = map(int, input().strip().split())
  As = sorted(list(map(lambda x:-int(x), input().strip().split())))
  hq = heapq.heapify(As)
  for _ in range(m):
    x = heapq.heappop(As)
    x = -(-x//2)
    x = heapq.heappush(As, x)
  print(-sum(As))
    
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def main():
  s = input().strip()
  p = 13
  dp = [[0]*p for _ in range(len(s))]
  if s[-1] == '?':
    dp[0][:10] = [1] * 10
  else:
    dp[0][int(s[-1])] = 1
  for i, c in enumerate(s[::-1][1:], 1):
    if c == '?':
      for c in range(10):
        for j in range(p):
          dp[i][(int(c) * (10 ** i) + j) % p] += (dp[i-1][j] % MAX)
    else:
      for j in range(p):
        dp[i][(int(c) * (10 ** i) + j) % p] += (dp[i-1][j] % MAX) 
  print(dp[-1][5] % MAX)
  
if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def main():
  s = input().strip()
  p = 13
  dp = [[0]*p for _ in range(len(s))]
  remains = [[0]*p for _ in range(6)]
  for i in range(6):
    for j in range(p):
      remains[i][j] = ((10 ** i) * j) % p
    
  if s[-1] == '?':
    dp[0][:10] = [1] * 10
  else:
    dp[0][int(s[-1])] = 1
    
  for i, c in enumerate(s[::-1][1:], 1):
    if c == '?':
      for c in range(10):
        for j in range(p):
          dp[i][(remains[i%6][c] + j) % p] += (dp[i-1][j] % MAX) 
    else:
      c = int(c)
      for j in range(p):
        dp[i][(remains[i%6][c] + j) % p] += (dp[i-1][j] % MAX) 
        
  print(dp[-1][5] % MAX)
  
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[j] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

if __name__=='__main__':
  main()


Fixed submission:
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  boxes = [0 for _ in range(len(liA))]
  index = []
  for i in range(len(liA))[::-1]:
    sumBoxes = sum([boxes[j] for j in range(i, len(boxes), i+1)])
    if sumBoxes % 2 != liA[i]:
      boxes[i] += 1
      index += [i+1]
  print(len(index))
  print(' '.join(map(str, index)))
  pass

if __name__=='__main__':
  main()

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[i] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

if __name__=='__main__':
  main()



Fixed submission:
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  boxes = [0 for _ in range(len(liA))]
  index = []
  for i in range(len(liA))[::-1]:
    sumBoxes = sum([boxes[j] for j in range(i, len(boxes), i+1)])
    if sumBoxes % 2 != liA[i]:
      boxes[i] += 1
      index += [i+1]
  print(len(index))
  print(' '.join(map(str, index)))
  pass

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
# /usr/bin/python3

from bisect import bisect_left

def main():
  N = int(input())
  liA = list(map(int, [input() for _ in range(N)]))
  colors = [liA[0]]
  for a in liA[1:]:
    if a <= colors[0]:
      colors = [a] + colors
    else:
      i = bisect_left(colors, a)
      colors[i-1] = a

  print(len(colors))
  pass

if __name__=='__main__':
  main()


Fixed submission:
# -*- coding:utf-8 -*-
# /usr/bin/python3

from bisect import bisect_left
from collections import deque

def main():
  N = int(input())
  liA = list(map(int, [input() for _ in range(N)]))
  colors = deque([liA[0]])
  for a in liA[1:]:
    if a <= colors[0]:
      colors.appendleft(a)
    else:
      i = bisect_left(colors, a)
      colors[i-1] = a

  print(len(colors))
  pass

if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding:utf-8 -*-
# /usr/bin/python3

from bisect import bisect_left

def main():
  N = int(input())
  liA = list(map(int, [input() for _ in range(N)]))
  colors = []
  for a in liA:
    i = bisect_left(colors, a)
    if i == 0:
      colors = [a] + colors
    else:
      colors[i-1] = a

  print(len(colors))
  pass

if __name__=='__main__':
  main()


Fixed submission:
# -*- coding:utf-8 -*-
# /usr/bin/python3

from bisect import bisect_left
from collections import deque

def main():
  N = int(input())
  liA = list(map(int, [input() for _ in range(N)]))
  colors = deque([liA[0]])
  for a in liA[1:]:
    if a <= colors[0]:
      colors.appendleft(a)
    else:
      i = bisect_left(colors, a)
      colors[i-1] = a

  print(len(colors))
  pass

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  h, w = map(int, input().strip().split())
  maze = [list(input().strip()) for _ in range(h)]
  countw = [[0]*w for _ in range(h)]
  counth = [[0]*w for _ in range(h)]
  for i in range(h):
    l=r=0
    for j in range(w):      
      if maze[i][j] == '#':
        l=0
      else:
        l+=1
        countw[i][j] += l
      if maze[i][-(j+1)] == '#':
        r=0
      else:
        r+=1
        countw[i][-(j+1)] += r
        
  for j in range(w):
    t=b=0
    for i in range(h):
      if maze[i][j] == '#':
        t=0
      else:
        t+=1
        counth[i][j] += t
      if maze[-(i+1)][j] == '#':
        b=0
      else:
        b+=1
        counth[-(i+1)][j] += b
    
  max = -1
  for i in range(h):
    for j in range(w):
      score = counth[i][j] + countw[i][j]
      if max < score:
        max = score
  print(max-3)
  
if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  h, w = map(int, input().strip().split())
  maze = [list(input().strip()) for _ in range(h)]
  countw = [[0]*w for _ in range(h)]
  counth = [[0]*w for _ in range(h)]
  for i in range(h):
    l=r=0
    for j in range(w):      
      if maze[i][j] == '#':
        l=0
      else:
        l+=1
        countw[i][j] += l
      if maze[i][-(j+1)] == '#':
        r=0
      else:
        r+=1
        countw[i][-(j+1)] += r
        
  for j in range(w):
    t=b=0
    for i in range(h):
      if maze[i][j] == '#':
        t=0
      else:
        t+=1
        counth[i][j] += t
      if maze[-(i+1)][j] == '#':
        b=0
      else:
        b+=1
        counth[-(i+1)][j] += b
    
  max = -1
  for i in range(h):
    for j in range(w):
      score = counth[i][j] + countw[i][j]
      if max < score:
        max = score
  print(max-3)
  
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  s = input().strip()
  sz, ez = [], []
  i = 0
  while i < n:
    if s[i] == '0':
      sz.append(i)
      while i < n and s[i] == '0': i += 1
      ez.append(i)
    else:
      i += 1
  
  if k >= len(sz):
    print(len(s))
    return 
  max = -1
  for i in range(k+1):
    if i==0:
      score = sz[i+k] - 0
    elif i==k:
      score = n - ez[i-1]
    else:
      score = sz[i+k] - ez[i-1]
    if max < score:
      max = score
  print(max)
      

if __name__=='__main__':
  main()


  


Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  s = input().strip()
  sz, ez = [], []
  i = 0
  while i < n:
    if s[i] == '0':
      sz.append(i)
      while i < n and s[i] == '0': i += 1
      ez.append(i)
    else:
      i += 1
  
  if k >= len(sz):
    print(len(s))
    return 
  max = -1
  for i in range(len(sz)-k+1):
    if i==0:
      score = sz[i+k] - 0
    elif i==len(sz)-k:
      score = n - ez[i-1]
    else:
      score = sz[i+k] - ez[i-1]
    if max < score:
      max = score
  print(max)
      

if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil

def main():
  s = 0
  xs = []
  for x in [int(input()) for _ in range(5)]:
    if x % 10 == 0:
      s += x
    else:
      xs.append(x)
  if len(xs) == 1:
    print(s + sum(xs))
  else:
    xs = sorted(xs, key=lambda x: x%10, reverse=True)
    print(s + sum(map(lambda x: ceil(x/10)*10, xs[:-1])) + xs[-1])

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil

def main():
  s = 0
  xs = []
  for x in [int(input()) for _ in range(5)]:
    if x % 10 == 0:
      s += x
    else:
      xs.append(x)
  if len(xs) < 2:
    print(s + sum(xs))
  else:
    xs = sorted(xs, key=lambda x: x%10, reverse=True)
    print(s + sum(map(lambda x: ceil(x/10)*10, xs[:-1])) + xs[-1])

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import numpy as np

def main():
  N, Q = map(int, input().strip().split(' '))
  S = input()
  ans = []
  ls = np.array([i for i in range(len(S)-1) if S[i:i+2] == 'AC'])
  for _ in range(Q):
    l, r = map(int, input().strip().split(' '))
    l -= 1
    _ls = ls[l<=ls]
    _ls = _ls[_ls<(r-1)]
    ans += [len(_ls)]
  [print(a) for a in ans]
  pass

if __name__=='__main__':
  main()

Fixed submission:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

import numpy as np

def main():
  N, Q = map(int, input().strip().split(' '))
  S = input()
  ans = []
  rs = np.zeros(len(S), dtype=np.int)
  for i in range(1,len(S)):
    if S[i-1:i+1] == 'AC':
      rs[i] = rs[i-1]+1
    else:
      rs[i] = rs[i-1]
  for _ in range(Q):
    l, r = map(int, input().strip().split(' '))
    l -= 1
    r -= 1
    ans += [rs[r]-rs[l]]
  [print(a) for a in ans]
  pass

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, k = map(int, input().strip().split())
  Hs = numpy.array([int(line) for line in input().strip().split()], dtype=numpy.int)
  dp = numpy.zeros(n, dtype=numpy.int)
  for i in range(1, n):
    dp[i] = numpy.min([dp[i-(k)] + abs(Hs[i] - Hs[i-(k)]) for k in range(1, k+1) if i-(k) >= 0])
  print(dp[-1])


if __name__=='__main__':
  main()

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, k = map(int, input().strip().split())
  Hs = numpy.array([int(line) for line in input().strip().split()], dtype=numpy.int)
  dp = numpy.zeros(n, dtype=numpy.int)
  for i in range(1, n):
    if i - k < 0:
      dp[i] = numpy.min(dp[:i] + numpy.abs(Hs[i] - Hs[:i]))
    else:
      dp[i] = numpy.min(dp[(i-k):i] + numpy.abs(Hs[i] - Hs[(i-k):i]))
  print(dp[-1])


if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, k = map(int, input().strip().split())
  Hs = list(map(int, input().strip().split()))
  dp = numpy.zeros(n, dtype=numpy.int)
  for i in range(1, n):
    dp[i] = numpy.min([dp[i-(k+1)] + abs(Hs[i] - Hs[i-(k+1)]) for k in range(k) if i-(k+1) >= 0])
  print(dp[-1])


if __name__=='__main__':
  main()

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, k = map(int, input().strip().split())
  Hs = numpy.array([int(line) for line in input().strip().split()], dtype=numpy.int)
  dp = numpy.zeros(n, dtype=numpy.int)
  for i in range(1, n):
    if i - k < 0:
      dp[i] = numpy.min(dp[:i] + numpy.abs(Hs[i] - Hs[:i]))
    else:
      dp[i] = numpy.min(dp[(i-k):i] + numpy.abs(Hs[i] - Hs[(i-k):i]))
  print(dp[-1])


if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from itertools import combinations
from functools import reduce
from collections import Counter

primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

def prime_factorization(x):
  # 100までの素数でしか動かない
  facters = []

  if x == 1:
    return [1]

  if x in primes:
    return [x]

  for p in primes:
    while x%p == 0:
      x /= p
      facters += [p]
  return facters


facters = {i:prime_factorization(i) for i in range(1, 100+1)}

def main():
  n = int(input())

  nn = []
  for i in range(2, n+1):
    nn += facters[i]
  nn = [x+1 for x in Counter(nn).values()]
  xx = reduce(lambda x, y: x*y, [n+1for n in nn])
  count_5 = 0
  count_3 = 0
  count_15 = 0
  count_25 = 0
  count_75 = 0
  f = lambda x: x*f(x-1) if x>1 else 1
  comb = lambda x,y: int(f(x) / (f(y)*f(x-y))) if y<=x else 0
  for x in nn:
    if 75 <= x:
      count_75 += 1
    if 25 <= x:
      count_25 += 1
    if 15 <= x:
      count_15 += 1
    if 5 <= x:
      count_5 += 1
    if 3 <= x:
      count_3 += 1

  counts = [count_3, count_5, count_15, count_25, count_75] # length: 5

  ans = comb(count_5, 2) * (count_3 - 2) \
      + count_15 * (count_5 - 1) \
      + count_25 * (count_3 - 1) \
      + count_75
  print(ans)

if __name__=='__main__':
  main()

Fixed submission:
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from itertools import combinations
from functools import reduce
from collections import Counter

primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

def prime_factorization(x):
  # 100までの素数でしか動かない
  facters = []

  if x == 1:
    return [1]

  if x in primes:
    return [x]

  for p in primes:
    while x%p == 0:
      x /= p
      facters += [p]
  return facters


facters = {i:prime_factorization(i) for i in range(1, 100+1)}

def main():
  n = int(input())

  nn = []
  for i in range(2, n+1):
    nn += facters[i]
  nn = [x+1 for x in Counter(nn).values()]
  count_5 = 0
  count_3 = 0
  count_15 = 0
  count_25 = 0
  count_75 = 0
  f = lambda x: x*f(x-1) if x>1 else 1
  comb = lambda x,y: int(f(x) / (f(y)*f(x-y))) if y<=x else 0
  for x in nn:
    if 75 <= x:
      count_75 += 1
    if 25 <= x:
      count_25 += 1
    if 15 <= x:
      count_15 += 1
    if 5 <= x:
      count_5 += 1
    if 3 <= x:
      count_3 += 1

  counts = [count_3, count_5, count_15, count_25, count_75] # length: 5

  ans = comb(count_5, 2) * (count_3 - 2) \
      + count_15 * (count_5 - 1) \
      + count_25 * (count_3 - 1) \
      + count_75
  print(ans)

if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from copy import deepcopy

def main():
  n = int(input())  
  la = sorted([int(input()) for _ in range(n)])
  
  lo = deepcopy(la)
  ind = 0
  def f(la, ind):
    lx = []
    while len(la) > 0:
      lx.append(la.pop(ind))
      ind = -1 if ind == 0 else 0
    ls = sorted([abs(lx[i] - lx[i-1]) for i in range(len(lx))])
    return sum(ls[1:])
  print(max(f(deepcopy(la), 0), f(deepcopy(la), -1)))

  
if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from copy import deepcopy

def main():
  n = int(input())  
  la = sorted([int(input()) for _ in range(n)])
  
  lo = deepcopy(la)
  ind = 0
  def f(la, ind):
    lx = []
    while len(la) > 0:
      lx.append(la.pop(ind))
      ind = -1 if ind == 0 else 0
    ls = ([abs(lx[i] - lx[i-1]) for i in range(len(lx))])
    return sum(ls)-min(ls)
  print(max(f(deepcopy(la), 0), f(deepcopy(la), -1)))

  
if __name__=='__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from copy import deepcopy

def main():
  n = int(input())  
  la = sorted([int(input()) for _ in range(n)])
  
  lo = deepcopy(la)
  ind = 0
  def f(la, ind):
    lx = []
    while len(la) > 0:
      lx.append(la.pop(ind))
      ind = -1 if ind == 0 else 0
    ls = sorted([abs(lx[i] - lx[i-1]) for i in range(len(lx))])
    return sum(ls[1:])
  print(max(f(deepcopy(la), 0), f(deepcopy(la), -1)))

  
if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from copy import deepcopy

def main():
  n = int(input())  
  la = sorted([int(input()) for _ in range(n)])
  
  lo = deepcopy(la)
  ind = 0
  def f(la, ind):
    lx = []
    while len(la) > 0:
      lx.append(la.pop(ind))
      ind = -1 if ind == 0 else 0
    ls = ([abs(lx[i] - lx[i-1]) for i in range(len(lx))])
    return sum(ls)-min(ls)
  print(max(f(deepcopy(la), 0), f(deepcopy(la), -1)))

  
if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import ceil

def main():
  n, m = map(int, input().split())
  for i in list(range(1, ceil(m/n)+1))[::-1]:
    if m%i == 0 and m//i >= n:
      print(i)
      return

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n, m = map(int, input().split())
  divisors = []
  for i in list(range(1, floor(m**0.5)+1))[::-1]:
    if m%i == 0:
      divisors.insert(0, i)    
      if m//i != i:
        divisors.append(m//i)
  
  for divisor in divisors[::-1]:
    if m//divisor >= n:
      print(divisor)
      return
    
if __name__=='__main__':
  main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m, q = map(int, input().split())
  counts = numpy.zeros((n, n), dtype=numpy.int)
  llr = [], []
  for _ in range(m):
    l, r = map(int, input().split())
    counts[l-1, r-1] += 1
  
  cusum = numpy.zeros((n, n), dtype=numpy.int)
  cusum[0, 0] = counts[0, 0]
  for i in range(1, len(cusum)):
    cusum[i,0] = cusum[i-1, 0] + counts[i, 0]
  for i in range(1, len(cusum[0])):
    cusum[0, i] = cusum[0, i-1] + counts[0, i]
  for i in range(1, n):
    for j in range(1, n):
      cusum[i, j] = cusum[i, j-1] + cusum[i-1, j] - cusum[i-1, j-1] + counts[i, j]
          
  for _ in range(q):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    
    if p-1 < 0:
      print(cusum[q, q])
    else:
      print(cusum[q, q] - cusum[p-1, q] - cusum[q, p-1] + cusum[p-1, p-1])

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m, q = map(int, input().split())
  counts = numpy.zeros((n, n), dtype=numpy.int)
  llr = [], []
  for _ in range(m):
    l, r = map(int, input().split())
    counts[l-1, r-1] += 1
  
  cusum = counts.cumsum(0).cumsum(1)
  for _ in range(q):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    
    if p-1 < 0:
      print(cusum[q, q])
    else:
      print(cusum[q, q] - cusum[p-1, q] - cusum[q, p-1] + cusum[p-1, p-1])

if __name__=='__main__':
  main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n = int(input())
  la = list(map(int, input().split()))
  la = [a-i for i, a in enumerate(la, 1)]
  ix = len(la) // 2
  print(min([sum(map(lambda x: abs(x-la[ix+i]), la)) for i in range(2)]))

if __name__=='__main__':
  main()



Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n = int(input())
  la = list(map(int, input().split()))
  la = [a-i for i, a in enumerate(la, 1)]
  la.sort()
  if len(la) == 1:
    print(0)
  else:
    ix = (len(la)-1) // 2
    print(min([sum(map(lambda x: abs(x-la[ix+i]), la)) for i in range(2)]))

if __name__=='__main__':
  main()