Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02802 (python)

Fixed submission:
N, M=map(int, input().split())
lst=[input().split() for _ in range(M)]
AC=[False for _ in range(N)]
WA=[0 for _ in range(N)]
for p, S in lst:
  p=int(p)-1
  if S=="AC":
    AC[p]=True
  if S=="WA" and not AC[p]:
    WA[p]+=1
for i in range(N):
  if not AC[i]:
    WA[i]=0
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
lst=[input().split() for _ in range(M)]
AC=[False for _ in range(N)]
WA=[0 for _ in range(N)]
for p, S in lst:
  p=int(p)-1
  if S=="AC":
    AC[p]=True
  if S=="WA" and not AC[p]:
    WA[p]+=1
for i in range(M):
  if not AC[p]:
    WA[i]=0
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M=map(int, input().split())
lst=[input().split() for _ in range(M)]
AC=[False for _ in range(N)]
WA=[0 for _ in range(N)]
for p, S in lst:
  p=int(p)-1
  if S=="AC":
    AC[p]=True
  if S=="WA" and not AC[p]:
    WA[p]+=1
for i in range(N):
  if not AC[p]:
    WA[i]=0
print(sum(AC), sum(WA))
Problem p02850 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)

Buggy submission (verdict: Runtime Error):
N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
to=[[] for _ in range(N)]
color=[0 for _ in range(N-1)]
for i in range(N-1):
    a, b=ab[i]
    a-=1
    b-=1
    to[a].append([b, i])
    to[b].append([a, i])

def dfs(v, p=-1, c=-1):
    k=1
    for i in range(len(to[v])):
        u, index=to[v][i]
        if u==p:
            continue
        if k==c:
            k+=1
        color[index]=k
        dfs(u, v, k)
        k+=1

