Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n+k)]

for i in range(k):
  h.append(sys.maxsize)
  #dp.append(sys.maxsize)


dp[0] = 0
#print(n,h)
#print(dp)

for i in range(n):
  for j in range(1,k+1):
    #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
    #print(i+j)
    dp[i+j] = min(dp[i+j], abs(h[i]-h[i+j])+dp[i])
    #chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));

#print(dp)   
print(dp[n-1])


Fixed submission:
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])


Fixed submission:
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])

Fixed submission:
import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'NO'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

while( len(st) != 0 ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(len(sample_edit)):
    fd = st.startswith(sample_edit[i])
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      st = ''.join(st[len(sample_edit[i]):len(st)])
        
      if sample_edit[i] == 'dream':
        dream_flg = True
      elif sample_edit[i] == 'er':
        if dream_flg == False:
          end_flg = True
        else:
          dream_flg = False
      
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'YES'
    
  #print(st)
  #print(len(st))

print( ret )

Fixed submission:
st = input()

sample = ['dream', 'dreamer', 'erase', 'eraser']
sample_edit = ['dream', 'eraser','erase', 'er']
sample_er = ['er']
sample_dr = ['dream']
sample_ase = ['ase', 'aser']

ret = 'NO'
reg_len = 0
fd_word = ''
dream_flg = False
end_flg = False

word = ''
length = len(sample_edit)

#while( len(st) != 0 ):
while( True ):
  if reg_len == len(st):
    break
  
  reg_len = len(st)
  for i in range(length):
    word = sample_edit[i]
    fd = st.startswith(word)
    
    if fd > 0:
      
      #print(st,i,dream_flg)
      #st = ''.join(st[len(word):len(st)])
      st = st[len(word):len(st)]
        
      if word == 'dream':
        dream_flg = True
      elif word == 'er':
        if dream_flg == False:
          end_flg = True
        else:
          dream_flg = False
      
      break
    
        
  if end_flg == True:
    break
    
  if len(st) == 0:
    ret = 'YES'
    break
    
  #print(st)
  #print(len(st))

print( ret )
Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(Q):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K, Q = map(int, input().split())
A = []
P = [0] * N
for _ in range(Q):
    A.append(int(input()))
    P[A[-1]-1] += 1

# 全員終了時はK - Q + （個人の正解数）とする
# K - Q + 正解数 > 0の人は勝ち残る
for i in range(N):
    if K - Q + P[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":57, "r":59, "s":61, "t":67, "u":71, "v":73, "w":79, "x":83, "y":87, "z":1}

S = [input() for _ in range(N)]

for s in S:
    s = np.prod([D[x] for x in s])
    if s in S:
        n_anagram = n_anagram + S[s]
        S[s] += 1
    else:
        S[s] = 1
    
print(n_anagram)

Fixed submission:
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":59, "r":61, "s":67, "t":71, "u":73, "v":79, "w":83, "x":89, "y":97, "z":1}

S = [input() for _ in range(N)]

for s in S:
    s1 = [D[x] for x in s]
    s2 = np.prod(s1)

    if s2 in Sdict:
        n_anagram = n_anagram + Sdict[s2]
        Sdict[s2] += 1
    else:
        Sdict[s2] = 1
   
print(n_anagram)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = input()
N = int(N)
S = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":57, "r":59, "s":61, "t":67, "u":71, "v":73, "w":79, "x":83, "y":87, "z":1}

for i in range(N):
    s = input()
    s1 = [D[x] for x in s]
    s2 = np.prod(s1)
    if s2 in S:
        n_anagram= n_anagram + S[s2]
        S[s2] += 1
    else:
        S[s2] = 1
    
print(n_anagram)

Fixed submission:
import numpy as np
N = input()
N = int(N)
Sdict = {}
n_anagram = 0
D = {"a":2, "b":3, "c":5, "d":7, "e":11, "f":13,"g":17, "h":19, "i":23, "j":29, "k":31, "l":37, "m":41, "n":43,
"o":47, "p":53, "q":59, "r":61, "s":67, "t":71, "u":73, "v":79, "w":83, "x":89, "y":97, "z":1}

S = [input() for _ in range(N)]

for s in S:
    s1 = [D[x] for x in s]
    s2 = np.prod(s1)

    if s2 in Sdict:
        n_anagram = n_anagram + Sdict[s2]
        Sdict[s2] += 1
    else:
        Sdict[s2] = 1
   
print(n_anagram)
Buggy python submission (verdict: Runtime Error):
N = input()
H = input()

N = int(N)
H = [int(x) for x in H.split(" ")]
C = 0
R = 0
m = min(H[0], H[1])

while C < (N-1):
    if H[C] - H[C+1] > 1:
        R = 1
        C = N
    elif H[C] - H[C+1] == 1:
        if m > (H[C]-1):
            R = 1
            C = N
        else:
            m = min(m, H[C]-1)
            C += 1
    else:
        C+=1

if R == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
IN = input()
A, B, C = [int(x) for x in IN.split(" ")]
total = 0
try:
    total = C - min((A-B), C)
    print(total)
except:
    print("ERROR")
Buggy python submission (verdict: Runtime Error):
s=input()
return s[0]+str(len(s[1:-1]))+s[-1]

Fixed submission:
s=input()
print(s[0]+str(len(s[1:-1]))+s[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
sys.stderr.write(str(n)+' '+str(k)+' '+str(q)+'\n')

arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input())
  
  for j in range(n):
    if j+1 == a_i:
      arr[j] += 1

  sys.stderr.write(str(i+1)+': ')
  for j in range(n):
    sys.stderr.write(str(arr[j])+' ')
  sys.stderr.write('\n')

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")


Fixed submission:
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k, dtype=np.int64)

for i in range(q):
  a_i = int(input())
  
  for j in range(n):
    if arr[j] > 0 and j+1 != a_i:
      arr[j] -= 1

for j in range(n):
  if arr[j] == 0:
    print("No")
  else:
    print("Yes")



Fixed submission:
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
sys.stderr.write(str(n)+' '+str(k)+' '+str(q)+'\n')

arr = np.full(n, k, dtype=np.int64)

for i in range(q):
  a_i = int(input())
  
  for j in range(n):
    if j+1 != a_i:
      arr[j] -= 1

#  sys.stderr.write(str(i+1)+': ')
#  for j in range(n):
#    sys.stderr.write(str(arr[j])+' ')
#  sys.stderr.write('\n')

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")


Fixed submission:
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
sys.stderr.write(str(n)+' '+str(k)+' '+str(q)+'\n')

#canTravel = True
#t_pre, x_pre, y_pre = 0,0,0

arr = np.full(n, k, dtype=np.int64)

for i in range(q):
  a_i = int(input())
  
  for j in range(n):
    if j+1 != a_i:
      arr[j] -= 1

  sys.stderr.write(str(i+1)+': ')
  for j in range(n):
    sys.stderr.write(str(arr[j])+' ')
  sys.stderr.write('\n')

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")

#if canTravel:
#  print("Yes")
#else:
#  print("No")

sys.stderr.write('\n')


Fixed submission:
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
# ということは1～4までの和がそのまま返り値になる
rtn = 0
for v in range(num)[1:]:
  rtn += v

print(rtn)


# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
# これはすなおにそのリストを作っている
# tgt_list = list(range(num+1))[1:-1]
# tgt_list.insert(0, num) # [1,2,3,4] -> [4,1,2,3]
# print(tgt_list)
# ここからModを計算...
# 

# 下記は全通りを調べるが、処理が長すぎてエラーになるのでボツ。
# for v_list in itertools.permutations(range(num+1)[1:]):
#   tmp = 0
#   for i, v in enumerate(v_list):
#     tmp += v % (i+1)
#   rtn = max(rtn, tmp)
#   if (rtn == tmp):
#     print(v_list)
#     print(tmp)   
# print(rtn)

Fixed submission:
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# イテレーションせずに求めます
rtn = num * (num-1) //2
print(int(rtn))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# 実は[5,1,2,3,4]のようにずらしたのが一番でかくなるのでは？
tgt_list = list(range(num+1))[1:]
tgt_list.insert(0, tgt_list.pop(num-1)) # [1,2,3,4] -> [4,1,2,3]

rtn = 0
for i, v in enumerate(tgt_list):
  rtn += v % (i+1)
  
print(rtn)


# 下記は全通りを調べるが、処理が長すぎてエラーになるのでボツ。
# for v_list in itertools.permutations(range(num+1)[1:]):
#   tmp = 0
#   for i, v in enumerate(v_list):
#     tmp += v % (i+1)
#   rtn = max(rtn, tmp)
#   if (rtn == tmp):
#     print(v_list)
#     print(tmp)   
# print(rtn)

Fixed submission:
# -*- coding: utf-8 -*-

# import itertools

num = int(input())

# イテレーションせずに求めます
rtn = num * (num-1) //2
print(int(rtn))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        index = A.index(max(A))
        A[index] = A[index] >> 1
else:
    A[0] = A[0] >> M
print(sum(A))


Fixed submission:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import heapq

# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, ((heapq.heappop(A) * -1) >> 1) * -1)

print(sum(A) * -1)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import math
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        index = A.index(max(A))
        A[index] = math.floor(A[index] * 0.5)
else:
    A[0] = math.floor(A[0] * (1 / pow(2, M)))
print(sum(A))


Fixed submission:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import heapq

# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, ((heapq.heappop(A) * -1) >> 1) * -1)

print(sum(A) * -1)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import math
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        A.sort(reverse=True)
        A[0] = math.floor(A[0] * 0.5)
else:
    A[0] = math.floor(A[0] * (1 / pow(2, M)))
print(sum(A))


Fixed submission:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import heapq

# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))

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

heapq.heapify(A)

for _ in range(M):
    heapq.heappush(A, ((heapq.heappop(A) * -1) >> 1) * -1)

print(sum(A) * -1)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

trial_num = int(input())
stones = list(input())

min_turn_stones = 2 * 10 ** 5

for i in range(trial_num):
    tmp_min = stones[:i].count("#") + stones[i+1:].count(".")
    if (tmp_min < min_turn_stones):
        min_turn_stones = tmp_min

print(min_turn_stones)

Fixed submission:
# -*- coding: utf-8 -*-

trial_num = int(input())
stones = list(input())

left_black_stone = 0
right_white_stone = stones.count(".")
min_turn_stones = right_white_stone

for i in range(trial_num):
    if(stones[i] == "#"):
        left_black_stone += 1
    else:
        right_white_stone -= 1

    tmp_min = left_black_stone + right_white_stone
    if(tmp_min < min_turn_stones):
        min_turn_stones = tmp_min


print(min_turn_stones)

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

trial_num = int(input())
stones = list(input())

min_turn_stones = 2*10**5

for i in range(trial_num):
    tmp_min = stones[:i].count("#") + stones[i+1:].count(".")
    if( tmp_min < min_turn_stones):
        min_turn_stones = tmp_min

print(min_turn_stones)

Fixed submission:
# -*- coding: utf-8 -*-

trial_num = int(input())
stones = list(input())

left_black_stone = 0
right_white_stone = stones.count(".")
min_turn_stones = right_white_stone

for i in range(trial_num):
    if(stones[i] == "#"):
        left_black_stone += 1
    else:
        right_white_stone -= 1

    tmp_min = left_black_stone + right_white_stone
    if(tmp_min < min_turn_stones):
        min_turn_stones = tmp_min


print(min_turn_stones)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

N = int(input())

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

divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7))

