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

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

print(sum(a))

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


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

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

print(sum(a))

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


Question:
A = int(input())
B = int(input())

rist = [ A+B , A-B , A*B]

print(max(rist))

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


Question:
A = int(input())
B = int(input())

rist = [ A+B , A-B , A*B]

rist.sort()
print(rist[3])

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


Question:
A = int(input())
B = int(input())

rist = [ A+B , A-B , A*B]

rist.sort()

print(rist[3])

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


Question:
n,k = map(int,input().split())
print(input().replace(s[k-1],s[k-1].lower()))

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


Question:
S = int(input())

if 0 < S // 100 <= 12 and 0 < S % 100<= 12:
    print("AMBIGUOUS")
elif 0 < S // 100 <= 12:
    print("MMYY")
elif 0 < S % 100 <= 12:
    print("YYMM")
else :
    print("NA")

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


Question:
food = [int(input()) for i in range(5)]
a = 10

for i in range(5):
    x = food[i] % 10
    if 0 < x < a:
        a = x
        remove = food[i]

food.remove(remove)

ans = remove

for i in range(4):
    ans += -(-food[i]//10)*10

print(ans)

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


Question:
s = input()
ACGT = ["A","C","G","T"]
ans = 0
ANS = []

for i in range(len(s)):
    if s[i] in ACGT:
        ans += 1
    else:
        ANS.append(ans)
        ans = 0

print(max(ANS))

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


Question:
S = input()

list_ = []
length = 0

for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        length += 1
    else:
        list_.append(length)
        length = 0

print(max(list_))

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


Question:
n,q = map(int,input().split())
s = list(input())
ac = []

for i in range(n-1):
    if s[i] == "A":
        if s[i+1] == "C":
            ac.append(i)

for _ in range(q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    ans = 0

    for i in ac:
        if r <= i:
            break

        if l <= i < r:
            ans += 1

    print(ans)

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


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:
- Runtime Error
- Memory Limit Exceeded
- Compile Error
- Time Limit Exceeded


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

while a[-2] != 0:
    for i in range(n):
        if a[i] != 0:
            w = a[i]
            wi = i
            break

    for i in range(n):
        if i != wi:
            a[i] %= w

        a = sorted(a)

print(a[-1])

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


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

while a[-2] != 0:
    w = 10**9+1

    for i in range(n):
        a[i] %= w

        if a[i]!=0 and w==10**9+1:
            w = a[i]

        a = sorted(a)

print(a[-1])

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


Question:
k,s = map(int,input().split())
ans = 0

for x in range(min(k,s)+1):
    for y in range(min(k,s)+1):
        if 0 <= s - x - y <= min(k,s):
            ans += 1

print(ans)

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


Question:
rdx = list(map(lambda x: int(x), input().split()))
r = rdx[0]
d = rdx[1]
x = rdx[2]

memo = [0 for i in range(d+1)]

memo[0] = x
for i in range(10):
  memo[i+1] = memo[i] * r - d
  print(memo[i+1])

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


Question:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

gates = [list(map(lambda x: int(x), input().split())) for i in range(m)]

keys = [i+1 for i in range(n)]
key_count = [0 for i in range(n)]

for gate in gates:
  new_key = keys.copy()

  for key in keys:
    if (key >= gate[0] and key <= gate[1]):
      key_count[key-1] += 1
    else:
      new_key.remove(key)
  keys = new_key

print(len(keys))

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


Question:
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

gates = [list(map(lambda x: int(x), input().split())) for i in range(m)]

key = [0 for i in range(n)]

for gate in gates:
  for i in range(len(key)):
    if (i+1 >= gate[0] and i+1 <= gate[1]):
      key[i] += 1

print(key.count(m))

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


Question:
import heapq

nm = list(map(lambda x: int(x), input().split()))
n = nm[0]
m = nm[1]

a = list(map(lambda x: int(x), input().split()))
bc = [list(map(lambda x: int(x), input().split())) for i in range(m)]

head_a = []

for a_item in a:
  heapq.heappush(head_a, a_item)

# そーと
bc.sort(key=lambda x: x[1])
bc = list(reversed(bc))

for bc_item in bc:
  for i in range(bc_item[0]):
    head_a_item = heapq.heappop(head_a)
    heapq.heappush(head_a, max(head_a_item, bc_item[1]))

print(sum(head_a))

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


Question:
n = int(input())
edges = [list(map(int, input().split())) for i in range(n-1) ]

# -1 -> Black, 1 -> white, 0 -> not yet
memo = [0 for i in range(n)]
memo[0] = 1

# print("memo", memo)

def paint(index, node_num):
  for edge in edges:
    if (edge[0]==node_num):
      if (edge[2] % 2 == 0):
        # print("edge", edge)
        memo[edge[1]-1] = memo[i]
        edges.remove(edge)
        paint(edge[1]-1, edge[1])
      else:
        # print("edge", edge)
        memo[edge[1]-1] = -memo[i]
        edges.remove(edge)
        paint(edge[1]-1, edge[1])
    if (edge[1]==node_num):
      if (edge[2] % 2 == 0):
        # print("edge", edge)
        memo[edge[0]-1] = memo[i]
        edges.remove(edge)
        paint(edge[0]-1, edge[1])
      else:
        # print("edge", edge)
        memo[edge[0]-1] = -memo[i]
        edges.remove(edge)
        paint(edge[0]-1, edge[1])

for i in range(n):
  if (memo[i] != 0):
    continue
  memo[i] = 1
  node_num = i + 1
  # print("node_num", node_num)
  # print("=======================")
  paint(i, node_num)
  # print("memo", memo)
  # print("=======================")

# print("memo", memo)

for item in memo:
  if (item == 1):
    print("1")
  else:
    print("0")

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


Question:
n = input()
v = input()
v = v.split()
c = input()
c = c.split()

VSubC = []

for index in range(n):
  heapq.heappush(VSubC, -(v[index] - c[index]))

answer = 0
while(len(VSubC) > 0):
  item = heapq.heappop(VSubC)
  if (item < 0):
    answer -= item
  else:
    break

print(answer)

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


Question:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

# INPUT
n, x = map(int, input().split())
capitals = list(map(int, input().split()))

# PROCESS
distance_cap = list(map(lambda c: abs(x-c), capitals))
answer = gcd_list(distance_cap)

# OUTPUT
print(answer)

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


Question:
S=input()
a=S.count("A")
b=S.count("B")
if a==3 or b==3:
  print("No")
else
  print("Yes")

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


Question:
import math

X, K, D = map(int, input().split())

a = X - K * D
if a > 0:
    print(a)
    return
if a + 2 * K * D < 0:
    print(abs(a + 2 * K * D))
    return
else:
    b = a / (-2 * D)
    p = math.floor(b)
    q = math.ceil(b)
    r = -(a + 2 * D * p)
    s = a + 2 * D * q
    print(min(r,s))
    return

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


Question:
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
while K > 0:
    if not A == [] and not B == []:
        if A[0] <= B[0]:
            K = K - A[0]
            A.remove(A[0])
            if K >= 0:
                c += 1
        else:
            K = K - B[0]
            B.remove(B[0])
            if K >= 0:
                c += 1
    if A == []:
        K = K - B[0]
        B.remove(B[0])
        if K >= 0:
            c += 1
    if B == []:
        K = K - A[0]
        A.remove(A[0])
        if K >= 0:
            c += 1
print(c)

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


Question:
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
while K > 0:
    if not A == [] and not B == []:
        if A[0] >= B[0]:
            K = K - A[0]
            A.remove(A[0])
            if K >= 0:
                c += 1
        else:
            K = K - B[0]
            B.remove(B[0])
            if K >= 0:
                c += 1
    if A == []:
        K = K - B[0]
        B.remove(B[0])
        if K >= 0:
            c += 1
    if B == []:
        K = K - A[0]
        A.remove(A[0])
        if K >= 0:
            c += 1
print(c)

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


Question:
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
while K > 0:
    if not A == [] and not B == []:
        if A[0] >= B[0]:
            K = K - A[0]
            A.remove(A[0])
            if K >= 0:
                c += 1
        else:
            K = K - B[0]
            B.remove(B[0])
            if K >= 0:
                c += 1
    if A == []:
        K = K - B[0]
        B.remove(B[0])
        if K >= 0:
                c += 1
    if B == []:
        K = K - A[0]
        A.remove(A[0])
        if K >= 0:
                c += 1
print(c)

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


Question:
S = str(input())
if S = 'ABC':
  print('ARC')
else:
  print('ABC')

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


Question:
import math

A, B, N = (int(x) for x in input().split())
h = []
a = 0
for i in range(0, N+1):
    a = math.floor(A * i / B) - A * math.floor(i / B)
    h.append(a)
print(max(h))

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


Question:
N = int(input())
h = list(input() for x in range(N))
a = []
c = 0
for i in range(0, N):
    if h[i] in a:
        c += 1
    else:
        a.append(h[i])
print(N - c)

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


Question:
N = int(input())
h = list(input() for x in range(N))
a = []
for i in range(0, N):
    if h[i] not in a:
        a.append(h[i])
print(len(a))

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


Question:
N = int(input())
h = [input() for x in range(N)]
a = []
for i in range(0, N):
    if h[i] not in a:
        a.append(h[i])
print(len(a))

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


Question:
N = int(input())
h=list(map(int,input().split()))
c = 0
A = [h[0]]
for i in range(0,N):
    A.append(h[i])
    if min(A) >= h[i]:
        c += 1
print(c)

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


Question:
N = int(input())
h=list(map(int,input().split()))
c = 0
a = h[0]
for i in range(0,N):
    s = 0
    if h[i] > a:
        a = h[i]
    else:
        for j in range(0,i):
            if h[j] >= h[i]:
                s += 1
        if s == i:
            c += 1
print(c)

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


Question:
N = int(input())
h=list(map(int,input().split()))
c = 0
for i in range(0,N):
    s = 0
    for j in range(0,i):
        if h[j] >= h[i]:
            s += 1
    if s == i:
        c += 1
print(c)

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


Question:
K,X=input().split()
if 500 * K >= X:
  return 'Yes'
else:
  return 'No'

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


Question:
N = int(input())
S = input()
r_c = 0
ch = 0
for i in S:
  if i == "R":
    r_c += 1
for i in range(r_c):
  if i == "W"
    ch += 1
print(ch)

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


Question:
(red, blue) = list(input().split())
(p, q) = list(input().split())
st = input()

if red == st:
  print( p-1+ " " +q )
else:
  print( p+ " " +q-1 )

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


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

count = 1

for i in range(1,len(k)+1):
  if k[i-1] > k[i]:
    count += 1

print(count)

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


Question:
A, B = list(map(int, (input().split())))
k = -1
if A <= 9 && B <= 9:
  k = A * B
print(str(k))

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


Question:
A, B = list(map(int, (input().split())))
k = -1
if A <= 9 && B <= 9:
  k = A * B
print(k)

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


Question:
N = int(input())

AryA = list(map(int, input().split()))

AryB = list(map(int, input().split()))

AryC = list(map(int, input().split()))

sum = 0
tmpBox = N+1

for item in AryA:
	sum += AryB[item]
	if (item == tmpBox + 1):
		sum += AryC[tmpBox]

print sum

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


Question:
N=int(input())
A=list(map(int,inpu().split()))
bef=99999999999999
count=0
for i in range(N):
  l=A.pop()
  if l > bef:
    count +=1
  else:
    count=0
  if max<=count:
    max=count
  bef=l
print(max)

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


Question:
a b c = list(map(int, input().split()))
d = c - (a - b)
if d > 0:
  print(d)
else:
  print(0)

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


Question:
N = int(input())

V = list(map(int, input().split()))

C = list(map(int, input().split()))

P = 0

for i in range(0,N+1):
  Y = V[i] - C[i]
  if Y >0:
    P += Y
print(Y)

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


Question:
ans=-10**18
if a<=0<=b or c<=0<=d:
  ans=0
ans=max(ans,a*c,a*d,b*c,b*d)
print(ans)

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


Question:
import collections
import sys
input=sys.stdin.readline

def divisors(n):
  ret=[]
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      ret.append(i)
      while n%i==0:
        n//=i
  return ret

def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input().split()))
cnt=[False]*(max(arr)+1)
is_pairwise=True
tmp=arr[0]
for val in arr:
  tmp=gcd(tmp,val)
  if is_pairwise==False:
    continue
  divisor=divisors(val)
  for val2 in divisor:
    if cnt[val2]==True
      is_pairwise=False
      break
    cnt[val2]=True
