Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n-1,-1,-1):
    r[i]=gcd(r[i+1],a[i])
ans=l[-1]
for i in range(n):
    ans=max(ans,gcd(l[i],r[i+1]))
print(ans)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i+1]=gcd(l[i],a[i])
for i in range(n-1,-1,-1):
    r[i]=gcd(r[i+1],a[i])
ans=l[-1]
for i in range(n):
    ans=max(ans,gcd(l[i],r[i+1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, __import('sys')__.stdin.readline().split())
print(a * b)

Fixed submission:
x, y = map(int, input().split())
print(x * y)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
a, b = input().split()
a = int(a)
b = int(b)
print(a * b)

Fixed submission:
import sys
input = sys.stdin.readline
 
from decimal import Decimal
import math

a, b = map(Decimal, input().split())
print(math.floor(a * b))
Buggy python submission (verdict: Runtime Error):
n = int(input()[-1])
if n in [2, 4, 5, 7, 9]: print('hon')
else if n in [0, 1, 6, 8]: print('pon')
else: print('bon')

Fixed submission:
n = int(input()[-1])
if n in [2, 4, 5, 7, 9]: print('hon')
elif n in [0, 1, 6, 8]: print('pon')
else: print('bon')
Buggy python submission (verdict: Runtime Error):
print('safe' if int(input()) > int(input()) else 'unsafe')

Fixed submission:
s, w = map(int, input().split())
print('safe' if s > w else 'unsafe')
Buggy python submission (verdict: Runtime Error):
from math import pi
print(f'{2 * pi * r:.5f}')

Fixed submission:
from math import pi
print(f'{2 * pi * int(input()):.5f}')
Buggy python submission (verdict: Runtime Error):
s = input()
print('No' if if s[0] == s[1] and s[1] == s[2] else 'Yes')

Fixed submission:
s = input()
print('No' if s[0] == s[1] and s[1] == s[2] else 'Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

(n, k), s = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split()))
print(f'{max([sum(s[i:i+k]) for i in range(n - k + 1)]):.10f}')

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

(n, k), s, res, sm = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split())), 0, 0
for i in range(n):
	if i < k: sm += s[i]
	else: sm += s[i]; sm -= s[i-k]
	res = max(res, sm)
print(f'{res:.10f}')
# print(f'{max([sum(s[i:i+k]) for i in range(n - k + 1)]):.10f}')

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

(n, k), s = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split()))
print(f'{max([sum(s[i:i+k]) for i in range(n - k)]):.10f}')

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

(n, k), s, res, sm = map(int, input().split()), list(map(lambda x: (int(x) + 1) / 2, input().split())), 0, 0
for i in range(n):
	if i < k: sm += s[i]
	else: sm += s[i]; sm -= s[i-k]
	res = max(res, sm)
print(f'{res:.10f}')
# print(f'{max([sum(s[i:i+k]) for i in range(n - k + 1)]):.10f}')
Buggy python submission (verdict: Runtime Error):
3*(r**2)

Fixed submission:
r = int(input())
print(3*(r**2))

Buggy python submission (verdict: Runtime Error):
3(r**2)

Fixed submission:
r = int(input())
print(3*(r**2))

Buggy python submission (verdict: Runtime Error):
S = 3*(r**2)

