Harryxun/stf_run huggingface dataset:
def knapSack(W, wt, val, n): 
    K = [[0 for x in range(W+1)] for x in range(n+1)] 
  
    # Build table K[][] in bottom up manner 
    for i in range(n+1): 
        for w in range(W+1): 
            if i==0 or w==0: 
                K[i][w] = 0
            elif wt[i-1] <= w: 
                K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]) 
            else: 
                K[i][w] = K[i-1][w] 
  
    return K[n][W] 
  
n, W = map(int, input().split()) 
val = [] 
wt = [] 

for _ in range(n):
	w, v = map(int, input().split()) 
    val.append(v)
    wt.append(w)

print(knapSack(W, wt, val, n)

### FIXED CODE ###

# DP
def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()
#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    kmax = ((n - 1) * (n - 2)) // 2
    if k > kmax:
        print(-1)
        return

    edges = getedges(n, k, kmax)
    print(len(edges))
    for i, j in edges:
        print(i, j)

def getedges(n, k, kmax):
    edges = []
    for i in range(1, n):
        edges.append((i, n))
    c = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            edges.append((i, j))
            c += 1
            if c == kmax - k:
                return edges
    assert False


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    n, k = map(int, input().split())
    kmax = ((n - 1) * (n - 2)) // 2
    if k > kmax:
        print(-1)
        return

    edges = getedges(n, k, kmax)
    print(len(edges))
    for i, j in edges:
        print(i, j)

def getedges(n, k, kmax):
    edges = []
    for i in range(1, n):
        edges.append((i, n))
    if kmax == k:
        return edges
    c = 0
    for i in range(1, n - 1):
        for j in range(i + 1, n):
            edges.append((i, j))
            c += 1
            if c == kmax - k:
                return edges
    assert False

if __name__ == "__main__":
    main()
o = input()
e = input()
a = ''
for i in range(len(o)):
    a += o[i] + e[i]
print(a)

### FIXED CODE ###

o = input()
e = input()
a = ''
for i in range(len(e)):
    a += o[i] + e[i]
if len(o) > len(e):
    a += o[-1]
print(a)
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=0
while(d<=x and i<=n):
  d+=l[i]
  i+=1;
print(i)

### FIXED CODE ###

n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
i=1
while i<=n:
  d+=l[i-1]
  if x<d:
    break
  i+=1
print(i)
# coding: utf-8
print map(str, [x[0] for x in map(str, raw_input().split())]).upper()

### FIXED CODE ###

# coding: utf-8
print ''.join([x[0] for x in map(str, raw_input().split())]).upper()
n = int(input())
a = [int(i) for i in input().split()]

if n < 1000:
    d = a.copy()

    for i in range(1, n // 2):
        b = [0] * n
        c = -10**24
        for j in range(i * 2, n):
            c = max(c, a[j - 2])
            b[j] = c + d[j]

        a = b.copy()
    print(a[-1])
    exit()
    
b = a[:4]
e = [True]*4

for i in range(1, n // 2):
    c = [0] * 4
    f = [False]*4
    d = -10**24
    for j in range(4):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(240):
    if e[i]:
        ans = max(ans, b[i])
print(e)
print(ans)

### FIXED CODE ###

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

if n // 2 == 1:
    print(max(a))
    exit()
if n < 20:
    d = a.copy()
    
    for i in range(1, n // 2):
        b = [0] * n
        c = -10 ** 24
        ans = -10 ** 24
        for j in range(i * 2, n):
            c = max(c, a[j - 2])
            b[j] = c + d[j]
            ans = max(ans, c + d[j])

        a = b.copy()
    print(ans)
    exit()

b = a[:10]
e = [True]*10

for i in range(1, n // 2):
    c = [0] * 10
    f = [False]*10
    d = -10**24
    for j in range(10):
        if 2 * i + j >= n:
            continue
        if not e[j]:
            continue
        d = max(d, b[j])
        c[j] = d + a[2 * i + j]
        f[j] = True
    e = f.copy()
    b = c.copy()
ans = -10 ** 24
for i in range(10):
    if e[i]:
        ans = max(ans, b[i])
print(ans)
import sys
input = sys.stdin.readline

S = list(input())
T = list(input())

alpha2num = lambda c: ord(c) - ord('a') 

alpha = [[] for _ in range(26)]
for i,s in enumerate(S):
    alpha[alpha2num(s)].append(i)

import bisect
tmp = 0
N = len(S)
base = 0
for t in T:
    a = alpha2num(t)
    if len(alpha[a]) == 0:
        print(-1)
        sys.exit()
    else:
        L = len(alpha[a])        
        num = bisect.bisect_right(alpha[a],tmp)
        
        if num == L:
            base += 1
            tmp = alpha[a][0]
        else:
            tmp = alpha[a][num]
            
            
ans = N * base + tmp + 1
print(ans)
        
    


### FIXED CODE ###


import sys
#input = sys.stdin.readline

S = list(input())
T = list(input())

alpha2num = lambda c: ord(c) - ord('a') 

alpha = [[] for _ in range(26)]
for i,s in enumerate(S):
    alpha[alpha2num(s)].append(i)

import bisect
tmp = -1
N = len(S)
base = 0
for t in T:
    a = alpha2num(t)
    if len(alpha[a]) == 0:
        print(-1)
        sys.exit()
    else:
        L = len(alpha[a])        
        num = bisect.bisect_right(alpha[a],tmp)
        
        if num == L:
            base += 1
            tmp = alpha[a][0]
        else:
            tmp = alpha[a][num]
ans = N * base + tmp + 1
print(ans)
print("Christmas", "Eve"*(25-int(input()))

### FIXED CODE ###

print("Christmas", *["Eve"]*(25-int(input())))
K,X=map(int,input().split)

if 500*K>=X:
  print('yes')
else:
  print('no')

### FIXED CODE ###

K,X=map(int,input().split())

if 500*K >= X:
  print('Yes')
else:
  print('No')
def calc(i, k):
    ans_list = [i]
    ans_set = set([i])
    count = 1
    i = a[i]
    while (i not in ans_set) & (count < k):
        ans_list.append(i)
        ans_set.add(i)
        count += 1
        i = a[i]
    index = ans_list.index(i)
    ans_list.append(i)
    return count, ans_list

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

count, ans_list = calc(0, k)
if count < k:
    index = ans_list.index(ans_list[-1])
    k = k - index
    ans_list = ans_list[index + 1:]
    print(ans_list[k % len(ans_list) - 1] + 1)
else:
    print(ans_list[-1] + 1)

### FIXED CODE ###

n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
visit = {0}
tmp = 0
a_list = [0]
ans = True
for i in range(k):
    tmp = a[tmp]
    if tmp in visit:
        left = a_list.index(tmp)
        ans = False
        print(a_list[left + (k - left) % (i + 1 - left)] + 1)
        break
    else:
        visit.add(tmp)
        a_list.append(tmp)
if ans:
    print(tmp + 1)
N = int(input())

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))

### FIXED CODE ###

N,K = map(int,input().split())
if K == 1:
    print(0)
else:
    print(N-K)
n = int(input())

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

l = min(xs)
r = max(xs)

costs = []
for i in range(l, r):
    cost = 0
    for j in xs:
        cost += (j - i) * (j - i)
    costs.append(cost)

print(min(costs))



### FIXED CODE ###

n = int(input())

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

l = min(xs)
r = max(xs)

costs = []
for i in range(1, 100):
    cost = 0
    for j in xs:
        cost += (j - i) * (j - i)
    costs.append(cost)

print(min(costs))
n=int(input())
b=list(map(int,input().split()))
a[0]*n
for i in range(i):
  if i<=n-2:
    a[i] = min(b[i],b[i+1])
  else:
    a[i] = b[i-1]
print(sum(a))

### FIXED CODE ###

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

for i in range(N):
  if i==0:
    A[i] = B[i]
  elif i==N-1:
    A[i] = B[i-1]
  else:
  	A[i] = min(B[i],B[i-1]) 

print(sum(A))
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://qiita.com/suecharo/items/30f5d817da4c948c3be6
def count_sort(arr):
    max_num = max(arr)
    min_num = min(arr)
    count = [0] * (max_num - min_num + 1)
    for ele in arr:
        count[ele - min_num] += 1

    return [ele for ele, cnt in enumerate(count, start=min_num) for __ in range(cnt)]


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    order = list(x)

    for i in range(n):
        tmp = order[i]
        x.remove(tmp)
        x = count_sort(x)
        print(x[(n // 2) - 1])
        x += [tmp]


### FIXED CODE ###

# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    sorted_x = sorted(x)

    low = sorted_x[(n // 2) - 1]
    high = sorted_x[(n // 2)]

    for i in range(n):
        if x[i] < high:
            print(high)
        else:
            print(low)
import sys
n,k = map(int,input().split())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])

### FIXED CODE ###

import sys
n = int(input())
l = list(map(int, input().split()))
dp = [sys.maxsize] *n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+3):
        if(j<n):
            dp[j]=min(dp[j],dp[i]+abs(l[i]-l[j]))
print(dp[n-1])
def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    n = iput()
    a = lput()
    a.sort()
    ans = 0
    if a[0] == a[1]:
        ans += 1
    for i in range(1,n):
        for j in range(0, i):
            if a[i] % a[j] == 0:
                ans += 1
                break
    print(n - ans)
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    s = set()
    cnt = collections.Counter(arr)
    for i in range(n):
        if arr[i] in s:
            continue
        elif cnt[arr[i]] >= 2:
            s.add(arr[i])
        for j in range(2, 10**6//arr[i]+1):
            s.add(arr[i]*j)
    ans = 0
    for i in arr:
        if i in s:
            continue
        ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
n, x = map(int, input().split())
*l, = map(int, input().split())

d = 0
ans = 0
for i in range(n+1):
    if x < d:
        break
    d += l[i]
    ans += 1
print(ans)


### FIXED CODE ###

n, x = map(int, input().split())
*l, = map(int, input().split())

d = 0
ans = 1
for i in range(n):
    d += l[i]
    if x < d:
        break
    ans += 1
print(ans)
N,M=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
X.sort()
rui=[]
for i in range(len(X)-1):
  rui.append(X[i+1]-X[i])
rui.sort()
print(sum(rui[0:-(N-1)]))N,M=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
X.sort()
rui=[]
for i in range(len(X)-1):
  rui.append(X[i+1]-X[i])
rui.sort()
print(sum(rui[0:-(N-1)]))

### FIXED CODE ###

N,M=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
X.sort()
rui=[]
for i in range(len(X)-1):
  rui.append(X[i+1]-X[i])
rui.sort()
if N==1:
  print(sum(rui))
elif M>=N:
  print(sum(rui[0:-(N-1)]))
else:
  print(0)
num = (input())
a = ""
for _ in range(num):
  a += "ACL"
print(a)

### FIXED CODE ###

num = int(input())
a = ""
for _ in range(num):
  a += "ACL"
print(a)
n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
if len(a) = 3 and a[1] = 2:
    cnt = 1
    
print (cnt)    

### FIXED CODE ###

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

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)
N = int(input())

print(n*(n-1)/2)

### FIXED CODE ###

N = int(input())
print((N*(N-1))//2)
n = int(input())
A = list(map(int,input().split().rstrip()))
A.append(0)
ans = 0
for i in range(n):
  if A[i]==(i+1):
    ans += 1
    if A[i+1]==(i+2):
      ans -= 1

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
A.append(0)
T = []

ans = 0
for i in range(n+1):
  if A[i]==(i+1):
    T.append(1)
  else:
    T.append(0)    
for i in range(n+1):
  if T[i]:
    ans+=1
    T[i+1]=0

print(ans)
a,b,x = map(int,input().split())
    print("YES" if (a+b)>=x else "NO")

### FIXED CODE ###

a,b,x = map(int,input().split())
print("YES" if a<=x and (a+b)>=x else "NO")
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]
cnt = 0
for j in range(a,b+1):
    if j%c != 0 and j%d != 0
        cnt += 1
print(cnt)

### FIXED CODE ###

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

def gcd(x,y):
    while y !=0:
        x,y = y,x%y
    return x

def sums(x):
    S1 = x//c
    S2 = x//d
    S3 = x// (c*d//gcd(c,d))
    return x - S1 - S2 + S3


print(sums(b)-sums(a-1))
S=input()
L=len(S)
cnt=0
for i in range(L):
  if L[i] is not L[L-1-i]:
    cnt +=1
print(cnt)

### FIXED CODE ###

S=input()
L=len(S)
cnt=0
for i in range(L//2):
  if S[i] is not S[L-1-i]:
    cnt +=1
print(cnt)
from bisect import bisect_left, bisect, insort

def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = i
    if p != -1:
        ans[v] = max(ans[v], ans[p])
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [None]*(2*10**5+1)
    INF = 10**10
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    dp = [INF]*(2*10**5+1)
    dp[0] = -INF
    dfs(0, -1)
    for i in range(n):
        print(ans[i])

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    dp = [INF]*(n+1)
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))
N, X = map(int, input().split())
L=list(map(int, input().split()))

D=0
count=1
while D<=X:
   D=D+L[count-1]
   count+=1
print(count-1)

### FIXED CODE ###

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

D=0
count=1
while D<=X and count<=N+1:
    if count != N+1:
       D=D+L[count-1] #count kaime no jump
    count+=1

print(count-1)
r = int(input())
x = r * r * 3.14159265
y = r * 2 * 3.14159265
print(x, y)



### FIXED CODE ###

r = float(input())
x = r * r * 3.14159265359
y = r * 2 * 3.14159265359
print("{0:.10f} {1:.10f}".format(x, y))
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
c = [0] * (m + 1)

for ai in a:
    for i in range(ai, m + 1, ai):
        if bisect_right(a, i) - bisect_left(a, i) == 1:
            c[i] += 1

print(c.count(1))

### FIXED CODE ###

x = list(map(int, input().split()))
print(15 - sum(x))
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
print(max(a+b, a-b, a*b))

### FIXED CODE ###

# ABC137a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

a, b = map(int, input().split())
print(max(a+b, a-b, a*b))
import math
A, B, C, D = map(int, input().split())
l = int((B-A)/C)
m = int((B-A)/D)
lcm = C*D/math.gcd(C,D)
c = B-A-l-m+int((B-A)/lcm)
print(c)


### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split())
def F(x):
    l = x//C
    l += x//D
    lcm = C*D//fractions.gcd(C,D)
    l -= x//lcm
    return x-l
print(F(B)-F(A-1))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
	for j in range(W+1):
		if j-w[i-1] >= 0:
			dp[i+1][j] = max(dp[i][j], dp[i][j-w[i-1]]+v[i-1])
		else:
			dp[i+1][j] = dp[i][j]
print(dp[N][W])


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, islice
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')

N, W = MAP()
w, v = ZIP(N)
max_v = sum(v)
dp = [INF]*(max_v+1)
dp[0] = 0
for w, v in zip(w, v):
	for i in range(max_v, -1, -1):
		if i-v >= 0:
			dp[i] = min(dp[i], dp[i-v]+w)

ans = 0
for i in range(len(dp)):
	if dp[i] <= W:
		ans = i
print(ans)
import numpy as np
N=int(input())
A=np.empty((N))
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j=j-1
        A[j+1] = v
    print(A)


### FIXED CODE ###

N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j=j-1
        A[j+1] = v
    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        if k==N-1:
            print(A[k])
a,b,c= input().list()

if b == "+":
    print(ing(a)+int(c))
else:
    print(int(a)-int(c))



### FIXED CODE ###

a,b,c= input().split()

if b == "+":
    print(int(a)+int(c))
else:
    print(int(a)-int(c))
import numpy as np
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())), dtype="int64")

size = n*(n-1)//2

asort = np.sort(a)
x = np.multiply.outer(asort, asort)
xtril = np.tril(x, -1)

xunder0 = np.sort(xtril[xtril < 0])
xunsize = xunder0.size
xupper0 = np.sort(xtril[xtril > 0])
xupsize = xupper0.size
x0size = size - xunsize - xupsize
### print(x0size, xunsize, xupsize) ###

if k <= xunsize:
    print(xunder0[k-1])
elif k <= xunsize + x0size:
    print(0)
else:
    print(xupper0[k-xunsize-x0size-1])

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())), np.int64)

A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]

