Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
import itertools

n = int(input())

distans = []
tmps = []
for i in range(n):
    x,y = map(int,input().split())
    tmps.append((x - y)**2)

ans = 0
comb = list(itertools.combinations(range(int((n*(n-1))/2)),2))
for k in range(len(comb)):
    distans.append(math.sqrt(tmps[comb[k][0]] + tmps[comb[k][1]]))
    ans += distans[k] * (math.factorial(n)-n+1) 
print(ans/math.factorial(n))

Fixed submission:
import itertools
import math
n = int(input())
xy = [list(map(int,input().split()))for _ in range(n)]

ans = 0
for i in itertools.permutations(range(n), n):
    tmp = i[0]
    for j in i:
        ans += (((xy[tmp][0]-xy[j][0])**2 + (xy[tmp][1]-xy[j][1])**2)**0.5)
        tmp = j
print(ans/math.factorial(n))

Buggy python submission (verdict: Runtime Error):
import math

n = int(input())

distans = []
tmps = []
for i in range n:
    x,y = map(int,input().split())
    tmps[i] = (x - y)**2

for i in range n-1:
    distans[i] = math.sqrt(tmps[i] + tmps[i+1])
    ans += distans[i] * (math.factorial(n)-1) 

print(ans/math.factorial(n))

Fixed submission:
import itertools
import math
n = int(input())
xy = [list(map(int,input().split()))for _ in range(n)]

ans = 0
for i in itertools.permutations(range(n), n):
    tmp = i[0]
    for j in i:
        ans += (((xy[tmp][0]-xy[j][0])**2 + (xy[tmp][1]-xy[j][1])**2)**0.5)
        tmp = j
print(ans/math.factorial(n))
Buggy python submission (verdict: Time Limit Exceeded):
#それゆけにぶたんまん
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        #jより大きい整数kでl[k]<l[i]+l[j]を満たす最大のk
        le = j
        ri = n
        while ri-le>1:
            m = (ri+le)//2
            if l[m]<l[i]+l[j]:
                le = m
            else:
                ri = m
        ans += le-j

print(ans)


Fixed submission:
#それゆけにぶたんまん
#python3.8.2のTLEの壁に阻まれました
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        #jより大きい整数kでl[k]<l[i]+l[j]を満たす最大のk
        le = j
        ri = n
        while ri-le>1:
            m = (ri+le)//2
            if l[m]<l[i]+l[j]:
                le = m
            else:
                ri = m
        ans += le-j

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#愚直にn^3
n = int(input())
l = list(map(int,input().split()))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            len = l[i]+l[j]+l[k]
            ma = max(l[i],max(l[j],l[k]))
            rest = len-ma
            if ma < rest:
                ans += 1
print(ans)

Fixed submission:
#それゆけにぶたんまん
#python3.8.2のTLEの壁に阻まれました
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        #jより大きい整数kでl[k]<l[i]+l[j]を満たす最大のk
        le = j
        ri = n
        while ri-le>1:
            m = (ri+le)//2
            if l[m]<l[i]+l[j]:
                le = m
            else:
                ri = m
        ans += le-j

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#愚直にn^3
n = int(input())
l = list(map(int,input().split()))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            len = l[i]+l[j]+l[k]
            ma = max(l[i],max(l[j],l[k]))
            rest = len-ma
            if ma < rest:
                ans += 1
print(ans)

Fixed submission:
#それゆけにぶたんまん
#python3.8.2のTLEの壁に阻まれました
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n):
    for j in range(i+1,n):
        #jより大きい整数kでl[k]<l[i]+l[j]を満たす最大のk
        le = j
        ri = n
        while ri-le>1:
            m = (ri+le)//2
            if l[m]<l[i]+l[j]:
                le = m
            else:
                ri = m
        ans += le-j

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[]
[a.append(int(input())-1) for _ in range(q)]
i=[k]*n

for l in range(q):
    i = list(map(lambda x:x-1 ,i))
    i[a[l]] += 1

for l in range(n):
    if i[l] <= 0:
        print("No")
    else:
        print("Yes")

Fixed submission:
n,k,q=map(int,input().split())
a=[]
[a.append(int(input())-1) for _ in range(q)]
i=[k-q]*n

