Harryxun/stf_run huggingface dataset:
N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
for _ in range(M):
  a, b = map(int, input().split())
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
for _ in range(K):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)


friendnetwork = []
sgn = [0 for _ in range(N)] #networkに属したら1
groupnum = 0

def makenetwork(n, groupnum):
  for item in friend[n]:
    if sgn[item] > 0:
      continue
    else:
      sgn[item] = groupnum
      makenetwork(item, groupnum)

for k in range(N):
  if sgn[k] == 0:
    groupnum += 1
    makenetwork(k, groupnum)

friends = [[] for _ in range(groupnum)]
for k in range(N):
  friends[sgn[k]-1].append(k)

ans = []
for k in range(N):
  num = len(friends[sgn[k]-1])-1  - len(friend[k])
  for item in block[k]:
    if sgn[item] == sgn[k]:
      num -= 1
  ans.append(num)

a = str(ans[0])
for j in range(1, len(ans)):
  a += ' '+ str(ans[j])
print(a)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)


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


friendnetwork = []
sgn = [0 for _ in range(N)]
groupnum = 0

def makenetwork(n, groupnum):
  for item in friend[n]:
    if sgn[item] > 0:
      continue
    else:
      sgn[item] = groupnum
      makenetwork(item, groupnum)

for k in range(N):
  if sgn[k] == 0:
    groupnum += 1
    sgn[k] = groupnum
    makenetwork(k, groupnum)


friends = [[] for _ in range(groupnum)]
for k in range(N):
  friends[sgn[k]-1].append(k)

ans = []
for k in range(N):
  num = len(friends[sgn[k]-1])-1  - len(friend[k])
  for item in block[k]:
    if sgn[item] == sgn[k]:
      num -= 1
  ans.append(num)

a = str(ans[0])
for j in range(1, len(ans)):
  a += ' '+ str(ans[j])
print(a)
a b = map(int,input().split())
s = input()
hoge = s.pop(a)
if s.isdigit() == True and hoge == '-':
  print('Yes')
else:
  print('No')

### FIXED CODE ###

a,b = map(int,input().split())
s = input()
hoge = s[a]
s =s[:a]+s[a+1:]
if s.isdigit() == True and hoge == '-':
  print('Yes')
else:
  print('No')
import sys
from bisect import bisect_left, bisect_right
from copy import deepcopy
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    repn = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        repn[u - 1].append(v - 1)
        repn[v - 1].append(u - 1)
    
    Length = [0] * N
    Length[0] = 1
    q = [(0, [A[0]])] # (vertex, dp)

    while q:
        v, dp = q.pop()
        for u in repn[v]:
            if Length[u] != 0:
                continue
            if A[u] > dp[-1]:
                Length[u] = Length[v] + 1
                new_dp = dp + [A[u]]
            else:
                Length[u] = Length[v]
                idx = bisect_right(dp, A[u])
                new_dp = deepcopy(dp)
                new_dp[idx] = A[u]
            q.append((u, new_dp))
    
    for ans in Length:
        print(ans)



    


    


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(2*10**5)
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    repn = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        repn[u - 1].append(v - 1)
        repn[v - 1].append(u - 1)
    
    length = [0] * (N + 1)
    dp = [-1]

    """
    やはり各頂点でLIS配列を取ると配列コピーの時間がかかってTLEするので、
    配列は唯一つを扱って、DFSからバックするときに配列も元に戻す操作を行いたい
    （ここの実装の仕方がわからなかった）

    これはdfsを再帰で書いた後に復元操作を追記すれば異常に楽に書ける。。。
    """

    def dfs(v, p=N):
        if A[v] > dp[-1]:
            dp.append(A[v])
            length[v] = length[p] + 1
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp.pop()
        else:
            length[v] = length[p]
            idx = bisect_left(dp, A[v]) # bisect_rightだとdpに重複する値を書き込んでしまうのでダメ
            old = dp[idx]
            dp[idx] = A[v]
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp[idx] = old
        #print("v={}, len={}, dp={}".format(v, length[v], dp))

    dfs(0)
    length.pop()
    for ans in length:
        print(ans)
    


