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


import sys
sys.setrecursionlimit(10 ** 7)

def resolve():
    N, M,K = map(int, input().split())
    frind = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x:int(x)-1, input().split())
        frind[a].append(b)
        frind[b].append(a)

    block = [[] for _ in range(N)]
    for _ in range(K):
        a, b = map(lambda x: int(x) - 1, input().split())
        block[a].append(b)
        block[b].append(a)


    D = {}
    parent = [-1]*N
    visited = [False]*N
    for root in range(N):
        if visited[root]:
            continue
        D[root] = set([root])
        stack = [root]
        while stack:
            n = stack.pop()
            visited[n] = True
            parent[n] = root
            for to in frind[n]:
                if visited[to]:
                    continue
                D[root].add(to)
                stack.append(to)

    ans = [0]*N
    for i in range(N):
        gr = D[parent[i]]
        tmp = len(gr)-len(frind[i]) - 1
        for bl in block[i]:
            if bl in gr:
                tmp -= 1
        ans[i] = tmp
    print(*ans)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, M, K = map(int, inp().split())
friends = [set() for _ in range(N+1)]
blocked = [set() for _ in range(N+1)]

for _ in range(M):
  a, b = map(int, inp().split())
  friends[a].add(b)
  friends[b].add(a)
for _ in range(K):
  c, d = map(int, inp().split())
  blocked[c].add(d)
  blocked[d].add(c)  

checked = set()
ans = [0]*(N+1)
for i in range(1, N+1):
  if i in checked:
    continue
  chain = set()
  
  stack = list(friends[i])
  while stack:
    friend = stack.pop()
    if friend in checked:
      continue
      
    checked.add(friend)
    chain.add(friend)
    stack.extend(friends[friend])
  cnt = len(chain) - 1 # 自分を引く
  for c in chain:
    ans[c] += cnt - len(chain & (friends[c] | blocked[c]))
    
print(*ans[1:])
### BUGGY CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()

# 奇数番目は1のカタマリの人数　偶数番目は0のカタマリの人数 両端は必ず1のカタマリの人数
now_state, now_count = '1', 0
L = []
for i in range(len(S)):
  if S[i] == now_state:
    now_count += 1
  else:
    L.append(now_count)
    # reset
    now_count = 1
    now_state = '1' if now_state == '0' else '0'
L.append(now_count)
if now_state == '0':
  L.append(0)

#print(L)
# 0の塊をj個ひっくり返す
# j==1のとき101の3個の和の最大
# j==2のとき10101の5個の和の最大
# j==jのとき101...1のj*2+1個の和の最大

def evenngram(n, _list):
  return [_list[i:i+n] for i in range(len(_list)-n+1) if i%2==0]

now_max = 0
j = min(int((len(L)-1)/2), K) # 0のカタマリをひっくり返せるだけひっくり返す
tmp = evenngram(j*2+1, L)
tmp = [sum(t) for t in tmp]
tmp = max(tmp) if len(tmp) > 0 else 0
now_max = max(tmp, now_max)
print(now_max)


### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
S = input().strip()
l,r,now_max,now_zeros = 0,0,1,0
for r in range(1,N):
  if S[r-1] == '0':
    if S[r] == '0':
      continue
    else:
      now_zeros += 1
  else:
    if S[r] == '0':
      if now_zeros < K:
        continue
      else:
        now_max = max(r-l, now_max)
        now_zeros -= 1
        for _ in range(l,r):
          l += 1
          if S[l-1:l+1] == '01':
            break
    else:
      continue
now_max = max(r-l+1, now_max)
print(now_max)
### BUGGY CODE ###

A, B, Q = map(int, input().split())
s = []
for i in range(A):
    s.append(int(input()))
s.sort()
t = []
t.sort()
for i in range(B):
    t.append(int(input()))
x = []
for i in range(Q):
    x.append(int(input()))

for i in range(Q):
    sx, tx, sy, ty = [], [], [], []
    for j in range(A):
        sx.append(abs(s[j] - x[i]))
    for j in range(B):
        tx.append(abs(t[j] - x[i]))
    sxi = sx.index(min(sx))
    txi = tx.index(min(tx))
    for j in range(B):
        ty.append(abs(t[j] - s[sxi]))
    for j in range(A):
        sy.append(abs(s[j] - t[txi]))
    a = min(sx) + min(ty)
    b = min(tx) + min(sy)
    if a < b:
        print(str(a))
    else:
        print(str(b))


