Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
from collections import deque


N = int(input())
A = list(map(int,input().split()))
d = deque(A)
ans = 0
for i in range(N):
    q = d.popleft()
    a = collections.Counter(d)
    tmp = a.values()
    l = list(tmp)
    for j in range(len(l)):
        n = l[j]-1
        ans += n*(n+1)//2
    print(ans)
    ans = 0
    d.append(q)




Fixed submission:
import collections

N = int(input())
A = list(map(int,input().split()))
a = collections.Counter(A)
v = a.values()
l_v = list(v)

#合計
s = 0
for i in range(len(l_v)):
    n = l_v[i]-1
    s += n*(n+1)//2
#カウント
for i in range(N):
    print(s-(a[A[i]]-1))
Buggy python submission (verdict: Time Limit Exceeded):
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


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 9
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

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

# mod = 10 ** 9 + 7
ans = (2 ** n - 1) - (cmb(n, a, mod) + cmb(n, b, mod))
print(ans)


Fixed submission:
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
#2 ** n はだめ
n_max = pow(2, n, mod) - 1


def comb_mod(n, r, mod):
    num = 1
    den = 1
    for i in range(r):
        num = (num * (n - i)) % mod
        den = (den * (i + 1)) % mod
    den_r = pow(den, mod - 2, mod)
    return (num * den_r) % mod


ans = (n_max - comb_mod(n, a, mod) - comb_mod(n, b, mod)) % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
tmp = 0
count = float(0)
for i in range(k, n + 1):
    tmp = (sum(p[i - k:i]) + k) / 2
    if ans <= tmp:
        ans = tmp
print(ans)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

tmp_sum = sum(p[0:k])
ans = (tmp_sum + k) / 2
count = float(0)
for i in range(k, n):
    tmp_sum = tmp_sum + p[i] - p[i - k]
    tmp = (tmp_sum + k) / 2
    if ans <= tmp:
        ans = tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))
tmp = []
ans = 0
for i in range(n):
    tmp.append(p[i])
    if min(tmp)>=p[i]:
        ans+=1
print(ans)

Fixed submission:
n = int(input())
p = list(map(int,input().split()))
mtmp = p[0]
ans = 0
for i in range(0,n):
    if mtmp>=p[i]:
        mtmp=p[i]
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
p = input().replace(" ", "")
q = input().replace(" ", "")
m = ""
for i in range(1, n + 1):
    m += str(i)
anagram_list = ["".join(v) for v in itertools.permutations(m)]

pa = 0
qa = 0

for i in range(len(anagram_list)):
    if anagram_list[i] == p:
        pa = i+1
    if anagram_list[i] == q:
        qa = i+1a
print(abs(pa-qa))


Fixed submission:
import itertools

n = int(input())
p = input().replace(" ", "")
q = input().replace(" ", "")
m = ""
for i in range(1, n + 1):
    m += str(i)
anagram_list = ["".join(v) for v in itertools.permutations(m)]

pa = 0
qa = 0

for i in range(len(anagram_list)):
    if anagram_list[i] == p:
        pa = i+1
    if anagram_list[i] == q:
        qa = i+1
print(abs(pa-qa))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)


Fixed submission:
import numpy as np

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)

Buggy python submission (verdict: Time Limit Exceeded):
def xor(a, b):
    xor = a ^ b
    return xor


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

count = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        count += xor(a[i], a[j])

print(count % (10 ** 9 + 7))


Fixed submission:
import numpy as np

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for a in range(N):
    for b in range(a + 1, N):
        for c in range(b + 1, N):
            if L[c] >= L[a] + L[b]:
                break
            elif L[a] >= L[b] + L[c] or L[b] >= L[c] + L[a]:
                continue
            else:
                count += 1
print(count)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for a in range(N):
    for b in range(a + 1, N):
        c = bisect.bisect_left(L, L[a] + L[b])
        if c > b:
            count += c - b - 1
        else:
            break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import math


# 公約数列挙
# 重複する約数は1つにまとまるので注意
def make_common_divisors(x1, x2):
    cd = [1]
    for i in range(2, min(x1, x2) + 1):
        if x1 % i == 0 and x2 % i == 0:
            cd.append(i)
    return cd


A, B = map(int, input().split())
CD = make_common_divisors(A, B)


# 引数nが素数かどうかを判定
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


count = 1
for i in range(len(CD)):
    if is_prime(CD[i]):
        count += 1

print(count)


Fixed submission:

