Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

plus_zero = []
minus = []

for i in a:
    if i >= 0:
        plus_zero.append(i)
    if i < 0:
        minus.append(-i)

from collections import deque

plus_zero = deque(sorted(plus_zero, reverse=True))
minus = deque(sorted(minus, reverse=True))
ans_lst = []
# 負
if len(plus_zero) == 0 and (k % 2) != 0:
    for _ in range(k):
        ans_lst.append(-minus.pop())
# 正 or 0
else:
    # 境界条件: k == 1
    if k == 1:
        print(plus_zero[0] % MOD)
        sys.exit(0)
    while len(ans_lst) != k:
        if len(ans_lst) == k-1:
            ans_lst.append(plus_zero.popleft())
        else:
            if len(plus_zero) < 2:
                ans_lst.append(minus.popleft())
                ans_lst.append(minus.popleft())
                continue
            elif len(minus) < 2:
                ans_lst.append(plus_zero.popleft())
                continue
            else:
                if (plus_zero[0] * plus_zero[1]) >= (minus[0] * minus[1]):
                    ans_lst.append(plus_zero.popleft())
                else:
                    ans_lst.append(minus.popleft())
                    ans_lst.append(minus.popleft())
                continue

# functools.reduceはTLEをくらう場合があるので気をつける
ans = 1
for i in ans_lst:
    ans = (ans * i) % MOD
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

plus_zero = []
minus = []

for i in a:
    if i >= 0:
        plus_zero.append(i)
    if i < 0:
        minus.append(-i)

from collections import deque

plus_zero = deque(sorted(plus_zero, reverse=True))
minus = deque(sorted(minus, reverse=True))
ans_lst = []
# 境界条件: k == n
if k == n:
    ans_lst.extend(a)
# 負
elif len(plus_zero) == 0 and (k % 2) != 0:
    for _ in range(k):
        ans_lst.append(-minus.pop())
# 正 or 0
else:
    while len(ans_lst) != k:
        if len(ans_lst) == k-1:
            ans_lst.append(plus_zero.popleft())
        else:
            if len(plus_zero) == 0:
                ans_lst.append(minus.popleft())
                ans_lst.append(minus.popleft())
                continue
            if len(plus_zero) == 1:
                if (k - len(ans_lst)) % 2 == 0:
                    ans_lst.append(minus.popleft())
                    ans_lst.append(minus.popleft())
                else:
                    ans_lst.append(plus_zero.popleft())
                continue
            if len(minus) < 2:
                ans_lst.append(plus_zero.popleft())
                continue
            if len(plus_zero) >= 2 and len(minus) >= 2:
                if (plus_zero[0] * plus_zero[1]) >= (minus[0] * minus[1]):
                    ans_lst.append(plus_zero.popleft())
                else:
                    ans_lst.append(minus.popleft())
                    ans_lst.append(minus.popleft())
                continue
# functools.reduceはTLEをくらう場合があるので気をつける
ans = 1
for i in ans_lst:
    ans = (ans * i) % MOD
print(ans)
w,h,x,y = map(float,input().split(" "))

