Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    """
    書き足した辺は，子孫に対してのものなのでいわゆるショートかっと．
    後から同じ頂点にたどり着いた場合，そちらを優先する？
    """
    
    mod=10**9+7
    N,M=MI()
    fro=[[]for _ in range(N)]
    to=[[]for _ in range(N)]
    
    for _ in range(N+M-1):
        a,b=MI()
        a-=1
        b-=1
        fro[b].append(a)
        to[a].append(b)
        
    root=0
    for i in range(N):
        if len(fro[i])==0:
            root=i
            break
        
    P=[-1]*N
    
    
    import queue
    q=queue.Queue()
    q.put(root)
    
    while not q.empty():
        v=q.get()
        for nv in to[v]:
            q.put(nv)
            P[nv]=v
                
    for i in range(N):
        print(P[i]+1)
    
        

main()


Fixed submission:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    """
    書き足した辺は，子孫に対してのものなのでいわゆるショートかっと．
    後から同じ頂点にたどり着いた場合，そちらを優先する？

    """
    
    mod=10**9+7
    N,M=MI()
    fro=[[]for _ in range(N)]
    to=[[]for _ in range(N)]
    
    for _ in range(N+M-1):
        a,b=MI()
        a-=1
        b-=1
        fro[b].append(a)
        to[a].append(b)
        
    root=0
    target=[0]*N
    for i in range(N):
        target[i]=len(fro[i])
        if target[i]==0:
            root=i
        
    P=[-1]*N
    
    #何回通ったかカウント，これがtargetと一致した場合だけ先に進む（最後の一個だけを通すようにする）
    count=[0]*N
    
    import queue
    q=queue.Queue()
    q.put(root)
    
    while not q.empty():
        v=q.get()
        for nv in to[v]:
            count[nv]+=1
            if count[nv]==target[nv]:
                q.put(nv)
                P[nv]=v
                
    for i in range(N):
        print(P[i]+1)
    
        

main()
Buggy python submission (verdict: Time Limit Exceeded):
#ひとまず長さだけ持つ，後から表を後ろ向きに見て復元を試みる

s=input()
t=input()

ls=len(s)
lt=len(t)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列の長さ
dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
i=ls
j=lt
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        i-=1
        j-=1
        ans+=s[i]

print(ans[::-1])

Fixed submission:
#ひとまず長さだけ持つ，後から表を後ろ向きに見て復元を試みる

s=input()
t=input()

ls=len(s)
lt=len(t)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列の長さ
dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
i=ls
j=lt
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        i-=1
        j-=1
        ans+=s[i]
        


print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
#計算量的にはきつそうだけど，dp[i][j]でやる？

s=input()
t=input()

ls=len(s)
lt=len(t)

add=ls-lt
if add>0:
    t+="T"*add
else:
    s+="S"*(-1*add)
N=len(s)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列
dp=[[""]*(N+1) for _ in range(N+1)]

temp=["",""]

for i in range(N):
    for j in range(N):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+s[i]
            L=len(dp[i+1][j+1])
        else:
            temp[0]=dp[i+1][j]
            temp[1]=dp[i][j+1]
            if len(temp[0])>len(temp[1]):
                dp[i+1][j+1]=temp[0]
            else:
                dp[i+1][j+1]=temp[1]

                    
print(dp[-1][-1])

Fixed submission:
#ひとまず長さだけ持つ，後から表を後ろ向きに見て復元を試みる

s=input()
t=input()

ls=len(s)
lt=len(t)
    
    
#sのi文字目とtのj文字目までで取れる最長部分列の長さ
dp=[[0]*(lt+1) for _ in range(ls+1)]

for i in range(ls):
    for j in range(lt):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

ans=""
i=ls
j=lt
while(i>0 and j>0):
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        i-=1
        j-=1
        ans+=s[i]
        


print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)

N=int(input())
A=list(map(int,input().split()))
abc=[0,0,0]#1,2,3個の寿司が載っている皿の枚数
for i in A:
    abc[i-1]+=1

#1,2,3個の寿司が載っている皿の枚数がi,j,kから全てを取るのに必要な期待値
dp=[[[0]*(N+1) for _ in range(N+1)] for i in range(N+1)]

          
def rec(i,j,k):
    if dp[i][j][k]!=-0:
        return dp[i][j][k]
    if i==0 and j==0 and k==0:
        return 0
    x,y,z=0,0,0
    if i-1>=0:
        x=rec(i-1,j,k)*i
    if j-1>=0:
        y=rec(i+1,j-1,k)*j
    if k-1>=0:
        z=rec(i,j+1,k-1)*k
    dp[i][j][k]=((x+y+z)+N)/(i+j+k)
    return dp[i][j][k]
            