dfs(0)
print(max(color))
for i in range(N-1):
    print(color[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)
Problem p02855 (python)

Fixed submission:
from collections import deque

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
rows_list=[]
upper=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      rows_list.append([upper, i])
      upper=i+1
      break
rows_list[-1][-1]=H-1
ans_list=[]
for rows in rows_list:
  for i in range(rows[0], rows[1]+1):
    left=0
    for j in range(W):
      if cake[i][j]=="#":
        ans_list.append([rows[0], rows[1], left, j])
        left=j+1
    if ans_list:
      ans_list[-1][-1]=W-1
ans=[[0 for _ in range(W)] for _ in range(H)]
key=1
for l in ans_list:
  for i in range(l[0], l[1]+1):
    for j in range(l[2], l[3]+1):
      ans[i][j]=key
  key+=1
for a in ans:
  print(*a)

Buggy submission (verdict: Runtime Error):
from collections import deque

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
rows_list=[]
upper=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      rows_list.append([upper, i])
      upper=i+1
      break
rows_list[-1][-1]=H-1
ans_list=[]
for rows in rows_list:
  for i in range(rows[0], rows[1]+1):
    left=0
    for j in range(W):
      if cake[i][j]=="#":
        ans_list.append([rows[0], rows[1], left, j])
        left=j+1
    ans_list[-1][-1]=W-1
ans=[[0 for _ in range(W)] for _ in range(H)]
key=1
for l in ans_list:
  for i in range(l[0], l[1]+1):
    for j in range(l[2], l[3]+1):
      ans[i][j]=key
  key+=1
for a in ans:
  print(*a)

Buggy submission (verdict: Runtime Error):
def cut(i, j, num):
  marked[i][j]=num
  if i>0 and cake[i-1][j]=="." and marked[i-1][j]==0:
    cut(i-1, j, num)
  if j>0 and cake[i][j-1]=="." and marked[i][j-1]==0:
    cut(i, j-1, num)
  if i<H-1 and cake[i+1][j]=="." and marked[i+1][j]==0:
    cut(i+1, j, num)
  if j<W-1 and cake[i][j+1]=="." and marked[i][j+1]==0:
    cut(i, j+1, num)

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
marked=[[0 for _ in range(W)] for _ in range(H)]
mark=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      mark+=1
      cut(i, j, mark)
for i in range(H):
  print(*marked[i])

Buggy submission (verdict: Runtime Error):
def cut(i, j, num):
  marked[i][j]=num
  if i>0 and cake[i-1][j]=="." and marked[i-1][j]==0:
    cut(i-1, j, num)
  if j>0 and cake[i][j-1]=="." and marked[i][j-1]==0:
    cut(i, j-1, num)
  if i<H-1 and cake[i+1][j]=="." and marked[i+1][j]==0:
    cut(i+1, j, num)
  if j<W-1 and cake[i][j+1]=="." and marked[i][j+1]==0:
    cut(i, j+1, num)

H, W, K=map(int, input().split())
cake=[input() for _ in range(H)]
marked=[[0 for _ in range(W)] for _ in range(H)]
mark=0
for i in range(H):
  for j in range(W):
    if cake[i][j]=="#":
      mark+=1
      cut(i, j, mark)
print(marked)
Problem p02882 (python)

Fixed submission:
import math

a, b, x=map(int, input().split())
ans=math.degrees(math.atan(2*(a*a*b-x)/a**3) if x>=a**2*b/2 else math.atan(a*b**2/(2*x)))
print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

if x>=(a*a*b)/2:
    print(90-math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
else:
    print(90-math.degrees(math.asin(4*x/(a*b*b))/2))
Problem p02885 (python)

Fixed submission:
a, b=map(int, input().split())
ans=a-2*b if a-2*b>0 else 0
print(ans)

Buggy submission (verdict: Runtime Error):
A, B=map(int, input().split())
ans=a-2*b if a-2*b>0 else 0
print(ans)
Problem p02900 (python)

Fixed submission:
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)
  return divisors

def make_cd(x, y):
  div1=make_divisors(x)
  div2=make_divisors(y)
  cd=[]
  for i in div1:
    for j in div2:
      if i==j:
        cd.append(i)
        break
  cd.sort()
  return cd

A, B=map(int, input().split())
if A<B:
  A,B=B,A
cd=make_cd(A, B)
ok=[True for _ in range(len(cd))]
for i in range(1, len(cd)):
  if not ok[i]:
    continue
  for j in range(i+1, len(cd)):
    if cd[j]%cd[i]==0:
      ok[j]=False
print(sum([1 if ok[i] else 0 for i in range(len(cd))]))

Buggy submission (verdict: Runtime Error):
import math

def searchPrimeNum(N):
    maxV=int(math.sqrt(N))
    searchList=[i for i in range(2, N+1)]
    primeNum=[]
    while searchList[0]<=maxV:
        primeNum.append(searchList[0])
        tmp=searchList[0]
        searchList=[i for i in searchList if i%tmp!=0]
    primeNum.extend(searchList)
    return primeNum

A, B=map(int, input().split())
primeNum=searchPrimeNum(max(A, B))
ans=1
for p in primeNum:
    if A%p==0 and B%p==0:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import math

def searchPrimeNum(N):
    maxV=int(math.sqrt(N))
    searchList=[i for i in range(2, N+1)]
    primeNum=[]
    while searchList[0]<=maxV:
        primeNum.append(searchList[0])
        tmp=searchList[0]
        searchList=[i for i in searchList if i%tmp!=0]
    primeNum.extend(searchList)
    return primeNum

A, B=map(int, input().split())
primeNum=searchPrimeNum(max(A, B))
ans=1
for p in primeNum:
    if A%p==0 and B%p==0:
        ans+=1
print(ans)
Problem p02927 (python)

Fixed submission:
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(i/10), i%10
    if d2 < 2:
      continue
    res += 1 if d1*d2<=m else 0
  print(res)

Buggy submission (verdict: Runtime Error):
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(d/10), d%10
    res += 1 if d1*d2<=m else 0
   print(res)
Problem p02937 (python)

Fixed submission:
s=input()
t=input()
import bisect
res=0
if len(set(t)-set(s)) > 0:
    res=-1
else:
    pos={}
    set_t=set(t)
    for e_t in t:
        pos[e_t]=[]
    for i in range(len(s)):
        if s[i] in set_t:
            pos[s[i]].append(i+1)
    cur = 0
    nxt=0
    for e_t in t:
        nxt=bisect.bisect_left(pos[e_t], cur+1)
        if nxt < len(pos[e_t]):
            cur=pos[e_t][nxt]
        else:
            cur=pos[e_t][0]
            res+=len(s)
    res+=cur
print(res)

Buggy submission (verdict: Runtime Error):
res=0
if len(set(t)-set(s)) > 0:
    res=-1
else:
    dic={}
    for e_t in t:
        dic[e_t]=[]
    for i in range(len(s)):
        if s[i] in t:
            dic[s[i]].append(i+1)
    cur = 0
    for i in range(len(t)):
        nxt=cur
        for e in dic[t[i]]:
            if e > cur:
                nxt=e
                break
        if nxt == cur:
            nxt = dic[t[i]][0]
            res+=len(s)
        cur=nxt
    res+=cur
print(res)
Problem p02945 (python)

Fixed submission:
a,b=map(int, input().split())
print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(max(a+b, a-bm a*b))
Problem p02946 (python)

Fixed submission:
k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))