if a.count(max(a)) > 1:
    print('{:.6f}'.format(w*h/2,1)
else:
    print('{:.6f}'.format(w*h/2,0)


### FIXED CODE ###

w,h,x,y = map(int,input().split(" "))

if x == w/2 and y == h/2:
    print('{:.6f}'.format(w*h/2),1)
else:
    print('{:.6f}'.format(w*h/2),0)
from decimal import *
 
a = list(input().rstrip().split(" "))
 
A,B =Decimal(int(a[0])),float(a[1])
 
if A > 100:
    C = int(B*100)
    
    ans2 = (A-100)*C
    ans3 = int(ans2/100)
    ans = C + ans3
else:
    ans = int(A*B)
    
print(ans)

### FIXED CODE ###

a, b = map(float, input().split())
a = int(a)
b = int(b * 1000)
print((a*b)//1000)
a,b,c,d = map(int,input().split())
ans = []
for i in c,d:
    ans.append(a*i)
for j in c,d:
    ans.append(b*j)

print(max(ans))

### FIXED CODE ###

n = int(input())
mod = 10**9+7
print((((10**n)%mod)-(9**n%mod)-(9**n%mod)+(8**n%mod))%mod)
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse=True)
SUM = 0

if K > N:
    print(0)
    exit()

for i in range(K):
    H.pop(i)
    
for i in range(len(H)):
    SUM = SUM + H[i]

print(SUM)

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H)
SUM = 0

if K >= N:
    print(0)
    exit()


    
for i in range(len(H)-K):
    SUM = SUM + H[i]


print(SUM)
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;
    vector<int>d_vec(k, 0);
    for (int i = 0; i < k; ++i) {
        cin >> d_vec[i];
    }

    int price = n;
    while (true){
        bool isValid = true;
        int digit_cnt = floor(log10(price));
        int now = price;
        for (int digit = 0; digit < digit_cnt+1; ++digit) {
            int tmp = now % 10;
            auto iter = find(d_vec.begin(), d_vec.end(), tmp);
            if (iter != d_vec.end()){
                isValid = false;
                break;
            }
            now /= 10;
        }

        if (isValid){
            cout << price << endl;
            break;
        }


        price++;
    }
    return 0;


### FIXED CODE ###

import itertools, math

n, k = input().split()
nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()}
length = len(n)
coms = itertools.product(nums, repeat=length)
n = int(n)
ans = float("inf")
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)

coms = itertools.product(nums, repeat=length+1)
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)
print(ans)
# ABC045
from collections import deque
S_A = deque(input())
S_B = deque(input())
S_C = deque(input())

next_turn = S_A.pop()

while True:
    if next_turn == 'a':
        next_turn = S_A.pop()
    elif next_turn == 'b':
        next_turn = S_B.pop()
    else:
        next_turn = S_C.pop()

    # 勝利判定
    if len(S_A) == 0:
        print("A")
        exit()
    elif len(S_B) == 0:
        print("B")
        exit()
    elif len(S_C) == 0:
        print("C")
        exit()
    else:
        pass


### FIXED CODE ###

# ABC045
from collections import deque
S_A = deque(input())
S_B = deque(input())
S_C = deque(input())

# 最初はAから
next_turn = 'a'

while True:
    # 勝利判定
    if len(S_A) == 0 and next_turn == 'a':
        print("A")
        exit()
    elif len(S_B) == 0 and next_turn == 'b':
        print("B")
        exit()
    elif len(S_C) == 0 and next_turn == 'c':
        print("C")
        exit()
    else:
        if next_turn == 'a':
            next_turn = S_A.popleft()
        elif next_turn == 'b':
            next_turn = S_B.popleft()
        elif next_turn == 'c':
            next_turn = S_C.popleft()
import sys
import math
from collections import deque
import copy

input = sys.stdin.readline

s = input()
t = input()

dp = [[0 for _ in range(len(s) + 10)] for _ in range(len(s) + 10)]

for i in range(1, len(s)):
    for l in range(1, len(t)):
        if s[i - 1] == t[l - 1]:
            dp[i][l] = max(max(dp[i - 1][l - 1] + 1, dp[i][l - 1]), dp[i - 1][l])
        else:
            dp[i][l] = max(dp[i][l - 1], dp[i - 1][l])
length = dp[len(s) - 1][len(t) - 1]
if length == 0:
    print("")
else:
    ans = ' '
    i = len(s) - 1
    l = len(t) - 1
    while i > 0 and l > 0:
        if dp[i][l] == dp[i - 1][l - 1] + 1:
            ans = s[i - 1] + ans
            i -= 1
            l -= 1
        elif dp[i-1][l] == dp[i][l]:
            i -= 1
        elif dp[i][l-1] == dp[i][l]:
            l -= 1
    print(ans)


### FIXED CODE ###

import sys
import math
from collections import deque
import copy

input = sys.stdin.readline