for l in range(q):
    i[a[l]] += 1

for l in range(n):
    if i[l] <= 0:
        print("No")
    else:
        print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[]
[a.append(int(input())-1) for _ in range(q)]
i=[k]*n

for l in range(q):
    i = list(map(lambda x:x-1 ,i))
    i[a[l]] += 1

for l in range(n):
    if i[l] <= 0:
        print("No")
    else:
        print("Yes")

Fixed submission:
n,k,q=map(int,input().split())
a=[]
[a.append(int(input())-1) for _ in range(q)]
i=[k-q]*n

for l in range(q):
    i[a[l]] += 1

for l in range(n):
    if i[l] <= 0:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for _ in range(n-1)]
px = [list(map(int,input().split()))for _ in range(q)]

graph = [[] for _ in range(n+3)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if v == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)
print(*value[1:],end="\t")


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)

n,q = map(int,input().split())
ab = [list(map(int,input().split()))for _ in range(n-1)]
px = [list(map(int,input().split()))for _ in range(q)]

graph = [[] for _ in range(n+3)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0]*(n+1)
for p,x in px:
    value[p] += x

def dfs(v,add):
    value[v] += add
    for x in graph[v]:
        dfs(x,value[v])

dfs(1,0)
print(*value[1:],end="\t")


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 遅延評価で加えてあげるだけ

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(v,parent,add):
    value[v] += add
    for x in graph[v]:
        if x == parent:
            continue
        dfs(x,v,value[v])

dfs(1,0,0)

answer = ' '.join(map(str,value[1:]))
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
ans=0
for i in range(n):
  S=str(sorted(input()))
  s.append(S)

for i in range(len(set(s))):
  tmp = s.count(list(set(s))[i])
  if tmp==1:
    ans+=0
  else:
    ans+=tmp*(tmp-1)/2
  
print(int(ans))


Fixed submission:
n = int(input())
s = {}
ans = 0
for i in range(n):
    tmp = str(sorted(input()))
    if tmp in s:
        ans += s[tmp]
        s[tmp] += 1
    else:
        s[tmp] = 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
s=[]
ans=0
for i in range(n):
  S=''.join(sorted(input()))
  s.append(S)

for i in range(len(set(s))):
  tmp = s.count(list(set(s))[i])
  if tmp==1:
    ans+=0
  else:
    ans+=math.factorial(tmp)/math.factorial(2)*math.factorial(tmp-2)
  
print(int(ans))


Fixed submission:
n = int(input())
s = {}
ans = 0
for i in range(n):
    tmp = str(sorted(input()))
    if tmp in s:
        ans += s[tmp]
        s[tmp] += 1
    else:
        s[tmp] = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
best_cnt=0
[a.append(int(input())) for _ in range(n)]
b = sorted(a)
if len(set(b))==1:
  best=better=b[-1]
else:
  best=list(set(b))[-1]
  better=list(set(b))[-2]
for i in range(n):
  if a[i]==best:
    best_cnt+=1
    
for i in range(n):
  if a[i] == best:
    if b_cnt==1:
      print(better)
    else:
      print(best)
  else:
    print(best)

Fixed submission:
n=int(input())
a=[]
best_cnt=0
[a.append(int(input())) for _ in range(n)]
b = sorted(a)
if len(set(b))==1:
  best=better=b[-1]
else:
  best=list(set(b))[-1]
  better=list(set(b))[-2]
for i in range(n):
  if a[i]==best:
    best_cnt+=1
    
for i in range(n):
  if a[i] == best:
    if best_cnt==1:
      print(better)
    else:
      print(best)
  else:
    print(best)
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())
ans = 2018
for i in range(l,r+1):
    for j in range(l,r+1):
        if i<j:
            ans = min(ans,(i*j)%2019)
            if ans == 0:break
print(ans)

Fixed submission:
l,r=map(int,input().split())
ans = 2018
for i in range(l,r+1):
    for j in range(l,r+1):
        if i<j:
            ans = min(ans,(i*j)%2019)
            if ans == 0:
                print(0)
                exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 1000000007
