Harryxun/stf_run huggingface dataset:
SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N) -> bool:
    tree[cur_pos + 1] = calc_next_animal(tree, cur_pos)
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


if __name__ == '__main__':
    N = int(input())
    answer = [True if i == 'o' else False for i in input().rstrip()]
    aa = [[WOLF, WOLF]
        , [WOLF, SHEEP]
        , [SHEEP, SHEEP]
        , [SHEEP, WOLF]]
    super_list = [0] * int(1E5)
    for a in aa:
        super_list[:2] = a
        if wfs(super_list, 1, N):
            print_tree(super_list[:N])
            break
    else:
        print(-1)

### FIXED CODE ###

import sys

sys.setrecursionlimit(int(2E5))

SHEEP = True
WOLF = False


def print_tree(tree):
    print(''.join(['S' if e else 'W' for e in tree]))


def calc_next_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos - 1]
        else:
            return not tree[cur_pos - 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos - 1]
        else:
            return tree[cur_pos - 1]


def calc_prev_animal(tree, cur_pos):
    if answer[cur_pos]:
        if tree[cur_pos] == SHEEP:
            return tree[cur_pos + 1]
        else:
            return not tree[cur_pos + 1]
    else:
        if tree[cur_pos] == SHEEP:
            return not tree[cur_pos + 1]
        else:
            return tree[cur_pos + 1]


def wfs(tree, cur_pos, N):
    tree[cur_pos + 1] = calc_next_animal(tree, cur_pos)
    cur_pos += 1
    if cur_pos == N - 1:
        return tree[0] == calc_next_animal(tree, cur_pos) and tree[cur_pos] == calc_prev_animal(tree, 0)
    else:
        return wfs(tree, cur_pos, N)


if __name__ == '__main__':
    N = int(input())
    answer = [True if i == 'o' else False for i in input().rstrip()]
    aa = [[WOLF, WOLF]
        , [WOLF, SHEEP]
        , [SHEEP, SHEEP]
        , [SHEEP, WOLF]]
    super_list = [0] * int(2E5)
    for a in aa:
        super_list[:2] = a
        if wfs(super_list, 1, N):
            print_tree(super_list[:N])
            break
    else:
        print(-1)
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai = -1
bi = -1
answer = 0
t_sum = 0
if sum(a) + sum(b) <= k:
    print(n + m)
elif sum(a) <= k:
    t_sum = sum(a)
    ai = n-1
    while True:
        bi += 1
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m:
            bi += 1
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
else:
    for i in range(n):
        t_sum += a[i]
        if t_sum > k:
            ai = i-1
            break
    while True:
        bi += 1
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m:
            bi += 1
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)

### FIXED CODE ###

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai = -1
bi = -1
answer = 0
t_sum = 0
if sum(a) + sum(b) <= k:
    print(n + m)
elif sum(a) <= k:
    t_sum = sum(a)
    ai = n-1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
else:
    while True:
        ai += 1
        if t_sum + a[ai] > k:
            break
        t_sum += a[ai]
    ai -= 1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi]
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
import sys

i = 0

while x != 0:
  x = sys.stdin.readline()
  i += 1

  print case,
  print "%d: %d", %(i,x)
  

### FIXED CODE ###

i = 0
d = 0

while d == 0:
    x = input()
    if x != 0:
        i += 1
        print("Case %d: %d" %(i, x))
    else:
        d = 1
import collections
n = int(input())

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

a = sorted(a)
b = list(set(a))
c=collections.Counter(a)

ans = 1
for i in range(1,n-1):
    cnt = 0
    if abs(b[i]-b[i-1]) <= 1 and abs(b[i]-b[i+1]) <= 1:
        cnt += c[b[i]] + c[b[i-1]] + c[b[i+1]]
        
    ans = max(ans,cnt)

print(ans)

### FIXED CODE ###

n = int(input())

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

l = [0]*100005 

for i in a:
    l[i] += 1
    
