Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
import numpy as np
N, C = map(int, input().split())
D = np.ndarray((C, C), dtype=int)
c = np.ndarray((N, N), dtype=int)
for i in range(C):
    D[i] = list(map(int,input().split()))
for i in range(N):
    c[i] = list(map(int,input().split()))
c -= 1
acc = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        for k in range(C):
            acc[(i+j) % 3][k] += D[c[i][j]][k]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)

Fixed submission:
from itertools import permutations
import numpy as np
N, C = map(int, input().split())
D = np.ndarray((C, C), dtype=int)
c = np.ndarray((N, N), dtype=int)
for i in range(C):
    D[i] = list(map(int,input().split()))
for i in range(N):
    c[i] = list(map(int,input().split()))
c -= 1
acc = np.zeros((3, C), dtype=int)
for i in range(N):
    for j in range(N):
        acc[(i+j) % 3] += D[c[i][j]]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
N, C = map(int, input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]
acc = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        for k in range(C):
            acc[(i+j) % 3][k] += D[c[i][j]-1][k]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)

Fixed submission:
from itertools import permutations
import numpy as np
N, C = map(int, input().split())
D = np.ndarray((C, C), dtype=int)
c = np.ndarray((N, N), dtype=int)
for i in range(C):
    D[i] = list(map(int,input().split()))
for i in range(N):
    c[i] = list(map(int,input().split()))
c -= 1
acc = np.zeros((3, C), dtype=int)
for i in range(N):
    for j in range(N):
        acc[(i+j) % 3] += D[c[i][j]]
ans = float("inf")
for i,j,k in permutations(range(C), r=3):
    ans = min(ans, acc[0][i]+acc[1][j]+acc[2][k])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
 
red.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])
blue.sort(key=lambda x:x[1])
 
ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            print(a,b,c,d)
            blue.pop(j)
            ans += 1
            break
print(ans)
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]

red.sort(key=lambda x:x[0])
red.sort(key=lambda x:x[1])
blue.sort(key=lambda x:x[0])
blue.sort(key=lambda x:x[1])

ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            blue.pop(j)
            ans += 1
            break
print(ans)

Fixed submission:
N = int(input())
red = [tuple(map(int,input().split())) for _ in range(N)]
blue = [tuple(map(int,input().split())) for _ in range(N)]
 
red.sort(key=lambda x:x[0], reverse=True)
blue.sort(key=lambda x:x[1])
 
ans = 0
for i in range(N):
    a,b = red[i]
    for j in range(len(blue)):
        c,d = blue[j]
        if a < c and b < d:
            blue.pop(j)
            ans += 1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = []
black = 0
for i in range(H):
    l = list(input())
    for j in range(W):
        if l[j] == "#":
            black += 1
    s.append(l)
white = H*W-black
from collections import deque
q = deque([(0,0,0)])
s[0][0] = "#"
while q:
    x,y,cnt = q.popleft()
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        nx,ny = x+dx,y+dy
        if 0<=nx<H and 0<=ny<W and s[nx][ny] != "#":
            if nx == H-1 and ny == W-1:
                print(white-cnt-2)
                exit(114514)
            s[nx][ny] = "#"
            q.append((nx,ny,cnt+1))
print(-1)

Fixed submission:
H, W = map(int,input().split())
s = []
black = 0
for i in range(H):
    tmp = list(input())
    s.append(tmp)
    for j in range(W):
        if tmp[j] == "#":
            black += 1
white = H*W - black


q = [(0,0,0)]
s[0][0] = "#"
while q:
    i, j, cnt = q.pop(0)
    for di, dj in [(1,0),(0,1),(-1,0),(0,-1)]:
        ni, nj = i+di, j+dj
        if ni == H-1 and nj == W-1:
            print(white-cnt-2)
            exit(0)
        elif 0 <= ni < H and 0 <= nj < W and s[ni][nj] == ".":
            s[ni][nj] = "#"
            q.append((ni,nj,cnt+1))
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq as hq
from math import ceil
N, H = map(int, input().split())
ab = [tuple(map(int,input().split())) for _ in range(N)]
ab.sort(key=lambda x:x[1], reverse=True)
ab.sort(key=lambda x:x[0], reverse=True)
ma, mb = ab[0]
ab = ab[1:]
q = []
for _,b in ab:
    if b > ma:
        hq.heappush(q, b)
ans = float("inf")