Fixed submission:
r = int(input())
print(3*(r**2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
from functools import reduce
if __name__ == '__main__':
    n = int(input())
    a = []
    ans = 0
    for i in range(n):
        tmp = int(input())
        a.append(tmp)
        if tmp == 0:
            ans += math.floor(reduce(lambda x, y: x + y, a) // 2)
            a.clear()
    ans += math.floor(reduce(lambda x, y: x + y, a) // 2)
    print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import math
from functools import reduce
from operator import add
if __name__ == '__main__':
    n = int(input())
    a = [0]
    ans = 0
    for i in range(n):
        tmp = int(input())
        a.append(tmp)
        if tmp == 0:
            ans += math.floor(reduce(add, a) // 2)
            a.clear()
            a.append(0)
    ans += math.floor(reduce(add, a) // 2)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
l = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in l:
    if n <= i:
        r = i
        break
result = r - n
print(result)

Fixed submission:
n = int(input())
l = [1000,2000,3000,4000,5000,6000,7000,8000,9000,10000]
for i in l:
    if n <= i:
        r = i
        break
result = r - n
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in a:
    ans*=i
if ans>1000000000000000000:
    print(-1)
else:
    print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
su=0
count=0
for j in a:
    if j==0:
        su+=1
        break
if su>0:
    print(0)
else:
    for i in a:
        ans*=i
        if ans>1000000000000000000:
            print(-1)
            count+=1
            break
    if count!=1:
        if ans>1000000000000000000:
            print(-1)
        else:
            print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=(map(int,input().split()))
s=input()
count=0
for _ in range(q):
    l,r=(map(int,input().split()))
    for i in range(l,r):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1 
    print(count)
    count=0

Fixed submission:
n,q=(map(int,input().split()))
s=input()
count=0
c=[0]*n
for i in range(1,n):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1
        c[i]=count
for _ in range(q):
    l,r=(map(int,input().split())) 
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=(map(int,input().split()))
s=input()
count=0
for _ in range(q):
    l,r=[*map(int,input().split())]
    for i in range(l,r):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1 
    print(count)
    count=0

Fixed submission:
n,q=(map(int,input().split()))
s=input()
count=0
c=[0]*n
for i in range(1,n):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1
        c[i]=count
for _ in range(q):
    l,r=(map(int,input().split())) 
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=(map(int,input().split()))
s=input()
count=0
for _ in range(q):
    l,r=[*map(int,input().split())]
    for i in range(l,r):
        if s[i-1]=="A":
            if s[i]=="C":
               count+=1 
    print(count)
    count=0

Fixed submission:
n,q=(map(int,input().split()))
s=input()
count=0
c=[0]*n
for i in range(1,n):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1
        c[i]=count
for _ in range(q):
    l,r=(map(int,input().split())) 
    print(c[r-1]-c[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=[*map(int,input().split())]
s=input()
count=0
for _ in range(q):
    l,r=[*map(int,input().split())]
    for i in range(l,r):
        if s[i-1]=="A":
            if s[i]=="C":
               count+=1 
    print(count)
    count=0

Fixed submission:
n,q=(map(int,input().split()))
s=input()
count=0
c=[0]*n
for i in range(1,n):
        if s[i-1]=='A':
            if s[i]=='C':
               count+=1
        c[i]=count
for _ in range(q):
    l,r=(map(int,input().split())) 
    print(c[r-1]-c[l-1])
Buggy python submission (verdict: Runtime Error):
no=int(input())
s=[*map(int,input().split())]
q=0
p=0
le=len(s)
if no==2:
    print(abs(s[1]-s[0]))
elif no==3:
    print(abs(s[2]-s[0]))
else:
    a=abs(s[1]-s[0])
    b=abs(s[2]-s[0])
    if no%2==0:
        for i in range(1,len(s)-1,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        for k in range(2,len(s)-2,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        p=p+(abs((s[le-1])-(s[le-2])))
        print(min(q,p))
    else:
        for i in range(1,len(s)-2,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        q=q+(abs((s[le-1])-(s[le-2])))
        for k in range(2,len(s)-1,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        print(min(q,p))

Fixed submission:
no=int(input())
s=list(map(int,input().split()))
a=[0]
a.append(abs(s[1]-s[0]))
for i in range(2,no):
    a.append(min(abs((s[i]-s[i-1]))+a[i-1],abs((s[i]-s[i-2]))+a[i-2]))
print(a[-1])

Buggy python submission (verdict: Runtime Error):
no=int(input())
s=[*map(int,input().split())]
q=0
p=0
le=len(s)
if no==2:
    print(abs(s[1]-s[0]))
if no==3:
    print(abs(s[2]-s[0]))
else:
    a=abs(s[1]-s[0])
    b=abs(s[2]-s[0])
    if no%2==0:
        for i in range(1,len(s)-1,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        for k in range(2,len(s)-2,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        p=p+(abs((s[le-1])-(s[le-2])))
        print(min(q,p))
    else:
        for i in range(1,len(s)-2,2):
            q=q+abs(s[i]-s[i+2])
        q+=a
        q=q+(abs((s[le-1])-(s[le-2])))
        for k in range(2,len(s)-1,2):
            p=p+abs(s[k]-s[k+2])    
        p+=b
        print(min(q,p))
        

Fixed submission:
no=int(input())
s=list(map(int,input().split()))
a=[0]
a.append(abs(s[1]-s[0]))
for i in range(2,no):
    a.append(min(abs((s[i]-s[i-1]))+a[i-1],abs((s[i]-s[i-2]))+a[i-2]))
print(a[-1])

Buggy python submission (verdict: Runtime Error):
no=int(input())
s=[*map(int,input().split())]
q=0
p=0
le=len(s)
if no==2:
    print(abs(s[1]-s[0]))
if no==3:
    print(abs(s[2]-s[0]))
else:
    a=abs(s[1]-s[0])
    b=abs(s[2]-s[0])
    for i in range(1,len(s)-1,2):
        q=q+abs(s[i]-s[i+2])
    q+=a
    for k in range(2,len(s)-2,2):
        p=p+abs(s[k]-s[k+2])    
    p+=b
    p=p+(abs((s[le-1])-(s[le-2])))
    # print(p,q)
    print(min(q,p))


Fixed submission:
no=int(input())
s=list(map(int,input().split()))
a=[0]
a.append(abs(s[1]-s[0]))
for i in range(2,no):
    a.append(min(abs((s[i]-s[i-1]))+a[i-1],abs((s[i]-s[i-2]))+a[i-2]))
print(a[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m, c = map(int, input().split())
array = np.array(list(map(int,input().split())))
nm = []
for _ in range(n):
    _ = list(map(int,input().split()))
    nm.append(_)

count = 0
for _ in nm:
    if np.inner(array, _)+c>0:
        count += 1
print(count)

Fixed submission:
import numpy as np

n, m, c = map(int, input().split())
array = np.array(list(map(int,input().split())))
nm = []
for _ in range(n):
    _ = list(map(int,input().split()))
    nm.append(_)

count = 0
for _ in nm:
    if np.inner(array, _)+c>0:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def simulator(n, a, b, s):
    print()
    boolean_list = ['No'] * n
    count = 0
    for i in range(n):
        if s[i]=='a' and count < a+b:
            count += 1
            boolean_list[i] = 'Yes'
        if s[i]=='b' and count < a+b and s[:i].count('b') <b :
            count += 1
            boolean_list[i] = 'Yes'
    
    for _ in boolean_list:
        print(_)

n, a, b = map(int,input().split())
s = input()
simulator(n, a, b, s)

Fixed submission:
def simulator(n, a, b, s):
    print()
    boolean_list = ['No'] * n
    count = 0
    for i in range(n):
        if s[i]=='a' and count < a+b:
            count += 1
            boolean_list[i] = 'Yes'
        if s[i]=='b' and count < a+b and s[:i].count('b') <b :
            count += 1
            boolean_list[i] = 'Yes'
    
    for _ in boolean_list:
        print(_)

n, a, b = map(int,input().split())
s = input()
simulator(n, a, b, s)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from heapq import heapify, heappop, heappush
from random import randint
from collections import defaultdict
from itertools import accumulate
from fractions import gcd
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N = int(input())
A = inpl()
#N = 10**4
#A = [randint(0, 10**6) for _ in range(10**4)]

lcm = 1
for a in A:
    lcm = a * lcm // gcd(a, lcm)
ans = 0
for i in range(N):
    ans = (ans + lcm // A[i])%MOD
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from fractions import gcd
from string import ascii_lowercase as ABC
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N, M = inpl()
if (N == M):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

H, W = inpl()
A = [inpl() for _ in range(H)]
B = [inpl() for _ in range(W)]

DP = [[0 for _ in range(W+1)] for _ in range(H+1)]
DP[0][0] = 1 << 12800

for h in range(H):
    for w in range(W):
        d = abs(A[h][w] - B[h][w])
        DP[h+1][w] |= DP[h][w] >> d
        DP[h+1][w] |= DP[h][w] << d
        DP[h][w+1] |= DP[h][w] >> d
        DP[h][w+1] |= DP[h][w] << d
l = 1 << 12800
r = 1 << 12800
for i in range(12801):
    if (DP[-1][-2]& l) | (DP[-1][-2] & r):
        print(i)
        break
    l = l << 1
    r = r >> 1

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from itertools import product
from collections import Counter, defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

A = inpl()
if sum(A) >= 22:
    print("bust")
else:
    print("win")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)

Fixed submission:
from collections import Counter
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)

Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)

Fixed submission:
from collections import Counter
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

MOD = 998244353
N= int(input())
D = inpl()
C = Counter(D)

if (D[0] != 0) or (C[0] != 1):
    print(0)
else:
    M = max(C.keys())
    ans = 1
    for i in range(M):
        ans = ans * pow(C[i], C[i+1], MOD) % MOD
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
S = input()[::-1]
x = 1

DP = [0]*13
DP[0] = 1
for i in range(len(S)):
    DP2 = [0]*13
    if S[i] != "?":
        s = int(S[i])
        for i in range(13):
            DP2[(i + s*x)%13] = DP[i]%MOD
    else:
        for j in range(10):
            for i in range(13):
                DP2[(i + j*x)%13] = (DP2[(i + j*x)%13] + DP[i])%MOD
    x *= 10
    DP = DP2

print(DP[5]%MOD)

Fixed submission:
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
S = input()[::-1]
x = 1

DP = [0]*13
DP[0] = 1
for i in range(len(S)):
    DP2 = [0]*13
    if S[i] != "?":
        s = int(S[i])
        for i in range(13):
            DP2[(i + s*x)%13] = DP[i]%MOD
    else:
        for j in range(10):
            for i in range(13):
                DP2[(i + j*x)%13] = (DP2[(i + j*x)%13] + DP[i])%MOD
    x = x*10%13
    DP = DP2

print(DP[5]%MOD)
Buggy python submission (verdict: Runtime Error):
print(3*int(input()**2)

Fixed submission:
print(3*int(input())**2)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stfin.readline
n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)
for a in a:print(b[(a<b[-1])-2])


Fixed submission:
print(3*int(input())**2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]

print(sum(D))
print(*[i for i in range(N+1) if D[i]])

Fixed submission:
def inpl(): return list(map(int, input().split()))

N = int(input())
A = [0] + inpl()
D = [0]*(N+1)

for i in range(N, 0, -1):
    D[i] = (sum(D[2*i::i])%2)^A[i]
print(sum(D))
print(*[i for i in range(N+1) if D[i]])
Buggy python submission (verdict: Runtime Error):
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
input = sys.stdin.readline
from collections import Counter
import numpy as np
def inpl(): return list(map(int, input().split()))
N, D = inpl()
S = set([i**2 for i in range(1, 400)])
X = np.array([inpl() for _ in range(N)], dtype=np.int64)

ans = 0
for i in range(N):
    for x in np.power(X - X[i], 2).sum(axis=1):
        if x in S:
            ans += 1
print(ans//2)

Fixed submission:
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
input = sys.stdin.readline
from collections import Counter
import numpy as np
def inpl(): return list(map(int, input().split()))
N, D = inpl()
S = set([i**2 for i in range(1, 400)])
X = np.array([inpl() for _ in range(N)], dtype=np.int64)

ans = 0
for i in range(N):
    for x in np.power(X - X[i], 2).sum(axis=1):
        if x in S:
            ans += 1
print(ans//2)
Buggy python submission (verdict: Time Limit Exceeded):
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
#input = sys.stdin.readline
from collections import Counter
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

 
size = 2 * 10**5
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD



N, K = inpl()
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = inpl()
    G[a-1].append(b-1)
    G[b-1].append(a-1)
C = [0]*N
P = [0]*N
searched = [0]*N
searched[0] = 1

def count(p):
    global C, searched
    cnt = 0
    for q in G[p]:
        if not searched[q]:
            P[q] = p
            searched[q] = 1
            cnt += 1
            count(q)
    C[p] = cnt
count(0)

ans = K * cmb(K-1, C[0], MOD) * g1[C[0]] % MOD
for i in range(1, N):
    if C[i] == 0:
        continue
    ans = ans * cmb(K-2, C[i], MOD) * g1[C[i]] % MOD

print(ans%MOD)

Fixed submission:
def inpl(): return map(int, input().split())
from itertools import accumulate
from bisect import bisect, bisect_left
from collections import Counter, deque
from functools import reduce
from itertools import accumulate
from operator import itemgetter, xor

from sys import setrecursionlimit
setrecursionlimit(10**9)
 
import sys
#input = sys.stdin.readline
from collections import Counter
def inpl(): return list(map(int, input().split()))

MOD = 10**9 + 7
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


size = 2 * 10**5
g1, g2, inverse = [0]*size, [0]*size, [0]*size
 
g1[:2] = [1, 1] # 元テーブル
g2[:2] = [1, 1] #逆元テーブル
inverse[:2] = [0, 1] #逆元テーブル計算用テーブル
 
for i in range(2, size):
    g1[i] =  ( g1[i-1] * i ) % MOD 
    inverse[i] = (-inverse[MOD % i] * (MOD//i) ) % MOD 
    g2[i] =  (g2[i-1] * inverse[i]) % MOD



N, K = inpl()
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = inpl()
    G[a-1].append(b-1)
    G[b-1].append(a-1)
C = [0]*N
P = [0]*N
searched = [0]*N
searched[0] = 1

"""
def count(p):
    global C, searched
    cnt = 0
    for q in G[p]:
        if not searched[q]:
            P[q] = p
            searched[q] = 1
            cnt += 1
            count(q)
    C[p] = cnt
count(0)"""

Q = deque([0])
while Q:
    p = Q.popleft()
    for q in G[p]:
        if not searched[q]:
            P[q] = p
            searched[q] = 1
            C[p] += 1
            Q.append(q)


ans = K * cmb(K-1, C[0], MOD) * g1[C[0]] % MOD
for i in range(1, N):
    if C[i] == 0:
        continue
    ans = ans * cmb(K-2, C[i], MOD) * g1[C[i]] % MOD

print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
elif W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a == b:
    print(a, 1)
    raise
elif a > b:
    print(a, int(2*x == W))
else:
    print(b, int(2*y == H))


Fixed submission:
def inpl(): return list(map(int, input().split()))
X, A = inpl()
if X < A:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
elif W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a > b:
    print(a, int(2*x == W))
else:
    print(b, int(2*y == H))
    raise

Fixed submission:
W, H, x, y = map(int, input().split())
print(H*W/2, int((2*y == H)&(2*x == W)))

Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
    raise
elif W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a > b:
    print(a, int(2*x == W))
else:
    print(b, int(2*y == H))

Fixed submission:
W, H, x, y = map(int, input().split())
print(H*W/2, int((2*y == H)&(2*x == W)))

Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x*2 > W:
    x = W-x
if y*2 > H:
    y = H-y

a = W*y
b = H*x
if x == 0 or y == 0:
    print(H*W/2, 0)
elif W*y == H*x:
    print(H*W/2, int(W==2*x))
    raise
elif a == b:
    print(a, 1)
elif a > b:
    print(a, 0)
else:
    print(b, 0)


Fixed submission:
W, H, x, y = map(int, input().split())
print(H*W/2, int((2*y == H)&(2*x == W)))

Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))
W, H, x, y = inpl()
if x > W/2:
    x = W-x
if y > H/2:
    y = H-y

a = W*y
b = H*x
if W/H == x/y:
    print(H*W/2, int(W/2==x))
elif a == b:
    print(a, 1)
elif a > b:
    print(a, 0)
else:
    print(b, 0)

Fixed submission:
W, H, x, y = map(int, input().split())
print(H*W/2, int((2*y == H)&(2*x == W)))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(sum(map(abs, A[1:])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
    else:
      print(A[-1], a)
      A[-1] -= a
      print(A[-1], A[0])


Fixed submission:
def inpl(): return list(map(int, input().split()))
N, K = inpl()
if K == 1:
    print(0)
else:
    print(N-K)

Buggy python submission (verdict: Runtime Error):
N, K = inpl()
if K == 1:
    print(0)
else:
    print(N-K)

Fixed submission:
def inpl(): return list(map(int, input().split()))
N, K = inpl()
if K == 1:
    print(0)
else:
    print(N-K)