# nを素因数分解したリストを返す
def decomposition_prime(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(int(n))
    return table

A, B = map(int, input().split())
Ap = set(decomposition_prime(A))
Bp = set(decomposition_prime(B))
print(len(Ap & Bp)+1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline

def main():

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

    while M > 0:
        tmp = A.pop()
        tmp = tmp // 2
        bisect.insort_right(A, tmp)
        M -= 1
    print(sum(A))

if __name__ == '__main__':
    main()

Fixed submission:
import heapq
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp = heapq.heappop(A)
        tmp *= -1
        tmp = tmp // 2
        heapq.heappush(A, tmp * (-1))
    print(sum(A) * (-1))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
import math
import bisect

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

while M > 0:
    tmp = A.pop()
    tmp = tmp // 2
    index = bisect.bisect_right(A, tmp)
    A.insert(index, tmp)
    M -= 1
print(sum(A))


Fixed submission:
import heapq
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(A)

    for _ in range(M):
        tmp = heapq.heappop(A)
        tmp *= -1
        tmp = tmp // 2
        heapq.heappush(A, tmp * (-1))
    print(sum(A) * (-1))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] * N
m = 0
for i in range(N):
    A[i] = int(input())
    if A[i] > m:
        m = A[i]
for i in range(N):
    if A[i] != m:
        print(m)
    else:
        A[i] = 0
        print(max(A))
        A[i] = m

Fixed submission:
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())
tmp = sorted(A)
m1 = tmp[-1]
m2 = tmp[-2]
for i in range(N):
    if A[i] != m1:
        print(m1)
    else:
        print(m2)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
mod = 2019
ans = mod + 100

if R - L >= 3000:
    print(0)
else:
    L %= mod
    R %= mod
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % mod
            if m < ans:
                ans = m
print(ans)


Fixed submission:
N, A, B = map(int, input().split())
print(min(A * N, B))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = []
mod = 10 ** 9 + 7
for _ in range(m):
    a.append(int(input()))
dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
    if i in a:
        continue
    if i >= 2:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    else:
        dp[i] = dp[i - 1]
print(dp[-1])


Fixed submission:
n, m = [int(x) for x in input().split()]
a = set(int(input()) for _ in range(m))

mod = 10 ** 9 + 7

dp = [0] * (n + 1)
dp[0] = 1
for i in range(1, n + 1):
    if i in a:
        continue
    if i >= 2:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
    else:
        dp[i] = dp[i - 1]
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
c = []
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        c.append(count)
        count = 0
print(max(c))

Fixed submission:
S = input()
count = 0
c = [0]
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        c.append(count)
        count = 0
c.append(count)
print(max(c))
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())
    l-=1
    r-=1
    for i in range(l,r):
        if S[i] == "A" and S[i+1] == "C":
            count += 1
    print(count)
    count = 0

Fixed submission:
N, Q = map(int, input().split())
S = input()
AC = [0] * (N)
for i in range(1, N):
    if S[i] == "C" and S[i - 1] == "A":
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i-1]
for _ in range(Q):
    l,r = map(int,input().split())
    l-=1
    r-=1
    print(AC[r]-AC[l])
Buggy python submission (verdict: Runtime Error):
# https://atcoder.jp/contests/dp/tasks/dp_b

N,K = map(int,input().split())
h = [int(x) for x in input().split()]

dp = [0] * (N)
dp[0] = 0

# 参考：https://atcoder.jp/contests/dp/submissions/10181844
for i in range(1, N):
    tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
    dp[i] = min(tmp)
print(dp[-1])


Fixed submission:
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#メモ化再帰
#入力
h = [0]*100010
dp = [float("inf")]*100010

def rec(i):
    #DPの値が更新されていたらそのままリターン
    if dp[i]<float("inf"):
        return dp[i]
    if i==0:
        return 0
    res = float("inf")
    res = min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        res = min(res, rec(i - 2) + abs(h[i] - h[i - 2]))
    dp[i]=res
    return dp[i]

#入力
N=int(input())
H=list(map(int,input().split()))
for i in range(N):
    h[i] = H[i]

print(rec(N-1))

Fixed submission:
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#配るDP
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i+1] = min(dp[i],dp[i]+abs(h[i]-h[i+1]))
    if i>1:
        dp[i+2] = min(dp[i],dp[i]+abs(h[i]-h[i+2]))

print(dp[-1])


Fixed submission:
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/dp/tasks/dp_b

N,K = map(int,input().split())
h = [int(x) for x in input().split()]

dp = [0] * (N)
dp[0] = 0

# 参考：https://atcoder.jp/contests/dp/submissions/10181844
for i in range(1, N):
    tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
    dp[i] = min(tmp)
