Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

s = list('x'+input())
#n,a,b = map(int,input().split())
# al = list(map(int,input().split()))

cnt = 0
i = 1
while i < len(s):
    if s[i-1] == 'B' and s[i] == 'W':
       cnt += 1
       s[i] = 'B'
       s[i-1] = 'W'
       i -= 2
    else:
        i += 1


print(cnt)


### FIXED CODE ###

from collections import Counter, defaultdict, deque
s = input()
#n,a,b = map(int,input().split())
# al = list(map(int,input().split()))

b = 0
ans = 0
for i in range(len(s)):
    if s[i] == 'B':
        b += 1
    elif s[i] == 'W':
        ans += b
    else:
        b = 0
print(ans)
### BUGGY CODE ###


def solve():
    for i in range(Q):
        cnt = S[lr[i][0]-1:lr[i][1]].count("AC")
#        print(S[lr[i][0]-1:lr[i][1]])
        print(cnt)

if __name__ == "__main__":
    N,Q = list(map(int, input().split()))  
    S = input()
    lr = [list(map(int, input().split())) for _ in range(Q)]
    solve()


### FIXED CODE ###


def solve():
    t = [0] * (N+1)
    for i in range(N):
        if S[i:i+2] == "AC":
            t[i+1] = t[i] + 1
        else:
            t[i+1] = t[i]
    for j in range(Q):
        print(t[lr[j][1]-1]-t[lr[j][0]-1])

if __name__ == "__main__":
    N,Q = list(map(int, input().split()))  
    S = input()
    lr = [list(map(int, input().split())) for _ in range(Q)]
    solve()
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=10**9
f=1
g=3
for i in range(2,n-1):
    while f < i and abs(sum(a[:f])-sum(a[f:i])) > abs(sum(a[:f+1])-sum(a[f+1:i])):
        f+=1
    while g < n and abs(sum(a[i:g])-sum(a[g:])) > abs(sum(a[i:g+1])-sum(a[g+1:])):
        g+=1
    ans=min(ans,max(abs(sum(a[:f])-sum(a[f:i])),abs(sum(a[:f])-sum(a[i:g])),abs(sum(a[:f])-sum(a[g:]))
                ,abs(sum(a[f:i])-sum(a[i:g])),abs(sum(a[f:i])-sum(a[g:])),abs(sum(a[i:g])-sum(a[g:]))))
print(ans)

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
a=[0]
c=0
for si in s:
    c+=si
    a.append(c)
ans=[]
f=1
g=3
for i in range(2,n-1):
    while abs(a[f]-(a[i]-a[f])) > abs(a[f+1]-(a[i]-a[f+1])):
        f+=1
    while abs(a[g]-a[i]-(a[n]-a[g])) > abs(a[g+1]-a[i]-(a[n]-a[g+1])):
        g+=1
    ls=[a[f],a[i]-a[f],a[g]-a[i],a[n]-a[g]]
    ans.append(max(ls)-min(ls))
print(min(ans))
### BUGGY CODE ###

input()
S = input().split()
input()
T = input().split()
count = 0
for t in T:
    if t in S:
        count += 1
print(count)

### FIXED CODE ###

input()
S = set(input().split())
input()
T = set(input().split())
count = 0
for t in T:
    if t in S:
        count += 1
print(count)
### BUGGY CODE ###

import math
N = int(input())
for n in range(int(math.sqrt(N)), N+1):
    if N % n == 0:
        print(int(math.log10(n)) + 1)
        exit()
print(int(math.log10(N)))

### FIXED CODE ###