s = input()
t = input()

dp = [[0 for _ in range(len(t) + 10)] for _ in range(len(s) + 10)]

for i in range(1, len(s)):
    for l in range(1, len(t)):
        if s[i - 1] == t[l - 1]:
            dp[i][l] = max(max(dp[i - 1][l - 1] + 1, dp[i][l - 1]), dp[i - 1][l])
        else:
            dp[i][l] = max(dp[i][l - 1], dp[i - 1][l])
length = dp[len(s) - 1][len(t) - 1]
if length == 0:
    print("")
else:
    ans = ''
    i = len(s) - 1
    l = len(t) - 1
    while i > 0 and l > 0:
        if dp[i-1][l] == dp[i][l] and i >= 1:
            i -= 1
        elif dp[i][l-1] == dp[i][l] and l >= 1:
            l -= 1
        else:
            ans = s[i - 1] + ans
            i -= 1
            l -= 1
    print(ans)
list = []

for i in range(3):
    list.append(int(input()))

area = (list[0]+list[1])*list[2]/2)


print(int(area))

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())

def area():
    return (a+b)*h/2

print(int(area()))
N, M = map(int, input().split())
ad_list = {}
for i in range(M):
  a, b = map(int, input().split())
  if a in ad_list:
    ad_list[a].add(b)
  else:
    ad_list[a] = {b}
  if b in ad_list:
    ad_list[b].add(a)
  else:
    ad_list[b] = {a}

#BFS
ans = 0
done = [True for i in range(N+1)]

def dfs(x):
  global done
  global tmp
  for y in ad_list[x]:
    if done[y]:
      done[y] = False
      tmp += 1
      dfs(y)
      
for i in range(1, N+1):
  if done[i]:
    done[i] = False
    tmp = 1
    if i in ad_list:
        dfs(i)
    ans = max(ans, tmp)

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
ad_list = {}
for i in range(M):
  a, b = map(int, input().split())
  if a in ad_list:
    ad_list[a].add(b)
  else:
    ad_list[a] = {b}
  if b in ad_list:
    ad_list[b].add(a)
  else:
    ad_list[b] = {a}

#BFS
ans = 0
done = [True for i in range(N+1)]

import queue
q = queue.Queue()

for i in range(1, N+1):
  if done[i]:
    done[i] = False
    tmp = 1
    if i in ad_list:
      q.put(i)
      while not q.empty():
        x = q.get()
        for y in ad_list[x]:
          if done[y]:
            tmp += 1
            done[y] = False
            q.put(y)
    ans = max(ans, tmp)

print(ans)
N, Y = map(int, input().split())
if(Y > 10000 * N):
  print(-1, -1, -1)
  exit()
for a in N:
  for b in (N - a):
	if(Y == (10000 * a + 5000 * b + 1000 * (N - a - b))):
    	print(a, b, N - a - b)


### FIXED CODE ###

in_n, in_cond = map(int, input().split())
def hoge(n, cond):
    for i in range(n+1):
        for j in range(n + 1 -i):
            if(10000 * i + 5000 * j + 1000 * (n - i - j) == cond):
                return [str(i), str(j), str(n - i - j)]
    return ["-1","-1","-1"]
print(" ".join(hoge(in_n, in_cond)))
HW = [int(i) for i in input().split()]
hw = [int(i) for i in input().split()]

print((HW[0] - hw[0])(HW[1] - hw[1]))

### FIXED CODE ###

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

print((HW[0] - hw[0])*(HW[1] - hw[1]))
N,M = map(int,input().split())
Ls = []
Lp = []
for i in range(N):
    a,b = map(int,input().split())
    Ls.append(a)
    Ls.append(b)
for m in range(M):
    c,d = map(int,input().split())
    Lp.append(c)
    Lp.append(d)
for i in range(N):
    dis = []
    for m in range(M):
        dis.append(abs(Ls[i][0]-Lp[m][0])+abs(Ls[i][1]-Lp[m][1]))
    print(dis.index(min(dis))+1)

