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

a=input()
b=input()

N=int(a)
An = [int(b0) for b0 in b.split(' ')]

for i in range(1,N+1):
    for j in range(N):
        if i == An[j]:
            print(j+1, end=' ')
    

### FIXED CODE ###

a=input()
b=input()


N=int(a)
An = [int(b0) for b0 in b.split(' ')]

Cn=[0]*len(An)
for i in range(len(An)):
    Cn[An[i]-1] = i+1

for i in Cn:
    print(i, end=' ')
### BUGGY CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    more_h = [x for x in H_dict if x[1] >= tmp_h]
    cnt2 = 0
    if len(more_h) == 0:
        cnt += 1
    else:
        for y in more_h:
            left = [y[0], h+1]
            right = [h+1, y[0]]
            if left in AB or right in AB:
                cnt2 += 1
        if cnt2 == 0:
            cnt += 1
print(cnt)


### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
min_val = sorted(A)[0]
for _ in range(M):
  B, C = map(int, input().split())
  if min_val <= C:
  	A.extend([C]*B)
  
A = sorted(A, reverse=True)
print(sum(A[:N]))

### FIXED CODE ###

N, M = map(int, input().split())
A = [int(i) for i in input().split()]
BC = []
for _ in range(M):
    B, C = map(int, input().split())
    BC.append([B, C])
BC = sorted(BC, key=lambda x: x[1], reverse=True)
# print("A: {}".format(A))
# print("BC: {}".format(BC))

A_dash = []
for ij in BC:
    i, j = ij
    A_dash.extend([j]*i)
    if len(A_dash) >= N:
        break
A_dash = A_dash[:N]

A_dash.extend(A)
A_dash = sorted(A_dash, reverse=True)[:N]

print(sum(A_dash))
### BUGGY CODE ###

#ABC124_C
S=input()
 
S_rev=list(S)[::-1]
 
s=0
st0=0
st1=0
 
def bit_count(x):
    x=bin(x)[2:]
    ans=0
    for i in range(len(x)):
        if int(x[i])==1:
            ans+=1
    return ans
            
 
for i in range(len(S)):
    if i%2==0:
        st0+=2**i
    else:
        st1+=2**i
    if int(S_rev[i])==1:
        s+=2**i
 
cand0=st0^s
cand1=st1^s
 
    
bc0=bit_count(cand0)
bc1=bit_count(cand1)
if bc0>bc1:
    print(bc1)
else:
    print(bc0)
    

### FIXED CODE ###

#124_C

S=input()

a=''
b=''

lenS=len(S)

for i in range(lenS):
    if i%2==0:
        a+='1'
        b+='0'
    else:
        a+='0'
        b+='1'
        
ca=0
cb=0
for i in range(lenS):
    if a[i]!=S[i]:
        ca+=1
    if b[i]!=S[i]:
        cb+=1
print(min(ca,cb))
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

def f(a, b):
    sho, amari = int(a/b), a%b
    return sho, amari

R_s, R_a = f(N, R)

cnt = 0

for i in range(R_s + 1):
    x = R_a + i * R # R を i 個使う
    G_s, G_a = f(x, G)
    for j in range(G_s + 1):
        y = G_a + j * G # G を j 個使う
        B_s, B_a = f(y, B)
        if B_a == 0:
            cnt += 1

print(cnt)





### FIXED CODE ###

R, G, B, N = map(int, input().split())

def f(a, b):
    sho, amari = int(a/b), a%b
    return sho, amari


def ans(l, m, s):
    cnt = 0

    R_s, R_a = f(N, l)

    for i in range(R_s + 1):
        x = R_a + i * l # R を i 個使う
        G_s, G_a = f(x, m)
        for j in range(G_s + 1):
            y = G_a + j * m # G を j 個使う
            if y % s == 0:
                cnt += 1
    return cnt

li = [R, G, B]
li.sort(reverse=True)

cnt = ans(li[0], li[1], li[2])

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