if __name__ == "__main__":
    main()
a, b = int(input()).split()
c = a * b
if c/2 == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = (int(x) for x in input().split())
c = a * b
if c%2 !=0:
    print("Odd")
else:
    print("Even")
N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
from collections import Counter as co
D=co(A)

cnt=0
for i in range(N):
  if D[A[-1-i]]>0:
    D[A[-1-i]]-=1
    for j in range(1,16):
      d=2**j
      if A[-1-i]<d:
        e=d-A[-1-i]
        break
    if e in D:
      cnt+=1
      D[e]-=1
print(cnt)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A=sorted(A)
from collections import Counter as co
D=co(A)

cnt=0
for i in range(N):
  if D[A[-1-i]]>0:
    D[A[-1-i]]-=1
    d=A[-1-i]
    f=len(bin(d))-2
    e=2**f-d
    if D[e]>0:
      cnt+=1
      D[e]-=1
print(cnt)
a = input_raw()
b = input_raw()
c = input_raw()
 
print(a[0])
print(b[1])
print(c[2])

### FIXED CODE ###

a = input()
b = input()
c = input()
 
print(a[0]+b[1]+c[2])
s=[13,1,2,3,4,5,6,7,8,9,10,11,12]
a,b=map(int,input().split())
if s[a-1]==s[b-1]:
  print("Draw")
elif s[a-1]<s[b-1]
  print("Bob")
else:
  print("Alice")

### FIXED CODE ###

s=[13,1,2,3,4,5,6,7,8,9,10,11,12]
a,b=map(int,input().split())
if s[a-1]==s[b-1]:
  print("Draw")
elif s[a-1]<s[b-1]:
  print("Bob")
else:
  print("Alice")
ST = input().split()
N = ST[0]
M = ST[1]
print((N*(N-1)+(M*(M-1)))/2)

### FIXED CODE ###

ST = input().split()
N = int(ST[0])
M = int(ST[1])
print(int((N*(N-1)+(M*(M-1)))/2))
#! -*- coding: utf-8-unix -*-
import sys

if __name__=='__main__':
  lines = [x.strip() for x in sys.stdin.readlines() if x != '' and x != '\n']
  n = int(lines[0])
  for i in xrange(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, lines[i+1].split(' '))
    if x1 == x2:
      if x3 == x4:
        print 'YES'
      else:
        print 'NO'
    if y1 == y2:
      if y3 == y4:
        print 'YES'
      else:
        print 'NO'
    a1 = (y2 - y1) / (x2 - x1)
    b1 = y1 - a1 * x1
    a2 = (y4 - y3) / (x4 - x3)
    b2 = y3 - a2 * x3
    if (a1 == a2) and (b1 != b2):
      print 'YES'
    else:
      print 'NO'

### FIXED CODE ###

#! -*- coding: utf-8-unix -*-
import math

if __name__=='__main__':
  # lines = [x.strip() for x in sys.stdin.readlines() if x != '' and x != '\n']
  # n = int(lines[0])
  n = int(raw_input())
  for i in xrange(n):
    # x1, y1, x2, y2, x3, y3, x4, y4 = map(float, lines[i+1].split(' '))
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().strip().split(' '))
    # if x1 == x2 or x3 == x4:
    #   if x1 == x2 and x3 == x4:
    #     print 'YES'
    #   else:
    #     print 'NO'
    #   continue
    # elif y1 == y2 or y3 == y4:
    #   if y1 == y2 and y3 == y4:
    #     print 'YES'
    #   else:
    #     print 'NO'
    #   continue
    # else:
      # if (y2 - y1) * (x4 - x3) == (y4 - y3) * (x2 - x1):
    if math.fabs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10:
      print 'YES'
    else:
      print 'NO'
      # a1 = (y2 - y1) / (x2 - x1)
      # b1 = y1 - a1 * x1
      # a2 = (y4 - y3) / (x4 - x3)
      # b2 = y3 - a2 * x3
      # if (a1 == a2):# and (b1 != b2):
      #   print 'YES'
      # else:
      #   print 'NO'
    # except:
    #   break
N,Q = map(int, input().split())
S = input()
count = [0]*8
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)

### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
count = [0]*N
ans = []
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1]=='AC' : count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    ans.append(count[r-1]-count[l-1])
for i in  ans:
    print(i)
rgb = int(input().replace(" ","").)

if rgb % 4 == 0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

rgb = int(input().replace(" ",""))
     
if rgb % 4 == 0:
      print("YES")
else:
      print("NO")
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力を取得
    """
    N = int(input())
    x, y = [], []
    for n in range(N):
        x_n, y_n = list(map(int, input().split()))
        x.append(x_n)
        y.append(y_n)

    return N, x, y


def get_distance(x: list, y: list, i: int, j: int) -> float:
    """
    町iと町jの間の距離を取得する.

    Args:\n
        x (list): 町のx座標
        y (list): 町のy座標
        i (int): 町
        j (int): 町

    Returns:\n
        float: 町iと町jの間の距離
    """
    return math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)


def get_path_length(N: int, distance: dict, path: list) -> float:
    """
    経路の長さを求める.

    Args:\n
        N (int): 町の数
        distance (dict): 町間の距離
        path (list): 経路

    Returns:\n
        float: 経路の長さ
    """
    path_length = 0
    for n in range(N - 1):
        path_length += distance[(path[n], path[n + 1])]

    return path_length


def main(N: int, x: list, y: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 町の数
        x (list): 町のx座標
        y (list): 町のy座標
    """
    # 事前に町間の距離情報を作っておく
    distance = {}
    for i, j in itertools.product(range(N), repeat=2):
        distance[(i, j)] = get_distance(i, j)

    # 求解処理
    ans = 0
    for path in itertools.permutations(range(N)):
        ans += get_path_length(distance, path)
    ans /= math.factorial(N)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, x, y = get_input()

    # メイン処理
    main(N, x, y)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools

# 標準入力を取得
N = int(input())
x, y = [], []
for n in range(N):
    x_n, y_n = list(map(int, input().split()))
    x.append(x_n)
    y.append(y_n)


def get_distance(i: int, j: int) -> float:
    return math.sqrt((x[i] - x[j])**2 + (y[i] - y[j])**2)


def get_path_length(distance: dict, path: list) -> float:
    path_length = 0
    for n in range(N - 1):
        path_length += distance[(path[n], path[n + 1])]

    return path_length


# 求解処理
distance = {}
for i, j in itertools.product(range(N), range(N)):
    distance[(i, j)] = get_distance(i, j)

ans = 0
for path in itertools.permutations(range(N)):
    ans += get_path_length(distance, path)
ans /= math.factorial(N)

# 結果出力
print(ans)
a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b): #if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)

### FIXED CODE ###

a, b, n = map(int, input().split())
 
tmp = 0
for x in (range(1, b+1, b-2) if b<=n else range(1, n+1, n-1)):
#for x in range(1, n+1):
    calc = a*x//b - a*(x//b)
    if calc > tmp:
        tmp = calc
 
print(tmp)
n=int(input())
lst=[[[0]*10 for i in range(0,3)] for j in range(0,4)]
for k in range(n):
    b,f,r,v = map(int,input().split())
    lst[b-1][f-1][r-1] +=v
x=0
for i in range (4)
    if x<>0: print("#"*20)
    +=x
    for a in range(3):
        for b in range(10):
            print((lst[i][a][b]),end="")
        print()


### FIXED CODE ###

n= int(input())
tbl=[[[0]*10 for i in range(0,3)] for j in range(0,4)]
for k in range(n):
    b,f,r,v = map(int,input().split())
    tbl[b-1][f-1][r-1] +=v
x=0
for i in range (4):
    if x !=0 : print("#"*20)
    x +=1
    for a in range(3):
        for b in range(10):
            print(" %d"%(tbl[i][a][b]),end="")     
        print()
from sys import stdin, setrecursionlimit
input = stdin.readline

setrecursionlimit(10 ** 8)

S = int(input())

A = [-1] * (S + 1)
mod = 10 ** 9 + 7

for i in range(3):
    A[i] = 0

for i in range(3, 6):
    A[i] = 1