print(rec(abc[0],abc[1],abc[2]))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
abc=[0,0,0]#1,2,3個の寿司が載っている皿の枚数
for i in A:
    abc[i-1]+=1
    
total=sum(A)

#1,2,3個の寿司が載っている皿の枚数がi,j,kから全てを取るのに必要な期待値
dp=[[[0.0]*(N+1) for _ in range(N+1)] for i in range(N+1)]



for k in range(abc[2]+1):#3枚の皿は初期枚数から増えない
    for j in range(abc[2]+abc[1]+1-k):#2枚の皿の枚数は，3枚の皿が減った枚数に依存
        for i in range(sum(abc)+1-j-k):
            if i==0 and j==0 and k==0:
                continue
            if i-1>=0:
                dp[i][j][k]+=dp[i-1][j][k]*i
            if j-1>=0:
                dp[i][j][k]+=dp[i+1][j-1][k]*j
            if k-1>=0:
                dp[i][j][k]+=dp[i][j+1][k-1]*k
            dp[i][j][k]+=N
            dp[i][j][k]/=(i+j+k)

print(dp[abc[0]][abc[1]][abc[2]])

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

N=int(input())
A=list(map(int,input().split()))
abc=[0,0,0]#1,2,3個の寿司が載っている皿の枚数
for i in A:
    abc[i-1]+=1

#1,2,3個の寿司が載っている皿の枚数がi,j,kから全てを取るのに必要な期待値
dp=[[[0]*(N+1) for _ in range(N+1)] for i in range(N+1)]

          
def rec(i,j,k):
    if dp[i][j][k]!=-0:
        return dp[i][j][k]
    if i==0 and j==0 and k==0:
        return 0
    x,y,z=0,0,0
    if i-1>=0:
        x=rec(i-1,j,k)*i
    if j-1>=0:
        y=rec(i+1,j-1,k)*j
    if k-1>=0:
        z=rec(i,j+1,k-1)*k
    dp[i][j][k]=((x+y+z)+N)/(i+j+k)
    return dp[i][j][k]
            
print(rec(abc[0],abc[1],abc[2]))







Fixed submission:
N=int(input())
A=list(map(int,input().split()))
abc=[0,0,0]#1,2,3個の寿司が載っている皿の枚数
for i in A:
    abc[i-1]+=1
    
total=sum(A)

#1,2,3個の寿司が載っている皿の枚数がi,j,kから全てを取るのに必要な期待値
dp=[[[0.0]*(N+1) for _ in range(N+1)] for i in range(N+1)]



for k in range(abc[2]+1):#3枚の皿は初期枚数から増えない
    for j in range(abc[2]+abc[1]+1-k):#2枚の皿の枚数は，3枚の皿が減った枚数に依存
        for i in range(sum(abc)+1-j-k):
            if i==0 and j==0 and k==0:
                continue
            if i-1>=0:
                dp[i][j][k]+=dp[i-1][j][k]*i
            if j-1>=0:
                dp[i][j][k]+=dp[i+1][j-1][k]*j
            if k-1>=0:
                dp[i][j][k]+=dp[i][j+1][k-1]*k
            dp[i][j][k]+=N
            dp[i][j][k]/=(i+j+k)

print(dp[abc[0]][abc[1]][abc[2]])
Buggy python submission (verdict: Time Limit Exceeded):
#L
import sys
sys.setrecursionlimit(10**5)

N=int(input())
a=list(map(int,input().split()))

S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+a[i]

dp=[[0]*(N+1) for _ in range(N+1)]#[l,r)の範囲が残っているときに取れる最大値

def rep(l,r):
    if l==r:
        return 0
    if dp[l][r]!=0:
        return dp[l][r]
    else:
        x=a[l]+(S[r]-S[l+1] - rep(l+1,r))
        y=a[r-1]+(S[r-1]-S[l] - rep(l,r-1))
        dp[l][r]=max(x,y)
        return dp[l][r]
    
    
rep(0,N)
print(2*dp[0][N] - S[-1] )








Fixed submission:
#L

N=int(input())
a=list(map(int,input().split()))

S=[0]*(N+1)
for i in range(N):
    S[i+1]=S[i]+a[i]

dp=[[0]*(N+1) for _ in range(N+1)]#[l,r)の範囲が残っているときに取れる最大値

