Harryxun/stf_run huggingface dataset:
S = input()

X = [SUN,MON,TUE,WED,THU,FRI,SAT]
print(7 - X.index(S))

### FIXED CODE ###

S = input()

X = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7 - X.index(S))
def main(){
 

    n = input()
    R = []

    for i in range(n-1):
        R.append(input())
 
    max = R[1] - R[0]
    min = R[0]
 
    for i+1 in range(n-1):
        if R[i]-min>max:
            max = R[i] - min
        if R[i]<min:
            min = R[i]
 
    print max

}
 

### FIXED CODE ###

n = input()

R = [input() for i in range(n)]
  
max = R[1] - R[0]
min = R[0]
  
for i in range(1,n):
    if R[i] - min > max:
        max = R[i] - min
    if R[i] < min:
        min = R[i]
  
print max
N, *L = map(int, open('0').read().split())
cost = []
for i, m in enumerate(zip(*[iter(L)]*N)):
  cost.append(list(m))
  cost[i][i] = 10**10
ans = 0
for i in range(N):
  for j in range(i):
    m = min(cost[i][k]+cost[k][j] for k in range(N))
    if m<cost[i][j]:
      print(-1)
      import sys
      sys.exit()
    if m!=cost[i][j]:
      ans += cost[i][j]
print(ans)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
cost = [[0]*N for i in range(N)]
dist = [[0]*N for i in range(N)]
log = defaultdict(int)
for i in range(N):
  inf = [int(c) for c in input().split()]
  for j in range(N):
    cost[i][j] = inf[j]
for i in range(N):
  for j in range(i+1,N):
    m = float('inf')
    for k in range(N):
      if cost[i][j]>=cost[i][k]+cost[k][j]:
        m = min(m,cost[i][k]+cost[k][j])
        if k != i and k!= j:
          log[(min(i,j),max(i,j))] = 1
    dist[i][j] = m
    dist[j][i] = m
ans = 0
for i in range(N):
  for j in range(i+1,N):
    flag = False
    if dist[i][j]<cost[i][j]:
      print(-1)
      flag = True
      break
    elif log[(i,j)]==0:
      ans += cost[i][j]
  if flag:
    break
else:
  print(ans)
もうだめだ...

### FIXED CODE ###

a=input()
A=a[0]
b=a[1]
c=a[2]
d=a[3]
if A==b and b==c:
  print("Yes")
elif b==c and c==d:
  print("Yes")
else:
  print("No")
s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i] 
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i]:
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")
N=int(input())
A=int(input())
B=int(input())
if N==1:
  print("Hello World")
else:
  print(A+B)

### FIXED CODE ###

N=int(input())
if N==1:
    print("Hello World")
else:
    A=int(input())
    B=int(input())
    print(A+B)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = ch*w+cw
goal = dh*w+dw
seen = [None]*n
seen[start] = 0
from heapq import heappop as hpp, heappush as hp
q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
e = 10**-9