ans = 0
for i in range(1,99999):
    ans = max(ans,l[i] + l[i-1] + l[i+1])

print(ans)
from collections import deque
def main():
  n,m=map(int,input().split())
  e=[[]for _ in range(n)]
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    e[a].appned(b)
    e[b].append(a)
  ans=[-1]*n
  ans[0]="Yes"
  dq=deque([0])
  while dq:
    g=dq.popleft()
    for v in e[g]:
      if ans[v]==-1:
        ans[v]=g+1
        dq.append(v)
  print(*ans)
main()  


### FIXED CODE ###

def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
N=int(input())
A=[int(i) for i in input().split()]
T=[[A[0],A[1]]]
k=0
for i in range(2,N):
    if len(T[k])<=1:
        T[k].append(A[i])
        #continue
    if not((T[k][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[k][0]<=A[i-2]<=A[i-1]<=A[i])):
        k+=1
        T.append([])
        T[k].append(A[i])
    else:
        T[k].append(A[i])
print(len(T))


### FIXED CODE ###

N=int(input())
A=[int(i) for i in input().split()]
if N==1:
    print(1)
    exit()
T=[[A[0],A[1]]]
k=0
for i in range(2,N):
    if len(T[k])<=1:
        T[k].append(A[i])
        continue
    if not((T[k][0]>=A[i-2]>=A[i-1]>=A[i]) or (T[k][0]<=A[i-2]<=A[i-1]<=A[i])):
        k+=1
        T.append([A[i]])
    else:
        T[k].append(A[i])
print(len(T))
n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
i = 0
while(ab[i][0] == 1):
  relaypoint.append(ab[i][1])
  i += 1
ab.sort(key = lambda ab:ab[1] reverse = True)
relaypoint = list(set(relaypoint))
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == 5):
  if ab[j][0] in relaypoint:
    flag = 1
if flag == 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(m)])
relaypoint = []
for i in range(m):
  if ab[i][0] == 1:
    relaypoint.append(ab[i][1])
  else:
    break
ab.sort(key = lambda ab:ab[1],reverse = True)
relaypoint = set(relaypoint)
x = len(relaypoint)
j = 0
flag = 0
while(ab[j][1] == n):
  if ab[j][0] in relaypoint:
    flag = 1
  j += 1
if flag == 1:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
MOD = 10**9 + 7
X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()
  
if X < Y:
  X, Y = Y, X

sub = X - Y
tan = Y - sub

X = sub + tan//3 + 3
Y = tan//3 + 3
dp = [[0]*X for _ in range(Y)]

dp[1][0] = 1
for i in range(1, Y):
  for j in range(1, X):
    if dp[j][i]:
      dp[i][j] = dp[j][i]
      continue
    dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % MOD

print(dp[Y-1][X-1])

### FIXED CODE ###

import math

MOD = 10**9 + 7

# nCk
def comb(n, r):
    r = min(r, n-r)
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
  
# nCk mod
def comb_mod(n, r, mod):
  r = min(r, n-r)
  
  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 )

  return g1[n] * g2[r] * g2[n-r] % mod

X, Y = map(int, input().split())
  
if (X+Y)%3!=0:
  print(0)
  quit()

# (+1,+2):n, (+2,+1):m
m = (X*2 - Y) // 3
n = X - m*2

if m < 0 or n < 0:
  print(0)
  quit()

ans = comb_mod(n+m, n, MOD)

print(ans)
n, k = map(int, raw_input().split(" "))
s = raw_input()

new_s = s[:k] + chr(ord(s[k]) + 32) + s[k+1:]
print(new_s)


### FIXED CODE ###

n, k = map(int, raw_input().split(" "))
s = raw_input()

new_s = s[:k - 1] + chr(ord(s[k - 1]) + 32) + s[k:]
print(new_s)
V=int(input().strip())
E=V-1
inf=3*10**15
G=[]
dist=[inf]*V

for i in range(V):
    G.append([])