Buggy submission (verdict: Runtime Error):
k,x=map(int, input().split())
print(" ".join([x-k+i for i in range(1, 2k)]))

Buggy submission (verdict: Runtime Error):
k,x=map(int, input().split())
print(" ".join([x-k+1+i for i in range(2k+1)]))

Buggy submission (verdict: Runtime Error):
k, x=map(int, input().split())
print(" ".join([x-i for i in range(-k, k+1)]))

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(" ".join([x-i for i in range(-k, k)]))
Problem p02947 (python)

Fixed submission:
from collections import Counter
n=int(input())
string_list=["".join(sorted(list(input()))) for i in range(n)]
counter=Counter(string_list)
cnt=0
for k, v in counter.items():
  cnt+=int(v*(v-1)/2)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
counter = Counter(ss)
for k, v in counter.items():
  cnt += v*(v-1)/2
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else:
    dic[s]+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt = 0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s]=1
  else :
    dic[s]+=1
for v in dic.values():
  cnt += v*(v-1)/2
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
ss = [sorted(input()) for i in range(n)]
cnt=0
dic = {}
for s in ss:
  if s not in dic.keys():
    dic[s] = 1
  else :
    dic[s] += 1
for v in dic.values():
  cnt += v
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += int(v)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic.items():
  cnt += v
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
ss = [sorted(input()) for i in range(n)]
dic = Counter(ss)
cnt=0
for k, v in dic:
  cnt += v
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
string_list=[sorted(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
string_list=[Counter(input()) for i in range(n)]
string_set=set(string_list)
cnt=0
for s in string_set:
  n=string_list.count(s)
  cnt+=int(n*(n-1)/2)
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
string_list=[sorted(Counter(input()), key=lambda x:x[0]) for i in range(n)]
cnt=0
for i in range(n):
  si = string_list[i]
  for j in range(i, n):
    sj = string_list[j]
    if si.items() == sj.items():
      cnt += 1
print(cnt)
Problem p02949 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)

N, M, P = map(int, input().split())

INF = 10**10
# Bellman-Fordをするときは、辺集合を持つ
edges = [] 
# 1から行けない辺やNに到達できない辺を削除するための探索をする用
to = [[] for _ in range(2505)]
rto = [[] for _ in range(2505)]
reachableFrom1 = [False for _ in range(2505)]
reachableToN = [False for _ in range(2505)]
ok = [False for _ in range(2505)]

def dfs(v):
    if reachableFrom1[v]:
        return
    reachableFrom1[v] = True
    for u in to[v]:
        dfs(u)

def rdfs(v):
    if reachableToN[v]:
        return
    reachableToN[v] = True
    for u in rto[v]:
        rdfs(u)

for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1; b -= 1
    c -= P
    c = -c # 最短路にするため符号を逆転
    edges.append([a, b, c])
    to[a].append(b)
    rto[b].append(a)

# 考えるべき頂点だけ洗い出し
dfs(0)
rdfs(N-1)
for i in range(N):
    ok[i] = reachableFrom1[i] & reachableToN[i]

# Bellman-Ford
d = [INF for _ in range(N)]
d[0] = 0
upd = True
step = 0
flag = True
while upd:
    upd = False
    for i in range(M):
        a, b, c = edges[i]
        if not ok[a]:
            continue
        if not ok[b]:
            continue
        newD = d[a]+c
        if newD < d[b]:
            upd = True
            d[b] = newD
    step += 1
    if step > N:
        flag = False
        break
if flag:
    ans = -d[N-1]
    ans = max(ans, 0)
    print(ans)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M, P = map(int, input().split())

INF = 10**10
# Bellman-Fordをするときは、辺集合を持つ
edges = [] 
# 1から行けない辺やNに到達できない辺を削除するための探索をする用
to = [[] for _ in range(2505)]
rto = [[] for _ in range(2505)]
reachableFrom1 = [False for _ in range(2505)]
reachableToN = [False for _ in range(2505)]
ok = [False for _ in range(2505)]

def dfs(v):
    if reachableFrom1[v]:
        return
    reachableFrom1[v] = True
    for u in to[v]:
        dfs(u)

def rdfs(v):
    if reachableToN[v]:
        return
    reachableToN[v] = True
    for u in rto[v]:
        rdfs(u)

for i in range(M):
    a, b, c = map(int, input().split())
    a -= 1; b -= 1
    c -= P
    c = -c # 最短路にするため符号を逆転
    edges.append([a, b, c])
    to[a].append(b)
    rto[b].append(a)

# 考えるべき頂点だけ洗い出し
dfs(0)
rdfs(N-1)
for i in range(N):
    ok[i] = reachableFrom1[i] & reachableToN[i]

# Bellman-Ford
d = [INF for _ in range(N)]
d[0] = 0
upd = True
step = 0
flag = True
while upd:
    upd = False
    for i in range(M):
        a, b, c = edges[i]
        if not ok[a]:
            continue
        if not ok[b]:
            continue
        newD = d[a]+c
        if newD < d[b]:
            upd = True
            d[b] = newD
    step += 1
    if step > N:
        flag = False
        break
if flag:
    ans = -d[N-1]
    ans = max(ans, 0)
    print(ans)
else:
    print(-1)
Problem p02972 (python)

Fixed submission:
n=int(input())
A=[0]+list(map(int, input().split()))
B=[0]*(n+1)
B[n//2+1:]=A[n//2+1:]
for i in range(n//2, 0, -1):
  B[i]=(sum([B[j] for j in range(2*i, n+1, i)])+A[i])&1
res=[]
for i in range(n+1):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(*res)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split())).insert(0, 0)
B=[0]*(n+1)
for i in range(n, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]+=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))
Problem p02982 (python)