def f(x):
    cnt_tpl = 0
    if x >= 0: cnt_tpl += len(zero) * N
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    cnt_tpl -= np.count_nonzero(A * A <= x)
    # assert cnt_tpl % 2 == 0
    return cnt_tpl // 2

left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x

print(right)
import sys
while 1:
    a,b = sys.stdin.readline().split()
    if a == 0 and b == 0:
        break
    if a<b:print(a,b)
    else:print(b,a)

### FIXED CODE ###

import sys
while 1:
    a,b = [int(i) for i in sys.stdin.readline().split()]
    if a == 0 and b == 0:
        break
    if a > b:
        print(b,a)
    else:
        print(a,b)
from scipy.special import comb
import itertools

n, k = map(int, input().split())
x = list(map(int, input().split()))
X = []
m = 3*10**8

for v in itertools.combinations(x, k):
    X.append(list(v))

for i in range(comb(n, k, exact=True)):
    m0 = min(X[i])
    m1 = max(X[i])
    a = min(abs(abs(m0)+abs(m1-m0), abs(m1)+abs(m1-m0)))
    if m > a:
        m = a
print(m)

### FIXED CODE ###

n, k = map(int, input().split())
x = list(map(int, input().split()))
m = 3*10**8

for i in range(n-k+1):
    a = x[i]
    b = x[i+k-1]
    t= min(abs(a)+abs(b-a), abs(b)+abs(b-a))
    if m > t:
        m = t