n,m = map(int,input().split())

a = []
for _ in range(m):
    tmp = int(input())
    a.append(tmp)
a = set(a)

dp = [0] * 10**5
dp[0] = 1

for i in range(1,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1]
    if i > 1:
        dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n]%mod)

Fixed submission:
mod = 1000000007
n,m = map(int,input().split())

a = []
for _ in range(m):
    tmp = int(input())
    a.append(tmp)
a = set(a)

dp = [0] * (10**5 + 7)
dp[0] = 1

for i in range(1,n+1):
    if i in a:
        continue
    dp[i] = dp[i-1]
    if i > 1:
        dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n]%mod)
Buggy python submission (verdict: Runtime Error):
n=int(input())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    E[u].append((v,w))
    E[v].append((u,w))
color=[-1]*(n+1)

def dfs(i,j):
    color[i] = j
    for w,l in E[i]:
        if color[w] == -1:
            tj = j
            if l % 2 != 0:
                tj = int(not tj)
            dfs(w,tj)

dfs(1,0)
[print(color[i]) for i in range(1,n+1)]


Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
n=int(input())
E=[[] for _ in range(n+1)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    E[u].append((v,w))
    E[v].append((u,w))
color=[-1]*(n+1)

def dfs(i,j):
    color[i] = j
    for w,l in E[i]:
        if color[w] == -1:
            tj = j
            if l % 2 != 0:
                tj = int(not tj)
            dfs(w,tj)

dfs(1,0)
[print(color[i]) for i in range(1,n+1)]
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**8)

n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル

def rec(i):#再帰による全探索
    if dp[i] != float("inf"):
        return dp[i]
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0]-h[1])
    else:
        return dp[i] = min(rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**8)

n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル
#まずは使わない

def rec(i):#再帰による全探索
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0]-h[1])
    else:
        return min(rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル
#まずは使わない

def rec(i):#再帰による全探索
    if i == 0:
        return 0
    elif i == 1:
        return abs(h[0]-h[1])
    else:
        return min(rec(i-1)+abs(h[i]-h[i-1]),rec(i-2)+abs(h[i]-h[i-2]))

print(rec(n-1))


Fixed submission:
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]メモ化テーブル

def rec(i):
    res = float("inf")
    if i<=0:
        return 0
    return min(rec(i-1) + abs(h[i]-h[i-1]),rec(i-2) + abs(h[i]-h[i-2]))

print(rec(n-1))

Fixed submission:
n = int(input())
h = list(map(int,input().split()))

dp = [float("inf")] * n #dpテーブル
#dp[i]:=i番目の足場まで来るのに必要な最小コスト

#初期条件
dp[0]=0
dp[1]=abs(h[1]-h[0])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]) ,dp[i-2] + abs(h[i-2]-h[i]))

print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
#最小全域木　プリム法
from heapq import *

n=int(input())
xy=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y,i])

#今回の問題では,高々xが隣のやつとyが隣のやつを全部考えればよし
#（詳しくは解説pdfより）
x_sort = sorted(xy, key=lambda x: x[0])
y_sort = sorted(xy, key=lambda x: x[1])

cost = [[]for _ in range(n+3)] #cost[i]にはi番目から(j,k)でj番目にコストkかかる
for i in range(n-1):
    cost[x_sort[i][2]].append((x_sort[i+1][2],x_sort[i+1][0]-x_sort[i][0]))
    cost[x_sort[i+1][2]].append((x_sort[i][2],x_sort[i+1][0]-x_sort[i][0]))

    cost[y_sort[i][2]].append((y_sort[i+1][2],y_sort[i+1][1]-y_sort[i][1]))
    cost[y_sort[i+1][2]].append((y_sort[i][2],y_sort[i+1][1]-y_sort[i][1]))


used=[False]*(n+3)#頂点が最小全域木にもうすでに含まれているかどうか
q=[]
#すでに最小全域木が決まっている部分からまだ決まっていない部分への辺をヒープで管理
#(a,b)でaには向かう先の頂点,bにはかかるコスト
#ヒープで小さいコストからとりだせる

