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

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

if M == 0:
  print(0,0)
  exit();

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w) 

ac = wa = 0  
for k,v in x.items():
  for j in x[k]:
    if 'AC' not in v:
      break
    elif j == 'AC':
      ac += 1
      break
    elif j =='WA':
      wa += 1
  
print(ac,wa)

### FIXED CODE ###

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

if M == 0:
  print(0,0)
  exit();

x = {}  
for _ in range(M):
  a,w = map(str,input().split())
  x.setdefault(int(a),[]).append(w)
  
ac = at = wa = wt = 0  
for k,v in x.items():
  for j in v:
    if j == 'AC':
      at += 1
      break
    elif j =='WA':
      wt += 1
  if at == 0:
    wt = 0
  else:
    ac += at
    wa += wt
    at = 0
    wt = 0
      
print(ac,wa)
### BUGGY CODE ###

N = int(input())
H = list(map(lambda x:int(x), input().split()))

idx = sorted(range(N-1), key=lambda k: H[k], reverse=True)

ans = 0
for i in idx:
  count = 0
  if (i != 0) and (H[i-1] > H[i]): continue
#  if i == N-1: continue

  for j in range(i, N-1):
    if H[j] < H[j+1]: break
    count += 1
  ans = max(ans, count)

print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(lambda x:int(x), input().split()))
count = 0
ans = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    count = 0
  ans = max(ans, count)

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

N = int(input().strip())

A = {}
for a in [int(x) for x in input().strip().split(" ")]:
    A.setdefault(a, 0)
    A[a] += 1

Q = int(input().strip())

for q in range(Q):
    B, C = [int(x) for x in input().strip().split(" ")]
    if B in A:
        A.setdefault(C, 0)
        A[C] += A[B]
        del A[B]
    print(sum([k * v for k, v in A.items()]))


### FIXED CODE ###

N = int(input().strip())

A = {}
for a in [int(x) for x in input().strip().split(" ")]:
    A.setdefault(a, 0)
    A[a] += 1
total = sum([k * v for k, v in A.items()]) 

Q = int(input().strip())

for q in range(Q):
    B, C = [int(x) for x in input().strip().split(" ")]
    if B in A:
        A.setdefault(C, 0)
        dif = (C - B) * A[B]
        A[C] += A[B]
        del A[B]
        total += dif
    print(total)
### BUGGY CODE ###

H,W = map(int,input().split())
s = [[] for i in range(H)]
for i in range(H): s[i] = list(input())
l = [[0]*W for i in range(H)]
r = [[0]*W for i in range(H)]
d = [[0]*W for i in range(H)]
u = [[0]*W for i in range(H)]

for h in range(H):
    for w in range(W):
        if s[h][w] == ".":
            l[h][w], d[h][w] = 1,1
            if w != 0: l[h][w] = l[h][w-1] + 1
            if h != 0: d[h][w] = d[h-1][w] + 1
    for w in range(W):
        if s[H-1-h][W-1-w] == ".":
            r[H-1-h][W-1-w] = 1
            if w != 0: r[H-1-h][W-1-w] = r[H-1-h][W-w] + 1

for h in range(H):
    for w in range(W):
        if s[H-1-h][W-1-w] == ".":
            u[H-1-h][W-1-w] = 1
            if h != 0: u[H-1-h][W-1-w] = u[H-h][W-1-w] + 1
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, l[h][w]+r[h][w]+u[h][w]+d[h][w]-3)

print(ans)
        

### FIXED CODE ###

H,W = map(int,input().split())
s = [[] for i in range(H)]
for i in range(H): s[i] = list(input())
l = [[0]*W for i in range(H)]
r = [[0]*W for i in range(H)]
d = [[0]*W for i in range(H)]
u = [[0]*W for i in range(H)]

for h in range(H):
    if s[h][0] == ".": l[h][0] = 1
    for w in range(1,W):
        if s[h][w] == ".": l[h][w] = l[h][w-1] + 1
    if s[h][W-1] == ".": r[h][W-1] = 1
    for w in range(1,W):
        if s[h][W-1-w] == ".": r[h][W-1-w] = r[h][W-w] + 1

for w in range(W):
    if s[0][w] == ".": d[0][w] = 1
    for h in range(1,H):
        if s[h][w] == ".": d[h][w] = d[h-1][w] + 1
    if s[H-1][w] == ".": u[H-1][w] = 1
    for h in range(1,H):
        if s[H-1-h][w] == ".": u[H-1-h][w] = u[H-h][w] + 1
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, l[h][w]+r[h][w]+u[h][w]+d[h][w]-3)

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