print(m)
import collections
import math
n=int(input())
s=[''.join(list(input()).sort()) for _ in range(n)]
l=collections.Counter(s).values()
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    if l[i]!=1:c+=combinations_count(l[i],2)
print(c)

### FIXED CODE ###

import collections
import math
n=int(input())
s=[]
for i in range(n):
    sl=list(input())
    sl.sort()
    s.append("".join(sl))

l=list(collections.Counter(s).values())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

c=0
for i in range(len(l)):
    k=int(l[i])
    if k!=1:c+=combinations_count(k,2)
print(c)
n,k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
amax = max(a)
count = [0]*2000
c_in = 0
for i in range(n):
  for j, t in enumerate(a[:i]):
    c_in += int(t > a[i])
    if t > a[i]:
  count[a[i]-1] += 1
c_out = 0
for i in range(n):
  c_out += sum(count[:a[i]-1])
res = int(c_in*k + c_out*k*(k-1)/2)
print(res%(10**9+7))

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
x=0
for i in range(n):
    for j in range(i+1,n):
        if a[i]>a[j]:
            x+=1
y=0
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            y+=1
cnt=(x*k)+(k*(k-1)//2*y)
print(cnt%(10**9+7))
N,M=map(int,raw_input().split(' '))

g=[[False for i in range(N)] for j in range(N)]
ab=[()]*N
v=[False]*N

def dfs(n):
    v[n]=True
    for i in range(N):
        if g[n][i]==True and v[i]==False:
            dfs(i)

for i in range(M):
    a,b=map(int,raw_input().split(' '))
    a-=1
    b-=1
    g[a][b]=g[b][a]=1
    ab[i]=(a,b)

ans=0
for i in range(M):
    a,b=ab[i]
    g[a][b]=g[b][a]=False

    dfs(0)

    if v!=[True]*N:
        ans+=1

    g[a][b]=g[b][a]=True
    v=[False]*N

print ans



### FIXED CODE ###

N,M=map(int,raw_input().split(' '))

g=[[False for i in range(N)] for j in range(N)]
ab=[()]*M
v=[False]*N

def dfs(n):
    v[n]=True
    for i in range(N):
        if g[n][i]==True and v[i]==False:
            dfs(i)

for i in range(M):
    a,b=map(int,raw_input().split(' '))
    a-=1
    b-=1
    g[a][b]=g[b][a]=True
    ab[i]=(a,b)

ans=0
for i in range(M):
    a,b=ab[i]
    g[a][b]=g[b][a]=False

    dfs(0)

    if v!=[True]*N:
        ans+=1

    g[a][b]=g[b][a]=True
    v=[False]*N

print ans