Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys
from itertools import chain


def max_add_1_to_n(loop, n):
    # print('  max_add_1_to_n', loop, n)
    l = len(loop)
    acc = loop.copy()
    # print('    ', acc)
    max_val = max(acc)
    for i in range(1, n):
        for j in range(0, l):
            acc[j] += loop[(i + j) % l]
        # print("    ", acc)
        max_val = max(max(acc), max_val)
    return max_val


def max_add_0_to_n(loop, n):
    # print('  max_add_0_to_n', loop, n)
    if n >= 1:
        return max(max_add_1_to_n(loop, n), 0)
    else:
        return 0


def max_loop_k(loop, K):
    l = len(loop)
    if K <= 2 * l:
        return max_add_1_to_n(loop, K)
    # K は 2 * l より長い
    l_sum = sum(loop)
    if l_sum <= 0:
        return max_add_1_to_n(loop, l)
    else:
        Kdiv = K // l
        Kmod = K % l
        # print('  l Kdiv Kmod', l, Kdiv, Kmod)
        return max_add_0_to_n(loop, l + Kmod) + l_sum * (Kdiv - 1)


def solve(N: int, K: int, P: "List[int]", C: "List[int]"):
    # 簡単のためインデックスを 0 からにする
    # (使用済みは -1 を入れる)
    P = [i - 1 for i in P]
    answer = -float("inf")
    for i0 in range(N):
        if P[i0] == -1:
            continue
        loop = []
        i = i0
        while P[i] != -1:
            loop.append(C[i])
            i_next = P[i]
            P[i] = -1
            i = i_next
        answer = max(answer, max_loop_k(loop, K))

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, P, C)
    print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python
import sys
from itertools import chain

# import numpy as np


def solve(S: str):
    answer = max(list(map(len, S.split("S"))))
    return answer


def main():
    S = input()  # type: str
    print(solve(S))


if __name__ == "__main__":
    main()
import copy
S_dash = input()
T = input()

len_S = len(S_dash)
len_T = len(T)

candidate0 = list(S_dash)


ans = "z"*51

if len_S >= len_T:
  for s in range(len_S):
    cha_S = S_dash[s]
    if cha_S != "?" and cha_S in list(T):
      for t in range(len_T):
        cha_T = T[t]
        if cha_S == cha_T:
          S_cut = S_dash[s-t:s-t+len_T]
          
          candidate1 = copy.deepcopy(candidate0)
          
          for x in range(len_T):
            if S_cut[x] == "?":
              candidate1[s-t+x] = T[x]
            elif  S_cut[x] != T[x]:
              break
          
          else:
            if candidate1[s-t:s-t+len_T].count("?") == 0:
              if ans > "".join(candidate1).replace('?', 'a'):
                ans = "".join(candidate1).replace('?', 'a')
                
if ans = "z"*51:
  ans = "UNRESTORABLE"
print(ans)

### FIXED CODE ###

import copy
S_dash = input()
T = input()

len_S = len(S_dash)
len_T = len(T)

candidate0 = list(S_dash)


ans = "z"*51

if len_S >= len_T:
  for s in range(len_S):
    cha_S = S_dash[s]
    if cha_S != "?" and cha_S in list(T):
      for t in range(len_T):
        cha_T = T[t]
        if cha_S == cha_T and 0<= s-t < len_S and  0< s-t+len_T <= len_S:
          S_cut = S_dash[s-t:s-t+len_T]
          candidate1 = copy.deepcopy(candidate0)
          for x in range(len_T):
            if S_cut[x] == "?":
              candidate1[s-t+x] = T[x]
            elif  S_cut[x] != T[x]:
              break
          else:
            if "".join(candidate1[s-t:s-t+len_T]) == T:
              if ans > "".join(candidate1).replace('?', 'a'):
                ans = "".join(candidate1).replace('?', 'a')
  
  
  
  for u in range(len_S-len_T+1):
    cut_S = S_dash[u:u+len_T]
    if cut_S.count("?") == len_T:
      candidate1 = copy.deepcopy(candidate0)
      for t in range(len_T):
        candidate1[u+t] = T[t]
      if ans > "".join(candidate1).replace('?', 'a'):
        ans = "".join(candidate1).replace('?', 'a')
                