N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    #tmp = {}
    # tmp = {i for i in range(a-1,b-1)}
    # print(tmp)
    # print(len(tmp&p))
    count=0
    for j in p:
        #print("j",j)
        if a <= j+1 and j+1 < b:
            count+=1
    print(count)

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
p = [0]*(N)
a = 0
for i in range(-1,N-2):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])
### BUGGY CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(N):
	lst.append(V[i] - C[i])
  
high_score = 0
  
for i in range(2 ** N):
	a = list(str(bin(i))[2:])
	for k in range(N - len(a)):
		a.insert(0, "0")
	b = list(map(int, a))
	score = 0
	for j in range(len(b)):
		score += lst[j] * b[j]
	if high_score < score:
		high_score = score
    
print(high_score)

### FIXED CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(N):
	if V[i] > C[i]:
		lst.append(V[i] - C[i])

print(sum(lst))
### BUGGY CODE ###

import sys

s = input()
q = int(input())
is_reverse = False
for _ in range(q):
  tf = sys.stdin.readline().split()
  if tf[0] == '1':
    is_reverse = False if is_reverse else True
  else:
    if tf[1] == '1':
      if is_reverse:
        s += tf[2]
      else:
        s = tf[2] + s
    else:
      if is_reverse:
        s = tf[2] + s
      else:
        s += tf[2]
if is_reverse:
  print(s[::-1])
else:
  print(s)

### FIXED CODE ###

import sys
from collections import deque

s = input()
q = int(input())
is_reverse = False
ds = deque(s)

for _ in range(q):
  tf = sys.stdin.readline().split()
  if len(tf) == 1:
    is_reverse = False if is_reverse else True
  else:
    if tf[1] == '1':
      if is_reverse:
        ds.append(tf[2])
      else:
        ds.appendleft(tf[2])
    else:
      if is_reverse:
        ds.appendleft(tf[2])
      else:
        ds.append(tf[2])
if is_reverse:
  ds.reverse()
ans = ''.join(list(ds))
print(ans)
### BUGGY CODE ###

n=int(input())
nums=input().split()
nums_uniq=[]

for n in nums:
    if n not in nums_uniq:
        nums_uniq.append(n)

k=0
for p in nums_uniq:
    if nums.count(p)==int(p):
        continue
    elif nums.count(p)>int(p):
        while nums.count(p)>int(p):
            nums.remove(p)
            k+=1
    else:
        while nums.count(p)>0:
            nums.remove(p)
            k+=1
print(k)

### FIXED CODE ###

from collections import Counter
n=int(input())
counter=Counter(map(int,input().split()))
print(sum(c-num if c>=num else c for num,c in counter.items()))
### BUGGY CODE ###

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

ans = 10**10
for i in range(1, N):
    a = sum(A[0:i])
    b = sum(A[i:N+1])
    ans = min(ans, abs(a - b))

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
arai = sum(A)
sunuke = 0

ans = 10**10
for i in range(0, N-1):
    sunuke += A[i]
    arai -= A[i]
    ans = min(ans, abs(sunuke - arai))

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

from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n = int(input())
    l = list(map(int, input().split()))

    # eprint("=======================")
    while True:
        xx = min([x for x in l if x > 0])
        l = [(tt if tt==xx else tt%xx) for tt in l]

        # eprint(l)
        if all(x==l[0] for x in l):
            print(l[0])
            return
        if 1 in l:
            print(1)
            return 0
        if sum(l)==xx:
            print(xx)
            return 0
        # eprint("=======================")

    print(xx)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    n = int(input())
    l = list(map(int, input().split()))

    eprint("=======================")
    while True:
        xx = min([x for x in l if x > 0])
        # eprint("min_index: "+str(min_index))
        eprint("xx: "+str(xx))
        flag = 0
        for i in range(len(l)):
            if l[i] == xx and flag == 0:
                flag=1
            else:
                l[i] = l[i]%xx

        # eprint(l)
        if all(x==l[0] for x in l):
            # eprint(l)
            print(l[0])
            return 0
        if 1 in l:
            print(1)
            return 0
        if sum(l)==xx:
            print(xx)
            return 0
        eprint("=======================")

    print(xx)
    return 0


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

s=input()
cnt=0
while "BW" in s:
    s=s.replace("BW","WB",1)
    cnt+=1
    if s[0]=="W":s=s[1:]
    if s[-1]=="B":s=s[:-1]