Fixed submission:
import math
N, D=map(int, input().split())
X=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
N, D=map(int, input())
Xs=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)
Problem p03032 (python)

Fixed submission:
import heapq
from collections import deque

N, K=map(int, input().split())
V=list(map(int, input().split()))
limitAB=min(N, K)
ans=0
for num in range(limitAB+1):
  for A in range(num+1):
    B=num-A
    d=deque(V)
    h=[]
    while d and len(h)<A:
      heapq.heappush(h, d.popleft())
    while d and len(h)<A+B:
      heapq.heappush(h, d.pop())
    cnt=0
    while h and h[0]<0 and cnt<K-(A+B):
      heapq.heappop(h)
      cnt+=1
    ans=max(ans, sum(h))
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
import heapq

N, K=map(int, input().split())
V=list(map(int, input().split()))
lim=min(N, K)
ans=0
for num in range(lim+1):
    for A in range(num+1):
        B=num-A
        d=deque(V)
        hands=[]
        while d and len(h)<A:
            hands.append(d.popleft())
        while d and len(h)<A+B:
            hands.append(d.pop())
        heapq.heapify(hands)
        cnt=K-num
        while len(hands) and hands[0]<0 and cnt>0:
            cnt-=1
            heapq.heappop(hands)
        ans=max(ans, sum(hands))
print(ans)

Buggy submission (verdict: Runtime Error):
N, K=map(int, input().split())
D=list(map(int, input().split()))
limit=min(N, K)
ans=0
for A in range(limit+1):
  for B in range(limit-A+1):
    jewels=D[:A]+D[-B:] if B>0 else D[:A]
    jewels.sort()
    for k in range(min(len(jewels)-1, K-(A+B))):
      if jewels[k]>=0:
        break
      jewels.pop(0)
    ans=max(ans, sum(jewels))