if tmp==1:
  is_setwise=True
else:
  is_setwise=False
if is_pairwise==True:
  print('pairwise coprime')
elif is_setwise==True:
  print('setwise coprime')
else:
  print('not coprime')

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


Question:
#!/usr/bin/env python3

import collections

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input()+'#') for _ in range(h)]+[['#']*(w+2)]
checked=[[False]*(w+1) for _ in range(h+1)]
checked[sy][sx]=True
q=collections.deque()
q.append((sy,sx))
ans=0
while 1:
  cur_pos=[]
  while len(q)!=0:
    y,x=q.popleft()
    cur_pos.append((y,x))
    for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
      if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and checked[y+dy][x+dx]==False:
        checked[y+dy][x+dx]=True
        q.append((y+dy,x+dx))
  if checked[gy][gx]==True:
    print(ans)
    exit()
  if len(cur_pos)==0:
    print(-1)
    exit()
  ans+=1
  for y,x in cur_pos:
    for dy in range(-2,3):
      for dx in range(-2,3):
        if dy==0 and dx==0:
          continue
        if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and checked[y+dy][x+dx]==False:
          checked[y+dy][x+dx]=True
          q.append((y+dy,x+dx))

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


Question:
#!/usr/bin/env python3

import heapq
import sys
input=sys.stdin.readline

def calc():
  h,w=map(int,input().split())
  sy,sx=map(int,input().split())
  gy,gx=map(int,input().split())
  board=[['#']*(w+2)]+[list('#'+input().replace('\n','')+'#') for _ in range(h)]+[['#']*(w+2)]
  costs=[[10**18]*(w+1) for _ in range(h+1)]
  costs[sy][sx]=0
  q=[]
  heapq.heappush(q,(0,sy,sx))
  while len(q)!=0:
    cost,y,x=heapq.heappop(q)
    if y==gy and x==gx:
      print(cost)
      exit()
    for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
      if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]:
        costs[y+dy][x+dx]=costs[y][x]
        heapq.heappush(q,(cost,y+dy,x+dx))
    for dy in range(-2,3):
      for dx in range(-2,3):
        if dy==0 and dx==0:
          continue
        if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]+1:
          costs[y+dy][x+dx]=costs[y][x]+1
          heapq.heappush(q,(cost+1,y+dy,x+dx))
  print(-1)
calc()

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


Question:
#!/usr/bin/env python3

import heapq

h,w=map(int,input().split())
sy,sx=map(int,input().split())
sy-=1
sx-=1
gy,gx=map(int,input().split())
gy-=1
gx-=1
board=''
for _ in range(h):
  board+=input()
costs=[10**18]*(w*h)
costs[sy*w+sx]=0
q=[]
heapq.heappush(q,(0,sy,sx))
while len(q)!=0:
  cost,y,x=heapq.heappop(q)
  cur_pos=y*w+x
  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    next_pos=cur_pos+dy*w+dx
    if 0<=y+dy<h and 0<=x+dx<w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]:
      costs[next_pos]=costs[cur_pos]
      heapq.heappush(q,(cost,y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dy==0 and dx==0:
        continue
      next_pos=cur_pos+dy*w+dx
      if 0<=y+dy<h and 0<=x+dx<w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]+1:
        costs[next_pos]=costs[cur_pos]+1
        heapq.heappush(q,(cost+1,y+dy,x+dx))
if costs[gy*w+gx]==10**18:
  print(-1)
else:
  print(costs[gy*w+gx])

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


Question:
#!/usr/bin/env python3

import heapq

h,w=map(int,input().split())
sy,sx=map(int,input().split())
sy-=1
sx-=1
gy,gx=map(int,input().split())
gy-=1
gx-=1
board=''
for _ in range(h):
  board+=input()
costs=[10**18]*(w*h)
costs[sy*w+sx]=0
q=[]
heapq.heappush(q,(0,sy,sx))
while len(q)!=0:
  cost,y,x=heapq.heappop(q)
  cur_pos=y*w+x
  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    next_pos=cur_pos+dy*w+dx
    if 1<=y+dy<=h and 1<=x+dx<=w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]:
      costs[next_pos]=costs[cur_pos]
      heapq.heappush(q,(cost,y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dy==0 and dx==0:
        continue
      next_pos=cur_pos+dy*w+dx
      if 1<=y+dy<=h and 1<=x+dx<=w and board[next_pos]=='.' and costs[next_pos]>costs[cur_pos]+1:
        costs[next_pos]=costs[cur_pos]+1
        heapq.heappush(q,(cost+1,y+dy,x+dx))
if costs[gy*w+gx]==10**18:
  print(-1)
else:
  print(costs[gy*w+gx])

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


Question:
#!/usr/bin/env python3

import heapq

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input()+'#') for _ in range(h)]+[['#']*(w+2)]
costs=[[10**18]*(w+1) for _ in range(h+1)]
costs[sy][sx]=0
q=[]
heapq.heappush(q,(0,sy,sx))
while len(q)!=0:
  cost,y,x=heapq.heappop(q)
  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]:
      costs[y+dy][x+dx]=costs[y][x]
      heapq.heappush(q,(cost,y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dy==0 and dx==0:
        continue
      if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]+1:
        costs[y+dy][x+dx]=costs[y][x]+1
        heapq.heappush(q,(cost+1,y+dy,x+dx))
if costs[gy][gx]==10**18:
  print(-1)
else:
  print(costs[gy][gx])

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


Question:
#!/usr/bin/env python3

import heapq

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input()+'#') for _ in range(h)]+[['#']*(w+2)]
costs=[[10**18]*(w+1) for _ in range(h+1)]
costs[sy][sx]=0
q=[]
heapq.heappush(q,(0,sy,sx))
while len(q)!=0:
  cost,y,x=heapq.heappop(q)
  if y==gy and x==gx:
    print(cost)
    exit()
  for dy,dx in [[-1,0],[1,0],[0,-1],[0,1]]:
    if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]:
      costs[y+dy][x+dx]=costs[y][x]
      heapq.heappush(q,(cost,y+dy,x+dx))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dy==0 and dx==0:
        continue
      if 1<=y+dy<=h and 1<=x+dx<=w and board[y+dy][x+dx]=='.' and costs[y+dy][x+dx]>costs[y][x]+1:
        costs[y+dy][x+dx]=costs[y][x]+1
        heapq.heappush(q,(cost+1,y+dy,x+dx))
print(-1)

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


Question:
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=[['#']*(w+2)]+[list('#'+input().replace('\n','')+'#') for _ in range(h)]+[['#']*(w+2)]
scores=[[10**18]*(w+2) for _ in range(h+2)]
scores[sy][sx]=0
q=collections.deque()
q.append((sy,sx,0))
count=0
while len(q)!=0:
  y,x,score=q.popleft()
  for dx,dy in [[-1,0],[1,0],[0,-1],[0,1]]:
    if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>score:
      scores[y+dy][x+dx]=score
      q.append((y+dy,x+dx,score))
  for dy in range(-2,3):
    for dx in range(-2,3):
      if dx==0 and dy==0:
        continue
      if 1<=x+dx<=w and 1<=y+dy<=h and board[y+dy][x+dx]!='#' and scores[y+dy][x+dx]>score+1:
        scores[y+dy][x+dx]=score+1
        q.appendleft((y+dy,x+dx,score+1))
if scores[gy][gx]==10**18:
    print(-1)
else:
    print(scores[gy][gx])

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


Question:
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=''
for _ in range(h):
    board+=input().replace('\n','')
uf=UnionFind(h*w)
for y in range(h):
    for x in range(w):
        v=y*w+x
        if board[v]=='#':
            continue
        if y+1<h and board[v+w]=='.':
            uf.Unite(v,v+w)
        if x+1<w and board[v+1]=='.':
            uf.Unite(v,v+1)
edges=[[] for _ in range(h*w+1)]
checked=set()
for y in range(h):
    for x in range(w):
        if board[y*w+x]=='#':
            continue
        for dy in [-2,-1,0,1,2]:
            if y+dy<0 or y+dy>=h:
                continue
            for dx in [-2,-1,0,1,2]:
                if x+dx<0 or x+dx>=w:
                    continue
                if board[(y+dy)*w+(x+dx)]=='#':
                    continue
                r1=uf.FindRoot(y*w+x)
                r2=uf.FindRoot((y+dy)*w+x+dx)
                if (r1,r2) in checked:
                    continue
                if r1!=r2:
                    edges[r1].append(r2)
                    checked.add((r1,r2))