import math
N = int(input())
ans = int(math.log10(N))
for n in range(1, int(math.sqrt(N))+1):
    if N % n == 0:
        ans = int(math.log10(N // n)) + 1
print(ans)
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
s_rgb = sorted([r, g, b], reverse=True)
result = 0
for i in range(int(n / s_rgb[0]) + 1)[::-1]:
    for j in range(int((n - s_rgb[0] * i) / s_rgb[1]) + 1)[::-1]:
        if s_rgb[0] * i + s_rgb[1] * j > n:
            break
        for k in range(int((n - s_rgb[0] * i - s_rgb[1] * j) / s_rgb[2]) + 1)[::-1]:
            if s_rgb[0] * i + s_rgb[1] * j + s_rgb[2] * k > n:
                break
            if s_rgb[0] * i + s_rgb[1] * j + s_rgb[2] * k == n:
                result += 1
                break
print(result)


### FIXED CODE ###

r, g, b, n = map(int, input().split())
s_rgb = sorted([r, g, b], reverse=True)
count = 0
for i in range(int(n / s_rgb[0]) + 1)[::-1]:
    for j in range(int((n - s_rgb[0] * i) / s_rgb[1]) + 1)[::-1]:
        tmp = n - s_rgb[0] * i - s_rgb[1] * j
        if (tmp >= 0 and tmp % s_rgb[2] == 0):
            count += 1
print(count)
### BUGGY CODE ###

import math

n=int(input())
A=list(map(int, input().split()))
L=['null']*n
R=['null']*n
c=0

for i,a in enumerate(A):
  L[i]=i+a
  R[i]=i-a
  c+=L.count(R[i])
print(c)


### FIXED CODE ###

n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)
### BUGGY CODE ###

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for lc in "abcdefghijklmnopqrstuvwxyz":
    for i in s_dic[lc]:
        for j in range(i + 1, len(s) + 1):
            substrings.add(s[i:j])
    if len(substrings) >= K:
        break
print(sorted(list(substrings))[K - 1])


### FIXED CODE ###

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for indices in s_dic.values():
    for i in indices:
        for j in range(i + 1, i + K + 1):
            substrings.add(s[i:j])
print(sorted(list(substrings))[K - 1])
### BUGGY CODE ###

import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l)]
for z in l:
  for f in m:
    if f+z == b:
      count+=1
print(count)

### FIXED CODE ###

import itertools
a,b=(int(x) for x in input().split())
l = range(a+1)
count = 0
m = [x+y for x,y in itertools.product(l,l) if (x+y)<=b]
for i in m:
  if b-i <= a:
    count+=1
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
H, W =  map(int, input().split(' '))
table = [list(input()) for _ in range(H)]

buf = []

for i in range(H):
    for j in range(W):
        if table[i][j] == '#':
            buf.append((i, j))


ans = 0
while True:
    n = 0
    for i in range(H):
        for j in range(W):
            if table[i][j] == '#':
                n += 1
    if n == H * W:
        break


    buf2 = []
    for i, j in buf:
        if i-1 >= 0 and table[i-1][j] != '#':
            table[i - 1][j] = '#'
            buf2.append((i-1, j))

        if i+1 < H and table[i+1][j] != '#':
            table[i + 1][j] = '#'
            buf2.append((i+1, j))

        if j-1 >= 0 and table[i][j-1] != '#':
            table[i][j-1] = '#'
            buf2.append((i, j-1))

        if j+1 < W and table[i][j+1] != '#':
            table[i][j+1] = '#'
            buf2.append((i, j+1))

    ans += 1
    buf = buf2


    # print('-- -- --')
    # print(buf)
    # for row in table:
    #     print(''.join(row))


print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
H, W =  map(int, input().split(' '))
table = [list(input()) for _ in range(H)]

buf = []

n = 0
for i in range(H):
    for j in range(W):
        if table[i][j] == '#':
            buf.append((i, j))
            n += 1


ans = 0
while n != H * W:
    ans += 1

    buf2 = []
    for i, j in buf:
        if i-1 >= 0 and table[i-1][j] != '#':
            table[i - 1][j] = '#'
            buf2.append((i-1, j))
            n += 1

        if i+1 < H and table[i+1][j] != '#':
            table[i + 1][j] = '#'
            buf2.append((i+1, j))
            n += 1

        if j-1 >= 0 and table[i][j-1] != '#':
            table[i][j-1] = '#'
            buf2.append((i, j-1))
            n += 1

        if j+1 < W and table[i][j+1] != '#':
            table[i][j+1] = '#'
            buf2.append((i, j+1))
            n += 1

    buf = buf2

    # print('-- -- --')
    # print(buf)
    # for row in table:
    #     print(''.join(row))


print(ans)
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s = input()

r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    if s[i] == "G":
        g.append(i)
    if s[i] == "B":
        b.append(i)

l = list(itertools.product(r,g,b))

ans = len(l)
for i in range(len(l)):
    ll = sorted(l[i])
    if ll[1] - ll[0] == ll[2] - ll[1]:
        ans -= 1

print(ans)

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
s = input()

r = []
g = []
b = []
for i in range(n):
    if s[i] == "R":
        r.append(i)
    if s[i] == "G":
        g.append(i)
    if s[i] == "B":
        b.append(i)

ans = len(r)*len(g)*len(b)

for i in range(1,n):
    for j in range(n):
        k = j + 2 * i
        if k < n and s[j] != s[j + i] and s[j] != s[j + 2 * i] and s[j + i] != s[j + 2 * i]:
            ans -= 1