if ans == "z"*51:
  ans = "UNRESTORABLE"
print(ans)
N=int(input())
dict={}

for i in range(N):
	dict[input()]=1

ans=0
for d in dict:
  ans+=1
  
print('Three' if ans==3 else 'Four')


### FIXED CODE ###

N=int(input())
Colors=list(map(str,input().split()))
dict={}

for c in Colors:
  dict[c]=1

ans=0
for d in dict:
  ans+=1
  
print('Three' if ans==3 else 'Four')
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

### FIXED CODE ###

from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)
def main():
  from itertools import combinations
  x = int(input())
  ls = [0]
  if x == 1:
    print(0, -1)
  for i in range(1, 100):
    ls.append(i**5)
    ls.append(-i**5)
  ls.sort()
  for b in ls:
    if x + b in ls:
      a = x + b  
      break
  if a < 0:
    print(-1*int(pow(-a, 0.2)), end=' ')
  else:
    print(int(pow(a, 0.2)), end=' ')
  if b < 0:
    print(-1*int(pow(-b, 0.2)), end=' ')
  else:
    print(int(pow(b, 0.2)), end=' ')
  


if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  from itertools import combinations
  x = int(input())
  ls = [0]
  a = 0
  b = 0
  if x == 1:
    print(0, -1)
    exit()
  for i in range(1, 200):
    ls.append(i**5)
    ls.append(-i**5)
  ls.sort()
  for b in ls:
    if x + b in ls:
      a = x + b  
      break
  if a < 0:
    print(-1*int(pow(-a, 0.2)), end=' ')
  else:
    print(int(pow(a, 0.2)), end=' ')
  if b < 0:
    print(-1*int(pow(-b, 0.2)), end=' ')
  else:
    print(int(pow(b, 0.2)), end=' ')
  


if __name__ == '__main__':
  main()
N, M, X, Y =map( int, input()split())
x = list(map( int, input().split()))
y = list(map( int, input().split()))
 
x = sorted(x)
y = sorted(y)
 
for i in range(X + 1, Y + 1):
  if( x[N-1] < i <= y[0]):
    print('No War')
    exit()
    
  else:
    print('War')
    break

### FIXED CODE ###

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

N = sorted(N)

Nmax = int( N[2] * 10 + N[1] + N[0])

print(int(Nmax))
a,b,k = map(int,input().split())

t=[1]
for i in range(2, int(b/2)):
    if a%i == 0 and b%i == 0:
        t.append(i)
print(t[k-1])

### FIXED CODE ###

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

t=[]
for i in range(1, min(a,b)+1):
    if a%i == 0 and b%i == 0:
        t.append(i)
t = sorted(t,reverse=True)
print(t[k-1])
def s(n):
	rtn=0
    while n>0:
    	rtn+=n%10
        n//10
    return rtn
n=int(input())
print("Yes" if n%s(n)==0 else "No") 

### FIXED CODE ###

def s(n):
    rtn=0
    while n>0:
        rtn += n%10
        n//=10
    return rtn
x=int(input())
print('Yes' if x%s(x)==0 else 'No')
n, k = map(int,input().split())

import math
import decimal

x = decimal.Decimal(0)

