Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    big_array = []
    for i in range(N):
        big_array += [a[i]]*b[i]
    big_array.sort()
    print(big_array[K-1])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, K: int, a: "List[int]", b: "List[int]"):
    ab = list(zip(a,b))
    ab.sort(key=lambda x: x[0])
    sumb =0
    123334
    for i in range(N):
        sumb+=ab[i][1]
        if sumb>=K:
            print(ab[i][0])
            return 
        
    

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, K, a, b)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if not (A%2==0 and B%2==0 and C%2==0):
        print(0)
        return

    if A==B==C:
        print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+y
        C = y+z
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if A==B==C:
        if A%2==1 or B%2==1 or C%2==1:
            print(0)
        else:
            print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+z
        C = y+x
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if not(A%2==0 and B%2==0 and C%2==0):
        print(0)
        return
        
    if A==B==C:
        print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+y
        C = y+z
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    A,B,C = MAP()
    if A==B==C:
        if A%2==1 or B%2==1 or C%2==1:
            print(0)
        else:
            print(-1)
        return
    answer = 0
    
    while A%2==0 and B%2==0 and C%2==0:
        x = A//2
        y = B//2
        z = C//2
        A = y+z
        B = x+z
        C = y+x
        answer += 1
    print(answer)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    answer=0
    for i in range(K+1):
        for j in range(K+1):
            for k in range(K+1):
                if i+j+k == S:
                    answer+=1
    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(K: int, S: int):
    answer=0
    for i in range(K+1):
        for j in range(K+1):

            if 0<=S-i-j<=K:
                answer+=1
                    
    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    solve(K, S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    while len(S)>4:
        if S[:11]=="dreameraser":
            S=S[11:]
        elif S[:10] == "dreamerase":
            S= S[10:]
        elif S[:6]=="eraser":
            S= S[6:]
        elif S[:5] == "erase" or S[:5]== "dream":
            S=S[5:]
        elif S[:7] == "dreamer":
            S=S[7:]
        else:
            print(NO)
        
    
    if len(S) == 0:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()



Fixed submission:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    S = S[::-1]
    while len(S)>4:
        if S[:6]=="resare":
            S= S[6:]
        elif S[:5] == "esare" or S[:5]== "maerd":
            S=S[5:]
        elif S[:7] == "remaerd":
            S=S[7:]
        else:
            print(NO)
            return 
        
    
    if len(S) == 0:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    while len(S)>4:
        if S[:6] == "eraser":
            S= S[6:]
        elif S[:5] == "erase" or S[:5]== "dream":
            S=S[5:]
        elif S[:7] == "dreamer":
            S=S[7:]
        else:
            print(NO)
        
    
    if len(S) == 0:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str

def solve(S: str):
    S = S[::-1]
    while len(S)>4:
        if S[:6]=="resare":
            S= S[6:]
        elif S[:5] == "esare" or S[:5]== "maerd":
            S=S[5:]
        elif S[:7] == "remaerd":
            S=S[7:]
        else:
            print(NO)
            return 
        
    
    if len(S) == 0:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, T: "List[int]", A: "List[int]"):
    current = [T[0],A[0]]
    for i in range(1,N):
        t = T[i]
        a = A[i]
        while current[0]>t or current[1]>a:
            t+=T[i]
            a+=A[i]
        
        current[0]=t
        current[1]=a
    print(sum(current))

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int()] * (N)  # type: "List[int]"
    A = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        T[i] = int(next(tokens))
        A[i] = int(next(tokens))
    solve(N, T, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, T: "List[int]", A: "List[int]"):
    current = [T[0],A[0]]
    for i in range(1,N):
        t = T[i]
        a = A[i]
        if current[0]>t or current[1]>a:
            multi = max((current[0]+t-1)//t,(current[1]+a-1)//a)
            t = t*multi
            a = a*multi
        
        current[0]=t
        current[1]=a

    print(sum(current))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    T = [int()] * (N)  # type: "List[int]"
    A = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        T[i] = int(next(tokens))
        A[i] = int(next(tokens))
    solve(N, T, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

def solve(N: int, A: int, x: "List[int]"):
    ## dp[i][j][k] = i番目までのカードからjマイ選んで合計kにする選び方の総数
    dp = [[[0]*2500 for _ in range(N+1)] for _ in range(N+1)]

    for i in range(N):
        dp[i][0][0] = 1

    for i in range(N):
        for j in range(N):
            for k in range(2500):
                if k-x[i] >= 0:
                    dp[i+1][j+1][k] = dp[i][j][k-x[i]]+dp[i][j+1][k]
                else:
                    dp[i+1][j+1][k] = dp[i][j+1][k]

    answer = 0
    for j in range(1,N+1):
        answer += dp[N][j][A*j]
    print(answer)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, x)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
# dp[j][t]=(y1,...,yj から 0 枚以上選んで yi の合計を t − 1250 にするような選び方の総数)

def solve(N: int, A: int, x: "List[int]"):
    x = [x[i]-A for i in range(N)]
    dp = [[0]*2500 for _ in range(N+1)]
    dp[0][1250] = 1

    for j in range(1,N+1):
        for t in range(2500):
            if t-x[j-1]>=0 and t-x[j-1]<2500:
                dp[j][t] = dp[j-1][t] + dp[j-1][t-x[j-1]]
            else:
                dp[j][t] = dp[j-1][t]
    print(dp[N][1250]-1)
    
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, x)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
T=[]
T=list(input())
values = np.array(T)
searchval = '?'
ii = np.where(values == searchval)[0]