print(cnt)

### FIXED CODE ###

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


def main():
    n,k = map(int,input().split())
    dests =[0 for _ in range(n)]
    telepos = list(map(int,input().split()))
    for i,t in enumerate(telepos):
        dests[i] = t-1
    print(dfs(dests,k))




def dfs(dests,k,here = 0):
    here = 0
    telepo_times = 0
    cycle_start = -1
    cycle_end = -1
    cycle_length = -1
    visited = []


    #循環検出！同じ町にいつ戻ってくるのか
    while telepo_times < k:
        #print("現在地は",here)
        if here in visited:
            cycle_start = visited.index(here)
            #print(cycle_start,"でループが始まった")
            cycle_end = telepo_times - 1
            #print(cycle_end,"でループが終わった")
            cycle_length = cycle_end - cycle_start + 1
            #print("サイクルの長さは",cycle_length,"だ")
            break

        visited.append(here)
        telepo_times += 1
        here = dests[here]
    if cycle_length == -1:
        return here + 1

    cycle_index = (k-cycle_start) % cycle_length
    return visited[cycle_start + cycle_index] + 1




    #telepo_times = 0
    #while telepo_times < (k - cycle_start)%cycle_length:
    #    telepo_times += 1
    #    here = dests[here]







if __name__ == '__main__':
    main()


### FIXED CODE ###


def main():
    n,k = map(int,input().split())
    dests =[0 for _ in range(n)]
    telepos = list(map(int,input().split()))
    for i,t in enumerate(telepos):
        dests[i] = t-1
    print(solve(dests,k))




def solve(dests,k,here = 0):
    here = 0
    telepo_times = 0
    cycle_start = -1
    cycle_end = -1
    cycle_length = -1
    visited = dict()
    visited2 = []


    #循環検出！同じ町にいつ戻ってくるのか
    while telepo_times < k:
        #print("現在地は",here)
        if here in visited:
            cycle_start = visited[here]
            #print(cycle_start,"でループが始まった")
            cycle_end = telepo_times - 1
            #print(cycle_end,"でループが終わった")
            cycle_length = cycle_end - cycle_start + 1
            #print("サイクルの長さは",cycle_length,"だ")
            break
        #ids[here] = telepo_times

        visited[here] = telepo_times
        visited2.append(here)
        telepo_times += 1
        here = dests[here]
    if cycle_length == -1:
        return here + 1

    cycle_index = (k-cycle_start) % cycle_length
    return visited2[cycle_start + cycle_index] + 1




    #telepo_times = 0
    #while telepo_times < (k - cycle_start)%cycle_length:
    #    telepo_times += 1
    #    here = dests[here]







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

from itertools import product

def sol():
    N = int(input())
    XYP = [tuple(map(int, input().split())) for _ in range(N)]
    X = [x for x, _, _ in XYP]
    Y = [y for _, y, _ in XYP]
    INF = 10**18

    def calcCost(AP, A):
        ret = [[INF] * N for _ in range(1 << N)]
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i, (a, p) in enumerate(AP):
                cost = abs(a)
                for z in useA:
                    cost = min(cost, abs(a - z))
                ret[state][i] = cost * p
        return ret

    costX = calcCost([(x, p) for x, _, p in XYP], X)
    costY = calcCost([(y, p) for _, y, p in XYP], Y)

    def makeState(state, sign):
        ret = 0
        for s in state:
            ret <<= 1
            if s == sign:
                ret |= 1
        return ret

    ans = [INF] * (N + 1)
    for state in product((0, 1, 2), repeat=N):
        stateX = 0
        stateY = 0
        M = N
        for s in state:
            stateX <<= 1
            stateY <<= 1
            if s == 0: M -= 1
            if s == 1: stateX |= 1
            if s == 2: stateY |= 1

        cx = costX[stateX]
        cy = costY[stateY]

        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])

        if ans[M] > cost:
            ans[M] = cost

    print(*ans, sep='\n')

sol()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()
### BUGGY CODE ###

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

x = []*n
y = []*2

for i in range(n):
  y.append(h[i][0]-h[i][1]) #腕が届く地点の最小値
  y.append(h[i][0]+h[i][1]) #腕が届く地点の最大値
  x.append(y) #xに保存
  y = []*2 #yを初期化

x.sort(key = lambda x:x[1]) #腕が届く地点の最大値が小さい順にソート

k = 0 #配列xのtale
con = -10 ** 10

