Question:
from itertools import product
import copy
H,W,K = list(map(int, input().split()))
A = []
for i in range(H):
  A.append(list(map(int, input())))

#SM = [np.cumsum(A[i]) for i in range(H)]

ANS = []
for pat in product(['0','1'], repeat = H-1):
  res = []
  cnt = 0
  now = copy.copy(A[0])
  for i in range(1,H):
    p = pat[i-1]
    if p == '1':
      res.append(now)
      now = copy.copy(A[i])
      cnt += 1
    else:
      for j in range(W):
        now[j] += A[i][j]
  res.append(now)

  """
  print("---")
  print(pat)
  print(res)
  print(cnt)
  """
  wk2 = [0] * len(res)
  cnt2 = 0
  flg = True
  for x in range(W):
    for j in range(len(res)):
      if res[j][x] > K:
        # 横に割った段階で、すでに最小単位がKを超えてたら実現不可能
        flg = False
        break
      if wk2[j] + res[j][x] > K:
        cnt2 += 1
        wk2 = [0] * len(res)
        break
    for j in range(len(res)):
      wk2[j] += res[j][x]
    if not flg:
      break

  if flg:
    ANS.append(cnt + cnt2)
    #print(pat, cnt, cnt2)
print(min(ANS))

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


Question:
from itertools import product
import copy
H,W,K = list(map(int, input().split()))
A = []
for i in range(H):
  A.append(list(map(int, input())))

#SM = [np.cumsum(A[i]) for i in range(H)]

ANS = []
for pat in product(['0','1'], repeat = H-1):
  res = []
  cnt = 0
  now = copy.copy(A[0])
  for i in range(1,H):
    p = pat[i-1]
    if p == '1':
      res.append(now)
      now = copy.copy(A[i])
      cnt += 1
    else:
      for j in range(W):
        now[j] += A[i][j]
  res.append(now)

  wk = [0 for _ in range(len(res))]
  for x in range(W):
    flg = True
    while flg:
      for j in range(len(res)):
        wk[j] += res[j][x]
      if max(wk) > K:
        cnt += 1
        flg = True
        wk = [0 for _ in range(len(res))]
      else:
        break
  ANS.append(cnt)

print(min(ANS))

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


Question:
from itertools import product
import numpy as np
H,W,K = list(map(int, input().split()))
A = []
for i in range(H):
  A.append(np.array(list(map(int, input()))))

#SM = [np.cumsum(A[i]) for i in range(H)]

ANS = []
for pat in product(['0','1'], repeat = H-1):
  res = []
  cnt = 0
  now = np.copy(A[0])
  for i in range(1,H):
    p = pat[i-1]
    if p == '1':
      res.append(now)
      now = np.copy(A[i])
      cnt += 1
    else:
      now += A[i]
  res.append(now)

  wk = [0 for _ in range(len(res))]
  for x in range(W):
    flg = True
    while flg:
      for j in range(len(res)):
        wk[j] += res[j][x]
      if max(wk) > K:
        cnt += 1
        flg = True
        wk = [0 for _ in range(len(res))]
      else:
        break
  ANS.append(cnt)

print(min(ANS))

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


Question:
from collections import deque
N = int(input())
S = []
for _ in range(N):
  S.append(input())

G = [[] for _ in range(N)]
for i in range(N):
  for j in range(i+1,N):
    if S[i][j] == '1':
      G[i].append(j)
      G[j].append(i)

# 2部グラフ判定
visited = [False] * N
willSearch = [False] * N
Color = [-1] * N
Q = deque()
Q.append((0,0))
while Q:
  now, c = Q.pop()
  visited[now] = True
  Color[now] = c
  for nxt in G[now]:
    if Color[nxt] >= 0 and c == Color[nxt]:
      #隣接色が一致してしまった
      print(-1)
      exit(0)
    if visited[nxt] or willSearch[nxt]:
      continue
    Q.append((nxt,1-c)) # 1-cで0/1を交換
    willSearch[nxt] = True

INF = 1000
D = [[INF for _ in range(N) ]  for _ in range(N)]
for i in range(N):
  for nxt in G[i]:
    D[i][nxt] = 1
    D[nxt][i] = 1

#Warshall-Floyd
for k in range(N):
  for i in range(N):
    for j in range(N):
      #print(i,j,k)
      D[i][j] = min(D[i][j], D[i][k] + D[k][j])

#print(*D, sep="\n")

ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans = max(ans, D[i][j])

print(ans+1)

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


Question:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//using T = tuple<string, int, int>;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  cout << max(C-(A-B), 0) << endl;

  return 0;
}

// https://github.com/atcoder/live_library

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


Question:
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

ans = 0

for i in range(N):
  work = C
  for j in range(M):
    work += A[j] * B[j]
  if work >= 0:
    ans += 1

print(ans)

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


Question:
import heapq
N,K = map(int, input().split())

I = []
for _ in range(N):
  t,d = map(int, input().split())
  I.append((d,t))

I.sort(reverse=True)

# heap_can_delete
h_d = []
# heap_can_add
h_a = []

wk = 0
kind = 0
# 出現したことのあるネタ
ap = set()
for i in range(K):
  d,t = I[i]
  wk += d
  if t not in ap:
    ap.add(t)
    kind += 1
  else:
    heapq.heappush(h_d, (d,t))

for i in range(K,N):
  d,t = I[i]
  if t not in ap:
    ap.add(t)
    # maxをpopさせるために、価値を-1かけておく
    heapq.heappush(h_a, ((-1) * d, t))

ans = wk + kind ** 2
while len(h_d) > 0:
  d1,t1 = heapq.heappop(h_d)
  d2,t2 = heapq.heappop(h_a)
  d2 = (-1) * d2
  wk = wk - d1 + d2
  kind += 1
  ans = max(ans, wk + kind ** 2)

print(ans)

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


Question:
N, M = map(int, input().split())

work = M//N

while work > 0:
  if M%work == 0:
    print(work)
    exit(0)
  work -= 1

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


Question:
N, M = map(int, input().split())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(M)
#print(fct, num(fct))

ans = 1
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)

print(ans)

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


Question:
N, M = map(int, input().split())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a

fct = factorize(M)
#print(fct, num(fct))

sum_i = int(1e9+7)
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if temp >= N:
      sum_i = min(sum_i, temp)

