Harryxun/stf_run huggingface dataset:
s=input()
x,y=map(int,input().split())
N=len(s)

memo={}
def dfs(startx,starty,direction,num):
    if (startx,starty,direction,num) in memo.keys():
        return memo[(startx,starty,direction,num)]
    if num==N:
        memo[(startx,starty,direction,num)]=0
        memo[(startx,starty,direction,num)]=(startx==x and starty==y)
        return (startx==x and starty==y)

    if s[num]=='F':
        if direction==0:
            memo[(startx,starty,direction,num)]=0
            memo[(startx,starty,direction,num)]=dfs(startx+1,starty,direction,num+1)
            return memo[(startx,starty,direction,num)]
        if direction==90:
            memo[(startx,starty,direction,num)]=0
            memo[(startx,starty,direction,num)]=dfs(startx,starty+1,direction,num+1)
            return memo[(startx,starty,direction,num)]
        if direction==180:
            memo[(startx,starty,direction,num)]=0
            memo[(startx,starty,direction,num)]=dfs(startx-1,starty,direction,num+1)
            return memo[(startx,starty,direction,num)]
        if direction==270:
            memo[(startx,starty,direction,num)]=0
            memo[(startx,starty,direction,num)]=dfs(startx,starty-1,direction,num+1)
            return memo[(startx,starty,direction,num)]

    if s[num]=='T':
        memo[(startx,starty,direction,num)]=0
        if dfs(startx,starty,(direction+90)%360,num+1):
            memo[(startx,starty,direction,num)]=True
            return True
        if dfs(startx,starty,(direction-90)%360,num+1):
            memo[(startx,starty,direction,num)]=True
            return True

        memo[(startx,starty,direction,num)]=False
        return False

if dfs(0,0,0,0):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

from itertools import groupby


s=input()
x,y=map(int,input().split())
data=[s[i] for i in range(0,len(s))]
data=groupby(data)
LR=[]
UD=[]
point='LR'
flag=0
checkx=2**8000
for key,group in data:
    g=len(list(group))
    if key=='F':
        if flag==0:
            checkx=checkx<<g
            flag=1
        else:
            if point=='LR':
                LR.append(g)
            else:
                UD.append(g)
    else:
        if g%2==1:
            if point=='LR':
                point='UD'
            else:
                point='LR'
        flag=1


for i in range(0,len(LR)):
    checkx=(checkx<<LR[i])|(checkx>>LR[i])

checky=2**8000
for i in range(0,len(UD)):
    checky=(checky<<UD[i])|(checky>>UD[i])


if checkx>>(x+8000) &1==1 and checky>>(y+8000) &1==1:
    print('Yes')
else:
    print('No')
N = int(input())
A = map(int, input().split())

stage_hight = []
for i, ai in enumerate(A):
	if not i and ai < A[i-1]:
		stage_hight.append(A[i-1] - ai)
		A[i] = A[i-1]
print(sum(stage_hight))


### FIXED CODE ###

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

stage_hight = []
for i, ai in enumerate(A):
	if i != 0 and ai < A[i-1]:
		stage_hight.append(A[i-1] - ai)
		A[i] = A[i-1]
print(sum(stage_hight))
N=int(input())
A=list(map(int,input().split()))
A.sort()

dp=[False]*(10**6)
ans=0
for i in A:
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp>10**6:
    dp[tmp]=True
    tmp+=i
print(ans)

### FIXED CODE ###

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

A.sort()