for i in range(1,N+1):#r-lの値
    for j in range(N):#lの値
        r=j+i
        if r>N:
            break
        l=j
        x=a[l]+(S[r]-S[l+1]) - dp[l+1][r]
        y=a[r-1]+(S[r-1]-S[l]) - dp[l][r-1]
        dp[l][r]=max(x,y)

print(2*dp[0][N] - S[-1] )
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
1,2,3
    3,4,5,6
          6,7,8,9
                ...
のように，かぶらないものが2個ずつになるように伸ばす．
のちに1,4,7,...,Nと2,5,8,...,Nを作ればだいたいいける．
1,2,3と6,7,8,9でかぶるものがないので大きいところのあまりから適当に持ってきて両方に追加する

"""

def main():
    mod=10**9+7
    N=I()

    if N==1:
        print("Yes")
        print(2)
        print(1,1)
        print(1,1)
        exit()
    elif N==3:
        print("Yse")
        print(3)
        print(2,1,2)
        print(2,3,1)
        print(2,2,3)
        exit()
        
    now=0
    temp=0
    for i in range(N):
        now+=i
        if now==N:
            cnt=i
            break
        elif now>N:
            print("No")
            exit()
            
    k=cnt+1
    cnt-=1
    S=[[]for _ in range(k)]
    S[0]=[1,2,3]
    now=3
    for i in range(1,cnt-1):
        for j in range(4):
            S[i].append(now+j)
        now+=3
    
    for j in range(3):
        S[cnt-1].append(now+j)
    now+=3
        
    for i in range(cnt):
        for j in range(i+2,cnt):
            S[i].append(now)
            S[j].append(now)
            now+=1
            
    for j in range(2):
        for i in range(cnt):
            S[-1-j].append(j+1+i*3)
            
    S[-1].append(N)
    S[-2].append(N)
    
    print(k)
    for i in range(k):
        print(len(S[i]),(' '.join(map(str, S[i]))))
        
    
        
        
        
        
        

main()


Fixed submission:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
k組ある，
ある組から見て，残りの(k-1)組と被りが1つずつあるから要素数はk-1

"""

def main():
    mod=10**9+7
    N=I()

    k=0
    for i in range(N+5):
        ii=i*(i-1)
        if ii==2*N:
            k=i
            break
    if k==0:
        print("No")
        exit()
    
    ans=[[]for _ in range(k)]
    now=1#配る数字
    import itertools
    
    for ite in itertools.combinations(range(k),2):
        i=ite[0]
        j=ite[1]
        ans[i].append(now)
        ans[j].append(now)
        now+=1
        
    print("Yes")
    print(k)
    for i in range(k):
        print(len(ans[i]),' '.join(map(str, ans[i])))
        
        
            
            
            
 
        

main()
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=int(input())
B=int(input())

if N==1:
    print("Hello World")
else:
    print(A+B)

Fixed submission:
N=int(input())

if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)
Buggy python submission (verdict: Runtime Error):
N=int(input())
x=[0]*N
y=[0]*N
h=[0]*N

for i in range(N):
    x[i],y[i],h[i]=map(int,input().split())

for tx in range(101):
    for ty in range(101):
        th=h[0]+abs(tx-x[0])+abs(ty-y[0])
        flag=1
        for i in range(N):
            nh=h[i]+abs(tx-x[i])+abs(ty-y[i])
            if nh!=th:
                flag=0
                break
        if flag==1:
            ans=[tx,ty,th]
            break

print(' '.join(map(str, ans)))     

Fixed submission:
N=int(input())
x=[0]*N
y=[0]*N
h=[0]*N

ti=0

for i in range(N):
    x[i],y[i],h[i]=map(int,input().split())
    if h[i]!=0:
        ti=i



flag=0
for tx in range(101):
    if flag==1:
        break
    for ty in range(101):
        th=h[ti]+abs(tx-x[ti])+abs(ty-y[ti])
        flag=1
        for i in range(N):
            nh=h[i]+abs(tx-x[i])+abs(ty-y[i])
            if (h[i]!=0 and nh!=th) or (h[i]==0 and nh<th ):
                flag=0
                break
        if flag==1:
            ans=[tx,ty,th]
            break

print(' '.join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

ans=0
for i in range(1,M//N+1):
    if M%i==0:
        ans=max(ans,i)
        
print(ans)

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

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)

    # divisors.sort()
    return divisors

ans=0
table=make_divisors(M)
table.sort()

for i in table:
    if i<=M//N:
        ans=i
        
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))

