Question:
N = int(input())
z,w = [],[]
K = 0
for i in range(N):
  x,y = map(int,input().split())
  z.append(x)
  w.append(y)
for j in range(1,N-1):
  if z[j] == w[j] and z[j+1] == w[j+1] and z[j+2] == w[j+2]:
    K += 1

if K >= 1:
  print("Yes")
else:
  print("No")

Choices:
- Runtime Error
- No abnormally found
- Compile Error
- Time Limit Exceeded


Question:
N = int(input())
z,w = [],[]
K = 0
for i in range(N):
  x,y = map(int,input().split())
  z.append(x)
  w.append(y)
for j in range(N):
  if z[j] == w[j] and z[j+1] == w[j+1] and z[j+2] == w[j+2]:
    K += 1

if K >= 1:
  print("Yes")
else:
  print("No")

Choices:
- No abnormally found
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded


Question:
a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d))

Choices:
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error


Question:
a,b,c,d = map(int,input().split())
print(max[a*c,a*d,b*c,b*d])

Choices:
- Compile Error
- Runtime Error
- Internal error
- Memory Limit Exceeded


Question:
#ABC134 C

N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

for i in range(N):
    if A[i] != max(A):
        print(max(A))
    else:
        p = A[i]
        A[i] = 0
        print(max(A))
        A[i] = p

Choices:
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded
- Compile Error


Question:
#ABC132 B

n = int(input())
K = 0
for i in range(n-2):
    if (P[i]<P[i+1] and P[i+1] < P[i+2]) or (P[i+2]<P[i+1] and P[i+1]<P[i]):
        K += 1

print(K)

Choices:
- Runtime Error
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded


Question:
#ABC132 A

S = str(input())
T = [S[0],S[1],S[2],S[3]]
T.sort()
if T[0] == T[1] and T[2] == T[3] and T[1] != T[2]
    print("Yes")
else:
    print("No")

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- No abnormally found
- Runtime Error


Question:
#ABC132 A

S = str(input())
S.sort()
if S[0] = S[1] and S[2] = S[3]:
    print("Yes")
else:
    print("No")

Choices:
- Runtime Error
- Memory Limit Exceeded
- No abnormally found
- Internal error


Question:
#ABC132 B

n = int(input())
K = 0
for i in range(n-2):
    if (P[i]<P[i+1] and P[i+1] < P[i+2]) or (P[i+2]<P[i+1] and P[i+1]<P[i]):
        K += 1

print(K)

Choices:
- Runtime Error
- Compile Error
- No abnormally found
- Memory Limit Exceeded


Question:
n = int(input())
K = 0
for i in range(n-2):
    if P[i]<P[i+1]<P[i+2] or P[i+2]<P[i+1]<P[i]:
        K += 1

print(K)

Choices:
- Internal error
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded


Question:
W,H,x,y = map(int,input().split())
if y == H*x/W or y == H - H*x/W:
    print(W*H,1.split())
else:
    print(W*H,0.split())

Choices:
- Compile Error
- Internal error
- Time Limit Exceeded
- Runtime Error


Question:
W,H,x,y = map(int,input().split())
if y == H*x/W or y == H - H*x/W:
    print(W*H 1)
else:
    print(W*H 0)

Choices:
- Runtime Error
- Internal error
- Memory Limit Exceeded
- Compile Error


Question:
#ABC126 B

S = list(map(int,input()))
if 1 <= S[0]*10 + S[1] <= 12 and 1 <= S[2]*10 + S[3] <= 12:
    print("AMBIGUOUS")
elif 1 <= S[0]*10 + S[1] <= 12 and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("MMYY")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0)  and  1 <= S[2]*10 + S[3] <= 12:
    print("YYMM")
elif (S[0]*10 + S[1] > 12 or S[0]*10 + S[1] == 0) and (S[2]*10 + S[3] > 12 or S[2]*10 + S[3] == 0):
    print("NA")

Choices:
- Internal error
- Memory Limit Exceeded
- Time Limit Exceeded
- Runtime Error


Question:
n = int(input())
a = [int(s) for s in input().split()]
b = a.copy()
max_index = a.index(max(a))
count = 0
last_index = len(a)
while(last_index > 0):
    b[max_index: last_index] = [a[max_index]] * (last_index - max_index)
    last_index = max_index

    if last_index == 0 or len(set(a[:last_index])) <= 1:
        break
    max_index = a.index(max(a[:last_index]))

for i in range(len(a)):
    count += b[i] - a[i]
print(count)

Choices:
- No abnormally found
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error


Question:
n = int(input())
a = [int(s) for s in input().split()]
b = a.copy()
max_index = a.index(max(a))
count = 0
last_index = len(a)
while(last_index > 0):
    b[max_index: last_index] = [a[max_index]] * (last_index - max_index)
    last_index = max_index
    if last_index == 0:
        break
    max_index = a.index(max(a[:last_index]))

for i in range(len(a)):
    count += b[i] - a[i]
print(count)

Choices:
- Compile Error
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question:
n = int(input())
a = [int(s) for s in input().split()]
max_index = a.index(max(a))
count = 0
last_index = len(a)
while(last_index > 0):
    for i in range(max_index,last_index):
        count += a[max_index] - a[i]
    last_index = max_index
    if last_index == 0:
        break
    max_index = a.index(max(a[:last_index]))

print(count)

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Time Limit Exceeded


Question:
n = int(input())
a = [int(s) for s in input().split()]
b = a.copy()
max_index = a.index(max(a))
last_index = len(a)
while(last_index > 0):
    for i in range(max_index,last_index):
        b[i] = b[max_index]
    last_index = max_index
    if last_index == 0:
        break
    max_index = b.index(max(a[:last_index]))

count = 0
for i in range(len(a)):
    count += b[i] - a[i]
print(count)

Choices:
- Time Limit Exceeded
- Internal error
- No abnormally found
- Compile Error


Question:
s = input()
ans = 'No'
index = s.find(s[0], 1)
if index >= 1:
    s = s.replace(s[0], '')
    if (len(s) >= 2) & (s[0] == s[1]):
        ans ='Yes'

print(ans)

Choices:
- No abnormally found
- Internal error
- Memory Limit Exceeded
- Runtime Error


Question:
n=int(input())
a=str(input())
b=str(input())

a=a[:n]
b=b[:n]
x=0
for i in a:
	print(a[x],b[x],end='')
	x+=1
print()

Choices:
- Internal error
- Memory Limit Exceeded
- Compile Error
- Runtime Error


Question:
str1, str2 = input().split()
num1, num2 = map(int,input.split())
trim = input()

if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1

print("%d %d",%(num1, num2))

Choices:
- Internal error
- Compile Error
- Time Limit Exceeded
- Runtime Error


Question:
str1, str2 = input().split()
num1, num2 = map(int,input.split())
trim = input()

if trim == str1:
	num1 = num1 - 1
else:
  	num2 = num2 - 1

print("%d %d",%(num1, num2))

Choices:
- Internal error
- Compile Error
- Runtime Error
- Memory Limit Exceeded


Question:
n = input()
list = list(map(int,input().split()))
count = 0
for i, val in enumerate(list):
  if min(list[0:i+1]) >= val:
    count += 1
print("%d"%(count))

Choices:
- Time Limit Exceeded
- Compile Error
- No abnormally found
- Runtime Error


Question:
import sys

def main():
    input = sys.stdin.buffer.readline
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    num_a = 0
    while num_a <= n:
        # Aの上からi冊の和
        s = sum(a[:num_a])
        if s > k:
            break
        # Bから読める本の数
        for j in range(len(b)):
            if s + b[j] <= k:
                s += b[j]
            else:
                num_b = j
                break
        else:
            num_b = len(b)
        if num_a + num_b > ans:
            ans = num_a + num_b
        num_a += 1

    print(ans)

if __name__ == '__main__':
    main()

Choices:
- Internal error
- Memory Limit Exceeded
- Time Limit Exceeded
- Compile Error


Question:
from functools import lru_cache
import sys
MOD = 998244353

@lru_cache(maxsize=3100)
def pow_mod(i):
    # pow(2, i - 1, MOD)
    if i == 1:
        return 1
    else:
        return pow_mod(i - 1) * 2 % MOD

def main():
    input = sys.stdin.buffer.readline
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[None] * (s + 1) for _ in range(n + 1)]
#     dp[i][j]:=集合{1..i}の空でない部分集合T全てについて,和がjとなる部分集合の個数の和
    for i in range(n + 1):
        for j in range(s + 1):
            if i == 0 or j == 0:
                dp[i][j] = 0
                continue
            if j > a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + dp[i - 1][j - a[i - 1]]
            elif j == a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + pow_mod(i)
            else:
                dp[i][j] = dp[i - 1][j] * 2
            dp[i][j] %= MOD
    print(dp[n][s])

if __name__ == '__main__':
    main()

Choices:
- Memory Limit Exceeded
- No abnormally found
- Runtime Error
- Compile Error


Question:
from functools import lru_cache
import sys
MOD = 998244353

@lru_cache(maxsize=None)
def pow_mod(i):
    # pow(2, i - 1, MOD)
    if i == 1:
        return 1
    else:
        return pow_mod(i - 1) * 2 % MOD

def main():
    input = sys.stdin.buffer.readline
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[None] * (s + 1) for _ in range(n + 1)]
#     dp[i][j]:=集合{1..i}の空でない部分集合T全てについて,和がjとなる部分集合の個数の和
    for i in range(n + 1):
        for j in range(s + 1):
            if i == 0 or j == 0:
                dp[i][j] = 0
                continue
            if j > a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + dp[i - 1][j - a[i - 1]]
            elif j == a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + pow_mod(i)
            else:
                dp[i][j] = dp[i - 1][j] * 2
            dp[i][j] %= MOD
    print(dp[n][s])

if __name__ == '__main__':
    main()

Choices:
- Internal error
- Memory Limit Exceeded
- Compile Error
- Runtime Error


Question:
import sys
MOD = 998244353

def main():
    input = sys.stdin.buffer.readline
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    dp = [[None] * (s + 1) for _ in range(n + 1)]
#     dp[i][j]:=集合{1..i}の空でない部分集合T全てについて,和がjとなる部分集合の個数の和
    for i in range(n + 1):
        for j in range(s + 1):
            if i == 0 or j == 0:
                dp[i][j] = 0
                continue
            if j > a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + dp[i - 1][j - a[i - 1]]
            elif j == a[i - 1]:
                dp[i][j] = dp[i - 1][j] * 2 + pow(2, i - 1, MOD)
            else:
                dp[i][j] = dp[i - 1][j] * 2
            dp[i][j] %= MOD
    print(dp[n][s])

if __name__ == '__main__':
    main()

Choices:
- Compile Error
- Internal error
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
            sys.exit()
        check[index] = count
        count += 1
        index = a[index]

if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)

Choices:
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded
- Internal error


Question:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(lambda x: int(x) - 1, input().split()))
loop = []
start = 0
index = 0
check = [-1] * N
fin = False
count = 0
while True:
    if check[index] != -1:
        start = check[index]
        break
    else:
        loop.append(index)
        if len(loop) == K + 1:
            print(index + 1)
			exit()
        check[index] = count
        count += 1
        index = a[index]

if (K + 1 - start) % len(loop[start:]) == 0:
    print(loop[-1] + 1)
else:
    print(loop[start + (K + 1 - start) % len(loop[start:]) - 1] + 1)

Choices:
- Memory Limit Exceeded
- Runtime Error
- Compile Error
- Time Limit Exceeded


Question:
import sys
from math import factorial
input = sys.stdin.readline
N, M, K = map(int, input().split())
MOD = 998244353
inv = [1] * N
FAC = factorial(N - 1) % MOD
if M == 1:
    print(1 if K == N - 1 else 0)