### FIXED CODE ###

import bisect

A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF]
for i in range(A):
    S.append(int(input()))
S.append(INF)
T = [-INF]
for i in range(B):
    T.append(int(input()))
T.append(INF)
X = []
for i in range(Q):
    X.append(int(input()))

for x in X:
    a, b = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
    print(min(abs(s-t) + min(abs(s-x), abs(t-x))
              for s in S[a-1:a+1] for t in T[b-1:b+1]))
### BUGGY CODE ###

n = input()
x = list(map(int,input().split()))
sum = 1
for i in x:
    sum = sum * i


if sum > 10**18:
    print(-1)
else:
    print(sum)

### FIXED CODE ###

n = input()
x = list(map(int,input().split()))
x.sort()
sum = 1
done = False



for i in x:

    # if 0 sum must be 0
    if i == 0:
        sum = 0
        break

    sum = sum * i

    if sum > 10**18:
        break

    



if sum > 10**18:
    print(-1)
else:
    print(sum)
### BUGGY CODE ###

s = input()
k = int(input())

if len(s) == 1:
  print(k // 2)
else:
  cnt = 0
  p = 1
  while p < len(s):
    if s[p-1] == s[p]:
      cnt += 1
      p += 1
    p += 1
      
  cnt2 = 0
  p2 = 1
  s2 = s + s
  while p2 < len(s2):
    if s2[p2-1] == s2[p2]:
      cnt2 += 1
      p2 += 1
    p2 += 1

  if 2*cnt < cnt2:
    print(k*cnt + (k - 1))
  else:
    print(k*cnt)
    
for i in range(k):
  i += 1

### FIXED CODE ###

s = input()
k = int(input())

if len(s) == 1:
  print(k // 2)
else:
  cnt = 0
  p = 1
  while p < len(s):
    if s[p-1] == s[p]:
      cnt += 1
      p += 1
    p += 1
      
  cnt2 = 0
  p2 = 1
  s2 = s + s
  while p2 < len(s2):
    if s2[p2-1] == s2[p2]:
      cnt2 += 1
      p2 += 1
    p2 += 1

  flg = 1
  for i in range(len(s)-1):
    if s[i] != s[i+1]:
      flg = 0
  
  if 2*cnt < cnt2:
    if flg == 1:
      print(k*cnt + (k//2))
    else:
      print(k*cnt + (k - 1))
  else:
    print(k*cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:10 2020

@author: liang
"""
#D
N, K = map(int, input().split())
areas = list()
for i in range(K):
    l, r = map(int,input().split())
    areas.append((l,r))
areas_sum = [0] * N 

d = [0] * N
d[0] = 1
for i in range(N):
    for j in range(K):
        l, r = areas[j]
        if i-l >= 0:
            areas_sum[j] += d[i-l]
        if i-r-1 >= 0:
            areas_sum[j] -= d[i-r-1]
    d[i] += sum(areas_sum)
    d[i] %= 998244353 

#print(d)
ans = d[N-1]
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:18:10 2020

@author: liang
"""
#D
N, K = map(int, input().split())
areas = list()
for i in range(K):
    l, r = map(int,input().split())
    areas.append((l,r))
#areas_sum = [0] * N 
tmp = 0
d = [0] * N
#check = [0] * N
#check[0] = 1
d[0] = 1
for i in range(N):
    for j in range(K):
        l, r = areas[j]
        if i-l >= 0:
            #areas_sum[j] += d[i-l]
            tmp += d[i-l]
        if i-r-1 >= 0:
            #areas_sum[j] -= d[i-r-1]
            tmp -= d[i-r-1]
    d[i] += tmp
    #check[i] += tmp
    d[i] %= 998244353 
    tmp  %= 998244353 
    #t.append(tmp)

#print(d)
#print(check)
ans = d[N-1]
print(ans)
#print(tmp)
### BUGGY CODE ###

N = int(input())
P = 1
for i in range(1, N+1):
    P *= i
_, ans = divmod(P, 1000000007)
print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
for i in range(1, N+1):
    _, ans = divmod(ans * i, 1000000007)
print(ans)
### BUGGY CODE ###

H,W,D = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
Q = int(input())

L = [0]*(H*W+1)
for i in range(H):
    for j in range(W):
        L[A[i][j]] = [i, j]
        
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    while l < r:
        ans += abs(L[l+D][0]-L[l][0])+abs(L[l+D][1]-L[l][1])
        l += D
    print(ans)

### FIXED CODE ###

H,W,D = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
Q = int(input())

L = [0]*(H*W+1)
for i in range(H):
    for j in range(W):
        L[A[i][j]] = [i, j]
        
E = [0]*(H*W+1)
for i in range(D+1, H*W+1):
    E[i] = E[i-D] + abs(L[i][0]-L[i-D][0])+abs(L[i][1]-L[i-D][1])
    
for i in range(Q):
    ans = 0
    l, r = map(int, input().split())
    ans = E[r] - E[l]
    print(ans)
### BUGGY CODE ###

from collections import Counter
S = input()
MOD = 10 ** 9 + 7
ans = 0
for i in range(len(S)):
  # Bの位置を固定
  if S[i] == 'B' or S[i] == '?':
    front = Counter(S[:i])
    back = Counter(S[i+1:])
    # ?を使わない
    ans += front['A'] * back['C'] * (3 ** (front['?'] + back['?']))
    # Aだけ?をつかう
    ans += front['?'] * back['C'] * (3 ** (front['?'] + back['?'] - 1))
    # Cだけ?をつかう
    ans += front['A'] * back['?'] * (3 ** (front['?'] + back['?'] - 1))
    # 両方?をつかう
    ans += front['?'] * back['?'] * (3 ** (front['?'] + back['?'] - 2))
    ans %= MOD

print(int(ans))

### FIXED CODE ###

from collections import Counter
S = input()
MOD = 10 ** 9 + 7
ans = 0
front = [0, 0, 0, 0]
back = [0, 0, 0, 0]
m = { 'A': 0, 'B': 1, 'C': 2, '?': 3 }
for c in S:
  back[m[c]] += 1

pow3 = [1]
for i in range(max(3, back[3])):
  pow3.append((pow3[-1] * 3) % MOD)

for i in range(len(S)):
  c = S[i]
  back[m[c]] -= 1
  # Bの位置を固定
  if c == 'B' or c == '?':
    fbsum = front[3] + back[3]
    # ?を使わない
    ans += front[0] * back[2] * (pow3[fbsum])
    # Aだけ?をつかう
    ans += front[3] * back[2] * (pow3[fbsum - 1])
    # Cだけ?をつかう
    ans += front[0] * back[3] * (pow3[fbsum - 1])
    # 両方?をつかう
    ans += front[3] * back[3] * (pow3[fbsum - 2])
    ans %= MOD
  front[m[c]] += 1

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

# EduDPD - Knapsack 1
import sys
input = sys.stdin.readline

n, w = list(map(int, input().rstrip().split()))
arr = [tuple(map(int, input().rstrip().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
    for j in range(w, arr[i][0] - 1, -1):
        dp[j] = max(dp[j], dp[j - arr[i][0]] + arr[i][1])
print(max(dp))

### FIXED CODE ###

# EduDPD - Knapsack 1
import sys
input = sys.stdin.readline

n, w = list(map(int, input().rstrip().split()))
arr = [tuple(map(int, input().rstrip().split())) for _ in range(n)]
dp = [0] * (w + 1)
for i in range(n):
    for j in range(w, arr[i][0] - 1, -1):
        dp[j] = max(dp[j], dp[j - arr[i][0]] + arr[i][1])
print(max(dp))
### BUGGY CODE ###

N, K = map(int, input().split())
tmp = input().split(' ')
A = []
for i in range(N):
    A = A + [int(tmp[i])]

while K > 0 and A.count(N)!=N:
    K = K - 1
    B = [0]*N
    for i in range(N):
        l =  max(0,i-A[i])
        r =  min(N-1,i+A[i])
        B[l] = B[l]+1
        if r+1 < N:
            B[r+1] = B[r+1]-1

    A[0] = B[0]
    for i in range(1,N):
        A[i]=A[i-1]+B[i]

print(' '.join(map(str,A)))

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    Z = [N]*N

    while K > 0 and A != Z:
        K-=1
        B = [int(0)]*(N+1)
        for i in range(N):
            B[max(int(0),i-A[i])]+=1
            B[min(N-1,i+A[i])+1]-=1
        for i in range(1,N):
            B[i]+=B[i-1]

        A = B[0:N]

    print(' '.join(map(str,A)))

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

#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def discount(M, A):
    for _ in range(M):
        A.sort(reverse=True)
        A[0] = int(A[0]/2)
    return sum(A)

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(discount(M, A))

if __name__ == '__main__':
    main()


### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def discount(M, A):
    from heapq import heappush, heappop
    hq = []
    for x in A:
        heappush(hq, (-x, x))
    for _ in range(M):
        _, price = heappop(hq)
        dprice = int(price/2)
        heappush(hq, (-dprice, dprice))
    return sum([x for _, x in hq])

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    print(discount(M, A))

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

import bisect

N = int(input())
A = list(map(int,input().split()))
A.sort()
Q = int(input())
s = [list(map(int,input().split())) for i in range(Q)]
for i in range(Q):
  search = s[i][0]
  b=bisect.bisect_left(A,search)
  c=bisect.bisect_right(A,search)
  for j in range(b,c):
    A[j] = s[i][1]
  print(sum(A))



### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
Q = int(input())
BC = [list(map(int,input().split())) for i in range(Q)]
B, C = [list(i) for i in zip(*BC)]
#print(B,C,BC)

dic = {}
for a in A:
  dic[a] = dic.get(a,0) + 1
#print(dic)

ans = sum(A)
for q in range(Q):
  ans = ans + (C[q]-B[q]) * dic.get(B[q],0)
  dic[C[q]] = dic.get(B[q],0) + dic.get(C[q],0)
  dic[B[q]] = 0
  print(ans)
### BUGGY CODE ###

n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


print(ans)


### FIXED CODE ###

n=int(input())
ans=0
dic={}
for _ in range(n):
    s=input()
    s=sorted(s)
    s=''.join(s)
    if not s in dic.keys():
      dic[s]=1
    else: dic[s]+=1
for i in dic.values():
  ans+=i*(i-1)//2


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

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = [1] * (n - k + 1)
for i in range(k):
    s[0] *= a[i]
for i in range(1, n - k + 1):
    s[i] = int(s[i - 1] / a[i - 1] * a[k + i - 1])
for i in range(n - k):
    print('Yes' if s[i] < s[i + 1] else 'No')

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n - k + 1):
    print('Yes' if 1 < a[k + i - 1] / a[i - 1] else 'No')
### BUGGY CODE ###

K, S = map(int, input().split())
 
count = 0
for x in range(S+1):
  # print("x", x)
  for y in range(S-x+1):
    # print("y" , y)
    z = S - x - y
    # print("z", z)
    if (x>=0 and x<=K) and (y>=0 and y<=K) and (z>=0 and z<=K):
      count += 1
      
print(count)

### FIXED CODE ###

K, S = map(int, input().split())
 
count = 0

for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if (z>=0) and (z<=K):
      count += 1

print(count)
### BUGGY CODE ###

from itertools import combinations
N=int(input())
A=list(map(int,input().split()))



ans=0
for i in combinations(A,2):
    ans+=i[0]*i[1]

print(ans%(10**9+7))    


### FIXED CODE ###

from itertools import combinations
N=int(input())
A=list(map(int,input().split()))

zen=sum(A)


ans=0
part=0
for i in range(N-1):
    part+=A[i]
    ans+=A[i]*(zen-part)

print(ans%(10**9+7))
### BUGGY CODE ###

def b_search(a,tgt):
    left = 0
    right = len(a) - 1

    while abs(right - left):
        mid = (left + right) // 2
        if a[mid] > tgt:
            right = mid
        else:
            left = mid
    return a[right]

def main():
    import sys
    sys.setrecursionlimit(4100000)
    input = sys.stdin.readline
    s = input().strip()
    t = input().strip()
    s_set = set(list(s))
    s_dict = {}
    s_len = len(s)
    t_list = list(t)
    t_set = set(t_list)
    c = 0
    ans = []
    ans_append = ans.append
    for i in s_set:
        s_dict[i] = []
    for i in range(s_len):
        s_dict[s[i]].append(i)
    if len(t_set) == len(t_set & s_set):
        for i in t_list:
            idxs = s_dict[i]
            if idxs[-1] <= c:
                c = idxs[0]
                ans_append(c)
            else:
                c = b_search(idxs,c)
                ans_append(c)
        count = 0
        for i in range(len(ans)-1):
            if ans[i] >= ans[i+1]:
                count += 1
        print(s_len*count + ans[-1] + 1)
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect

def main():
    s = input()
    t = input()
    s_set = set(list(s))
    s_dict = {}
    s_len = len(s)
    t_list = list(t)
    t_set = set(t_list)
    c = -1
    ans = []
    ans_append = ans.append
    for i in s_set:
        s_dict[i] = []
    for i in range(s_len):
        s_dict[s[i]].append(i)
    if len(t_set) == len(t_set & s_set):
        for i in t_list:
            idxs = s_dict[i]
            if idxs[-1] <= c:
                c = idxs[0]
                ans_append(c)
            else:
                c = idxs[bisect.bisect(idxs,c)]
                ans_append(c)
        count = 0
        for i in range(len(ans)-1):
            if ans[i] >= ans[i+1]:
                count += 1
        print(s_len*count + ans[-1] + 1)
    else:
        print(-1)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

#D問題
A = list(str(input()))
N = len(A)

left = ""
right = ""
count = 0
for i in range(N):
    I = i
    left = A[I]
    for j in range(N-i-1):
        J = i+j+1
        right = A[J]
        if left == right:
            count+=1
            
ans = 1
for i in range(N):
    if i == 0:
        pass
    else:
        ans+=(N-i)
#print(ans,count)
ans-=count
print(ans)


### FIXED CODE ###

#D問題
A = list(str(input()))
N = len(A)

used = []
count = 0
for a in A:
    if a not in used:
        used.append(a)
        c = A.count(a)
        count+=(c*(c-1)//2)
            
ans = 1
for i in range(N):
    if i == 0:
        pass
    else:
        ans+=(N-i)
#print(ans,count)
ans-=count
print(ans)
### BUGGY CODE ###

gcd_memo = {}


def gcd(a, b):
    if b == 0:
        return a
    else:
        r = a % b
        gcd_memo[(a, b)] = gcd(b, r)
        return gcd_memo[(a, b)]


if __name__ == "__main__":
    K = int(input())
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                tmp = gcd(gcd(a, b), c)
                ans += tmp
    print(ans)


### FIXED CODE ###

gcd_memo = {}


def gcd(a, b):
    if b == 0:
        return a
    elif (a, b) in gcd_memo:
        return gcd_memo[(a, b)]
    else:
        r = a % b
        gcd_memo[(a, b)] = gcd(b, r)
        gcd_memo[(b, a)] = gcd_memo[(a, b)]
        return gcd_memo[(a, b)]


if __name__ == "__main__":
    K = int(input())
    ans = 0
    for a in range(1, K+1):
        for b in range(1, K+1):
            for c in range(1, K+1):
                tmp = gcd(gcd(a, b), c)
                ans += tmp
    print(ans)
### BUGGY CODE ###


man_count = int(input())

infos = [int(i) for i in input().split()]

ans = []

for i in range(len(infos)+1):
    work = infos.count(i+1)
    ans.append(work)

for i in ans:
    print(i)



### FIXED CODE ###

import bisect

man_count = int(input())

infos = [int(i) for i in input().split()]
infos.sort()

next_num = 0
end = 0
for i in range(len(infos)+1):
    if i != next_num:
        print(0)
        continue

    # 速度を上げるために添え字を吹き飛ばそう。
    start = bisect.bisect_right(infos, i+1, end)  # iが始まる添え字を得る。
    print(start - end)
    end = start

    # 添え字が最後の場合 or 最後でない で切り分け必要。
    if start == len(infos):
      next_num = infos[start-1] -1
    else:
      next_num = infos[start] -1

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


from collections import defaultdict

def get_p(ind, parent):
    while parent[ind] != ind:
        ind = parent[ind]
    return ind

def get_p2(ind, parent):
    while parent[ind] != -1:
        ind = parent[ind]
    return ind


def main():
    num, swap = map(int, input().split())
    data = list(map(int, input().split()))

    parent = [-1 for i in range(num + 1)]

    for i in range(swap):
        a, b = map(int, input().split())
        if parent[a] == -1 and parent[b] == -1:
            parent[max(a, b)] = min(a, b)
        elif parent[a] != -1 and parent[b] != -1:
            a_parent = get_p2(a, parent)
            b_parent = get_p2(b, parent)
            parent[max(a_parent, b_parent)] = min(a_parent, b_parent)
        elif parent[a] == -1:
            parent[a] = get_p2(b, parent)
        else:
            parent[b] = get_p2(a, parent)


    ans = 0

    for i in range(num + 1):
        if parent[i] == -1:
            parent[i] = i


    for i in range(num):
        now_int = i + 1
        ind = data.index(i + 1)
        ind += 1
        if get_p(now_int, parent) == get_p(ind, parent):
            ans += 1
        elif ind == now_int:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###



def get_p(ind):
    if parent[ind] != ind:
        parent[ind] = get_p(parent[ind])
    return parent[ind]



num, swap = map(int, input().split())
data = list(map(int, input().split()))

parent = [i for i in range(num + 1)]

for i in range(swap):
    a, b = map(int, input().split())
    a_parent = get_p(a)
    b_parent = get_p(b)
    if a_parent != b_parent:
        parent[max(a_parent, b_parent)] = min(a_parent, b_parent)

ans = 0

for i in range(num):
    now_int = i + 1
    ind =  data[i]
    if get_p(now_int) == get_p(ind):
        ans += 1
    elif ind == now_int:
        ans += 1

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

#!/usr/bin/env python3
import sys
from functools import lru_cache
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 998244353  # type: int


def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    # 和がSとなるように選択する
    # DP[i][wa] ... i文字目まで見て和がwaとなる個数
    DP = [[0]*(S+1) for i in range(N+1)]
    DP[0][0] = 1
    for i in range(1, N+1):
        DP[i][0] = 1
        for wa in range(S+1):
            DP[i][wa] = DP[i-1][wa]
            if 0 <= wa-A[i-1] <= S:
                DP[i][wa] += DP[i-1][wa-A[i-1]]
    # print(*DP, sep="\n")

    # 組み合わせはDP[N][S]個存在する。
    # DPを逆に辿って集合を得る
    # 集合を含むような部分集合を数えあげる

    @lru_cache(maxsize=None)
    def reconstruct(n, wa):
        # nまで見て、和がwaとなるような集合のリストを返す
        # print("(n, wa)", n, wa)
        ans = []
        if wa < 0 or n < 0 or DP[n][wa] == 0:
            # print("?")
            return ans
        ans += reconstruct(n-1, wa)
        if DP[n][wa] != DP[n-1][wa]:
            # 文字の追加がある
            if wa-A[n-1] == 0:
                # print("only")
                ans.append({n-1})
            else:
                # print("add")
                b = reconstruct(n-1, wa-A[n-1])
                ans.extend([bb | {n-1} for bb in b])
        # print("ret, ", ans)
        return ans

    ans = 0
    for s in reconstruct(N, S):
        # print(s)
        # print(s, [A[i] for i in s])
        ans += pow(2, N - len(s), MOD)
        # print(2**(N - len(s)))
        ans %= MOD
    print(ans)

    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from functools import lru_cache
sys.setrecursionlimit(10**8)

MOD = 998244353  # type: int


def main():
    N, S = map(int, input().split())
    A = list(map(int, input().split()))

    DP = [[0]*(S+1) for i in range(N+1)]
    DP[0][0] = 1
    for i in range(1, N+1):
        for wa in range(S+1):
            DP[i][wa] = 2*DP[i-1][wa]
            DP[i][wa] %= MOD
            if 0 <= wa-A[i-1] <= S:
                DP[i][wa] += DP[i-1][wa-A[i-1]]
                DP[i][wa] %= MOD

    print(DP[N][S])
    return


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

n = int(input())
a = list(map(int,input().split()))
wa = []
wa2 = []
for i in range(n):
    wa.append(sum(a[0:i+1]))
    wa2.append(sum(a[-1:-(i+2):-1]))

ans = 10**10
for i in range(n-1):
    if ans > abs(wa[i] - wa2[-(i+2)]):
        ans = abs(wa[i] - wa2[-(i+2)])
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
wa = []
wa2 = []
#for i in range(n):
#    wa.append(sum(a[0:i+1]))
#    wa2.append(sum(a[-1:-(i+2):-1]))
s = 0
s1 = 0
for i in range(n):
    s +=a[i]
    wa.append(s)
    s1 +=a[-(i+1)]
    wa2.append(s1)

ans = 10**10
for i in range(n-1):
    if ans > abs(wa[i] - wa2[-(i+2)]):
        ans = abs(wa[i] - wa2[-(i+2)])
print(ans)
### BUGGY CODE ###

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

for i in range(a, b+1):
    if  i < a+k:
        print(i)
    elif b-k < i:
        print(i)

### FIXED CODE ###

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

s1 = [i for i in range(a, a+k) if i<=b]
s2 = [i for i in range(b-k+1, b+1) if i>=a]

s = list(set(s1+s2))
s.sort()

for i in s:
    print(i)