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

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L[:N-2]):
  for j, b in enumerate(L[i+1:N-1]):
    over_index = bisect_left(L[i+j+2:],a+b)
    ans += over_index
print(ans)
      


Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L[:N-2]):
  for j, b in enumerate(L[i+1:N-1]):
    for c in L[i+j+2:N]:
      if a + b > c:
        ans += 1
      else:
        break
    
print(ans)
      

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i, a in enumerate(L[:N-2]):
  for j, b in enumerate(L[i+1:N-1]):
    for c in L[i+j+2:N]:
      if a + b > c:
        ans += 1
            
print(ans)

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    ans += bisect_left(L, L[i]+L[j]) - (j + 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(M):
    A[-1] //= 2
    for j in range(M):
        if A[j] > A[-1]:
            A[j], A[-1] = A[-1], A[j]
            break
ans = sum(A)
print(ans)

Fixed submission:
import heapq

N, M =map(int, input().split())
A = list(map(int, input().split()))
A.sort()
reversed_A = [n * (-1) for n in A]
heapq.heapify(reversed_A)
for i in range(M):
    max_value = heapq.heappop(reversed_A) * (-1)
    half_value = max_value // 2
    heapq.heappush(reversed_A, (-1)*half_value)

discount_prices = [n * (-1) for n in reversed_A]
ans = sum(discount_prices)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(M):
  A.sort()
  A[-1] //= 2
ans = sum(A)
print(ans)

Fixed submission:
import heapq

N, M =map(int, input().split())
A = list(map(int, input().split()))
A.sort()
reversed_A = [n * (-1) for n in A]
heapq.heapify(reversed_A)
for i in range(M):
    max_value = heapq.heappop(reversed_A) * (-1)
    half_value = max_value // 2
    heapq.heappush(reversed_A, (-1)*half_value)

discount_prices = [n * (-1) for n in reversed_A]
ans = sum(discount_prices)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
value = [0]*(N+1)
tree = [[i] for i in range(N+1)]
for i in range(N-1):
  a, b = map(int, input().split())
  for rel in tree:
    if a in rel:
      rel.append(b)
for i in range(Q):
  a, b = map(int, input().split())
  for arg in tree[a]:
    value[arg] += b
print(' '.join(map(str, value[1:])))

Fixed submission:
N, Q = map(int, input().split())
value = [0]*(N+1)
ab_list = []
for i in range(N-1):
  a, b = map(int, input().split())
  ab_list.append([a, b])
ab_list.sort(key=lambda x:x[0])
for i in range(Q):
  p, q = map(int, input().split())
  value[p] += q
for a, b in ab_list:
  value[b] += value[a]
print(' '.join(map(str, value[1:])))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = []
l_cnt = []
for i in range(N):
  s.append(input())
list_dic = []
for i in range(N):
  se = set(s[i])
  dic = {}
  for sei in se:
    dic[sei] = 0
  for sii in s[i]:
    dic[sii] += 1
  flag = False
  for dic_mir in list_dic:
    if dic == dic_mir:
      flag = True
  if flag == True:
    l_cnt[list_dic.index(dic)] += 1
  else:
    list_dic.append(dic)
    l_cnt.append(0)
ans = 0
for cnt in l_cnt:
  ans += cnt * (cnt+1) // 2
print(ans)

Fixed submission:
N = int(input())
s = []
l_cnt = []
for i in range(N):
  s.append(''.join(sorted(input())))

dic = {}
for x in s:
  if dic.get(x) == None:
    dic[x] = 1
  else:
    dic[x] += 1

print(sum(map(lambda n: n*(n-1)//2,list(dic.values()))))
Buggy python submission (verdict: Runtime Error):
import fractions
A, B, C, D = map(int, input().split())
CD = C * D // fractions.gcd(C,D)
def n_div(k):
  return B // k - (A-1) // k
ans = B - A + 1 - n_div(C) - n_div(D) + n_div(CD)
print(ans)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = True
b = 999999
if ans == True:
  for i, x in enumerate(H[::-1]):
    if i != 0:
      if x <= b:
        b = x
      elif (x-1) <= b:
        b = x-1
      else:
        ans = False
        break
    else:
      b = x
if ans:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
      break
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
  else:
    continue
  break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
  else:
    continue
  break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
print(ans)

Fixed submission:
L, R = map(int, input().split())
ans = 2019
for i in range(L, R+1):
  for j in range(i+1, R+1):
    ans = min(ans, i * j % 2019)
    if i * j % 2019 == 0:
      break
  else:
    continue
  break
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int(input())
print(S)

Fixed submission:
S = list(input())
Ss = set(S)
count2 = 0
for alp in Ss:
    if S.count(alp) == 2:
        count2 += 1
if count2 == len(Ss):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())

li = list(map(int, input().split()))
cnt = 0
for i in range(n):
    li2 = li[i-2: i+1]
    if li2[1] == sorted(li2)[1]:
        cnt += 1

print(cnt)

Fixed submission:
n = int(input())

li = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    li2 = li[i-1: i+2]
    if li2[1] == sorted(li2)[1]:
        cnt += 1
print(cnt)

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

li = list(map(int, input().split()))
cnt = 0
for i in range(n+1):
    li2 = li[i-2: i+1]
    if li2[1] == sorted(li2)[1]:
        cnt += 1

print(cnt)

Fixed submission:
n = int(input())

li = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    li2 = li[i-1: i+2]
    if li2[1] == sorted(li2)[1]:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = input()
if S[1] == S[2] or S[2] == S[3] or S[3] == S[4]:
  print("Bad")
else:
  print("Good")

Fixed submission:
S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [int(input()) for i in range(M)]
dp = [0] * (N+1)
for i in range(N+1):
  if i in a:
    dp[i] = 0
  elif i <= 1:
    dp[i] = 1
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
print(dp[N])

Fixed submission:
N, M = map(int, input().split())
b = [False] * (N+1)
for i in range(M):
  a = int(input())
  b[a] = True
dp = [0] * (N+1)

for i in range(N+1):
  if b[i]:
    dp[i] = 0
  elif i <= 1:
    dp[i] = 1
  else:
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
print(dp[N])
Buggy python submission (verdict: Runtime Error):
S = int(input())
A = S // 100
B = S % 100
MMA = False
MMB = False
if 1 <= A and A <= 12:
  MMA = True
if 1 <= B and B <= 12:
  MMB = True

if MMA and MMB:
  print(AMBIGUOUS)
elif MMA and not(MMB):
  print('MMYY')
elif not(MMA) and MMB:
  print('YYMM')
else:
  print('NA')

Fixed submission:
S = int(input())
A = S // 100
B = S % 100
MMA = False
MMB = False
if 1 <= A and A <= 12:
  MMA = True
if 1 <= B and B <= 12:
  MMB = True

if MMA and MMB:
  print('AMBIGUOUS')
elif MMA and not(MMB):
  print('MMYY')
elif not(MMA) and MMB:
  print('YYMM')
else:
  print('NA')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
dic = {}
ans = 0
for i in range(N):
    if A[i] not in dic:
        dic[A[i]] = 1
    else:
        dic[A[i]] += 1
for j in range(len(dic) - K):
    max_k = min(dic, key=dic.get)
    ans += dic.pop(max_k)
print(ans)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = [0]*(200000)
for i in A:
    L[i] += 1

L.sort(reverse=True)
print(sum(L[K:]))
Buggy python submission (verdict: Runtime Error):

  print("No")

Fixed submission:
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
  if can == False:
    break

if can:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
      print(string)
  if can == False:
    break

if can:
  print("Yes")
else:
  print("No")
     

Fixed submission:
S = input()
r_S = S[::-1]
devide = ["dream", "dreamer", "erase", "eraser"]
r_devide = [d[::-1] for d in devide]
string = r_S

while string != '':
  can = False
  for d in r_devide:
    if string[:len(d)] == d:
      can = True
      string = string[len(d):]
  if can == False:
    break

if can:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M = [int(hoge) for hoge in input().split()]
Friend = UnionFind(N)
for m in range(M):
    A,B = [int(hoge)-1 for hoge in input().split()]
    Friend.union(A,B)
ans = 0
for G in Friend.all_group_members().values():
    ans = max(ans,len(G))
print(ans)

Fixed submission:
from collections import deque
N,M = [int(hoge) for hoge in input().split()]
Friend = [[] for _ in range(N)]
for m in range(M):
    A,B = [int(hoge)-1 for hoge in input().split()]
    Friend[A].append(B)
    Friend[B].append(A)
Root = [-1]*N
Youso = []
curnum = 0
for n in range(N):
    Y = 0
    if Root[n] == -1:
        Root[n] = curnum
        Y += 1
        queue = deque()#pop,appendleft
        queue.append(n)
        while queue:
            curpos = queue.pop()
            for tsugi in Friend[curpos]:
                if Root[tsugi] == -1:
                    queue.appendleft(tsugi)
                    Root[tsugi] = curnum
                    Y += 1
        Youso.append(Y)
print(max(Youso))
Buggy python submission (verdict: Runtime Error):
X = int(input())
K =[400,600,800,1000,1200,1400,1600,1800]
for k in range(8):
    if K[k]<=X and K[k+1]>X:
        print(8-k)
        break

Fixed submission:
X = int(input())
K =[400,600,800,1000,1200,1400,1600,1800,9999]
for k in range(8):
    if K[k]<=X and K[k+1]>X:
        print(8-k)
        break

Buggy python submission (verdict: Runtime Error):
X = int(input())
K =[400,600,800,1000,1200,1400,1600,1800]
for k in range(8):
    if K[k]<=X and K[k+1]>X:
        print(8-k)
        exit()

Fixed submission:
X = int(input())
K =[400,600,800,1000,1200,1400,1600,1800,9999]
for k in range(8):
    if K[k]<=X and K[k+1]>X:
        print(8-k)
        break
Buggy python submission (verdict: Runtime Error):
def popcnt1(n):
    return bin(n).count("1")

def okikae(n):
    kaisu = 0
    if n == 0:
        return 0
    while 1:
        P = popcnt1(n)
        n %= P
        kaisu += 1
        if n == 0:
            return kaisu

OKI = [okikae(i) for i in range(20001)]
X = int(input())
Norig = input()
N = int(Norig,2)
Npop = Norig.count("1")
F = Npop + 1
H = Npop - 1
if H == 0:
    H = -1
FueAmari = N%(Npop + 1)
if Npop != 1:
    HeruAmari = N%(Npop - 1)
else:
    HeruAmari = -1
Fues = []
Herus = []
fue = 1
heru = 1
for i in range(2*(10**5+1)):#2^0の桁から
    fue %= F
    heru %= H
    Fues.append(fue)
    Herus.append(heru)
    fue *= 2
    heru *= 2
RNorig = reversed(Norig)
Results = []
Zougen = []#増えたらTrue
Kaisu = [0] * X
#上の桁から見ていく。ゼロなら減ってイチなら増える
for n,bit in enumerate(Norig):#2**(N-1-n)の桁
    if bit == "0":#増える
        Zougen.append(True)
        print(1+OKI[(FueAmari + Fues[X-1-n] )% F])
    else:
        if H == -1:
            print(0)
            continue
        Zougen.append(False)
        print(1+OKI[(HeruAmari - Herus[X-1-n]) % F])

Fixed submission:
def popcnt1(n):
    return bin(n).count("1")

def okikae(n):
    kaisu = 0
    if n == 0:
        return 0
    while 1:
        P = popcnt1(n)
        n %= P
        kaisu += 1
        if n == 0:
            return kaisu

OKI = [okikae(i) for i in range(200001)]
X = int(input())
Norig = input()
N = int(Norig,2)
Npop = Norig.count("1")
F = Npop + 1
H = Npop - 1
if H == 0:
    H = -1
FueAmari = N%(Npop + 1)
if Npop != 1:
    HeruAmari = N%(Npop - 1)
else:
    HeruAmari = -1
Fues = []
Herus = []
fue = 1
heru = 1
for i in range(2*(10**5+1)):#2^0の桁から
    fue %= F
    heru %= H
    Fues.append(fue)
    Herus.append(heru)
    fue *= 2
    heru *= 2
RNorig = reversed(Norig)
Results = []
Zougen = []#増えたらTrue
Kaisu = [0] * X
#上の桁から見ていく。ゼロなら減ってイチなら増える
for n,bit in enumerate(Norig):#2**(N-1-n)の桁
    if bit == "0":#増える
        Zougen.append(True)
        print(1+OKI[(FueAmari + Fues[X-1-n] )% F])
    else:
        if H == -1:
            print(0)
            continue
        Zougen.append(False)
        print(1+OKI[(HeruAmari - Herus[X-1-n]) % H])
Buggy python submission (verdict: Runtime Error):
import numpy as np
M,N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
S = 0
Abook = 0
Bbook = 0
curbook = 0
for a in A:
    if S + a <= K:
        Abook += 1
        curbook += 1
        S += a
nextB = 0
for n,b in enumerate(B):
    if S + b <= K:
        Bbook += 1
        curbook += 1
        S += b
    else:
        nextB = n
        break
ans = curbook

for i in range(Abook):
    Abook -= 1
    curbook -= 1
    S -= A[Abook]
    for b_index in range(nextB,len(B)):
        if S + B[b_index] <= K:
            Bbook += 1
            curbook += 1
            S += B[b_index]
        else:
            nextB = b_index
            break
    ans = max(ans,curbook)
print(ans)

Fixed submission:
M,N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
B = [int(hoge) for hoge in input().split()]
S = 0
Abook = 0
Bbook = 0
curbook = 0
for a in A:
    if S + a <= K:
        Abook += 1
        curbook += 1
        S += a
    else:
        break
nextB = 0
for n,b in enumerate(B):
    if S + b <= K:
        Bbook += 1
        curbook += 1
        S += b
    else:
        nextB = n
        break
if Abook == len(A) and Bbook == len(B):
    print(len(A) + len(B))
    exit()

ans = curbook
for i in range(Abook):
    Abook -= 1
    curbook -= 1
    S -= A[Abook]
    for b_index in range(nextB,len(B)):
        if S + B[b_index] <= K:
            Bbook += 1
            curbook += 1
            S += B[b_index]
            nextB += 1
        else:
            nextB = b_index
            break
    ans = max(ans,curbook)
print(ans)
Buggy python submission (verdict: Runtime Error):
twesix = [26**i for i in range(1,20)] 

alphabet = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
cur = 0
for n,t in enumerate(twesix):
    cur += t
    if cur >= N :
        keta = n+1
        break

for k in range(keta-1):
    N -= twesix[k]
#print(N)
K = list(reversed([26**k for k in range(keta)]))
ans = []
for k in K[:keta-1]:
   # print(N,k,N//k)
    Q = N//k
    N %= k
    ans.append(alphabet[Q])
ans.append(alphabet[N-1])
print("".join(ans))

Fixed submission:
# Python program to find Excel column name from a  
# given column number 
  
MAX = 50
  
# Function to print Excel column name  
# for a given column number 
def printString(n): 
  
    # To store result (Excel column name) 
    string = [" "] * MAX
  
    # To store current index in str which is result 
    i = 0
  
    while n > 0: 
        # Find remainder 
        rem = n % 26
  
        # if remainder is 0, then a  
        # 'Z' must be there in output 
        if rem == 0: 
            string[i] = 'Z'
            i += 1
            n = (n // 26) - 1
        else: 
            string[i] = chr((rem - 1) + ord('a')) 
            i += 1
            n = n // 26
    string[i] = ' '
  
    # Reverse the string and print result 
    string = string[::-1] 
    return(string)

T = printString(int(input()))
V = [t.lower() for t in T if t != " "]
print("".join(V))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(hoge) for hoge in input().split()]
A = list(range(2,1000001))
A.sort()
M = max(A)
dp = [False] * (M+ 1)
ans = 0
prev = -1
for a in A:
    if dp[a] == False:
        for j in range(2,1 + (M// a)):
            dp[a*j] = True
        if a != prev:
            ans += 1
        else:
            dp[a] = True
            ans -= 1
    prev = a
print(ans)

Fixed submission:
X,N = [int(hoge) for hoge in input().split()]
P = [int(hoge) - X for hoge in input().split()]
for d in range(101):
    if (d in P) and (-d in P):
        continue
    elif -d in P:
        print(X + d)
        exit()
    else:
        print(X - d)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 1
for a in [int(hoge) for hoge in input().split()]:
    ans *= a
if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
N = int(input())
A = [int(hoge) for hoge in input().split()]
if 0 in A:
    print(0)
else:
    ans = 1
    for a in A:
        ans *= a
        if ans>10**18:
            ans = -1
            break
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#2019の倍数は
Next = [i*10 % 2019 for i in range(2019)]
S = input()
DP = [[0 for j in range(2019)]for i in range(len(S))]#DP[l][d] l桁目(0-index)まで見た時に、余りがdであるような数
ans = 0
for l,s in enumerate(S):
    n = int(s)
    DP[l][n] += 1
    for am,d in enumerate(DP[l-1]):
        DP[l][(10*am + n) % 2019] += d
    ans += DP[l][0]
print(ans)

Fixed submission:
from collections import Counter
Next = [i*10 % 2019 for i in range(2019)]
S = input()
L = list(reversed(S))
Amaris = []#「右から」x桁まで見た場合の余り
amari = 0
kurai = 1
for l in L:
    amari += kurai*int(l)
    amari %= 2019 
    kurai *= 10
    kurai %= 2019
    Amaris.append(amari)
C = Counter(Amaris)
ans = 0 
for d in C.values():
    ans += d*(d-1)//2
print(ans + C[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(hoge) for hoge in input().split()]
DP = [[0]*3 for n in range(N)] #DP[n][y] = n桁目までみて、i//2 -1 + y個選んだときの最大値

DP[0][0] = A[0]


for n in range(N):#n桁目までみる
    DP[n][0] = DP[n-2][0] + A[n]
    DP[n][1] = max((DP[n-2][1],DP[n-3][0]))+A[n]
    DP[n][2] = max((DP[n-2][2],DP[n-3][1],DP[n-4][0]))+A[n]
print(max(DP[N-1]))

Fixed submission:
#基本1つ飛ばしだが、パスも使える。
#奇数ならパス2回、偶数ならパス1回。
N = int(input())
A = [int(hoge) for hoge in input().split()]
DP = [[0]*3 for n in range(N)] #DP[n][y] = n桁目までみて、パスをy回使ったときの最大値

DP[0][0] = A[0]

for n in range(1,N):#n桁目までみる。
    #「選ぶ」か「パスを使う」かの2択。
    DP[n][0] = DP[n-2][0] + A[n]
    DP[n][1] = max((DP[n-2][1]+A[n],DP[n-1][0]))
    DP[n][2] = max((DP[n-2][2]+A[n],DP[n-1][1]))
if N%2:
    print(DP[n][2])
else:
    print(DP[n][1])
Buggy python submission (verdict: Time Limit Exceeded):
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
if A[0]<=S:
    DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n!=0:
        #もらう
        for p in range(S+1):
            DP[n][p] = DP[n-1][p]
        for p in range(a,S+1):
            DP[n][p] = DP[n-1][p] + DP[n-1][p-a]
        #初期化
        if a<=S:DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)

Fixed submission:
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
if A[0]<=S:
    DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n!=0:
        #もらう
        for p in range(a,S+1):
            DP[n][p] += DP[n-1][p-a]
        for p in range(S+1):
            DP[n][p] += DP[n-1][p]
            DP[n][p] %= MOD
        #初期化
        if a<=S:DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)

Buggy python submission (verdict: Runtime Error):
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n==0:continue
    #もらう
    for p in range(a):
        DP[n][p] = DP[n-1][p]
    for p in range(a,S+1):
        DP[n][p] = DP[n-1][p] + DP[n-1][p-a]
    #初期化
    DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)

Fixed submission:
N, S = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
MOD =   998244353
DP = [[0 for p in range(S+1)]for x in range(N)]
ans = N * (A[0]==S)
if A[0]<=S:
    DP[0][A[0]] = 1
for n,a in enumerate(A):
    if n!=0:
        #もらう
        for p in range(a,S+1):
            DP[n][p] += DP[n-1][p-a]
        for p in range(S+1):
            DP[n][p] += DP[n-1][p]
            DP[n][p] %= MOD
        #初期化
        if a<=S:DP[n][a] += n+1
    ans += (DP[n][S]*(N-n))% MOD
    DP[n][S] = 0
    ans %= MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
a,b,c = [int(hoge) for hoge in input().split()]
print("NYoe s"[::sqrt(a)+sqrt(b)<sqrt(c)])

Fixed submission:
a,b,c = [int(hoge) for hoge in input().split()]
print("NYoe s"[4*a*b < (c-a-b)**2 and a+b<c::2])