for l in range(len(q)+1):
    h = H
    cnt = l
    h -= sum(q[:l])
    if h <= 0:
        ans = min(ans, cnt)
        continue
    h -= mb
    cnt += 1
    if h <= 0:
        ans = min(ans, cnt)
        continue
    cnt += ceil(h/ma)
    ans = min(ans, cnt)
print(ans)

Fixed submission:
import heapq as hq
from itertools import accumulate
from math import ceil
N, H = map(int, input().split())
ab = [tuple(map(int,input().split())) for _ in range(N)]
ab.sort(key=lambda x:x[1], reverse=True)
ab.sort(key=lambda x:x[0], reverse=True)
ma, mb = ab[0]
q = [ab[i][1] for i in range(1, N)]
q.sort(reverse=True)
ans = float("inf")
acc = [0]+list(accumulate(q, lambda x,y:x+y))
for l in range(len(q)+1):
    h = H
    cnt = l
    h -= acc[l]
    if h <= 0:
        ans = min(ans, cnt)
        continue
    h -= mb
    cnt += 1
    if h <= 0:
        ans = min(ans, cnt)
        continue
    cnt += ceil(h/ma)
    ans = min(ans, cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
H,W = map(int,input().split())
d = defaultdict(int)
for _ in range(H):
    for c in list(input()):
        d[c] += 1
for i in range((H-1)//2+1):
    for j in range((W-1)//2+1):
        s = set([(x,y) for x,y in [(i,j),(i,W-1-j),(H-1-i,j),(H-1-i,W-1-j)] if 0<=x<H and 0<=y<W])
        f = True
        for k,_ in sorted(d.items(),key=lambda x:x[1]):
            if d[k] >= len(s):
                d[k] -= len(s)
                f = False
                for x,y in s:
                    test[x][y] = k
                break
        if f:
            print("No")
            exit(0)
print("Yes")

Fixed submission:
from collections import defaultdict
H,W = map(int,input().split())
d = defaultdict(int)
for _ in range(H):
    for c in list(input()):
        d[c] += 1
for i in range((H-1)//2+1):
    for j in range((W-1)//2+1):
        s = set([(x,y) for x,y in [(i,j),(i,W-1-j),(H-1-i,j),(H-1-i,W-1-j)] if 0<=x<H and 0<=y<W])
        f = True
        for k,_ in sorted(d.items(),key=lambda x:x[1]):
            if d[k] >= len(s):
                d[k] -= len(s)
                f = False
                break
        if f:
            print("No")
            exit(0)
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
if __name__ == "__main__":
    N = int(input())
    V = N
    dp = []
    for i in range(N):
        dp.append(list(map(int,input().split())))
    edge = [[True]*N for _ in range(N)]
    for k in range(V):
        for i in range(V):
            for j in range(V):
                a = dp[i][j]
                b = dp[i][k]+dp[k][j]
                if a > b:
                    print(-1)
                    exit(0)
                elif a == b and k != i and k != j:
                    edge[i][j] = False
                    edge[j][i] = False
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if edge[i][j]:
                ans += dp[i][j]
    print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
if __name__ == "__main__":
    N = int(input())
    V = N
    dp = []
    for i in range(N):
        dp.append(list(map(int,input().split())))
    edge = [[True]*N for _ in range(N)]
    for k in range(V):
        for i in range(V):
            for j in range(V):
                a = dp[i][j]
                b = dp[i][k]+dp[k][j]
                if a > b:
                    print(-1)
                    exit(0)
                elif a == b and k != i and k != j:
                    edge[i][j] = False
                    edge[j][i] = False
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            if edge[i][j]:
                ans += dp[i][j]
    print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from itertools import accumulate
def GCD(args):
    return list(accumulate(args,gcd))[-1]
N = int(input())
T = [int(input()) for _ in range(N)]
g = GCD(T)
ans = g
for t in T:
    ans *= t//g
print(ans)

Fixed submission:
def gcd(n,m):
    if n < m:
        t = n
        n = m
        m = t
    r = n % m
    while r > 0:
        n, m = m, r
        r = n % m
    return m
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1,N):
    g = gcd(ans,T[i])
    ans = ans*T[i]//g
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
from itertools import accumulate
def GCD(*args):
    return list(accumulate(*args,gcd))[-1]
N = int(input())
T = [int(input()) for _ in range(N)]
g = GCD(T)
ans = g
for t in T:
    ans *= t//g
print(ans)

Fixed submission:
def gcd(n,m):
    if n < m:
        t = n
        n = m
        m = t
    r = n % m
    while r > 0:
        n, m = m, r
        r = n % m
    return m
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1,N):
    g = gcd(ans,T[i])
    ans = ans*T[i]//g
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
from itertools import accumulate
def GCD(*args):
    return list(accumulate(*args,gcd))[-1]
def LCM(*args):
    g = GCD(args)
    return list(accumulate([x//g for x in list(args)], lambda x,y:x*y))[-1]*g
_,*T = open(0)
print(LCM(*map(int,T)))

Fixed submission:
def gcd(n,m):
    if n < m:
        t = n
        n = m
        m = t
    r = n % m
    while r > 0:
        n, m = m, r
        r = n % m
    return m
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(1,N):
    g = gcd(ans,T[i])
    ans = ans*T[i]//g
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq as hq
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    edges[a].append((b,1))
    edges[b].append((a,1))
INF = float("inf")
d = [INF]*N
d[0] = 0
q = [(0,0)]
while q:
    dist, i = hq.heappop(q)
    if d[i] < dist:
        continue
    for j, w in edges[i]:
        if d[j] > d[i]+w:
            d[j] = d[i]+w
            hq.heappush(q, (d[j], j))
def cnt(n,m):
    ret = 1
    for v,_ in edges[n]:
        if v != m and not visited[v]:
            visited[v] = True
            ret += cnt(v,m)
    return ret
visited = [False]*N
visited[0] = True
fnc = cnt(0,N-1)
visited = [False]*N
visited[N-1] = True
snk = cnt(N-1,0)
if d[N-1] % 2 == 0:
    snk -= 1
print("Fennec" if snk < fnc else "Snuke")

Fixed submission:
import heapq as hq
from collections import deque
N = int(input())
edges = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    edges[a].append((b,1))
    edges[b].append((a,1))
INF = float("inf")
d = [INF]*N
d[0] = 0
prev = [None]*N
q = [(0,0)]
while q:
    dist, i = hq.heappop(q)
    if d[i] < dist:
        continue
    for j, w in edges[i]:
        if d[j] > d[i]+w:
            d[j] = d[i]+w
            prev[j] = i
            hq.heappush(q, (d[j], j))
path = deque()
i = N-1
while prev[i] != 0:
    path.append(prev[i])
    i = prev[i]
fncq = deque([0])
snkq = deque([N-1])
fnc = 1
snk = 1
visited = [False]*N
visited[0] = True
visited[N-1] = True
while path:
    v = path.pop()
    fncq.append(v)
    visited[v] = True
    fnc += 1
    if path:
        v = path.popleft()
        snkq.append(v)
        visited[v] = True
        snk += 1
po = [fncq, snkq]
while fncq or snkq:
    for i in range(2):
        q = po[i]
        if q:
            v = q.popleft()
            for w,_ in edges[v]:
                if not visited[w]:
                    visited[w] = True
                    q.append(w)
                    if i == 0:
                        fnc += 1
                    else:
                        snk += 1
print("Fennec" if fnc > snk else "Snuke")
Buggy python submission (verdict: Time Limit Exceeded):
ls = []
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        ls = [a[i]]+ls
    else:
        ls.append(a[i])
if n%2 == 0:
    print(*reversed(ls))
else:
    print(*ls)

Fixed submission:
from collections import deque
ls = deque()
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    if i%2==0:
        ls.appendleft(a[i])
    else:
        ls.append(a[i])
if n%2 == 0:
    print(*reversed(ls))
else:
    print(*ls)
Buggy python submission (verdict: Runtime Error):
S = input()
def trans(s,i):
    if s == "":
        return "YES"
    if i == 0:
        t = s[:5]
        if t == "dream":
            return trans(s[5:],1)
        elif t == "erase":
            return trans(s[5:],2)
        else:
            return "NO"
    elif i == 1:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:2] == "er":
            return trans(s[2:],3)
        else:
            return "NO"
    elif i == 2:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:5] == "erase":
            return trans(s[5:],2)
        elif s[:1] == "r":
            return trans(s[1:],0)
        else:
            return "NO"
    elif i == 3:
        if s[:5] == "dream":
            return trans(s[5:],1)
        elif s[:3] == "ase":
            return trans(s[3:],2)
        elif s[:5] == "erase":
            return trans(s[5:],2)
        else:
            return "NO"
    
print(trans(S,0))

Fixed submission:
s = input()
i = 0
while True:
    if s == "":
        print("YES")
        exit(0)
    if i == 0:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        else:
            break
    elif i == 1:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:2] == "er":
            s = s[2:]
            i = 3
        else:
            break
    elif i == 2:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        elif s[:1] == "r":
            s = s[1:]
            i = 0
        else:
            break
    elif i == 3:
        if s[:5] == "dream":
            s = s[5:]
            i = 1
        elif s[:3] == "ase":
            s = s[3:]
            i = 2
        elif s[:5] == "erase":
            s = s[5:]
            i = 2
        else:
            break
print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d=map(int,input().split())
if x==0:
    if d%2==0:
        print(0)
    else:
        print(d)
else:
    cou=0
    ok=True
    if x>0:
        while x>0:
            cou+=1
            x-=d
            if cou==k:
                ans=x
                ok=False
                break
        xx=x+d
        if ok:
            if cou%2==0 and k%2==0:
                ans=x
            elif cou%2==0 and k%2==1:
                ans=xx
            elif cou%2==1 and k%2==0:
                ans=xx
            else:
                ans=x
    
    if x<0:
        while x<0:
            cou+=1
            x+=d
            if cou==k:
                ans=x
                ok=False
                break
        xx=x-d
        if ok:
            if cou%2==0 and k%2==0:
                ans=x
            elif cou%2==0 and k%2==1:
                ans=xx
            elif cou%2==1 and k%2==0:
                ans=xx
            else:
                ans=x
    print(abs(ans))

Fixed submission:
x,k,d=map(int,input().split())
if x==0:
    if d%2==0:
        print(0)
    else:
        print(d)
else:
    cou=0
    ok=True
    if x>0:
        xx=x
        while x>0:
            if xx-k*d>0:
                ans=x-k*d
                ok=False
                break
            cou+=1
            x-=d
            
        xx=x+d
        if ok:
            if cou%2==0 and k%2==0:
                ans=x
            elif cou%2==0 and k%2==1:
                ans=xx
            elif cou%2==1 and k%2==0:
                ans=xx
            else:
                ans=x
    
    if x<0:
        xx=x
        while x<0:
            if xx+k*d<0:
                ans=xx+k*d
                ok=False
                break
            cou+=1
            x+=d
            
        xx=x-d
        if ok:
            if cou%2==0 and k%2==0:
                ans=x
            elif cou%2==0 and k%2==1:
                ans=xx
            elif cou%2==1 and k%2==0:
                ans=xx
            else:
                ans=x
    print(abs(ans))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
ans=[a[0]]
ap=a[0]
for i in range(n-1):
    ap*=a[i+1]
    if i>=k-1:
        ans.append(ap/ans[i-k+1])
    else:
        ans.append(ap)
    

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

Fixed submission:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
    

for i in range(n-k):
    if a[i]>=a[i+k]:
        print("No")
    else:
        print("Yes")

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
ans=[a[0]]
ap=a[0]
for i in range(n-1):
    ap*=a[i+1]
    if i>=k-1:
        ans.append(ap/ans[i-k+1])
    else:
        ans.append(ap)
    
com=ans[k-1]

for i in range(n-k):
    if ans[i+k-1]>=ans[i+k]:
        print("No")
    else:
        print("Yes")
    com=ans[i+k]/ans[i]

Fixed submission:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
    

for i in range(n-k):
    if a[i]>=a[i+k]:
        print("No")
    else:
        print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
ans=[a[0]]

for i in range(n-1):
    ans.append(ans[-1]*a[i+1])
    
com=ans[k-1]
for i in range(n-k):
    if com>=ans[i+k]/ans[i]:
        print("No")
    else:
        print("Yes")
    com=ans[i+k]/ans[i]

Fixed submission:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
    

for i in range(n-k):
    if a[i]>=a[i+k]:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
(n,m,k),*A,=[list(map(int,i.split())) for i in open(0)]
a=A[0]
b=A[1]

time=0
ans=0
anss=[]
i=0
def dfs(time,ans,a,b):
    if time>k:
        anss.append(ans-1)
    elif time==k:
        anss.append(ans)
    else:
        if len(a)>0:
            dfs(time+a[0],ans+1,a[1:],b)
        if len(b)>0:
            dfs(time+b[0],ans+1,a,b[1:])
        if len(a)==0 and len(b)==0:
            anss.append(ans)
dfs(0,0,a,b)
print(max(anss))

Fixed submission:
(n,m,k),*A,=[list(map(int,i.split())) for i in open(0)]
a=A[0]
b=A[1]

aa=[0]
bb=[0]
for i in range(n):
    aa.append(aa[i]+a[i])
for i in range(m):
    bb.append(bb[i]+b[i])

ans=0

for i in range(n+1):
    if aa[i]>k:
        break
    while bb[m]>k-aa[i]:
        m-=1
    ans=max(ans,m+i)
        
print(ans)

Buggy python submission (verdict: Runtime Error):
(n,m,k),*A,=[list(map(int,i.split())) for i in open(0)]
a=A[0]
b=A[1]

time=0
ans=0
anss=[]
i=0
def dfs(time,ans,a,b):
    if time>k:
        anss.append(ans-1)
    elif time==k:
        anss.append(ans)
    else:
        if len(a)>0:
            dfs(time+a[0],ans+1,a[1:],b)
        if len(b)>0:
            dfs(time+b[0],ans+1,a,b[1:])
        if len(a)==0 and len(b)==0:
            anss.append(ans)
dfs(0,0,a,b)
print(max(anss))

Fixed submission:
(n,m,k),*A,=[list(map(int,i.split())) for i in open(0)]
a=A[0]
b=A[1]

aa=[0]
bb=[0]
for i in range(n):
    aa.append(aa[i]+a[i])
for i in range(m):
    bb.append(bb[i]+b[i])

ans=0

for i in range(n+1):
    if aa[i]>k:
        break
    while bb[m]>k-aa[i]:
        m-=1
    ans=max(ans,m+i)
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]
aa=[]
for i in range(n):
    ans=0
    for j in a:
        if j!=a[i]:
            ans^=j
    aa.append(ans)
    ans=0
print(" ".join(map(str,aa)))

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
aa=[]
ans=0
for i in a:
    ans^=i
anss=int(ans)
for i in range(n):
    anss^=a[i]
    aa.append(anss)
    anss=int(ans)
print(" ".join(map(str,aa)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
for i in range(n):
    ans=0
    for j in a:
        if j!=a[i]:
            ans^=j
    aa.append(a)
print("".join(aa))

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
aa=[]
ans=0
for i in a:
    ans^=i
anss=int(ans)
for i in range(n):
    anss^=a[i]
    aa.append(anss)
    anss=int(ans)
print(" ".join(map(str,aa)))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lis=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    lis[a].append(b)
    lis[b].append(a)
ans=[0 for i in range(n+1)]
i=1
ii=lis[i]
for oo in ii:
  ans[oo]=1
  lis[oo].clear()
while i<=n:
    for k in ii:
        for j in lis:
            if ii!=j:
                if k in j:
                    ans[lis.index(j)]=k
                    j.clear()
    i+=1
print("Yes")
for i in range(2,len(ans)):
  print(ans[i])

Fixed submission:
n,m=map(int,input().split())
lis=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    lis[a-1].append(b-1)
    lis[b-1].append(a-1)

ans=[-1]*n
ans[0] = 0
from collections import deque
q = deque([0])
while q:
    a=q.popleft()
    for i in lis[a]:
        if ans[i]==-1:
            ans[i]=a
            q.append(i)
print("Yes")
for i in range(1,len(ans)):
    print(ans[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
b=[]
for i in range(n):
    a=input()
    if a not in b:
        b.append(a)
print(len(b))

Fixed submission:
n=int(input())
b={}
for i in range(n):
    a=input()
    b[a]=1
print(len(b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]

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

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b={i:0 for i in range(1,n+1)}

for i in a:
    b[i]+=1

for i in b.values():
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(i) for i in input().split()]

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

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b={i:0 for i in range(1,n+1)}

for i in a:
    b[i]+=1

for i in b.values():
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c=map(int,input().split())
d=0
e=0
ok=False
while True:
    for i in range(b):
        if d>=a:
            ok=True
            break
        d+=1
        e+=1
    if ok:
        break
    for i in range(c):
        if d>=a:
            ok=True
            break
        d+=1
    if ok:
        break
print(e)

Fixed submission:
a,b,c=map(int,input().split())
d=0
e=0
ok=False

total=int(a/(b+c))
sa=a-(b+c)*total
if total==0:
    if a>=b:
        print(b)
    else:
        print(a)
else:
    if sa>=b:
        print(b+b*total)
    else:
        print(sa+b*total)