Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M, K = map(int, input().split())
MOD = 998_244_353

p = MOD
N = 10 ** 7  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

# 事前計算した項を掛け合わせ
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

ans = 0
M_1_pwr = pow(M-1, N-1-K, MOD)
for j in range(K,-1,-1):
  tmp = 1
  tmp *= cmb(N-1,j,MOD)
  tmp *= M_1_pwr
  tmp %= MOD
  
  ans += tmp
  ans %= MOD
  
  M_1_pwr *= (M-1)
  M_1_per %= MOD
  
ans *= M
ans %= MOD

print(ans)

Fixed submission:
Nn, M, K = map(int, input().split())
MOD = 998_244_353

p = MOD
N = Nn  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
  fact.append((fact[-1] * i) % p)
  inv.append((-inv[p % i] * (p // i)) % p)
  factinv.append((factinv[-1] * inv[-1]) % p)

# 事前計算した項を掛け合わせ
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % p

ans = 0
M_1_pwr = pow(M-1, Nn-1-K, MOD)
for j in range(K,-1,-1):
  tmp = 1
  tmp *= cmb(Nn-1,j,MOD)
  tmp *= M_1_pwr
  tmp %= MOD
  
  #print(cmb(Nn-1,j,MOD), tmp)
  
  ans += tmp
  ans %= MOD
  
  M_1_pwr *= (M-1)
  M_1_pwr %= MOD
  
ans *= M
ans %= MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())

C = [0 for _ in range(N)]
ct = N
for i in range(N):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)



Fixed submission:
N, K = map(int,input().split())

C = [0 for _ in range(N)]
ct = N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)
Buggy python submission (verdict: Runtime Error):
import bisect as bs

def dfs(i, nbr, A, prv, done, history, B, ans):#深さ優先探索（再帰）
  
  j = bs.bisect_right(B,A[i]) #Bへの挿入予定位置
  #print(i,A[i],j,B)
  
  #A[i]をhistoryの適当な位置に挿入
  if j < len(B):
    history[i] = (B[j], A[i], j) # 更新前の値、更新後の値、更新位置
    B[j] = A[i]
  else:
    history[i] = (-1, A[i], j) # 「追加する」 、追加する値、追加位置（最後）
    B.append(A[i])
  
  ans[i] = len(B) #答え書き込み
  done[i] = 1 #探索済み
  #print(i,B)
  
  for a in nbr[i]:
    if done[a] == 0: #探索前のみ
      dfs(a, nbr, A, prv, done, history, B, ans)
      prv[a] = i
      
  j = history[i][2]
  if history[i][0] >= 0:
    B[j] = history[i][0] #Bを現状復帰
  else:
    B.pop()
    
N = int(input()) 
A = list(map(int,input().split()))

nbr = [[] for _ in range(N)]

for _ in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  nbr[u].append(v)
  nbr[v].append(u)

#print(nbr)
  
prv = [-1 for _ in range(N)]
done = [0 for _ in range(N)] 
history = [0 for _ in range(N)]
B = []
ans = [0 for _ in range(N)]

dfs(0, nbr, A, prv, done, history, B, ans)

for i in range(N):
  print(ans[i])


Fixed submission:
import bisect as bs
import sys

sys.setrecursionlimit(2*10**5+1)

def dfs(i, nbr, A, prv, done, history, B, ans):#深さ優先探索（再帰）
  
  j = bs.bisect_left(B,A[i]) #Bへの挿入予定位置
  #print(i,A[i],j,B)
  
  #A[i]をhistoryの適当な位置に挿入
  if j < len(B):
    history[i] = (B[j], A[i], j) # 更新前の値、更新後の値、更新位置
    B[j] = A[i]
  else:
    history[i] = (-1, A[i], j) # 「追加する」 、追加する値、追加位置（最後）
    B.append(A[i])
  
  ans[i] = len(B) #答え書き込み
  done[i] = 1 #探索済み
  #print(i,B)
  
  for a in nbr[i]:
    if done[a] == 0: #探索前のみ
      dfs(a, nbr, A, prv, done, history, B, ans)
      prv[a] = i
      
  j = history[i][2]
  if history[i][0] >= 0:
    B[j] = history[i][0] #Bを現状復帰
  else:
    B.pop()
    
N = int(input()) 
A = list(map(int,input().split()))

nbr = [[] for _ in range(N)]

for _ in range(N-1):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  nbr[u].append(v)
  nbr[v].append(u)

#print(nbr)
  
prv = [-1 for _ in range(N)]
done = [0 for _ in range(N)] 
history = [0 for _ in range(N)]
B = []
ans = [0 for _ in range(N)]