q=collections.deque()
q.append(((uf.FindRoot((sy-1)*w+(sx-1))),0))
checked=[False]*(h*w+1)
ans=10**18
goal=uf.FindRoot((gy-1)*w+(gx-1))
while len(q)!=0:
    v,times=q.popleft()
    if v==goal:
        ans=min(ans,times)
        break
    checked[v]=True
    for u in edges[v]:
        if checked[u]==False:
            q.append((u,times+1))
if ans==10**18:
    print(-1)
else:
    print(ans)

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


Question:
#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]

h,w=map(int,input().split())
sy,sx=map(int,input().split())
gy,gx=map(int,input().split())
board=''
for _ in range(h):
    board+=input().replace('\n','')
uf=UnionFind(h*w)
for y in range(h):
    for x in range(w):
        v=y*w+x
        if board[v]=='#':
            continue
        if y+1<h and board[v+w]=='.':
            uf.Unite(v,v+w)
        if x+1<w and board[v+1]=='.':
            uf.Unite(v,v+1)
edges=[[] for _ in range(h*w+1)]
checked=set()
for y in range(h):
    for x in range(w):
        if board[y*w+x]=='#':
            continue
        for dy in [-2,-1,0,1,2]:
            if y+dy<0 or y+dy>=h:
                continue
            for dx in [-2,-1,0,1,2]:
                if x+dx<0 or x+dx>=w:
                    continue
                if board[(y+dy)*w+(x+dx)]=='#':
                    continue
                r1=uf.FindRoot(y*w+x)
                r2=uf.FindRoot((y+dy)*w+x+dx)
                if (r1,r2) in checked:
                    continue
                if r1!=r2:
                    edges[r1].append(r2)
                    checked.add((r1,r2))
q=collections.deque()
q.append(((uf.FindRoot((sy-1)*w+(sx-1))),0))
checked=[False]*(h*w+1)
ans=10**18
goal=uf.FindRoot((gy-1)*w+(gx-1))
while len(q)!=0:
    v,times=q.popleft()
    if v==goal:
        ans=min(ans,times)
    checked[v]=True
    for u in edges[v]:
        if checked[u]==False:
            q.append((u,times+1))
if ans==10**18:
    print(-1)
else:
    print(ans)

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


Question:
import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_all=[[] for _ in range(n+1)]
for i in range(n):
  val=arr[i]
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=0
  pos_all[val].append(i+1)
for i in range(n+1):
  pos_all[i].append(-1)
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if pos_all[val][pos_now[val]+1]!=-1:
      pos_now[val]+=1
      bit.add(pos_all[val][pos_now[val]],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

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


Question:
import collections
import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_all=[[] for _ in range(n+1)]
for i in range(n):
  val=arr[i]
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=0
  pos_all[val].append(i+1)
for i in range(n+1):
  pos_all[i].append(-1)
cnt=collections.Counter(arr)
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if pos_all[val][pos_now[val]+1]!=-1:
      pos_now[val]+=1
      bit.add(pos_all[val][pos_now[val]],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

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


Question:
import collections
import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_all=[[] for _ in range(n+1)]
for i in range(n):
  val=arr[i]
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=0
  pos_all[val].append(i+1)
for i in range(n+1):
  pos_all[i].append(-1)
cnt=collections.Counter(arr)
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if cnt[val]!=1:
      bit.add(pos_all[val][pos_now[val]],-1)
      if pos_all[val][pos_now[val]+1]!=-1:
        pos_now[val]+=1
        bit.add(pos_all[val][pos_now[val]],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

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


Question:
import collections
import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[list(map(int,input().split()))+[i] for i in range(q)]
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_next=[[] for _ in range(n+1)]
for i in range(n):
  val=arr[i]
  if pos_now[val]==-1:
    pos_now[val]=i+1
    bit.add(i+1,1)
  else:
    pos_next[val].append(i+1)
cnt=collections.Counter(arr)
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if cnt[val]!=1:
      bit.add(pos_now[val],-1)
      if len(pos_next[val])!=0:
        pos_now[val]=pos_next[val][0]
        pos_next[val]=pos_next[val][1:]
        bit.add(pos_now[val],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

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


Question:
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

class SegmentTreeSet():
  def __init__(self,n,init):
    self.offset=2**((n-1).bit_length())
    self.tree=[init]*(2*self.offset)
    self.init=init
  def update(self,pos,val):
    pos+=self.offset
    self.tree[pos]=self.tree[pos]|val
    while pos>1:
      pos=pos//2
      self.tree[pos]=self.tree[2*pos]|self.tree[2*pos+1]
  def query(self,l,r):
    l+=self.offset
    r+=self.offset
    ret=self.init
    while l<=r:
      ret=ret|self.tree[r]
      r=(r-1)//2
      ret=ret|self.tree[l]
      l=(l+1)//2
    return ret

n,q=map(int,input().split())
arr=list(map(int,input().split()))
st=SegmentTreeSet(n,set())
for i in range(n):
    tmp=set()
    tmp.add(arr[i])
    st.update(i,tmp)
for _ in range(q):
    l,r=map(int,input().split())
    l-=1
    r-=1
    print(len(st.query(l,r)))

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


Question:
def calc():
  n=int(input())
  table=[i for i in range(n+1)]
  for i in range(2,n+1):
    if table[i]<i:
      continue
    for j in range(i,n+1,i):
      table[j]=i
  ans=0
  for i in range(1,n+1):
    cnt={}
    tmp=i
    while tmp!=1:
      if table[tmp] in cnt:
        cnt[table[tmp]]+=1
      else:
        cnt[table[tmp]]=1
      tmp//=table[tmp]
    tmp=i
    for val in cnt.values():
      tmp*=val+1
    ans+=tmp
  print(ans)
calc()

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


Question:
n=int(input())
t=[1]*(n+1)
check=[False]*(n+1)
for i in range(2,n+1):
  if check[i]==True:
    continue
  check[i]=True
  for j in range(1,n//i+1):
    check[i*j]=True
    cnt=0
    k=i*j
    while k%i==0:
      k//=i
      cnt+=1
    t[i*j]*=(i**cnt)*(cnt+1)
print(sum(t[1:]))

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[[0]*(s+1) for _ in range(n+1)]
  dp[0][0]=1
  for i in range(1,n+1):
    val=arr[i-1]
    for j in range(s,-1,-1):
      dp[i][j]=2*dp[i-1][j]
      dp[i][j]%=mod
      if j-val>=0 and dp[i-1][j-val]!=0:
        dp[i][j]+=dp[i-1][j-val]
  print(dp[n][s]%mod)
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      dp[k]%=mod
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
  print(dp[s]%mod)
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      dp[k]%=mod
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
        dp[k]%=mod
  print(dp[n]%mod)
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[0]*(s+1)
  dp[0]=1
  ans=0
  for i in range(1,n+1):
    val=arr[i-1]
    for k in range(s,-1,-1):
      dp[k]*=2
      if k>=val and dp[k-val]!=0:
        dp[k]+=dp[k-val]
  print(dp[n])
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[[[0]*(s+1) for _ in range(n+1)] for _ in range(n+1)]
  dp[0][0][0]=1
  for i in range(1,n+1):
    val=arr[i-1]
    for j in range(i,-1,-1):
      for k in range(s,val-1,-1):
        dp[i][j][k]=dp[i-1][j][k]
        dp[i][j][k]+=dp[i-1][j-1][k-val]
      for k in range(val-1,-1,-1):
        dp[i][j][k]=dp[i-1][j][k]
  ans=0
  for i in range(1,n+1):
    ans+=dp[n][i][s]*pow(2,n-i,mod)
    ans%=mod
  print(ans)
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[[[0]*(s+1) for _ in range(n+1)] for _ in range(n+1)]
  dp[0][0][0]=1
  for i in range(1,n+1):
    val=arr[i-1]
    for j in range(i,-1,-1):
      for k in range(s,val-1,-1):
        dp[i][j][k]=dp[i-1][j][k]%mod
        dp[i][j][k]+=dp[i-1][j-1][k-val]
      for k in range(val-1,-1,-1):
        dp[i][j][k]=dp[i-1][j][k]%mod
  ans=0
  for i in range(1,n+1):
    ans+=dp[n][i][s]*pow(2,n-i,mod)
    ans%=mod
  print(ans)
calc()

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


Question:
import sys
input=sys.stdin.readline

def calc():
  mod=998244353
  n,s=map(int,input().split())
  arr=list(map(int,input().split()))
  dp=[[[0]*(s+1) for _ in range(n+1)] for _ in range(n+1)]
  dp[0][0][0]=1
  for i in range(1,n+1):
    val=arr[i-1]
    for j in range(i,-1,-1):
      for k in range(s,-1,-1):
        dp[i][j][k]=dp[i-1][j][k]
        if k-val>=0 and dp[i-1][j-1][k-val]!=0:
          dp[i][j][k]+=dp[i-1][j-1][k-val]
          dp[i][j][k]%=mod
  ans=0
  for i in range(1,n+1):
    ans+=dp[n][i][s]*pow(2,n-i,mod)
    ans%=mod
  print(ans)
calc()

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


Question:
n=int(input())
arr1=[]
arr2=[]
for _ in range(n):
  s=input()
  cnt1=0
  cnt2=0
  for i in range(len(s)):
    if s[i]=='(':
      cnt1+=1
    else:
      if cnt1==0:
        cnt2+=1
      else:
        cnt1-=1
  if cnt1-cnt2>=0:
    arr1.append([cnt1,cnt2])
  else:
    arr2.append([cnt1,cnt2])
arr1=sorted(arr1,key=lambda x:x[1])
arr2=sorted(arr2,reverse=True,key=lambda x:x[0])
arr=arr1+arr2
cnt=0
for a,b in arr:
  if b>cnt:
    print('No')
    break
  else:
    cnt+=a-b
else:
  if cnt==0:
    print('Yes')
  else:
    print('No')

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


Question:
n=int(input())
arr=list(map(int,input().split()))
arr=[[arr[i],i] for i in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[0])
dp=[[-1]*(n+1) for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(n):
    if dp[i][j]==-1:
      continue
    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+arr[i][0]*abs(arr[i][1]-j))
    dp[i+1][j]=max(dp[i+1][j],dp[i][j]+arr[i][0]*abs(n-1-(i-j)-arr[i][1]))
print(max(dp[-1]))

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


Question:
def calc():
  n=int(input())
  s=list(input())
  cnt1=0
  cnt2=0
  cnt3=0
  for i in range(n):
      if s[i]=='R':
          cnt1+=1
          s[i]=1
      elif s[i]=='G':
          cnt2+=1
          s[i]=2
      elif s[i]=='B':
          cnt3+=1
          s[i]=4
  ans=cnt1*cnt2*cnt3
  for i in range(n):
      for j in range(i+1,n):
        k=1*j-i
          if k>=n:
            continue
          if s[i]+s[j]+s[k]==7:
            ans-=1
  print(ans)
calc()

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


Question:
n=int(input())
s=input()
cnt=[0,0,0]
for i in range(n):
    if s[i]=='R':
        cnt[0]+=1
    elif s[i]=='G':
        cnt[1]+=1
    elif s[i]=='B':
        cnt[2]+=1
ans=cnt[0]*cnt[1]*cnt[2]
for i in range(n):
    for j in range(i+1,n):
        if 2*j-i>=n:
          continue
        if len(set([s[i],s[j],s[2*j-i]]))==3:
          ans-=1
print(ans)

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


Question:
n=int(input())
s=input()
cnt=[[0,0,0] for _ in range(n)]
for i in range(n):
    if s[i]=='R':
        cnt[i][0]+=1
    elif s[i]=='G':
        cnt[i][1]+=1
    elif s[i]=='B':
        cnt[i][2]+=1
acum=[[0,0,0]]
for i in range(n):
    tmp=[0,0,0]
    for j in range(3):
        tmp[j]+=acum[-1][j]
        tmp[j]+=cnt[i][j]
    acum.append(tmp)
ans=0
for i in range(n):
    for j in range(i+1,n):
        if s[i]==s[j]:
            continue
        if 'R' not in (s[i],s[j]):
            ans+=acum[-1][0]-acum[j][0]
            if 2*j-i<n and s[2*j-i]=='R':
                ans-=1
        elif 'G' not in (s[i],s[j]):
            ans+=acum[-1][1]-acum[j][1]
            if 2*j-i<n and s[2*j-i]=='G':
                ans-=1
        elif 'B' not in (s[i],s[j]):
            ans+=acum[-1][2]-acum[j][2]
            if 2*j-i<n and s[2*j-i]=='B':
                ans-=1
print(ans)

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


Question:
s=int(input())
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')

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


Question:
class SegmentTreeMax():
  def __init__(self,n,init):
    self.offset=2**((n-1).bit_length())
    self.tree=[init]*(2*self.offset)
    self.init=init
  def update(self,pos,val):
    pos+=self.offset
    self.tree[pos]=val
    while pos>1:
      pos=pos//2
      self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])
  def query(self,l,r):
    l+=self.offset
    r+=self.offset
    ret=self.init
    while l<=r:
      ret=max(ret,self.tree[r])
      r=(r-1)//2
      ret=max(ret,self.tree[l])
      l=(l+1)//2
    return ret

mod=998244353
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[0])
st=SegmentTreeMax(n,0)
ranges=[]
for i in range(n):
  x=arr[i][0]+arr[i][1]
  l=-1
  r=n
  while r-l!=1:
    mid=(l+r)//2
    if arr[mid][0]>=x:
      r=mid
    else:
      l=mid
  ranges.append(l)
  st.update(i,r)
for i in range(n-1,-1,-1):
  ranges[i]=st.query(i,ranges[i])
  st.update(i,ranges[i])
dp=[0]*(n+1)
dp[-1]=1
for i in range(n-1,-1,-1):
  j=ranges[i]
  dp[i]=dp[i+1]+dp[j]
  dp[i]%=mod
print(dp[0])

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


Question:
#reference Segment-Tree code from:https://ikatakos.com/pot/programming_algorithm/data_structure/segment_tree

def bisect(pos):
  l=-1
  r=n
  while r-l!=1:
    mid=(l+r)//2
    if arr[mid][0]>=pos:
      r=mid
    else:
      l=mid
  return r

mod=998244353
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[0])
poss=[]
for i in range(n):
  poss.append(bisect(arr[i][0]+arr[i][1]))
poss.append(n)

offset=2**((n-1).bit_length())
st=[0]*(2*offset)

def update(pos,x):
  pos+=offset
  st[pos]=x
  while pos>1:
    y=st[pos^1]
    if x<=y:
      break
    pos>>=1
    st[pos]=x

def get_max(l,r):
  ret=0
  l+=offset
  r+=offset
  while l<r:
    if r&1:
      ret=max(ret,st[r-1])
    if l&1:
      ret=max(ret,st[l])
      l+=1
    l>>=1
    r>>=1
  return ret

for i in range(n):
  update(i,poss[i])
for i in range(n-1,-1,-1):
  poss[i]=get_max(i,poss[i])
  update(i,poss[i])

dp=[0]*(n+1)
dp[-1]=1
for i in range(n-1,-1,-1):
  dp[i]+=dp[i+1]
  dp[i]%=mod
  pos=poss[i]
  dp[i]+=dp[pos]
  dp[i]%=mod
print(dp[0]%mod)

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


Question:
def ctoi(c):
  return ord(c)-97

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

bits=[[0]*(n+1) for _ in range(26)]

def query(pos):
  ret=[0]*26
  for i in range(26):
    tmp=0
    p=pos
    while p>0:
      tmp+=bits[i][p]
      p-=p&(-p)
    ret[i]=tmp
  return ret

def update(pos,a,x):
  while pos<=n:
    bits[a][pos]+=x
    pos+=pos&(-pos)

for i in range(n):
  update(i+1,ctoi(s[i]),1)

q=int(input())
for _ in range(q):
  flag,a,b=map(str,input().split())
  flag=int(flag)
  a=int(a)
  if flag==1:
    if s[a-1]==b:
      continue
    else:
      update(a,ctoi(s[a-1]),-1)
      update(a,ctoi(b),1)
      s[a-1]=b
  elif flag==2:
    b=int(b)
    cnt1=query(b)
    cnt2=query(a-1)
    ans=0
    for i in range(26):
      if cnt1[i]-cnt2[i]>0:
        ans+=1
    print(ans)

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


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

num=2**((n-1).bit_length())
st=[[0]*(2*num) for _ in range(26)]

def update(pos,a,x):
  pos+=num
  st[a][pos]=x
  while pos>=0:
    pos=(pos-1)//2
    st[a][pos]=st[a][2*pos+1]|st[a][2*pos+2]

def query(l,r):
  ret=0
  for a in range(26):
    tl=l+num
    tr=r+num
    tmp=0
    while tl<tr:
      if tr&1==1:
        tr-=1
        tmp=max(tmp,st[a][tr-1])
      if tl&1==1:
        tmp=max(tmp,st[a][tl-1])
        tl+=1
      tl>>=1
      tr>>=1
    if tmp!=0:
      tmp=1
    ret+=tmp
  return ret

for i in range(n):
  update(i,ord(s[i])-97,1)

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)-1
  if a==1:
    if c==s[b]:
      continue
    update(b,ord(s[b])-97,0)
    update(b,ord(c)-97,1)
    s[b]=c
  elif a==2:
    c=int(c)-1
    print(query(b,c+2))

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


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