### FIXED CODE ###

#ABC057.B
N,M = map(int,input().split())
L1 = []
L2 = []

for i in range(N):
    a,b = map(int,input().split())
    L1.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    L2.append([c,d])

for j in range(N):
    L3 = []
    for l in range(M):
        L3.append(abs(L1[j][0]-L2[l][0]) + abs(L1[j][1]-L2[l][1]))
    print(L3.index(min(L3))+1)
# -*- coding: utf-8 -*-
bigALlist = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
smoALlist = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
while True:
    try:
        text = list(input())
        for j in range(len(bigALlist)):
            for i in text:
                if (bigALlist[j] in i) or (smoALlist[j] in i):
                    cnt[j] = cnt + 1
            print('{0} : {1}'.format(smoALlist[j],cnt))
    except EOFError:
        break


### FIXED CODE ###

# -*- coding: utf-8 -*-
bigALlist = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
smoALlist = list('abcdefghijklmnopqrstuvwxyz')
cnt = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
while True:
    try:
        text = list(input())
        for j in range(len(bigALlist)):
            for i in text:
                if (bigALlist[j] in i) or (smoALlist[j] in i):
                    cnt[j] = cnt[j] + 1
    except EOFError:
        break
for j in range(len(bigALlist)):
    print('{0} : {1}'.format(smoALlist[j],cnt[j]))
import math

def lcm (a, b):
    return a // math.gcd (a, b) * b

n, ts = int(input()), []
for i in range (n):
    ts.append (int (input ()))

ans = 1
for i in range (n):
    ans = lcm (ans, ts[i])

print (ans)

### FIXED CODE ###

from fractions import gcd

def lcm (a, b):
    return a // gcd (a, b) * b

n, ts = int (input ()), []
for i in range (n):
    ts.append (int (input ()))

ans = 1
for i in range (n):
    ans = lcm (ans, ts[i])

print (ans)
n=int(input())
print((int((n-1)*n)/2))

### FIXED CODE ###

s=input()
t=input()
a=0
for i in range(3):
  if s[i]==t[i]:
    a+=1