for i in range(E):
    at,bt,ct=map(int,input().strip().split(' '))
    G[at-1].append([ct,bt-1])
    G[bt-1].append([ct,at-1])

visited=[False]*V
def dfs(v,p,d):
    #global d
    dist[v]=d
    for q in G[v]:
        if q[1]==p:
            continue
        dfs(q[1],v,d+q[0])

Q, K=map(int,input().strip().split(' '))
K-=1 #0-indexedに直す

dfs(K,-1,0)

x=[]
y=[]

for i in range(Q):
    xt, yt=map(int,input().strip().split(' '))
    x.append(xt-1)#0-indexedに直して入れる
    y.append(yt-1)#0-indexedに直して入れる
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])




### FIXED CODE ###

import sys
#limit=sys.getrecursionlimit()
sys.setrecursionlimit(10000000)
#sys.setrecursionlimit(1000000000)

V=int(input().strip())
E=V-1
inf=3*10**15
G=[]
dist=[inf]*V

for i in range(V):
    G.append([])
for i in range(E):
    at,bt,ct=map(int,input().strip().split(' '))
    G[at-1].append([ct,bt-1])
    G[bt-1].append([ct,at-1])

visited=[False]*V
def dfs(v,p,d):
    #global d
    dist[v]=d
    for q in G[v]:
        if q[1]==p:
            continue
        dfs(q[1],v,d+q[0])

Q, K=map(int,input().strip().split(' '))
K-=1 #0-indexedに直す

dfs(K,-1,0)

x=[]
y=[]

for i in range(Q):
    xt, yt=map(int,input().strip().split(' '))
    x.append(xt-1)#0-indexedに直して入れる
    y.append(yt-1)#0-indexedに直して入れる
for i in range(Q):
    print(dist[x[i]]+dist[y[i]])
import fractions
from functools import reduce
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                s=n[j]/t
                if n[j] % t == 0 and s % 2 == 1:
                        n[j] = int(s)
 
                else: return 0
        return t/2
 