def dfs(n):
    if A[n] != -1:
        return A[n]
    else:
        A[n] = (dfs(n - 3) + dfs(n - 1)) % mod
        return A[n]


print(dfs(S))


### FIXED CODE ###

from sys import stdin
input = stdin.readline

S = int(input())

A = [-1] * (2001)
mod = 10 ** 9 + 7

for i in range(3):
    A[i] = 0

for i in range(3, 6):
    A[i] = 1


def dfs(n):
    if A[n] != -1:
        return A[n]
    else:
        A[n] = (dfs(n - 3) + dfs(n - 1)) % mod
        return A[n]


print(dfs(S))
n=int(input())
a=[int(input()) for i in range(n)]
c,s=1,a[0]
while S!=2 and c<n:
  c,s=c+1,a[s-1]
print(c if c<n else -1)

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
c,s=1,a[0]
while s!=2 and c<n:
  c,s=c+1,a[s-1]
print(c if c<n else -1)
N=int(input())
if N==1:
  print(1)
elif N % 2==0:
  print(1/2)
else:
  print((N-1)/2N)


### FIXED CODE ###

N=int(input())
if N==1:
  print(1)
elif N%2 == 0:
  print(1/2)
else:
  print((N+1)/(2*N))
#!/usr/bin/env python
# -*- coding: utf-8 -*-


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

    R = [False] * (N + 1)
    D = []

    p = 1

    while True:
        if R[p]:
            break
        D.append(p)
        R[p] = True
        p = A[p - 1]

    m = D.index(p)
    c = len(D) - m

    if K <= m:
        print(D[K])
    else:
        print(D[m + K - m] % c)


if __name__ == "__main__":
    main()


### FIXED CODE ###

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


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

    R = [False] * (N + 1)
    D = []

    p = 1

    while True:
        if R[p]:
            break
        D.append(p)
        R[p] = True
        p = A[p - 1]

    m = D.index(p)
    c = len(D) - m

    if K <= m:
        print(D[K])
    else:
        print(D[m + (K - m) % c])


if __name__ == "__main__":
    main()
R = 3
r = []
for i in range(R):
  r[i] = list(map(int, input().split(' ')))

def check():
  for y in range(R):
    f = True
    for x in range(R):
      if r[y][x] != 0:
        f = False
    if f:
      return True

  for x in range(R):
    f = True
    for y in range(R):
      if r[y][x] != 0:
        f = False
    if f:
      return True

  f = True
  for p in range(R):
    if r[p][p] != 0:
	    f = False
  if f:
    return True

  f = True
  for p in range(R):
    if r[R-1-p][p] != 0:
	    f = False
  return f

N = input()
for i in range(N):
  v = int(input())
  
  for y in range(R):
    for x in range(R):
      if r[y][x] == v:
        r[y][x] = 0

print('Yes' if check() else 'No')


### FIXED CODE ###

R = 3
r = [ list(map(int, input().split(' '))) for i in range(R) ]

def check():
  for y in range(R):
    f = True
    for x in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  for x in range(R):
    f = True
    for y in range(R):
      if r[y][x] != 0:
        f = False
        break
    if f:
      return True
 
  f = True
  for p in range(R):
    if r[p][p] != 0:
      f = False
      break
  if f:
    return True
 
  f = True
  for p in range(R):
    if r[R-1-p][p] != 0:
      f = False
      break
  return f
 
N = int(input())
for i in range(N):
  v = int(input())
  
  for y in range(R):
    for x in range(R):
      if r[y][x] == v:
        r[y][x] = 0
 
print('Yes' if check() else 'No')
N,X = map(int, input().split())


def para(a,b):
    if a > b:
        return a+b + para(b,a-b)
    if a < b:
        return 2*a + para(a,b-a)
    if a == b:
        return 3*a
print(X+para(X,N-X))

### FIXED CODE ###

N,X = map(int,input().split(" "))
 
Y,X = sorted([N - X,X])
 