for i in range(n):
    e = math.floor(math.log2(k//(i+1)))+1
    print(e)
    x += decimal.Decimal(1/(n*(2**e)))
print(x)

### FIXED CODE ###

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

import math
x=0

for i in range(n):
    if i+1<k:
        e = math.ceil(math.log2(k/(i+1)))
        
        x += 1/(n*(2**e))
    else:
        x+= 1/n
print(x)
from sympy import nextprime
x=int(input())
print(nextprime(x))

### FIXED CODE ###

x=int(input())

def isprime(n):
    if n==1:
        return False
    else:
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                return False
        return True
        
while True:
    if isprime(x):
        print(x)
        exit()
    else:
        x+=1
import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if ans1 <= 45.0:
    print (ans1)
else:
    print (ans2)

### FIXED CODE ###

import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a > x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 = 0.0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if a*a*b/2 <= x:
    print (ans1)
else:
    print (ans2)
a = int(input())
b = int(input())

import math
c = a*100 + b
d= int(math.sqrt(c))
if d**2 == c:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from math import sqrt
a, b = input().split()
n = int(a+b)
if(int(sqrt(n))**2 == n):
    print("Yes")
else:
    print("No")
import sys
def main(): 
    input_line1 = raw_input()
    work = input_line1.split(' ')

    ret = 'a<b' 
    if work[0] == work[1]:
        ret = 'a==b'
    if work[0] > work[1]:
        ret = 'a>b' 
    return ret

if __name__ == '__main__':
    sys.exit(main())

### FIXED CODE ###

input_value = raw_input().split(' ')
ret = 'a == b'
if int(input_value[0]) < int(input_value[1]): ret = 'a < b'
if int(input_value[0]) > int(input_value[1]): ret = 'a > b'
print(ret)
import math
temp=list(map(lambda x:int(x),input().split()))
A,B,C,D=temp[0],temp[1],temp[2],temp[3]
public_cd=math.gcd(C,D)

c_n_full=B//C
d_n_full=B//D
cd_n_full=B//((C*D)//public_cd)

c_n_par=(A-1)//C
d_n_par=(A-1)//D
cd_n_par=(A-1)//((C*D)//public_cd)

c_n=c_n_full-c_n_par
d_n=d_n_full-d_n_par
cd_n=cd_n_full-cd_n_par
counter=(B-A+1)-(c_n+d_n)+cd_n

print(counter)

### FIXED CODE ###


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

temp=list(map(lambda x:int(x),input().split()))
A,B,C,D=temp[0],temp[1],temp[2],temp[3]
public_cd=gcd(C,D)

c_n_full=B//C
d_n_full=B//D
cd_n_full=B//((C*D)//public_cd)

c_n_par=(A-1)//C
d_n_par=(A-1)//D
cd_n_par=(A-1)//((C*D)//public_cd)

c_n=c_n_full-c_n_par
d_n=d_n_full-d_n_par
cd_n=cd_n_full-cd_n_par
counter=(B-A+1)-(c_n+d_n)+cd_n

print(counter)
INF = float("inf") #const

def main():
    n,m = map(int,input().split())
    issafe = [0]*m
    for i in range(m):
        a = int(input())
        issafe[a] = False
    dp = [0]*(n+1)
    dp[0],dp[1] = 1,1

    for i in range(2,n+1):
        if issafe[i-1]:
            dp[i] += dp[i-1]
        if issafe[i-2]:
            dp[i] += dp[i-2]

    print(dp[n]%(10**9+7))


if __name__ == "__main__":
    main()


### FIXED CODE ###

INF = float("inf") #const

def main():
    n,m = map(int,input().split())
    issafe = [True]*n
    for i in range(m):
        a = int(input())
        issafe[a] = False
    dp = [0]*(n+1)
    dp[0],dp[1] = 1,1

    for i in range(2,n+1):
        if issafe[i-1]:
            dp[i] += dp[i-1]
        if issafe[i-2]:
            dp[i] += dp[i-2]

    print(dp[n]%(10**9+7))


if __name__ == "__main__":
    main()
def gcd(a, b):
    if b == 1:
        return 1
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

def lcm(A, n):
    if n == 2:
        return A[0]*A[1] // gcd(A[0], A[1])
    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
    a = lcm(A, n-1)
    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
a = []
for i in range(n-1):
    a.append(int(input()))
#a.sort(reverse = True)
ans = lcm(a, n)
print(str(ans))

### FIXED CODE ###

def gcd(a, b):
    if b == 1:
        return 1
    # a > b　を仮定
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

#def lcm(A, n):
#    if n == 2:
#        return A[0]*A[1] // gcd(A[0], A[1])
#    #lcm(A, n)はA[0]-A[n-1]までの最小公倍数を求める
#    a = lcm(A, n-1)
#    return a* A[n-1] // gcd(a, A[n-1])

n = int(input())
#a = []
T1 = int(input())
for i in range(n-1):
    T2 = int(input())
    T1 = T1*T2 // gcd(T1, T2)
    #a.append(int(input()))
#a.sort(reverse = True)
#ans = lcm(a, n)
print(str(T1))
e = S.count("E")
cnt = e
for i in S:
    if i == "E":
        cnt -= 1
    else:
        cnt += 1
    e = min(e, cnt)
print(e)

### FIXED CODE ###

N = int(input())
S = input()
e = S.count("E")
cnt = e
for i in S:
    if i == "E":
        cnt -= 1
    else:
        cnt += 1
    e = min(e, cnt)
print(e)
# ABC044
N, A = map(int, input().split())
X = list(map(int, input().split()))

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
dp = [[[0] * (max_wa + 5) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    ans += dp[-1][k][k*A]

print(ans)

### FIXED CODE ###

# ABC044
N, A = map(int, input().split())
X = list(map(int, input().split()))

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
dp = [[[0] * (max(X) * (N+1)) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    if k * A > max_wa:
        break
    ans += dp[-1][k][k*A]

print(ans)
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

H,W,M=nm()
r=[0]*(10**6)
c=[0]*(10**6)
ans=0
mass=[[0 for i in range(10**6)] for j in range(10**6)]
for i in range(M):
    h,w=nm()
    mass[h][w]=1
    r[h]+=1
    c[w]+=1

inds1=list(range(10**6))
inds1.sort(key=lambda x: r[x])

inds2=list(range(10**6))
inds2.sort(key=lambda x: c[x])

r.sort(reverse=True)
l.sort(reverse=True)

r1=0
l1=0

while(1):
    if(r[r1+1]==r[r1])
        r1+=1
    else:
        break

while(1):
    if(l[l1+1]==l[l1])
        l1+=1
    else:
        break

flag=False
for i in range(r1+1):
    for j in range(l1+1):
        if(mass[inds1[i]][inds2[j]]==0):
            flag=True
        
if(flag==True):
    print(r[0]+l[0])
else:
    print(r[0]+l[0]-1)






### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

H,W,M=nm()
r=[0]*(10**6)
c=[0]*(10**6)
mass=set()
for i in range(M):
    h,w=nm()
    mass.add(H*h+w)
    r[h]+=1
    c[w]+=1

rl=[]
cl=[]

r_max=0
for i in range(1,H+1):
    r_max=max(r[i],r_max)
    
c_max=0
for i in range(1,W+1):
    c_max=max(c[i],c_max)

for i in range(1,H+1):
    if(r[i]==r_max):
        rl.append(i)

for i in range(1,W+1):
    if(c[i]==c_max):
        cl.append(i)



for i in rl:
    for j in cl:
        if(i*H+j not in mass):
            print(r_max+c_max)
            sys.exit(0)


print(r_max+c_max-1)
import sys
sys.setrecursionlimit(10000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

print(li1,file=sys.stderr)
print(mm,file=sys.stderr)
ans = [mm[li1[i]-1]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    # print(str(i)+" ",end="")
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)
def dfs(X,Y,ch):
	stack.append([X,Y])
	print stack
	field[X][Y] = '.'
	while len(stack) != 0:
		x,y = stack.pop()
		for i in range(4):
				nx = x+moveY[i]
				ny = y+moveX[i]
				if (nx >= 0 and ny >= 0) and(nx < H and ny < W) and field[nx][ny] == ch:
					if field[nx][ny] == '#' or field[nx][ny] == '*'or field[nx][ny] == '@':
						field[nx][ny] = '.'
						stack.append([nx,ny])
						print stack
stack = []
moveY = [-1,0,1,0]
moveX = [0,1,0,-1]
while True:
	H,W = map(int,raw_input().split(' '))
	if H == 0 and W == 0:
		break
	field = ['' for i in range(H)]
	h = 0
	while True:
		field[h] = list(raw_input())
		h += 1
	correct =0
	for i in range(H):
		for j in range(W):
			if field[i][j] == '@' or field[i][j] == '#'or field[i][j] == '*':
				dfs(i,j,field[i][j])
				correct += 1
	print correct

### FIXED CODE ###

def dfs(X,Y,ch):
	stack.append([X,Y])
	field[X][Y] = '.'
	while len(stack) > 0:
		x,y = stack.pop()
		for i in range(4):
				nx = x+moveY[i]
				ny = y+moveX[i]
				if nx < 0 or ny < 0 or nx >= H or ny >= W or field[nx][ny] != ch:
					continue
				if field[nx][ny] == '#' or field[nx][ny] == '*'or field[nx][ny] == '@':
					field[nx][ny] = '.'
					stack.append([nx,ny])
stack = []
moveY = [-1,0,1,0]
moveX = [0,1,0,-1]
while True:
	H,W = map(int,raw_input().split(' '))
	if H == 0 and W == 0:
		break
	field = [list(raw_input()) for i in range(H)]
	correct =0
	for i in range(H):
		for j in range(W):
			if field[i][j] == '@' or field[i][j] == '#'or field[i][j] == '*':
				dfs(i,j,field[i][j])
				correct += 1
	print correct
print(input).swapcase()

### FIXED CODE ###

print(input().swapcase())
s = input()

if s == "Sunny":
  return "Cloudy"
elif s == "Cloudy":
  return "Rainy"
elif s == "Rainy":
  return "Sunny"

### FIXED CODE ###

s = input()

if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
elif s == "Rainy":
  print("Sunny")
import sys

def main(lines):
	n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(r + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys

def main(lines):
  n, r = map(int,lines[0].split())

  if n >= 10:
    print(r)
  else:
    print(r + 100*(10-n))
  return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
N = int(input())
balls = []
for i in range(2 * N):
    c, a = input().split()
    balls += [(c, int(a))]

# numB[i][b]: 初期状態において、i番目の玉より右にある、1～bが書かれた黒玉の数
numB = [[0] * (N + 1) for i in range(2 * N)]
numW = [[0] * (N + 1) for i in range(2 * N)]
for i in reversed(range(1, 2 * N)):
    c, a = balls[i]
    numB[i - 1] = numB[i].copy()
    numW[i - 1] = numW[i].copy()
    if c == 'B':
        for b in range(a, N + 1):
            numB[i - 1][b] += 1
    else:
        for w in range(a, N + 1):
            numW[i - 1][w] += 1

# costB[b][w]: 黒玉1～b、白玉1～wのうち、初期状態において、黒玉[b+1]より右にある玉の数
costB = [[0] * (N + 1) for i in range(N + 1)]
costW = [[0] * (N + 1) for i in range(N + 1)]
for i in reversed(range(2 * N)):
    c, a = balls[i]
    if c == 'B':
        cost = numB[i][a - 1]
        for w in range(N + 1):
            costB[a - 1][w] = cost + numW[i][w]
    else:
        cost = numW[i][a - 1]
        for b in range(N + 1):
            costW[b][a - 1] = cost + numB[i][b]

dp = [[float('inf')] * (N + 1) for i in range(N + 1)]
dp[0][0] = 0
for b in range(N + 1):
    for w in range(N + 1):
        if b > 0:
            dp[b][w] = min(dp[b][w], dp[b - 1][w] + costB[b - 1][w])
        if w > 0:
            dp[b][w] = min(dp[b][w], dp[b][w - 1] + costW[b][w - 1])

print(dp[N][N])


### FIXED CODE ###

N = int(input())
balls = []
for i in range(2 * N):
    c, a = input().split()
    balls += [(c, int(a))]

# numB[i][b]: 初期状態において、i番目の玉より右にある、1～bが書かれた黒玉の数
numB = [[0] * (N + 1) for i in range(2 * N)]
numW = [[0] * (N + 1) for i in range(2 * N)]
for i in reversed(range(1, 2 * N)):
    c, a = balls[i]
    numB[i - 1] = list(numB[i])
    numW[i - 1] = list(numW[i])
    if c == 'B':
        for b in range(a, N + 1):
            numB[i - 1][b] += 1
    else:
        for w in range(a, N + 1):
            numW[i - 1][w] += 1

# costB[b][w]: 黒玉1～b、白玉1～wのうち、初期状態において、黒玉[b+1]より右にある玉の数
costB = [[0] * (N + 1) for i in range(N + 1)]
costW = [[0] * (N + 1) for i in range(N + 1)]
for i in reversed(range(2 * N)):
    c, a = balls[i]
    if c == 'B':
        cost = numB[i][a - 1]
        for w in range(N + 1):
            costB[a - 1][w] = cost + numW[i][w]
    else:
        cost = numW[i][a - 1]
        for b in range(N + 1):
            costW[b][a - 1] = cost + numB[i][b]

dp = [[float('inf')] * (N + 1) for i in range(N + 1)]
dp[0][0] = 0
for b in range(N + 1):
    for w in range(N + 1):
        if b > 0:
            dp[b][w] = min(dp[b][w], dp[b - 1][w] + costB[b - 1][w])
        if w > 0:
            dp[b][w] = min(dp[b][w], dp[b][w - 1] + costW[b][w - 1])

print(dp[N][N])
from fractions import gcd
import numpy as np
n = int(input())
a = list(map(int, input().split()))
l = np.zeros(n)
r = np.zeros(n+1)
r[n] = 0
for i in range(n):
    if i == 0:
        l[0] = 0
    else:
        l[i] = gcd(l[i-1],a[i-1])
for j in range(n-1, -1, -1):
        r[j] = gcd(r[j+1],a[j])
m = 0
for i in range(n):
    m = max(gcd(l[i],r[i+1]),m)
print(int(m))

### FIXED CODE ###

from fractions import gcd
import numpy as np
n = int(input())
a = list(map(int, input().split()))
l = np.zeros(n)
r = np.zeros(n+1)
r[n] = 0
for i in range(n):
    if i == 0:
        l[0] = 0
    else:
        l[i] = gcd(l[i-1],a[i-1])
for j in range(n-1, -1, -1):
        r[j] = gcd(r[j+1],a[j])
m = 0
for i in range(n):
    m = max(gcd(l[i],r[i+1]),m)
print(int(m))
w =str(input())

length = len(w)
z = sorted(w)
i=0
while i < length:
    if z[i]==z[i+1]:
        i += 2
    else:
        print("No")
        break
if i >= length-1:
    print("Yes")

### FIXED CODE ###

w =str(input())

length = len(w)
z = sorted(w)
i=1
m=0
   
if length%2 == 1:
    m = 1
    pass
else:
    while i < length:        
        if z[i]==z[i-1]:
            i += 2
        else:
            m = 1
            break
        
if m == 1:
    print("No")
else:
    print("Yes")
import math
N = int(input())

if N % 2 == 0 :
    print(N)
else :
    print((2 * N) // math.gcd(2, N))


### FIXED CODE ###

N = int(input())
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

print(lcm(2,N))