print(dp[-1])


Fixed submission:
# https://atcoder.jp/contests/dp/tasks/dp_b

def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [0] * (N)
    dp[0] = 0

    # 参考：https://atcoder.jp/contests/dp/submissions/10181844
    for i in range(1, N):
        tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
        dp[i] = min(tmp)
    print(dp[-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# https://atcoder.jp/contests/dp/tasks/dp_b

N, K = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

dp = [0] * (N)
dp[0] = 0

# 参考：https://atcoder.jp/contests/dp/submissions/10181844
for i in range(1, N):
    tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
    dp[i] = min(tmp)
print(dp[-1])


Fixed submission:
# https://atcoder.jp/contests/dp/tasks/dp_b

def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [0] * (N)
    dp[0] = 0

    # 参考：https://atcoder.jp/contests/dp/submissions/10181844
    for i in range(1, N):
        tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
        dp[i] = min(tmp)
    print(dp[-1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#https://atcoder.jp/contests/dp/tasks/dp_b

N,K = [int(x) for x in input().split()]
h = list(map(int,input().split()))

dp = [0] * (N)
dp[0] = 0
dp[1] = abs(h[1]-h[0])
tmp_dp = []
for i in range(2,N):
    for k in range(1,K+1):
        if k > i:
            break
        tmp_dp.append(dp[i-k] + abs(h[i]-h[i-k]))
#        print(dp[i-k], abs(h[i]-h[i-k]),tmp_dp)
#    print("tmp_dp",i,tmp_dp)
    dp[i] = min(tmp_dp)
    tmp_dp = []
print(dp[-1])

Fixed submission:
# https://atcoder.jp/contests/dp/tasks/dp_b

def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [0] * (N)
    dp[0] = 0

    # 参考：https://atcoder.jp/contests/dp/submissions/10181844
    for i in range(1, N):
        tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
        dp[i] = min(tmp)
    print(dp[-1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
D,N = map(int,input().split())
ans = []
for i in range(1,N+1):
    tmp = (100**D)*i
    if tmp // 100 == 100**D:
        continue
    else:
        ans.append(tmp)
print(ans[N-1])

Fixed submission:
D, N = map(int, input().split())
if N == 100:
    print(100**D*N+100**D)
else:
    print(100**D*N)
Buggy python submission (verdict: Runtime Error):
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(2,n):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))


Fixed submission:
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(1,n):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))
Buggy python submission (verdict: Runtime Error):
import sys

H,W = map(int,input().split())
s = [list(input()) for i in range(W)]
a = [["."]*H for _ in range(W)]
for i in range(H):
    for j in range(1,W):
        if s[i][j-1] == "#" and s[i][j] == "#":
            a[i][j-1] = "#"
            a[i][j] = "#"

sT = list(zip(*s))
aT = [list(x) for x in zip(*a)]

for i in range(H):
    for j in range(1,W):
        if sT[i][j-1] == "#" and sT[i][j] == "#":
            aT[i][j-1] = "#"
            aT[i][j] = "#"

ans = list(zip(*aT))

for i in range(H):
    for j in range(W):
        if s[i][j] != ans[i][j]:
            print("No")
            sys.exit()
print("Yes")

Fixed submission:
import sys

H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
a = [["."]*W for _ in range(H)]
for i in range(H):
    for j in range(1,W):
        if s[i][j-1] == "#" and s[i][j] == "#":
            a[i][j-1] = "#"
            a[i][j] = "#"

sT = list(zip(*s))
aT = [list(x) for x in zip(*a)]

for i in range(W):
    for j in range(1,H):
        if sT[i][j-1] == "#" and sT[i][j] == "#":
            aT[i][j-1] = "#"
            aT[i][j] = "#"

ans = list(zip(*aT))

for i in range(H):
    for j in range(W):
        if s[i][j] != ans[i][j]:
            print("No")
            sys.exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
ans = []
for i in range(A,B+1):
    if i <= K+A-1 or i >= B-K+1:
        ans.append(i)
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
A,B,K = map(int,input().split())
ans = []
for i in range(A,K+A):
    if i > B:
        break
    ans.append(i)

for i in range(B-K+1,B+1):
    if i < A:
        continue
    ans.append(i)

ans = set(ans)
ans = list(ans)
ans.sort()
for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
def digit10_str(n):
    dten_str = ""
    while(n>0):
        dten_str+=str(n%10)
        n/=10
    return dten_str

a,b = map(int,input().split())
c = 0
for i in range(a,b):
    if digit10_str(i)[0]==digit10_str(i)[-1] and digit10_str(i)[1]==digit10_str(i)[-2]:
        c+=1
print(c)

Fixed submission:
a,b = map(int,input().split())
c = 0
for i in range(a,b+1):
    s = str(i)
    if s == s[::-1]:
        c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
for i in range(n):
    A[i]=int(input())
count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

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

count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
for i in range(n):
    A[i]=int(input())
count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

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

count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
import sys

N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
s = [0] * max(a)
s[0] = 1
count = 0
for _ in range(N):
    for i in range(N):
        if s[i] == 1:
            s[i] = 0
            s[a[i]-1] = 1
            break
    count += 1
    if s[1] == 1:
        print(count)
        sys.exit()
print(-1)


Fixed submission:
import sys

N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
s = 1
for i in range(N):
    tmp = a[s]
    if tmp == 2:
        print(i+1)
        sys.exit()
    else:
        s = tmp
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = 1
for i in range(1,N + 1):
    p *= i
print(p % (10 ** 9 + 7))


Fixed submission:
N = int(input())
p = 1
mod = 10 ** 9 + 7
for i in range(1,N + 1):
    p = (p*i) % mod
print(p)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [input() for _ in range(w)]
ans=[]
for i in range(w):
    ans.append(s[i])
    ans.append(s[i])
for i in range(w*2):
    print(ans[i])

Fixed submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans=[]
for i in range(h):
    ans.append(s[i])
    ans.append(s[i])
for i in range(h*2):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
c=0
for i in range(a,b+1):
    if i%x == 0:
        c+=1
print(c)

Fixed submission:
a,b,x = map(int,input().split())
ans=0
if a>0:
    ans = b//x-(a-1)//x
elif a==0:
    ans = b//x+1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)-1
l=[]
for i in range(n):
    l.append("+")
sum = 0
for i in range(2 ** n):
    plus = []
    tmp = ""
    ans = 0
    for j in range(n):
        if ((i>>j) & 1):
            plus.append(l[j])
        else:
            plus.append("")
    for i in range(n):
        tmp += s[i]+plus[i]
        if i == n-1:
            tmp+=s[i+1]
    tmp2 = tmp.split("+")
    for i in range(len(tmp2)):
        ans += int(tmp2[i])
    sum+=ans
print(sum)



Fixed submission:
s=input()
n=len(s)-1
l=[]
for i in range(n):
    l.append("+")
sum = 0

if len(s) < 2:
    sum = s

else:
    for i in range(2 ** n):
        plus = []
        tmp = ""
        ans = 0
        for j in range(n):
            if ((i>>j) & 1):
                plus.append(l[j])
            else:
                plus.append("")
        for i in range(n):
            tmp += s[i]+plus[i]
            if i == n-1:
                tmp+=s[i+1]
        tmp2 = tmp.split("+")
        for i in range(len(tmp2)):
            ans += int(tmp2[i])
        sum+=ans

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
  q.append((-1)*a[i])
for k in range(m):
  heapq.heapify(q)
  ma=heapq.heappop(q)
  if ma%2==0:
    heapq.heappush(q,ma//2)
  else:
    heapq.heappush(q,ma//2+1)
print(sum(q)*(-1))

Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
  q.append((-1)*a[i])
heapq.heapify(q)
for k in range(m):
  ma=heapq.heappop(q)
  if ma%2==0:
    heapq.heappush(q,ma//2)
  else:
    heapq.heappush(q,ma//2+1)
print(sum(q)*(-1))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
  q.append((-1)*a[i])
for k in range(m):
  heapq.heapify(q)
  ma=heapq.heappop(q)
  if ma%2==0:
    heapq.heappush(q,ma//2)
  else:
    heapq.heappush(q,ma//2+1)
print(sum(q)*(-1))

Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in range(n):
  q.append((-1)*a[i])
heapq.heapify(q)
for k in range(m):
  ma=heapq.heappop(q)
  if ma%2==0:
    heapq.heappush(q,ma//2)
  else:
    heapq.heappush(q,ma//2+1)
print(sum(q)*(-1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n
for i in range(n):
  a[i]=int(input())

for i in range(n):
  print(max(a[:i]+a[i+1:]))

Fixed submission:
import copy
n=int(input())
a=[0]*n
for i in range(n):
  a[i]=int(input())
b=copy.deepcopy(a)
m1=max(a)
a.remove(m1)
m2=max(a)
for i in range(n):
  if b[i]==m1:
    print(m2)
  else:
    print(m1)