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

infty=10**5
memo_of_num=[]
for i in range(infty):
    memo_of_num.append([0]*infty)
def numOfPath(n,m,l=[]):
    if (n,m) in l:
        memo_of_num[n][m]=0
    elif n*m==0:
        memo_of_num[n][m]=1
    else:
        memo_of_num[n][m]=numOfPath(n-1,m,l)+numOfPath(n,m-1,l)
    return memo_of_num[n][m]

def nCk(n,k):
    return numOfPath(n-k,k)


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
s1=0
for i in range(N-K+1):
    s1+=A[i]*nCk(N-(i+1),K-1)
A=A[::-1]
s2=0
for i in range(N-K+1):
    s2+=A[i]*nCk(N-(i+1),K-1)
print(s1-s2)

### FIXED CODE ###

mod = 10**9 + 7
MAX=10**6
fac,finv,inv=[0]*MAX,[0]*MAX,[0]*MAX

def nCkinit(mod):
    fac[0]=finv[0]=1
    fac[1]=finv[1]=inv[1]=1
    for i in range(2,MAX):
        fac[i]=fac[i-1]*i % mod
        inv[i]=mod-inv[mod%i] *(mod//i) %mod
        finv[i]=finv[i-1]*inv[i] % mod
        
def modnCk(n,k,mod):
    if n<k:return 0
    if n<0 or k<0:return 0
    else:
        return fac[n]*(finv[n-k]*finv[k]% mod) % mod
    
nCkinit(mod)

###
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
s1=s2=0
for i in range(N-K+1):
    s1+=(A[i]*modnCk(N-(i+1),K-1,mod))%mod
    s2+=(A[N-(i+1)]*modnCk(N-(i+1),K-1,mod))%mod
print((s1-s2)%mod)
### BUGGY CODE ###

N = int(input())
items = []

for i in range(N):
    item = input()
    if item not in items:
        items.append(item)

print(len(items))

### FIXED CODE ###

N = int(input())
items = set()

for i in range(N):
    items.add(input())

print(len(items))
### BUGGY CODE ###

def find_parent(x):
    y=parent[x]
    if y<0:
        return x
    parent[x]=find_parent(y)
    return parent[x]

def connect(a,b):
    c=find_parent(a)
    d=find_parent(b)
    if c==d:
        return
    if parent[c]<parent[d]:
        parent[c]+=parent[d]
        parent[d]=c
    else:
        parent[d]+=parent[c]
        parent[c]=d
    return

N=int(input())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append([x,i])
    Y.append([y,i])
X.sort()
Y.sort()
edge=[]
for i in range(1,N):
    edge.append([X[i][0]-X[i-1][0],X[i-1][1],X[i][1]])
    edge.append([Y[i][0]-Y[i-1][0],Y[i-1][1],Y[i][1]])
edge.sort()
parent=[-1]*N
 
ans=0
for l,a,b in edge:
    if find_parent(a)==find_parent(b):
        continue
    else:
        ans+=l
        connect(a,b)
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline

def find_parent(x):
    y=parent[x]
    if y<0:
        return x
    parent[x]=find_parent(y)
    return parent[x]

def connect(a,b):
    c=find_parent(a)
    d=find_parent(b)
    if c==d:
        return
    if parent[c]<parent[d]:
        parent[c]+=parent[d]
        parent[d]=c
    else:
        parent[d]+=parent[c]
        parent[c]=d
    return

N=int(input())
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    X.append([x,i])
    Y.append([y,i])

X.sort()
Y.sort()
edge=[]
for i in range(1,N):
    edge.append([X[i][0]-X[i-1][0],X[i-1][1],X[i][1]])
    edge.append([Y[i][0]-Y[i-1][0],Y[i-1][1],Y[i][1]])
edge.sort()
parent=[-1]*N

ans=0
for l,a,b in edge:
    if find_parent(a)==find_parent(b):
        continue
    else:
        ans+=l
        connect(a,b)

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

N = int(input())
l = list(map(int, input().split()))
l2 = l.copy()
ans = []
l.sort()

for i in l:
    ans.append(l2.index(i)+1)

print(*ans)

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
ans = [0]*N

for i in range(N):
    ans[l[i]-1] = i+1
print(*ans)
### BUGGY CODE ###

def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N >= B:
        for x in range(B-1, N+1, B):
            k = x / B
            ans = int(A*k) - int(k)
            if ans > mini:
                mini = ans
    else:
        ans = int(A*(N)/B)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    A, B, N = (int(x) for x in input().split())
    mini = 0
    if N >= B:
        ans = int(A*(B-1)/B)
    else:
        ans = int(A*(N)/B)
    print(ans)


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

from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(0, N):
    if i == 0:
        tmp = A[1]
    else:
        tmp = A[0]
    for j in range(0, N):
        if i != j:
            tmp = gcd(A[j], tmp)
        if tmp < ans:
            break
    ans = max(ans, tmp)
print(ans)


### FIXED CODE ###

from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(1, N):
    L.append(gcd(A[i-1], L[i-1]))
R = [0]
for i in range(1, N):
    R.append(gcd(R[i-1], A[N-i]))
R.reverse()
ans = []
for i in range(0, N):
    ans.append(gcd(L[i], R[i]))
print(max(ans))
### BUGGY CODE ###

import math

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

x = 1
k = 1/b
f = math.floor(a*k) - math.floor(k)*a
ans = 0
while x<=n:
  if ans<f:
    ans = f
  x += 1
  k = x/b
  f = math.floor(a*k) - math.floor(k)*a
  
print(ans)

### FIXED CODE ###

a,b,n = map(int, input().split())
yuka = lambda a,b: (a-(a%b))//b

x = min(n,b-1)
score = yuka(a*(x%b),b)
ans = score

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

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

A.insert(0,0)
sum=0


for i in range(N):
    sum=0
    tmp = A.pop(i+1)
#    print('tmp',tmp)

    for j in range(1,N):
        sum+=abs(A[j]-A[j-1])
#        print('sum',sum)
    sum+=abs(A[N-1])
    print(sum)
    A.insert(i+1,tmp)

### FIXED CODE ###

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

A.insert(0,0)
A.insert(N+1,0)
sum=0


for i in range(N+1):
    sum+=abs(A[i]-A[i+1])


for j in range(1,N+1):
    tmp=0
    tmp=abs(A[j-1]-A[j+1])-abs(A[j-1]-A[j])-abs(A[j]-A[j+1])
    print(sum+tmp)
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
for _ in range(q):
    l,r=map(int,input().split())
    print(s[l-1:r].count("AC"))

### FIXED CODE ###

import numpy as np
n,q=map(int,input().split())
s=list(input())
t=np.zeros(n+1,dtype=int)
for i in range(n-1):
    if s[i]+s[i+1]=="AC":
        t[i+1]=1
t=t.cumsum()
for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

import itertools

s = input()
A = list(int(x) for x in s)
S = [0] * (len(s) + 1)
S[1:] = itertools.accumulate(A)

ans = 0
for j in range(4, len(s)):
    for i in range(len(s) - j + 1):
        x = int(s[i:i + j])
        if (S[i + j] - S[i]) % 3 == 0:
            if int(s[i:i + j]) % 673 == 0:
                ans += 1
                i = i + j - 1
print(ans)


### FIXED CODE ###

S = input()
N = len(S)
SUM = [0] * (N + 1)
MOD = 2019

r = 1  # 10のi乗を2019で割った余り
S = S[::-1]
for i in range(N):
    A = r * int(S[i])
    SUM[i + 1] = (SUM[i] + A) % MOD
    r = r * 10 % MOD

cnt = [0] * 2019
ans = 0
for x in SUM:
    ans += cnt[x]
    cnt[x] += 1
print(ans)
### BUGGY CODE ###

import sys
def main():
    st = input()
    q = int(input())
    qnt_inv = 0
    for _ in range(q):
        t = sys.stdin.read(1)
        if t == '2':
            if qnt_inv % 2 == 1:
                st = st[::-1]
                qnt_inv = 0
            f, a = input().split()
            if f == '1':
                st = a + st
            else:
                st = st + a
        else:
            t = sys.stdin.read(1)
            qnt_inv += 1

    if qnt_inv > 0 and qnt_inv % 2 == 1:
        st = st[::-1]
    print(st)

main()

### FIXED CODE ###

"""
    Author: _YL_
"""
s = input()
n = int(input())

flip = 0
left = 0
right = 1
strs = ["", ""]

i = 0
while i < n:
    lst = input().split()

    if lst[0] == "1":
        flip += 1
        left = 0 if left == 1 else 1
        right = 0 if right == 1 else 1
    elif lst[1] == "1":
        strs[left] += lst[2]
    else:
        strs[right] += lst[2]
    i += 1

if flip % 2 == 1:
    s = s[::-1]
    
s = strs[left][::-1] + s + strs[right]

print(s)
### BUGGY CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = LI()
    t = LI()
    a = [[1 if i==j else 0 for j in t] for i in s]
    u = [0] * m
    for i in range(n):
        c = a[i]

        for j in range(1,m):
            if c[j] == 1:
                c[j] += u[j-1]

        e = c[:]
        for j in range(1,m):
            e[j] += e[j-1]
            e[j] %= mod

        if i > 0:
            for j in range(m):
                e[j] += u[j]
                e[j] %= mod
        u = e

    r = sum(map(lambda x: sum(x) % mod, a)) + 1

    return r % mod


print(main())





### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    s = LI()
    t = LI()
    a = [[1 if i==j else 0 for j in t] for i in s]
    u = [0] * m
    for i in range(n):
        c = a[i]

        for j in range(1,m):
            if c[j] == 1:
                c[j] += u[j-1]

        e = c[:]
        for j in range(1,m):
            e[j] += e[j-1]
            e[j] %= mod

        if i > 0:
            for j in range(m):
                e[j] += u[j]
                e[j] %= mod
        u = e

    r = sum(map(lambda x: sum(x) % mod, a)) + 1

    return r % mod


print(main())
### BUGGY CODE ###


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

m_l = [[0,0]]*m
for i in range(m):
  m_l[i] = list(map(int, input().split()))

cnt = 0
for ni in range(n):
  t = h_a[ni]
  for r in m_l:
    com = -1;
    if r[0] - 1 == ni:
      com = h_a[r[1] - 1]
    elif r[1] - 1 == ni:
      com = h_a[r[0] - 1]
    if com >= t:
      t = float('inf')
      break

  if t==h_a[ni]:
    cnt += 1

print(cnt)

### FIXED CODE ###

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

m_l = [[0,0]]*m
r_l = [{}]*n
for i in range(m):
  r = list(map(int, input().split()))
  a = r[0] - 1
  b = r[1] - 1

  ral = set([]) if len(r_l[a]) == 0 else r_l[a]
  rbl = set([]) if len(r_l[b]) == 0 else r_l[b]

  ral.add(b)
  rbl.add(a)

  r_l[a] = ral
  r_l[b] = rbl

cnt = 0
for ni in range(n):
  for r in r_l[ni]:
    if h_a[r] >= h_a[ni]:
      break
  else:
    cnt+=1

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

from statistics import median

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

def get_median(l):
    return median(l)

for i in range(N):
    target_l = X[:i] + X[i+1:]
    print(median(target_l))

### FIXED CODE ###

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

# N = 2
# X = [1, 2]

# N = 6
# X = [5, 5, 4, 4, 3, 3]

# target = int((N-1)/2)
first_m = int(N/2)
second_m = first_m - 1
X_ = sorted(X)
for i in range(N):
    if X[i] <= X_[second_m]: print(X_[first_m])
    else: print(X_[second_m])
### BUGGY CODE ###

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

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

C = [[0]*W for i in range(H)]

for h in range(H):
    for w in range(W):
        C[h][w] = abs(A[h][w] - B[h][w])
        
#print(C)

ZZZ = 80*77

DP = [[[0]*ZZZ for i in range(W)] for j in range(H)]

for h in range(H):
    for w in range(W):
        if h==0 and w==0:
            DP[h][w][C[h][w]] = 1
        elif h==0:
            for i in range(ZZZ):
                DP[h][w][i] = DP[h][w-1][abs(i-C[h][w])]| (DP[h][w-1][abs(i+C[h][w])] if abs(i+C[h][w])<ZZZ else 0)
        elif w==0:
            for i in range(ZZZ):
                DP[h][w][i] = DP[h-1][w][abs(i-C[h][w])]|(DP[h-1][w][abs(i+C[h][w])] if abs(i+C[h][w])<ZZZ else 0)
        else:
            for i in range(ZZZ):
                DP[h][w][i] = DP[h-1][w][abs(i-C[h][w])]|(DP[h-1][w][abs(i+C[h][w])] if abs(i+C[h][w])<ZZZ else 0)|DP[h][w-1][abs(i-C[h][w])]|(DP[h][w-1][abs(i+C[h][w])] if abs(i+C[h][w])<ZZZ else 0)
                
for i in range(ZZZ):
    if DP[H-1][W-1][i]==1:
        ans = i
        break
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

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

C = [[0]*W for i in range(H)]
M = 0

for h in range(H):
    for w in range(W):
        C[h][w] = abs(A[h][w] - B[h][w])
        
#print(C)

c = 80*(H+W-1)+1

DP = [[0]*W for j in range(H)]

for h in range(H):
    for w in range(W):
        if h==0 and w==0:
            DP[h][w] = 1 << (C[h][w]+c)
        elif h==0:
            DP[h][w] = (DP[h][w-1] << C[h][w]) | (DP[h][w-1] >> C[h][w])
        elif w==0:
            DP[h][w] = (DP[h-1][w] << C[h][w]) | (DP[h-1][w] >> C[h][w])
        else:
            DP[h][w] = (DP[h][w-1] << C[h][w]) | (DP[h][w-1] >> C[h][w]) | (DP[h-1][w] << C[h][w]) | (DP[h-1][w] >> C[h][w])

ans = float('inf')
now = DP[H-1][W-1]
tmpans = -c
while now != 0:
    if now%2==1:
        ans = min(ans,abs(tmpans))
    tmpans += 1
    now = now >> 1

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

n = int(input())
A = [int(x) for x in input().split()]

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        # print(i, j)
        ans += (A[i] * A[j]) % (10**9+7)
        ans %= (10**9+7)
print(ans)


### FIXED CODE ###

n = int(input())
A = [int(x) for x in input().split()]
l = []

a = 0
for i in reversed(A):
    a += i
    l.append(a)
l.pop(n-1)
ans = 0

l.reverse()
for i in range(n-1):
    ans += (A[i]*l[i])
print(ans%(10**9+7))
### BUGGY CODE ###

from collections import deque
N,Q = (int(x) for x in input().split())
ab = [list(map(int, input().split())) for _ in range(N-1)]
px = [list(map(int, input().split())) for _ in range(Q)]
connected = [[] for _ in range(N)]
for a, b in ab:
    connected[a-1].append(b)
    connected[b-1].append(a)
counter = [0] * N
for p, x in px:
    counter[p-1] += x
ans = counter
q = deque([(1,0)])
searched = [0] * N
while q:
    a,p = q.popleft()
    if searched[a-1] == 0:
        if p != 0:
            ans[a-1] += ans[p-1]
        searched[a-1] = 1
        for child in connected[a-1]:
            q.append((child,a))
print(*ans)

### FIXED CODE ###

from collections import deque
N,Q = (int(x) for x in input().split())
connected = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = (int(x) for x in input().split())
    connected[a-1].append(b)
    connected[b-1].append(a)
counter = [0] * N
for _ in range(Q):
    p,x = (int(y) for y in input().split())
    counter[p-1] += x
ans = counter
q = deque([(1,0)])
searched = [0] * N
while q:
    a,p = q.popleft()
    if p != 0:
        ans[a-1] += ans[p-1]
    searched[a-1] = 1
    for child in connected[a-1]:
        if searched[child-1] == 0:
            q.append((child,a))
print(*ans)
### BUGGY CODE ###

x = input()
y = input()


for i in range(97,123):
    li = []
    li_2 = []
    for j in range(len(x)):
        if chr(i) == x[j]:
            li.append(y[j])
        elif chr(i) == y[j]:
            li_2.append(x[j])
        if len(li) >= 2:
            if len(list(set(li))) == 1:
                continue
            else:
                print('No')
                exit()
        elif len(li_2) >= 2:
            if len(list(set(li_2))) == 1:
                continue
            else:
                print('No')
                exit()

print('Yes')


### FIXED CODE ###

s = input()
t = input()

alphabet_1 = [[] for _ in range(26)]
alphabet_2 = [[] for _ in range(26)]

for i in range(len(s)):
    if alphabet_1[ord(s[i])-97] == []:
        alphabet_1[ord(s[i])-97] = t[i]
    else:
        if alphabet_1[ord(s[i])-97] == t[i]:
            continue
        else:
            print('No')
            exit()

    if alphabet_2[ord(t[i])-97] == []:
        alphabet_2[ord(t[i])-97] = s[i]
    else:
        if alphabet_2[ord(t[i])-97] == s[i]:
            continue
        else:
            print('No')
            exit()

print('Yes')
### BUGGY CODE ###

X = int(input())
a = []
b = 0
flag = True
for i in range(1,X+1):
  if(X%i== 0):
    a.append(i)
  
while(flag):
  for i in range(len(a)): 
    if(pow(b+a[i],5)-pow(b,5) == X):
      print("%d %d"%(b+a[i],b))
      flag = False
      break
  b -= 1
  if(-pow(b,5) > X):
    b = int(X**(1/5))

### FIXED CODE ###

X = int(input())
a = []
b = 0
flag = True
num = 120
if(X <= 120):
  num = X
for i in range(1,num+1):
  if(X%i== 0):
    a.append(i)
while(flag):
  for i in range(len(a)): 
    if(pow(b+a[i],5)-pow(b,5) == X):
      print("%d %d"%(b+a[i],b))
      flag = False
      break
  b -= 1
  if(b < -119):
    b = 119
### BUGGY CODE ###

import re

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
re = 0

for kk in s:
  if not kk:
    continue
  while 'AD' in kk:
    re += kk.count('AD')
    kk = kk.replace('AD', 'DA')
    
print(re)

### FIXED CODE ###

import re
import sys
input = sys.stdin.readline

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)
### BUGGY CODE ###