for i in range(n):
  if con > x[k][0]:
    x.pop(k)
  else:
    con = x[k][1]
    k += 1	#taleを一個後ろに下げる

print(len(x)) #要素数(残ったロボットの数)を出力

### FIXED CODE ###

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

x = []*n
y = []*2

for i in range(n):
  y.append(h[i][0]-h[i][1]) #腕が届く地点の最小値
  y.append(h[i][0]+h[i][1]) #腕が届く地点の最大値
  x.append(y) #xに保存
  y = []*2 #yを初期化

x.sort(key = lambda x:x[1]) #腕が届く地点の最大値が小さい順にソート

k = 0	#配列xのtale

for i in range(n-1):
  if x[k][1] > x[k+1][0]: #k番目の最大値よりもk+1の最小値の方が小さい時(つまり腕が重なる時)
    x.pop(k+1) #k+1番目を取り出す

  else:
    k += 1 #taleを一個後ろに下げる

print(len(x)) #要素数(残ったロボットの数)を出力
### BUGGY CODE ###

N=int(input())
cnt = 0
for i in range(357, N+1):
    c = 0
    T = str(i)
    if T.find('3') == -1:
        continue
    else:
        c += T.count('3')
    if T.find('5') == -1:
        continue
    else:
        c += T.count('5')
    if T.find('7') == -1:
        continue
    else:
        c += T.count('7')
    if c == len(T):
        cnt += 1
print(cnt)


### FIXED CODE ###

N=int(input())

L=[3,5,7]
f = 0
cnt = 0
while f == 0:
  for i in range(3):
    x = L[cnt] * 10 + L[i]
    if x > N:
      f = 1
      break
    else:
      L.append(L[cnt] * 10 + L[i])
  cnt += 1

ans = set(["3","5","7"])
cnt = 0
for i in L:
    s = set(str(i))
    if s == ans:
        cnt += 1
print(cnt)
### BUGGY CODE ###

import collections
S=input()
l=len(S)
T=0
A=[0]*2019
A[0]=1
for i in range(l):
    T+=int(S[l-i-1])*(10**i)
    A[T%2019]+=1