def mp(v):
        if v%2==1:v+=1
        return int(v//2)
 
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
n=sorted(set(n),reverse = True)
bs = int(n[0]//2)
 
if len(n) > 1:
        c = chk(n[-1])
        if  c != 0:
                v = lcm_o()*c
                if v > M: print(0) 
 
                else: print(mp(M//v))
        
        else: print(0)
        
elif len(n)==1: print(mp(M//bs))

### FIXED CODE ###

import fractions
from functools import reduce
N,M= [int(i) for i in input().split()]
n = [int(i) for i in input().split()]
#print(n)
n=sorted(set(n),reverse = True)
bs = n[0]
#print(n)
#c=len(n)
 
 
def lcm_b(a, b):
        #print("base",a,b)
        return (a * b) // fractions.gcd(a, b)
 
def lcm_o():
        global n
        return reduce(lcm_b, n)
 
def chk(v):
        global n
        for i in range(1,30):
                if v%2 == 1:break
                v = v//2
        t=2**(i-1)
        for j in range(len(n)):
                if n[j] % t == 0 and (n[j] / t) % 2 == 1:
                        n[j] = int(n[j]/t)
                else: return 0
        return i-1
 
if len(n) > 1:
        
        c = chk(n[-1])
        
        if  c != 0:
                v = lcm_o()*(2**(c-1))
                
                if v > M:
                        print(0) 
                else:
                        v = M//v
                        if v%2==1: v+=1
                        print(int(v//2))
        
        else: print(0)
elif len(n)==1:
        v = int(bs*0.5)
        v = M//v
        if v%2==1: v+=1
        print(int(v//2))
from decimal import * 
a,b,c = map(int, input().split())
if Decimal(a)**0.5+Decimal(b)**0.5 < Decimal(c)**0.5:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from decimal import * 
a,b,c = map(int, input().split())
if Decimal(a) ** Decimal('0.5')+Decimal(b) ** Decimal('0.5') < Decimal(c) ** Decimal('0.5'):
    print('Yes')
else:
    print('No')
import math
import sys
sys.setrecursionlimit(10**10)
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if b != 0:
    print(lcm(a, b))
else:
    print(a)

### FIXED CODE ###

from fractions import gcd
import sys
sys.setrecursionlimit(10**7)
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // gcd(x, y)
if b != 0:
    print(lcm(a, b))
else:
    print(a)
t = [[0 for i in range(10)] for j in range(10)]
case1 = [(0, 0), (0, -1), (1, 0), (0, 1), (-1, 0)]
case2 = [(1, -1), (1, 1), (-1, 1), (-1, -1)]
case3 = [(0, -2), (2, 0), (0, 2), (-2, 0)]
while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break
    for c in [case1, case2, case3][:s]:
        for _x, _y in c:
            if y+_y < 0 or x+_x < 0:
                continue
            t[y+_y][x+_x] += 1
            
print(sum(1 for l in t for v in l if not v))
print(max(v for l in t for v in l))

### FIXED CODE ###

t = [[0 for i in range(10)] for j in range(10)]
case1 = [(0, 0), (0, -1), (1, 0), (0, 1), (-1, 0)]
case2 = [(1, -1), (1, 1), (-1, 1), (-1, -1)]
case3 = [(0, -2), (2, 0), (0, 2), (-2, 0)]
while True:
    try:
        x, y, s = map(int, input().split(','))
    except:
        break
    for c in [case1, case2, case3][:s]:
        for _x, _y in c:
            if y+_y < 0 or x+_x < 0:
                continue
            try:
                t[y+_y][x+_x] += 1
            except IndexError:
                continue

print(sum(1 for l in t for v in l if not v))
print(max(v for l in t for v in l))
n,k=map(int,input().split())
step=list(map(int,input().split()))
dp=[0]*n
if n>=k:
  for i in range(1,k):
    min=10**7
    for j in range(1,i+1):
      if dp[i-j]+abs(step[i]-step[i-j])<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
    dp[i]=min
  for i in range(k,n):
    min=10**7
    count=k
    for j in step[i-k:i]:
      if dp[i-count]+abs(step[i]-j)<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
      count-=1
    dp[i]=min
else:
  for i in range(1,n):
    min=10**7
    for j in range(1,i+1):
      if dp[i-j]+abs(step[i]-step[i-j])<min:
        min=dp[i-j]+abs(step[i]-step[i-j])
    dp[i]=min
print(dp[n-1])


### FIXED CODE ###

def solve():
  n,k=[int(i) for i in input().split()]
  step=[int(i) for i in input().split()]
  dp=[0]*n
  for i in range(1,n):
    dp[i]=min([dp[j] + abs(step[i]-step[j]) for j in range(max(i-k,0),i)])
  return dp[n-1]
print(solve())
N = int(input())
a = 1
while a * a <= N:
  if N % a = 0:
    k = a
  a += 1
print(k + (N // k) - 2)


### FIXED CODE ###

N = int(input())
a = 1
while a * a <= N:
  if N % a == 0:
    k = a
  a += 1
b = N //k
print(b + k - 2)
n=int(input())
a=list(map(int,input().split()))
res = "YES"
for i in range(n):
  if i.count(a[i])>=2:
    res="NO"
    break
print(res)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=set(a)
print("YES" if n == len(b) else "NO")
n,m,q=map(int,input().split())
import math
a=[]
for i in range(1,min(m-1,q+1)):
    a.append(math.floor(n*i/m)-n*math.floor(i/m))
print(max(a))

### FIXED CODE ###

A, B, N = map(int, input().split())
from math  import floor

def f(A, B, N):
    return floor(A*N/B)-A*floor(N/B)


print(f(A, B, min(B-1, N)))
ソースコード 

Copy
Copy
A=list(map(int,input().split()))
S=input()
S=S[0:(A[1]-1)]+S[A[1]-1].lower()+S[(A[1]+1):A[0]]
print(S)

### FIXED CODE ###

A=list(map(int,input().split()))
S=input()
S=S[0:(A[1]-1)]+S[A[1]-1].lower()+S[A[1]:A[0]]
print(S)
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

#Educational DP Contest
#H-Grid1


r,c,k = map(int,input().split())
items = [[0]*c for _ in range(r)]
for i in range(k):
    a,b,v = map(int,readline().split())
    a,b = a-1,b-1
    items[a][b] = v

dp = [[[0]*4 for i in range(c+1)] for j in range(r+1)]

#process1
#移動は→↓の２通りのみなので、その方向に探索していけば良い。
for i in range(1,r+1):
    for j in range(1,c+1):
        if items[i-1][j-1]:
            dp[i][j][0] = max(max(dp[i-1][j]),dp[i][j-1][0])
            dp[i][j][1] = max(max(dp[i-1][j])+items[i-1][j-1],dp[i][j-1][1],dp[i][j-1][0]+items[i-1][j-1])
            dp[i][j][2] = max(dp[i][j-1][2],dp[i][j-1][1]+items[i-1][j-1])
            dp[i][j][3] = max(dp[i][j-1][3],dp[i][j-1][2]+items[i-1][j-1])
        else:
            dp[i][j][0] = max(max(dp[i-1][j]),dp[i][j-1][0])
            dp[i][j][1] = dp[i][j-1][1]
            dp[i][j][2] = dp[i][j-1][2]
            dp[i][j][3] = dp[i][j-1][3]
        """if maze[i][j] == "#":
            continue
        if i > 0: #i-1を参照するため端っこは除く
            dp[i][j] += dp[i-1][j]
        if j > 0:
            dp[i][j] += dp[i][j-1]
        dp[i][j] %= mod"""
"""ans = 0
for i in range(c):
    ans = max(ans,max(dp[-1][i]))

print(ans)"""
print(max(dp[-1][-1]))

### FIXED CODE ###

import sys
readline = sys.stdin.buffer.readline
r,c,k = map(int,readline().split())
items = [[0]*c for _ in range(r)]
for i in range(k):
    a,b,v = map(int,readline().split())
    a,b = a-1,b-1
    items[a][b] = v

dp0 = [[0]*(c+1) for j in range(r+1)]
dp1 = [[0]*(c+1) for j in range(r+1)]
dp2 = [[0]*(c+1) for j in range(r+1)]
dp3 = [[0]*(c+1) for j in range(r+1)]

for i in range(1,r+1):
    for j in range(1,c+1):
        #dp[i][j][0] = max(maximam[i-1][j],dp[i][j-1][0])
        #dp[i][j][1] = max(maximam[i-1][j]+items[i-1][j-1],dp[i][j-1][1],dp[i][j-1][0]+items[i-1][j-1])
        dp1[i][j] = max(dp0[i][j]+items[i-1][j-1],dp1[i][j-1],dp0[i][j-1]+items[i-1][j-1])
        dp2[i][j] = max(dp2[i][j-1],dp1[i][j-1]+items[i-1][j-1])
        dp3[i][j] = max(dp3[i][j-1],dp2[i][j-1]+items[i-1][j-1])
        if i < r:
            dp0[i+1][j] = max(dp0[i][j],dp1[i][j],dp2[i][j],dp3[i][j])
        #maximam[i][j] = max(dp[i][j])

print(max(dp0[-1][-1],dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))
n=int(input())
c=0
for i in range(n):
    a,b=input().split()
    if b=="JPY":
        c+=float(b)
    else:
        c+=float(b)*3800
print(c)

### FIXED CODE ###

n=int(input())
c=0
for i in range(n):
    a,b=input().split()
    if b=="JPY":
        c+=float(a)
    else:
        c+=float(a)*380000
print(c)
N = int(input())
ans = 0
for i in range(N):
    l,r = map(int,input())
    ans += r-l+1
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(N):
    l,r = map(int,input().split())
    ans += r-l+1
print(ans)
R = input()
S = R*3.14*2
print(S)

### FIXED CODE ###

import math
R = int(input())
print(2*math.pi*R)
n = int( raw_input( ) )
t = [ int( val ) for val in raw_input( ).split( " " ) ]
q = int( raw_input( ) )
s = [ int( val ) for val in raw_input( ).split( " " ) ]

cnt = 0
for si in s:
	for ti in t:
		if si == ti:
			cnt += 1
			break

print( cnt )

### FIXED CODE ###

n = int( input( ) )
t = [ int( val ) for val in input( ).rstrip( ).split( " " ) ]
q = int( input( ) )
s = [ int( val ) for val in input( ).split( " " ) ]
 
cnt = 0
for si in s:
    for ti in t:
        if si == ti:
            cnt += 1
            break
 
print( cnt )
S=str(input())
T=str(input())
ls = []
cnt = 0
for i in range(len(S)-len(T)):
    cnt = 0
    for j in range(len(T)):
        if T[j] != S[j+i]:
            cnt += 1
    ls.append(cnt)
print(min(ls))


### FIXED CODE ###

S=str(input())
T=str(input())
ls = []
cnt = 0
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        #print(i,j)
        if T[j] != S[j+i]:
            #print(T[j],S[j+i])
            cnt += 1
    ls.append(cnt)
#print(ls)
print(min(ls))
a,b=(int(x) for x in input().split())
list = []
t_cnt = 0
f_cnt = 0
for i in range(b):
  s = input().split()
  if s[1] == 'AC':
    if not (s[0] in list):
    	list.append(s[0])
        t_cnt += 1
  else:
    if not (s[0] in list):
      f_cnt += 1
print("{} {}".format(t_cnt, f_cnt))

### FIXED CODE ###

a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = [0]*a
for i in range(b):
  c, d = map(str,input().split())
  x = int(c) - 1
  if list[x] == 0:
    if d == 'AC':
        list[x] = 1
        t_cnt += 1
    else:
        f_cnt[x] += 1
for i in range(a):
  if list[i] ==0:
    f_cnt[i] = 0
print("{} {}".format(t_cnt, sum(f_cnt)))
import math
N=int(input())
M=math.factorial(N)
R=[]
for r in range (2,N+1):
  count=0
  while M%r==0:
    M=M/r
    count+=1
  R+=[count]

count=1
for r in range(N-1):
  count=count*(R[r]+1)
print(count)

### FIXED CODE ###

N=int(input())
R=[0]*(N-1)
for i in range(1,N+1):
  for r in range (2,N+1):
    count=0
    while i%r==0:
      i=i/r
      count+=1
    R[r-2]+=count

count=1
for r in range(N-1):
  count=count*(R[r]+1)
print(count%(10**9+7))
from operator import itemgetter
import sys

input = sys.stdin.readline
n,m = map(int,input().split())

in_p = []
in_y = []
p = []

for _ in range(n):
    p.append([])

for i in range(m):
    a,b = map(int,input().split())
    in_p.append(a)
    in_y.append(b)
    p[a-1].append(b)  

for i in range(n):
    p[i].sorted()

for i in range(m):
    year=str(in_p[i]).zfill(6)
    a = p[in_p[i]-1].index(in_y[i]) 
    num=str(a).zfill(6)
    print("{0}{1}".format(year,num))



### FIXED CODE ###

import copy

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

cnt = [0]*(10**5+4)

yy = []
yp = []
for _ in range(m):
    a,b = map(int,input().split())
    a,b = b,a
    yy.append([a,0])
    yp.append([a,b])

inlist = copy.deepcopy(yp)
yp.sort()
yy = dict(yy)

for i in range(m):
    cnt[yp[i][1]]+=1
    yy[yp[i][0]] = cnt[yp[i][1]]

for key,value in inlist:
    print("{:06}{:06}".format(value,yy[key]))