print(ans)
### BUGGY CODE ###

s = list(input())

minLength = 4
maxLength = len(s)

cnt = 0

for length in range(minLength,maxLength+1):
    for position in range(maxLength - length + 1):
        num = int(''.join(s[position:position+length]))
        if num % 3 == 0:
            if num % 673 == 0:
                cnt += 1

print(cnt)

### FIXED CODE ###

s = list(input())
mods = [0]*(len(s))
countRemainder = [0] * 2019
cnt = 0


m = 1
mod = 0
for i in range(len(s)):
    mod += int(s[len(s) - i - 1]) * m

    mod %= 2019
    m *= 10
    m %= 2019

    countRemainder[mod] += 1

countRemainder[0] += 1

for i in range(2019):
    cnt += int(countRemainder[i] * (countRemainder[i] - 1) / 2)

print(cnt)
### BUGGY CODE ###

import math
A, B, N = list(map(int, input().split(" ")))

def tgt(A,B,d):
    return math.floor(A * d / B) - A * math.floor(d/B)

if N >= B-1:
    d_max = B-1
else: # N< B-1
    d_max = N

ret = 0
for d in range (d_max+1):
    tmp = tgt(A,B,d)
    if ret <= tmp:
        ret = tmp

print(ret)





### FIXED CODE ###

import math
A, B, N = list(map(int, input().split(" ")))

def tgt(A,B,d):
    return math.floor(A * d / B)

if N >= B-1:
    d_max = B-1
else: # N< B-1
    d_max = N

ret = tgt(A,B,d_max)

print(ret)
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    for j in range(i + A[i],  N):
       if j - i == A[i] + A[j]:
           ans += 1

print(ans)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
dp = [0] * 10 ** 7
ans = 0
for i in range(N):
    x = i + 1 - A[i]
    if x >= 0:
        ans += dp[x]
    y = i + 1 + A[i]
    if y < 10 ** 7:
        dp[y] += 1

print(ans)
### BUGGY CODE ###

A, B, K = (int(x) for x in input().split())
for i in range(K):
  if A >= 1:
    A -= 1
  elif B >= 1:
    B -= 1
print(A,B)

### FIXED CODE ###

A, B, K = (int(x) for x in input().split())
if K >= A+B:
  A = 0
  B = 0
elif K >= A:
  B = B + A - K
  A = 0
elif K < A:
  A = A - K
print(A,B)
### BUGGY CODE ###

#!/usr/bin/python3
import sys
import queue

# main
q = queue.PriorityQueue()
m = 2 * (10 ** 9)
S = sys.stdin.readlines()
for line in S:
    s = line.split()
    if s[0].startswith('i'):
        q.put(m - int(s[1]))
    elif s[0].startswith('ex'):
        print(m - q.get())
    if s[0] == 'end':
        exit()

### FIXED CODE ###

#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()
### BUGGY CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(sorted(input()))

#ans = []
#for i in range(n):
    #ans.append(sorted(s[i]))

x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x = x + 1

print(x)

### FIXED CODE ###

from collections import Counter

n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(input())))
    
v = list(Counter(s).values())
ans = []
for i in range(len(v)):
    if v[i] >= 2:
        ans.append((v[i] * (v[i]-1))/2)

print(int(sum(ans)))
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
L = list(set(l))
count = 0
for x in L:
  if l.count(x) == x:
    continue
  elif l.count(x) > x:
    count += l.count(x) - x
  else:
    count += l.count(x)
print(count)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
dic = {}
count = 0

for i in range(n):
  dic.setdefault(l[i],0)
  dic[l[i]] += 1

for x,y in dic.items():
  if x <= y:
    count += y - x
  else:
    count += y
print(count)
### BUGGY CODE ###

import sys
n,k=map(int,input().split())
w=list(map(int,sys.stdin.readlines()))
def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
l,r=max(w),sum(w)
while l<r:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m
print(r)


### FIXED CODE ###

import sys
def s():
 n,k=map(int,input().split())
 w=list(map(int,sys.stdin.readlines()))
 def f():
  c=t=0
  for j in w:
   t+=j
   if t>m:
    t=j
    c+=1
    if c>=k:return 0
  return 1
 l,r=max(w),sum(w)
 while l<r:
  m=(l+r)//2
  if f():r=m
  else:l=m+1
 print(r)
if'__main__'==__name__:s()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



N, M =two_int()

max_index=2**N
INF=10**15

dp=[INF for i in range(max_index)]
dp[0]=0

key_list=[]
treasures=[]