""" AtCoder """

A, B = map(int, input().split())

ans = 0
for i in range(A, B + 1):
    ans = ans ^ i

print(ans)


### FIXED CODE ###

""" AtCoder """

A, B = map(int, input().split())

if A % 2 == 0 and B % 2 == 0:
    if (B - A) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(tmp ^ B)
elif A % 2 != 0 and B % 2 == 0:
    if (B - A - 1) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(A ^ tmp ^ B)
elif A % 2 == 0 and B % 2 != 0:
    if (B - A + 1) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(tmp)
else:
    if (B - A) % 4 == 0:
        tmp = 0
    else:
        tmp = 1
    print(A ^ tmp)
### BUGGY CODE ###

x = input()
a = []
for i in range(int(x)):
    a.append(int(input()) - 1)

index = 0
count = 0

while (index != 1):
    index = a[index]
    count += 1
    if count >= int(x):
        print(-1)

print(count)

### FIXED CODE ###

x = input()
a = []
check = []
for i in range(int(x)):
    a.append(int(input()) - 1)
    check.append(1)

index = 0
count = 0


while True:
    count += 1
    check[index] = 0
    index = a[index]

    if check[index] == 0:
        print(-1)
        break
    if index == 1:
        print(count)
        break
### BUGGY CODE ###