n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    ss = s[l - 1:r]
    ss_rep = ss.replace('AC', '')
    print((len(ss) - len(ss_rep)) // 2)


### FIXED CODE ###

import bisect
n, q = map(int, input().split())
s = input()
cnt = 0
apoint = []
cpoint = []
for i in range(len(s) - 1):
    if s[i] + s[i + 1] == 'AC':
        cnt += 1
        apoint.append(i)
        cpoint.append(i)
# print('cnt:', cnt)
# print('acpoint:', apoint)
for i in range(q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    left = bisect.bisect_left(apoint, l)
    right = bisect.bisect_left(cpoint, r)
    print(right - left)
### BUGGY CODE ###

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

from math import gcd

flg=0
ans='pairwise coprime'
for i in range(n-1):
    for j in range(i+1,n-1):
        g=gcd(a[i],a[j])
        if g!=1:
            ans='setwise coprime'
            flg=1
            break

if flg==0:
    print(ans)
    exit(0)

tmp=a[0]
for j in range(1,n):
    tmp=gcd(tmp,a[j])

if tmp==1:
    print(ans)
    exit(0)
else:
    print('not coprime')



### FIXED CODE ###

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

A=max(a)

def min_factor(k):
    d=[]
    for i in range(k+1):
        d.append(i)

    i=2
    while i*i<=k:
        if d[i]==i:
            j=i*i
            while j<=k:
                if d[j]==j:
                    d[j]=i
                j+=i
        i+=1
    
    return d

def prime_factor_set(p):
    s=set()
    while p!=1:
        s.add(d[p])
        p//=d[p]  
    
    return s


d=min_factor(A)
cur=set()
flg=True
for i in range(n):
    tmp = prime_factor_set(a[i])
    if len(cur&tmp)>=1:
        flg=False
        break
    cur |= tmp

import numpy as np

g= np.gcd.reduce(a)

if flg:
    ans='pairwise coprime'
elif not flg and g==1:
    ans='setwise coprime'
else:
    ans='not coprime'

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

import re
N,Q=[int(e) for e in input().split(' ')]
S=input()
qs=[]
for i in range(Q):
    qs.append([int(e) for e in input().split(' ')])

sts=[]
for i in range(N):
    if i>0:
        if S[i-1:i+1]=='AC':
            sts.append(i)

for q in qs:
    print(len([1 for e in sts if e>=q[0] and e<q[1]]))
#    print(len(re.findall('AC',substr)))

### FIXED CODE ###

import re
N,Q=[int(e) for e in input().split(' ')]
S=input()
qs=[]
for i in range(Q):
    qs.append([int(e) for e in input().split(' ')])

sts=[0]*N
for i in range(N):
    if i>0:
        if S[i-1:i+1]=='AC':
            sts[i]=sts[i-1]+1
        else:
            sts[i]=sts[i-1]
for q in qs:
    print(sts[q[1]-1]-sts[q[0]-1])
### BUGGY CODE ###

NM = input().split(" ")
A_LIST = input().split(" ")
A = []
for i in A_LIST:
    A.append(int(i))

N = int(NM[0])
M = int(NM[1])

A.sort()
for i in range(0, M):
    if A[N-1] >= A[N-2]:
        m = A[N-1]
        m = m // 2
        A[N-1] = m
    elif A[N-2] >= A[N-3]:
        m = A[N-2]
        m = m // 2
        A[N-2] = m
        A.sort()
S = 0
for i in A:
    S += i
print(S)

### FIXED CODE ###

import heapq

NM =input().split(" ")
A_LIST = input().split(" ")
N = int(NM[0])
M = int(NM[1])

A = []
for i in A_LIST:
    heapq.heappush(A, -1 * int(i))
    
for i in range(0, M):
    m = heapq.heappop(A)
    m = -1 * m
    m = m // 2
    heapq.heappush(A, -1 * m)

S = 0    
for i in A:
    S += (-1 * i)

print(S)
### BUGGY CODE ###

s = input()
t = input()
sett = set(t)
sets = set(s)
for e in sett:
  if e not in sets:
    print(-1)
    exit()

sumidx = 0
tmps = s
for e in t:
  idx = tmps.find(e)
  if idx == -1:
    tmps += s
    #print(tmps)
  idx = tmps.find(e)
  sumidx += idx+1
  tmps = tmps[idx+1:]
 # print(tmps)
print(sumidx)

### FIXED CODE ###

import bisect
import re

s = input()
t = input()
sett = set(t)
sets = set(s)
for e in sett:
  if e not in sets:
    print(-1)
    exit()

sumidx = 0
tmps = s
#tの各文字についてs内での出現場所をリストアップする
s_dict = {}
count = 1
for e in sett:
  s_dict[e] = [m.start() for m in re.finditer(e, s)]
idx = 0
for e in t:
  l = s_dict[e]
  idx = bisect.bisect_left(l, idx)
  #print(idx)
  if idx == len(l):
    count += 1
    if count > 10 ** 100:
      print(-1)
      exit()
    sumidx += len(s)
    idx = l[0]+1
  else:
    #print(l[idx])
    idx = l[idx]+1
sumidx += idx
print(sumidx)
### BUGGY CODE ###

# from sys import stdin
import math


def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


N = int(input())
A = list(map(int, input().split()))
# print(A)
d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
for l in range(N):
    d[A[cnt]] = d.get(A[cnt], 0)-1
    # print(d)
    # print(len(d))
    sum = 0
    for key, value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

### FIXED CODE ###

# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1
### BUGGY CODE ###

import bisect

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

ans = 0
#print(A)
#print(C)
for b in B:
    lenA = bisect.bisect_left(A,b) #競合時は無事無視される
    lenC = N - bisect.bisect_left(C,b) if b not in C else N - C.index(b) - 1
    ans += lenA*lenC
    #print(lenA,lenC)
    
print(ans)

### FIXED CODE ###

import bisect

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

ans = 0
#print(A)
#print(C)
for b in B:
    lenA = bisect.bisect_left(A,b)
    lenC = N - bisect.bisect(C,b)
    ans += lenA*lenC
    #print(lenA,lenC)
    
print(ans)
### BUGGY CODE ###

import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
c = [''.join(sorted(list(input()))) for _ in range(n)]
s = set(c)

anagram = [0] * len(s)
for i, si in enumerate(s):
    anagram[i] = c.count(si)

print(sum(comb(a, 2) for a in anagram if a > 1))

### FIXED CODE ###

import math
import collections


def comb(n, r):
    mf = math.factorial
    return mf(n) // (mf(n - r) * mf(r))


n = int(input())
s = [''.join(sorted(list(input()))) for _ in range(n)]
c = collections.Counter(s)
print(sum(comb(a, 2) for a in c.values() if a > 1))
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(len(P)):
  ref_list = [(j-P[i]) for j in P[:i+1]]
  if all(k>=0 for k in ref_list):
    count += 1  
print(count)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
count = 1
min_num = P[0]
for i in range(1, N):
  if P[i] <= min_num:
    count += 1
    min_num = P[i]
print(count)
### BUGGY CODE ###

from collections import defaultdict

n,m = map(int,input().split())
uf = [-1]*n
def root(x):
    if uf[x] < 0:
        return x
    uf[x] = root(uf[x])
    return uf[x]
def unite(x,y):
    rx, ry = root(x), root(y)
    if rx==ry: return False
    if rx > ry: rx, ry = ry, rx
    uf[rx] += uf[ry]
    uf[ry] = rx
    return True

edge = [[-1]*n for i in range(n)]
edge = defaultdict(list)
for i in range(m):
    l,r,d = map(int, input().split())
    edge[l-1].append((r-1,d))
    edge[r-1].append((l-1,-d))
    unite(l-1, r-1)

dist = [0]*n
visited = [False]*n
ans = True

def bfs(p, d=0):
    global ans
    if not ans:
        return
    if not visited[p]:
        visited[p] = True
        dist[p] = d
        for ind, j in edge[p]:
            bfs(ind, d+j)
    else:
        if dist[p] != d:
            ans = False

for i in range(n):
    if uf[i] >= 0:
        continue
    bfs(i, 0)
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from collections import defaultdict, deque

n,m = map(int,input().split())
edge = [[] for i in range(n)]
for i in range(m):
    l,r,d = map(int, input().split())
    edge[l-1].append((r-1,d))
    edge[r-1].append((l-1,-d))

dist = [0]*n
visited = [False]*n

for i in range(n):
    if visited[i]:
        continue
    q = deque()
    q.append((i,0))
    while q:
        to, d = q.popleft()
        if visited[to]:
            if dist[to] != d:
                print("No")
                exit()
        else:
            visited[to] = True
            dist[to] = d
            for ind, j in edge[to]:
                q.append((ind,d+j))

print("Yes")
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pk_max_idx = numpy.argmax([sum(P[i:i+K]) for i in range(len(P))])
    print((sum(P[Pk_max_idx:Pk_max_idx+K])+K)/2)

main()



### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string,scipy
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N,K = LI()
    P = LI()
    Pe = [(v+1)/2 for v in P]
    P_ms = numpy.cumsum(Pe)
    if K==N:print("{:.12f}".format(sum(Pe)));exit(0)
    ans = 0
    for i in range(K,N):
        ans = max(ans,P_ms[i]-P_ms[i-K])
    print("{:.12f}".format(ans))
main()
### BUGGY CODE ###

N, K = map(int, input().split())
A = tuple(map(int, input().split()))

inf = 10**9
dp = [inf] * (N+5)

dp[0] = 0

for i in range(1, N):
    h = A[i]
    dp[i] = min(dp[j]+abs(h-A[j]) for j in range(max(0, i-K), i))

print(dp[N - 1])


### FIXED CODE ###

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

dp=[100000 for i in range(N)]
dp[0]=0

for i,h_now in enumerate(h):
    if i==0:
        continue
    x=max(0,i-K)
    dp[i]=min([dp_i+abs(h_now-h_i) for dp_i,h_i in zip(dp[x:i],h[x:i])])

print(dp[N-1])
### BUGGY CODE ###

def calculate():
    s = input()

    count = 0
    while s.count("01") > 0 or s.count("10"):
        if s.count("01") > 0:
            s = s.replace("01","",1)
            count += 1
        if s.count("10") > 0:
            s = s.replace("10", "",1)
            count += 1

    print(count*2)



calculate()

### FIXED CODE ###

def calculate():
    s = input()

    n0 = s.count("0")
    n1 = s.count("1")

    if n0 == n1:
        print(n0*2)
    elif n0 > n1:
        print(n1 * 2)
    else:
        print(n0 * 2)



calculate()
### BUGGY CODE ###

while 1:
    n,s=map(int,input().split())
    if not n:break
    a=sorted([int(input()) for _ in range(n)],reverse=1)
    b=0
    try:
        for i in range(n):
            for j in range(i+1,n):
                if a[i]+a[j]>s:b+=1
                else:raise Exception;pass
    except:pass
    print(b)

### FIXED CODE ###

while 1:
    n,s=map(int,input().split())
    if n==0:break
    r=[0]*101
    for _ in [0]*n:r[int(input())]+=1
    a=0
    for i in range(101):
        if i*2>s:a+=(r[i]**2-r[i])//2
        a+=r[i]*sum(r[j] for j in range(max(i+1,s+1-i),101))
    print(a)
### BUGGY CODE ###

N = int(input())
S = list(input())
R = []
G = []
B = []
for i in range(N):
    if S[i] == "R":
        R.append(i)
    elif S[i] == "G":
        G.append(i)
    elif S[i] == "B":
        B.append(i)
count = 0


for a in R:
    for b in G:
        for c in B:
            num = [a, b, c]
            num.sort()
            if num[1] - num[0] != num[2] - num[1]:
                count += 1
print(count)

### FIXED CODE ###

N = int(input())
S = list(input())
R = []
G = []
B = []
Reval = {}
Geval = {}
Beval = {}
for i in range(N):
    if S[i] == "R":
        R.append(i)
        Reval[2*i] = 2*i
    elif S[i] == "G":
        G.append(i)
        Geval[2*i] = 2*i
    elif S[i] == "B":
        B.append(i)
        Beval[2*i] = 2*i
count = len(R)*len(G)*len(B)

for a in R:
    for b in G:
        if (a + b) in Beval:
            count -= 1
for a in G:
    for b in B:
        if (a + b) in Reval:
            count -= 1
for a in B:
    for b in R:
        if (a + b) in Geval:
            count -= 1
print(count)
### BUGGY CODE ###

n,k=map(int,raw_input().split())
arr=map(int,raw_input().split())
na=[0 for i in range(n)]
for i in range(1,n):
    m=999999999
    for j in range(max(i-k,0),i):
        m=min(m,na[j]+abs(arr[i]-arr[j]))
    na[i]=m
print na[-1]



### FIXED CODE ###

n,k=map(int,raw_input().split())
arr=map(int,raw_input().split())
na=[0 for i in range(n)]
for i in range(1,n):
    m=999999999
    for j in range(max(i-k,0),i):
        m=min(m,na[j]+abs(arr[i]-arr[j]))
    na[i]=m
print na[-1]
### BUGGY CODE ###

primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

while True:
    n = int(input())
    if n == 0:
        break
    while not (primes[n] & primes[n-2] & primes[n-6] & primes[n-8]):
        n -= 1
    print(n)

### FIXED CODE ###

import bisect


primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

values = [i for i, v in enumerate(primes) if v]
while True:
    n = int(input())
    if n == 0:
        break
    index = bisect.bisect(values, n)
    for i in range(2, index)[::-1]:
        if all(primes[values[i]-j] for j in [0, 2, 6, 8]):
            print(values[i])
            break
### BUGGY CODE ###

N,X,Y=map(int,input().split())
def shortest(x,y,a,b):
    ans=min(y-x,abs(y-b)+1+abs(a-x),abs(y-a)+1+abs(b-x))
    return ans
distance=[0]*(N-1)
for x in range(1,N):
    for y in range(2,N+1):
        if y<=x:
            continue
        a=shortest(x,y,X,Y)
        distance[a-1]+=1
ans="\n".join(map(str,distance))
print(ans)

### FIXED CODE ###

N,X,Y=map(int,input().split())
def shortest(x,y,a,b):
    ans=min(y-x,abs(y-b)+1+abs(a-x),abs(y-a)+1+abs(b-x))
    return ans
distance=[0]*N
for x in range(1,N+1):
    for y in range(1,N+1):
        if y<=x:
            continue
        else:
            a=shortest(x,y,X,Y)
            distance[a-1]+=1
for i in range(N-1):
    print(distance[i])
### BUGGY CODE ###

N,M=map(int,input().split())
E={(1,N)}
for _ in[0]*M:
    a,b=map(int,input().split())
    E|={(a,b)}
    F=set()
    for s,t in E:
        if s<=a and b<=t:
            F.add((a,b))
        else:
            F.add((s,t))
    E=F
cnt=0
E=list(E)
while E:
    cnt+=1
    M, Mi = 0, 0
    A = [0]*N
    l = len(E)
    B = [set(range(l))for _ in[0]*N]
    for k,(s,t) in enumerate(E):
        for i in range(s,t):
            A[i]+=1
            B[i]-={k}
            if M<A[i]:
                M, Mi = A[i], i
    E=[E[i]for i in B[Mi]]
print(cnt)

### FIXED CODE ###

n,m=map(int,input().split())
ab=sorted([list(map(int,input().split()))for _ in[0]*m],key=lambda x:x[1])
cnt=0
x=0
for a,b in ab:
   if x<a:x=b-1;cnt+=1
print(cnt)
### BUGGY CODE ###

N, M = list(map(int, input().split()))
A=[0] * M
B=[0] * M

import math

for i in range(M):
  A[i], B[i] = list(map(int, input().split()))

  
island_dict = {i+1:i+1 for i in range(N)} #島が属するグループ
group_dict = {i+1:[i+1] for i in range(N)} #グループに属する島
group_len_dict= {i+1:1 for i in range(N)}

answer = [0] * M
answer[-1] = math.factorial(N) // (math.factorial(N-2)*2)
  
for i in range(M)[:0:-1]:
  if island_dict[A[i]] == island_dict[B[i]]:
    answer[i-1] = answer[i]
  else:
    groupA = island_dict[A[i]]
    groupB = island_dict[B[i]] #グループ合併, groupB消滅
    NA = group_len_dict[groupA]
    NB = group_len_dict[groupB]
    
    if NA>=NB:
      for j in group_dict[groupB]:
        island_dict[j] = groupA
      group_dict[groupA] = group_dict[groupA] + group_dict[groupB]
      #group_dict[groupB] = []
      group_len_dict[groupA] = group_len_dict[groupA] + group_len_dict[groupB]
      #group_len_dict[groupB] = 0
      
    else:
      for j in group_dict[groupA]:
        island_dict[j] = groupB
      group_dict[groupB] = group_dict[groupA] + group_dict[groupB]
      #group_dict[groupA] = []
      group_len_dict[groupB] = group_len_dict[groupA] + group_len_dict[groupB]
      #group_len_dict[groupA] = 0
      
    answer[i-1] = answer[i] - NA*NB

#print(answer)

for i in range(M):
  print(answer[i])
    
    

### FIXED CODE ###

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

roots = [(i,1) for i in range(N+1)] # root, num_islands_in_group

inconveniences = [0]*(M+1)
inconveniences[-1] = N*(N-1)//2 #すべての橋が崩落するとNC2

def find_root(a, roots=roots):
  if roots[a][0] == a:
    return roots[a]
  else:
    roots[a] = find_root(roots[a][0])
  return roots[a]

def reduce_inconvenience_with_unite(a, b, roots=roots):
  root_a, n_a = find_root(a)
  root_b, n_b = find_root(b)
  if root_a == root_b:
    return 0
  else:
    if n_a > n_b:
      roots[root_a] = (root_a, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_a, n_a + n_b)
    else:
      roots[root_a] = (root_b, n_a + n_b) # 二項目は何でも良い
      roots[root_b] = (root_b, n_a + n_b)
    return n_a * n_b

for i, ab in enumerate(AB[:0:-1]): #実は1個めの橋は全く関係ない
  a, b = ab
  inconveniences[M-1-i] = inconveniences[M-i] - reduce_inconvenience_with_unite(a,b)

for inc in inconveniences[1:]:
  print(inc)
### BUGGY CODE ###

S = input()

MOD = 10**9+7

dp = [[0 for _ in range(13)] for _ in range(len(S) + 1)]


dp[0][0] = 1

for index in range(1, len(S) + 1):
    s = S[len(S) - index ]
    mul = (10 ** (index - 1)) % 13
    if s == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i * mul  +  pre_index ) % 13
                dp[index][next_i] += dp[index - 1][pre_index] 
    else:
        for pre_index in range(13):
            i = int(s)
            next_i = (i * mul +  pre_index ) % 13
            dp[index][next_i] += dp[index - 1][pre_index] 

    for i in range(13):
        dp[index][i] %= MOD



print(dp[len(S)][5])


### FIXED CODE ###

S = input()
 
MOD = 10**9+7
 
dp = [[0]*13 for _ in range(len(S) + 1)]
 
 
dp[0][0] = 1
 
for index in range(len(S)):
    if S[index] == '?':
        for pre_index in range(13):
            for i in range(10):
                next_i = (i +  pre_index * 10 ) % 13
                dp[index+1][next_i] += dp[index][pre_index] 
                dp[index+1][next_i] %= MOD

    else:
        for pre_index in range(13):
            i = int(S[index])
            next_i = (i +  pre_index  * 10) % 13
            dp[index+1][next_i] += dp[index][pre_index] 
            dp[index+1][next_i] %= MOD
 
 
 
print(dp[len(S)][5])
### BUGGY CODE ###

import collections

def main():
    S = list(map(int,list(input())))
    t = [0] * (len(S) + 1)
    for i in range(len(S)):
        t[i+1] = (t[i] + S.pop() * 10 ** i) % 2019
    count_dict = collections.Counter(t)
    result = sum([b*(b-1)//2 for a, b in count_dict.items()])
    print(result)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    S = list(input())
    N = len(S)
    t = 0
    A = [0] * 2019
    A[0] += 1
    d = 1
    for s in reversed(S):
        d *= 10
        d %= 2019
        t += (int(s) * d)
        t %= 2019
        A[t] += 1
    result = sum([a*(a-1)//2 for a in A])
    print(result)


if __name__ == '__main__':
    main()