print(a)
s = input()
print(s[:4]+" "+s[4:]

### FIXED CODE ###

s = input()
print(s[:4]+" "+s[4:])
# -*- coding: utf-8 -*-
n = int(input())
h = reversed(list(map(int, input().split())))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')


### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
h = list(reversed(list(map(int, input().split()))))

cnt = 0
for i in range(n-1):
    if h[i+1] - h[i] > 1:
        print('No')
        exit(0)
    elif h[i+1] - h[i] == 1:
        h[i+1] -= 1

print('Yes')
print(-~(int(input()//2))

### FIXED CODE ###

from math import ceil
print(ceil(int(input())/2))
a, b, c = map(int, input().split())

count = 1

for i in range(a, b+1):
   if c%i = 0:
      count += 1

print(count)


### FIXED CODE ###

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

count = 0

for i in range(a, b+1):
   if c % i == 0:
      count += 1

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

print(N**2-A)

### FIXED CODE ###

N = int(input())
A = int(input())

print(N**2-A)
N,K = map(int,input().split())
A = list(map(int,input().split()))

A = [A[i] for i in range(N) if A[i]!=0]
c = (N+len(A)-1)*(N-len(A))
N = len(A)
A.sort()
B = A[::-1]

def count(m):
    res = 0
    if m>=0:
        res += c
        j = N
        for i in range(N):
            if A[i]>0:
                break
            while j>0:
                if A[i]*A[j-1]<=m:
                    j -= 1
                else:
                    break
            res += N-j
        if A[i]>0:
            j = N-1
            for i in range(i,N):
                while j>=0:
                    if A[i]*A[j]>m:
                        j -= 1
                    else:
                        break
                res += j+1
    else:
        j = N
        for i in range(N):
            if B[i]<0:
                break
            while j>0:
                if B[i]*B[j-1]<=m:
                    j -= 1
                else:
                    break
            res += N-j
        if B[i]<0:
            j = -1
            for i in range(i,N):
                while j<N-1:
                    if B[i]*B[j+1]<=m:
                        j += 1
                    else:
                        break
                res += j+1
    for i in range(N):
        if A[i]*A[i]<=m:
            res -= 1
    res //= 2
    return res

ng = -10**18
ok = 10**18
m = (ng+ok)//2
for n in range(100):
    if count(m)<K:
        ng = m
    else:
        ok = m
    m = (ng+ok)//2
ans = int(ok)
print(ans)

### FIXED CODE ###

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

A = [A[i] for i in range(N) if A[i]!=0]
c = (N+len(A)-1)*(N-len(A))
N = len(A)
A.sort()
B = A[::-1]

def count(m):
    res = 0
    if m>=0:
        res += c
        j = N
        for i in range(N):
            if A[i]>0:
                break
            while j>0:
                if A[i]*A[j-1]<=m:
                    j -= 1
                else:
                    break
            res += N-j
        if A[i]>0:
            j = N-1
            for i in range(i,N):
                while j>=0:
                    if A[i]*A[j]>m:
                        j -= 1
                    else:
                        break
                res += j+1
    else:
        j = 0
        for i in range(N):
            if B[i]<0:
                break
            while j<N:
                if B[i]*B[j]>m:
                    j += 1
                else:
                    break
            res += N-j
        if B[i]<0:
            j = -1
            for i in range(i,N):
                while j<N-1:
                    if B[i]*B[j+1]<=m:
                        j += 1
                    else:
                        break
                res += j+1
    for i in range(N):
        if A[i]*A[i]<=m:
            res -= 1
    res //= 2
    return res

ng = -10**18
ok = 10**18
m = (ng+ok)//2
if N==0:
    ans = 0
else:
    for n in range(100):
        if count(m)<K:
            ng = m
        else:
            ok = m
        m = (ng+ok)//2
    ans = int(ok)
print(ans)
N = int(input())
alist = []
for _ in range(N):
    alist.append(int(input()))
i = 1
for _ in range(N):
    i = alist[i - 1]
    if i == 2:
        print(len(history))
        break
else:
    print(-1)

### FIXED CODE ###

N = int(input())
alist = []
for _ in range(N):
    alist.append(int(input()))
i = 1
for n in range(N):
    i = alist[i - 1]
    if i == 2:
        print(n + 1)
        break
else:
    print(-1)
import math
x1, y1, x2, y2 = map(int, input().split())
print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))

### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, input().split())
print(math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2))
N = int(input())
abc=[]
for _ in range(N-1):
    abc.append(tuple(map(int, input().split())))
Q, K = map(int, input().split())
xy=[]
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))
#print(abc)
#print(xy)

G = [[] for _ in range(N+1)]
for el in abc:
    a,b,c = el
    G[a].append((b,c))
    G[b].append((a,c))
#print(G)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for el in G[n]:
        if seen[el[0]] == False:
            distance[el[0]] = distance[n] + el[1]
            dfs(el[0])
dfs(K)
#print(distance)

for q in xy:
    print(distance[q[0]]+distance[q[1]])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)


N = int(input())
abc=[]
for _ in range(N-1):
    abc.append(tuple(map(int, input().split())))
Q, K = map(int, input().split())
xy=[]
for _ in range(Q):
    xy.append(tuple(map(int, input().split())))
#print(abc)
#print(xy)

G = [[] for _ in range(N+1)]
for el in abc:
    a,b,c = el
    G[a].append((b,c))
    G[b].append((a,c))
#print(G)

seen=[False]*(N+1)
distance=[0]*(N+1)
def dfs(n):
    seen[n]=True
    for el in G[n]:
        if seen[el[0]] == False:
            distance[el[0]] = distance[n] + el[1]
            dfs(el[0])
dfs(K)
#print(distance)

for q in xy:
    print(distance[q[0]]+distance[q[1]])