for i in range(M):
    mon,_ =two_int()
    key_list.append(mon)
    
    
    temp= many_int()
    temp = map(lambda x: 1<<(x-1), temp)
    sums = sum(temp)
    treasures.append(sums)
    
    for k in range(max_index):
        new_i = int(bin(treasures[i] | k),2)
        cost = dp[k] + key_list[i]
        dp[new_i] = min(dp[new_i], cost) 

goal_index=max_index-1
if dp[goal_index]!=INF:
    print(dp[goal_index])
else:
    print(-1)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))


def main():
    N, M =two_int()

    key_list=[]
    treasures=[]
    check={}

    for i in range(M):
        mon,_ =two_int()
        temp = map(lambda x: 1<<(x-1), many_int())
        sums = sum(temp)
        
        if sums in check:
            if check[sums] > mon:
                check[sums]=mon
        else:
            check[sums]=mon
            
    for k,v in check.items():
        key_list.append(v)
        treasures.append(k)

    max_index=2**N
    INF=10**15

    dp=[INF for i in range(max_index)]
    dp[0]=0
    M=len(key_list)

    for i in range(max_index-1):
        for j in range(M):
            new_i = int(bin(treasures[j] | i),2)
            cost = dp[i] + key_list[j]
            dp[new_i] = min(dp[new_i], cost) 
        
    goal_index=max_index-1
    if dp[goal_index]!=INF:
        print(dp[goal_index])
    else:
        print(-1)

main()
### BUGGY CODE ###

#C問題 together

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

a.sort()

minval = a[0]
maxval = a[-1]
l = (maxval - minval +1)

num = [0]*l
num_ans = []


num[0] = a.count(minval)

for i in a:
	if num[i-minval] == 0:
		num[i-minval] = a.count(i)

if l == 1:
	print(num[0])
	exit(0)

num_ans.append(num[0]+num[1]) 

if l == 2:
	print(num_ans[0])
	exit(0)

for i in range(1,l-1):
	num_ans.append(num[i-1]+num[i]+num[i+1])
num_ans.append(num[-2]+num[-1])

print(max(num_ans))

### FIXED CODE ###

#C問題 together
 
N = int(input())
a = list(map(int,input().split(" ")))
 

 
minval = min(a)
maxval = max(a)
l = (maxval - minval +1)
 
num = [0]*(l+2)

for i in a:
	num[i-minval] += 1

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

print(ans)
### BUGGY CODE ###

import math
def equation(a, b, c):
    D = (b**2 - 4*a*c) ** (1/2)
    x_1 = (-b + D) / (2 * a)
    x_2 = (-b - D) / (2 * a)

    return x_1, x_2



def main():
    N = int(input())

    for n in range(1, N+1):
        cnt = 0
        for y in range(1, int(math.sqrt(n))):
            for z in range(1, int(math.sqrt(n))):
                x_1, x_2 = equation(1, y+z, y**2 + y*z + z**2 - n)

                if isinstance(x_1, float):
                    x_1 = round(x_1, 5)
                    if x_1.is_integer() == True and x_1 >= 1:
                        cnt += 1

                if isinstance(x_2, float):
                    x_2 = round(x_2, 5)
                    if x_2.is_integer() == True and x_2 >= 1:
                        cnt += 1

        print(cnt)




if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline


import math

# def equation(a, b, c):
#     D = (b**2 - 4*a*c) ** (1/2)
#     x_1 = (-b + D) / (2 * a)
#     x_2 = (-b - D) / (2 * a)

#     return x_1, x_2



def main():
    n = int(input())

    ans = [0]*(n+1)

    for x in range(1, int(math.sqrt(n))):
        for y in range(1, int(math.sqrt(n))):
            for z in range(1, int(math.sqrt(n))):

                e = x**2 + y**2 + z**2 + x*y + y*z + z*x
                if e >= 1 and e <= n:
                    ans[int(e)] += 1

    for i in range(len(ans)-1):
        print(ans[i+1])




                # x_1, x_2 = equation(1, y+z, y**2 + y*z + z**2 - n)

                # if isinstance(x_1, float):
                #     x_1 = round(x_1, 5)
                #     if x_1.is_integer() == True and x_1 >= 1:
                #         cnt += 1

                # if isinstance(x_2, float):
                #     x_2 = round(x_2, 5)
                #     if x_2.is_integer() == True and x_2 >= 1:
                #         cnt += 1

        # print(cnt)




if __name__ == '__main__':
    main()
### BUGGY CODE ###