s = 0
while Y:
    s += (X//Y)*Y*3
    Y,X = [X%Y,Y]
 
print(s)
S = list(input())
lon = len(S)
count = 0
num = S.count("?")

#print(S)

if S[0] == "?":
  if S[1] == "D":
    S[0] = "P"
  else:
    S[0] = "D"
    
if S[-1] == "?":
  if S[-2] == "P":
    S[-1] = "D"
  else:
    S[-1] = "D"
    
    
for i in range(1, lon-1):
  if S[i] == "?":
    if S[i-1] == "P":
      S[i] = "D"
    elif S[i+1] == "D":
      S[i] = "P"
    elif S[i-1] == "D":
      S[i] = "P"
    else:
      S[i] = "D"

    
T = "".join(S)
#print(T.count("D") + T.count("PD") )
print(T)

### FIXED CODE ###

S = list(input())
lon = len(S)
for i in range(lon):
  if S[i] == "?":
    S[i] = "D"
 
    

T = "".join(S)
#print(T.count("D") + T.count("PD") )
print(T)
n, m = map(int, input().split())

s, c = [], []
for _ in range(m):
  s_, c_ = map(int, input().split())
  s.append(s_)
  c.append(c_)

flg = False
for i in range(10**n):
  for j in range(m):
    if str(i)[s[j]-1] != str(c[j]):
      break
  else:
    print(i)
    flg = True
    break
if not flg:
  print(-1)

### FIXED CODE ###

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

s, c = [], []
for _ in range(m):
  s_, c_ = map(int, input().split())
  s.append(s_)
  c.append(c_)

for i in range(10**n):
  ans = str(i)
  if len(ans) == n and all([ans[s[j]-1] == str(c[j]) for j in range(m)]):
    print(ans)
    exit()

print(-1)
a = list(map(int,input().split()))
X = a[1]
Y = a[2]

if (Y-2*X) % 2 == 0 and (Y-2*X) >= 0:
	print('Yes')
else:
    print('No')

### FIXED CODE ###

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

X = a[0]
Y = a[1]
 
if (Y-2*X) % 2 == 0 and (Y-2*X) >= 0 and (4*X-Y) % 2 == 0 and (4*X-Y) >= 0:
	print('Yes')
else:
    print('No')
import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(n)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)

  

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
jobs = [[] for _ in range(m)]

for i in range(n):
  a, b = map(int, input().split())
  if a > m:
    continue
  jobs[m-a].append(b)

que = []#候補入れ
ans = 0
for i in range(m-1, -1, -1):
  for wage in jobs[i]:
    heapq.heappush(que, wage*-1)
  if len(que):
    ans += heapq.heappop(que)*-1
    
print(ans)
N,M,X,Y=map(int,input().split())

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

x_max=max(a)
y_max=max(b)

coun="War"

for i in range(X,Y+1):
    if i>x_max and i<=y_min and i>X and i<Y:
        count="No War"

print(count)

### FIXED CODE ###

# coding: utf-8 -*-

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

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

# print(X, a)

x_max = max(a)
y_min = min(b)


# print(x_max, y_min)

count = 'War'


for i in range(X, Y + 1):
    if i > x_max and i <= y_min and i > X and i < Y:
        count = 'No War'

print(count)
a,b = map( input() , input() )

ans1 = a * b
ans2 = 2 * ( a + b )

print ans1 + ' ' + ans2

### FIXED CODE ###

a,b = map( int , raw_input().split() )

ans1 = a * b
ans2 = 2 * ( a + b )

print ans1 , ans2
N, Y = map(int, input().split())

answer = '-1 -1 -1'
for x in range(0,N+1):
    for y in range(0,N+1):
        for z in range(0,N+1):
            if 10000*x + 5000*y + 1000*z == Y and x + y + z == N:
                answer = f'{x} {y} {z}'
                break
        else:
            continue
        break
    else:
        continue
    break
print(answer)





### FIXED CODE ###

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

answer = '-1 -1 -1'
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if 10000*x + 5000*y + 1000*z == Y and z >= 0:
            answer = str(x) + ' ' + str(y) + ' ' + str(z) 
            break
print(answer)
x, y = list(map(int, input().split()))
arr = list(map(int, input().split()))