def main():
    N = int(input())
    a = input().split(" ")
    dict = {}
    for i in range(N):
        dict[int(a[i])] = str(i + 1)
    dict_sorted = sorted(dict.items(), key=lambda x:x[0])
    ans = ""
    for i in dict_sorted:
        ans = ans + i[1] + " "
    print(ans[:len(ans) - 1])


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = map(int, input().split(" "))
    list = [""] * (N + 1)
    for i, a in enumerate(A, 1):
        list[a] = str(i)
    print(" ".join(list[1:]))


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

N,K=map(int,input().split())
dice = list(map(int, input().split()))#dic=[]


#def calc(n):
#    return (n+1)/2
#t1=time.time()
#data = list(map(calc, dice))
#t2=time.time()
#t3=time.time()
p=[]
for j in range(N-K+1):
    su=sum(dice[j:j+K])
    p.append(su)
#t4=time.time()
print((max(p)+K)/2)


### FIXED CODE ###

N,K=map(int,input().split())
dice = list(map(int, input().split()))
a=sum(dice[0:K])

l = [a]
for i in range(1,N-K+1):
    a = a - dice[i-1] + dice[K-1+i]
    l.append(a)
print((max(l)+K)/2)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = ["YES"]
for i in range(1,N):
    if sorted(A)[i] == sorted(A)[i-1]:
        B[0] ="NO"
        break