else:
    res = 0
    for i in range(1, N):
        inv[i] = pow(factorial(i), MOD - 2, MOD)
    for k in range(K + 1):
        # k個の○とN-k-1個の|を並べる順列
        # punc = (N-1)!/k!/(N-k-1)!
        # punc = factorial(
        #     k + (N - k - 1)) // factorial(k) // factorial(N - k - 1)
        punc = FAC
        # punc *= pow(factorial(k), MOD - 2, MOD)
        punc *= inv[k]
        punc = punc % MOD
        # punc *= pow(factorial(N - k - 1), MOD - 2, MOD)
        punc *= inv[N - k - 1]
        punc = punc % MOD
        color = M * pow(M - 1, N - k - 1, MOD)
        res += ((punc % MOD) * color) % MOD
        res = res % MOD
    print(res % MOD)

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Internal error
- No abnormally found


Question:
import sys
from math import factorial
input = sys.stdin.readline
N, M, K = map(int, input().split())
MOD = 998244353
if M == 1:
    print(1 if K == N - 1 else 0)
else:
    res = 0
    for k in range(K + 1):
        # k個の○とN-k-1個の|を並べる順列
        # punc = (N-1)!/k!/(N-k-1)!
        # punc = factorial(
        #     k + (N - k - 1)) // factorial(k) // factorial(N - k - 1)
        punc = factorial(N - 1) % MOD
        punc *= pow(factorial(k), MOD - 2, MOD)
        punc = punc % MOD
        punc *= pow(factorial(N - k - 1), MOD - 2, MOD)
        punc = punc % MOD
        color = M * pow(M - 1, N - k - 1, MOD)
        res += ((punc % MOD) * color) % MOD
        res = res % MOD
    print(res % MOD)

Choices:
- Time Limit Exceeded
- Compile Error
- Memory Limit Exceeded
- Runtime Error


Question:
import sys
from math import factorial
input = sys.stdin.readline
N, M, K = map(int, input().split())
if M == 1:
    print(1 if K == N - 1 else 0)
else:
    res = 0
    for k in range(K + 1):
        # k個の○とN-k-1個の|を並べる順列
        punc = factorial(
            k + (N - k - 1)) // factorial(k) // factorial(N - k - 1)
        # color = M * ((M - 1)**(N - k - 1))
        color = M
        for _ in range(N - k - 1):
            color *= M - 1
            color = color % 998244353
        res += ((punc % 998244353) * (color % 998244353)) % 998244353
        res = res % 998244353
    print((res) % 998244353)

Choices:
- Compile Error
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded


Question:
import sys
from math import factorial
input = sys.stdin.readline
N, M, K = map(int, input().split())
if M == 1:
    print(1 if K == N - 1 else 0)
else:
    res = 0
    for k in range(K + 1):
        # k個の○とN-k-1個の|を並べる順列
        punc = factorial(k + (N - k - 1)) // (factorial(k)
                                              * factorial(N - k - 1))
        color = M * ((M - 1)**(N - k - 1))
        res += punc * color
    print((res) % 998244353)

Choices:
- Compile Error
- Time Limit Exceeded
- Runtime Error
- Internal error


Question:
import sys

def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], dp[max(j - a[i], 0)] + b[i])
    print(min(dp[h:]))

if __name__ == "__main__":
    main()

Choices:
- Internal error
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded


Question:
import sys

def main():
    input = sys.stdin.buffer.readline
    h, n = map(int, input().split())
    a = [0] * n
    b = [0] * n
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    max_a = max(a)
    # dp[j]:jダメージ与える魔力の最小値
    dp = [1e9] * (h + max_a + 1)
    dp[0] = 0
    for i in range(n):
        for j in range(1, h + max_a + 1):
            dp[j] = min(dp[j], min(dp[max(j - a[i], 0) : j]) + b[i])
    print(min(dp[h:]))

if __name__ == "__main__":
    main()

Choices:
- Time Limit Exceeded
- Runtime Error
- Internal error
- Memory Limit Exceeded


Question:
from collections import Counter

def main():
    n = int(input())
    cnt = Counter()
    ans = 0
    for i in range(n):
        s = sorted(input())

        if cnt[s] == 0:
            cnt[s] = 1
        else:
            ans += cnt[s]
            cnt[s] += 1
    print(ans)

if __name__ == "__main__":
    main()

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- No abnormally found
- Runtime Error


Question:
import sys

n, k = map(int, input().split())
A = list(map(int, input().split()))

L = [1]
tmp = 1
ct = 0
check = 0
while True:
    x = A[tmp - 1]
    ct += 1
    if x in L or ct > k:
        check = x
        break
    else:
        L.append(x)
        tmp = x
if ct > k:
    print(L[k])
    sys.exit()
p = L.index(check)
l = len(L)
roop = l - p
if k < p:
    print(L[k])
else:
    k -= p
    k %= roop
    print(L[p + k])

Choices:
- No abnormally found
- Internal error
- Compile Error
- Time Limit Exceeded


Question:
import sys

n, k = map(int, input().split())
A = list(map(int, input().split()))

dic = {}
for i in range(1, n+1):
    dic[i] = A[i-1]

L = [1]
tmp = 1
ct = 0
check = 0
while True:
    x = dic[tmp]
    ct += 1
    if x in L or ct > k:
        check = x
        break
    else:
        L.append(x)
        tmp = x
if ct > k:
    print(L[k])
    sys.exit()
p = L.index(check)
l = len(L)
roop = l - p
if k < p:
    print(L[k])
else:
    k -= p
    k %= roop
    print(L[p + k])

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Time Limit Exceeded


Question:
n, k = map(int, input().split())
A = list(map(int, input().split()))

dic = {}
for i in range(1, n+1):
    dic[i] = A[i-1]

L = [1]
tmp = 1
ct = 0
check = 0
while True:
    x = dic[tmp]
    ct += 1
    if x in L:
        check = x
        break
    else:
        L.append(x)
        tmp = x
p = L.index(check)
l = len(L)
roop = l - p
if k < p:
    print(L[k])
else:
    k -= p
    k %= roop
    print(L[p + k])

Choices:
- Compile Error
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
a, b, n = map(int, input().split())
ans = 0
for x in range(1, min(b,n) + 1):
    fx = int(a*x/b) - a * int(x/b)
    if ans < fx:
        ans = fx
print(ans)

Choices:
- Internal error
- Memory Limit Exceeded
- Time Limit Exceeded
- Compile Error


Question:
a, b, n = map(int, input().split())
fx = [int(a*x/b) - a * int(x/b) for x in range(1, n+1)]
print(max(fx))

Choices:
- Internal error
- No abnormally found
- Runtime Error
- Time Limit Exceeded


Question:
import math
a, b, n = map(int, input().split())
ans = -100
for x in range(1, n+1):
    fx = math.floor(a*x/b) - a * math.floor(x/b)
    if ans < fx:
        ans = fx
print(ans)

Choices:
- Compile Error
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question:
N = int(input())
S = [input() for _ in range(N)]
list = []
for i in range(N):
    if not S[i] in list:
        list.append(S[i])
print(len(list))

Choices:
- No abnormally found
- Compile Error
- Time Limit Exceeded
- Internal error


Question:
S = list(input().split())
if S[2] == S[3] or S[4] == S[5]:
  print("Yes")
else:
  print("No")

Choices:
- No abnormally found
- Runtime Error
- Time Limit Exceeded
- Compile Error


Question:
s = input().split()
n = int(s[3])
l1=[1]*int(s[0])
l2=[0]*int(s[1])
l3=[-1]*int(s[2])
l=l1+l2+l3
sum_=0
i=0
while i < n:
    sum_+=l[i]

    i += 1
print(sum_)

Choices:
- Internal error
- No abnormally found
- Memory Limit Exceeded
- Runtime Error


Question:
s = input().split()
n = int(s[3])

l1=[1]*int(s[0])
l2=[0]*int(s[1])
l3=[-1]*int(s[2])
l=l1+l2+l3
sum_=0
i=0
while i < n:
    sum_+=l[i]

    i += 1
print(sum_)

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Internal error
- Runtime Error


Question:
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])
~

Choices:
- Runtime Error
- Memory Limit Exceeded
- Internal error
- Compile Error


Question:
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
new_l= np.array([A[0]])
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l=np.append(new_l,A[new_l[r]-1])
    i+=1

index = np.where(new_l == target)
index=list(index)[0][0]
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])

Choices:
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded
- Internal error


Question:
N, K = map(int, input().split())
A = list(map(int, input().split()))
new_l=[A[0]]
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l.append(A[new_l[r]-1])
    i+=1

index = new_l.index(target)
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])

Choices:
- Runtime Error
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question: 4 2000

Choices:
- Compile Error
- Memory Limit Exceeded
- Internal error
- Runtime Error


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
i = 0
j = 0
for _ in range(n + m):
    if i > len(a) - 1:
        time += b[j]
        j += 1
    elif j > len(b) -1 :
        time += a[i]
        i += 1
    elif i > len(a)-1 and j > len(b)-1:
        break
    else:
        if a[i] < b[j]:
            time += a[i]
            i +=1
        elif a[i] > b[j]:
            time += b[j]
            j +=1
        else:
            time += a[i]
            if a[i + 1] < b[j+1]:
                i += 1
            else:
                j += 1
    if time > k:
        break
    else:
        count += 1
print(count)

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Memory Limit Exceeded


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
i = 0
j = 0
for _ in range(n + m):
    if a[i] < b[j]:
        time += a[i]
        i +=1
    elif a[i] > b[j]:
        time += b[j]
        j +=1
    else:
        time += a[i]
        if a[i + 1] < b[j+1]:
            i += 1
        else:
            j += 1
    if time > k:
        break
    else:
        count += 1
print(count)

Choices:
- Time Limit Exceeded
- Compile Error
- Internal error
- Runtime Error


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(n + m):
    if len(a) > 0 and len(b)>0:
        if a[0] < b[0]:
            time += a[0]
            a = a[1:]
        else:
            time += b[0]
            b = b[1:]
    elif len(a) == 0 and len(b) > 0:
        time += b[0]
        b = b[]
    elif len(b) == 0 and len(a) > 0:
        time += a[0]
        a = a[:-1]
    if time > k:
        break
    else:
        count += 1