def bubble_sort(arr):
    change = True
    while(change):
        change = False
        if(1 <= x, y <= 1000 and 1 <= max(arr) <= 1000 and 1 <= min(arr) <= 1000):
            for i in range(len(arr) - 1):
                if arr[i] > arr[i + 1]:
                    arr[i], arr[i + 1] = arr[i + 1], arr[i]
                    change = True
    return arr


sorted_list = bubble_sort(arr)

result = sorted_list[0] + sorted_list[1] + sorted_list[2]

print(result)

### FIXED CODE ###

x, y = list(map(int, input().split()))
arr = list(map(int, input().split()))


def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    if(1 <= x, y <= 1000 and 1 <= max(arr) <= 1000 and 1 <= min(arr) <= 1000):
        ref = arr[0]
        ref_count = 0

        for ele in arr:
            if ele < ref:
                left.append(ele)
            elif ele > ref:
                right.append(ele)
            else:
                ref_count += 1
        left = quick_sort(left)
        right = quick_sort(right)
        return left + [ref] * ref_count + right


sorted_list = quick_sort(arr)

result = 0

for i in range(0, y):
    result += sorted_list[i]


print(result)
def main():
    n = int(input())
    a = int(input())
    b = int(input())
    if n == 1:
        print('Hello World')
    else:
        print(a + b)


if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    n = int(input())
    if n == 1:
        print('Hello World')
    else:
        a = int(input())
        b = int(input())
        print(a + b)


if __name__ == "__main__":
    main()
a,b,k=map(int,input().split())
for i in range(k):
  if(a>0):
    a-=1
  elif(b>0):
    b-=1
  else:
    pass
print("{} {}".format(a,b))
  

### FIXED CODE ###

s=input().split()
print("{}{}".format(s[1],s[0]))
#include<bits/stdc++.h>
using namespace std;

int main(){
  long long int n,i,ans=1;
  cin>>n;
  
  for(i=1;i<=n;i++)
  ans=(ans*i)%(10000000007);
  
cout<<ans<<endl;

### FIXED CODE ###

s=int(input())
ans=1
for i in range(1,s+1):
  ans=ans%(10**9+7)*i
  
  
print(ans%(10**9+7))
from collections import defaultdict

n, k = map(int, input().split())
al = [int(i) for i in range(n)]

# dictionary で種類と数値をとっておく
d = defaultdict(int)
for a in al:
  d[a] += 1

# 種類が少ないものから色を変えていくと最小の変えなければいけないボールの数がわかる
ans = 0
if d.keys() > k:
  # 色を塗り替えないといけないので数えなければ…
  v = d.values()
  v.sort()
  ans = sum(v[:d.keys() - k])
print(ans)

### FIXED CODE ###

from collections import defaultdict

n, k = map(int, input().split())
al = [int(i) for i in input().split()]

# dictionary で種類と数値をとっておく
d = defaultdict(int)
for a in al:
  d[a] += 1

# 種類が少ないものから色を変えていくと最小の変えなければいけないボールの数がわかる
ans = 0
if len(d.keys()) > k:
  # 色を塗り替えないといけないので数えなければ…
  v = list(d.values())
  v.sort()
  ans = sum(v[:len(d.keys()) - k])
print(ans)
import numpy as np
import math

s = input()
dg = len(s)

count = 0

if dg < 5:
    for i in range(1,int(s)):
        if set(list(str(i))) == {'7','5','3'}:
            count += 1

    print(count)
else:
    import ipdb; ipdb.set_trace()
    base = (math.factorial(dg-1))/(math.factorial(dg-4)*math.factorial(3)) * (3**(dg-4))
    for i in range(10**dg, int(s)+1):
        if set(list(str(i))) == {'7','5','3'}:
            count += 1
    print(count + base)

### FIXED CODE ###

s = input()
n = int(s)
dg = len(s)

all_list = []

for i in '753':
    for j in '753':
        for k in '753':
            all_list.append(''.join([i,j,k]))

for i in range(4,dg+1):
    add_list = []
    for c in '753':
        add_list += [''.join(c+e) for e in all_list]
    all_list += add_list

all_list = set(all_list)
res = sum([True for _ in all_list if set(list(_))=={'7','5','3'} and int(_) <= n])
print(res)