num=2**((n-1).bit_length())
st=[[0]*(2*num) for _ in range(26)]

def update(pos,a,x):
  pos+=num
  st[a][pos]=x
  while pos>=0:
    pos=(pos-1)//2
    st[a][pos]=max(st[a][2*pos+1],st[a][2*pos+2])

def query(l,r):
  ret=0
  for a in range(26):
    tl=l+num
    tr=r+num
    tmp=0
    while tl<tr:
      if tr&1==1:
        tr-=1
        tmp=max(tmp,st[a][tr-1])
      if tl&1==1:
        tmp=max(tmp,st[a][tl-1])
        tl+=1
      tl>>=1
      tr>>=1
    if tmp!=0:
      tmp=1
    ret+=tmp
  return ret

for i in range(n):
  update(i,ord(s[i])-97,1)

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)-1
  if a==1:
    if c==s[b]:
      continue
    update(b,ord(s[b])-97,0)
    update(b,ord(c)-97,1)
    s[b]=c
  elif a==2:
    c=int(c)-1
    print(query(b,c+2))

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


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

num=2**((n-1).bit_length())
st=[[0]*(2*num) for _ in range(26)]

def update(pos,a,x):
  pos+=num
  st[a][pos]=x
  while pos>=0:
    pos=(pos-1)//2
    st[a][pos]=max(st[a][2*pos+1],st[a][2*pos+2])

def query(l,r):
  ret=0
  for a in range(26):
    tl=l+num
    tr=r+num
    tmp=0
    while tl<tr:
      if tr&1==1:
        tr-=1
        tmp=max(tmp,st[a][tr-1])
      if tl&1==1:
        tmp=max(tmp,st[a][tl-1])
        tl+=1
      tl>>=1
      tr>>=1
    if tmp!=0:
      tmp=1
    print(a,tmp)
    ret+=tmp
  return ret

for i in range(n):
  update(i,ord(s[i])-97,1)

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)-1
  if a==1:
    if c==s[b]:
      continue
    update(b,ord(s[b])-97,0)
    update(b,ord(c)-97,1)
    s[b]=c
  elif a==2:
    c=int(c)-1
    print(query(b,c+2))

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


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

num=2**(n-1).bit_length()
st=[set() for _ in range(2*num)]

def update1(pos,x):
  pos+=num
  st[pos].add(x)
  while pos>=0:
    pos=(pos-1)//2
    st[pos]=st[2*pos+1]|st[2*pos+2]

def update2(pos,x):
  pos+=num
  st[pos].discard(x)
  while pos>=0:
    pos=(pos-1)//2
    st[pos]=st[2*pos+1]|st[2*pos+2]
    st[pos].discard(x)

def query(l,r):
  tl=l+num
  tr=r+num
  ret=set()
  while tl<tr:
    if tr&1==1:
      tr-=1
      ret=ret|st[tr-1]
    if tl&1==1:
      ret=ret|st[tl-1]
      tl+=1
    tl=tl//2
    tr=tr//2
  return len(ret)

for i in range(n):
  update1(i,s[i])

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)-1
  if a==1:
    if c==s[b]:
      continue
    update2(b,s[b])
    s[b-1]=c
    update1(b,c)
    print(st)
  elif a==2:
    c=int(c)-1
    print(query(b,c))

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


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

num=2**(n-1).bit_length()
st=[set() for _ in range(2*num)]

def update1(pos,x):
  pos+=num
  st[pos].add(x)
  while pos>=0:
    pos=(pos-1)//2
    st[pos]=st[2*pos+1]|st[2*pos+2]