B=map(lambda x: x*(x-1)//2,A)
print(sum(B))
















### FIXED CODE ###

s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d %= 2019
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
### BUGGY CODE ###

A,B,N = map(int,input().split())
ans = []
for x in range(N+1):
    tmp = (A * x // B) - A * (x//B)
    ans.append(tmp)
print(max(ans))

### FIXED CODE ###

A,B,N = map(int,input().split())
if N >= (B-1):
        x = B -1
else:
        x = N
print((A * x // B) - A * (x//B))
### BUGGY CODE ###



tmp = input().split(" ")
n = tmp[0]
q = int(tmp[1])

s = input()

ac_indexes=[]
start=0
while True:
    ind = s.find("AC", start)
    if ind != -1:
        start=ind+2
        ac_indexes.append(ind)
    else:
        break

memo = {}

for i in range(q):

    if len(ac_indexes) == 0:
        print ("0")
        continue

    tmp = input().split(" ")
    a = int(tmp[0]) - 1
    b = int(tmp[1]) - 2

    memo_ = memo.get(str(a) + "," + str(b))
    if memo_ != None:
        print (str(memo))


    left = 0
    right = len(ac_indexes)-1
    left_kari=-1
    left_kakutei = -1
    while left <= right:
        center = (left+right)//2
        if ac_indexes[center] > a:
            right = center-1
            left_kari = center
        elif ac_indexes[center] < a:
            left = center+1
        else:
            left_kakutei = center
            break
    if left_kakutei == -1:
        left_kakutei = left_kari
    
    left = 0
    right = len(ac_indexes)-1
    right_kari = -1
    right_kakutei = -1
    while left <= right:
        center = (left+right)//2
        #print (left, center, right)
        if ac_indexes[center] > b:
            right = center-1
        elif ac_indexes[center] < b:
            left = center+1
            right_kari = center
        else:
            right_kakutei = center
            break
    if (right_kakutei == -1):
        right_kakutei = right_kari

    if (left_kakutei > right_kakutei or left_kakutei==-1 or right_kakutei==-1):
        print ("0")
        continue

    print(str(right_kakutei - left_kakutei + 1))
    memo.update({str(a) + "," + str(b): (right_kakutei - left_kakutei + 1)})


### FIXED CODE ###

import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,q = get_nums_l()
s = input()

ruiseki_ac = [0] * (n+1)

for i in range(n-1):
    x = 0
    if s[i] == "A" and s[i+1] == "C":
        x = 1
    ruiseki_ac[i+1] = ruiseki_ac[i] + x
ruiseki_ac[n] = ruiseki_ac[n-1]

log(ruiseki_ac)

for i in range(q):

    a,b = get_nums_l()
    print(ruiseki_ac[b-1] - ruiseki_ac[a-1])
### BUGGY CODE ###

def resolve():
    from collections import deque
    k = int(input())
    a = list(map(int, input().split()))

    ra = a[::-1]
    now = deque([2])
    for i in range(k):
        nxt = deque([])
        while now:
            test = now.popleft()
            if test % ra[i] == 0:
                k = 0
                while k < ra[i]:
                    nxt.append(test+k)
                    k += 1
        if not nxt:
            print(-1)
            exit()
        now = nxt
    nxt = sorted(list(nxt))
    print("{} {}".format(nxt[0], nxt[-1]))
resolve()

### FIXED CODE ###

def resolve():
    # from collections import deque
    k = int(input())
    a = list(map(int, input().split()))
    rl = [2, 2]
    ra = a[::-1]

    for i in range(k):
        nxt = []
        nowa = ra[i]
        if (rl[-1] // nowa) - ((rl[0]-1)//nowa) > 0:
            nxt.append((((rl[0]-1)//nowa)+1)*nowa)
            nxt.append((rl[-1]//nowa)*nowa + nowa-1)
        if not nxt:
            print(-1)
            exit()
        rl = nxt

    print("{} {}".format(rl[0], rl[-1]))
resolve()
### BUGGY CODE ###

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

tmpsort = [[0]for i in range(n)]
p_list = []
y_list = []

for i in range(m):
    p,y = map(int,input().split())
    tmpsort[p-1].append(y)
    p_list.append(p)
    y_list.append(y)

for i in range(n):
    tmpsort[i].sort()
for i in range(len(p_list)):
    idx = tmpsort[p_list[i]-1].index(y_list[i])
    print((str(p_list[i]).zfill(6) + str(idx).zfill(6)))

### FIXED CODE ###

N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i)
### BUGGY CODE ###

k, s = map(int, input().split(' '))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k == s:
                ans += 1
print(ans)

### FIXED CODE ###

k, s = map(int, input().split(' '))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-i-j <= k:
            ans += 1
print(ans)
### BUGGY CODE ###

#coding: utf-8
N = int(input())
L = list(map(int, input().split()))

cnt = 0
tri_cnt = 0
mem = 0

#全てが奇数になるまで実行し続ける
while(tri_cnt != len(L)):
    if(L[mem]%2 != 0):
        mem += 1
    else:
        L[mem] //= 2
        for i in range(len(L)):
            if(i != mem):
                L[i] *= 3
        cnt += 1

    tri_cnt = 0
    for i in range(len(L)):
        if (L[i] % 2 != 0):
            tri_cnt += 1
    # print(L)
    # print(tri_cnt)
else:
    print(cnt)

### FIXED CODE ###

#coding: utf-8
N = int(input())
L = list(map(int, input().split()))

cnt = 0
tri_cnt = 0
mem = 0

#全てが奇数になるまで実行し続ける
while(mem != len(L)):
    if(L[mem]%2 != 0):
        mem += 1
    else:
        L[mem] //= 2
        # for i in range(len(L)):
        #     if(i != mem):
        #         L[i] = L[i] * 3
        #         print('',end='')
        cnt += 1

    # tri_cnt = 0
    # for i in range(len(L)):
    #     if (L[i] % 2 != 0):
    #         tri_cnt += 1
else:
    print(cnt)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
#print(a)

a.sort()
w=10**9
for j in range(a[0],a[n-1]+1):
    s=0

    for k in range(n):
        s+=abs(a[k]-j)
    if s<w :
        w=s
print(w)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
#print(a)

a.sort()

#bはaの最小から最大まで
x=0
z=n-1
y=(x+z)//2
while z!=x:
    s1=0
    s2=0
    for k in range(n):
        s1+=abs(a[k]-a[y])
    for k in range(n):
        s2+=abs(a[k]-a[y+1])
    if s1<s2 :
        z=y
        y=(x+z)//2
    elif s1==s2:
        x=y
        z=y
    else:
        x=y+1
        y=(x+z)//2
#x=y=zとなっている
s=0
for k in range(n):
    s+=abs(a[k]-a[y])

print(s)