count=[0]*M#あまりが0~M-1
S=[0]*(N+1)

for i in range(N):
    S[i+1]=S[i]+A[i]
    S[i+1]%=M
    
ans=0
for i in range(N+1):
    ans+=count[S[i]]
    count[S[i]]+=1
    
print(ans)
    

Fixed submission:
from collections import defaultdict

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

dd = defaultdict(int)#あまりをカウント
S=[0]*(N+1)

for i in range(N):
    S[i+1]=S[i]+A[i]
    S[i+1]%=M
    
ans=0
for i in range(N+1):
    ans+=dd[S[i]]
    dd[S[i]]+=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
ソースコード
from fractions import gcd
n=int(input())
g=gcd(2,n)
print(2*n//g)

Fixed submission:
from fractions import gcd

n=int(input())
g=gcd(2,n)
print(2*n//g)
Buggy python submission (verdict: Runtime Error):
import itertools

N,C=map(int,input().split())
D=[[] for _ in range(C)]
c=[[] for _ in range(N)]

for i in range(C):
    D[i]=list(map(int,input().split()))
    
for i in range(N):
    c[i]=list(map(int,input().split()))
    
hist=[[0]*3 for i in range(C)]#hist[i][j]は余りiのマスにj色のマスがいくつあるか
    
    
for i in range(N):
    for j in range(N):
        rem=(i+j+2)%3
        hist[rem][c[i][j]-1]+=1
    
ans=10**10
for cset in itertools.permutations(range(C), 3):
    temp=0
    for i in range(3):
        for j in range(C):
            temp+=hist[i][j]*D[j][cset[i]]
    ans=min(ans,temp)
    
print(ans)
    

Fixed submission:
import itertools

N,C=map(int,input().split())
D=[[] for _ in range(C)]
c=[[] for _ in range(N)]

for i in range(C):
    D[i]=list(map(int,input().split()))
    
for i in range(N):
    c[i]=list(map(int,input().split()))
    
hist=[[0]*C for i in range(3)]#hist[i][j]は余りiのマスにj色のマスがいくつあるか
    
    
for i in range(N):
    for j in range(N):
        rem=(i+j+2)%3
        hist[rem][c[i][j]-1]+=1
    
ans=10**10
for cset in itertools.permutations(range(C), 3):
    temp=0
    for i in range(3):
        for j in range(C):
            temp+=hist[i][j]*D[j][cset[i]]
    ans=min(ans,temp)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W,D=map(int,input().split())
A=[[] for _ in range(H)]

for i in range(H):
    A[i]=list(map(int,input().split()))
    
index=[[-1,-1] for _ in range(H*W+1)]

for i in range(H):
    for j in range(W):
        index[A[i][j]]=[i,j]
   
        
    
S=[[0]*(H*W//D) for _ in range(D+1)]
for start in range(1,D+1):
    for j in range(H*W//D-1):
        prev=start+j*D
        nxt=prev+D
        diff=abs(index[nxt][0] - index[prev][0]) + abs(index[nxt][1] - index[prev][1])
        S[start][j+1]=S[start][j]+diff
        
Q=int(input())
        
for i in range(Q):
    L,R=map(int,input().split())
    start=L%D
    if start==0:
        start=D
    print(S[start][(R-start)//D] - S[start][(L-start)//D])
    

Fixed submission:
H,W,D=map(int,input().split())
A=[[] for _ in range(H)]

for i in range(H):
    A[i]=list(map(int,input().split()))
    
index=[[-1,-1] for _ in range(H*W+1)]

for i in range(H):
    for j in range(W):
        index[A[i][j]]=[i,j]
        
    
S=[[0]*(H*W//D+1) for _ in range(D+1)]
for start in range(1,D+1):
    for j in range(H*W//D):
        prev=start+j*D
        nxt=prev+D
        if nxt>H*W:
            break
        diff=abs(index[nxt][0] - index[prev][0]) + abs(index[nxt][1] - index[prev][1])
        S[start][j+1]=S[start][j]+diff
        
Q=int(input())
        
for i in range(Q):
    L,R=map(int,input().split())
    start=L%D
    if start==0:
        start=D
    print(S[start][(R-start)//D] - S[start][(L-start)//D])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    p=LI()
    ans=0
    for i in range(N):
        if p[i]==i+1:
            p[i],p[i+1]=p[i+1],p[i]
            ans+=1
            
    print(ans)

main()


Fixed submission:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    p=LI()
    ans=0
    for i in range(N):
        if p[i]==i+1:
            if i!=N-1:
                p[i],p[i+1]=p[i+1],p[i]
                ans+=1
            else:
                p[i],p[i-1]=p[i-1],p[i]
                ans+=1
            
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    from math import gcd
    N=I()
    ans=1
    for i in range(N):
        T=I()
        ans=(ans*T)//(gcd(ans,T))
        
        
    print(ans)

main()


Fixed submission:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from fractions import gcd

def main():
    mod=10**9+7
    N=I()
    ans=1
    for i in range(N):
        t=I()
        ans=(ans*t)//gcd(ans,t)
        
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import queue

def main():
    mod=10**9+7
    N=I()
    adj=[[] for _ in range(N)]
    for i in range(N-1):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
    bit=[-1]*N#未確認,F,S    
    bit[0]=0
    bit[-1]=1
    pL=[0]*N
    dS=0
    
    q=queue.Queue()
    q.put([0,0,0])#v.pare,depth
    
    #深さを調べる
    while not q.empty():
        v,p,d=q.get()
        pL[v]=p
        if v==N-1:
            dS=d
            break
        for i in range(len(adj[v])):
            nv=adj[v][i]
            if nv!=p:
                q.put((nv,v,d+1))
    
    #主要なところを塗る            
    v=N-1            
    for _ in range((dS-1)//2):
        v=pL[v]
        bit[v]=1
        
        
    q.put([0,0])#v.pare
    while not q.empty():
        v,p=q.get()
        if bit[v]==-1:
            bit[v]=bit[p]

        for i in range(len(adj[v])):
            nv=adj[v][i]
            if nv!=p:
                q.put((nv,v))
        
        
                    
    s=sum(bit)#sunukeが塗れる
    if s>=N-s:
        print("Snuke")
    else:
        print("Fennec")
     
        
    
    

main()


Fixed submission:
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
import queue

def main():
    mod=10**9+7
    N=I()
    adj=[[] for _ in range(N)]
    for i in range(N-1):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
    bit=[-1]*N#未確認,F,S    
    bit[0]=0
    bit[-1]=1
    pL=[0]*N
    dS=0
    
    q=queue.Queue()
    q.put((0,0,0))#v.pare,depth
    
    #深さを調べる
    while not q.empty():
        v,p,d=q.get()
        pL[v]=p
        if v==N-1:
            dS=d
            break
        for i in range(len(adj[v])):
            nv=adj[v][i]
            if nv!=p:
                q.put((nv,v,d+1))
    
    #主要なところを塗る            
    v=N-1            
    for _ in range((dS-1)//2):
        v=pL[v]
        bit[v]=1
        
    q2=queue.Queue()
    q2.put((0,0))#v.pare
    while not q2.empty():
        v,p=q2.get()
        if bit[v]==-1:
            bit[v]=bit[p]

        for i in range(len(adj[v])):
            nv=adj[v][i]
            if nv!=p:
                q2.put((nv,v))
        
        
                    
    s=sum(bit)#sunukeが塗れる
    if s>=N-s:
        print("Snuke")
    else:
        print("Fennec")
     
        
    
    

main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    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

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, N + 5):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
        
    loc=[-1]*N
    mu=[-1,-1]
    for i in range(N+1):
        if loc[a[i]-1]==-1:
            loc[a[i]-1]=i
        else:
            mu[0]=loc[a[i]-1]
            mu[1]=i
    N1=mu[0]
    N2=N-mu[1]
    for i in range(N+1):
        if i==0:
            print(N)
        else:
            temp=0
            for j in range(i+1):
                temp+=cmb(N1,j,mod)*cmb(N2,i-j,mod)
                temp%=mod
                
            print((cmb(N+1,i+1,mod)-temp)%mod)
        
            
    
            
            
        


main()


Fixed submission:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    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

    fact=[1,1]
    factinv=[1,1]
    inv=[0,1]
    
    for i in range(2, N + 5):
        fact.append((fact[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod // i)) % mod)
        factinv.append((factinv[-1] * inv[-1]) % mod)
        
    loc=[-1]*N
    mu=[-1,-1]
    for i in range(N+1):
        if loc[a[i]-1]==-1:
            loc[a[i]-1]=i
        else:
            mu[0]=loc[a[i]-1]
            mu[1]=i
    N1=mu[0]
    N2=N-mu[1]
    
    for i in range(N+1):
        if i==0:
            print(N)
        else:   
            print((cmb(N+1,i+1,mod)-cmb(N1+N2,i,mod))%mod)
        
            
    
            
            
        


main()