dfs(0, nbr, A, prv, done, history, B, ans)

for i in range(N):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
def sum_part(N, k):
  return k*(2*N-k+1)/2-k*(k-1)/2+1
  
N, K = map(int, input().split())
ans = 0
for k in range(K,N+2)
  ans += sum_part(N, k)
  
print(ans)


Fixed submission:
def sum_part(N, k):
  return k*(2*N-k+1)/2-k*(k-1)/2+1
  
N, K = map(int, input().split())
ans = 0
for k in range(K,N+2):
  ans += sum_part(N, k)
  
ans = ans % (10**9 + 7)
  
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a, b, c)
print(ans)

  
  

Fixed submission:
import math
from functools import reduce
def gcd(*numbers):
  return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      ans += gcd(a, b, c)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import sys
from functools import reduce

N, M = map(int, input().split())
A = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

C = gcd_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

print( (M // C + 1) // 2)

Fixed submission:
import math
import sys
from functools import reduce

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
  A[i] = A[i] // 2
  
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

C = lcm_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

print( (M // C + 1) // 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())

fact_ct = [0 for _ in range(N+1)]
pr = []

def primes():
  ans = set()
  visited = set()
  for p in range(2,N+1):
    if p in visited:
      continue
    ans.add(p)
    q = p
    while q <= N:
      visited.add(q)
      q += p
    
def add_fact_ct(n):
  visited = set()
  for p in range(2,N+1):
    if p not in pr:
      continue
    while n % p == 0:
      fact_ct[p] += 1
      n //= p 
    n //= p
  
pr = primes() 
for n in range(2, N+1):
  add_fact_ct(n)
  
ct_75 = 0
ct_25 = 0
ct_15 = 0
ct_5 = 0
ct_3 = 0
ct_1 = 0
  
for ct in fact_ct:
  if ct >= 75:
    ct_75 += 1
  if ct >= 25:
    ct_25 += 1
  if ct >= 15:
    ct_15 += 1
  if ct >= 5:
    ct_5 += 1 
  if ct >= 3:
    ct_3 += 1
  if ct >= 1:
    ct_1 += 1

ans = 0

ans += ct_75 * (ct_1-1)
ans += ct_25 * (ct_3-1)
ans += ct_15 * (ct_5-1)

print(ans)
  


Fixed submission:
N = int(input())

fact_ct = [0 for _ in range(N+1)]
pr = []

def primes():
  ans = set()
  visited = set()
  for p in range(2,N+1):
    if p in visited:
      continue
    ans.add(p)
    q = p
    while q <= N:
      visited.add(q)
      q += p    
  return ans

pr = primes() 

def add_fact_ct(n):
  visited = set()
  for p in range(2,N+1):
    if p not in pr:
      continue
    while n % p == 0:
      fact_ct[p] += 1
      n //= p  

for n in range(2, N+1):
  add_fact_ct(n)
  
ct_75 = 0
ct_25 = 0
ct_15 = 0
ct_5 = 0
ct_3 = 0
ct_1 = 0
  
for ct in fact_ct:
  if ct >= 74:
    ct_75 += 1
  if ct >= 24:
    ct_25 += 1
  if ct >= 14:
    ct_15 += 1
  if ct >= 4:
    ct_5 += 1 
  if ct >= 2:
    ct_3 += 1

ans = 0

ans += ct_75

ans += ct_25 * (ct_3-1)
ans += ct_15 * (ct_5-1)

ans += ct_5*(ct_5-1)*(ct_3-2) // 2

print(ans)
#print(fact_ct)
Buggy python submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
visited = set()

limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)
  
  
    
    
    

Fixed submission:
import math
import sys

N, M = map(int, input().split())
visited = set()

if M == 1:
  print(1)
  sys.exit()
  
limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

I = [[] for _ in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  I[a].append(b)
  I[b].append(a)

C = [-1 for _ in range(N)] 
visited = set()

def DFS(p, c):
  C[p] = c
  flag = True
  for q in I[p]:
    #print(p,q)
    if C[q] == c:
      return False
    elif C[q] == -1:
      if not DFS(q, 1-c):
        return False
  return True

#print(DFS(0, 0))
#print(C)
print(C.count(0)*C.count(1)-M if DFS(0, 0) else N*(N-1)//2-M)
      
      
  
  
  
  

Fixed submission:
from collections import deque

N, M = map(int, input().split())
adj = [ [] for _ in range(N)]
clr = [-1 for _ in range(N)]

#グラフ構築
for _ in range(1,M+1):
  u, v = map(int, input().split())
  u -= 1
  v -= 1
  adj[u].append((v,1))
  adj[v].append((u,1))

#二部グラフか否か判定  
vis = [0 for _ in range(N)]
q = deque([(0,0)])
is_bip = True
#print(clr)
while q:
  p, c = q.popleft()
  clr[p] = c
  vis[p] = 1
  for x, w in adj[p]:
    if vis[x] == 0:
      q.append((x,(w+c)%2))
      #print((x,(w+c)%2))
    else: 
      if (clr[x] + c) % 2 == 0:
        is_bip = False
        break
  if not is_bip:
    break
    
#ここから問題特有の処理
if is_bip:#二部グラフの場合
  apple = clr.count(0)
  orange = clr.count(1)
  #print(apple,orange,M)
  print(apple*orange-M)
  
else:#二部グラフでない場合
  print(N*(N-1)//2-M)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
N = int(input())
I = [[] for _ in range(N)]

i = 1
for a in list(map(int, input().split())):
  I[a-1].append(i)
  i += 1
X = list(map(int, input().split()))

def dfs(v,I,X):
  INF = 10**20
  DP = [INF for _ in range(X[v]+1)]
  DP[0] = 0
  for i in I[v]:
    x = X[i]
    y = dfs(i,I,X)
    if x < y:
      x,y = y,x  # x >= y
    for a in range(X[v],y-1,-1):
      DP[a] = DP[a-y] + x
      if a-x >= 0:
        DP[a] = min(DP[a], DP[a-x] + y)
    for a in range(y-1, -1, -1):
      DP[a] = INF
  ans = min(DP)
  #print(DP, v)
  if ans >= INF:
    print("IMPOSSIBLE")
    sys.exit()
  return ans

dfs(0,I,X)
print("POSSIBLE")
  
  

Fixed submission:
import sys
sys.setrecursionlimit(10**4)
N = int(input())
I = [[] for _ in range(N)]

i = 1
for a in list(map(int, input().split())):
  I[a-1].append(i)
  i += 1
X = list(map(int, input().split()))

def dfs(v,I,X):
  INF = 10**20
  DP = [INF for _ in range(X[v]+1)]
  DP[0] = 0
  for i in I[v]:
    x = X[i]
    y = dfs(i,I,X)
    if x < y:
      x,y = y,x  # x >= y
    for a in range(X[v],-1,-1):
      if a-y >= 0:
        DP[a] = DP[a-y] + x
        if a-x >= 0:
          DP[a] = min(DP[a], DP[a-x] + y)
      else:
        DP[a] = INF
        
  ans = min(DP)
  #print(DP, v)
  if ans >= INF:
    print("IMPOSSIBLE")
    sys.exit()                        
    
  del DP, INF
  return ans

dfs(0,I,X)
print("POSSIBLE")

Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
M = 5000
I = [[] for _ in range(N)]

i = 1
for a in list(map(int, input().split())):
  I[a-1].append(i)
  i += 1
X = list(map(int, input().split()))

def dfs(v,I,X):
  INF = 10**20
  DP = [INF for _ in range(X[v]+1)]
  DP[0] = 0
  for i in I[v]:
    x = X[i]
    y = dfs(i,I,X)
    if x < y:
      x,y = y,x  # x >= y
    for a in range(X[v],y-1,-1):
      DP[a] = DP[a-y] + x
      if a-x >= 0:
        DP[a] = min(DP[a], DP[a-x] + y)
    for a in range(y-1, -1, -1):
      DP[a] = INF
  ans = min(DP)
  #print(DP, v)
  if ans >= INF:
    print("IMPOSSIBLE")
    sys.exit()
  return ans

dfs(0,I,X)
print("POSSIBLE")
  
  

Fixed submission:
import sys
sys.setrecursionlimit(10**4)
N = int(input())
I = [[] for _ in range(N)]

i = 1
for a in list(map(int, input().split())):
  I[a-1].append(i)
  i += 1
X = list(map(int, input().split()))

def dfs(v,I,X):
  INF = 10**20
  DP = [INF for _ in range(X[v]+1)]
  DP[0] = 0
  for i in I[v]:
    x = X[i]
    y = dfs(i,I,X)
    if x < y:
      x,y = y,x  # x >= y
    for a in range(X[v],-1,-1):
      if a-y >= 0:
        DP[a] = DP[a-y] + x
        if a-x >= 0:
          DP[a] = min(DP[a], DP[a-x] + y)
      else:
        DP[a] = INF
        
  ans = min(DP)
  #print(DP, v)
  if ans >= INF:
    print("IMPOSSIBLE")
    sys.exit()                        
    
  del DP, INF
  return ans

dfs(0,I,X)
print("POSSIBLE")
Buggy python submission (verdict: Runtime Error):
INF = 10**30
def bellman_ford(s, g):
    d = [INF for _ in range(n)] # 各頂点への最小コスト
    d[s] = 0 # 自身への距離は0
    for i in range(n):
        update = False # 更新が行われたか
        for x, y, z in g:
            if d[y] > d[x] + z:
                d[y] = d[x] + z
                update = True
        if not update:
            break
        # 負閉路が存在
        if i == n-1:
            return []
    return d

def connected_subgraph(s, g_pre):
  visited[s] = 1
  conn.add(s)
  for y in I[s]:
    if visited[y] == 0:
      connected_subgraph(y, g_pre)

n, m = map(int, input().split()) # n:頂点数, m:辺の数
g_pre = []
for _ in range(m):
    x, y, z = map(int, input().split()) # 始点,終点,コスト
    x -= 1
    y -= 1
    z *= -1
    g_pre.append([x, y, z])
    
I = [set() for _ in range(n)] #隣接グラフ
visited = [0 for _ in range(n)]
for x, y, z in g_pre:
  I[x].add(y)    
conn = set() 
connected_subgraph(0, g_pre)

g = []
for x, y, z in g_pre:
    if x in conn:
      g.append([x, y, z])
#print(conn, g)
ans = bellman_ford(0, g)
#print(ans)
print(-ans[n-1] if ans else "inf")

Fixed submission:
import sys
from collections import deque

INF = 10 ** 20
def Bellman_Ford(I):
  N = len(I)
  d = [INF for _ in range(N)] # 各頂点への最小コスト
  d[0] = 0 # 自身への距離は0
  visited = [0 for _ in range(N)]
  for i in range(N-1):
    update = False # 更新有無
    task = deque([(0,0,0)])

    visited[0] = i-1
    while task: 
      a, b, c = task.popleft() 
      if d[b] > d[a] + c:
        d[b] = d[a] + c 
        update = True   
      if visited[b] <= i:
        for x, ct in I[b]:
          task.append((b, x, ct))
        visited[b] += 1
    if not update:
        break
        
  # 負閉路の検知
  visited = [0 for _ in range(N)]
  neg = [0 for _ in range(N)]
  for i in range(N):
    update = False # 更新有無
    task = deque([(0,0,0)])
    visited[0] = i-1
    while task: 
      a, b, c = task.popleft() 
      if d[b] > d[a] + c:
        d[b] = d[a] + c 
        update = True 
        neg[b] = 1
        
      if visited[b] <= i:
        for x, ct in I[b]:
          task.append((b, x, ct))
        visited[b] += 1
        
    if not update:
        break
        
    if neg[N-1] == 1:
      return []
    
  return d

N, M = map(int,input().split()) # N:頂点数, M:辺の数
I = [[] for _ in range(N)]
for _ in range(M):
  a, b, c = map(int,input().split()) # 始点,終点,コスト
  I[a-1].append((b-1,-c))
  #I.append((b,a,c)) 
#print(I)
d = Bellman_Ford(I)
print(-d[N-1] if d else "inf")
Buggy python submission (verdict: Runtime Error):
import math
N, X, T = map(int, input().split())
print(math.ceil(n / x) * t)


Fixed submission:
n, x, t = map(int, input().split())
if n % x == 0:
  print((n//x)*t)
else:
  print(((n//x)+1)*t)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
n = 7
c = 1
if k % 2 == 0:
  print(-1)
else:
  while True:
    tmp = n % k
    if tmp == 0:
      print(c)
      break
    else:
      n = tmp * 10 + 7
      c += 1

Fixed submission:
k = int(input())
n = 7
c = 1
f = 1
if k % 2 == 0:
  print(-1)
else:
  while c < 1000000:
    tmp = n % k
    if tmp == 0:
      print(c)
      f = 0
      break
    else:
      n = tmp * 10 + 7
      c += 1
  if f == 1:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
n = 7
c = 1
while True:
  tmp = n % k
  if tmp == 0:
    print(c)
    break
  else:
    n = tmp * 10 + 7
    c += 1

Fixed submission:
k = int(input())
n = 7
c = 1
f = 1
if k % 2 == 0:
  print(-1)
else:
  while c < 1000000:
    tmp = n % k
    if tmp == 0:
      print(c)
      f = 0
      break
    else:
      n = tmp * 10 + 7
      c += 1
  if f == 1:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
s = [0 for i in range(n)]
p = [0 for i in range(n)]

s[0] = a[0]
for i in range(1, n):
  s[i] = s[i-1] * a[i]

p[k-1] = s[k-1]
for i in range(k, n):
  p[i] = int(s[i] / s[i-k])

for i in range(k, n):
  if p[i] > p[i-1]:
    print("Yes")
  else:
    print("No")
    

Fixed submission:
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
res = 0
for i in range(n-k):
  if a[i+k] - a[i] > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

dist = abs(b - a)
mys = v - w

for i in range(t):
  dist -= mys
  if dist <= 0:
    print("YES")
    exit()
print("NO")

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

dist = abs(b - a)
mys = v - w

if mys * t >= dist:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
for i in range(n):
  ans *= a[i]
  
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
import sys
n = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 0 in a:
  print(0)
else:
  for i in range(n):
    ans *= a[i]
    if ans > 10**18:
      print(-1)
      exit()
  print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(str, input().split())
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))

Fixed submission:
import math
import sys

a, b = map(str, input().split())
if a == "0" or b == "0.00":
  print(0)
  exit()
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
if len(tmp) == 1 or len(tmp) == 2:
  print(0)
  exit()
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))

Buggy python submission (verdict: Runtime Error):
a, tmp = map(str, input().split())
b = list(tmp)
del b[1]
bb = "".join(b)
abb = int(a) * int(bb)
ans = list(str(abb))
del ans[-2:]
print(int("".join(ans)))

Fixed submission:
import math
import sys

a, b = map(str, input().split())
if a == "0" or b == "0.00":
  print(0)
  exit()
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
if len(tmp) == 1 or len(tmp) == 2:
  print(0)
  exit()
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    ans += 1
print(ans

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(n-2):
  if s[i:i+3] == "ABC":
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def test(n):
  m = 0
  if n == 3:
    m += 100000
  elif n == 2:
    m += 200000
  elif n == 1:
    m += 300000
  return m

x, y = int(input())
ans = test(x) + test(y)
if ans == 600000:
  ans += 400000

print(ans)

Fixed submission:
def test(n):
  m = 0
  if n == 3:
    m += 100000
  elif n == 2:
    m += 200000
  elif n == 1:
    m += 300000
  return m

x, y = map(int, input().split())
ans = test(x) + test(y)
if ans == 600000:
  ans += 400000

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a >= 10 || b >= 10:
  print(-1)
else:
  print(a*b)

Fixed submission:
a, b = map(int, input().split())
if a >= 10 or b >= 10:
  print(-1)
else:
  print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import itertools
num = int(input())
lines = list(int(i) for i in input().split())
lines.sort(reverse=True)
counter = 0

comb = itertools.combinations(lines, 3)

for c in comb:
  cl = list(c)
  if cl[0] < cl[1] + cl[2]:
    counter += 1
    
print(counter)

Fixed submission:
import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
num = int(input())
lines = list(int(i) for i in input().split())
lines.sort(reverse=True)
counter = 0

for i in range(num):
  for j in range(i+1, num):
    for k in range(j+1, num):
      if lines[i] < lines[j] + lines[k]:
        counter += 1
print(counter)


Fixed submission:
import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%2=0:
  print(1/2)
else:
  print((n+1)/2n)
  

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(1/2)
elif n % 2 == 1:
  print((n+1)/(2*n))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

mass = int(input())
buildings = np.array(list(int(i) for i in input().split()))
move_history = []

for place in range(mass):
  now = place
  move_num = 0
  for move in range(mass-(place+1)):
    if buildings[now] >= buildings[now+1]:
      move_num += 1
      now += 1
    else:
      break
  move_history.append(move_num)
print(max(move_history))

Fixed submission:
import numpy as np

mass = int(input())
buildings = np.array(list(int(i) for i in input().split()))
move_count = 0
max_move = 0

for i in range(mass-1):
  if buildings[i] >= buildings[i+1]:
    move_count += 1
  else:
    if move_count > max_move:
      max_move = move_count
    move_count = 0
  if move_count > max_move:
    max_move = move_count

print(max_move)

Buggy python submission (verdict: Time Limit Exceeded):
mass = int(input())
buildings = list(int(i) for i in input().split())
move_history = []

for place in range(mass):
  now = place
  move_num = 0
  for move in range(mass-(place+1)):
    if buildings[now] >= buildings[now+1]:
      move_num += 1
      now += 1
    else:
      break
  move_history.append(move_num)
print(max(move_history))

Fixed submission:
import numpy as np

mass = int(input())
buildings = np.array(list(int(i) for i in input().split()))
move_count = 0
max_move = 0

for i in range(mass-1):
  if buildings[i] >= buildings[i+1]:
    move_count += 1
  else:
    if move_count > max_move:
      max_move = move_count
    move_count = 0
  if move_count > max_move:
    max_move = move_count

print(max_move)