for i in range(3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(e)
data = []
rs = []
cs = []
for pu in range(n):
    ux,uy = divmod(pu,w)
    if ss[ux][uy]=="#":
        continue
    for xx,yy,vv in zip(dx,dy,vvs):
        x,y = ux+xx, uy+yy
        if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
            continue
        u = x*w + y
        data.append(vv)
        rs.append(pu)
        cs.append(u)
assert False
import scipy.sparse
m = scipy.sparse.csr_matrix((data, (rs, cs)), shape=(n, n))
ans = scipy.sparse.csgraph.dijkstra(m, indices=start, directed=False) # startからの最短路木を求める
if ans[goal]>10**9:
    print(-1)
else:
    print(int(ans[goal]))

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

from collections import defaultdict

ns = defaultdict(set)
ss = [None] * rows
for i in range(rows):
    s = input()
    ss[i] = s
n = rows * cols
start = ch*w+cw
goal = dh*w+dw
seen = [None]*n
seen[start] = 0
from heapq import heappop as hpp, heappush as hp
q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
# dx = [0,1,0,-1]
# dy = [1,0,-1,0]
dx = []
dy = []
vvs = []
for i in range(-2,3):
    for j in range(-2,3):
        if not (i==j==0):
            dx.append(i)
            dy.append(j)
            if abs(i)+abs(j)>1:
                vvs.append(1)
            else:
                vvs.append(0)
while q:
    pnum,pu = hpp(q)
    ux,uy = divmod(pu,w)
    # print(pnum,divmod(pu,w))
    if pu==goal:
        break
    for xx,yy,vv in zip(dx,dy,vvs):
#         x = ux+xx
#         y = uy+yy
        x,y = ux+xx, uy+yy
        u = x*w + y
        num = pnum+vv
        if x<0 or y<0 or x>=h or y>=w or ss[x][y]=="#":
            continue
#         print(x,y)
        if seen[u] is None or seen[u]>num:
            seen[u] = num
            hp(q, (num, u))
val = seen[goal]
if val is None:
    print(-1)
else:
    print(val)
a,b,c=map(int,input().split())
print('YES' if b-a=c-b else 'NO')

### FIXED CODE ###

a,b,c=map(int,input().split())
print('YES' if b-a==c-b else 'NO')
import heapq
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
p = []
m = []
ans = 1
for i in a:
    if i < 0:
        heapq.heappush(m,i)
    else:
        heapq.heappush(p,-i)
heapq.heappush(m,0)
heapq.heappush(m,0)
heapq.heappush(p,0)
heapq.heappush(p,0)
m1 = heapq.heappop(m)
m2 = heapq.heappop(m)
p1 = -heapq.heappop(p)
p2 = -heapq.heappop(p)
while k:
    if k%2 == 1:
        ans *= p1
        p1 = p2
        p2 = -heapq.heappop(p)
        k -= 1
    elif m1 * m2 > p1 * p2:
        ans *= m1 * m2
        m1 = heapq.heappop(m)
        m2 = heapq.heappop(m)
        k -= 2
    else:
        ans *= p1
        p1 = p2
        p2 = -heapq.heappop(p)
        k -= 1
    ans %= mod
print(ans)
    

### FIXED CODE ###

from collections import deque
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
p = []
m = []
ans = 1
for i in a:
    if i < 0:
        m.append(-i)
    else:
        p.append(i)
cp = len(p)
cm = len(m)
m.append(0)
m.append(0)
p.append(0)
p.append(0)
p.sort()
m.sort()
p = deque(p)
m = deque(m)
if cm == n and k%2 == 1:
    f = 1
else:
    f = 0 
if f == 0:
    while k:
        # print(k,cm,m)
        if k%2 == 1 and cp:
            p1 = deque.pop(p)
            ans *= p1
            k -= 1
            cp -= 1
        elif f == 0 and m[-1] * m[-2] > p[-1] * p[-2] and cm > 1 and k>1:
            m1 = deque.pop(m)
            m2 = deque.pop(m)
            ans *= m1 * m2
            cm -= 2
            k -= 2
        elif cp > 0:
            p1 = deque.pop(p)
            ans *= p1
            k -= 1
            cp -= 1
        else:
            
            ans *= -m[2]
            m1 = deque.popleft(m)
            m2 = deque.popleft(m)
            m3 = deque.popleft(m)
            deque.appendleft(m,m1)
            deque.appendleft(m,m2)
            cm -= 1
            k -= 1
        ans %= mod
else:
    m1 = deque.popleft(m)
    m2 = deque.popleft(m)
    m1 = deque.popleft(p)
    m2 = deque.popleft(p)
    deque.append(m,10**10)
    deque.append(p,10**10)
    while k:
        k-=1
        # print(p,m)
        if p[0] < m[0]:
            ans *= deque.popleft(p)
        else:
            ans *= -deque.popleft(m)
        ans %= mod

print(ans)
n, m = map(int, input().split())
x = list(map(int, input().split()))

if m == 1:
    print('0')
    exit()
if n >= m:
    print(0)
    exit()
elif abs(m-n)==1:
    x = sorted(x)
    prev = x[0]
    diff = []
    for i, v in enumerate(x[1:]):
        diff.append([i, abs(prev-v)])
        prev = v

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

    print(min(diff)[1])
    exit()

x = sorted(x)
prev = x[0]
diff = []
for i, v in enumerate(x[1:]):
    diff.append([i, abs(prev-v)])
    prev = v

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

split_index = list(map(lambda x: x[0]+1, diff[:n-1]))

ans = x[split_index[-1]:][-1] - x[split_index[-1]:][0]
index_from = 0
for i in range(n-1):
    index_to = split_index[i]
    ans += (x[index_from:index_to][-1] - x[index_from:index_to][0])
    index_from = index_to
print(ans)

### FIXED CODE ###

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

if n >= m:
    print(0)
    exit()

a = sorted(a)
diff = []
for i in range(1, m):
    diff += [abs(a[i] - a[i-1])]

diff = sorted(diff, reverse=True)

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

print(ans)
A = int(input())
P = int(input())
 
pi = round((A*3 + P)/2)
 
print(pi)

### FIXED CODE ###

a,p=map(int,input().split())
print((a*3+p)//2)
import numpy as np
from scipy.spatial.distance import cityblock
H,W = map(int,input().split())
for row in range(H):
    Inputs = input().split(',')
    for column in [i for i, x in enumerate(Inputs) if x == '#']:
        B.append((column,row))
for b in B:
    OO.apppend(cityblock((0,0),b))
    OI.apppend(cityblock((H-1,0),b))
    IO.apppend(cityblock((0,W-1),b))
    II.append(cityblock(H-1,W-1,b))
print(min(min(OO),min(OI),min(IO),min(II)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
h, w = map(int, input().split())
a = []
a = [[True] * (w + 2)]
for i in range(h):
    a.append([True] + [x == '#' for x in input()] + [True])
a.append([True] * (w + 2))
q = []

for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j]:
            q.append((i, j))

count = 0
while True:
    qq = []
    for i, j in q:
        if not a[i-1][j]:
            a[i-1][j] = True
            qq.append((i - 1, j))
        if not a[i+1][j]:
            a[i+1][j] = True
            qq.append((i + 1, j))
        if not a[i][j-1]:
            a[i][j-1] = True
            qq.append((i, j - 1))
        if not a[i][j+1]:
            a[i][j+1] = True
            qq.append((i, j + 1))
    q = qq
    if len(q) <= 0:
        break
    count += 1

print(count)
n=input()
s=input()
t=s.count('R')
if 2*t>n:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n=int(input())
s=input()
t=s.count('R')
if 2*t>n:
    print('Yes')
else:
    print('No')
(X,Y,Z,K) = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

delicious_list = []
for a in A[:min((1500,len(A)))]:
    for b in B[:min((1500,len(A)))]:
        for c in C[:min((1500,len(A)))]:
            delicious_list.append(a+b+c)
delicious_list.sort(reverse=True)
for i in range(K):
    print(delicious_list[i])

### FIXED CODE ###

lis = []
for i in range(5):
    lis.append(int(input()))
k = int(input())

flag_disconnectable = False
for i in range(5):
    for j in range(5):
        if i == j: continue
        if (lis[j]-lis[i]) > k:
            flag_disconnectable = True
            break

if flag_disconnectable:
    print(":(")
else:
    print("Yay!")
S = input()
return s[0:3]

### FIXED CODE ###

s = input()
print(s[0:3])
while True :
    (x,y) = int(i) for i in input().strip(split())
    if x = 0 and y = 0 :
        break
    elif x <= y:
        print(x,y)
    else :
        peint(y,x)

### FIXED CODE ###

while True:
    (x, y) = [int(i) for i in input().split()]
    
    if x == y == 0 :
        break

    if x <= y :
        print(x, y)
    else :
        print(y, x)
w = input()

for i in w:
    if w.count(i)%2! = 0:
        print("No")
            break
else:
    print("Yes")



### FIXED CODE ###

w = input()

ans = "No"
for i in w:
    if w.count(i)%2!= 0:
        break
else:
    ans = "Yes"
print(ans)
from math import math
print(int(input())**2*math.pi)


### FIXED CODE ###

import math
r,p = float(input()),math.pi
print(r**2*p,2*p*r)
s = str(input())
        k = int(input())
        for i in s:
            if i != "1":
                print(i)
                break

### FIXED CODE ###

S = input()
K = int(input())
 
if K == 1:
    print(S[0])
    exit()
else:
    for i in range(K):
        if S[i] != '1':
            print(S[i])
            exit()
print(1)
S = input()
L = len(input())
dp = [[0 for _ in range(13)] for _ in range(L+1)]
dp[0][0] = 1
MOD = 10 ** 9 + 7
for i in range(L):
  if S[i] == '?':
    for j in range(10):
      for k in range(13):
        dp[i][(k*10+j)%13] += dp[i][j]
  else:
    for k in range(13):
      dp[i][(k*10+int(i))%13] += dp[i][j]
print(dp[L][5]

### FIXED CODE ###

S = input()
l = len(S)
dp = [[0] * 13 for _ in range(l+1)]
dp[0][0] = 1
MOD = 10 ** 9 + 7
mul = 1
for i in range(l):
    if S[-(i+1)] == '?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(j * mul + k) % 13] += dp[i][k]
                dp[i+1][(j * mul + k) % 13] %= MOD
    else:
        j = int(S[-(i+1)])
        for k in range(13):
            dp[i+1][(j * mul + k) % 13] += dp[i][k]
            dp[i+1][(j * mul + k) % 13] %= MOD
    mul = mul * 10 % 13
print(dp[l][5])
x1,y1,x2,y2=map(int,input().split())
print(float((abs(x1-x2)**2)+abs(y1-y2)**2)**(1/2))

### FIXED CODE ###

v,w,x,y=map(float,input().split())
print(float((abs(v-x)**2)+abs(w-y)**2)**(1/2))
a, b, h = map(int, input().split())
print(int((a + b) * h / 2))

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
s = a*b
if s%2==0:
  print("Even")
else :
  print("Odd")
  

### FIXED CODE ###

a,b = map(int,input().split())
s = a*b
if s%2==0:
  print("Even")
else :
  print("Odd")
S=input()
x,y=map(int,input().split())
import itertools
Xmove=[]
Ymove=[]
Xbase=0
Ybase=0
Xtar=True
for key,g in itertools.groupby(S):
  num=len(list(g))
  if key=="T":
    if num%2==1:
      Xtar^=True
  else:
    if Xtar:
      Xmove.append(num)
      Xbase+=num
    else:
      Ymove.append(num)
      Ybase+=num
if Xbase<x or Ybase<y:
  print("No")
  exit(0)

dpX=[[False for i in range(Xbase*2+1)] for j in range(2)]
dpY=[[False for i in range(Ybase*2+1)] for j in range(2)]
Xind=0

if S[0]=="F":
  dpX[0][Xbase+Xmove[0]]=True
  Xind=1
else:
  dpx[0][Xbase]=True
dpY[0][Ybase]=True

cur=0
for i in range(Xind,len(Xmove)):
  for j in range(len(dpX[cur])):
    if dpX[cur][j]:
      dpX[1-cur][j+Xmove[i]]=True
      dpX[1-cur][j-Xmove[i]]=True
      dpX[cur][j]=False
  cur=1-cur
  
if not dpX[cur][x+Xbase]:
  print("No")
  exit(0)
  
cur=0
for i in range(len(Ymove)):
  for j in range(len(dpY[cur])):
    if dpY[cur][j]:
      dpY[1-cur][j+Ymove[i]]=True
      dpY[1-cur][j-Ymove[i]]=True
      dpY[cur][j]=False
  cur=1-cur
  
if dpY[cur][y+Ybase]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

S = input()
X,Y = map(int,input().split())

# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
  sumS.append([key,len(list(g))])
  
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
  startx = sumS[0][1]
  sumS.popleft()

xdir = True # X軸方向を向いている
dpXcur = set()
dpXcur.add(startx)
dpYcur = set()
dpYcur.add(0) # Y軸は必ず0から始まる
dpXnex = set()
dpYnex = set()
for i in range(len(sumS)):
  if sumS[i][0] == "F":
    steps = sumS[i][1] # 進む数
    if xdir: # X軸方向を向いている場合
      for x in dpXcur:
        dpXnex.add(x + steps)
        dpXnex.add(x - steps)
      dpXcur = dpXnex
      dpXnex = set()
    else:
      for y in dpYcur:
        dpYnex.add(y + steps)
        dpYnex.add(y - steps)
      dpYcur = dpYnex
      dpYnex = set()
  elif sumS[i][0] == "T":
    turns = sumS[i][1] # 方向転換する数
    if turns % 2 == 1:
      # 奇数回の場合はX/Y軸の切り替え (偶数回の場合は何も起こらない)
      xdir ^= True
      
if X in dpXcur and Y in dpYcur:
  print("Yes")
else:
  print("No")
N, M, K = map(int, input().split())

ans = False
for n in range(N + 1):
    if (M * n - K) % (2 * n - N) == 0:
        ans = True
        break
print('Yes' if ans else 'No')


### FIXED CODE ###

N, M, K = map(int, input().split())

ans = False
for n in range(N + 1):
    for m in range(M + 1):
        if n * (M - m) + m * (N - n) == K:
            ans = True
            break
    else:
        continue
    break
print('Yes' if ans else 'No')
N,A,B= map(int,input().split(' '))
x=A*N:
if x>B:
  print(str(B))
elif x=B:
  print(str(B))
else ;
  print(str(x))


### FIXED CODE ###

n,a,b=map(int,input().split())
print(min(n*a,b))
import numpy as np
n,k=map(int,input().split())
a=[0]+[int(input())-k for _ in range(n)]
ac=np.cumsum(a)
##BITは分からない
def rec(l):
    ll=len(l)
    if ll<=1:
        return 0
    l1=l[:ll//2]
    l2=l[ll//2:]
    res=rec(l1)+rec(l2)
    l1.sort()
    l2.sort()
    i2=0
    for i in range(len(l1)):
        while i2<len(l2) and l2[i2]<l1[i]:
            res+=len(l1)-i
            i2+=1
    return res
print(n*(n+1)//2-rec(ac))
    
    

### FIXED CODE ###

n,k=map(int,input().split())
a=[0]+[int(input())-k for _ in range(n)]
sm=0
ac=[]
for ai in a:
    sm+=ai
    ac.append(sm)


def rec(l):
    ll=len(l)
    if ll<=1:
        return 0
    l1=l[:ll//2]
    l2=l[ll//2:]
    res=rec(l1)+rec(l2)
    l1.sort()
    l2.sort()
    i2=0
    for i in range(len(l1)):
        while i2<len(l2) and l2[i2]<l1[i]:
            res+=len(l1)-i
            i2+=1
    return res
print(n*(n+1)//2-rec(ac))
def dfs(G,s,p):
    for nv in G[s]:
        if(nv==p):
            continue
        Count[nv]+=Count[s]
        dfs(G,nv,s)
    
N,Q=map(int,input().split())
Count=[0]*N
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
for i in range(Q):
    p,x=map(int,input().split())
    Count[p-1]+=x
dfs(G,0,-1)
print(*Count)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
def dfs(G,s,p):
    for nv in G[s]:
        if(nv==p):
            continue
        Count[nv]+=Count[s]
        dfs(G,nv,s)
    
N,Q=map(int,input().split())
Count=[0]*N
G=[[] for i in range(N)]
for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)
for i in range(Q):
    p,x=map(int,input().split())
    Count[p-1]+=x
dfs(G,0,-1)
print(*Count)
S = input()
l = len(S)
if l%2:
    c = S[l//2]
    for i in range(1,l//2+1):
        if S[l//2-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
    print(l//2+i)
else:
    c = S[l//2]
    for i in range(l//2+1):
        if S[l//2-i] != c or S[l//2 - 1 + i] != c:
            break
    else:
        i += 1
    print(l//2 + i)

### FIXED CODE ###

S = input()
l = len(S)
i = 0
if l%2:
    c = S[l//2]
    for i in range(1,l//2+1):
        if S[l//2-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
    print(l//2+i)
else:
    c = S[l//2]
    for i in range(l//2):
        if S[l//2-1-i] != c or S[l//2 + i] != c:
            break
    else:
        i += 1
        pass
    print(l//2 + i)
A - Strings

### FIXED CODE ###

x, y = input().split()
print(y+x)
a,b = [int(e) for e in input().split()]
print('{0} {1} {:f}'.format(a//b, a%b, a/b))

### FIXED CODE ###

a, b = [int(x) for x in input().split()]
print('{0} {1} {2:f}'.format(a//b, a%b, a/b))
def main():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')
if __name__ == '__main__':
    main(

### FIXED CODE ###

def main():
    s = input()
    if s == 'ABC':
        print('ARC')
    else:
        print('ABC')
if __name__ == '__main__':
    main()
N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))
 
import numpy as np
 
count=np.array([0 for i in range(N)])
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        count[i+1:]+=1
 
for i,j in lr:
    print(count[j-1]-count[i-1])

### FIXED CODE ###

N,Q = list(map(int, input().split()))
S = str(input())
lr=[]
for i in range(Q):
    lr.append(list(map(int, input().split())))


count=[0]

k = 0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        k += 1
    count.append(k)

for i,j in lr:
    print(count[j-1]-count[i-1])
n = int(input())
A = list(map(int,input().split())
c = 1
for a in A:
	c *= a
    if c > 10**18:
         print("-1")
         quit()
print(c)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
c = 1
flag = True
for _ in a:
    c *= _
    if c > 10**18:
        flag = False
        c = 1
    if c == 0:
        print(0)
        quit()
if flag:
    print(c)
else:
    print(-1)
N=int(input())
d=list(map(int,input().split()))
a=[]
for i in range(N):
  if a.count(d[i])==0:
    a.append(d[i])
print(len(a))


### FIXED CODE ###

N=int(input())
d=[int(input()) for i in range(N)]
a=[]
for i in range(N):
  if a.count(d[i])==0:
    a.append(d[i])
print(len(a))
N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*M

for i in range(M):
    P = C[i][1]
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1] + 1)]
    Num[P-1] += 1

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])

### FIXED CODE ###

N, M = map(int, input().split())
C = [[0, 0, 0] for i in range(M)] # Cities
for i in range(M):
    P, Y = map(int, input().split())
    C[i] = [i, P, Y]

C.sort(key=lambda x: x[2])

I = [[0, 0] for i in range(M)]
Num = [0]*N

for i in range(M):
    P = C[i][1]
    Num[P-1] += 1
    I[i] = [C[i][0], "%06d%06d" % (P, Num[P-1])]

I.sort(key=lambda x: x[0])
for i in range(M):
    print(I[i][1])
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0]*(W+1) for _ in range(N+2)]
    #dp = [0]*(W+1)
    for i in range(N):
        for sum_w in range(W):
            if sum_w+w[i] <=W:
                dp[i+1][sum_w+w[i]] = max(dp[i][sum_w+w[i]], dp[i][sum_w]+v[i])
                #dp[sum_w+w[i]] = max(dp[sum_w+w[i]], dp[sum_w]+v[i])
            #dp[i+1][sum_w] = dp[i][sum_w]
            dp
        dp[i+2] = dp[i+1].copy()
    return max(dp[-1])


# Generated by 1.1.4 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
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    print(solve(N, W, w, v))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy

def solve(N, W, w, v):
    dp = [[0]*(W+1) for _ in range(N+2)]
    for i in range(N):
        for sum_w in range(W):
            if sum_w+w[i] <=W:
                dp[i+1][sum_w+w[i]] = max(dp[i][sum_w+w[i]], dp[i][sum_w]+v[i])
        dp[i+2] = copy.copy(dp[i+1])
    return max(dp[-1])

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
w,v=[], []
for i in wv:
    w.append(i[0])
    v.append(i[1])

print(solve(N, W, w, v))