if len(ii)>0:
    for k in ii:
        if k==0:
            if T[k+1]=='D':
                T[k]='P'
            else:
                T[k]='D'

        else:
            if T[k-1] == 'P':
                T[k] = 'D'
            else:
                T[k] = 'P'

newT=''.join(map(str,T))
print(newT)


Fixed submission:
import numpy as np
T=[]
T=list(input())
values = np.array(T)
searchval = '?'
ii = np.where(values == searchval)[0]

if len(ii)>0:
    for k in ii:
        if k==0:
            if len(T)>1:
                if T[k+1]=='D':
                    T[k]='P'
                else:
                    T[k]='D'
            else:
                T[k] = 'D'

        else:
            if T[k-1] == 'P':
                T[k] = 'D'
            else:
                if k+1<len(T):
                    if T[k+1] == 'D':
                        T[k] = 'P'
                    else:
                        T[k]='D'
                else:
                    T[k] = 'D'

newT=''.join(map(str,T))
print(newT)
Buggy python submission (verdict: Runtime Error):
k = int(input())
ans = k%2 == 0 ? (k/2)**2 : (k+1)/2 * ((k+1)/2 - 1)
print(ans)


Fixed submission:
k = int(input())
ans = (k/2)**2 if k%2==0 else (k+1)/2 * ((k+1)/2 -1)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
k = int(input())
ans = k%2 == 0 ? (k/2)**2 : (k//2)*(k//2 -1)
print(ans)

Fixed submission:
k = int(input())
ans = (k/2)**2 if k%2==0 else (k+1)/2 * ((k+1)/2 -1)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 & m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = cn_l[0]
        tmp = s
        tmp.pop(0)
        tmp.pop(cn)
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
else:
    print('WA')

Fixed submission:
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 and m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = int(cn_l[0])
        tmp = s
        tmp.pop(0)
        tmp.remove('C')
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')

Buggy python submission (verdict: Runtime Error):
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    for i, m in enumerate(s):
        if 1<i<l-1 & m=='C':
            cn = i
            c_cnt += 1
    if c_cnt == 1:
        tmp = s
        tmp.pop(0)
        tmp.pop(cn)
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
else:
    print('WA')



Fixed submission:
s = list(input())
l = len(s)
if s[0] == 'A':
    c_cnt = 0
    cn_l = []
    for i, m in enumerate(s):
        if 1<i<l-1 and m=='C':
            cn_l.append(i)
            c_cnt += 1
    if c_cnt == 1:
        cn = int(cn_l[0])
        tmp = s
        tmp.pop(0)
        tmp.remove('C')
        tmp_s = ''.join(tmp)
        if tmp_s == tmp_s.lower():
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')
Buggy python submission (verdict: Runtime Error):
n , k = map(int, input().split())
print(n//(k-1))

Fixed submission:
n = int(input())
l = list(str(n))
s = 0
for i in l:
    s += int(i)
if n>=s and n%s == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n , k = map(int, input().split())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif n%2 != 0 k%2 == 0 and (n-k)%(k-1) != 0:
  	print(n//(k-1) + 1)
else:
    print(n//(k-1))

Fixed submission:
n , k = map(int, input().split())
if k == 2:
    print(n-1)
elif k == n-1:
    print(2)
elif (n-k)%(k-1) == 0:
    print((n-k)//(k-1) +1)
else:
    print((n-k)//(k-1) + 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



Fixed submission:
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = input().split()
    if a[0] == "M":
        member[0] += 1
    elif a[1] == "A":
        member[1] += 1
    elif a[2] == "R":
        member[2] += 1
    elif a[3] == "C":
        member[3] += 1
    elif a[4] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(i+2, 5):
            ans += member[i]*member[j]*member[k]

print(ans)



Fixed submission:
N = int(input())
member = [0,0,0,0,0]
ans = 0
for _ in range(N):
    a = list(input())
    if a[0] == "M":
        member[0] += 1
    elif a[0] == "A":
        member[1] += 1
    elif a[0] == "R":
        member[2] += 1
    elif a[0] == "C":
        member[3] += 1
    elif a[0] == "H":
        member[4] += 1
 
for i in range(3):
    for j in range(i+1, 4):
        for k in range(j+1, 5):
            ans += member[i]*member[j]*member[k]

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
cards = map(int, input().split()).sort(reverse=True)
A, B = sum(cards[0::2]), sum(cards[1::2])
print(str(A-B))



Fixed submission:
N = int(input())
cards = sorted(map(int, input().split()), reverse=True)
A, B = sum(cards[0::2]), sum(cards[1::2])
print(str(A-B))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
# 全探索
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            tmp = i*500 + j*100 + k*50
            if tmp == x:
                ans += 1
print(ans)

Fixed submission:
n = int(input())
A = []
for _ in range(2):
    A.append(list(map(int, input().split())))
cand = []
for i in range(n):
    cand.append(sum(A[0][:i+1])+sum(A[1][i:]))
print(max(cand))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(n)
f = 0
for i in l:
  f += int(i)
if n%f == 0:
  print('Yes')
else:
  print('No')

Fixed submission:
n = int(input())
l = list(str(n))
f = 0
for i in l:
  f += int(i)
if n%f == 0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
num = input().split()
if num[0] == num[1] and num[1] == num[2]:
    print("Yes")
elif num[1] == num[2] and num[2] == num[3]:
    print("Yes")
else:
    print("No")

Fixed submission:
num = [int(x) for x in list(input())]

if num[0] == num[1] and num[1] == num[2]:
    print("Yes")
elif num[1] == num[2] and num[2] == num[3]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
R=int(input())
G=int(input())
P=2G-R
print(P)

Fixed submission:
R=int(input())
G=int(input())
P = 2*G-R
print(P)

Buggy python submission (verdict: Runtime Error):
R=int(input()), G=int(input())
P=2G-R
print(P)

Fixed submission:
R=int(input())
G=int(input())
P = 2*G-R
print(P)
Buggy python submission (verdict: Runtime Error):
a,b,c = int(input().split())
if a==b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)

Fixed submission:
a,b,c = map(int, input().split())
if a==b:
    print(c)
elif b==c:
    print(a)
else:
    print(b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import *
from itertools import *
h, w = map(int, input().split())
maze = [input() for _ in range(h)]
dest = [(1, 0), (-1, 0), (0, 1), (0, -1)]
score = 0

for sx, sy in product(range(w), range(h)):
  if maze[sy][sx] == '#':
    continue
  r = [[-1] * w for _ in range(h)]
  r[sy][sx] = 0
  queue = deque([(sx, sy)])
  while queue:
    x, y = queue.popleft()
    for dx, dy in dest:
      nx, ny = x + dx, y + dy
      if not (0 <= nx < w and 0 <= ny < h):
        continue
      if maze[ny][nx] == '#' and r[ny][nx] != -1:
        continue
      r[ny][nx] = r[y][x] + 1
      queue.append((nx, ny))
      score = max(score, r[ny][nx])
print(score)

Fixed submission:
from collections import *
from itertools import *
h, w = map(int, input().split())
maze = [input() for _ in range(h)]
dest = [(1, 0), (-1, 0), (0, 1), (0, -1)]
score = 0

for sx, sy in product(range(w), range(h)):
  if maze[sy][sx] == '#':
    continue
  r = [[-1] * w for _ in range(h)]
  r[sy][sx] = 0
  queue = deque([(sx, sy)])
  while queue:
    x, y = queue.popleft()
    for dx, dy in dest:
      nx, ny = x + dx, y + dy
      if not (0 <= nx < w and 0 <= ny < h):
        continue
      if maze[ny][nx] == '#' or r[ny][nx] != -1:
        continue
      r[ny][nx] = r[y][x] + 1
      queue.append((nx, ny))
      score = max(score, r[ny][nx])
print(score)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
p = []
for i in range(n):
  r, l = map(int, input().split())
  p.append((r, l))

p.sort()
mr = 0
c = 0
for l, r in p:
  if l >= mr:
    mr = r
    continue
  c += 1
  mr = min(mr, r)

print(c)

Fixed submission:
n, m = map(int, input().split())
p = []
for i in range(m):
  r, l = map(int, input().split())
  p.append((r, l))

p.sort()
mr = 0
c = 0
for l, r in p:
  if l >= mr:
    mr = r
    c += 1
    continue
  mr = min(mr, r)

print(c)
Buggy python submission (verdict: Runtime Error):
def search(node, searched, goal):
  if searched == goal:
    return 1
  v = 0
  for nei in edges[node]:
    if searched & (1 << nei):
      continue
    v += search(nei, searched | (1<<nei), goal)
    
  return v
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(n):
  a, b = map(lambda x: int(x) - 1, input().split())
  edges[a].append(b)
  edges[b].append(a)
print(search(0, 1, (1<<n) - 1))


Fixed submission:
def search(node, searched, goal):
  if searched == goal:
    return 1
  v = 0
  for nei in edges[node]:
    if searched & (1 << nei):
      continue
    v += search(nei, searched | (1<<nei), goal)
    
  return v

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for i in range(m):
  a, b = map(lambda x: int(x) - 1, input().split())
  edges[a].append(b)
  edges[b].append(a)
print(search(0, 1, (1<<n) - 1))