#初期条件
#はじめはどこでもよいので０番目スタートとする(0番目だけではコストは0)
used[0] = True
ans = 0

#0番目からの辺をすべてヒープに挿入
for to,cst in cost[0]:
    heappush(q,(cst,to))

#すでに決まっている最小全域木部分からまだ決まっていない部分を貪欲的にひたすら追加する
#はじめは初期条件の通り
while(len(q)!=0):
    c,ver=heappop(q)
  #すでに決まっている部分から一番小さいコストの辺を取り出す
    if used[ver] == True:
        continue
  #もしすでに最小全域木部分であればやり直し
  #そうでなければコストの分を加算し、新しい頂点を最小全域木部分に追加する
    ans += c
    used[ver] = True
  #新しく追加した頂点からの辺をヒープに追加する
    for to,cst in cost[ver]:
        heappush(q,(cst,to))
　#これを貪欲的に繰り返すことでうまくいくらしい
print(ans)


Fixed submission:
#最小全域木　プリム法
from heapq import *

n=int(input())
xy=[]
for i in range(n):
    x,y=map(int,input().split())
    xy.append([x,y,i])

#今回の問題では,高々xが隣のやつとyが隣のやつを全部考えればよし
#（詳しくは解説pdfより）
x_sort = sorted(xy, key=lambda x: x[0])
y_sort = sorted(xy, key=lambda x: x[1])

cost = [[]for _ in range(n+3)] #cost[i]にはi番目から(j,k)でj番目にコストkかかる
for i in range(n-1):
    cost[x_sort[i][2]].append((x_sort[i+1][2],x_sort[i+1][0]-x_sort[i][0]))
    cost[x_sort[i+1][2]].append((x_sort[i][2],x_sort[i+1][0]-x_sort[i][0]))

    cost[y_sort[i][2]].append((y_sort[i+1][2],y_sort[i+1][1]-y_sort[i][1]))
    cost[y_sort[i+1][2]].append((y_sort[i][2],y_sort[i+1][1]-y_sort[i][1]))


used=[False]*(n+3)#頂点が最小全域木にもうすでに含まれているかどうか
q=[]
#すでに最小全域木が決まっている部分からまだ決まっていない部分への辺をヒープで管理
#(a,b)でaには向かう先の頂点,bにはかかるコスト
#ヒープで小さいコストからとりだせる

#初期条件
#はじめはどこでもよいので０番目スタートとする(0番目だけではコストは0)
used[0] = True
ans = 0

#0番目からの辺をすべてヒープに挿入
for to,cst in cost[0]:
    heappush(q,(cst,to))

#すでに決まっている最小全域木部分からまだ決まっていない部分を貪欲的にひたすら追加する
#はじめは初期条件の通り
while(len(q)!=0):
    c,ver=heappop(q)
#すでに決まっている部分から一番小さいコストの辺を取り出す
    if used[ver] == True:
        continue
#もしすでに最小全域木部分であればやり直し
#そうでなければコストの分を加算し、新しい頂点を最小全域木部分に追加する
    ans += c
    used[ver] = True
#新しく追加した頂点からの辺をヒープに追加する
    for to,cst in cost[ver]:
        heappush(q,(cst,to))
#これを貪欲的に繰り返すことでうまくいくらしい
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))

Fixed submission:
s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))

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

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0])

Fixed submission:
s = input()
n = len(s)