from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()

    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)

    ans = 0
    minIndex = 0
    isFinished = False

    for b,c in bcs:

        for _ in range(b):
            if cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break

    ans += sum(cards[minIndex:])

    print(ans)
    
if __name__=='__main__':
    main()

### FIXED CODE ###

from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()

    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)

    ans = 0
    minIndex = 0
    isFinished = False

    for b,c in bcs:

        for _ in range(b):
            if minIndex < n and cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break

    if minIndex < n:
        ans += sum(cards[minIndex:])

    print(ans)
    
if __name__=='__main__':
    main()
k = int(input())
x = int(input())
li = [str(2*k-1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)

### FIXED CODE ###

k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)
from math import ceil


def dfs(i, sum, count, residue):
    global ans
    if i == d:
        if sum < g:
            use = max(residue)
            n = min(pc[use - 1][0], ceil((g - sum) / (use * 100)))
            count += n
            sum += n * use * 100

        if g <= sum:
            ans = min(ans, count)

    else:
        dfs(i + 1, sum, count, residue)
        dfs(i + 1, sum + pc[i][0] * (i + 1) * 100 + pc[i][1], count + pc[i][0], residue - {i + 1})


d, g = map(int, input().split())

pc = [list(map(int, input().split())) for _ in range(d)]

ans = float('inf')

dfs(0, 0, 0, set(range(1, d + 1)))
print(ans)


### FIXED CODE ###

def dfs(i, f, result):
    if i == l - 1:
        if result == 7:
            print(f + '=7')
            exit()
    else:
        dfs(i + 1, f + '-' + s[i + 1], result - int(s[i + 1]))
        dfs(i + 1, f + '+' + s[i + 1], result + int(s[i + 1]))


s = input()
l = len(s)

dfs(0, s[0], int(s[0]))
S = input()

if S == "SAT":
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)


### FIXED CODE ###

S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)
N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return str(bin(x)).count("1")

pl=a%(popcount(a)+1)
if popcount!=1:
  mi=a%(popcount(a)-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,popcount(a)+1)
    b%=popcount(a)+1
  else:
    if popcount(a)-1!=0:
      b=mi
      b-=pow(2,N-i-1,popcount(a)-1)
      b%=popcount(a)-1
    else:
      print(0)
      continue
  print(f(b))

### FIXED CODE ###

N=int(input())
X=input()
a=int(X,2)

def popcount(x):
  return bin(x).count("1")
p=X.count('1')

pl=a%(p+1)
if p!=1:
  mi=a%(p-1)

def f(x):
  if x==0:
    return 1
  else:
    return f(x%popcount(x))+1

for i in range(N):
  if X[i]=='0':
    b=pl
    b+=pow(2,N-i-1,p+1)
    b%=p+1
  else:
    if p!=1:
      b=mi
      b-=pow(2,N-i-1,p-1)
      b%=p-1
    else:
      print(0)
      continue
  print(f(b))
b=input()
if b='A':c='T'
if b='T':c='A'
if b='C':c='G'
if b='G':c='C'
print(c)

### FIXED CODE ###

b=input()
if b=='A':c='T'
if b=='T':c='A'
if b=='C':c='G'
if b=='G':c='C'
print(c)
n,k = map(int, input().split())
flag = [1 for i in range(n)]
for _ in range(k):
  d = int(input())
  for _ in range(d):
    for a in map(int, input().split()):
      flag[a-1] = 0
print(sum(flag))

### FIXED CODE ###

n,k = map(int, input().split())
flag = [1 for i in range(n)]
for _ in range(k):
  d = int(input())
  for a in map(int, input().split()):
      flag[a-1] = 0
print(sum(flag))
while True:
    a = list(map(int, (input().split())))
    a = sorted(a, reverse=True)
    for i in range(4): print(a[i],end=' ')
    print(a[4])


### FIXED CODE ###

a = list(map(int, (input().split())))
a = sorted(a, reverse=True)
for i in range(4): print(a[i],end=' ')
print(a[4])