dp=[False]*(10**6*2)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6*2-1:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)
A = int(input())
B = input()
C = (B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0')
ans = A*C/100
print(ans)

### FIXED CODE ###

A,B = map(str,input().split())
A = int(A)
B = int(B.replace(".",""))
ans = A*B//100
print(ans)
S=input()
if S=ABC:
	print("ARC")
else:
	print("ABC")

### FIXED CODE ###

S=input()
if S=="ABC":
	print("ARC")
else:
	print("ABC")
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heap.push(a, -1*b)
print(-1*sum(a))

### FIXED CODE ###

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

import heapq
a = [-1*i for i in a]
heapq.heapify(a)
for i in range(M):
    b = heapq.heappop(a)
    b = (-1*b)//2
    heapq.heappush(a, -1*b)
print(-1*sum(a))
import fractions

a, b, c, d = map(int, input().split())

b_c = b//c - (a-1)//c
d_c = b//d - (a-1)//d
cd = (c * d) // fractions.gcd(c, d)
cd_c = b//cd - (a-1)//cd

print((b - a + 1) - (b_c + d_c - cd_c))


### FIXED CODE ###

s = list(input())

p = ''
for i in s:
    if p == i:
        print('Bad')
        exit()
    else:
        p = i
print('Good')
N = int(input())
A = list(map(int, input().split()))

K = sum(A) / sum(range(1, N+1))
for i in range(-1,N-1):
    D = A[i+1] - A[i] - K 

for d in D:
    if not (d <= 0 and d % N == 0):
        print("NO")
        break
else:
    print("YES")


### FIXED CODE ###

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

K = sum(A) / sum(range(1, N+1))
D = []
for i in range(-1,N-1):
    D.append(A[i+1] - A[i] - K )

for d in D:
    if not (d <= 0 and d % N == 0):
        print("NO")
        break
else:
    print("YES")
N = int(input())
array = list(map(int,input().split()))
array.sort(reverse=True)
array2 = []
tmp = array[0]
for i in range(1,N):
    if tmp == array[i]:
        array2.append(array[i])
    tmp = array[i]
if array2.count(max(array2)) >= 4:
    print(max(array2)**2)
    exit()
array3 = list(set(array2))
array3.sort(reverse=True)
if 2 <= len(array3):
    print(array3[0]*array3[1])
else:
    print(0)

### FIXED CODE ###

N = int(input())
array = list(map(int,input().split()))
array.sort(reverse=True)
array2 = []
tmp = array[0]
for i in range(1,N):
    if tmp == array[i]:
        array2.append(array[i])
    tmp = array[i]
if len(array2) >= 1 and array2.count(max(array2)) >= 4:
    print(max(array2)**2)
    exit()
array3 = list(set(array2))
array3.sort(reverse=True)
if 2 <= len(array3):
    print(array3[0]*array3[1])
else:
    print(0)
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

sums = [0]*N
remainders = [0]*M

ans = 0

for i in range(N):
    if i == 0:
        t = A[i] % M
    else:
        t = (A[i] % M + sums[i-1]) % M
    sums[i] = t
    remainders[t] += 1
    ans += remainders[t] if t == 0 else remainders[t] - 1

print(ans)


### FIXED CODE ###

import collections
n, m = map(int, input().split())
A = [int(i) for i in input().split()]

R = [0]
a = 0
for i in range(n):
    a += A[i]
    a %= m
    R.append(a)


def nc2(n):
    return n*(n-1)//2


c = collections.Counter(R)
ans = 0
for r in set(R):
    ans += nc2(c[r])
print(ans)
from itertools import product

H, W, K = map(int, input().split())

C = [list(input().split()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt = K:
                ans += 1
print(ans)

### FIXED CODE ###

from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)
a=int(input())
b=int(input())
if (a*b)%2==0:
  print('Even')
else:
  print('Odd')


### FIXED CODE ###

a, b = map(int, input().split())
if a*b%2==0:
  print('Even')
else:
  print('Odd')
n, m = map(int, input().split())
import math
def comb(n, r):
	return math.factorial(s) // (math.factorial(s - r) * math.factorial(s))
print (comb(n,2) + comb(m,2))

### FIXED CODE ###

s = input()
n = len(s)
if s != s[::-1]:
	print ("No")
	exit()
if s[:n//2] != s[:n//2][::-1]:
	print ("No")
	exit()
if s[(n+3)//2-1:] != s[(n+3)//2-1:][::-1]:
	print ("No")
	exit()
print ("Yes")
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

line = input()
arr =  [int(n) for n in line.split(' ')]

print(lcm(*arr))


### FIXED CODE ###

import fractions

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

line = input()
arr =  [int(n) for n in line.split(' ')]

print(lcm(*arr))
from collections import deque
def main(*args, **kwargs):
    # Initialize data
    H, W = map(int, input().split())
    total_cells = H * W
    existing_black_cells = 0
 
    grid = []
    for i in range(H):
        line = input()
        existing_black_cells += line.count('#')
        grid.append = line
 
    # Initialize Search
    queue = deque()
    queue.append((0, 0))  # start point
    visited = set()
    movement = 0
 
    while len(queue) > 0:
        movement += 1
        for i in range(len(queue)): # Process same level
            coodinate = queue.popleft()
            visited.add(coodinate)
            y = coodinate[0]
            x = coodinate[1]
 
            # Terminate condition
            if y == H - 1 and x == W - 1:
                print(total_cells - movement - existing_black_cells)
                return
     
            for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                X = x+dx
                Y = y+dy
                adjacent = (Y, X)
                if grid[Y][X] == '.' and 0 <= X < W and 0 <= Y < H and adjacent not in visited:
                    queue.append(adjacent)
    print(-1)
    return
main()

### FIXED CODE ###

import sys
from collections import deque
    
def main(*args, **kwargs):
    # Initialize data
    H, W = map(int, sys.stdin.readline().split())
    total_cells = H * W
    existing_black_cells = 0
 
    grid = []
    for i in range(H):
        line = sys.stdin.readline()
        existing_black_cells += line.count('#')
        grid.append(line)
 
    # Initialize Search
    queue = deque()
    queue.append((0, 0))  # start point
    visited = set()
    visited.add((0, 0))
    movement = 0
 
    while len(queue) > 0:
        movement += 1
        for i in range(len(queue)):  # Process same level
            coodinate = queue.popleft()
            y = coodinate[0]
            x = coodinate[1]
 
            # Terminate condition
            if y == H - 1 and x == W - 1:
                print(total_cells - movement - existing_black_cells)
                return
 
            for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
                X = x + dx
                Y = y + dy
                adjacent = (Y, X)
                if 0 <= X < W and 0 <= Y < H and grid[Y][X] == '.' and adjacent not in visited:
                    queue.append(adjacent)
                    visited.add(adjacent)
    print(-1)
    return
main()
Import numpy as np

N,A,B=[int(i) for i in input().split()]
x=min(A,B)
if((A+B)>N):
    z=N
    y=abs(A+B-z)
else:
    y=0
print("{} {}".format(x,y))


### FIXED CODE ###

import numpy as np

N,A,B=[int(i) for i in input().split()]
x=min(A,B)
if((A+B)>N):
    z=N
    y=abs(A+B-z)
else:
    y=0
print("{} {}".format(x,y))
n=int(input())
a=list(map(int,input().split()))
d=[0]*(max(a)+2)
for i in a:
  d[i]+=1
  d[i+1]+=1
  d[i+2]+=1
print(max(d))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
d=[0]*(max(a)+3)
for i in a:
  d[i]+=1
  d[i+1]+=1
  d[i+2]+=1
print(max(d))
INF = 10**10 - 1 #無限大
SMAX = 3000 + 1

# 文字列入力
s1 = input()
s2 = input()

'''
dpの初期化
s1の文字列位置を一次軸、s2の文字列位置を二次軸に取り
その値として：LCSの最長値として更新していく
　　　　　　　初期値はすべて０
'''
dp = [ [0] * (len(s2)+1) for i in range(len(s2)+1)]

for s1pos in range(1,len(s1)+1):
    s1s = s1[s1pos-1:s1pos]
    for s2pos in range(1,len(s2)+1):
        s2s = s2[s2pos-1:s2pos]
        if s1s == s2s:
            dp[s1pos][s2pos] = dp[s1pos-1][s2pos-1] + 1
        dp[s1pos][s2pos] = max(dp[s1pos][s2pos],dp[s1pos][s2pos-1],dp[s1pos-1][s2pos])
    #print("s1pos=",s1pos,"dp=",dp[s1pos])

#print("LCS_len",dp[len(s1)][len(s2)])

res = ""
s1pos = len(s1)
s2pos = len(s2)
while (s1pos > 0 and s2pos > 0):
    # (s1pos-1, s2pos) -> (s1pos, s2pos) と更新されていた場合
    if (dp[s1pos][s2pos] == dp[s1pos-1][s2pos]):
        s1pos -= 1 # DP の遷移を遡る
    # (s1pos, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    elif (dp[s1pos][s2pos] == dp[s1pos][s2pos-1]):
        s2pos -= 1 # DP の遷移を遡る
    # (s1pos-1, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    else:
        res = s1[s1pos-1:s1pos] + res # 該当文字を取得
        s1pos -= 1 # DP の遷移を遡る
        s2pos -= 1 # DP の遷移を遡る

print(res)

### FIXED CODE ###

INF = 10**10 - 1 #無限大
SMAX = 3000 + 10

# 文字列入力
s1 = input()
s2 = input()

'''
dpの初期化
s1の文字列位置を一次軸、s2の文字列位置を二次軸に取り
その値として：LCSの最長値として更新していく
　　　　　　　初期値はすべて０
'''
dp = [ [0] * (SMAX) for i in range(SMAX)]

for s1pos in range(1,len(s1)+1):
    s1s = s1[s1pos-1:s1pos]
    for s2pos in range(1,len(s2)+1):
        s2s = s2[s2pos-1:s2pos]
        if s1s == s2s:
            dp[s1pos][s2pos] = dp[s1pos-1][s2pos-1] + 1
        dp[s1pos][s2pos] = max(dp[s1pos][s2pos],dp[s1pos][s2pos-1],dp[s1pos-1][s2pos])
    #print("s1pos=",s1pos,"dp=",dp[s1pos])

#print("LCS_len",dp[len(s1)][len(s2)])

res = ""
s1pos = len(s1)
s2pos = len(s2)
while (s1pos > 0 and s2pos > 0):
    # (s1pos-1, s2pos) -> (s1pos, s2pos) と更新されていた場合
    if (dp[s1pos][s2pos] == dp[s1pos-1][s2pos]):
        s1pos -= 1 # DP の遷移を遡る
    # (s1pos, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    elif (dp[s1pos][s2pos] == dp[s1pos][s2pos-1]):
        s2pos -= 1 # DP の遷移を遡る
    # (s1pos-1, s2pos-1) -> (s1pos, s2pos) と更新されていた場合
    else:
        res = s1[s1pos-1:s1pos] + res # 該当文字を取得
        s1pos -= 1 # DP の遷移を遡る
        s2pos -= 1 # DP の遷移を遡る

print(res)
N=int(input())
C = Counter(map(int, input().split()))
dp = [[[.0] * (N + 2) for _ in range(N + 2)] for _ in range(N + 2)]
for i in range(C[3] + 1):
    for j in range(N - C[1] - i + 1):
        for k in range(N - i - j + 1):
            if i + j + k != 0:
                dp[i][j][k] = (
                    N +
                    i * dp[i - 1][j + 1][k] +
                    j * dp[i][j - 1][k + 1] +
                    k * dp[i][j][k - 1]
                ) / (i + j + k)
print(dp[C[3]][C[2]][C[1]])

### FIXED CODE ###

N=int(input())
C=[0]*4
for i in map(int, input().split()):
    if i==1:
        C[1]+=1
    elif i==2:
        C[2]+=1
    else:
        C[3]+=1
dp = [[[.0] * (N + 2) for _ in range(N + 2)] for _ in range(N + 2)]
for i in range(C[3] + 1):
    for j in range(N - C[1] - i + 1):
        for k in range(N - i - j + 1):
            if i + j + k != 0:
                dp[i][j][k] = (
                    N +
                    i * dp[i - 1][j + 1][k] +
                    j * dp[i][j - 1][k + 1] +
                    k * dp[i][j][k - 1]
                ) / (i + j + k)
print(dp[C[3]][C[2]][C[1]])
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

### FIXED CODE ###

import sys
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)
N, M = input()
print(N*(N-1)//2+M*(M-1)//2)

### FIXED CODE ###

N, M = map(int, input().split())
print(N*(N-1)//2+M*(M-1)//2)
n,x=map(int,raw_input().split())
m=[int(raw_input()) for xrange(n)]
m.sort()

cnt = n
x -= sum(m)
cnt += x / m[0]

print cnt

### FIXED CODE ###

n,x=map(int,raw_input().split())
m=[int(raw_input()) for j in xrange(n)]
m.sort()

cnt = n
x -= sum(m)
cnt += x / m[0]

print cnt
N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)
n,m=map(int,input().split())
e=[]
for i in range(m):
    e.append(list(map(int,input().split())))
ans=0
for i in range(m):
    g=[[] for _ in range(n)]
    for j in range(m):
        if i==j:
            continue
        g[e[j][0]-1].append(e[j][1])
        g[e[j][1]-1].append(e[j][0])
    visited=[0]*n
    visited[0]=1
    q=[1]
    while len(q)>0:
        a=pop(q)
        visited[a-1]=1
        for k in g[a-1]:
            if visited[k-1]==0:
                q+=[k]
    if sum(visited)!=n:
        ans+=1
print(ans)
                    


### FIXED CODE ###

n,m=map(int,input().split())
e=[]
for i in range(m):
    e.append(list(map(int,input().split())))
ans=0
for i in range(m):
    g=[[] for _ in range(n)]
    for j in range(m):
        if i==j:
            continue
        g[e[j][0]-1].append(e[j][1])
        g[e[j][1]-1].append(e[j][0])
    visited=[0]*n
    visited[0]=1
    q=[1]
    while len(q)>0:
        a=q.pop(0)
        visited[a-1]=1
        for k in g[a-1]:
            if visited[k-1]==0:
                q+=[k]
    if sum(visited)!=n:
        ans+=1
print(ans)
x = int(input())
def resolve():
    x = int(input())
    print(8 - ((x - 400) // 200))

resolve()

### FIXED CODE ###

def resolve():
    x = int(input())
    print(8 - ((x - 400) // 200))

resolve()
n = int(input())
a = input().split()
s = ''
iList = [[ 0 for i in range(n)] for i in range(n)]


MIN = 100
#iの時にa[i]人いた
#a[i]が小さい順に並べてその時のiを順番に出力
for i in range(n):
	a[i] = int(a[i])
	iList[i][0] = a[i]
	iList[i][1] = i+1
for i in range(n):
	for j in range(n):
		if iList[i][0] < iList[j][0]:
			t = iList[i]
			iList[i] = iList[j]
			iList[j] = t
for i in range(n):
	s += str(iList[i][1])
	s += ' '


print(s)


### FIXED CODE ###

n = int(input())
ans = []
A = list(map(int,input().split()))
A2 = [[0,i+1] for i in range(n)]

for i in range(n):
	A2[i][0] = A[i]
#print(A2)
A2 = sorted(A2,key = lambda x:x[0])

for i in range(n):
	ans.append(A2[i][1])
print(*ans)
N = int(input())
score = list(map(int, input().split()))
total = 0
 
score.sort(reverse=True)
for i in range(0, N, 2):
  if score[i+1] == None:
    total += score[i]
  else:
    total += score[i]-score[i+1]

print(total)

### FIXED CODE ###

N = int(input())
score = list(map(int, input().split()))
A = 0
B = 0
 
score.sort(reverse=True)
for i in range(N):
  if i % 2 == 0:
    A += score[i]
  else:
    B += score[i]

print(A-B)
num=list(map(int,input().split()))
print('Yes' if len(num) == len(set(num) + 1) else 'No')

### FIXED CODE ###

num=list(map(int,input().split()))
print('Yes' if len(num) == len(set(num))+1 else 'No')
N,M = map(int,input().split())
adj = [ [] for _ in range(N) ]
for _ in range(M):
  u,v = map(int,input().split())
  u -= 1
  v -= 1
  adj[u].append(v)
  adj[v].append(u)

color = [None] * N
def dfs(n, c):
  color[n] = c
  for nei in adj[n]:
    if color[nei] is not None:
      if color[nei] == c: 
        return False
    else:
      dfs(nei, 1-c)

  return True

if dfs(0,1):
  print(color.count(1)*color.count(0) - M)
else:
  print(N*(N-1)//2 - M)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N,M = map(int,input().split())
adj_list = { i: [] for i in range(1, N+1) }

for i in range(M):
  a,b = map(int, input().split())
  adj_list[a].append(b)
  adj_list[b].append(a)

visited = [False]*(N+1)
colors = [None] * (N)
is_bipartite = True

## improved dfs ###
def dfs(node, c):
  colors[node-1] = c
  visited[node] = True
  for nei in adj_list[node]:
    if colors[nei-1] == c:
      return False
    if not visited[nei] and not dfs(nei, 1-c):
      return False

  return True

if dfs(1, 1):
  black = colors.count(1)
  print(black*(N-black) - M)
else:
  print(N*(N-1)//2 - M)
import math
from functools import reduce
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(math.gcd,l))

### FIXED CODE ###

import fractions
from functools import reduce
N,X = map(int,input().split())
l = list(map(lambda x: abs(int(x)-X),input().split()))
print(reduce(fractions.gcd,l))
B = 0
N = int(input())
A = (int(input()) for i in range(N))
for i in range(N):
  B += int(input())
C = (int(input()) for i in range(N-1))
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    B += C[i]
print(B)


### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    B.append(C[A[i]-1])
print(sum(B))
alphabet = 'abcdefghijklmnopqrstuvwxyz'
num_2_alpha = {i:alphabet[i - 1] for i in range(1,27)}

def named(N):
  _ = ''
  while N > 0:
    a = N % 26
    N = N // 26
    _ = num_2_alpha[a] + _
  
  return _

N = int(input())
print(named(N))

### FIXED CODE ###

alpha = [chr(i + 97) for i in range(26)] 
N = int(input())
name = ''
while N >= 1:
  N -= 1
  _ = N % 26
  name += alpha[_]
  N //= 26
  
print(name[-1::-1])
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

def calc(main,sub):
    if main%3==1:
        a=main//3
    else:
        a=main//3+1
    b=sub//2
    temp=[a*sub,(main-a)*b,(main-a)*(sub-b)]
    
    return max(temp)-min(temp)
        

if H%3==0 or W%3==0:
    print(0)
else:
    print(min(calc(H,W),calc(W,H),sub,main))
    


### FIXED CODE ###

# coding: utf-8
# Your code here!
H,W=map(int,input().split())

def calc(main,sub):
    if main%3==1:
        a=main//3
    else:
        a=main//3+1
    b=sub//2
    temp=[a*sub,(main-a)*b,(main-a)*(sub-b)]
    
    return max(temp)-min(temp)
        

if H%3==0 or W%3==0:
    print(0)
else:
    print(min(calc(H,W),calc(W,H),H,W))
N = int(input())

N_list = []
M_list = []
answer = -100

for i in range(N):
	s = input()
	N_list.append(s)

N = int(input())

for i in range(M):
	t = input()
	M_list.append(s)

for i in range(N):
	S = N_list[i]
	plus  = N_list.count(S)
	minus = M_list.count(S)
	if answer < (plus - minus):
		answer = (plus - minus)

print(answer)

### FIXED CODE ###

N = int(input())

N_list = []
M_list = []
answer = 0

for i in range(N):
	s = input()
	N_list.append(s)

M = int(input())

for i in range(M):
	t = input()
	M_list.append(t)

for i in range(N):
	S = N_list[i]
	plus  = N_list.count(S)
	minus = M_list.count(S)
	if answer < (plus - minus):
		answer = (plus - minus)

print(answer)
import math
def q45(n, d):
    a = math.ceil(n/(2*d+1))
    return a

N = int(input())
D = int(input())
print(q45(N, D))

### FIXED CODE ###

import math
def q45(n, d):
    a = math.ceil(n/(2*d+1))
    return a

N, D= [int(i) for i in input().split()]
print(q45(N, D))
n = int(input())
s = input()
R = s.count("R")
G = s.count("G")
B = s.count("B")
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        if 2*j - i <= n - 1:
            k = 2*j - i
            if len(set(s[i],s[j],s[k])) == 3:
                cnt += 1
print(R*G*B - cnt)

### FIXED CODE ###

n = int(input())
s = input()
R = s.count("R")
G = s.count("G")
B = s.count("B")
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        if j - i <= n - 1 - j:
            if s[i] != s[j] and s[j] != s[2*j - i] and s[i] != s[2*j - i]:
                cnt += 1
print(R*G*B - cnt)
N, M = map(int, input().split())
A = list(map(int, input().split())
         
t = sum(A)
if N < t:
  print(-1)
else:
  print(N-A)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
         
t = sum(A)
if N < t:
  print(-1)
  exit(0)
else:
  print(N-t)