#左から順番に文字を結合していき+を入れるパターンと入れないパターンについて同様に文字を結合させていく
def dfs(i,f):
    if i == n-1:#すべての文字を使いきったらそのときの計算をする
        return sum(list(map(int,f.split("+"))))
    return dfs(i+1,f+s[i+1]) + dfs(i+1,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
    
print(dfs(0,s[0]))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = 0
if n <= 2:
    if a[0] < a[1]:
        exit(print('Yes'))
    else:
        exit(print('No'))
p = 1
for i in range(k): p *= a[i]
for i in range(k,n):
    t = p * a[i]
    p *= a[i-k]
    if p < t:
        print('Yes')
    else:
        print('No')
    p = t


Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(k,n): print('Yes' if a[i] > a[i-k] else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = 0
if n <= 2:
    if a[0] < a[1]:
        exit(print('Yes'))
    else:
        exit(print('No'))
p = 1
for i in range(k): p *= a[i]
for i in range(k,n):
    t = p * a[i]
    p *= a[i-k]
    if p < t:
        print('Yes')
    else:
        print('No')
    p = t


Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(k,n): print('Yes' if a[i] > a[i-k] else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = 0
if n <= 2:
    if a[0] < a[1]:
        exit(print('Yes'))
    else:
        exit(print('No'))
p = 1
for i in range(k): p *= a[i]
for i in range(k,n):
    t = (p // a[i-k]) * a[i]
    if p < t:
        p = t
        print('Yes')
    else:
        p = t
        print('No')

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(k,n): print('Yes' if a[i] > a[i-k] else 'No')
Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
if n==0: exit(print(x))
p = list(map(int,input().split()))
p.sort()
if x not in p: exit(print(x))
for i in range(x,101):
    if i not in p:
        h = i
        break
for i in range(x,0,-1):
    if i not in p:
        l = i
        break
if abs(x-h)>=abs(x-l): print(l)
if abs(x-l)>abs(x-h): print(h)


Fixed submission:
x,n = map(int,input().split())
if n==0: exit(print(x))
p = list(map(int,input().split()))
p.sort()
if x not in p: exit(print(x))
h=101
l=0
for i in range(x,101):
    if i not in p:
        h = i
        break
for i in range(x,0,-1):
    if i not in p:
        l = i
        break
if abs(x-h)>=abs(x-l): print(l)
if abs(x-l)>abs(x-h): print(h)
Buggy python submission (verdict: Time Limit Exceeded):
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
z = 2
count = 0
if is_prime(n): exit(print(1))
while True:
    if n%z==0:
        n /= z
        count += 1
    while True:
        z += 1
        t = math.sqrt(z)
        t = prime_factorize(z)
        if is_prime(z) or sum(t)==t[0]*len(t): break
    if n < z: break
print(count)

Fixed submission:
import math
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr

n = int(input())
pl = factorization(n)
if len(pl) == 0: exit(print(0))
count = 0
for a,b in pl:
    if a==1 and b==1: exit(print(0))
    t=1
    while True:
        if b < t: break
        count += 1
        b-=t
        t+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
H = list(map(int,input().split()))
A,B = [0]*m,[0]*m
for i in range(m): A[i],B[i] = map(int,input().split())

ans = 0
for i in range(n):
    count = 1
    for j in range(m):
        if i != A[j]-1 and i != B[j]-1: continue
        if i == A[j]-1:
            if H[i] <= H[B[j]-1]:
                count = 0
                break
        if i == B[j]-1:
            if H[i] <= H[A[j]-1]:
                count = 0
                break
    ans += count
print(ans)

Fixed submission:
n,m = map(int,input().split())
judge = [1]*n
H = list(map(int,input().split()))

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if H[a] > H[b]:
        judge[b] *= 0
    elif H[a] < H[b]:
        judge[a] *= 0
    else:
        judge[a] *= 0
        judge[b] *= 0
print(sum(judge))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
H = list(map(int,input().split()))
A,B = [0]*m,[0]*m
for i in range(m): A[i],B[i] = map(int,input().split())

ans = 0
for i in range(n):
    count = 1
    for j in range(m):
        if i != A[j]-1: continue
        if H[i] <= H[B[j]-1]:
            count = 0
            break
    for j in range(m):
        if i != B[j]-1: continue
        if H[i] <= H[A[j]-1]:
            count = 0
            break
    ans += count
print(ans)

Fixed submission:
n,m = map(int,input().split())
judge = [1]*n
H = list(map(int,input().split()))

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if H[a] > H[b]:
        judge[b] *= 0
    elif H[a] < H[b]:
        judge[a] *= 0
    else:
        judge[a] *= 0
        judge[b] *= 0
print(sum(judge))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))

for i in range(n):
    print(A.count(i+1))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    ans[A[i]]+=1

for i in range(1,n+1):
    print(ans[i])

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

for i in range(n):
    print(A.count(i+1))

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    ans[A[i]]+=1

for i in range(1,n+1):
    print(ans[i])