def update2(pos,x):
  pos+=num
  st[pos].discard(x)
  while pos>=0:
    pos=(pos-1)//2
    st[pos]=st[2*pos+1]|st[2*pos+2]
    st[pos].discard(x)

def query(l,r):
  tl=l+num
  tr=r+num
  ret=set()
  while tl<tr:
    if tr&1==1:
      tr-=1
      ret=ret|st[tr-1]
    if tl&1==1:
      ret=ret|st[tl-1]
      tl+=1
    tl=tl//2
    tr=tr//2
  return len(ret)

for i in range(n):
  update1(i,s[i])

q=int(input())
for _ in range(q):
  a,b,c=map(str,input().split())
  a=int(a)
  b=int(b)
  if a==1:
    if c==s[b-1]:
      continue
    update2(b,s[b-1])
    s[b-1]=c
    update1(b,c)
  elif a==2:
    c=int(c)
    print(query(b,c+1))

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


Question:
s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))

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


Question:
def calc():
  h,n=map(int,input().split())
  arr=[]
  for _ in range(n):
    arr.append(list(map(int,input().split())))
  dp=[10**10]*20001
  dp[0]=0
  for i in range(20001):
    for j in range(n):
      if i+arr[j][0]>20000:
        continue
      dp[i+arr[j][0]]=min(dp[i+arr[j][0]],dp[i]+arr[j][1])
  ans=10**18
  for i in range(h,20001):
    ans=min(ans,dp[i])
  print(ans)
calc()

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


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

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


Question:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[(2**i)%mod for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(61):
  ans+=(plist[i]*blist[i])*(n-blist[i])+(plist[i]*(n-blist[i]))*blist[i]
  ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)

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


Question:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[2**i for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(n):
  flag=format(arr[i],'b')
  if len(flag)!=61:
    flag='0'*(61-len(flag))+flag
  flag=flag[::-1]
  for j in range(61):
    c=int(flag[j])
    if c==1:
      ans+=plist[j]*(n-blist[j])
      ans%=mod
    else:
      ans+=plist[j]*blist[j]
      ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)

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


Question:
n,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr1=sorted(arr1)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
l=-1
r=10**12+1
while r-l!=1:
  m=(r+l)//2
  tmp=0
  for i in range(n):
    if arr1[i]>m//arr2[i]:
      tmp+=(arr1[i]-m//arr2[i])
  if tmp<=k:
    r=m
  else:
    l=m
print(r)

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


Question:
import collections
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
for v in range(n):
  q=collections.deque()
  q.append((v,1))
  checked=[0]*n
  anss=[]
  while len(q)!=0:
    tmp,depth=q.popleft()
    anss.append(depth)
    checked[tmp]=1
    for v in g[tmp]:
      if checked[v]==0:
        q.append((v,depth+1))
  ans=max(ans,max(anss))
print(ans)

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


Question:
import collections
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
for v in range(n):
  q=collections.deque()
  q.append((v,1))
  checked=[0]*n
  anss=[]
  while len(q)!=0:
    tmp,depth=q.popleft()
    anss.append(depth)
    checked[tmp]=1
    for v in g[tmp]:
      if checked[v]==0:
        q.append((v,depth+1))
  ans=max(ans,max(anss))
print(ans)

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


Question:
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)
g2=[[0]*n for _ in range(n)]
for i in range(n):
  for j in range(n):
    g2[i][j]=int(arr[i][j])

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
d=floyd_warshall(g2)
for i in range(n):
  ans=max(ans,int(max(d[i])+1))
print(ans)

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


Question:
import collections
import sys
sys.setrecursionlimit(10**8)

n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    if arr[i][j]=='1':
      g[i].append(j)

colors=[0]*n

def dfs(v,color):
  colors[v]=color
  for u in g[v]:
    if colors[u]==color:
      return False
    if colors[u]==0 and not dfs(u,-color):
      return False
  return True

def is_bipartite():
  return dfs(0,1)

if is_bipartite()==False:
  print(-1)
  exit()

ans=0
for v in range(n):
  q=collections.deque()
  q.append((v,1))
  checked=[0]*n
  while len(q)!=0:
    tmp,depth=q.popleft()
    ans=max(ans,depth)
    checked[tmp]=1
    for v in g[tmp]:
      if checked[v]==0:
        q.append((v,depth+1))
print(ans)

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


Question:
n=int(input())
arr=[0]+[list(map(int,input().split())) for _ in range(n)]
pos=[0]*(n+1)
ans=0
while 1:
  flag=False
  cnt=0
  check=[0]*(n+1)
  for i in range(1,n+1):
    if check[i]==1:
      continue
    if pos[i]==n-1:
      cnt+=1
      continue
    pair=arr[i][pos[i]]
    if check[pair]==1:
      continue
    if arr[pair][pos[pair]]==i:
      flag=True
      pos[i]+=1
      pos[pair]+=1
      check[i]=1
      check[pair]=1
  if cnt==n:
    print(ans)
    break
  if flag==False:
    print(-1)
    break
  ans+=1

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


Question:
n=int(input())
arr=[0]+[list(map(int,input().split())) for _ in range(n)]
pos=[0]*(n+1)
ans=0
while 1:
  flag=False
  cnt=0
  check=set()
  for i in range(1,n+1):
    if i in check:
      continue
    if pos[i]==n-1:
      cnt+=1
      continue
    pair=arr[i][pos[i]]
    if pair in check:
      continue
    if arr[pair][pos[pair]]==i:
      flag=True
      pos[i]+=1
      pos[pair]+=1
      check.add(i)
      check.add(pair)
  if cnt==n:
    print(ans)
    break
  if flag==False:
    print(-1)
    break
  ans+=1

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


Question:
import heapq

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
for i in range(n):
  if arr2[i]!=arr1[i]:
    heapq.heappush(q,(-arr2[i],i))
cnt=0
while q:
  val,pos=heapq.heappop(q)
  val*=-1
  diff=arr2[pos-1]+arr2[(pos+1)%n]
  move=(val-arr1[pos])//diff
  if move==0:
    break
  cnt+=move
  tmp=arr2[pos]-diff*move
  arr2[pos]=tmp
  if tmp!=arr1[pos]:
    heapq.heappush(q,(-tmp,pos))
for i in range(n):
  if arr1[i]!=arr2[i]:
    print(-1)
    break
else:
  print(cnt)

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


Question:
import heapq

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
dic={}
for i in range(n):
  heapq.heappush(q,(-arr2[i],i))
cnt=0
while q:
  val,pos=heapq.heappop(q)
  val*=-1
  diff=arr2[pos-1]+arr2[(pos+1)%n]
  move=(val-arr1[pos])//diff
  if move==0:
    break
  cnt+=move
  tmp=arr2[pos]-diff*move
  arr2[pos]=tmp
  heapq.heappush(q,-tmp)
for i in range(n):
  if arr1[i]!=arr2[i]:
    print(-1)
    break
else:
  print(cnt)

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


Question:
import heapq

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
for i in range(n):
  heapq.heappush(q,(-arr2[i],i))
cnt=0
num=0
while 1:
  val,pos=-heapq.heappop(q)
  diff=arr2[pos-1]+arr2[(pos+1)%n]
  move=(val-diff)//diff+1
  if move<=0:
    break
  tmp=arr2[pos]-diff*move
  if tmp<=0:
    break
  arr2[pos]=tmp
  heapq.heappush(q,-tmp)
  if tmp==arr1[pos]:
    num+=1
  cnt+=move
  if num==n:
    break
for i in range(n):
  if arr1[i]!=arr2[i]:
    print(-1)
    break
else:
  print(cnt)

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


Question:
import heapq

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
q=[]
dic={}
for i in range(n):
  heapq.heappush(q,-arr2[i])
  dic[arr2[i]]=i
cnt=0
while len(q)!=0:
  val=-heapq.heappop(q)
  pos=dic[val]
  if val==arr1[pos]:
    continue
  diff=arr2[pos-1]+arr2[(pos+1)%n]
  if val-diff<arr1[pos]:
    continue
  move=(val-arr1[pos])//diff
  cnt+=move
  tmp=arr2[pos]-diff*move
  arr2[pos]=tmp
  heapq.heappush(q,-tmp)
  dic[tmp]=pos
for i in range(n):
  if arr1[i]!=arr2[i]:
    print(-1)
    break
else:
  print(cnt)

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


Question:
n=int(input())
dic={}
for _ in range(n):
  s=input()
  s=sorted(s)
  if s not in dic:
    dic[s]=1
  else:
    dic[s]+=1
ans=0
for val in dic.values():
  ans+=val*(val-1)//2
print(ans)

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


Question:
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr2=[[i,0] for i in range(1,m+1)]
arr.extend(arr2)
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
q=[]
ans=0
pos=0
while 1:
  a,b=arr[pos]
  if a>m:
    break
  if a==arr[pos+1][0]:
    heapq.heappush(q,-b)
  else:
    heapq.heappush(q,-b)
    ans-=heapq.heappop(q)
  pos+=1
print(ans)

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


Question:
import heapq

n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,reverse=True,key=lambda x:x[1])
arr=sorted(arr,reverse=True,key=lambda x:x[0])
q=[]
tmp=0
cnt=0
for a,b in arr:
  if tmp!=a:
    tmp=a
    cnt=0
  if m-tmp<cnt:
    continue
  heapq.heappush(q,(-b,a))
  cnt+=1
ans=0
cnt=0
box=[0]*(m+1)
while len(q)!=0:
  if cnt>=m:
    break
  tmp,date=heapq.heappop(q)
  if box[date]==0:
    box[date]=1
    ans-=tmp
    cnt+=1
  else:
    pos=date
    while 1:
      if pos==m:
        break
      pos+=1
      if box[pos]==0:
        box[pos]=1
        ans-=tmp
        cnt+=1
        break