print(B[0])

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if len(A) == len(set(A)):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

def rec(k, j, i):
    global dp
    if dp[k][j][i] != -1.0:
        return dp[k][j][i]
    if i+j+k == 0:
        return 0.0

    num = i+j+k
    ans = N_f / num
    if i > 0:
        ans += (rec(k, j, i-1) * i) / num
    if j > 0:
        ans += (rec(k, j-1, i+1) * j) / num
    if k > 0:
        ans += (rec(k-1, j+1, i) * k) / num
    dp[k][j][i] = ans
    return ans

N = ii()
N_f = float(N)
A = li()

cnt = [0, 0, 0]
for a in A:
    cnt[a-1] += 1

#dp = dp3(-1.0, cnt[2]+1, cnt[1]+cnt[2]+1, N+1)
dp = dp3(-1.0, N+1, cnt[1]+cnt[2]+1, cnt[2]+1)

print(rec(cnt[2], cnt[1], cnt[0]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
N_f = float(N)
A = li()

cnt = [0, 0, 0]
for a in A:
    cnt[a-1] += 1

#dp = dp3(-1.0, cnt[2]+1, cnt[1]+cnt[2]+1, N+1)
dp = dp3(0.0, N+1, N+1, N+1)
#dp = dp3(0.0, 301, 301, 301)
dp[0][0][0] = 0

for k in range(cnt[2]+1):
#for i in range(N+1):
    for j in range(cnt[1]+cnt[2]+1-k):
    #for j in range(N+1):
        #for k in range(cnt[2]+1):
        #for k in range(N+1):
        for i in range(N+1-j-k):
            #print(i, j, k)
            if i+j+k == 0:
                continue
            num = i+j+k
            dp[i][j][k] = N_f
            if i > 0:
                dp[i][j][k] += dp[i-1][j][k] * i
            if j > 0:
                dp[i][j][k] += dp[i+1][j-1][k] * j
            if k > 0:
                dp[i][j][k] += dp[i][j+1][k-1] * k
            dp[i][j][k] /= num

print(dp[cnt[0]][cnt[1]][cnt[2]])
### BUGGY CODE ###

s = list(input())[::-1]
num = len(s)

l = []
for i in range(1,num+1):
    l.append(int(''.join(s[:i][::-1])))

mod = []
for j in range(num):
    mod.append(l[j] % 2019)

ans = 0
for p in range(num):
    if mod[p] == 0:
        ans += 1
    tmp = 1
    for q in range(p+1,num):
        if mod[p] == mod[q]:
            tmp += 1
    ans += (tmp-1)*tmp//2

print(ans)


### FIXED CODE ###

s = input()[::-1]

cnts = [1] + [0] * (2019 - 1)
tmp = 0
d = 1

for i in s:
    tmp += int(i) * d
    cnts[tmp % 2019] += 1
    d = d * 10 % 2019 # 桁数が大きくなりすぎる → 10と2019が素だから可能

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

print(ans)