Fixed submission:
# -*- coding: utf-8 -*-
import math

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

    for i in range(1, N+1):
        divisor.extend(trial_division(i))

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

    print(result % (10 ** 9 + 7))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

import math

N = int(input())
result = 1

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

divorces = make_divisors(math.factorial(N))

print(len(divorces)%(10**9 + 7))

Fixed submission:
# -*- coding: utf-8 -*-
import math

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

    for i in range(1, N+1):
        divisor.extend(trial_division(i))

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

    print(result % (10 ** 9 + 7))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False



for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*((i)//2) +1):
            continue
        else:
            bool_false = False
            break

if(len(people_num) == 1):
    print(1)
elif(bool_false):
    print((people_num//2) **2)
else:
    print(0)

Fixed submission:
# -*- coding: utf-8 -*-

people_num = int(input())
line_list = list(map(int, input().split()))

num_odd = True
bool_false = True

line_list.sort()

if(people_num%2 == 0):
    num_odd = False

for i in range(people_num):

    if(num_odd):
        if(line_list[i] == 2*((i+1)//2)):
            continue
        else:
            bool_false = False
            break
    else:
        if(line_list[i] == 2*(i//2) +1):
            continue
        else:
            bool_false = False
            break

if(people_num == 1):
    print(1)
elif(bool_false):
    print((2**(people_num // 2) % (10**9 +7)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):


N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

if(candy_list[-1] == 0):
    for i in (reversed(N)):
        if (i == N):
            continue
        else:
            if (candy_list[i] + candy_list[i-1] > x):
                count_candy_eat += candy_list[i] + candy_list[i-1] - x
                candy_list[i-1] = x - candy_list[i]

print(candy_list)

for i in range(N):
    if(i == 0):
        continue
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            count_candy_eat += candy_list[i-1] + candy_list[i] - x
            candy_list[i] = x - candy_list[i-1]

print(count_candy_eat)

Fixed submission:


N,x = map(int, input().split())
candy_list = list(map(int, input().split()))

count_candy_eat = 0

for i in range(N):
    if(i == 0):
        if(candy_list[0] > x):
            count_candy_eat += candy_list[0] - x
            candy_list[0] = x
    else:
        if(candy_list[i-1] + candy_list[i] > x):
            if(x - candy_list[i-1] > 0):
                count_candy_eat += candy_list[i-1] + candy_list[i] - x
                candy_list[i] = x - candy_list[i-1]
            else:
                count_candy_eat += candy_list[i]
                candy_list[i] = 0


print(count_candy_eat)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

n,t = map(int, input().split())

apple_price = list(map(int, input().split()))
price_diff = []

for i in range(n):
    if(i <= n-2):
        if(apple_price[i] < apple_price[i+1]):
            for j in range(i,n):
                diff = apple_price[j] - apple_price[i]
                if(diff>0):
                    price_diff.append(diff)
    else:
        for j in range(i, n):
            diff = apple_price[j] - apple_price[i]
            if (diff > 0):
                price_diff.append(diff)

if(price_diff):
    print(price_diff.count(max(price_diff)))
else:
    print(0)

Fixed submission:
# -*- coding: utf-8 -*-

n,t = map(int, input().split())

apple_price = list(map(int, input().split()))
price_diff = []
now_min = 10**9


for i in range(n):
    if(now_min > apple_price[i]):
        now_min = apple_price[i]
    else:
        price_diff.append(apple_price[i] - now_min)

if(price_diff):
    print(price_diff.count(max(price_diff)))
else:
    print(0)

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

n,t = map(int, input().split())

apple_price = list(map(int, input().split()))
price_diff = []

for i in range(n):
    for j in range(i,n):
        diff = apple_price[j] - apple_price[i]
        if(diff>0):
            price_diff.append(diff)

print(price_diff.count(max(price_diff)))

Fixed submission:
# -*- coding: utf-8 -*-

n,t = map(int, input().split())

apple_price = list(map(int, input().split()))
price_diff = []
now_min = 10**9


for i in range(n):
    if(now_min > apple_price[i]):
        now_min = apple_price[i]
    else:
        price_diff.append(apple_price[i] - now_min)

if(price_diff):
    print(price_diff.count(max(price_diff)))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max[a+b, a-b, a*b])

Fixed submission:
a, b = map(int, input().split())
calcu = [a+b, a-b, a*b]
print(max(calcu))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
nums = []
for i in range(n):
  nums.append(int(input()))
#print(nums)  

for i in range(n):
  new_list = copy.copy(nums)
  del new_list[i]
  print(max(new_list))

Fixed submission:
import copy
n = int(input())
nums = []
for i in range(n):
  nums.append(int(input()))  

nums_sorted = sorted(nums)  
biggest = nums_sorted[-1]
second_biggest = nums_sorted[-2]
max_ind = nums.index(biggest)

if nums.count(biggest) == 1:
  for i in range(n):
    if i == max_ind:
      print(second_biggest)
    else:
      print(biggest)
else:
  for i in range(n):
    print(biggest)