print(ans)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    if tx<k and ty<k:
      if (2*k-(tx+ty))%2==0:
        td=2*k-(tx+ty)
        ans.append([tx+td//2,k-(tx+td//2)])
        ans.append([tx,ty])
      else:
        ans.append([tx,k-tx])
        td=ty-(k-tx)
        ans.append([tx+(k-td//2),ans[-1][1]+td//2])
        ans.append([tx,ty])
      n=len(ans)
    else:
      if tx+ty<2*k:
        if (2*k-(tx+ty))%2==0:
          td=2*k-(tx+ty)
          ans.append([tx+td//2,k-(tx+td//2)])
          ans.append([tx,ty])
        else:
          ans.append([tx,k-tx])
          td=ty-(k-tx)
          ans.append([tx+(k-td//2),ans[-1][1]+td//2])
          ans.append([tx,ty])
      n=len(ans)
      else:
        ans.append([0,0])
  else:
    ans.append([0,0])
    for i in range(tx//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-abs(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for i in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
          break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=ty-ans[-1][1]
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    if tx<k and ty<k:
      if (2*k-(tx+ty))%2==0:
        td=2*k-(tx+ty)
        ans.append([tx+td//2,k-(tx+td//2)])
        ans.append([tx,ty])
      else:
        ans.append([tx,k-tx])
        td=ty-(k-tx)
        ans.append([tx+(k-td//2),ans[-1][1]+td//2])
        ans.append([tx,ty])
      n=len(ans)
    else:
      if tx+ty<2*k:
        ans.append([0,0])
      else:
        ans.append([0,0])
  else:
    ans.append([0,0])
    for i in range(tx//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-abs(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for i in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
          break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=ty-ans[-1][1]
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    if tx<k and ty<k:
      if (2*k-(tx+ty))%2==0:
        td=2*k-(tx+ty)
        ans.append([tx+td//2,k-(tx+td//2)])
        ans.append([tx,ty])
    else:
      ans.append([tx,k-tx])
      td=ty-(k-tx)
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
      if tx+ty<2k:
        ans.append([0,0])
      else:
        ans.append([0,0])
  else:
    ans.append([0,0])
    for i in range(tx//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-abs(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for i in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
          break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=ty-ans[-1][1]
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    ans.append([0,0])
  else:
    ans.append([0,0])
    for i in range(tx//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-abs(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for i in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
          break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=ty-ans[-1][1]
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    ans.append([0,0])
  else:
    ans.append([0,0])
    for i in range(tx//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-abs(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for i in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
          break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=t-ans[-1][1]
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty-(k-tx%k)<k and (ty-(k-tx%k))%2!=0:
    td=0
  else:
    ans.append([0,0])
    for _ in range(x//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for _ in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
        break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=(ty-ans[-1][1])
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
    n=len(ans)
  elif ty+tx%k<2*k:
    arr.append([0,0])
  else:
    ans.append([0,0])
    for _ in range(x//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-(tx-ans[-1][0])])
    td=ty-ans[-1][1]
    if td%k==0:
      flag=True
    else:
      flag=False
    for _ in range(td//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
        break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=(ty-ans[-1][1])
      ans.append([tx+(k-td//2),ans[-1][1]+td//2])
      ans.append([tx,ty])
    ans.pop(0)
    n=len(ans)
  editarr(x,y,ans)
  print(n)
  for a,b in ans:
    print(a,b)

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


Question:
def editarr(x,y,arr):
  if abs(x)>=abs(y):
    for i in range(len(arr)):
      arr[i][0],arr[i][1]=arr[i][1],arr[i][0]
  if x<0:
    for i in range(len(arr)):
      arr[i][0]*=-1
  if y<0:
    for i in range(len(arr)):
      arr[i][1]*=-1

k=int(input())
x,y=map(int,input().split())
ans=[]
tx=abs(x)
ty=abs(y)
if tx>=ty:
  tx,ty=ty,tx
if k%2==0 and (tx+ty)%2!=0:
  print(-1)
else:
  if tx+ty<k:
    if (tx+ty)%2==0:
      m=(ty-tx)//2
      ans.append([k-m,m])
    else:
      td=k-(tx+ty)
      ans.append([tx,ty+td])
      ans.append([tx+(k-td//2),ty+td//2])
    ans.append([tx,ty])
  elif ty+tx%k<2*k:
  else:
    ans.append([0,0])
    for _ in range(x//k):
      ans.append([ans[-1][0]+k,0])
    if ans[-1][0]!=tx:
      ans.append([tx,k-ans[-1][0]])
    if (ty-ans[-1][1])%k==0:
      flag=True
    else:
      flag=False
    for _ in range((ty-ans[-1][1])//k):
      if flag==False and (ty-ans[-1][1])%2==0 and (ty-ans[-1][1])<=2*k:
        break
      ans.append([tx,ans[-1][1]+k])
    if ans[-1][1]!=ty:
      td=(ty-ans[-1][1])
      ans.append([tx+(k-td//2),ty+td//2])
      ans.append([tx,ty])
    ans.pop(0)
  editarr(x,y,ans)
  print(len(ans))
  for a,b in ans:
    print(a,b)

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


Question:
k=int(input())
x,y=map(int,input().split())
d=abs(x)+abs(y)
tg=max(abs(x),abs(y))
ts=k-min(abs(x),abs(y))%k
if k%2==0 and d%2!=0:
  #print(-1)
  print(0)
else:
  ans=[]
  if d<k and d%2==1:
    n=3
    td=k-d
    if y>=0:
      ans.append((x,y+td))
      ans.append((x+(k-td//2),y+td//2))
      ans.append((x,y))
    else:
      ans.append((x,y-td))
      ans.append((x+(k-td//2),y-td//2))
      ans.append((x,y))
  elif d<k and d%2==0:
    n=2
    if abs(x)>=abs(y):
      m=(abs(x)-abs(y))//2
      tk=k-m
      if x<0:
        m*=-1
      if y<0:
        tk*=-1
      ans.append((m,tk))
    else:
      m=(abs(y)-abs(x))//2
      tk=k-m
      if y<0:
        m*=-1
      if x<0:
        tk*=-1
      ans.append((tk,m))
    ans.append((x,y))
  print(n)
  for tx,ty in ans:
    print(tx,ty)

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


Question:
k=int(input())
x,y=map(int,input().split())
d=abs(x)+abs(y)
tg=max(abs(x),abs(y))
ts=k-min(abs(x),abs(y))%k
if k%2==0 and d%2!=0:
  print(0)
else:
  ans=[]
  if d<k and d%2==1:
    n=3
    td=k-d
    if y>=0:
      ans.append((x,y+td))
      ans.append((x+(k-td//2),y+td//2))
      ans.append((x,y))
    else:
      ans.append((x,y-td))
      ans.append((x+(k-td//2),y-td//2))
      ans.append((x,y))
  print(n)
  for tx,ty in ans:
    print(tx,ty)

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


Question:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
pos=[[] for _ in range(2*10**5+1)]
pos[0].append(-1)
arrpos=[0]*n
for i in range(n):
  pos[arr[i]].append(i)
  arrpos[i]=len(pos[arr[i]])
ans=[]
tmp=[0]
cnt=0
while len(tmp)!=0:
  p=pos[tmp[0]][0]+1
  ntmp=[]
  flag=True
  while p<n:
    if arrpos[p]<len(pos[arr[p]]):
      p=pos[arr[p]][arrpos[p]]+1
    else:
      ntmp.append(arr[p])
      if len(pos[arr[p]])!=1:
        flag=False
      p+=1
  ans.append(ntmp)
  tmp=ntmp
  cnt+=1
  if flag==True:
    break
for i in range(1,len(tmp)+1):
  ans.append(tmp[i:])
print(*ans[k%len(ans)-1])

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


Question:
import collections
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)]
num=1
ans=collections.deque([arr[0]])
print(ans)
for i in range(1,n):
  tmp=ans.popleft()
  if arr[i]<=tmp:
    ans.appendleft(tmp)
    ans.appendleft(arr[i])
  else:
    ans.appendleft(tmp)
    pos=bisect.bisect_right(ans,arr[i])
    ans[pos-1]=arr[i]
  print(ans)
print(ans)

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


Question:
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS = [arr[0]]
for i in range(1,n):
  print(LIS)
  if arr[i] >= LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_left(LIS, arr[i])] = arr[i]
print(len(LIS))

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


Question:
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=[-1]*(n+1)
num=1
ans[0]=arr[0]
for i in range(1,n):
  for j in range(num):
    if ans[j]<arr[i]:
      ans[j]=arr[i]
      break
  else:
    ans[num]=arr[i]
    num+=1
print(num)

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


Question:
n=int(input())
arr=[int(input()) for _ in range(n)]
ans=0
while 1:
  tmp=[]
  if len(arr)==0:
    break
  val=arr[0]
  for i in range(1,len(arr)):
    if arr[i]>val:
      val=arr[i]
    else:
      tmp.append(arr[i])
  arr=tmp
  ans+=1
print(ans)

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


Question:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
list2=[a%10,b%10,c%10,d%10,e%10]
worst=10
worstnum=0
flag=0
count=0
for i in range(5):
  if list2[i] != 0:
    if list2[i] < worst:
      worst = list2[i]
      flag = i
      worstnum=list[i]
  list[i] += 10-list[i]%10
for i in range(5):
  if i = flag:
    count += worstnum
  else:
    count += list[i]
print(count)

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


Question:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
list2=[a%10,b%10,c%10,d%10,e%10]
worst=10
worstnum
flag=0
count=0
for i in range(5):
  if list2[i] != 0:
    if list2[i] < worst:
      worst = list2[i]
      flag = i
  list[i] += 10-list[i]%10
for i in range(5):
  if i = flag:
    count += worstnum
  else:
    count += list[i]
print(count)

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


Question:
import heapq

a,b,c,k=map(int,input())
arr1=list(map(int,input().split()))
arr1=sorted(arr1,reverse=True)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
arr3=list(map(int,input().split()))
arr3=sorted(arr3,reverse=True)
heap=[]
heapq.heappush(heap,(-(arr1[0]+arr2[0]+arr3[0]),0,0,0))
s={(0,0,0)}
for _ in range(k):
  v,i,j,k=heapq.heappop(heap)
  if i+1<a and (i+1,j,k) not in s:
    s.add((i+1,j,k))
    heapq.heappush(heap,(-(arr1[i+1]+arr2[j]+arr3[k]),i+1,j,k))
  if j+1<b and (i,j+1,k) not in s:
    s.add((i,j+1,k))
    heapq.heappush(heap,(-(arr1[i]+arr2[j+1]+arr3[k]),i,j+1,k))
  if k+1<c and (i,j,k+1) not in s:
    s.add((i,j,k+1))
    heapq.heappush(heap,(-(arr1[i]+arr2[j]+arr3[k+1]),i,j,k+1))
  print(-v)

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


Question:
s=input()
l=len(s)
ans=0
for i in range(l):
  for j in range(1,l):
    t=s[i:i+j]
    for k in range(j):
      if t[k] not in ['A','C','G','T']:
        break
    else:
      ans=max(ans,j-i+1)
print(ans)

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


Question:
n,m=map(int,input().split())
s=input()
for i in range(m):
  a,b=map(int,input().split())
  count=0
  tmp=s[a-1:b]
  for j in range(len(tmp)-1):
    if tmp[j]=='A' and tmp[j+1]=='C':
      count+=1
  print(count)
  count=0

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


Question:
a,b,k=map(int,input().split())
count=0
ans=0
for i in range(200):
  if a%i==0 and b%i==0:
    count+=1
  if count==k:
    ans=i
print(ans)

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


Question:
import sys
sys.setrecursionlimit(10**9)

def multigcd(n,arr):
  a,b=max(n,arr[0]),min(n,arr[0])
  while b!=0:
    a,b=b,a%b
  if len(arr)==1:
    return a
  else:
    return multigcd(a,arr[1:])

n=int(input())
arr=list(map(int,input().split()))
print(multigcd(arr[0],arr[1:]))

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


Question:
def multigcd(n,arr):
  a,b=max(n,arr[0]),min(n,arr[0])
  while b!=0:
    a,b=b,a%b
  if len(arr)==1:
    return a
  else:
    return multigcd(a,arr[1:])

n=int(input())
arr=list(map(int,input().split()))
print(multigcd(arr[0],arr[1:]))

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


Question:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input()))
tmp=gcd(arr[0],arr[1])
for i in range(1,n):
  tmp=gcd(tmp,arr[i])
print(tmp)

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


Question:
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n=int(input())
arr=list(map(int,input()))
for i in range(n-1):
  tmp=gcd(arr[i],arr[i+1])
print(tmp)

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


Question:
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
dic={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]*(n+1)
for i in range(n+1):
  for val in arr:
    if i-dic[val]<0:
      continue
    else:
      dp[i]=max(dp[i],dp[i-dic[val]]+1)
ans=''
tmp=n
while tmp>0:
  for val in arr:
    if tmp-dic[val]<0:
      continue
    if dp[tmp]==dp[tmp-dic[val]]+1:
      ans+=str(val)
      tmp-=dic[val]
      break
  else:
    break
last=dic[int(ans[-1])]
cand=[]
for val in arr:
  if dic[val]-last==tmp:
    cand.append(val)
cand=sorted(cand,reverse=True)
ans=ans[:-1]+str(cand[0])
print(ans)

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


Question:
n=int(input())
arr=[int(input()) for _ in range(n)]
arr=sorted(arr)
total=sum(arr[:-1])
if arr[-1]<total:
  print('Yes')
else:
  print('No')

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


Question:
def calc():
  n,k=map(int,input().split())
  arr=list(map(int,input().split()))
  flag=format(k,'b')[::-1]
  l=len(flag)
  xor1=0
  cnt=0
  for i in range(l-2,-1,-1):
    for j in arr:
      if j&(2**i)!=0:
        cnt+=1
    if cnt<=n//2:
      xor1+=2**i
    cnt=0
  ans1=0
  for i in arr:
    ans1+=i^xor1
  xor2=0
  cnt=0
  check=False
  for i in range(l-1,-1,-1):
    if check==False and flag[i]=='0':
      continue
    for j in arr:
      if j&(2**i)!=0:
        cnt+=1
    if cnt<=n//2:
      if check==True or flag[i]=='1':
        xor2+=2**i
    else:
      if flag[i]=='1':
        check=True
    cnt=0
  ans2=0
  for i in arr:
    ans2+=i^xor2
  print(max(ans1,ans2))

calc()

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


Question:
arr=[j for j in input().split()]
arr=sorted(arr)
print(int(arr[0]*arr[1]/2))

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


Question:
def mks(num):
  s=str(num)
  if len(s)<6:
    s='0'*(6-len(s))+s
  return s

n,m=map(int,input().split())
arr=[]
for i in range(m):
  p,y=map(int,input().split)
  arr.append([p,y,i])
ans=[0]*m
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
cnt=1
for i in range(m):
  if arr[i][0]==tmp:
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
  else:
    cnt=1
    tmp=arr[i][0]
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
for i in range(m):
  print(ans[i])

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


Question:
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n,x=map(int,input().split())
arr=list(map(int,input().split()))
arr.append(x)
arr=sorted(arr)
arr2=[]
for i in range(n-1):
  arr2.append(arr[i+1]-arr[0])
if n==1:
  print(abs(arr[0]-x))
else:
  ans=gcd(arr2[0],arr2[1])
  for i in range(1,n):
    ans=gcd(ans,arr2[i])
  print(ans)

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


Question:
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

n,x=map(int,input())
arr=list(map(int,input().split()))
arr.append(x)
arr=sorted(arr)
arr2=[]
for i in range(n-1):
  arr2.append(arr[i+1]-arr[0])
if n==1:
  print(abs(arr[0]-x))
else:
  ans=gcd(arr2[0],arr2[1])
  for i in range(1,n):
    ans=gcd(ans,arr2[i])
  print(ans)

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


Question:
n=int(input())
if n<105:
  print(0)
elif n<135:
  print(1)
elif n<165:
  print(2):
elif n<189:
  print(3)
elif n<195:
  print(4)
else:
  print(5)

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


Question:
def S(num):
  ret=0
  for i in range(9):
    ret+=int((num%(10**(i+1)))/(10**i))
  return ret

n=int(input())
a=S(n)
if n%a == 0:
  print('Yes')
else:
  print('No')

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


Question:
def calc():
  n=int(input())
  arr=[list(input()) for _ in range(n)]
  ans=0
  for k in range(n):
    flag=True
    for i in range(1,n//2+1):
      for j in range(n):
        if arr[(j)%n][(k+j+i)%n]!=arr[(j+i)%n][(k+j+n)%n]:
          flag=False
          break
      if flag==False:
        break
    else:
      ans+=n
  print(ans)
calc()

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


Question:
n=int(input())
arr=[list(input()) for _ in range(n)]
ans=0
for k in range(n):
  flag=True
  for i in range(1,n//2+1):
    for j in range(n):
      if arr[(j)%n][(k+j+i)%n]!=arr[(j+i)%n][(k+j+n)%n]:
        flag=False
        break
    if flag==False:
      break
  else:
    ans+=n
print(ans)

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


Question:
n=int(input())
arr=[input() for _ in range(n)]
count=0
if arr.count('P')!=0:
  count+=1
if arr.count('Y')!=0:
  count+=1
if arr.count('W')!=0:
  count+=1
if arr.count('G')!=0:
  count+=1
if count==3:
  print('Three')
if count==4:
  print('Four')

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


Question:
n=input()
if len(n)==1:
  print(int(n))
else:
  cnt=n[1:].count('9')
  if cnt1==len(n)-1:
    print(int(n[0])+9*(len(n)-1))
  else:
    print(int(n[0])-1+9*(len(n)-1))

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


Question:
import math
pi=3.141592657589793238462643383279

#quoted from https://qiita.com/kkttm530/items/d6ca372491b75baeac3c
def signed_area(p1, p2, p3):
    '''符号付き面積を計算 '''

    area = (((p2[0] - p1[0]) * (p3[1] - p1[1])) - ((p3[0] - p1[0]) * (p2[1] - p1[1]))) / 2
    return area

def convex_hull(p_list):
    '''グラハムの凸包走査 '''

    p_sort = []
    for i in p_list:
        p_sort.append(i[0])

    # x座標が最小のものをリストの先頭に配置。
    min_index = p_sort.index(min(p_sort))
    min_p = p_list.pop(min_index)
    p_list.insert(0, min_p)

    # 座標最小の点と他の点との角度順にソート ソートアルゴリズムに選択の余地が有る。
    p_length = len(p_list)
    count = 0
    index = 0
    while True:
        count += 1
        index += 1

        area_sign = signed_area(p_list[0], p_list[index], p_list[index + 1])

        # 符号付き面積が負ならば点を入れ替え
        if area_sign < 0:
            p_list[index], p_list[index + 1] = p_list[index + 1], p_list[index]
            count = 0

        if count == p_length - 1:
            break

        if index == p_length - 2:
            index = 0

    # 凹部の点を削除する。
    index = -1
    count = 0
    while True:
        index += 1
        count += 1

        area_sign = signed_area(p_list[index], p_list[index + 1], p_list[index + 2])
        if area_sign < 0:
            del p_list[index + 1]
            count = 0

        if count == len(p_list):
            break

        if index >= len(p_list) - 3:
            index = -1
    return p_list

def getVectorLength(x,y):
  return (x**2+y**2)**0.5

def dotProduct(u,v):
  return u[0]*v[0]+u[1]*v[1]

def vectorsAngle(u,v):
  l1=getVectorLength(u[0],u[1])
  l2=getVectorLength(v[0],v[1])
  cosTheta=dotProduct(u,v)/(l1*l2)
  theta=math.acos(cosTheta)
  return 180*theta/pi

n=int(input())
arr=[]
for _ in range(n):
  x,y=map(int,input().split())
  arr.append((x,y))
arr2=convex_hull(arr[:])
ans=[0]*n
if n==2:
  print(0.5)
  print(0.5)
else:
  for i in range(n):
    pos=arr[i]
    if pos not in arr2:
      continue
    else:
      idx=arr2.index(pos)
      pos1=arr2[idx-1]
      pos2=arr2[(idx+1)%len(arr2)]
      x1=pos[0]-pos1[0]
      y1=pos[1]-pos1[1]
      x2=pos2[0]-pos[0]
      y2=pos2[1]-pos[1]
      angle=math.atan2(x1*y2-x2*y1,x1*x2+y1*y2)
      ans[i]=angle/(2*pi)
  for i in range(n):
    print(ans[i])

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


Question:
a,b,c,d=map(int,input())
if a<=c<=b:
  if b<d:
    print(b-c)
  else:
    print(d-c)
elif c<=a<=d:
  if b<d:
    print(b-a)
  else:
    print(d-a)
else:
  print(0)

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


Question:
a,b,c,d=map(int,input())
if a<=c<=b:
  if b<d:
    print(b-c)
  else:
    print(d-c):
elif c<=a<=d:
  if b<d:
    print(b-a)
  else:
    print(d-a):
else:
  print(0)

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


Question:
check='abcdefghijklmnopqrstuvwxyz'
s=input()
l=len(s)
pos=[0]*26
for i in range(l):
  for j in range(26):
    if s[i]==check[j]:
      pos[j].append(i)
ans=10**9:
  for i in range(26):
    tmp=0
    for j in range(len(pos[i])-1):
      tmp=max(tmp,pos[i][j+1]-pos[i][j])
    tmp=max(tmp,(l-1)-pos[i][-1])
    ans=min(ans,tmp)
print(ans)

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


Question:
n,m=map(int,input().split())
g=[[]*for _ in range(n+1)]
for _ in range(m):
  u,v=map(int,input().split())
  g[u].append(v)
  g[v].append(u)
flag=True
for i in range(1,n+1):
  if g[i]%2==0:
    continue
  else:
    flag=False
    break
if flag==True:
  print('YES')
else:
  print('NO')

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


Question:
import collections

def calc(x,y):
  cnt1=(x+k-1)//k
  cnt2=(w-1-x+k-1)//k
  cnt3=(y+k-1)//k
  cnt4=(h-1-y+k-1)//k
  return min(cnt1,cnt2,cnt3,cnt4)

h,w,k=map(int,input().split())
boards=[tuple(input()) for _ in range(h)]
for i in range(h):
  for j in range(w):
    if boards[i][j]=='S':
      sx=j
      sy=i
      break
q=collections.deque()
checked=[[0]*w for _ in range(h)]
checked[sy][sx]=1
q.append((sx,sy,0))
ans=1+calc(sx,sy)
while 1:
  if len(q)==0:
    break
  tx,ty,cnt=q.popleft()
  if cnt==k+1:
    break
  ans=min(ans,1+calc(tx,ty))
  if tx!=0 and boards[ty][tx-1]!='#' and checked[ty][tx-1]==0:
    checked[ty][tx-1]=1
    q.append((tx-1,ty,cnt+1))
  if tx!=w-1 and boards[ty][tx+1]!='#' and checked[ty][tx+1]==0:
    checked[ty][tx+1]=1
    q.append((tx+1,ty,cnt+1))
  if ty!=0 and boards[ty-1][tx]!='#' and checked[ty-1][tx]==0:
    checked[ty-1][tx]=1
    q.append((tx,ty-1,cnt+1))
  if ty!=h-1 and boards[ty+1][tx]!='#' and checked[ty+1][tx]==0:
    checked[ty+1][tx]=1
    q.append((tx,ty+1,cnt+1))
print(ans)

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


Question:
import collections

def calc(x,y):
  cnt1=(x+k-1)//k
  cnt2=(w-1-x+k-1)//k
  cnt3=(y+k-1)//k
  cnt4=(h-1-y+k-1)//k
  return min(cnt1,cnt2,cnt3,cnt4)

h,w,k=map(int,input().split())
boards=[list(input()) for _ in range(h)]
for i in range(h):
  for j in range(w):
    if boards[i][j]=='S':
      sx=j
      sy=i
      break
q=collections.deque()
checked=[[0]*w for _ in range(h)]
checked[sy][sx]=1
q.append((sx,sy,0))
ans=1+calc(sx,sy)
while 1:
  if len(q)==0:
    break
  tx,ty,cnt=q.popleft()
  if cnt==k+1:
    break
  ans=min(ans,1+calc(tx,ty))
  if tx!=0 and boards[ty][tx-1]!='#' and checked[ty][tx-1]==0:
    checked[ty][tx-1]=1
    q.append((tx-1,ty,cnt+1))
  if tx!=w-1 and boards[ty][tx+1]!='#' and checked[ty][tx+1]==0:
    checked[ty][tx+1]=1
    q.append((tx+1,ty,cnt+1))
  if ty!=0 and boards[ty-1][tx]!='#' and checked[ty-1][tx]==0:
    checked[ty-1][tx]=1
    q.append((tx,ty-1,cnt+1))
  if ty!=h-1 and boards[ty+1][tx]!='#' and checked[ty+1][tx]==0:
    checked[ty+1][tx]=1
    q.append((tx,ty+1,cnt+1))
print(ans)

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


Question:
s=str(input())
s1=str[:5]
s2=str[6:13]
s3=str[14:]
print('{} {} {}'.format(s1,s2,s3))

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


Question:
s=str(input())
s1=str[:5]
s2=str[6:12]
s3=str[14:]
print('{} {} {}'.format(s1,s2,s3))

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


Question:
a_i,a_o,a_t,a_j,a_l,a_s,a_z=map(int,input().split())
ans1=0
ans1+=a_o
ans2=0
for i in range(min(a_i,a_j,a_l)+1):
  tmp=3*i+2*((a_i-i)//2+(a_j-i)//2+(a_l-i)//2)
  ans2=max(ans2,tmp)
print(ans1+ans2)

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


Question:
import collections

s=input()
n=len(s)
slen=collections.deque()
tlen=collections.deque()
cnt=0
ans=0
for i in range(n):
  if s[i]=='S':
    tpos=i
    break
else:
  tpos=n
for i in range(n-1,-1,-1):
  if s[i]=='T':
    spos=i
    break
else:
  spos=-1
s=s[tpos:spos+1]+'x'
for i in range(len(s)-1):
  cnt+=1
  if s[i]!=s[i+1]:
    if s[i]=='S':
      slen.append(cnt)
      cnt=0
    else:
      tlen.append(cnt)
      cnt=0
for i in range(len(slen)):
  stmp,ttmp=slen.popleft(),tlen.popleft()
  if stmp>ttmp:
    ans+=ttmp
    tmp=slen.popleft()+(stmp-ttmp)
    slen.appendleft(tmp)
  else:
    ans+=stmp
print(n-ans*2)

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


Question:
import collections

s=input()
n=len(s)
slen=collections.deque()
tlen=collections.deque()
cnt=0
ans=0
for i in range(n):
  if s[i]=='S':
    tpos=i
    break
else:
  tpos=n
for i in range(n-1,-1,-1):
  if s[i]=='T':
    spos=i
    break
else:
  spos=-1
s=s[tpos:spos+1]+'x'
for i in range(len(s)-1):
  cnt+=1
  if s[i]!=s[i+1]:
    if s[i]=='S':
      slen.append(cnt)
      cnt=0
    else:
      tlen.append(cnt)
      cnt=0
for i in range(len(slen)):
  stmp,ttmp=slen.popleft(),tlen.popleft()
  if stmp>ttmp:
    ans+=ttmp
    tmp=stmp.popleft()+(stmp-ttmp)
    slen.appendleft(tmp)
  else:
    ans+=stmp
print(n-ans*2)

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


Question:
s=input()
ans=[0]*4
checK='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]+=1
if (ans[0]%2+ans[2]%2)%2==0 and (ans[1]%2+ans[3]%2)%2==0:
  print('Yes')
else:
  print('No')

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


Question:
s=input()
ans=[0]*4
checK='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]+=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')

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


Question:
import math
import sys
from functools import lru_cache
sys.setrecursionlimit(10000000)

N = int(input())
A_list = [int(e) for e in input().split()]

#pairwise coprime …… 素因数分解したとき、共通のものが1個もない
#setwise coprime　…… 素因数分解したとき、全てで共通のものがない

#試し割の結果の辞書を求める
def make_trial_division_dict(n):
    #import math
    td_dict = dict()
    for i in range(2,n+1):
        if i not in td_dict:
            td_dict[i] = i
            for j in range(2,1+n//i):
                if j*i not in td_dict:
                    td_dict[j*i] = i
    td_dict[1] = 1
    return td_dict

#試し割結果の辞書を利用して素因数分解する
#@lru_cache(maxsize=None)
#def high_speed_prime_factorization(n):
#    pf_list = list()
#    pf_list.append(td_dict[n])
#
#    if n//td_dict[n] == 1:
#        if n!=1:
#            pf_list.append(1)
#        return pf_list
#    else:
#        pf_list.extend(high_speed_prime_factorization(n//td_dict[n]))
#        return pf_list

td_dict = make_trial_division_dict(max(A_list))

all_pf = set()    #含まれる素因数がすべて集約される
common_pf = set() #共通する素因数が集約される
all_pf |= set(td_dict[A_list[0]])
common_pf |= set(td_dict[A_list[0]])
is_pairwise = True

#print(A_list[0],set(high_speed_prime_factorization(A_list[0])))

for i in range(1,len(A_list)):
    A_pf = set(td_dict[A_list[i]])
    common_pf &= A_pf

    #print(A_list[i],set(high_speed_prime_factorization(A_list[i])))

    if is_pairwise and len(all_pf&A_pf)!=1: #1は共通で含まれる
        is_pairwise = False
    else:
        all_pf |= A_pf

if is_pairwise:
    print("pairwise coprime")
elif len(common_pf) == 1: #1は共通で含まれる
    print("setwise coprime")
else:
    print("not coprime")

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


Question:
import math
import sys
from functools import lru_cache
sys.setrecursionlimit(10000000)

N = int(input())
A_list = [int(e) for e in input().split()]

#pairwise coprime …… 素因数分解したとき、共通のものが1個もない
#setwise coprime　…… 素因数分解したとき、全てで共通のものがない

def main():
    #試し割の結果の辞書を求める
    def make_trial_division_dict(n):
        #import math
        td_dict = dict()
        for i in range(2,n+1):
            if i not in td_dict:
                td_dict[i] = i
                for j in range(2,1+n//i):
                    if j*i not in td_dict:
                        td_dict[j*i] = i
        td_dict[1] = 1
        return td_dict

    #試し割結果の辞書を利用して素因数分解する
    @lru_cache(maxsize=None)
    def high_speed_prime_factorization(n):
        pf_list = list()
        pf_list.append(td_dict[n])

        if n//td_dict[n] == 1:
            if n!=1:
                pf_list.append(1)
            return pf_list
        else:
            pf_list.extend(high_speed_prime_factorization(n//td_dict[n]))
            return pf_list

    td_dict = make_trial_division_dict(max(A_list))

    all_pf = set()    #含まれる素因数がすべて集約される
    common_pf = set() #共通する素因数が集約される
    all_pf |= set(high_speed_prime_factorization(A_list[0]))
    common_pf |= set(high_speed_prime_factorization(A_list[0]))
    is_pairwise = True

    #print(A_list[0],set(high_speed_prime_factorization(A_list[0])))

    for i in range(1,len(A_list)):
        A_pf = set(high_speed_prime_factorization(A_list[i]))
        common_pf &= A_pf

        #print(A_list[i],set(high_speed_prime_factorization(A_list[i])))

        if is_pairwise and len(all_pf&A_pf)!=1: #1は共通で含まれる
            is_pairwise = False
        else:
            all_pf |= A_pf

    if is_pairwise:
        print("pairwise coprime")
    elif len(common_pf) == 1: #1は共通で含まれる
        print("setwise coprime")
    else:
        print("not coprime")

main()

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