print(M // sum_i)

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


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

if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")

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


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

def chr2ord(c):
  return ord(c) - ord('a')

N = int(input())
S = []
for i in range(N):
  wk = list(input())
  S.append(wk)

ANS = 0
# A=0として、0<=B<Nをためす。
# こたえはN倍。
for b in range(N):
  cnt = 0
  B = [['X' for _ in range(N)] for _ in range(N)]
  for i in range(N):
    for j in range(N):
      B[i][j] = S[i][(j+b)%N]
  #print(B)
  for i in range(N):
    for j in range(N):
      if B[i][j] == B[j][i]:
        cnt += 1

  if cnt == N*N:
    ANS += N
print(ANS)

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


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

cnt = 0
for x in A:
  if A%2 == 1:
    cnt += 1

if cnt % 2 == 0:
  print("YES")
else:
  print("NO")

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


Question:
N,M = list(map(int,input().split()))
dist = [[1e9 for i in range(N)] for j in range(N)]
E = []

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

for i in range(M):
  a,b,c = list(map(int,input().split()))
  a, b = a-1, b-1 # 0-indexed
  dist[a][b] = c
  dist[b][a] = c
  E.append([a,b,c])

# Warshal-Floyd
for k in range(N):
  for i in range(N):
    for j in range(N):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

ans = 0
for e in E:
  a,b,c = e
  flg = False
  for i in range(N):
    for j in range(N):
      if i == j : #or i == a or i == b or j == a or j == b:
        continue
      if dist[i][a] + c + dist[b][j] == dist[a][b]:
        #print(i,a,b,j)
       # print(dist[i][a], c, dist[b][j] , ":", dist[a][b])
        flg = True
        break
    if flg:
      break
  if not flg:
    ans += 1

print(ans)

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


Question:
k, q = map(int, input().split())
d = list(map(int, input().split()))
queries = [tuple(map(int, input().split())) for _ in range(q)]

for n, x, m in queries:
    d_mod = [elem % m for elem in d]
    rem_d_mod = d_mod[: (n - 1) % k]
    print(n - 1 - (x % m + ((n - 1) // k) * sum(d_mod) + sum(rem_d_mod)) // m
          - ((n - 1) // k) * d_mod.count(0) - rem_d_mod.count(0))

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


Question:
import sys
import numpy as np

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

n = int(input())
if n==1:
	print(0)
	sys.exit()

N = list(range(1,n))
print(np.cumsum(N)[-1])

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


Question:
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, M = MAP()

if N==M:
	print(1)
	sys.exit()

X = M//N+1
for i in range(X, -1, -1):
	if M % i == 0:
		print(i)
		sys.exit()
print(0)

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


Question:
import sys
from operator import mul
from functools import reduce

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

MARCH = 'MARCH'
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [input().rstrip() for _ in range(N)]

S = [s for s in S if s[0] in MARCH]

A = [0]*N
for s in S:
	A[MARCH.index(s[0])] += 1

#print(A)

if sum(A) <= 3:
	print(0)
	sys.exit()

ans = cmb(sum(A), 3)
#print(ans)

for a in A:
	if a<=1:continue
	if a>=3:
		ans -= cmb(a, 3)
	ans -= cmb(a, 2) * (sum(A)-a)

print(ans)

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


Question:
import sys
import itertools

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
S = [input().rstrip() for _ in range(N)]

S = [s for s in S if s[0] in 'MARCH']

C = list(itertools.combinations(S, 3))
#print(C)

cnt = 0
for c in C:
	#print(c)
	x, y, z = c
	if x[0] != y[0] and y[0] != z[0] and x[0] != z[0]:
		cnt += 1

print(cnt)

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


Question:
n = int(input())
a = [int(x) for x in input().split()]

odds = [i for i in a if 2%i]
print("No" if 2%len(odds) else "Yes")

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


Question:
n=int(input())
s,t=map(int,input().split())
j=0
k=0
r=[0 for i in range(2*n)]
for i in range(0,2*n,2):
  r[i]=s[j]
  j+=1

for i in range(1,2*n+1,2):
  r[i]=t[k]
  k+=1

print("".join(r))

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


Question:
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5)

for i in range(len(a)):
	a_cnt[a[i]]+=1

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

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


Question:
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5+1)

for i in range(max(a)+1):
	a_cnt[i]=a.count(i)

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

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


Question:
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])
a_cnt=[0]*(10**7)
for i in range(max(a)+1):
	a_cnt[i]=a.count(i)

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

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


Question:
A, B, C, K = int(input().split())
if K<=A:
    print(K)
elif A<K<=A+B:
    print(A)
else:
    print(A-(K-A-B))

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


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

s_list=[]
for i in s:
    if i=="L":s_list.append(0)
    else:s_list.append(1)
start_num=s_list[0]
i=0
while k>0:
    if s_list[i]!=start_num:
        k-=1
        while i<n and s_list[i]!=start_num:
            s_list[i]=start_num
            i+=1
    i+=1
ans=0
for i in range(n):
    if i+1<n and s_list[i]==1 and s_list[i+1]==1:
        ans+=1
    if i-1>=0 and s_list[i]==0 and s_list[i-1]==0:
        ans+=1
print(ans)

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


Question:
if a>=b:
    k=a
    a=a-1
else:
    k=b
    b=b-1

if a>=b:
    k=k+a
else:
    k=k+b

print(k)

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


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

if X >= K * D:
    print(X - K * D)
elif X <= K * (- D):
    print(abs(X + K * D))
else:
    if X >= 0:
        pos = X % D
        neg = X % D - D
        if K % 2 == (X // D) % 2:
            print(pos)
        else:
            print(abs(neg))
    if X <= 0:
        pos = D - (abs(X) % D)
        neg = - (abs(X) % D)
        if K % 2 == (X // D) % 2:
            print(abs(neg)
        else:
            print(pos))

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


Question:
def burger_size(N):
    if N == 0:
        return 1
    return 3 + 2 * burger_size(N - 1)

def burger_patty_num(N):
    if N == 0:
        return 1
    return 1+ 2 * burger_patty_num(N - 1)

def patty_num(N, X):
    if X == 0:
        return 0
    if X <= 1 + burger_size(N - 1):
        return patty_num(N - 1, X - 1)
    elif X == 2 + burger_size(N - 1):
        return 1 + burger_patty_num(N - 1)
    elif X <= 2 + 2 * burger_size(N - 1):
        return 1 + burger_patty_num(N - 1) + patty_num(N - 1, X - (2 + burger_size(N - 1)))
    else:
        return 1 + 2 * burger_patty_num(N - 1)

N, X = map(int, input().split())
print(patty_num(N, X))

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


Question:
def burger_size(N):
    if N == 0:
        return 1
    return 3 + 2 * burger_size(N - 1)

def burger_patty_num(N):
    if N == 0:
        return 1
    return 1+ 2 * burger_patty_num(N - 1)

def patty_num(N, X):
    if X == 0:
        return 0
    if X <= 1 + burger_size(N - 1):
        return patty_num(N - 1, X - 1)
    elif X == 2 + burger_size(N - 1):
        return 1 + burger_patty_num(N - 1)
    elif X > 2 + burger_size(N - 1):
        return 1 + burger_patty_num(N - 1) + patty_num(N - 1, X - (2 + burger_size(N - 1)))

N, X = map(int, input().split())
print(patty_num(N, X))

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


Question:
N = int(input())
s = list(map(int, input().split()))
if "Y" in s:
    print("Four")
else:
    print("Three")

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


Question:
k = int(input())
c = 0
a = [0]*(k+1)
a[0] = 7%k

if k%2 == 0 or k%5 == 0:
	print('-1')
else:
	for i in range(1,k+1):
		c += 1
		a[i+1] = (10*a[i] + 7)%k
		if a[i+1] == 0:
			break
	print(c)

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


Question:
import math
a,b,n = map(int,input().split())
max = 0
x = 0
while math.floor(a*x/b) - a*math.floor(x/b) <= a and x <= n:
	if max < math.floor(a*x/b) - a*math.floor(x/b):
		max = math.floor(a*x/b) - a*math.floor(x/b)
	x += 1
print(max)

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


Question:
k=int(input())
x=int(input())

if 500*k >= x:
print("'Yes'")
else:
print("'No'")

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


Question:
k = int(input())
x = int(input())

if 500*k < x:
print("No")
else:
print("Yes")

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


Question:
k=int(input())
x=int(input())

if 500*k < x:
print("No")
else
print("Yes")

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


Question:
n = int(input())
if n[0] == n[2]:
	print('Yes')
else:
	print('No')

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


Question:
A, B, C, K = map(int,input().split())
print(max(A*1*K + B*0*(K-A) + C*-1*(K-A-B)))

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


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

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


Question:
s = list(input())
L = 0
R = 0
tmp = []
for i in range(len(s)):
    if s[i] == "<":
        L += 1
    if s[i] == ">":
        R += 1
    if i == len(s)-1:
        if L == 0 or R == 0:
            tmp.append(L)
            tmp.append(R)
            L = 0
            R = 0
            break
        elif L > R:
            tmp.append(L)
            tmp.append(R-1)
            L = 0
            R = 0
            break
        elif L < R:
            tmp.append(L-1)
            tmp.append(R)
            L = 0
            R = 0
            break
    if s[i] == ">" and s[i+1] == "<":
        if L == 0 or R == 0:
            tmp.append(L)
            tmp.append(R)
            L = 0
            R = 0
        elif L > R:
            tmp.append(L)
            tmp.append(R-1)
            L = 0
            R = 0
        elif L < R:
            tmp.append(L-1)
            tmp.append(R)
            L = 0
            R = 0
ans = 0
for i in range(len(tmp)):
    if tmp[i] % 2 == 0:
        ans += (tmp[i] * (tmp[i] + 1) // 2)
    else:
        ans += ((tmp[i] - 1) * ((tmp[i] - 1) + 1) // 2 + tmp[i])
print(ans)

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


Question:
import itertools
N = int(input())
value_list = list(map(int, input().split()))
cost_list = list(map(int, input().split()))

value_result = []
for i in range(1,len(value_list)+1):
    for conb in itertools.combinations(value_list, i):
        value_result.append(list(conb))

cost_result = []
for i in range(1,len(cost_list)+1):
    for conb in itertools.combinations(cost_list, i):
        cost_result.append(list(conb))

ans_list = []
for i in range(len(value_result)):
    ans = sum(value_result[i]) - sum(cost_result[i])
    ans_list.append(ans)

if max(ans_list) > 0:
    print(max(ans_list))
else:
    print(0)

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


Question:
K = int(input())

p = 0
for i in range(100000000):
    p = (p*10+7) % K
    if p == 0:
        print(i+1)
        exit()
print(-1)

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


Question:
N, T = map(int, input().split())
ans = 1000000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
    ans = min(ans, c)
print(ans if ans < T else "TLE")

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


Question:
N = int(input())
n = len(str(N))
NS = str(N)
ans0 = 0
for i in range(NS):
    ans0 += int(i)
ans1 = int(NS[0])-1 + 9 * (n-1)
ans2 = 9 * (n-1)

print(max(ans0, ans1, ans2))

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


Question:
N = int(input())
h = list(map(int, input().split()))
h.append(1000000001)
max_n = 0
for i in range(N-1):
    add = 0
    count = 0
    while h[i+add] >= h[i+add+1]:
        count += 1
        add += 1
    max_n = max(max_n, count)
print(max_n)

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


Question:
n = int(input())
cnt=0
for _ in range(n):
    a,b=map(int,input()split())
    if a==b:
        cnt+=1
        if cnt>=3:
            break
    else:
        cnt=0
if cnt>=3:
    print("Yes")
else:
    print("No")

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


Question:
s=input()
if s==ABC:
  print("ARC")
else:
  print("ABC")

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


Question:
n = int(input())
ans = []
cnt = 0
for i in range(n):
    s = input()
    if not s in ans:
        ans.append(s)
        cnt+=1
print(cnt)

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


Question:
n = int(input())
a = list(map(int,input().split()))
s = n*[0]
for i in a:
    s[i]+=1
for i in range(0,n):
    s[a[i]]-=1
    ans=max(s)*(max(s)-1)/2
    s[a[i]]+=1
    print(int(ans))

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


Question:
x = int(input())
print(x//500*500*2+x%500//5*5)

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


Question:
s = input()
if s[0] == s[1] and a[1] == a[2]:
  print("No")
else:
  print("Yes")

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


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

s = ""
i = 0

while len(s) < n:
    s += "b"*a if i%2==0 else "r"*b
    i += 1

print(s[:n].count("b"))

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


Question:
# Vicfred
# https://atcoder.jp/contests/abc132/tasks/abc132_b
# implementation
n = int(input())
p = list(map(int,input()))

answer = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[1+1] or p[i-1] > p[i] > p[i+1]:
        answer += 1

print(answer)

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


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

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


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

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


Question:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
a1=a%10
b1=b%10
c1=c%10
d1=d%10
e1=e%10
ar=[a1,b1,c1,d1,e1]
a2=a//10
b2=b//10
c2=c//10
d2=d//10
e2=e//10
k=10
s=0
for i in ar:
    if i==0:
        s+=10
        continue
    minimini=min(i,k)
    if minimini==i:
        k=i
    else:
        s+=10
print((a2+b2+c2+d2+e2)*10+minimini+s)

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


Question:
H, W=int(HW[0]),int(HW[1])
h, w=int(hw[0]),int(hw[1])
ans=(W-w)*(H-h)
print(ans)

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


Question:
H, W=int(HW[0]),int(HW[1])
h, w=int(hw[0]),int(hw[1])
print((W-w)*(H-h))

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


Question:
s=input()
if int(s[4:5])>4:
    print("TBD")
else:
    print("Heisei")

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


Question:
|AB|,|BC|,|CA|=map(int, input().split())
ans=(|AB|*|BC|*|CA|/max(|AB|,|BC|,|CA|))/2
print(ans)

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


Question:
a,b -map(int, input().split())
if 9>a and 9>b:
    print("Yay!")
else:
    print(":(")

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


Question:
n=input()
ck=0
for i in range(n//2):
  if not n[i]==n[-1-i]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')

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


Question:
n=input()
ck=0
for _ in range(n//2):
  if not n[_]==n[-1-_]:
    ck+=1
if ck==0:
  print('Yes')
else:
  print('No')

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


Question:
n = int(input())
s = set()
for i in range(n):
  s.insert(input())
print(len(s))

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


Question:
from math import floor, ceil
N = int(input())
WHITE = 0
RED = 1
str = list(map(str, list(input())))
r = []
w = []

for i in range(N):
  w.append(i) if str[i] == "W" else r.append(i)
  str[i] = WHITE if str[i] == "W" else RED
r.reverse()

max_count = max(len(r), len(w))
count = 0
for i in range(max_count):
  if r[i] - w[i] < 0:
    count = i
    break

print(count)

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


Question:
A, B, K = list(map(int, input().split()))
A -= K
if A < 0:
  B += A
  A = 0
if B < 0:
  B = 0
print(A, B)a

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


Question:
a,b,c = input().split(' ')
for i in range(int(c)):
  if int(a) >= 1:
    a = int(a) - 1
  else:
    b = int(b) - 1
print(a + " " + b)

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


Question:
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
d = 2 ** (H - 1)
mcut = 1008
for i in range(d):
  L = [0 for _ in range(H)]
  for j in range(1, H):
    L[j] = L[j-1] + i % 2
    i //= 2
  C = [0 for _ in range(L[H-1]+1)]
  cutp, cutq = True, True
  cut = L[H-1]
  for m in range(W):
    for l in range(H):
      C[L[l]] += int(S[l][m])
    if cutq:
      cutq = False
      if max(C) > K:
        cutp = False
        break
    else:
      if max(C) > K:
        cut += 1
        C = [0 for _ in range(L[H-1]+1)]
        for l in range(H):
          C[L[l]] += int(S[l][m])
    if cutp == False:
      break
  if cutp:
    if cut < mcut:
      mcut = cut
print(mcut)

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


Question:
S = int(input())
if S == "AAA" or S == "BBB":
  print("No")
else:
  print("Yes")

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


Question:
n, a, b = map(int, input().split())
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  y = 1
  p = mod - 2
  base = x
  while p != 0:
    if p % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    p //= 2
  return y
def doubling(N, M):
  y = 1
  base = N
  while M != 0:
    if M % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    M //= 2
  return y
S = [inved(i+1) for i in range(b)]
A = doubling(2, n)
A = (A - 1) % mod
proda, prodb = 1, 1
for i in range(b):
  proda *= ((n - i) * S[i]) % mod
  proda %= mod
  if i == a - 1:
    A -= proda
    A %= mod
print((A - proda) % mod)

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


Question:
n, a, b = map(int, input().split())
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  y = 1
  p = mod - 2
  base = x
  while p != 0:
    if p % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    p //= 2
  return y
def doubling(N, M):
  y = 1
  base = N
  while M != 0:
    if M % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    M //= 2
  return y
S = [inved(i+1) for i in range(b)]
A = doubling(2, n)
A = (A - 1) % mod
proda, prodb = 1, 1
for i in range(a):
  proda *= ((n - i) * S[i]) % mod
  proda %= mod
for i in range(b):
  prodb *= ((n - i) * S[i]) % mod
  prodb %= mod
print((A - proda - prodb) % mod)

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


Question:
n, a, b = map(int, input().split())
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  a = extgcd(x, mod)
  return a % mod
def doubling(N, M):
  y = 1
  base = N
  while M != 0:
    if M % 2 == 1:
      y *= base
      y %= mod
    base *= base
    base %= mod
    M //= 2
  return y

A = doubling(2, n)
A = (A - 1) % mod
proda, prodb = 1, 1
for i in range(a):
  proda *= ((n - i) * inved(i + 1)) % mod
  proda %= mod
for i in range(b):
  prodb *= ((n - i) * inved(i + 1)) % mod
  prodb %= mod
print((A - proda - prodb) % mod)

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


Question:
N = int(input())
H = list(map(int, input().split()))
C = []

H.append(max(H)+1)
for s in range(N):
  i = 0
  while H[s+i] >= H[s+i+1]:
    i += 1
  C.append(i)
print(max(C))

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


Question:
N, M = map(int, input().split())
S = 1
p = 0
for i in range(2, int(M ** (1/2)) + 1):
  if M % i == 0:
    p = 1
if p != 0:
  for i in range(1, M // N + 1):
    if M % i == 0:
      S = i
print(S)

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


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

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


Question:
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]
def sugar(s):
  n = len(s)
  q = 0
  for i in range(n):
    if s[i] == 'z':
      q = i
  return i

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  if p == 26:
    S = S[:24] + S[25]
  else:
    m = D[S[p-2]]
    L = []
    for x in range(p, 26):
      if D[S[x]] >= m + 1:
        L.append(S[x])
    L.sort()
    S = S[:p-2] + L[0]
  print(S)

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


Question:
S = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
invalpha = "zyxwvutsrqponmlkjihgfedcba"
D = {alpha[i]: i for i in range(26)}
E = [0 for i in range(26)]
def sugar(s):
  n = len(s)
  q = 0
  for i in range(n):
    if s[i] == 'z':
      q = i
  return i

for i in range(len(S)):
  E[D[S[i]]] = 1
if min(E) == 0:
  for m in range(26):
    if E[m] == 0:
      S = S[:] + alpha[m]
      break
  print(S)
elif S == "zyxwvutsrqponmlkjihgfedcba":
  print(-1)
else:
  p = 26
  for i in range(25, 0, -1):
    if D[S[i]] < D[S[i-1]]:
      p = i
    else:
      break
  S = S[:p-2] + alpha[min(D[S[x]] for x in range(p, 26))]
  print(S)

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


Question:
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = int(1e+9) + 7
def extgcd(a, b):
  if b == 0:
    return 1, 0
  else:
    x, y, u, v, k, l = 1, 0, 0, 1, a, b
    while l != 0:
      x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
      k, l = l, k % l
    return x
def inved(x):
  a = extgcd(x, mod)
  return a % mod

F = [
  [
    [1, 0, 0, Y[5]-Y[4]+1, 0],
    [-1, 0, 0, 0, 0]
  ],
  [
    [1, X[5]-X[4]+1, 0, 0, 0],
    [-1, 0, 0, X[5]-X[4]+1, 0]
  ],
  [
    [1, 0, 0, Y[3]-Y[2]+1, 0],
    [-1, 0, 0, 0, Y[3]-Y[2]+1]
  ],
  [
    [1, 0, X[3]-X[2]+1, X[3]-X[2]+1, 0],
    [-1, X[3]-X[2]+1, 0, 0, X[3]-X[2]+1]
  ],
  [
    [1, 0, 0, 0, Y[1]-Y[0]+1],
    [-1, 0, 0, 0, 0]
  ],
  [
    [1, 0, 0, 0, X[1]-X[0]+1],
    [-1, 0, X[1]-X[0]+1, 0, 0]
  ],
  [
    [1, X[2]-X[5]-1, X[0]-X[3]-1, X[4]+Y[4]-X[3]-Y[3], X[2]+Y[2]-X[1]-Y[1]]
  ]
]
fact = [1 for i in range(2000001)]
invf = [0 for i in range(2000001)]
for i in range(2000000):
  fact[i+1] = ((i+1) * fact[i]) % mod
invf[-1] = inved(fact[2000000])
for i in range(2000000, 0, -1):
  invf[i-1] = (invf[i] * i) % mod
def encryptic(left, mat):
  cont = []
  for i in range(len(left)):
    for j in range(len(mat)):
      tmp = [left[i][0] * mat[j][0]]
      for k in range(1, 5):
        tmp.append(left[i][k] + mat[j][k])
      cont.append(tmp)
  return cont
Poly = [[1, 0, 0, 0, 0]]
for p in F:
  Poly = encryptic(p, Poly)
S = 0
D = {}
for p in Poly:
  a, b, c, d = -p[1], -p[2], p[3], p[4]
  s = p[0]
  M = min(b, c-a-2)
  tmp = 0
  for i in range(M+1):
    pix = (i+1) * invf[2+i+a] * invf[c-i-a-2]
    pix *= invf[b-i] * invf[d+i-b]
    pix %= mod
    tmp += pix
    tmp %= mod
  tmp *= fact[c] * fact[d]
  tmp %= mod
  S += s * tmp
  S %= mod
print(S)

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


Question:
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a], D[b] += 1
p = 0
for i in D:
  if i % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")

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


Question:
A = list(map(int, input().split()))
S = A[1]
S += (A[0] // 2) * 2
T = S
  if A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:
    S += (A[4] // 2) * 2 + (A[5] // 2) * 2
    A[4] -= 1
    A[5] -= 1
    T += 3
  T += (A[4] // 2) * 2 + (A[5] // 2) * 2
print(max(S, T))

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


Question:
H, W = map(int, input().split())
pos = [[0, 0]]
S = [input() for i in range(H)]
p = 1
def whiteout(Map, h, w):
  y = 0
  for i in range(h):
    for j in range(w):
      if Map[i][j] == '#':
        y += 1
  return y == 0

while pos != [H-1, W-1]:
  cnt = 0
  x, y = pos[0], pos[1]
  S[x] = S[x][:y] + '.' + S[x][y+1:]
  if x < H-1:
    if S[x+1][y] == '#':
      cnt += 1
      pos = [x+1, y]
  if y < W-1:
    if S[x][y+1] == '#':
      cnt += 1
      pos = [x, y+1]
  if cnt != 1:
    p = 0
    break
S[H-1] = S[H-1][:W-1] + '.'
if p == 1 and whiteout(S, H, W):
  print("Possible")
else:
  print("Impossible")

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


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

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


Question:
A,B=map(int,input().split())
if (A/0.08)%1==0.0:
    a1=int(A/0.08)
else:
    a1=int(A/0.08)+1
if (A/0.08)%1!=0.0:
    a2=int((A+1)/0.08)
else:
    a2=int((A+1)/0.08)-1

if (B/0.1)%1==0.0:
    b1=int(B/0.1)
else:
    b1=int(B/0.08)+1
if (B/0.1)%1!=0.0:
    b2=int((B+1)/0.1)
else:
    b2=int((B+1)/0.1)-1

#a=[]
#b=[]
for i in range(a1,a2+1):
    s=i
    a.append(s)
for i in range(b1,b2+1):
    t=i
    b.append(t)
print(a)
print(b)
if max(a)<min(b):
    print(-1)
elif max(b)<min(a):
    print(-1)
elif min(a)>=min(b):
    print(min(a))
else:
    print(min(b))

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


Question:
K,X=map(int,input())

if 500*K>=X:
  print("Yes")
else:
  print("No")

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

com_mx=200005
mod=998244353
fac=[0]*com_mx
finv=[0]*com_mx
inv=[0]*com_mx
fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1
for i in range(2,com_mx):
  fac[i]=fac[i-1]*i%mod
  inv[i]=-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def com(n,k):
  if n<k or n<0 or k<0:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod

def main():
  n,m,k=LI()
  ans=0
  col=m
  for x in range(n)[::-1]:
    now=col
    now*=com(n-1,x)
    if x<=k:
      ans+=now
      ans%=mod
    col*=m-1
  return ans

# main()
print(main())

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

class nCrMod():
  def __init__(self,n):
    self.n=n
    self.fact=[0]*(n+1)
    self.ifact=[0]*(n+1)
    self.fact[0]=1
    for i in range(1,n+1):
      self.fact[i]=self.fact[i-1]*i
      self.fact[i]%=mod
    self.ifact[n]=pow(self.fact[n],mod-2,mod)
    for i in range(1,n+1)[::-1]:
      self.ifact[i-1]=self.ifact[i]*i
      self.ifact[i-1]%=mod
  def comb(self,n,k):
    if k<0 or n<k:
      return 0
    return self.fact[n]*self.ifact[k]*self.ifact[n-k]%mod

def main():
  n,m,k=LI()
  c=nCrMod(100005)
  ans=0
  col=m
  for x in range(n)[::-1]:
    now=col
    now*=c.comb(n-1,x)
    if x<=k:
      ans+=now
      ans%=mod
    col*=m-1
  return ans

# main()
print(main())

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

com_mx=200005
mod=998244353
fac=[0]*com_mx
finv=[0]*com_mx
inv=[0]*com_mx
fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1
for i in range(2,com_mx):
  fac[i]=fac[i-1]*i%mod
  inv[i]=mod-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def com(n,k):
  if n<k or n<0 or k<0:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod

n,m,k=LI()
ans=0
col=m
for x in range(n)[::-1]:
  now=col
  now*=com(n-1,x)
  if x<=k:
    ans+=now
    ans%=mod
  col*=m-1
print(ans)

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

com_mx=200005
mod=998244353
fac=[0]*com_mx
finv=[0]*com_mx
inv=[0]*com_mx
fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1
for i in range(2,com_mx):
  fac[i]=fac[i-1]*i%mod
  inv[i]=mod-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def com(n,k):
  if n<k or n<0 or k<0:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod

n,m,k=LI()
ans=0
col=m
for x in range(n)[::-1]:
  now=col
  now*=com(n-1,x)
  if x<=k:
    ans+=now
    ans%=mod
  col*=m-1
print(ans)

# main()
print(main())

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

com_mx=200005
mod=998244353
fac=[0]*com_mx
finv=[0]*com_mx
inv=[0]*com_mx
fac[0]=1
fac[1]=1
finv[0]=1
finv[1]=1
inv[1]=1
for i in range(2,com_mx):
  fac[i]=fac[i-1]*i%mod
  inv[i]=mod-inv[mod%i]*(mod//i)%mod
  finv[i]=finv[i-1]*inv[i]%mod

def com(n,k):
  if n<k or n<0 or k<0:
    return 0
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod

def main():
  n,m,k=LI()
  ans=0
  col=m
  for x in range(n)[::-1]:
    now=col
    now*=com(n-1,x)
    if x<=k:
      ans+=now
      ans%=mod
    col*=m-1
  return ans

# main()
print(main())

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=998244353
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

class nCrMod():
  def __init__(self,n):
    self.n=n
    self.fact=[0]*(n+1)
    self.ifact=[0]*(n+1)
    self.fact[0]=1
    for i in range(1,n+1):
      self.fact[i]=self.fact[i-1]*i
      self.fact[i]%=mod
    self.ifact[n]=pow(self.fact[n],mod-2,mod)
    for i in range(1,n+1)[::-1]:
      self.ifact[i-1]=self.ifact[i]*i
      self.ifact[i-1]%=mod
  def comb(self,n,k):
    if k<0 or n<k:
      return 0
    return self.fact[n]*self.ifact[k]*self.ifact[n-k]%mod

def main():
  n,m,k=LI()
  c=nCrMod(200005)
  ans=0
  col=m
  for x in range(n)[::-1]:
    now=col
    now*=c.comb(n-1,x)
    if x<=k:
      ans+=now
      ans%=mod
    col*=m-1
  return ans

# main()
print(main())

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


Question:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  if m%n==0:
    return m//n

  ans=0
  for i in range(1,m//n+1):
    if m%i==0:
      ans=i

  return ans

# main()
print(main())

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


Question:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l1=[]
  l2=[]

  f=True
  for x in l:
    if f:
      f=False
      l1.append(x)
    else:
      f=True
      l2.append(x)

  l1.sort()
  l2.sort()

  l3=[]
  l4=[]

  a=l1[0]
  c=1
  for x in l1[1:]:
    if a==x:
      c+=1
    else:
      l3.append([a,c])
      a=x
      c=1
  l3.append([a,c])

  a=l2[0]
  c=1
  for x in l2[1:]:
    if a==x:
      c+=1
    else:
      l4.append([a,c])
      a=x
      c=1
  l4.append([a,c])

  l3=sorted(l3,key=lambda x:x[1],reverse=True)
  l4=sorted(l4,key=lambda x:x[1],reverse=True)

  print(l3)
  print(l4)

  if l3[0][0]==l4[0][0]:
    if len(l3)==1:
      return n-l3[0][1]-l4[1][1]
    elif len(l4)==1:
      return n-l3[1][1]-l4[0][1]
    else:
      return min(n-l3[0][1]-l4[1][1],n-l3[1][1]-l4[0][1])
  else:
    return n-l3[0][1]-l4[0][1]

print(main())

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


Question:
import fractions
from functools import reduce

def lcm_base(x,y):
  return x*y/fractions.gcd(x,y)

def lcm_list(numbers):
  return reduce(lcm_base,numbers,1)

n=int(input())
l=list(map(int,input().split()))
a=lcm_list(l)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

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


Question:
import fractions
from functools import reduce

def lcm_base(x,y):
  return x*y/fractions.gcd(x,y)

def lcm_list(numbers):
  return reduce(lcm_base,numbers,1)

a=lcm_list(l)
s=0
for j in l:
  s+=(int(a)-1)%j
print(s)

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


Question:
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
print(max(a)-min(a))

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


Question:
# 入力
N=int(input())
l=list(map(int,input().split()))

ln=len(set(l))

if ln==3:
  print('Three')
else:
  print('Four')

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


Question:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1

  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)

  if n!=1:
    l.append(n)

  return l

def main():
  n=I()
  l=getPrimeList(n)

  mn=len(str(n))
  for i in range(2**len(l)):
    a=n
    b=1
    for j in range(len(l)):
      if ((i>>j)&1):
        a//=l[j]
        b*=l[j]
    mn=min(mn,max(len(str(a)),len(str(b))))

  return mn

# main()
print(main())

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


Question:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1

  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)

  if n!=1:
    l.append(n)

  return l

# 10 -> n
def ten2n(a,n):
  x=a//n
  y=a%n
  if x:
    return ten2n(x,n)+str(y)
  return str(y)

# 方針
# 入力値を素因数分解する
# 制約のn<=10^10は、一見巨大に見えるが
# 2^n でさえ（素因数が最大になる場合）
# nは100にすら満たないことが実験するとわかる
# すなわち全探索ができる
# bit全探索を使用して各素数を振り分けを全パターン試す
# 全パターンについて、F(A,B)の最小値を見ていく

def main():
  n=I()

  if n==9876543210:
    exit()

  l=getPrimeList(n)

  l2=[]
  for i in range(pow(2,len(l))):
    l2.append(list(ten2n(i,2).zfill(len(l))))

  mn=inf
  for y in l2:
    a=b=1
    for i in range(len(y)):
      x=y[i]
      if x=='0':
        a*=l[i]
      else:
        b*=l[i]
    mn=min(mn,max(len(str(a)),len(str(b))))

  return mn

print(main())

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


Question:
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

from queue import Queue,PriorityQueue

from string import ascii_lowercase

sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):

    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def DFS(dictionary,vertex,visited):
    visited[vertex]=True
    stack=[vertex]
    print(vertex)
    while stack:
        a=stack.pop()
        for i in dictionary[a]:
            if not visited[i]:
                print(i)
                visited[i]=True
                stack.append(i)

def BFS(dictionary, vertex,visited):
    visited[vertex]=True
    q=deque()
    q.append(vertex)
    while q:
        a=q.popleft()
        for i in dictionary[a]:
            if not visited[i]:
                visited[i]=True
                q.append(i)
                print(i)

def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)

def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def solve():
    n=input()
    s=sum(list(map(int,str(n))))
    if s%9==0:
        pr('Yes')
    else:
        pr('No')

for _ in range(1):
    solve()

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


Question:
n = int(input())
print(!n)

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


Question:
def check(understanding,X):
    for individual in understanding:
        if individual<X:
            return False
    return True

cost=0
inputs1 =list(map(int, input().split()[:3]))
N=inputs1[0]
M=inputs1[1]
X=inputs1[2]

matrix=[]
understanding= []
for i in range(N):
    inputs =list(map(int, input().split()[:M+1]))
    matrix.append(inputs)

for i in range(N):
    cost+=matrix[i][0]
    for j in range(1,M+1):
        understanding[j]+=matrix[i][j]
    if check(understanding,X):
        print(cost)
        break

if not check(understanding,X):
    print(-1)

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


Question:
S = input()
list_num = S.split(' ')
list_num = map(int, list_num)
N, A, B = list_num

if A+B>N:
  print(N-A-B)
elif A+B=N:
  print(A)

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


Question:
n=input()
a=input()
b=input()
t=0
i=0
while t<=n:
    if t+a>n:
        i+=n-t
        break
    i+=a
    t+=a
    t+=b
print(i)

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


Question:
ab=int(input())
ll=s(ab)
def s(l):
    if l<2:
        return 1
    else:
        return s(l-2)
a=0
b=1
while(b):
    if(ll%10!=0):
        b=0
    else:
        a=a+1
print(a)

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


Question:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
if n % 2 == 1:
    print(0)
else:
    n //= 2
    ans = 0
    while n:
        n //= 5
        ans += n
    print(ans)

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


Question:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
 a= int(readline())
if a % 2 == 1:
    print(0)
else:
    a //= 2
    ans = 0
    while a:
        a //= 5
        ans += a
    print(ans)

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


Question:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n1 = int(readline())
if n1 % 2 == 1:
    print(0)
else:
    n1 //= 2
    ans = 0
    while n:
        n1 //= 5
        ans += n1
    print(ans)

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


Question:
def doublefactorial(n):

    if (n == 0 or n == 1):
        return 1;
    return n * doublefactorial(n - 2);

p=int(input())
print("Double factorial is",
       doublefactorial(p));

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


Question:
def factorial(n):
    return 1 if (n==1 or n==0) else n *factorial(n-2);

num = int(input())
print(factorial(num))

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


Question:
def fact(x):
    if x<2:
        return 1
    else:
        return x*fact(x-2)

facto = str(fact(int(input())))
count=0
for x in range(len(facto)-1,-1,-1):
    if facto[x]=="0":
        count+=1
    else:
        break

print(count)

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


Question:
s = raw_input()
    n = int(raw_input())

    a,b = s.split(' ')
    a,b = int(a),int(b)

    if a <= 9 and a >=1 and (1 <= b <= 9):
        return a * b
    else:
        return -1

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


Question:
A=variable
B=variable_2
A=1
B=1
C=A*B
while A and B <= 9;
	print(A*B)
	A=A+1
	B=B+1
print(C)

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


Question:
n = int(input()) #waiting_for_pudging
a = list(map(int, input().split())) #waiting_for_pudging
b = list(map(int, input().split())) #waiting_for_pudging
c = list(map(int, input().split())) #waiting_for_pudging
summ = 0 #waiting_for_pudging
for i in range(n-1): #pudging
    if a[i] + 1 == a[i + 1]: #pudging
        summ += c[a[i]] #pudging
        summ += b[a[i]] #pudging
    else: #pudging
        summ += b[a[i-1]] #pudging
print(summ) #pudging
#accepted

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


Question:
s=input()

t=input()
ans=0

for i in range(3):
    if s[i]==t[i]:
        ans+=1

print(ans)

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


Question:
import random

n = input()
n = int(n)

if n == 0:
	print(0)

elif n == 1:
	_ = input()
	print(0)

else:
	h = []

	for i in range(n):
		h.append(int(input()))

	rnd = random.randint(0, n)
	count = 0

	for i in range(rnd, n-1):
		if h[i+1] <= h[i]:
			count += 1

	print(count)

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


Question:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
#define ld long double

int main() {
    ll n;
    cin >> n;
    vector<ll> numbers(n);
    for(auto &i: numbers) cin >> i ;
    sort(numbers.begin(), numbers.end());
    ld ans = numbers[0];
    for(auto i: numbers) {
        ans = (ans + i)/2;
    }
    cout << ans << endl;
    return 0;
}

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


Question:
s = input()
if s[0] == s[1] and s[2] == s[3] or s[1] == s[2] and s[0] == s[3] or s[0] == s[2] and s[1] == s[3] and (a[0] != a[1] and a[1] != a[2] and a[2] != a[3]):
    print("Yes")
else:
    print("No")

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


Question:
s = 0
for i in range(2):
    if A > B:
        s += A
        A -= 1
    else:
        s += B
        B -= 1
print(s)

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


Question:
line = input()
num = [int(n) for n in line.split()]
sides = [num_a, num_b, num_c]
sides.sort()
area = round(sides[0] * sides[1]/2)
print(area)

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


Question:
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
area = int((0.5*a)*b)
print(area)

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


Question:
n = int(input())
words = ['']*n
for i in range(n):
    words[i] = input()
for i in range(len(words) - 1):
    if words.count(words[i]) > 1 or words[i][-1] != words[i+1][0]:
        print('No')
        exit()
print('Yes')

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


Question:
import sys
from collections import Counter
f = open('pokemon', 'r')
names = []
for line in f:
    names.append(line)
max_length = 0
pokemon = ''
for i in range(len(names)):
    p = [names[i]]
    start = names[i][-2]
    shiritori = True
    count = 1
    while shiritori == True:
        shiritori = False
        for j in range(len(names)):
            if i != j and names[j][0] == start and not names[j] in p:
                count += 1
                start = names[j][-2]
                shiritori = True
                p.append(names[j])
                if count > max_length:
                    max_length = count
                    pokemon = names[i]
                break
    print (p)
print (pokemon + str(max_length))

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


Question:
n=int(input())
if n>=2 and n<=100:
    if n%2==0:
        print( (n/2)^2)
    else:
        print( ((n//2)+1)^2)

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


Question:
N =int(input())
if N%2==1:
    odd = N-even
else:
    even = N/2
    odd = N/2
print(int(even*odd))

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


Question:
k= input()
odd=1
even=0
for i in range(2,k+1):
     if i%2==0:
        even+=1
     else:
           odd+=1
print(odd*even)

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


Question:
k= input ()
odd=1
even=0
for i in range(2,k+1)
     if i%2==0:
        even+=1
     else:
           odd+=1
print(odd*even)

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


Question:
k=input()
odd=0
even=0
for i in range(1,k+1)
     if i%2==0:
        even+=1
     else:
            odd+=1
print(odd*even)

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


Question:
k = map(int, input())
if k%2 == 0:
    print((k/2)*(k/2))

else:
    print(((k-1)/2)*(((k-1)/2)-k))

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


Question:
#!/usr/bin/env python3

from math import *

def lcm(a,b):
    return a*(b//gcd(a,b))

n = int(input())
A = [int(x) for x in input().split()]
m = 1
for i in A:
    m = lcm(i,m)

m -= 1
ans = 0
for i in A:
    ans += m%i

print(ans)

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


Question:
a = int(input())
b = int(input())
if(a + b > 16):
    print(":(")
elif(a <= 8 and b <= 8):
    print("Yay!")
else:
    print(":(")

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


Question:
def back_home():
    r=input()
    print(r)
    l = dict()
    for i in r:
        if i in l:
            l[i]=int(l[i])+1
        else:
            l[i]=1
    if (len(l)==1):
        return('NO')
    elif(len(l)==2):
        if (l['S']>0 and l['N']>0):
            return ("yes")
        elif(l['E']>0 and l['W']>0):
            return("yes")
        else:
            return("NO")
    elif(len(l)==3):
        return("NO")
    else:
        return("YES")

back_home()

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


Question:
S=input()
T=input()
a=len(S)
b=len(T)
m=a-b
A=[]
for i in range(m):
    cnt=b
    for j in range(b):
        if S[i+j]==T[j]:
            cnt-=1
    A.append(cnt)
print(min(A))

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


Question:
K=int(input())
if K%2==0:
    print(-1)
else:
    if K%7==0:
        L=9*K//7
    else:
        L=9*K
    i=1
    rest=(10**i)%L
    while True:
        if rest==1:
            print(i)
            exit()
        else:
            rest=(rest*10)%L
            i+=1

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


Question:
N=int(input())
c=input()
ans=[]
for i in range(N+1):
    ans.append(max(c[i:].count('R'),c[:i].count('W')))
print(min(ans))

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


Question:
N=int(input())
c=input()
ans=len(c)
for i in range(N+1):
    ans=min(ans,max(c[i:].count('R'),c[:i].count('W')))
print(ans)

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


Question:
a,b,k=map(int,input().split())
for i in range(k):
    if a>0:
        a-=1
    else:
        b-=1
    if a==0 and b==0:
        break
print(a,b)

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


Question:
s=input()
b=[]
count=0
for i in range(len(s)):
  if s[i] in "ATCG":
    count+=1
  else:
    b.append(count)
    count=0
print(max(b))

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


Question:
n,m=map(int,input().split())
AB=[]
for i in range(n):
  a,b=map(int,input().split())
  AB.append([a,b])
AB=sorted(AB)
i=0
amount=0
cost=0
while True:
  if amount+AB[i][1]<=m:
    amount+=AB[i][1]
    cost+=AB[i][0]*AB[i][1]
    i+=1
  else:
    cost+=(m-amount)*AB[i][0]
    print(cost)
    break

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


Question:
S=input()
alpha='abcdefghijklmnopqrstuvwxyz'
ans=''
P=[]
for i in range(26):
    P.append([alpha[i],1])

cnt=0
if len(S)==26:
    l=[]
    poe=S[::-1]
    for i in range(25):
        if poe[i]<poe[i+1]:
            cnt+=1
            l.append(poe[i])
        else:
            ans=poe[:i+1:-1]+min(l)
            break
    if cnt==25:
        ans='-1'
else:
    for i in range(len(S)):
        for j in range(26):
            if S[i]==P[j][0]:
                P[j][1]=0
        for i in range(26):
            if P[i][1]==1:
                ans=S+P[i][0]
                break

print(ans)

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


Question:
#!/usr/bin/env python3
import sys

def solve(x: int):

    if x == 1:
        return print('0')

    elif x == 0:
        return print('1')1

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

if __name__ == '__main__':
    main()

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


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

suma=0
sumb=0
sumc=0

for i in range(len(T)):
    A = T[i:]
    B = T[:i+1]
    if A in S:
        pass
    else:
        suma+=1

    if B in S:
        pass
    else:
        sumb+=1

    if A in S:
        if B in S:
            pass
    else:
        sumc+=1

suma = min(suma, sumb)
suma = min(suma, sumc)
print(suma)
~

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


Question:
#!/usr/bin/env python3
import sys

def solve(N: int, X: int, T: int):
    i = 0
    A = 0
    while:
        if A < 0:
            break
        A = N - X*i
        i+=1

    return print(i*T)

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

if __name__ == '__main__':
    main()
~

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


Question:
A, B, C, K = map(int,input().split())
ans = 0
if(K<=A):
  ans = K
else if(K<=A+B):
  ans = A
else:
  ans = A-(K-A-B)
print(ans)

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


Question:
def e_dividing_chocolate():
    # 参考: https://note.com/tanon_cp/n/ne70a87d249ed
    H, W, K = [int(i) for i in input().split()]
    Choco = [list(input()) for _ in range(H)]

    # 左上のマスを (0, 0)、右下のマスを (col, row) としたとき、2 点で張られる
    # 長方形区間の内部に含まれる 1 (ホワイトチョコレートのマス) の数を累積和で管理
    cumsum = [[0] * W for _ in range(H)]
    for row in range(H):
        for col in range(W):
            if Choco[row][col] == '1':
                cumsum[row][col] += 1
            if row != 0:
                cumsum[row][col] += cumsum[row - 1][col]
            if col != 0:
                cumsum[row][col] += cumsum[row][col - 1]
            if row != 0 and col != 0:
                cumsum[row][col] -= cumsum[row - 1][col - 1]

    def count_white_chocolate(x1, y1, x2, y2):
        """左上のマスを (x1, y1)、右下のマスを (x2, y2) としたとき、2 点で張られる
        長方形区間の内部に含まれる 1 (ホワイトチョコレートのマス) の数"""
        ret = cumsum[y2][x2]
        if x1 != 0:
            ret -= cumsum[y2][x1 - 1]
        if y1 != 0:
            ret -= cumsum[y1 - 1][x2]
        if x1 != 0 and y1 != 0:
            ret += cumsum[y1 - 1][x1 - 1]
        return ret

    ans = (H - 1) + (W - 1)  # 1 マスに分けてしまえば要求を満たすことは保証されている
    # 横の切り方は全探索する
    for bits in range(1 << (H - 1)):
        count = 0  # 何回チョコに切り込みを入れたか？

        # 横の切り込みをどこに入れるかを決める
        cut_row = []
        cut_flag = format(bits, 'b')[::-1]
        for k, flag in enumerate(cut_flag):
            if flag == '1':
                count += 1
                # k 行目と (k+1) 行目の間を切るとき、長方形区間の最下段は k 行目
                cut_row.append(k)
        cut_row.append(H - 1)  # チョコ全体での最下段も加えておく

        # col1-col2 の間は切り込みを入れないでもホワイトチョコが K 個以下である
        col1 = 0
        for col2 in range(W - 1):
            row1 = 0
            for row2 in cut_row:
                if count_white_chocolate(col1, row1, col2, row2) > K:
                    count = float('inf')  # 現在の横の切り込みの入れ方では要求を満たせない

                # col2 列目と col2+1 列目の間に縦に切り込みを入れなければならない
                if (count_white_chocolate(col1, row1, col2, row2) <= K
                        and count_white_chocolate(col1, row1, col2 + 1, row2) > K):
                    # ここで縦に切り込みを入れ、右の区画へ移動
                    count += 1
                    col1 = col2 + 1
                    break
                row1 = row2 + 1  # 下の区画へ移動

        # 最後に縦に切り込みを入れた区画の右の区画はまだ調べていないので、調べる
        row1 = 0
        for row2 in cut_row:
            if count_white_chocolate(col1, row1, W - 1, row2) > K:
                count = float('inf')
            row1 = row2 + 1

        ans = min(ans, count)
    return ans

print(e_dividing_chocolate())

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


Question:
def f_modularness():
    K, Q = [int(i) for i in input().split()]
    D = [int(i) for i in input().split()]
    Queries = [[int(i) for i in input().split()] for j in range(Q)]

    def divceil(a, b):
        return (a + b - 1) // b

    ans = []
    for n, x, m in Queries:
        last, eq = x, 0  # 末項、D_i % m == 0 となる D_i の数
        for i,d in enumerate(D):
            num = divceil(n - 1 - i, K)  # D_i を足すことは何回起きるか？
            last += (d % m) * num
            if d % m == 0:
                eq += num
        ans.append((n - 1) - (last // m - x // m) - eq)
    return '\n'.join(map(str, ans))

print(f_modularness())

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


Question:
def d_face_produces_unhappiness():
    N, K = [int(i) for i in input().split()]
    S = input()
    before_char = S[0]
    t = []
    v = 0
    for s in S + '*':
        if s != before_char:
            t.append(v)
            v = 1
        else:
            v += 1
        before_char = s
    t.sort(reverse=True)
    for i in range(K):
        t[i] += 2
    return min(sum([e - 1 for e in t]), N - 1)

print(d_face_produces_unhappiness())

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


Question:
def f_polynomal_construction(P, A):
    class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ["mod", "factorial", "inverse"]

        def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_n + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_n, 0, -1):
                inv_append(inv[-1] * i % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

    combination = Combination(P - 1, P)
    comb = [combination.combination(P - 1, i) for i in range(P)]

    ans = [0] * P
    for j, a in enumerate(A):
        if a == 0:
            continue
        # 1-(x-j)^{p-1} = 1 - \sum_{k=0}^{p-1} comb(p-1, p-k-1) * x^{p-k-1} * (-j)^k
        # なので、定数項に1を足し、x^k の係数から各々引く
        # pow(-j, k, P) としたいが、時間がかかるので tmp に掛けていくことにする
        ans[0] += 1
        tmp = 1
        for k in range(P):
            index = P - k - 1
            # if k > 0:
            #     tmp *= (-j)
            #     tmp %= P
            # ans[index] -= comb[index] * tmp
            ans[index] -= comb[index] * pow(-j, k, P)
            ans[index] %= P
    return ' '.join(map(str, ans))

P = int(input())
A = [int(i) for i in input().split()]
print(f_polynomal_construction(P, A))

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


Question:
def f_must_be_rectangular(N, Positions):
    # 参考: https://atcoder.jp/contests/abc131/submissions/6086451
    # x軸, y軸をまとめて1つのリストで扱う
    import sys
    sys.setrecursionlimit(10**6)

    vertex_maxsize = 10**5
    target = [[] for _ in range(2 * vertex_maxsize)]
    is_visited = [False] * (2 * vertex_maxsize)
    for x, y in Positions:
        y += vertex_maxsize  # 1つのリストで扱う都合上、ずらす
        target[x].append(y)
        target[y].append(x)

    def dfs(v):
        if is_visited[v]:
            return
        is_visited[v] = True
        count[v // vertex_maxsize] += 1  # vがx軸とy軸のどっちを指しているか
        for u in target[v]:
            dfs(u)  # 頂点vに接続されている頂点へ向かう

    ans = 0
    for i in range(2 * vertex_maxsize):
        if is_visited[i]:
            continue
        count = [0] * 2
        dfs(i)  # 頂点iにつながっている頂点を調べる
        # x座標とy座標のそれぞれについて、ペアにすると矩形が完成する
        # 座標がいくつあるか。その積が解となる
        ans += count[0] * count[1]
    return ans - N  # 最初に与えられた座標の分、引く

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(f_must_be_rectangular(N, Positions))

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


Question:
def f_must_be_rectangular(N, Positions):
    # 参考: https://atcoder.jp/contests/abc131/submissions/6086451
    # x軸, y軸をまとめて1つのリストで扱う
    import sys
    sys.setrecursionlimit(10**6)

    vertex_maxsize = 10**5
    target = [[] for _ in range(2 * vertex_maxsize)]
    is_visited = [False] * (2 * vertex_maxsize)

    for x, y in Positions:
        y += vertex_maxsize  # 1つのリストで扱う都合上、ずらす
        target[x].append(y)
        target[y].append(x)

    def dfs(v):
        if is_visited[v]:
            return
        is_visited[v] = True
        count[v // vertex_maxsize] += 1  # vがx軸かy軸かどっちを指しているか
        for u in target[v]:
            dfs(u)  # 頂点vに接続されている頂点へ向かう

    ans = 0
    for i in range(2 * vertex_maxsize):
        if is_visited[i]:
            continue
        count = [0] * 2
        dfs(i)  # 頂点iにつながっている頂点を調べる
        # x座標とy座標のそれぞれについて、ペアにすると矩形が完成する
        # 座標がいくつあるか。その積が解となる
        ans += count[0] * count[1]
    return ans - N  # 最初に与えられた座標の分、引く

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(f_must_be_rectangular(N, Positions))

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


Question:
def a_kenken_race(N, A, B, C, D, S):
    # cond1: 道のりの途中に岩が2つ連続する場所があると、ゴールに到達できない
    # cond2: ふぬけ君の道のりの途中に空きが3マス分ないと、すぬけ君が追い越せない
    cond1 = S[A:C + 1].count('##') == 0 and S[B:D + 1].count('##') == 0
    cond2 = S[B:D + 1].count('...') >= 1
    if C < D:
        # ふぬけ君をゴールに行かせてからすぬけ君をゴールに行かせればよい
        ans = 'Yes' if cond1 else 'No'
    else:
        # すぬけ君は途中でふぬけ君を追い越せないといけない
        ans = 'Yes' if cond1 and cond2 else 'No'
    return ans

S = input()
print(a_kenken_race(N, A, B, C, D, S))

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


Question:
N = int(input())
V = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = -float('inf')
d = len(V)
for b in range(2 ** d):
    tmp = 0
    for j in range(d):
        if ((b >> j) & 1):
            tmp += V[j] - C[j]
    ans = max(ans, tmp)
print(ans)

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


Question:
def d_xxor(N, K, A):
    # 参考: http://drken1215.hatenablog.com/entry/2019/02/03/224200
    ans = 0
    # N, K <= 10**12 < 2**40 なので、dの上限を40とする
    for d in range(40, -2, -1):
        # d=-1のケースはX=Kのケースを意味する
        if d != -1 and (K & (1 << d)) == 0:
            continue

        tmp = 0
        for e in range(40, -1, -1):
            bit_mask = 1 << e

            # Aの各要素を2進表記したとき、e番目のビットが立っているものは何個か？
            num = 0
            for a in A:
                if a & bit_mask != 0:
                    num += 1

            # このビットがfに貢献する値を決める。
            if e > d:
                if K & bit_mask != 0:
                    tmp += bit_mask * (N - num)  # X_e=1とする
                else:
                    tmp += bit_mask * num  # X_e=0とする
            elif e == d:
                tmp += bit_mask * num  # このビットは0とする(解説pdf参照)
            else:
                # これを満たすビットについては、独立に決めていい。
                # よって、貢献する値が大きな方を選べばいい
                tmp += bit_mask * max(num, N - num)
        ans = max(ans, tmp)
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_xxor(N, K, A))

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


Question:
def d_various_sushi(N, K, Param):
    import heapq

    # 寿司をおいしさの値が大きなものからK個取る
    sushi_parameter = sorted(Param, key=lambda x: x[1], reverse=True)
    sushi_invariably_chosen = []  # ネタが被っていない場合、貪欲に取っていい
    candidate_reject = []  # ネタの種類数を増やす時に取り除く候補(priority queueで管理)
    chosen_topping = set()  # 取った寿司ネタの種類
    for i in range(K):
        t, d = sushi_parameter[i]
        if t not in chosen_topping:
            sushi_invariably_chosen.append(d)
            chosen_topping.add(t)
        else:
            heapq.heappush(candidate_reject, d)

    # 暫定的な最大値を計算しておく
    delicious_sum1 = sum(sushi_invariably_chosen)
    delicious_sum2 = sum(candidate_reject)
    topping_variety = len(chosen_topping)
    ans = delicious_sum1 + delicious_sum2 + topping_variety**2
    if len(candidate_reject) == 0:
        return ans  # 除く寿司の候補がないので、満足度を大きくしようがない

    for i in range(K, N):
        t, d = sushi_parameter[i]
        if t in chosen_topping:
            # ネタが被った上、おいしさがこれまで取った寿司より小さな寿司と交換する理由はない
            continue

        # 取り除いてもネタの種類数が減らない寿司の中で最もおいしさの小さいものを取り除く
        delicious_sum2 -= heapq.heappop(candidate_reject)
        # これまでに取っている寿司にないネタを持ち、最もおいしさの大きい寿司を取る
        chosen_topping.add(t)
        delicious_sum1 += d
        topping_variety += 1

        ans = max(ans, delicious_sum1 + delicious_sum2 + topping_variety**2)
    return ans

N, K = [int(i) for i in input().split()]
Param = [[int(i) for i in input().split()] for j in range(N)]
print(d_various_sushi(N, K, Param))

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


Question:
def c_id():
    from collections import defaultdict
    N, M = [int(i) for i in input().split()]
    Cities = [[int(i) for i in input().split()] for j in range(M)]

    dic = defaultdict(list)
    # 県毎に市をまとめる
    for p, y in Cities:
        dic[p].append(y)
    # 市の認識番号を (座標) 圧縮
    for p, lst in dic.items():
        dic[p] = {v: k for k, v in enumerate(sorted(lst), 1)}
    return '\n'.join([f'{p:06d}{dic[p][y]:06d}' for p, y in Cities])

print(c_id())

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


Question:
def c_id():
    from collections import defaultdict
    N, M = map(int, input().split())
    City = [[s] + [int(i) for i in input().split()] for s in range(M)]

    # 同じ県に属する市を誕生年の早い順に並べ、順序付けする
    city_dict = defaultdict(list)
    for k, p, y in City:
        city_dict[p].append([k, p, y])
    for p in city_dict.keys():
        city_dict[p].sort(key=lambda x: x[2])
        for i in range(len(city_dict[p])):
            city_dict[p][i][2] = i + 1

    # 変換は終わった。通し番号順に並べる
    ans = sorted([e for v in city_dict.values() for e in v])
    return '\n'.join([f'{p:06d}{num:06d}' for _, p, num in ans])  # 通し番号は不要

print(c_id())

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


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:
- Runtime Error
- Compile Error
- Time Limit Exceeded
- No abnormally found


Question:
# -*- coding: utf-8 -*-
import numpy as np

def main():
    a=int(input())
    b=int(input())
    c=max(a,b)
    print(c+(c-1))

if __name__ == '__main__':
    main()

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


Question:
n = int(input())
a = []
for i in n:
    x,y = map(int,input().split())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

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


Question:
n = int(input())
a = []
for i in n:
    x,y = map(int,input())
    a.append([x,y])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

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


Question:
l = input()
for i in range(0, 5)
	print(l[i], end="")
for j in range(6, 13)
	print(l[j], end="")
for k in range(14, 19)
	print(l[k], end="")

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


Question:
l = input()
for i in range(0, 5) 　print(l[i], end="")
for j in range(6, 13) 　print(l[j], end="")
for k in range(14, 19) 　print(l[k], end="")

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


Question:
l = input()
for i in range(0, 5) 　print(l[i], end="")
for i in range(6, 13) 　print(l[i], end="")
for i in range(14, 19) 　print(l[i], end="")

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


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

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


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

cnt=0
ans=0

while cnt<N:
    if cnt%(A+B)<A:
        cnt+=1
        ans+=1
    else:
        cnt+=1

print(ans)

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


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

S = []

while len(S)<N:
    for i in range(A):
        if len(S)<N:
            S.append('b')
    for j in range(B):
        if len(S)<N:
            S.append('r')

print(S.count('b'))

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


Question:
S, T = map(input().split())
a, b = map(input().split())
U = input()

if S==U:
    a-=1
else:
    b-=1

print("{} {}".format(a, b))

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


Question:
N, K = map(int, input().split())
S = [i for i in input()]

for i in range(65, 65+26):
    if S[K]==chr(i):
        S[K]=chr(i+32)

print(''.join(S))

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


Question:
S = list(map(str, input()))
cnt = 0
CNT = []
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt += 1
    if S[i]!='A' and S[i]!='C' and S[i]!='G' and S[i]!='T':
        CNT.append(cnt)
        cnt = 0

print(max(CNT))

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


Question:
A, B, K = map(int, input().split())
s = []
for i in range(100):
  if A%i==0 and B%i==0:
    s.append(i)
print(s[K-1])

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


Question:
a=int(input())
if a==1:
  print(0)
if a==0
  print(1)

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


Question:
x,k,d=map(int,input().split())

if x==0 and k%2==0:print(0)
if x==0 and k%2==1:print(d)

if x>0 and x>=k*d:print(x-k*d)
if x>0 and x<k*d:
    if ((x-x%d)//d)%2==k%2:print(x%d)
    else:print(abs(x%d-d))
if x<0 and -x>=k*d:print(-x-k*d)
if x<0 and -x<k*d:
    fewa

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


Question:
ans = -(10**9)
ans = max(a*c, ans)
ans = max(a*d, ans)
ans = max(b*c, ans)
ans = max(b*d, ans)
print(ans)

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


Question:
ans = a*c
if ans < a*d:
    ans = a*d
elif ans < b*c:
    ans = b*c
elif ans < b*d:
    ans = b*d
print(ans)

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


Question:
ans = -(10**9)
ans = max(a*d, ans)
ans = max(b*d, ans)
ans = max(a*c, ans)
ans = max(b*c, ans)
print(ans)

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


Question:
a, b, c, k = map(int, input().split())
ans = 0
for aa in range(a+1):
    for bb in range(b+1):
        for cc in range(c+1):
            if aa+bb+cc == k:
                t = aa+cc*-1
                ans = max(t, ans)
print(ans)

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


Question:
n, a, b = map(int, input().split())
ans = []
while (True):
    for _ in range(a):
        ans.append('b')
    if len(ans) >= n:
        break
    for _ in range(b):
        ans.append('r')
    if len(ans) >= n:
        break
print(ans[:n].count('b'))

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


Question:
import sympy

n = int(input())
count = 0
for i in range(1, n+1):
    if i % 2 == 1:
        if len(sympy.divisors(i)) == 8:
            # print(i)
            count += 1
print(count)

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


Question:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[a,b,c,d,e]
last=9
for i in range(5):
    if l[i]%10!=0:
        last=min(last,l[i]%10)

sum=0
if a%10==0 and b%10==0 and c%10==0 and d%10==0 and e%10==0:
    print(sum(l))
else:
    for i in range(5):
        if l[i]%10==0:
            sum+=l[i]
        else:
            sum+=l[i]+10-l[i]%10
    print(sum-10+last)

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


Question:
n = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))

def f(i, j):
  if i == j == 0:
    return min(monsters[i], heros[i])
  if i == j - 1:
    return min(monsters[i+1], heros[i] - f(i, i))
  if i == j:
    return min(monsters[i] - f(i-1, i), heros[i])

s = 0
for i in range(n):
	s += f(i, i) + f(i, i+1)
print(s)

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


Question:
import sys
a, b, k = map(int, input().split())
c = 0
for i in range(min(a, b)):
  if a % i == 0 and b % i == 0:
    c += 1
  if c == k:
    print(a)
    sys.exit(0)

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


Question:
from bisect import bisect_left as bl

def f(v):
    v = str(v)
    return '0' * (6 - len(v)) + v

N, M = map(int, input().split())
dic = dict()
PY = []
for i in range(M):
    p, y = map(int, input().split())
    if dic.get(p, False):
        dic[p].append(y)
    else:
        dic[p] = [y]
    PY.append((p, y))

for i in range(1, N + 1):
    if dic.get(i, False):
        dic[i] = sorted(dic[i])

# print('dic', dic, PY)
for i in range(M):
    p, y = PY[i]
    # print('p y', p, y)
    l = dic[p]
    ans = f(p) + f(l.index(y) + 1)
    print(ans)

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


Question:
S = input()
S = sorted(S)
for i in range(len(S)):
    if S[i] == '-':
        ans = 2 * i - 4
        break
print(ans)

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


Question:
N = int(input())
A = list(map(int, input().split()))
for a in A:
  if a == 'Y':
    print('Four')
    exit()
print('Three')

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


Question:
import numpy as np
N, M = map(int, input().split())
A = np.array([list(input()) for _ in range(N)])
B = np.array([list(input()) for _ in range(M)])
# print('AB', A, B)
for i in range(N - M + 1):
    for j in range(N - M + 1):
        # print('i j', i, j)
        A_subset = A[i:i + N - 1, j:j + N - 1]
        # print('A_subset', A_subset)
        if np.all(A_subset == B):
            print('Yes')
            exit()
print('No')

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


Question:
n,a,b=map(int,input().split())
x,y=0,0
i=0
while(n>0):
    if(i%2==0):
        x+=min(n,a)
        n-=min(n,a)
    else:
        y+=min(b,n)
        n-=min(n,b)
    i+=1
print(x)

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


Question:
import sys

x1,y1,x2,y2=list(map(int,input().split()))
dx=x2-x1
dy=y2-y1
print("%d %d %d %d"%(x2-dy,y2+dx,x1-dy,y1+dx))

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


Question:
x1,y1,x2,y2=list(map(int,input().split()))
dx=x2-x1
dy=y2-y1
print(x2-dy,y2+dx,x1-dy,y1+dx)

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


Question:
import sys
sys.setrecursionlimit(4100000)

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod

#逆元を求める関数
def mod_inverse(mod:int, b:int)->int:
    return mod_pow(b, mod-2, mod)

#aCbをmodで割った余りを求める関数(bが小さい)
def nCr_mod(n:int, r:int, mod:int)->int:
    num, den = 1, 1 #numerator, denominator

    for i in range(r):
        num *= (n-i) % mod
        den *= (i+1) % mod

    return (num * mod_inverse(mod, den)) % mod

ans = (mod_pow(2, n, mod) - 1 - nCr_mod(n, a, mod) - nCr_mod(n, b, mod)) % mod
print(ans)

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


Question:
x=input().split()

a=x[0]
b=x[1]

p=a + b
q=a - b
r=a * b

max=p
if q > max:
    max = q
    if r > max:
        max = r

print(max)

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


Question:
 tmp = 10 ** 9 + 7
def div(n,T):
    _ = 1
    for t in range(T):
        _ *= n
        _ %= tmp
    return _

N = int(input())
a = div(10,N)
b = div(9,N)
c = div(8,N)

print((a + c - 2 * b) % tmp)

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


Question:
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT):
        d = 0
        for lt in range(LT):
            if S[ls + lt] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

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


Question:
S = input()
T = input()
LS = len(S)
LT = len(T)
L = []

if T in S:
  print(0)
else:
    for ls in range(LS - LT):
        d = 0
        for lt in range(LT):
            if S[ls + lt:ls + LT] != T[lt]:
                d += 1
        L.append(d)
    print(min(L))

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


Question:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
  return _

A, B, K = map(int, input().split())

a = max(A, B)
b = min(A, B)
e = euclidean(a, b)
by = []
r = int(e ** (1 / 2))

for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

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


Question:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
    return _

A, B, K = map(int, input().split())

a = max(A, B)
b = min(A, B)
e = euclidean(a, b)

by = []
r = int(e ** (1 / 2))

for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort(reverse = True)
print(by[K - 1])

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


Question:
def euclidean(a,b):
  _ = a % b
  while 1:
    if b % _ == 0:
      break
    else:
      _ = b % _
    return _

A, B, K = map(int, input().split())

a = max(A, B)
b = min(A, B)
e = euclidean(a, b)

by = []
r = int(e ** (1 / 2))

for i in range(1, r + 1):
  if e % i == 0:
    by.append(i)
    j = e // i
    if j != i:
      by.append(j)
by.sort()
print(by[K - 1])

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


Question:
N = int(input())
r_N = int(N ** (1 / 2))

li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n)))
  	li.append(l)

print(min(li))

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


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

    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[0:amari]

        for ball in S:
            if ball == 'b':
                cnt += 1

    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

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


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

def myPow(x,n,m):
  if n == 0:
    return 1
  if n % 2 == 0:
    return myPow(x * x % m, n / 2, m)
  else:
    return x * myPow(x, n - 1, m) % m

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

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

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

n_comb = 2 ** n - 1
n_comb = myPow(2, n, mod) - 1
ans = n_comb - (cmb(n,a, mod) + cmb(n,b,mod))
ans %= mod
print(ans)

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


Question:
import math
def solve():
    A, B, X = map(int, input().split())

    ans = 0
    for d in range(1, 18):
        N = (X - B*d)/A
        N = int(math.ceil(N))
        if N <= 0:
            continue
        if d == len(str(N)):
            if d >= 10:
                ans = 10**9
            else:
                ans = N

    print(ans)

if __name__ == '__main__':
    solve()

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


Question:
# import math
# import numpy as np
# import itertools
# import heapq
# =map(int,input().split())
n=int(input())
ans=0
q=[]
for i in range(n):
    x=input()
    if x not in q:
        ans+=1
    q.append(x)
print(ans)

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


Question:
e = list(map(int,input().split()))
K = e[0]
N = e[1]
a = list(map(int,input().split()))
c = [a[i+1] - a[i] for i in range(N-1)]
f = a[0]+ K - a[N-1]
c.append(f)
d = max(c)
print(K - d)

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


Question:
import sys
N=int(input())
ans=[]
if N==1:
    print(1)
    sys.exit()
for i in range(int(N**0.5)-1,N+1):
    if N%i==0:
        a=str(i)
        print(len(a))
        sys.exit()

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


Question:
import sys
N=int(input())
ans=[]
for i in range(int(N**0.5)-1,N+1):
    if N%i==0:
        a=str(i)
        print(len(a))
        break

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


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

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


Question:
N = int(input())
heights = list(map(int, input().split()))
before = 0
answer = 0

for h in heights:
  if h < before:
    answwer += before - h
  else:
    before = h
print(answer)

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


Question:
N = int(input())
nums = list(map(int, input().split()))
nums.sort()
ans = num
for num  in nums[1:]:
  ans = (ans + num)/2
print(ans)

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


Question:
N = int(input())
M = list(map(int, input().split()))
H = list(map(int, input().split()))

sum_m = 0
rest = 0
rest = max(0, H[1]-M[1])
sum_m += min(H[1], M[1])
for i in range(1, N):
  rest = max(0, H[i]+rest-M[i])
  if M[i] >= H[i]+rest:
    sum_m += H[i]+rest
  else:
    sum_m += M[i]
sum_m += min(rest, M[-1])

print(sum_m)

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


Question:
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3]) or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print('No')

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


Question:
N = int(input())
SP = [list(map(int, input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break

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


Question:
N = int(input())
SP = [list(map(int, input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverxe=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == SP[j][0] and SP[i][1] == SP[j][1]:
      print(j+1)
      break

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


Question:
import sys
sys.setrecursionlimit(20000)

N = int(input())
W = [list(map(int, input().split())) for _ in range(N-1)]
nodes = [[] for _ in range(N+1)]
for w in W:
    nodes[w[0]].append((w[1], w[2]))
    nodes[w[1]].append((w[0], w[2]))
ans = [-1] * (N+1)
ans[1] = 0
def search(num, root, dis):
    for node in nodes[num]:
        sum_d = dis
        if node[0] != root:
            idx = node[0]
            sum_d += node[1]%2
            if sum_d%2 != 0:
                ans[idx] = 1
            else:
                ans[idx] = 0
            search(idx, num, sum_d)

search(1, 0, 0)
for answer in ans[1:]:
    print(answer)

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


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

A[K-1::] = A[k-1::].lower()
print(A)

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