s = input()
q = int(input())
count = 0
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            ans = (c + ans) if f == "1" else (ans + c)
        else:
            ans = (ans + c) if f == "1" else (c + ans)
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)

### FIXED CODE ###

s = input()
q = int(input())
count = 0
top = ""
end = ""
ans = s
for i in range(q):
    tmp = input()
    if tmp[0] == "1":
        count += 1
    else:
        _, f, c = map(str, tmp.split())
        if count % 2 == 0:
            if f == "1":
                top = c + top
            else:
                end = end + c
        else:
            if f == "1":
                end = end + c
            else:
                top = c + top

ans = top + ans + end
ans = ans[::-1] if count % 2 == 1 else ans
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
h_list = list(map(int, input().split()))
road_list = [[''] * n for i in range(n)]
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    road_list[a - 1][b - 1] = 'x'
    road_list[b - 1][a - 1] = 'x'

for i in range(n):
    if 'x' not in road_list[i]:
        ans += 1
        continue
    numx = 0
    numh = 0
    for j in range(n):
        if road_list[i][j] == 'x':
            numx += 1
            if h_list[i] > h_list[j]:
                numh += 1
        if j == n - 1 and numx == numh:
            ans += 1

print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
h_list = list(map(int, input().split()))
n_list = [''] * n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    if h_list[b - 1] >= h_list[a - 1]:
        n_list[a - 1] = 'x'
    if h_list[a - 1] >= h_list[b - 1]:
        n_list[b - 1] = 'x'

for i in range(n):
    if n_list[i] == '':
        ans += 1

print(ans)
### BUGGY CODE ###

from collections import defaultdict
n, m = list(map(int, input().split()))
graph = defaultdict(set)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].add(v+n)
  graph[u+n].add(v+2*n)
  graph[u+2*n].add(v)
s, t = list(map(int, input().split()))
dist = [-1 for i in range(3*n+10)]

def bfs():
  que = [(s, 0)]
  while len(que) > 0:
    cur, cost = que.pop(0)
    if dist[cur] != -1:
      continue
    dist[cur] = cost
    for to in graph[cur]:
      que.append((to, cost+1))

bfs()
print(dist[t]//3)

### FIXED CODE ###

from collections import defaultdict, deque
n, m = list(map(int, input().split()))
graph = defaultdict(list)
for i in range(m):
  u, v = list(map(int, input().split()))
  graph[u].append(v+n)
  graph[u+n].append(v+2*n)
  graph[u+2*n].append(v)
s, t = list(map(int, input().split()))
dist = [-1 for i in range(3*n+10)]

def bfs():
  que = deque([s])
  dist[s] = 0
  while len(que) > 0:
    cur = que.popleft()
    for to in graph[cur]:
      if dist[to] == -1:
        dist[to] = dist[cur]+1
        que.append(to)

bfs()
print(dist[t]//3)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
total = sum(A)
costs = [0 for x in range(N-1)]

mem = [0 for x in range(N-1)]
def calcsum(i):
  if mem[i] == 0:
    mem[i] == calcsum(i - 1) + A[i-1]
  return mem[i]

for i in range(1, N):
  costs[i-1] = abs(total - 2 * sum(A[:i]))
  
print(min(costs))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
total = sum(A)
costs = [0 for x in range(N-1)]
mem = [0 for x in range(N-1)]

for i in range(1, N):
  if i == 1:
    mem[i-1] = A[i-1] * 2
  else:
    mem[i-1] = mem[i-2] + A[i-1] * 2
  costs[i-1] = abs(total - mem[i-1])
  
print(min(costs))
### BUGGY CODE ###

# input
X,Y,Z,K = map(int, input().split())
a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]
c_list = [int(i) for i in input().split()]

# list top K of a+b
a_plus_b_list = []
for a in a_list:
    for b in b_list:
        a_plus_b_list.append(a+b)
a_plus_b_list.sort(reverse = True)

# list top K of a+b+c
d_list = []
for a_b in a_plus_b_list:
    for c in c_list:
        d_list.append(a_b + c)
d_list.sort(reverse = True)
for i in range(K):
    print(d_list[i])

### FIXED CODE ###

import heapq
import sys
x, y, z, k = map(int, input().split())

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
### BUGGY CODE ###

#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
sum = 0
for i in range(5*10**8):
    sum += i
N = int(input())
if N >=5*10*8:
    for i in range((5*10**8),N):
        sum += i
else:
    for i in range(0,N,-1):
        sum -= i

print(sum)


### FIXED CODE ###

#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
N = int(input())
print(N*(N-1)//2)