print(ans)
Problem p03035 (python)

Fixed submission:
A, B=map(int, input().split())
if A<=5:
  print(0)
elif 6<=A<=12:
  print(B//2)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
A, B=map(int, input().split())
ans=B//2
if B=>13:
  ans=B
elif B<=5:
  ans=0
print(ans)
Problem p03062 (python)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
cnt=0
for i in range(N):
  if A[i]<0:
    A[i]*=-1
    cnt+=1
A=list(map(abs, A))
A.sort()
if cnt&1==0:
  print(sum(A))
else:
  print(sum(A[1:])-A[0])

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
A=list(map(lambda x:-x if x < 0 else x, A))
A.sort()
print(sum(A[1:]-A[0]))

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
A=list(map(int, input().split()))
A=list(map(math.fabs, A))
A.sort()
print(sum(A[1:]-A[0]))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
A=list(map(abs, A))
A.sort()
print(sum(A[1:]-A[0]))
Problem p02678 (python)

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

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

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

from collections import deque

q = deque([0])

ans = [-1]*N
ans[0] = 0

while q:
    v = q.popleft()
    for nv in V[v]:
        if ans[nv] == -1:
            ans[nv] = v + 1
            q.append(nv)

print("Yes")
print(*ans[1:],sep="\n")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())

V = [[] for _ in range(M)]

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

from collections import deque

q = deque([0])

ans = [-1]*N
ans[0] = 0

while q:
    v = q.popleft()
    for nv in V[v]:
        if ans[nv] == -1:
            ans[nv] = v + 1
            q.append(nv)

print("Yes")
print(*ans[1:],sep="\n")
Problem p02716 (python)

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

DP = [0,0,0]
m = N//2*2
if N%2 == 0:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[1] = max(DP[0],DP[1])

    print(DP[1])

else:
    for i in range(0,m,2):
        DP[0] += A[i]
        DP[1] += A[i+1]
        DP[2] += A[i+2]

        DP[1] = max(DP[0],DP[1])
        DP[2] = max(DP[1],DP[2])

    print(DP[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

if N%2 == 0:
    sum1 = sum(A[x*2] for x in range(N//2))
    sum2 = sum(A)-sum1
    print(max(sum1,sum2))
    exit()

DP = [0,0,0]
m = N//2*2
for i in range(0,m,2):
    DP[0] += A[i]
    DP[1] += A[i+1]
    DP[2] += A[i+2]

    DP[1] = max(DP[0],DP[1])
    DP[2] = max(DP[1],DP[2])

print(DP[3])
Problem p02718 (python)

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

A.sort(reverse=True)
S = sum(A)

for i in range(M):
    if A[i] < S/(4*M):
        print('No')
        exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)
S = sum(A)
i = 0

while A[i] >= S/(M*4) and i < N:
    i += 1

if i >= M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)
S = sum(A)
i = 0
while A[i] > S//(M*4) and i < N:
    i += 1

if i >= M:
    print("Yes")
else:
    print("No")
Problem p02732 (python)

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

ls = [0]*N
for i in range(N):
    ls[A[i]-1] += 1
s = 0
for i in range(N):
    s += ls[i]*(ls[i]-1)//2
ans = [0]*N
for i in range(N):
    ans[i] = s-ls[A[i]-1] + 1

print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

ls = [0]*N
for i in range(N):
    ls[A[i]] += 1
s = 0
for i in range(N):
    s += ls[i]*(ls[i]-1)//2

for k in range(N):
    print(s-ls[A[k]] + 1)
Problem p02772 (python)

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

for i in range(N):
    if A[i]%2 == 0 and (A[i]%3 != 0 and A[i]%5 != 0):
        print('DENIED')
        exit()

print('APPROVED')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,intput().split()))

for i in range(N):
    if A[i]%2 == 0 and (A[i]%3 != 0 and A[i]%5 != 0):
        print('DENIED')
        exit()

print('APPROVED')