print(count)

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Time Limit Exceeded


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(n + m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0 and len(b) > 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0 and len(a) > 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        break
    else:
        count += 1

print(count)

Choices:
- Compile Error
- Runtime Error
- Memory Limit Exceeded
- Internal error


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(n * m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        print(count)
        break
    else:
        count += 1

Choices:
- Memory Limit Exceeded
- Internal error
- Runtime Error
- Compile Error


Question:
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(N * M):
    if a[-1] < b[-1]:
        time += a[-1]
        a = a[:-1]
    else:
        time += b[-i-1]
        b = b[:-1]
    if time > k:
        print(count)
        break
    else:
        count += 1

Choices:
- Compile Error
- Memory Limit Exceeded
- No abnormally found
- Runtime Error


Question:
n = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1 * j

    return table

a = sum(num_divisors_table(n))
print(a)

Choices:
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded
- Runtime Error


Question:
n = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table

a = num_divisors_table(n)
b = 0
for i in range(1, n+1):
    b += i * a[i]
print(b)

Choices:
- Compile Error
- Time Limit Exceeded
- Internal error
- No abnormally found


Question:
n = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

count = 0
for i in range(1, n + 1):
    count += i * len(make_divisors(i))
print(count)

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- No abnormally found
- Compile Error


Question:
import sympy

n = int(input())

count = 0
for i in range(1, n + 1):
    count += i * len(sympy.divisors(i))
print(count)

Choices:
- Compile Error
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
n = int(input())

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

count = 0
for i in range(1, n + 1):
    count += i * len(make_divisors(i))

print(count)

Choices:
- Runtime Error
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question:
a = list(map(int, input().split()))
count = 1
for i in a:
    count *= i
if count > 10 ** 18:
    print(-1)
else:
    print(count)

Choices:
- Memory Limit Exceeded
- Internal error
- Runtime Error
- Compile Error


Question:
 = input()

A, B, C, K = map(int, a.split())

if A >= K:
  print(K)
elif A + B >= K > A:
  print(A)
else:
  print(- B - C +K)

Choices:
- Runtime Error
- No abnormally found
- Compile Error
- Memory Limit Exceeded


Question:
 = input()

A, B, C, K = map(int, a.split())

if A >= K:
  print(A)
elif A + B >= K > A:
  print(A)
else:
  print(- B - C +K)

Choices:
- Runtime Error
- Compile Error
- Internal error
- Time Limit Exceeded


Question:
from math import gcd
N=int(input())
A=list(map(int,input().split()))
l=[0]*1000001
pr=[]
for i in range(2,1000001):
    if l[i]:
        continue
    pr.append(i)
    for j in range(i**2,1000001,i):
        l[j]=1
lp=len(pr)
l=[0]*lp
g=gcd(A[0],A[1])
for i in A:
    g=gcd(g,i)
if g>1:
    print("not coprime")
    exit()
for i in A:
    t=i
    for j in range(lp):
        pj=pr[j]
        if pj>t:
            break
        if t%pj==0:
            if l[j]:
                print("setwise coprime")
                exit()
            l[j]=1
            while 1:
                t//=pj
                if t%pj:
                    break
print("pairwise coprime")

Choices:
- Time Limit Exceeded
- Internal error
- No abnormally found
- Compile Error


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
cx,cy=map(lambda x: int(x)+1,input().split())
dx,dy=map(lambda x: int(x)+1,input().split())
S=["#"*(W+4)]*2+["##"+input()+"##" for i in range(H)]+["#"*(W+4)]*2
l=[[-2]*(W+4) for i in range(H+4)]
for i in range(2,H+2):
    for j in range(2,W+2):
        if S[i][j]==".":
            l[i][j]=-1
l[cx][cy]=0
b=[(cx,cy)]
bb=[(cx,cy)]
t=0
while bb:
    while b:
        a=[]
        for i in b:
            if l[i[0]+1][i[1]]==-1:
                l[i[0]+1][i[1]]=t
                a.append((i[0]+1,i[1]))
            if l[i[0]-1][i[1]]==-1:
                l[i[0]-1][i[1]]=t
                a.append((i[0]-1,i[1]))
            if l[i[0]][i[1]+1]==-1:
                l[i[0]][i[1]+1]=t
                a.append((i[0],i[1]+1))
            if l[i[0]][i[1]-1]==-1:
                l[i[0]][i[1]-1]=t
                a.append((i[0],i[1]-1))
        bb+=a
        b=a
    aa=[]
    t+=1
    b=[]
    for i in bb:
        for j in range(-2,3):
            for k in range(-2,3):
                if l[i[0]+j][i[1]+k]==-1:
                    l[i[0]+j][i[1]+k]=t
                    aa.append((i[0]+j,i[1]+k))
                    b.append((i[0]+j,i[1]+k))
    if l[dx][dy]>=0:
        break
    bb=aa
print(l[dx][dy])

Choices:
- No abnormally found
- Compile Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
H,N=map(int,input().split())
l=[1000000000]*(H+1)
l[0]=0
for i in range(N):
    A,B=map(int,input().split())
    for j in range(1,A+1):
        if l[j]>B:
            l[j]=B
    for j in range(H):
        if j+A<=H:
            if l[j]+B<l[j+A]:
                l[j+A]=l[j]+B
print(l[-1])

Choices:
- Compile Error
- No abnormally found
- Runtime Error
- Internal error


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
N,A,B=map(int,input().split())
if (B-A)%2==0:5 2
    print((B-A)//2)
else:
    print(min(B-1,N-A))

Choices:
- Time Limit Exceeded
- Runtime Error
- Internal error
- Compile Error


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A=list(map(int,input().split()))
l=[0]*59
for i in A:
    s=str(bin(i))[2:]
    for j in range(len(s)):
        if s[-j-1]=="1":
            l[j]+=1
a=0
for i in range(59):
    a=(a+2**i*l[i]*(N-l[i]))%(10**9+7)
print(a)

Choices:
- No abnormally found
- Internal error
- Compile Error
- Runtime Error


Question:
from bisect import insort_left
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for _ in range(M):
    m=A.pop(-1)
    insort_left(A,m//2)
print(sum(A))

Choices:
- Runtime Error
- Internal error
- No abnormally found
- Time Limit Exceeded


Question:
N,Q=map(int,input().split())
l=[[1,0,0]]
for i in range(1,N):
    a,b=map(int,input().split())
    l.append([b,a,0])
l.sort()
for i in range(Q):
    p,x=map(int,input().split())
    l[p-1][2]+=x
t=[l[0][2]]
for i in range(1,N):
    t.append(t[l[i][1]-1]+l[i][2])
print(*t)

Choices:
- Internal error
- No abnormally found
- Compile Error
- Runtime Error


Question:
N, M= map(int, input().split())
B=[]
for i in range(N):
    B.append([None]*2)
    l=input().split()
    B[i][0]=int(l[1])
    B[i][1]=int(l[0])
B.sort(reverse=True)
h=[False]*(M+1)
a=0
d=M+1
for i in range(N):
    if d>B[i][1]:
      for j in range(B[i][1],d):
        if h[j]==False:
            h[j]=True
            a+=B[i][0]
            break
      else:
        d=B[i][1]
print(a)

Choices:
- Compile Error
- No abnormally found
- Runtime Error
- Time Limit Exceeded


Question:
N, M= map(int, input().split())
B=[]
for i in range(N):
    B.append([None]*2)
    l=input().split()
    B[i][0]=int(l[1])
    B[i][1]=int(l[0])
B.sort(reverse=True)
h=[0]*(M+1)
a=0
d=M+1
for i in range(N):
    if d>B[i][1]:
      for j in range(B[i][1],d):
        if h[j]==0:
            h[j]=1
            a+=B[i][0]
            break
      else:
        d=B[i][1]
print(a)

Choices:
- Time Limit Exceeded
- Runtime Error
- No abnormally found
- Memory Limit Exceeded


Question:
N, M= map(int, input().split())
B=[]
for i in range(N):
    B.append([None]*2)
    l=input().split()
    B[i][0]=int(l[1])
    B[i][1]=int(l[0])
B.sort(reverse=True)
h=[0]*(M+1)
a=0
d=M+1
for i in range(N):
    for j in range(B[i][1],d):
        if h[j]==0:
            h[j]=1
            a+=B[i][0]
            break
    else:
        d=B[i][1]
print(a)

Choices:
- Internal error
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
N, M= map(int, input().split())
B=[]
for i in range(N):
    B.append([None]*2)
    l=input().split()
    B[i][0]=int(l[1])
    B[i][1]=int(l[0])
B.sort(reverse=True)
h=[0]*(M+1)
a=0
for i in range(N):
    for j in range(B[i][1],M+1):
        if h[j]==0:
            h[j]=1
            a+=B[i][0]
            break
print(a)

Choices:
- Compile Error
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
s=[[]for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x: int(x)-1,input().split())
    s[a].append(b)
    s[b].append(a)
sys.setrecursionlimit(300000)
l=[None]*N
l[0]=0
def hu(n,c):
    for i in s[n]:
        if l[i]==None:
            l[i]=c
            hu(i,c+1)
hu(0,1)
t=l.index(max(l))
l=[None]*N
l[t]=0
hu(t,1)
if max(l)%3==1:
    print("Second")
else:
    print("First")

Choices:
- Compile Error
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded


Question:
N,Q=map(int,input().split())
S=input()
L=[]
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        L.append(i+1)
n=len(L)
for i in range(Q):
    l,r=map(int,input().split())
    a=0
    for j in range(n):
        if l<=L[j]<r:
            a+=1
    print(a)

Choices:
- Memory Limit Exceeded
- Internal error
- Time Limit Exceeded
- No abnormally found


Question:
N=int(input())
pr=10**9+7
a=0
l=[0]*N
C=[int(input())-1 for i in range(N)]
for i in range(N-1):
    if C[i]==C[i+1]:
        continue
    a,l[C[i]]=(l[C[i]]+a)%pr,(l[C[i]]+a+1)%pr
a+=l[C[-1]]
print((a+1)%pr)

Choices:
- Compile Error
- Runtime Error
- No abnormally found
- Time Limit Exceeded


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
pr=10**9+7
a=0
l=[0]*(N+1)
C=[int(input())-1 for i in range(N)]
for i in range(N-1):
    if C[i]==C[i+1]:
        continue
    a,l[C[i]]=(l[C[i]]+a)%pr,(l[C[i]]+a+1)%pr
a+=l[C[-1]]
print((a+1)%pr)

Choices:
- Runtime Error
- Compile Error
- Memory Limit Exceeded
- No abnormally found


Question:
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
pr=10**9+7
a=0
l=[0]*N
C=[int(input())-1 for i in range(N)]
for i in range(N-1):
    if C[i]==C[i+1]:
        continue
    a,l[C[i]]=(l[C[i]]+a)%pr,(l[C[i]]+a+1)%pr
a+=l[C[-1]]
print((a+1)%pr)

Choices:
- No abnormally found
- Compile Error
- Memory Limit Exceeded
- Runtime Error


Question:
from math import gcd
N=int(input())
A=list(map(int,input().split()))
g=gcd(A[0],A[1])
for i in range(2,N):
        g=gcd(g,A[i])
print(g)

Choices:
- Runtime Error
- Memory Limit Exceeded
- No abnormally found
- Compile Error


Question:
N,M=map(int,input().split())
A=list(map(int,input().split()))
d={2:0,3:0,4:0,5:0,6:0,7:0}
for i in A:
    if i==1:
        d[2]=1
    elif i==7:
        d[3]=7
    elif i==8:
        d[7]=8
    elif i==4:
        d[4]=4
    elif i==6 or i==9:
        if d[6]<i:
            d[6]=i
    else:
        if d[5]<i:
            d[5]=i
l=[]
for i in d.keys():
    if d[i]:
        l.append(i)
l.sort()
a=[]
m=0
if len(l)>=4:
    for i in range(4):
        for j in range(4):
            for k in range(4):
                t=N-i*l[1]-j*l[2]-k*l[3]
                if t%l[0] or t<0:
                    continue
                ke=i+j+k+t//l[0]
                if ke<m:
                    continue
                else:
                    s=[d[l[1]]]*i+[d[l[2]]]*j+[d[l[3]]]*k+[d[l[0]]]*(t//l[0])
                    s.sort(reverse=1)
                    if ke==m:
                        a.append(s)
                    else:
                        a=[s]
                        m=ke
    print(*max(a),sep="")
elif len(l)==3:
    for i in range(5):
        for j in range(5):
            t=(N-i*l[1]-j*l[2])
            if t%l[0] or t<0:
                continue
            ke=i+j+t//l[0]
            if ke<m:
                continue
            else:
                s=[d[l[1]]]*i+[d[l[2]]]*j+[d[l[0]]]*(t//l[0])
                s.sort(reverse=1)
                if ke==m:
                    a.append(s)
                else:
                    a=[s]
                    m=ke
    print(*max(a),sep="")
elif len(l)==2:
    for i in range(6):
        if (N-l[1]*i)%l[0]==0:
            a=[d[l[1]]]*i+[d[l[0]]]*((N-i*l[1])//l[0])
            a.sort(reverse=1)
            print(*a,sep="")
            break
else:
    a=d[l[0]]*(N//l[0])
    print(*a,sep="")

Choices:
- Compile Error
- Internal error
- Runtime Error
- No abnormally found


Question:
N=int(input())
h=list(map(int,input().split()))
t=[0]*N
a=0
for i in range(N):
        while t[i]<h[i]:
                for j in range(i,N):
                        if t[j]<h[j]:
                                t[j]+=1
                        else:
                                break
                a+=1
print(a)

Choices:
- Compile Error
- Runtime Error
- Time Limit Exceeded
- No abnormally found


Question:
N,M=map(int,input().split())
m=M//N
for i in range(m,0,-1):
    if M%i==0:
        print(i)
        break

Choices:
- Internal error
- No abnormally found
- Runtime Error
- Time Limit Exceeded


Question:
6
105 119 105 119 105 119

Choices:
- Memory Limit Exceeded
- No abnormally found
- Internal error
- Runtime Error


Question:
K=int(input())
A=list(map(int,input().split()))
mb=Mb=2
t=1
for i in A[::-1]:
    if Mb//i*i>=mb:
        Ma=(Mb//i+1)*i-1
    else:
        t=0
    if mb%i==0:
        ma=mb
    elif (mb//i+1)*i<=Mb:
        ma=(mb//i+1)*i
    else:
        t=0
    mb=ma
    Mb=Ma
if t:
    print(ma,Ma)
else:
    print(-1)

Choices:
- Memory Limit Exceeded
- Runtime Error
- No abnormally found
- Compile Error


Question:
import fractions
def lcm(a, b):
    y = a*b / fractions.gcd(a, b)
    return int(y)
N=int(input())
T = [int(input()) for i in range(N)]
if N==1:
    t=T[0]
else:
    t=lcm(T[0],T[1])
    if N>2:
        for i in range(1,N):
            t=lcm(t,T[i])
print(t)

Choices:
- No abnormally found
- Compile Error
- Internal error
- Runtime Error


Question:
import fractions
def lcm(a, b):
    y = a*b / fractions.gcd(a, b)
    return int(y)
N=int(input())
T = [int(input()) for i in range(N)]
t=lcm(T[0],T[1])
for i in range(1,N):
    t=lcm(t,T[i])
print(t)

Choices:
- Runtime Error
- Time Limit Exceeded
- Compile Error
- No abnormally found


Question:
import numpy as np
i8 = np.int64
i4 = np.int32

def calc(dp1, dp2, k):
    dp2[k:] += dp1[:dp1.shape[0]-k]
    dp2[:dp2.shape[0]-k] += dp1[k:]

def solve(z, dp):
    zero = dp.shape[2] // 2
    dp[0, 0, zero + z[0, 0]] = 1
    dp[0, 0, zero - z[0, 0]] = 1
    for x in range(1, z.shape[1]):
        calc(dp[0, x - 1], dp[0, x], z[0, x])
    for y in range(1, z.shape[0]):
        calc(dp[y - 1, 0], dp[y, 0], z[y, 0])
        for x in range(1, z.shape[1]):
            calc(dp[y, x - 1], dp[y, x], z[y, x])
            calc(dp[y - 1, x], dp[y, x], z[y, x])
    for i in range(zero, dp.shape[2]):
        if dp[dp.shape[0] - 1, dp.shape[1] - 1, i] > 0:
            return i - zero
    return -1

def main2():
    stdin = open('/dev/stdin')
    H, W = map(int, stdin.readline().split())
    a = np.empty((H, W), i8)
    b = np.empty((H, W), i8)
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            a[i, j] = c
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            b[i, j] = c
    z = np.abs(a - b)
    if H > W:
        z = z.T.copy()
    dp = np.zeros((H, W, 80 * 80 * 80*2 + 1), i8)
    ans = solve(z, dp)
    print(ans)

main2()

Choices:
- Internal error
- Compile Error
- Runtime Error
- Memory Limit Exceeded


Question:
import numpy as np
i8 = np.int64
i4 = np.int32

def calc(dp1, dp2, k):
    dp2[k:] += dp1[:-k]
    dp2[:-k] += dp1[k:]

def solve(z, dp):
    zero = dp.shape[2] // 2
    dp[0, 0, zero + z[0, 0]] = 1
    dp[0, 0, zero - z[0, 0]] = 1
    for x in range(1, z.shape[1]):
        calc(dp[0, x - 1], dp[0, x], z[0, x])
    for y in range(1, z.shape[0]):
        calc(dp[y - 1, 0], dp[y, 0], z[y, 0])
        for x in range(1, z.shape[1]):
            calc(dp[y, x - 1], dp[y, x], z[y, x])
            calc(dp[y - 1, x], dp[y, x], z[y, x])
    for i in range(zero, dp.shape[2]):
        if dp[dp.shape[0] - 1, dp.shape[1] - 1, i] > 0:
            return i - zero
    return -1

def main2():
    stdin = open('/dev/stdin')
    H, W = map(int, stdin.readline().split())
    a = np.empty((H, W), i8)
    b = np.empty((H, W), i8)
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            a[i, j] = c
    for i in range(H):
        for j, c in enumerate(map(int, stdin.readline().split())):
            b[i, j] = c
    z = np.abs(a - b)
    if H > W:
        z = z.T.copy()
    dp = np.zeros((H, W, 80 * 80 * 80*2 + 1), i8)
    ans = solve(z, dp)
    print(ans)

main2()

Choices:
- Runtime Error
- Memory Limit Exceeded
- Compile Error
- No abnormally found


Question:
from fractions import gcd

def main():
    def fmin(m):
        return X * m + D * m *(m - 1)//2
    def fmax(m):
        return X * m + D * m * (2 * N - m - 1) // 2
    N, X, D = map(int, input().split())
    if D == 0:
        if X == 0:
            print(1)
        else:
            print(N + 1)
        exit(0)
    if D < 0:
        X, D = -X, -D
    if X > 0:
        ans = 0
        g = gcd(X, D)
        loop = D // g
        for d in range(N + 1):
            if loop <= d:
                mmin = max(fmin(d), fmax(d - loop) + D)
            else:
                mmin = fmin(d)
            mmax = fmax(d)
            ans += (mmax - mmin) // D + 1
        print(ans)
    elif X == 0:
        print(fmax(N) // D + 1)
    else:
        if X + D*(N - 1) >= 0:
            print(N // 0)
        else:
            ans = 0
            g = gcd(-X, D)
            loop = D // g
            for d in range(N + 1):
                if loop <= d:
                    mmax = min(fmax(d), fmin(d - loop) - D)
                else:
                    mmax = fmax(d)
                mmin = fmin(d)
                ans += (mmax - mmin) // D + 1
            print(ans)

if __name__ == '__main__':
    main()

Choices:
- Internal error
- Time Limit Exceeded
- Runtime Error
- No abnormally found


Question:
from fractions import gcd

def main():
    def fmin(m):
        return X * m + D * m *(m - 1)//2
    def fmax(m):
        return X * m + D * m * (2 * N - m - 1) // 2
    N, X, D = map(int, input().split())
    if D == 0:
        if X == 0:
            print(1)
        else:
            print(N + 1)
    if D < 0:
        X, D = -X, -D
    if X > 0:
        ans = 0
        g = gcd(X, D)
        loop = D // g
        for d in range(N + 1):
            if loop <= d:
                mmin = max(fmin(d), fmax(d - loop) + D)
            else:
                mmin = fmin(d)
            mmax = fmax(d)
            ans += (mmax - mmin) // D + 1
        print(ans)
    elif X == 0:
        print(fmax(N) // D + 1)
    else:
        ans = 0
        g = gcd(-X, D)
        loop = D // g
        for d in range(N + 1):
            if loop <= d:
                mmax = min(fmax(d), fmin(d - loop) - D)
            else:
                mmax = fmax(d)
            mmin = fmin(d)
            ans += (mmax - mmin) // D + 1
        print(ans)

if __name__ == '__main__':
    main()

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Compile Error


Question:
from fractions import gcd

def main():
    def fmin(m):
        return X * m + D * m *(m - 1)//2
    def fmax(m):
        return X * m + D * m * (2 * N - m - 1) // 2
    N, X, D = map(int, input().split())
    if D < 0:
        X, D = -X, -D
    if X > 0:
        ans = 0
        g = gcd(X, D)
        loop = D // g
        for d in range(N + 1):
            if loop <= d:
                mmin = max(fmin(d), fmax(d - loop) + D)
            else:
                mmin = fmin(d)
            mmax = fmax(d)
            ans += (mmax - mmin) // D + 1
        print(ans)
    elif X == 0:
        print(fmax(N) // D + 1)
    else:
        ans = 0
        g = gcd(-X, D)
        loop = D // g
        for d in range(N + 1):
            if loop <= d:
                mmax = min(fmax(d), fmin(d - loop) - D)
            else:
                mmax = fmax(d)
            mmin = fmin(d)
            ans += (mmax - mmin) // D + 1
        print(ans)

if __name__ == '__main__':
    main()

Choices:
- Time Limit Exceeded
- Internal error
- Compile Error
- Runtime Error


Question:
import numpy as np

def solve(A, F, K):
    lo = 0
    hi = 10 ** 12
    while lo < hi:
        mid = (lo + hi) // 2
        total_train = 0
        for i in range(A.shape[0]):
            need = A[i] - mid // F[i]
            total_train += need if need > 0 else 0
        if total_train <= K:
            hi = mid
        else:
            lo = mid + 1
    return lo

stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
N, K = stdin[:2]
A = stdin[2: 2 + N]
F = stdin[2 + N:]
print(solve(np.sort(A)[::-1], np.sort(F), K))

Choices:
- No abnormally found
- Time Limit Exceeded
- Internal error
- Compile Error


Question:
mod = 10**9 + 7

def solve(now, from_, K, ab):
    if from_ == -1:
        can_num = K - 1
    else:
        can_num = K - 2
    if K < len(ab[now]):
        return 0
    case_num = 1
    for i in ab[now]:
        if i != from_:
            case_num *= can_num
            can_num -= 1
            case_num %= mod
    for i in ab[now]:
        if i != from_:
            case_num *= solve(i, now, K, ab)
            case_num %= mod
    return case_num

def main():
    N, K = map(int, input().split())
    if N == 1:
        print(K)
        exit(0)
    ab = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        ab[a - 1].append(b - 1)
        ab[b - 1].append(a - 1)
    ans = K * solve(0, -1, K, ab)
    print(ans % mod)

if __name__ == "__main__":
    main()

Choices:
- No abnormally found
- Memory Limit Exceeded
- Compile Error
- Runtime Error


Question:
import numpy as np
mod = 10**9 + 7

def solve(now, from_, K, pa, b):
    if from_ == -1:
        can_num = K - 1
    else:
        can_num = K - 2
    if K < pa[now + 1] - pa[now]:
        return 0
    case_num = 1
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= can_num
            can_num -= 1
            case_num %= mod
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= solve(b[i], now, K, pa, b)
            case_num %= mod
    return case_num

def main():
    N, K = map(int, input().split())
    if N == 1:
        print(K)
        exit(0)
    ab = np.array([list(map(int, input().split())) for _ in range(N - 1)], dtype=np.int32)
    ab = (ab - 1).T
    ab = np.hstack((ab, ab[[1, 0]]))
    ab = ab[:, np.argsort(ab[0])]
    pa = np.unique(ab[0], return_index=True)[1]
    pa = np.append(pa, 2 * (N - 1))
    ans = K * solve(0, -1, K, pa, ab[1])
    print(ans % mod)

if __name__ == "__main__":
    main()

Choices:
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded
- Runtime Error


Question:
import numpy as np
mod = 10**9 + 7

def solve(now, from_, K, pa, b):
    if from_ == -1:
        can_num = K - 1
    else:
        can_num = K - 2
    if K < pa[now + 1] - pa[now]:
        return 0
    case_num = 1
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= can_num
            can_num -= 1
            case_num %= mod
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= solve(b[i], now, K, pa, b)
            case_num %= mod
    return case_num

def main():
    N, K = map(int, input().split())
    ab = np.array([list(map(int, input().split())) for _ in range(N - 1)], dtype=np.int32)
    ab = (ab - 1).T
    ab = np.hstack((ab, ab[[1, 0]]))
    ab = ab[:, np.argsort(ab[0])]
    pa = np.unique(ab[0], return_index=True)[1]
    pa = np.append(pa, 2 * (N - 1))
    ans = K * solve(0, -1, K, pa, ab[1])
    print(ans % mod)

if __name__ == "__main__":
    main()

Choices:
- Runtime Error
- No abnormally found
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import numpy as np
mod = 10**9 + 7

def solve(now, from_, K, pa, b):
    if from_ == -1:
        can_num = K - 1
    else:
        can_num = K - 2
    if K < pa[now + 1] - pa[now]:
        return 0
    case_num = 1
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= can_num
            can_num -= 1
            case_num %= mod
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= solve(b[i], now, K, pa, b)
            case_num %= mod
    return case_num

def main():
    N, K = map(int, input().split())
    ab = np.array([list(map(int, input().split())) for _ in range(N - 1)], dtype=np.int32)
    ab = ab - 1
    ab = np.hstack((ab, ab[[1, 0]]))
    ab = ab[:, np.argsort(ab[0])]
    pa = np.unique(ab[0], return_index=True)[1]
    pa = np.append(pa, 2 * (N - 1))
    ans = K * solve(0, -1, K, pa, ab[1])
    print(ans % mod)

if __name__ == "__main__":
    main()

Choices:
- No abnormally found
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error


Question:
import sys
import numpy as np

i8 = np.int64
i4 = np.int32
mod = 10**9 + 7

def solve(now, from_, K, pa, b):
    if from_ == -1:
        can_num = K - 1
    else:
        can_num = K - 2
    if K < pa[now + 1] - pa[now]:
        return 0
    case_num = i8(1)
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= can_num
            can_num -= 1
            case_num %= mod
    for i in range(pa[now], pa[now + 1]):
        if b[i] != from_:
            case_num *= solve(b[i], now, K, pa, b)
            case_num %= mod
    return case_num

def main():
    pin = np.fromstring(sys.stdin.buffer.read(), dtype=i4, sep=' ')
    N = pin[0]
    K = pin[1]
    ab = pin[2:2 * N].reshape(N - 1, 2).T
    ab = ab - 1
    ab = np.hstack((ab, ab[[1, 0]]))
    ab = ab[:, np.argsort(ab[0])]
    pa = np.unique(ab[0], return_index=True)[1]
    pa = np.append(pa, 2 * (N - 1))
    ans = K * solve(0, -1, K, pa, ab[1])
    print(ans % mod)

if __name__ == "__main__":
    main()

Choices:
- Internal error
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
import sys

def calc(a, H, W):
    # 横方向
    for j in range(H):
        prev = 0
        start = 0
        for i in range(W + 1):
            if a[j][i] > 0:
                if prev == 0:
                    start = i
                    prev = 1
            else:
                if prev == 1:
                    num = i - start
                    for k in range(start, i):
                        a[j][k] = num
                    prev = 0
    # 縦方向
    for i in range(W):
        prev = 0
        start = 0
        for j in range(H + 1):
            if a[j][i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    num = j - start
                    for k in range(start, j):
                        a[k][i] += num - 1
                    prev = 0

sin = sys.stdin
H, W = map(int, sin.readline().split())
a = [[0] * (W + 1) for _ in range(H + 1)]

for j in range(H):
    for i, c in enumerate(sin.readline()):
        if c == '.':
            a[j][i] = 1

calc(a, H, W)

ans = 0
for row in a:
    ans = max(ans, max(row))
print(ans)

Choices:
- No abnormally found
- Time Limit Exceeded
- Runtime Error
- Compile Error


Question:
import numpy as np
import sys

def calc(a, H, W):
    # 横方向
    for j in range(H):
        prev = 0
        start = 0
        for i in range(W + 1):
            if a[j, i] > 0:
                if prev == 0:
                    start = i
                    prev = 1
            else:
                if prev == 1:
                    num = i - start
                    a[j, start:i] = num
                    prev = 0
    # 縦方向
    for i in range(W):
        prev = 0
        start = 0
        for j in range(H + 1):
            if a[j, i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    num = j - start - 1
                    a[start:j, i] += num
                    prev = 0

def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr

def main():
    H, W, arr = get_data(sys.stdin)
    a = np.zeros((H + 1, W + 1), dtype='i8')
    a[:-1, :-1] = arr == b'.'

    calc(a, H, W)
    print(a.max())

if __name__ == "__main__":
    main()

Choices:
- Time Limit Exceeded
- Internal error
- Runtime Error
- Memory Limit Exceeded


Question:
import numpy as np
import sys

def calc(a, H, W):
    # 横方向
    for j in range(H):
        prev = 0
        start = 0
        for i in range(W + 1):
            if a[j, i] > 0:
                if prev == 0:
                    start = i
                    prev = 1
            else:
                if prev == 1:
                    num = i - start
                    a[j, start:i] = num
                    prev = 0
    # 縦方向
    for i in range(W):
        prev = 0
        start = 0
        for j in range(H + 1):
            if a[j, i] > 0:
                if prev == 0:
                    start = j
                    prev = 1
            else:
                if prev == 1:
                    num = j - start - 1
                    a[start:j, i] += num
                    prev = 0

def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr

def main():
    start = time.time()
    H, W, arr = get_data(sys.stdin)
    a = np.zeros((H + 1, W + 1), dtype='i8')
    a[:-1, :-1] = arr == b'.'
    end = time.time()
    print(end - start)

    calc(a, H, W)
    print(a.max())

if __name__ == "__main__":
    main()

Choices:
- Runtime Error
- Time Limit Exceeded
- Internal error
- No abnormally found


Question:
#include <bits/stdc++.h>
using namespace std;
int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H + 1, vector<int>(W + 1));
    for(int i = 0; i < W + 1; i++){
        a.at(H).at(i) = 0;
    }
    for(int j = 0; j < H; j++){
        string str;
        cin >> str;
        a.at(j).at(W) = 0;
        for(int i = 0; i < W; i++){
            if(str.at(i) == '.')
                a.at(j).at(i) = 1;
            else
                a.at(j).at(i) = 0;
        }
    }

    //横方向
    for(int j = 0; j < H; j++){
        int prev = 0;
        int start = 0;
        for(int i = 0; i < W + 1; i++){
            if (a.at(j).at(i) > 0){
                if(prev == 0){
                    start = i;
                    prev = 1;
                }
            }else{
                if(prev == 1){
                    int num = i - start;
                    for(int k = start; k < i; k++){
                        a.at(j).at(k) = num;
                    }
                    prev = 0;
                }
            }
        }
    }

    //縦方向
    for(int i = 0; i < W; i++){
        int prev = 1;
        int start = 0;
        for(int j = 0; j < H + 1; j++){
            if (a.at(j).at(i) > 0){
                if(prev == 0){
                    start = j;
                    prev = 1;
                }
            }else{
                if(prev == 1){
                    int num = j - start;
                    for(int k = start; k < j; k++){
                        a.at(k).at(i) += num - 1;
                    }
                    prev = 0;
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < H; j++){
        int m1 = *max_element(a.at(j).begin(), a.at(j).end());
        ans = max(ans, m1);
    }
    cout << ans << endl;
}

Choices:
- Runtime Error
- No abnormally found
- Internal error
- Time Limit Exceeded


Question:
#include <bits/stdc++.h>
using namespace std;
int H, W;

int main() {
    cin >> H >> W;
    vector<vector<int>> a(H + 1, vector<int>(W + 1));
    vector<vector<int>> b(H + 1, vector<int>(W + 1, 0));
    for(int i = 0; i < W + 1; i++){
        a.at(H).at(i) = 1;
    }
    for(int j = 0; j < H; j++){
        string str;
        cin >> str;
        a.at(j).at(W) = 1;
        for(int i = 0; i < W; i++){
            if(str.at(i) == '.')
                a.at(j).at(i) = 0;
            else
                a.at(j).at(i) = 1;
        }
    }

    //横方向
    for(int j = 0; j < H; j++){
        int prev = 1;
        int start = 0;
        for(int i = 0; i < W + 1; i++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = i;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = i - start;
                    for(int k = start; k < i; k++){
                        b.at(j).at(k) = num;
                    }
                    prev = 1;
                }
            }
        }
    }

    //縦方向
    for(int i = 0; i < W; i++){
        int prev = 1;
        int start = 0;
        for(int j = 0; j < H + 1; j++){
            if (a.at(j).at(i) == 0){
                if(prev == 1){
                    start = j;
                    prev = 0;
                }
            }else{
                if(prev == 0){
                    int num = j - start;
                    for(int k = start; k < j; k++){
                        b.at(k).at(i) += num - 1;
                    }
                    prev = 1;
                }
            }
        }
    }

    int ans = 0;
    for(int j = 0; j < H; j++){
        int m1 = *max_element(b.at(j).begin(), b.at(j).end());
        ans = max(ans, m1);
    }
    cout << ans << endl;
}

Choices:
- Memory Limit Exceeded
- Runtime Error
- Internal error
- Compile Error


Question:
import numpy as np

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append([0 if i == "#" else H+W for i in list(input())])
a = np.array(b, dtype='i8')

for i in range(1, H):
    a[i:, :] = np.minimum(a[i:, :], a[i-1:-1, :] + 1)
for i in range(H - 1, 0, -1):
    a[:i, :] = np.minimum(a[:i, :], a[1:i+1, :] + 1)
for j in range(1, W):
    a[:, j:] = np.minimum(a[:,j:], a[:, j-1:-1] + 1)
for j in range(W -1, 0, - 1):
    a[:, :j] = np.minimum(a[:, :j], a[:, 1:j+1] + 1)

print(np.max(a))

Choices:
- Internal error
- No abnormally found
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
import numpy as np

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append([0 if i == "#" else H+W for i in list(input())])
a = np.array(b)

for i in range(1, H):
    a[i:, :] = np.minimum(a[i:, :], a[i-1:-1, :] + 1)
for i in range(H - 1, 0, -1):
    a[:i, :] = np.minimum(a[:i, :], a[1:i+1, :] + 1)
for j in range(1, W):
    a[:, j:] = np.minimum(a[:,j:], a[:, j-1:-1] + 1)
for j in range(W -1, 0, - 1):
    a[:, :j] = np.minimum(a[:, :j], a[:, 1:j+1] + 1)

print(np.max(a))

Choices:
- Memory Limit Exceeded
- Internal error
- Time Limit Exceeded
- No abnormally found


Question:
import numpy as np

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append([0 if i == "#" else H+W for i in list(input())])
a = np.array(b)

for i in range(H - 1):
    a[1:, :] = np.minimum(a[1:, :], a[:-1, :] + 1)
for i in range(H - 1):
    a[:-1, :] = np.minimum(a[:-1, :], a[1:, :] + 1)
for j in range(W - 1):
    a[:, 1:] = np.minimum(a[:,1:], a[:, :-1] + 1)
for j in range(W - 1):
    a[:, :-1] = np.minimum(a[:, :-1], a[:, 1:] + 1)

print(np.max(a))

Choices:
- Time Limit Exceeded
- Compile Error
- Runtime Error
- No abnormally found


Question:
import numpy as np

def func(x):
    if x == '.':
        return 2000
    else:
        return 0

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1:, :] = np.minimum(a[1:, :], a[:-1, :] + 1)
for i in range(H - 1):
    a[:-1, :] = np.minimum(a[:-1, :], a[1:, :] + 1)
for j in range(W - 1):
    a[:, 1:] = np.minimum(a[:,1:], a[:, :-1] + 1)
for j in range(W - 1):
    a[:, :-1] = np.minimum(a[:, :-1], a[:, 1:] + 1)

print(np.max(a))

Choices:
- Time Limit Exceeded
- Compile Error
- Memory Limit Exceeded
- No abnormally found


Question:
import numpy as np

def func(x):
    if x == '.':
        return 2000
    else:
        return 0

H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1+i:, :] = np.minimum(a[1+i:, :], a[i:-1, :] + 1)
for i in range(H - 1):
    a[:-1-i, :] = np.minimum(a[:-1-i, :], a[1:H-i, :] + 1)
for j in range(W - 1):
    a[:, 1+j:] = np.minimum(a[:, 1+j:], a[:, j:-1] + 1)
for j in range(W - 1):
    a[:, :-1-j] = np.minimum(a[:, :-1-j], a[:, 1:W-j] + 1)

print(np.max(a))

Choices:
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error


Question:
import numpy as np

def func(x):
    if x == '.':
        return 2000
    else:
        return 0

H, W = map(int, input().split())
b = []
for _ in range(W):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1+i:, :] = np.minimum(a[1+i:, :], a[i:-1, :] + 1)
for i in range(H - 1):
    a[:-1-i, :] = np.minimum(a[:-1-i, :], a[1:H-i, :] + 1)
for j in range(W - 1):
    a[:, 1+j:] = np.minimum(a[:, 1+j:], a[:, j:-1] + 1)
for j in range(W - 1):
    a[:, :-1-j] = np.minimum(a[:, :-1-j], a[:, 1:W-j] + 1)

print(np.max(a))

Choices:
- Internal error
- Memory Limit Exceeded
- Runtime Error
- No abnormally found


Question:
import numpy as np

def func(x):
    if x == '.':
        return 2000
    else:
        return 0

H, W = map(int, input().split())
b = []
for _ in range(W):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1+i:, :] = np.minimum(a[1+i:, :], a[i:-1, :] + 1)
for i in range(H - 1):
    a[:-1-i, :] = np.minimum(a[:-1-i, :], a[1:H-i, :] + 1)
for j in range(W - 1):
    a[:, 1+j:] = np.minimum(a[:, 1+j:], a[:, j:-1] + 1)
for j in range(W - 1):
    a[:, :-1-j] = np.minimum(a[:, :-1-j], a[:, 1:W-j] + 1)

print(max(a))

Choices:
- Memory Limit Exceeded
- No abnormally found
- Internal error
- Runtime Error


Question:
import numpy as np

def func(x):
    if x == '.':
        return 2000
    else:
        return 0

H, W = map(int, input().split())
b = []
for _ in range(W):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1+i:, :] = np.minimum(a[1+i:, :], a[i:-1, :] + 1)
for i in range(H - 1):
    a[:-1-i, :] = np.minimum(a[:-1-i, :], a[1:H-i, :] + 1)
for j in range(W - 1):
    a[:, 1+j:] = np.minimum(a[:, 1+j:], a[:, j:-1] + 1)
for j in range(W - 1):
    a[:, :-1-j] = np.minimum(a[:, :-1-j], a[:, 1:H-j] + 1)

print(np.max(a))

Choices:
- Runtime Error
- Internal error
- Memory Limit Exceeded
- Compile Error


Question:
from collections import deque

H, W = map(int, input().split())
a = [[0] * W for _ in range(H)]
q = deque([])
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            a[i][j] = 1
            q.appendleft((i, j, 0))

while True:
    try:
        i, j, val = q.pop()
        if i > 0 and a[i - 1][j] == 0:
            q.appendleft((i - 1, j, val + 1))
            a[i - 1][j] = 1
        if i < H - 1 and a[i + 1][j] == 0:
            q.appendleft((i + 1, j, val + 1))
            a[i + 1][j] = 1
        if j > 0 and a[i][j - 1] == 0:
            q.appendleft((i, j - 1, val + 1))
            a[i][j - 1] = 1
        if j < W - 1 and a[i][j + 1] == 0:
            q.appendleft((i, j + 1, val + 1))
            a[i][j + 1] = 1
    except:
        print(val)
        break

Choices:
- Runtime Error
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded


Question:
import numpy as np

def check(y, x, p):
    l = x - p
    r = x + p
    t = y - p
    b = y + p
    if b < T:
        if a[b, 0 if l < 0 else l: r + 1 if r < T else T].any():
            return True
    if t >= 0:
        if a[t, 0 if l < 0 else l: r + 1 if r < T else T].any():
            return True
    if r < T:
        if a[0 if t < 0 else t: b + 1 if b < T else T, r].any():
            return True
    if l >= 0:
        if a[0 if t < 0 else t: b + 1 if b < T else T, l].any():
            return True
    return False

H, W = map(int, input().split())
T = H + W
a = np.zeros((T, T), dtype=int)
ans = np.zeros((H, W), dtype=int)
for h in range(H):
    s = input()
    for w in range(W):
        if s[w] == '#':
            a[h + w, W + h - w - 1] = 1

for h in range(H):
    if h == 0:
        for w in range(W):
            if w == 0:
                for i in range(H + W):
                    if check(0, W - 1, i):
                        ans[0, 0] = i
                        break
            else:
                p = ans[0, w - 1]
                if p > 0 and check(h + w, W + h - w - 1, p - 1):
                        ans[h, w] = p - 1
                elif check(h + w, W + h - w - 1, p):
                    ans[h, w] = p
                else:
                    ans[h, w] = p + 1

    else:
        for w in range(W):
            if w == 0:
                p = ans[h - 1, 0]
                if p > 0 and check(h + w, W + h - w -1, p - 1):
                        ans[h, w] = p - 1
                elif check(h + w, W + h - w - 1, p):
                    ans[h, w] = p
                else:
                    ans[h, w] = p + 1
            else:
                p1 = ans[h, w - 1]
                p2 = ans[h - 1, w]
                pmax = max(p1, p2)
                pmin = min(p1, p2)
                if pmax - pmin == 2:
                    ans[h, w] = (pmax + pmin) // 2
                elif pmax - pmin == 1:
                    if check(h + w, W + h - w - 1, pmin):
                        ans[h, w] = pmin
                    else:
                        ans[h, w] = pmax
                else:
                    if p1 > 0 and check(h + w, W + h - w - 1, p1 - 1):
                        ans[h, w] = p1 - 1
                    elif check(h + w, W + h - w - 1, p1):
                        ans[h, w] = p1
                    else:
                        ans[h, w] = p1 + 1

print(ans.max())

Choices:
- Runtime Error
- Memory Limit Exceeded
- No abnormally found
- Time Limit Exceeded


Question:
import numpy as np
import sys

X, Y, Z, K = map(int, input().split())
a = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')
b = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')
c = np.array(list(map(int, sys.stdin.readline().split())), dtype='int64')

amax = a.max()
bmax = b.max()
cmax = c.max()

a = amax - a
a.sort()
b = bmax - b
b.sort()
c = cmax - c
c.sort()

def func(o, p):
    min_ = 0
    max_ = o[-1] + p[-1]
    v = (min_ + max_) // 2
    while True:
        mat = np.searchsorted(o, v - p, side='right')
        sum_ = mat.sum()
        if sum_ > K:
            max_ = v - 1
            v = (v + min_) // 2
        elif sum_ == K:
            return v
        else:
            min_ = v + 1
            v = (v + max_ + 1) // 2

if X * Y > K:
    u = func(a, b)
    matr = np.searchsorted(a, u - b, side='right')
    d = np.array([],dtype='int64')
    for i in range(Y):
        d = np.append(d, a[:matr[i]] + b[i])
    d.sort()
else:
    d = (a + b.reshape([len(b), 1])).flatten()
    d.sort()

u = func(d, c)
matr = np.searchsorted(d, u - c, side='right')
e = np.array([],dtype='int64')
for i in range(Z):
    e = np.append(e, d[:matr[i]] + c[i])
e.sort()

t = amax + bmax + cmax
for ec in e:
    print(t - ec)

Choices:
- No abnormally found
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
import numpy as np

X, Y, Z, K = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype='int64')
b = np.array(list(map(int, input().split())), dtype='int64')
c = np.array(list(map(int, input().split())), dtype='int64')

amax = a.max()
bmax = b.max()
cmax = c.max()

a = amax - a
a.sort()
b = bmax - b
b.sort()
c = cmax - c
c.sort()

def func(o, p):
    min_ = 0
    max_ = o[-1] + p[-1]
    v = (min_ + max_) // 2
    while True:
        mat = np.searchsorted(o, v - p, side='right')
        sum_ = mat.sum()
        if sum_ > K:
            max_ = v - 1
            v = (v + min_) // 2
        elif sum_ == K:
            return v
        else:
            min_ = v + 1
            v = (v + max_ + 1) // 2

if X * Y > K:
    u = func(a, b)
    matr = np.searchsorted(a, u - b, side='right')
    d = np.array([],dtype='int64')
    for i in range(Y):
        d = np.append(d, a[:matr[i]] + b[i])
    d.sort()
else:
    d = (a + b.reshape([len(b), 1])).flatten()
    d.sort()

u = func(d, c)
matr = np.searchsorted(d, u - c, side='right')
e = np.array([],dtype='int64')
for i in range(Z):
    e = np.append(e, d[:matr[i]] + c[i])
e.sort()

t = amax + bmax + cmax
for ec in e:
    print(t - ec)

Choices:
- No abnormally found
- Runtime Error
- Time Limit Exceeded
- Compile Error


Question:
iimport re
import functools

N = int(input())
MOD = 10 ** 9 + 7

@functools.lru_cache(maxsize=2**13)
def dfs(cur, last3):
    if cur == N:
        return 1
    ret = 0
    for c in 'ACGT':
        if not re.match('.AGC|.ACG|.GAC|A.GC|AG.C', last3 + c):
            ret += dfs(cur + 1, last3[1:] + c)
    return ret % MOD

print(dfs(0, 'TTT'))

Choices:
- Internal error
- No abnormally found
- Time Limit Exceeded
- Runtime Error


Question:
import sys

N = int(input())
C = [0]
for line in sys.stdin:
    c = int(line)
    if c[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = {}
for c in C:
    if c in dic.keys():
        a = dic[c]
        dic[c] += ans
        ans += a
    else:
        dic[c] = ans

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

Choices:
- Compile Error
- Runtime Error
- Memory Limit Exceeded
- Internal error


Question:
import numpy as np
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c
L = len(C)
A = np.array(C)

ans = 1
f = np.ones(L + 1, dtype="int")
for i in range(2, L):
    ans += np.sum(f[A[:i-1] == A[i]])
    f[i + 1] = ans

print(ans)

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- Internal error


Question:
import numpy as np
import sys

N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(sys.stdin.readline())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c
L = len(C)
A = np.array(C)

ans = 1
f = np.ones(L + 1, dtype="int")
for i in range(2, L):
    g = f[:i-1]
    ans += np.sum(g[A[:i-1] == A[i]])
    f[i + 1] = ans

print(ans)

Choices:
- Time Limit Exceeded
- Compile Error
- No abnormally found
- Runtime Error


Question:
N = int(input())
C = []
pre = 0
for _ in range(N):
    c = int(input())
    if pre == c:
        continue
    else:
        C.append(c)
        pre = c

ans = 1
f = [1] * (N + 1)
for i, c in enumerate(C):
    for j in range(i - 1):
        if C[j] == c:
            ans += f[j]
    f[i + 1] = ans

print(ans)

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- Internal error


Question:
N = int(input())
C = [int(input()) for _ in range(N)]
f = [0] * N

ans = 1
pre = 0
for i, c in enumerate(C):
    if pre == c:
        f[i] = ans
        continue
    else:
        pre = c

    flag = True
    for j in range(i - 1):
        if C[j] == c:
            if flag:
                if j == 0:
                    ans += 1
                else:
                    ans += f[j - 1]
                flag = False
            else:
                continue
        else:
            flag = True
    f[i] = ans

print(ans)

Choices:
- Internal error
- Compile Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
S = input()

num = 0
while True:
    p = S.find('01')
    if p > -1:
        S = S[:p] + S[p + 2:]
        num += 2
    else:
        break
while True:
    p = S.find('10')
    if p > -1:
        S = S[:p] + S[p + 2:]
        num += 2
    else:
        print(num)
        break

Choices:
- Time Limit Exceeded
- Compile Error
- Memory Limit Exceeded
- Internal error


Question:
import numpy as np
A, B, Q = map(int, input().split())
s = np.array([-10**10 - 1, -10**10] + [int(input()) for _ in range(A)] + [2*10**10])
t = np.array([-10**10 - 1, -10**10] + [int(input()) for _ in range(B)] + [2*10**10])
x = [int(input()) for _ in range(Q)]

def func(c, d, z):
    i = np.searchsorted(c, z)
    j1 = np.searchsorted(d, c[i - 1])
    j2 = np.searchsorted(d, c[i])
    return min(z - d[j1 - 1], z - c[i - 1] * 2 + d[j1], d[j2] - z, c[i] * 2 - z - d[j2 - 1])

for z in x:
    print(min(func(s, t, z), func(t, s, z)))

Choices:
- Internal error
- Runtime Error
- Time Limit Exceeded
- Memory Limit Exceeded


Question:
A, B, Q = map(int, input().split())
s = [-10**10] + [int(input()) for _ in range(A)] + [2*10**10, 2*10**10 + 1]
t = [-10**10] + [int(input()) for _ in range(B)] + [2*10**10, 2*10**10 + 1]
x = [int(input()) for _ in range(Q)]

def searchindex(p, z):
    for i, d in enumerate(p):
        if d > z:
            return i - 1

def func(c, d, z):
    i = searchindex(c, z)
    j1 = searchindex(d, c[i])
    j2 = searchindex(d, c[i + 1])
    return min(z - d[j1], z - c[i] * 2 + d[j1 + 1], d[j2 + 1] - z, c[i + 1] * 2 - z - d[j2])

for z in x:
    print(min(func(s, t, z), func(t, s, z)))

Choices:
- Compile Error
- Time Limit Exceeded
- No abnormally found
- Memory Limit Exceeded


Question:
N = int(input())
A = sorted(list(map(int, input().split())))

while len(A) > 1:
    m = A[0]
    for n in range(1, len(A)):
        A[n] = A[n] % m
    A = list(set(A))
    if A[0] == 0:
        A = A[1:]
print(A[0])

Choices:
- Internal error
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded


Question:
N = int(input())
A = sorted(list(map(int, input().split())))

while len(A) > 1:
    b = [0] * len(A)
    m = A[0]
    b[0] = m
    for n in range(1, len(A)):
        b[n] = A[n] % m
    A = list(set(b))
    if A[0] == 0:
        A = A[1:]
print(A[0])

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- No abnormally found


Question:
def f(x):
    k = int(x)
    return c[k], k

c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = list(map(f, input().split()))
A = sorted(A, key=lambda x: x[0] * 10 - x[1])

# 数字を作成するのに必要なマッチ数のリストを作成
b = []
dic = {}
n = 0
for d in A:
    if n != d[0]:
        b.append(d[0])
        n = d[0]
        dic[n] = d[1]

ans = [0] * b[0]
n = b[0]
while True:
    max_ = 0
    for d in b:
        if n - d == 0:
            if dic[d] > max_:
                max_ = dic[d]
        elif n - d > 0 and ans[n - d] > 0:
            t = dic[d] * (10 ** len(str(ans[n - d]))) + ans[n - d]
            max_ = max(max_, t)

    if n == N:
        print(max_)
        break
    ans.append(max_)
    n += 1

Choices:
- Runtime Error
- Memory Limit Exceeded
- Time Limit Exceeded
- Internal error


Question:
c = [0,2,5,5,4,5,6,3,7,6]
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

B = [0] * M
for i in range(M):
    B[i] = c[A[i]]

x = min(B)
value = 0
for i in range(M):
    if B[i] == x:
        value = max(A[i], value)
y = N % x
if y == 0:
    print(str(value) * (N / x))
else:
    k = 10
    for i in range(M):
        if B[i] % x == y:
            if k > B[i]:
                k = B[i]
                l = A[i]
            elif k == B[i]:
                l = max(l, A[i])
    if value > l:
        print(str(value) * ((N - k) // x) + str(l))
    else:
        print(str(l) + str(value) * ((N - k) // x))

Choices:
- Memory Limit Exceeded
- Runtime Error
- Internal error
- Compile Error


Question:
c = [0,2,5,5,4,5,6,3,7,6]
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

B = [0] * M
for i in range(M):
    B[i] = c[A[i]]

x = min(B)
value = 0
for i in range(M):
    if B[i] == x:
        value = max(A[i], value)
y = N % x
if y == 0:
    print(str(value) * (N / x))
else:
    k = 10
    for i in range(M):
        if B[i] % x == y:
            if k > B[i]:
                k = B[i]
                l = A[i]
            elif k == B[i]:
                l = max(l, A[i])
    if value > l:
        print(str(value) * ((N - k) // x) + str(l))
    else:
        print(str(l) + str(value) * ((N - k) / x))

Choices:
- Memory Limit Exceeded
- No abnormally found
- Runtime Error
- Compile Error


Question:
def calculate(j, eval, vval, ks):
    xi = max(eval)
    if xi == 0:
        return 0
    i = eval.index(xi)

    if d[i] >= n - d[i]:
        if ks[i] == '1':
            return calculate(i, eval[:i], vval[:i], ks[:i]) + sum(vval[i:])
        else:
            eval[i] = 0
            return vval[i] + calculate(j, eval, vval, ks)
    else:
        if ks[i] == '1':
            eval[i] = 0
            return vval[i] + calculate(j, eval, vval, ks)
        else:
            m = int(ks[:i + 1], 2)
            if m == 0:
                t = d[i] << (maxlen - i - 1)
                eval[i] = 0
                return t + calculate(j, eval, vval, ks)
            else:
                ks = format(m - 1, 'b')
                ks = '0'*(i - len(ks) + 1) + ks
                return calculate(i, eval[:i], vval[:i], ks[:i]) + sum(vval[i:])

if __name__ == "__main__":
    n, k = map(int, input().split())
    a = [format(int(x), 'b') for x in input().split()]

    maxlen = 40
    ks = format(k, 'b')
    ks = '0' * (maxlen - len(ks)) + ks

    d = [0] * maxlen
    for c in a:
        len_ = len(c)
        for j in range(len_):
            if c[j] == '1':
                d[j + maxlen - len_] += 1
    e = [0] * maxlen
    val = [0] * maxlen
    flag = True
    result = 0
    for j in range(maxlen):
        if flag:
            if ks[j] == '0' and d[j] == 0:
                continue
            else:
                flag = False
        e[j] = abs(2 * d[j] - n) << (maxlen - j - 1)
        if e[j] == 0:
            result += d[j] << (maxlen - j - 1)
        else:
            val[j] = max(d[j], n - d[j]) << (maxlen - j - 1)

    result += calculate(maxlen, e, val, ks)
    print(result)

Choices:
- Memory Limit Exceeded
- Runtime Error
- Time Limit Exceeded
- No abnormally found


Question:
from sys import stdin
n, k = map(int, stdin.readline().rstrip().split())
a = [format(int(x), 'b') for x in stdin.readline().rstrip().split()]

m = format(k, 'b')
maxlen = len(m)

d = [0] * maxlen
for c in a:
    len_ = len(c)
    for j in range(len_):
        if c[j] == '1':
            d[j + maxlen - len_] += 1

flag = False
result = 0
for j in range(maxlen):
    if d[j] >= n - d[j]:
        result = result * 2 + d[j]
        if m[j] == '1':
            flag = True
    else:
        if flag or m[j] == '1':
            result = result * 2 + n - d[j]
        else:
            result = result * 2 + d[j]

print(result)

Choices:
- No abnormally found
- Time Limit Exceeded
- Compile Error
- Runtime Error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        ans = max(ans, len1[i], len2[i])

    print(ans)

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Runtime Error
- Internal error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        ans = max(ans, len1[i], len2[i])

    for n, len_ in enumerate(len1):
        if len_ + 50 * L > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y1), ans)

    for n, len_ in enumerate(len2):
        if len_ + 50 * L > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y2), ans)
    print(ans)

Choices:
- Compile Error
- No abnormally found
- Memory Limit Exceeded
- Runtime Error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        can1[i] = (X[n + (N - n + 100)//2] - 2 * X[n] - (L - X[(N - n - 101)//2])) * 100
        can2[i] = (X2[n + (N - n + 100) // 2] - 2 * X2[n] - (L - X2[(N - n - 101) // 2])) * 100
        ans = max(ans, len1[i], len2[i])

    for n, (len_, can) in enumerate(zip(len1, can1)):
        if len_ + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y1), ans)

    for n, (len_, can) in enumerate(zip(len2, can2)):
        if len_ + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y2), ans)
    print(ans)

Choices:
- No abnormally found
- Runtime Error
- Time Limit Exceeded
- Compile Error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

X2 = X[::-1]
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    cn = (N + 1) // 200
    len1 = [0] * cn
    len2 = [0] * cn
    can1 = [0] * cn
    can2 = [0] * cn
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        can1[i] = X[n + (N - n + 100)//2] - 2 * X[n] - (L - X[(N - n - 101)//2])
        can2[i] = X2[n + (N - n + 100) // 2] - 2 * X2[n] - (L - X2[(N - n - 101) // 2])
        ans = max(ans, len1[i], len2[i])

    for n, (len_, can) in enumerate(zip(len1, can1)):
        if len_ + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y1), ans)

    for n, (len_, can) in enumerate(zip(len2, can2)):
        if len_ + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y2), ans)
    print(ans)

Choices:
- Time Limit Exceeded
- Internal error
- Compile Error
- Runtime Error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
X2 = X[::-1]
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

if N < 10000:
    ans = 0
    for n in range((N + 1) // 2):
        a = func(n)
        len1 = np.dot(a, Y1)
        len2 = np.dot(a, Y2)
        ans = max(ans, len1, len2)

    print(ans)
else:
    ans = 0
    len1 = [0] * (N + 1) // 200
    len2 = [0] * (N + 1) // 200
    can1 = [0] * (N + 1) // 200
    can2 = [0] * (N + 1) // 200
    for n in range(0, (N + 1) // 2, 100):
        a = func(n)
        i = n // 100
        len1[i] = np.dot(a, Y1)
        len2[i] = np.dot(a, Y2)
        can1[i] = X[n + (N - n + 100)//2] - 2 * X[n] - (L - X[(N - n - 101)//2])
        can2[i] = X2[n + (N - n + 100) // 2] - 2 * X2[n] - (L - X2[(N - n - 101) // 2])
        ans = max(ans, len1[n], len2[n])

    for n, len_, can in enumerate(zip(len1, can1)):
        if len + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y1), ans)

    for n, len_, can in enumerate(zip(len2, can2)):
        if len + can > ans:
            for j in range(100 * n, 100 * n + 100):
                ans = max(np.dot(func(j), Y2), ans)
    print(ans)

Choices:
- Internal error
- Runtime Error
- Memory Limit Exceeded
- Compile Error


Question:
import numpy as np
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]
Z = np.concatenate((np.arange(N, -1, -2), np.arange(N - 1, -1, -2)[::-1]))

def myfunc(n, Y):
    return sum(Y[n:n + (N - n + 1)//2]) - sum(Y[:n]) - sum(Y[-((N - n + 1)//2):])

len1 = np.dot(Z, Y1)
len2 = np.dot(Z, Y2)
a1 = Y1.tolist()
a2 = Y2.tolist()
ans = max(len1, len2)
for n in range(1, (N + 1) // 2):
    len1 += myfunc(n, a1)
    len2 += myfunc(n, a2)
    ans = max(ans, len1, len2)

print(ans)

Choices:
- No abnormally found
- Time Limit Exceeded
- Internal error
- Compile Error


Question:
import numpy as np
import sys

L, N = map(int, input().split())
X = np.array([int(sys.stdin.readline()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]

def func(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

ans = 0
for n in range(0, (N + 1) // 2):
    a = func(n)
    len1 = np.dot(a, Y1)
    len2 = np.dot(a, Y2)
    ans = max(ans, len1, len2)

print(ans)

Choices:
- Runtime Error
- No abnormally found
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
import numpy as np

L, N = map(int, input().split())
X = np.array([int(input()) for _ in range(N)])
Y1 = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))
Y2 = Y1[::-1]
Z = np.concatenate((np.arange(N, -1, -2), np.arange(N - 1, -1, -2)[::-1]))

def myfunc(n, Y):
    return np.sum(Y[n:n + (N - n + 1)//2]) - np.sum(Y[:n]) - np.sum(Y[-((N - n + 1)//2):])

len1 = np.dot(Z, Y1)
len2 = np.dot(Z, Y2)
ans = max(len1, len2)
for n in range(1, (N + 1) // 2):
    len1 += myfunc(n, Y1)
    len2 += myfunc(n, Y2)
    ans = max(ans, len1, len2)

print(ans)

Choices:
- Time Limit Exceeded
- Internal error
- Compile Error
- Runtime Error


Question:
import numpy as np

L, N = map(int, input().split())
X = np.array([int(input()) for _ in range(N)])
Y = np.concatenate(([X[0]], X[1:] - X[:-1], [L - X[-1]]))

def func1(n):
    return np.concatenate((np.full(n + 1, N - n, dtype=np.int), np.arange(N - n - 2, -1, -2), np.arange(N - n - 1, -1, -2)[::-1]))

def func2(n):
    return np.concatenate((np.arange(N - n - 1, -1, -2), np.arange(N - n - 2, -1, -2)[::-1], np.full(n + 1, N - n, dtype=np.int)))

ans = 0
for n in range((N + 1) // 2):
    len_ = np.dot(func1(n), Y)
    ans = max(ans, len_)
    len_ = np.dot(func2(n), Y)
    ans = max(ans, len_)

print(ans)

Choices:
- Time Limit Exceeded
- Memory Limit Exceeded
- Internal error
- Runtime Error


Question:
n=int(input())
p=list(map(int,input().split()))
c=0
for i in range(n):
    if p[i]==min(p[:i+1]):
        c+=1
print(c)

Choices:
- Memory Limit Exceeded
- Time Limit Exceeded
- No abnormally found
- Runtime Error


Choices:
- Compile Error
- No abnormally found
- Memory Limit Exceeded
- Runtime Error


Question:
def resolve():
    n=int(input())
    h=list(map(int,input().split()))
    ans=[0 for i in range(n)]
    if h[0]<h[1]:
        ans[0]=0
    else:
        ans[0]=1
    for i in range(1,n-1):
        if h[i]<h[i+1]:
            ans[i]=0
        else:
            ans[i]=ans[i-1]+1
    print(max(ans))
resolve()

Choices:
- Runtime Error
- Time Limit Exceeded
- Compile Error
- Internal error


Question:
n=int(input())
s=[sorted(list(input())) for _ in range(n)]
ans=0

for i in range(n-1):
    for j in range(i+1,n):
        if s[i]==s[j]:
            ans+=1
print(ans)

Choices:
- No abnormally found
- Memory Limit Exceeded
- Compile Error
- Time Limit Exceeded


Question:
n=int(input())
a=[int(input()) for _ in range(n)]
p=a[::]
m=max(a)
a.delete(m)
m2=max(a)
for i in p:
  if i==m:
    print(m2)
  else:
    print(m)

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- Internal error


Question:
n=int(input())
a=[int(input()) for _ in range(n)]
for i in range(n):
  p=a[::]
  p.pop(i)
  print(max(p))

Choices:
- Memory Limit Exceeded
- Runtime Error
- Time Limit Exceeded
- No abnormally found


Question:
n,q=map(int,input().split())
s=input()
for i in range(q):
	l,r=map(int,input().split())
	print(s[l-1:r].count('AC'))

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Time Limit Exceeded


Question:
def resolve():
	n,q=map(int,input().split())
	s=input()
	lr=[list(map(int,input().split())) for i in range(q)]

	for i in range(q):
		l=lr[i][0]-1
		r=lr[i][1]
		t=s[l:r]
		print(t.count('AC'))
resolve()

Choices:
- No abnormally found
- Runtime Error
- Internal error
- Time Limit Exceeded


Question:
def resolve():
	S=input()
	chk=1
	cnt=0
	while chk==1:
		chk=0
		if len(S)==0:
			break
		if '10' in S:
			cnt+=S.count('10')
			S=S.replace('10','')
			chk=1
		if '01' in S:
			cnt+=S.count('01')
			S=S.replace('01','')
			chk=1
	print(cnt*2)
resolve()

Choices:
- Compile Error
- Runtime Error
- Time Limit Exceeded
- No abnormally found


Question:
def resolve():
	S=input()
	chk=1
	cnt=0
	while chk==1:
		chk=0
		if len(S)==0:
			break
		if '10' in S:
			S=S.replace('10','',1)
			chk=1
			cnt+=1
		if '01' in S:
			S=S.replace('01','',1)
			chk=1
			cnt+=1
	print(cnt*2)
resolve()

Choices:
- Compile Error
- Internal error
- Runtime Error
- Time Limit Exceeded


Question:
def resolve():
	S=input()
	chk=1
	cnt=0
	while chk==1:
		chk=0
		if len(S)==0:
			break
		if '10' in S:
			S=S.replace('10','',1)
			chk=1
			cnt+=1
		elif '01' in S:
			S=S.replace('01','',1)
			chk=1
			cnt+=1
	print(cnt*2)
resolve()

Choices:
- Time Limit Exceeded
- Internal error
- Memory Limit Exceeded
- Runtime Error


Question:
def resolve():
	S=input()
	chk=1
	cnt=0
	while chk==1:
		chk=0
		if len(S)==0:
			break
		if '10' in S:
			S=S.replace('10','',1)
			chk=1
			cnt+=1
		elif '01' in S:
			S=S.replace('01','',1)
			chk=1
			cnt+=1
	print(cnt*2)

resolve()

Choices:
- No abnormally found
- Internal error
- Runtime Error
- Time Limit Exceeded


Question:
import functools
import fractions

def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	a=[abs(i-j) for i in x_list for j in x_list if i!=j]
	print(functools.reduce(fractions.gcd,a))

resolve()

Choices:
- Internal error
- Time Limit Exceeded
- Memory Limit Exceeded
- Compile Error


Question:
import functools
import math

def resolve():
	n,x=map(int,input().split())
	x_list=list(map(int,input().split()))
	x_list.append(x)
	a=[i-j for i in x_list for j in x_list if i!=j]
	print(functools.reduce(math.gcd,a))
resolve()

Choices:
- Compile Error
- Time Limit Exceeded
- Runtime Error
- Memory Limit Exceeded


Question:
a,b,c,d=map(int,input().split())
print(max(b-c),0)

Choices:
- No abnormally found
- Memory Limit Exceeded
- Runtime Error
- Compile Error


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

for i in range(n):
    a[i] -= 1

visited = [0]
now = 0
flag = 0

for i in range(k):
    now = a[now]

    if now in set(visited):
        loop_start = now
        flag = 1
        break

    else:
        visited.append(now)

if flag == 1:
    loop = visited[visited.index(loop_start):]
    m = len(loop)

    now = loop[(k-(len(visited)-m))%m]

print(now + 1)

Choices:
- No abnormally found
- Compile Error
- Time Limit Exceeded
- Internal error


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

for i in range(n):
    a[i] -= 1

visited = [0]
now = 0
flag = 0

for i in range(k):
    now = a[now]

    if now in set(visited):
        loop_start = now
        flag = 1
        break

    else:
        visited.append(now)

if flag == 1:
    loop = visited[visited.index(loop_start):]
    m = len(loop)

    now = loop[(k-(len(visited)-m))%m]

print(now + 1)

Choices:
- Runtime Error
- Time Limit Exceeded
- Compile Error
- Internal error


Question:
n = int(input())
s = list(input())

import collections
c = collections.Counter(s)

ans = c["R"] * c["B"] * c["G"]

for i in range(n-2):
    for j in range(i+1,n-1):
        x = s[i]
        y = s[j]

        if x != y:
            if "R" not in [x,y]:
                if 2*j-i < n:
                    if s[2*j-i] == "R":
                        ans -= 1

            elif "G" not in [x,y]:
                if 2*j-i < n:
                    if s[2*j-i] == "G":
                        ans -= 1

            else:
                if 2*j-i < n:
                    if s[2*j-i] == "B":
                        ans -= 1

print(ans)

Choices:
- Internal error
- Runtime Error
- Compile Error
- Time Limit Exceeded


Question:
n = int(input())
s = list(input())
ans = 0

R = [0] * n
G = [0] * n
B = [0] * n

r = 0
g = 0
b = 0

for i in range(n):
    if s[i] == "R":
        r += 1
        R[i] = r
    elif s[i] == "G":
        g += 1
        G[i] = g
    else:
        b += 1
        B[i] = b

for i in range(n-2):
    for j in range(i+1,n-1):
        x = s[i]
        y = s[j]

        if x != y:
            if "R" not in [x,y]:
                ans += R[n-1] - R[j]

                if 2*j-i < n:
                    if s[2*j-i] == "R":
                        ans -= 1

            if "G" not in [x,y]:
                ans += G[n-1] - G[j]

                if 2*j-i < n:
                    if s[2*j-i] == "G":
                        ans -= 1

            if "B" not in [x,y]:
                ans += B[n-1] - B[j]

                if 2*j-i < n:
                    if s[2*j-i] == "B":
                        ans -= 1

print(ans)

Choices:
- Internal error
- Compile Error
- Memory Limit Exceeded
- Time Limit Exceeded


Question:
n = int(input())
A = list(map(int,input().split()))
B = sorted(set(A))
ans = 0

for i in range(len(B)):
    m = A.count(B[i])
    if m > 1:
        ans += m*(m-1)//2

for i in range(n):
    m = A.count(A[i])
    print(ans + 1 - m)

Choices:
- No abnormally found
- Time Limit Exceeded
- Runtime Error
- Internal error


Question:
n = int(input())
A = list(map(int,input().split()))
B = sorted(set(A))
dic = {}
ans = 0

for i in range(len(B)):
    if A.count(B[i]) > 1:
        C = A.count(B[i])
        dic[B[i]] = C
        ans += C*(C-1)//2
    else:
        dic[B[i]] = 1

for i in range(len(B)):
    x = dic[B[i]]
    dic[B[i]] = ans + 1 - x

for i in range(n):
    print(dic[A[i]])

Choices:
- Memory Limit Exceeded
- Runtime Error
- Time Limit Exceeded
- No abnormally found


Question:
n = int(input())
A = list(map(int,input().split()))
B = sorted(set(A))
dic = {}
ans = 0

for i in range(len(B)):
    if A.count(B[i]) > 1:
        C = A.count(B[i])
        dic[B[i]] = C
        ans += C*(C-1)//2
    else:
        dic[B[i]] = 1

for i in range(n):
    x = dic[A[i]]
    print(ans - x*(x-1)//2 + (x-1)*(x-2)//2)

Choices:
- Runtime Error
- No abnormally found
- Time Limit Exceeded
- Compile Error


Question:
A = ["SUN","MON","TUE","WED","THU","ERI","SAT"]
print(7-A.index(input()))

Choices:
- Runtime Error
- Time Limit Exceeded
- No abnormally found
- Compile Error


Question:
S = input()
T = input()

result = 0
for i in range(0,3):
    if S[i] == T[i]:
        result += 1

print (result)

Choices:
- Runtime Error
- Time Limit Exceeded
- Memory Limit Exceeded
- No abnormally found


Question:
A , B = map ( int , input ( )  . split( ) )

if (A  <= 9 and B <= 9 ):
print ( A * B )

else:
print ( -1 )

Choices:
- Memory Limit Exceeded
- Compile Error
- Time Limit Exceeded
- Runtime Error


Question:
A , B = map ( int , input ( )  . split( ) )

if (A , B) <= 9 :
print ( A * B )

else:
print ( -1 )

Choices:
- Compile Error
- Runtime Error
- No abnormally found
- Internal error


Question:
A , B = map ( int , input ( )  . split( ) )

if A , B <= 9 :
print ( A * B )

else:
print ( -1 )

Choices:
- Compile Error
- Internal error
- Runtime Error
- Memory Limit Exceeded


Question:
if ( ( 1 <= A <= 9 ) and( ( A % 1 == 0 ) or ( A % 2 == 0 ) or ( A % 3 == 0 ) or ( A % 5 == 0 ) or ( A % 7 == 0 ) ) ) and ( ( 1 <= B <= 9 ) and( ( B % 1 == 0 ) or ( B % 2 == 0 ) or ( B % 3 == 0 ) or ( B % 5 == 0 ) or ( B % 7 == 0 ) ) ):
    print(A*B)
else:
    print ( -1 )

Choices:
- Runtime Error
- Compile Error
- No abnormally found
- Memory Limit Exceeded


Question:
n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2

    if 1 < len(a) and a[-2] > a[-1]:
        a = sorted(a)

print(sum(a))

Choices:
- Time Limit Exceeded
- Runtime Error
- Compile Error
- Internal error


Question:
n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2

    if a[-2] > a[-1]:
        a = sorted(a)

print(sum(a))

Choices:
- No abnormally found
- Memory Limit Exceeded
- Runtime Error
- Internal error