Harryxun/stf_run huggingface dataset:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,*a=map(int,read().split())
	
	aa=max(a)
	
	li=[[] for _ in range(aa+1)]
	
	for i in range(n):
		li[a[i]].append(i)
	
	ans=3 if len(li[0])==1 else 6
	
	
	
	for i in range(1,aa+1):
		k=bisect.bisect_left(li[i-1],li[i][0])
		ans*=k
		ans%=MOD
		
		if len(li[i])>1:
			k=bisect.bisect_left(li[i-1],li[i][1])-1
			ans *= k
			ans %= MOD
		
	print(ans)
	
	
if __name__ == "__main__":
		main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,*a=map(int,read().split())
	
	aa=max(a)
	
	li=[[] for _ in range(aa+1)]
	
	for i in range(n):
		li[a[i]].append(i)
	
	if len(li[0])>3 or len(li[0])==0:
		print(0)
		exit(0)
	else:
		ans=3 if len(li[0])==1 else 6
	for i in range(1,aa+1):
		if len(li[i])>3 or len(li[i])==0 or len(li[i])>len(li[i-1]):
			print(0)
			exit(0)
		else:
			k=bisect.bisect_right(li[i-1],li[i][0])
			ans*=k
			ans%=MOD
			
			if len(li[i])>1:
				k=bisect.bisect_right(li[i-1],li[i][1])-1
				ans *= k
				ans %= MOD
		
	print(ans)
	
	
if __name__ == "__main__":
		main()
from collections import defaultdict
n, x, m = map(int, input().split())
now = x
ans = x
d = defaultdict(int)
repeat = []

for i in range(n):
    now = (now**2)%m
    d[now] += 1
    repeat.append(now)
    if d[now] > 1:
        break

for g in range(len(repeat)):
    if repeat[g] == now:
        break
    else:
        ans += repeat[g]
        n -= 1
repeat = repeat[g:-1] 
n -= 1

ans += sum(repeat)*(n//len(repeat)) + sum(repeat[:n%len(repeat)])
print(ans)

### FIXED CODE ###

from collections import defaultdict
n, x, m = map(int, input().split())
now = x
ans = x
d = defaultdict(int)
repeat = []

for i in range(n):
    now = (now**2)%m
    d[now] += 1
    repeat.append(now)
    if d[now] > 1:
        break

for g in range(len(repeat)):
    if repeat[g] == now:
        break
    else:
        ans += repeat[g]
        n -= 1

repeat = repeat[g:-1] 
n -= 1
if len(repeat) != 0:
    ans += sum(repeat)*(n//len(repeat)) + sum(repeat[:n%len(repeat)])
print(ans)
if set(input().split())==aet([1,9,7,4]):
  print("Yes")
else:
  print("No")  

### FIXED CODE ###

if set(input().split())==set("1974"):
	print("YES")
else:
	print("NO")
a,b,c=input().split()
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min([s[0],s[1],s[2]]))

### FIXED CODE ###

a,b,c=input().split()
s=[0,0,0]
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s))
from collections import Counter
n = int(input())
A = Counter(input())
B = Counter(input())
C = Counter(input())
ans = ""
for key,value in A.items():
  ans.append(str(key)*min(value,B[key],C[key]))
print(sorted(ans))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=Counter(input())
for i in range(n-1):
    s&=Counter(input())
print("".join(sorted(s.elements())))
a,b,c = map(int, input().split())
if a>b:
    temp = a
    a = b
    b = temp

if b>c:
    temp = b
    b = c
    c = temp


if (a+b)==c:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# import time

# starttime=time.clock()

A,B,C =input().split()
a=int(A)
b=int(B)
c=int(C)
# print(a+c)
 
if a>b:
    temp = a
    a = b
    b = temp
if b>c:
    temp = b
    b = c
    c = temp
if (a+b)==c:
    print("Yes")
#     endtime = time.clock()
#     print(endtime-starttime)
else:
    print("No")
#     endtime = time.clock()
#     print(endtime-starttime)
#
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
    if p[i] == i+1:
        p[i],p[i+1] = p[i+1],p[i]
        ans += 1
print(ans) 

### FIXED CODE ###

N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
    if p[i] == i+1:
        try:
            p[i+1],p[i] = p[i],p[i+1]
        except:
            pass
        ans += 1

print(ans)
a=input()
b=input()
print(2*b-a)

### FIXED CODE ###

a=int(input())
b=int(input())
print(2*b-a)
s, ans = raw_input(), 0
for i in range(len(s) - 1):
    if (len(set(s[i : i + 2))) == 2):
        ans += 1
print ans

### FIXED CODE ###

s, ans = raw_input(), 0
for i in range(len(s) - 1):
    if (len(set(s[i : i + 2])) == 2):
        ans += 1
print ans
import numpy as np

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

p=np.sum(A>0)
q=np.sum(A<0)
Z=N-p-q
AP=A[-p:]
if q>0:
  AN=A[:q]

b=(N-Z)*Z+Z*(Z-1)//2
a=p*q

if K<=a:
  x=AP[-1]*AN[0]-1
  y=AP[0]*AN[-1]
  while y-x>1:
    tmp=(y+x)//2
    counter=np.searchsorted(AN, tmp/AP, side='right').sum()
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
elif K<=a+b:
  print(0)
else:
  K=K-a-b
  x=0
  y=10**18
  AN=AN[::-1]
  AN=-AN
  while y-x>1:
    tmp=(y+x)//2
    counter1=(np.searchsorted(AP, tmp//AP, side='right').sum()-np.searchsorted(AP, pow(tmp, 1/2), side='right'))//2
    counter2=(np.searchsorted(AN, tmp//AN, side='right').sum()-np.searchsorted(AN, pow(tmp, 1/2), side='right'))//2
    counter=counter1+counter2
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)

### FIXED CODE ###

import numpy as np

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

p=np.sum(A>0)
q=np.sum(A<0)
Z=N-p-q
if p>0:
  AP=A[-p:]
else:
  AP=[]
if q>0:
  AN=A[:q]
else:
  AN=[]

b=(N-Z)*Z+Z*(Z-1)//2
a=p*q

if K<=a:
  x=AP[-1]*AN[0]-1
  y=AP[0]*AN[-1]
  while y-x>1:
    tmp=(y+x)//2
    counter=np.searchsorted(AN, tmp//AP, side='right').sum()
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
elif K<=a+b:
  print(0)
else:
  x=0
  y=10**18
  K=K-a-b
  if q<=1:
    while y-x>1:
      tmp=(y+x)//2
      counter=(np.searchsorted(AP, tmp//AP, side='right').sum()-np.searchsorted(AP, int(pow(tmp, 1/2)), side='right'))//2
      if counter<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  AN=AN[::-1]
  AN=-AN
  
  if p<=1:
    while y-x>1:
      tmp=(y+x)//2
      counter=(np.searchsorted(AN, tmp//AN, side='right').sum()-np.searchsorted(AN, int(pow(tmp, 1/2)), side='right'))//2
      if counter<K:
        x=tmp
      else:
        y=tmp
    print(y)
    exit()
    
  while y-x>1:
    tmp=(y+x)//2
    counter1=(np.searchsorted(AP, tmp//AP, side='right').sum()-np.searchsorted(AP, int(pow(tmp, 1/2)), side='right'))//2
    counter2=(np.searchsorted(AN, tmp//AN, side='right').sum()-np.searchsorted(AN, int(pow(tmp, 1/2)), side='right'))//2
    counter=counter1+counter2
    if counter<K:
      x=tmp
    else:
      y=tmp
  print(y)
import sys
from bisect import bisect_left, bisect_right, insort
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = '-' + sr()
d = defaultdict(list)
for i in range(1, N+1):
    s = S[i]
    insort(d[s], i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = S[a]
        d[prev].remove(a)
        insort(d[b], a)
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in d:
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)

# 17

### FIXED CODE ###

import sys
from bisect import bisect_left, bisect_right, insort

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = list('-' + sr())
d = [[] for _ in range(26)]
for i in range(1, N+1):
    s = S[i]
    o = ord(s) - ord('a')
    insort(d[o], i)

Q = ir()
for _ in range(Q):
    q, a, b = sr().split()
    if q == '1':
        a = int(a)
        if S[a] == b:
            continue
        prev = ord(S[a]) - ord('a')
        d[prev].remove(a)
        next = ord(b) - ord('a')
        insort(d[next], a)
        S[a] = b
    else:
        a = int(a); b = int(b)
        ans = 0
        for alpha in range(26):
            if bisect_right(d[alpha], b) - bisect_left(d[alpha], a) >= 1:
                ans += 1
        print(ans)

# 17
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N,M = [int(n) for n in input().split()]
    jobs = [[] for _ in range(10000)]
    v = 0
    for i in range(N):
        a,b = [int(n) for n in input().split()]
        if a <= M:
            jobs[b].append((a,b))
            v = max(v,b)
    jobs = jobs[:v+1]
    # 時間でソート(昇順)
    for i in range(v):
        jobs[i] = sorted(jobs[i])

    # debug(jobs, "(期限、価値) in [価値]")
    ans = 0
    jobs_k = len(jobs)-1

    for i in range(jobs_k,-1,-1):
        while(len(jobs[i]) != 0 and jobs[i][-1][0] <= M):
            ans+=jobs[i][-1][1]
            M-=1
            jobs[i].pop()
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import exit, stderr, stdin
input = stdin.readline
import heapq
# from collections import defaultdict
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    N,M = [int(n) for n in input().split()]
    # {期限:価値}
    jobs = [[]]*N
    v = 0
    for i in range(N):
        jobs[i] = [int(n) for n in input().split()]
    # 価値降順→期間昇順
    jobs = sorted(jobs,key=lambda x:-x[1])
    jobs = sorted(jobs,key=lambda x:x[0])
    cur = 0
    ans = 0
    cand = []
    for i in range(1,M+1):
        while(cur < N and i >= jobs[cur][0]):
            heapq.heappush(cand,-jobs[cur][1])
            cur += 1
        if len(cand) != 0:
            ans -= cand[0]
            heapq.heappop(cand)
    print(ans)



if __name__ == "__main__":
    main()
K = int(input())

if K < 10:
  print(K)
else:
  count = 9

queue = [1,2,3,4,5,6,7,8,9]

while count != K:
  for x in queue:
    if x%10 != 0:
      queue.append(10*x + (x%10) - 1)
      count += 1
      if count == K:
        break

    queue.append(10*x + (x%10))
    count += 1
    if count == K:
      break

    if x%10 != 9:
      queue.append(10*x + (x%10) + 1)
      count += 1
      if count == K:
        break

print(queue[-1])


### FIXED CODE ###

K = int(input())

if K < 10:
  queue = range(1,K+1)
  count = K
else:
  count = 9
  queue = [1,2,3,4,5,6,7,8,9]

while count != K:
  for x in queue:
    if x%10 != 0:
      queue.append(10*x + (x%10) - 1)
      count += 1
      if count == K:
        break

    queue.append(10*x + (x%10))
    count += 1
    if count == K:
      break

    if x%10 != 9:
      queue.append(10*x + (x%10) + 1)
      count += 1
      if count == K:
        break

print(queue[-1])
from math import 8
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)		


### FIXED CODE ###

from math import *
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)
S = input()
if S = "hi"*int(len(S)//2):
    print("Yes")
else:
    print("No")    

### FIXED CODE ###

S = input()
if S == "hi"*int(len(S)//2):
    print("Yes")
else:
    print("No")
# coding: utf-8
# Your code here!
from math import gcd
 
N,M=map(int,input().split())

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

if N==1:
    print(0)
    exit()

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//gcd(A[i],A[i+1])

#print(A[-1])
if A[-1]%2==1 or (A[-1]//2)%2==0:
    print(0)
else:
    print((M-A[-1]//2)//A[-1]+1)

### FIXED CODE ###

# coding: utf-8
# Your code here!
import fractions

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

have2=[0]*len(A)

for index,item in enumerate(A):
    while item%2==0:
        item/=2
        have2[index]+=1

if len(list(set(have2)))!=1:
    print(0)
    exit()

f=0
f2=1
for item in A:
    f=fractions.gcd(f2,item)
    f2=f2*item//f
if M>=f2//2:
    M-=f2//2
    print(max(M//f2+1,0))
else:
    print(0)
n = list(map(int,input()))
n.sorted()
if n[0] + n[1] == n[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = list(map(int,input().split()))
n.sort()
if n[0] + n[1] == n[2]:
    print("Yes")
else:
    print("No")
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]

l1=[]
l2=[]
l3=[]
for i in range(m):
    if s[i][0]==1:
        l1.append(s[i])
    elif s[i][0]==2:
        l2.append(s[i])
    elif s[i][0]==3:
        l3.append(s[i])
l1=list(map(list, set(map(tuple, l1))))
l2=list(map(list, set(map(tuple, l2))))
l3=list(map(list, set(map(tuple, l3))))

check=0
if len(l1)>1 or len(l2)>1 or len(l3)>1:#同じ桁に違う数
    check+=1
if n==3 or n==2:
    if len(l1)>0 and l1[0][1]==0:#二桁三桁の時最初が０
        check+=1

if n==3:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
    if len(l3)==0:
        l3.append([3,0])
if n==2:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
if n==1:
    if len(l1)==0:
        l1.append([1,0])

if check>=1:
    print(-1)
else:
    ans=[]
    ans.append(l1[0][1])
    ans.append(l2[0][1])
    ans.append(l3[0][1])
    print(int("".join(map(str,ans))))

### FIXED CODE ###

n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]

l1=[]
l2=[]
l3=[]
for i in range(m):
    if s[i][0]==1:
        l1.append(s[i])
    elif s[i][0]==2:
        l2.append(s[i])
    elif s[i][0]==3:
        l3.append(s[i])
l1=list(map(list, set(map(tuple, l1))))
l2=list(map(list, set(map(tuple, l2))))
l3=list(map(list, set(map(tuple, l3))))

check=0
if len(l1)>1 or len(l2)>1 or len(l3)>1:#同じ桁に違う数
    check+=1
if n==3 or n==2:
    if len(l1)>0 and l1[0][1]==0:#二桁三桁の時最初が０
        check+=1

if n==3:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
    if len(l3)==0:
        l3.append([3,0])
if n==2:
    if len(l1)==0:
        l1.append([1,1])
    if len(l2)==0:
        l2.append([2,0])
if n==1:
    if len(l1)==0:
        l1.append([1,0])

if check>=1:
    print(-1)
else:
    ans=[]
    if len(l1)>0:
        ans.append(l1[0][1])
    if len(l2)>0:
        ans.append(l2[0][1])
    if len(l3)>0:
        ans.append(l3[0][1])
    print(int("".join(map(str,ans))))
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin
from heapq import heappush, heappop


def main():
  ## input
  N,Q = map(int, stdin.readline().rstrip().split())
  STX = deque()
  for i in range(N):
    s,t,x = map(int, stdin.readline().rstrip().split())
    STX.append([x,s-x,t-x])
  Dn = [int(stdin.readline().rstrip()) for _ in range(Q)] + [10**10]
  ans = []

  for x,s,t in sorted(list(STX)):
    l = bisect_left(Dn,s)
    r = l
    while Dn[r] < t:
      heappush(ans, (Dn[r],x))
      r += 1
    del Dn[l:r]

  for d in Dn[:-1]:
    heappush(ans, (d,-1))

  return ans


if __name__ == "__main__":
  ans = main()
  n=len(ans)
  for _ in range(n):
    print(heappop(ans)[1])    


### FIXED CODE ###

import sys
from bisect import bisect_left



N,Q = map(int, input().split())
lines = sys.stdin.readlines()
kkk = []
for line in lines[:N]:
  s, t, x = map(int, line.split())
  kkk.append((x, s, t))
kkk.sort()
ddd = list(map(int, lines[N:]))

ans = [-1] * Q
skip = [-1] * Q
for x, s, t in kkk:
  ss = bisect_left(ddd, s - x)
  tt = bisect_left(ddd, t - x)
  while ss < tt:
    sk = skip[ss]
    if sk == -1:
      ans[ss] = x
      skip[ss] = tt
      ss += 1
    else:
      ss = sk

print('\n'.join(map(str, ans)))
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
w = [tuple(map(int, input().split()))for _ in range(m)]
w.sort(key=lambda x: x[1], reverse=True)
ans = 0
p, i = 0, 0
b, c = w[i][0], w[i][1]

while p < n and i < m:
    cur = a[p]
    if cur < c:
        b -= 1
        ans += c
    else:
        ans += cur
    if b == 0:
        i += 1
        b, c = w[i][0], w[i][1]
    p += 1

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
w = [tuple(map(int, input().split()))for _ in range(m)]
w.sort(key=lambda x: x[1], reverse=True)
ans = 0
p, i = 0, 0
b, c = w[i][0], w[i][1]
while p < n and i < m:
    cur = a[p]
    if cur < c:
        b -= 1
        ans += c
    else:
        ans += cur
    if b == 0:
        i += 1
        if i == m:
            ans += sum(a[p+1:])
            break
        b, c = w[i][0], w[i][1]
    p += 1
print(ans)
A,B = map(int,input().split())
sum = 1
if A >= B:
  print(0)
else:
  for i in range(1,A+1):
    sum = sum + A -1
    if sum >= B:
      break
print(i)

### FIXED CODE ###

A,B = map(int,input().split())
sum = 1
c = 0
if B == 1:
  print(0)
else:
  while sum < B:
    sum = sum + A -1
    c += 1
  print(c)
import sys
from collections import defaultdict

cnt = [0] * 3 * 10 ** 5


def dfs(tree, p):
    global cnt
    for c in tree[p]:
        cnt[c] += cnt[p]
        dfs(tree, c)


def main():
    input = sys.stdin.buffer.readline
    n, q = map(int, input().split())
    tree = defaultdict(list)
    for _ in range(n - 1):
        a, b = map(int, input().split())
        tree[a].append(b)

    # cnt = [0] * (n + 1)
    global cnt
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x

    dfs(tree, 1)
    print(*cnt[1 : n + 1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import defaultdict


def dfs(tree, p, cnt, visited):
    visited[p] = True
    cnt_here = cnt[p]
    for c in tree.get(p):
        if visited[c]:
            continue
        cnt[c] += cnt_here
        dfs(tree, c, cnt, visited)


def main():
    input = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 9)
    n, q = map(int, input().split())
    tree = defaultdict(list)
    for _ in range(n - 1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    tree = dict(tree)
    cnt = [0] * (n + 1)

    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p] += x
    visited = [False] * (n + 1)
    dfs(tree, 1, cnt, visited)
    print(*cnt[1:])


if __name__ == "__main__":
    main()
n = int(input())
X = input()
x = int(X,2)
bitx = bin(x).count('1')
 
ans = [0]*(bitx+2)
for i in range(1,bitx+2):
    ans[i] = 1 + ans[i%bin(i).count('1')]
#print(ans)
l = []
bitp = bitx + 1
bitm = bitx - 1
xmp = 0
xmm = 0
for i in range(n):
    if X[i] == '1':
        xmp += pow(2, n-(i+1), bitp)
        xmm += pow(2, n-(i+1), bitm)
if bitx != 1:
    for i in range(n):
        if X[i] == '1':
            xm = (xmm - pow(2,n-i-1)) % bitm
            l.append(str(1+ans[xm]))
        else:
            xm = (xmp + pow(2,n-i-1))%bitp
            l.append(str(1+ans[xm]))

else:
    for i in range(n):
        if X[i] == '1':
            l.append(str(0))
        else:
            xm = (xmp + pow(2,n-i-1))%bitp
            l.append(str(1+ans[xm]))

print('\n'.join(l))



### FIXED CODE ###

n = int(input())
X = input()
x = int(X,2)
bitx = bin(x).count('1')
 
ans = [0]*(bitx+2)
for i in range(1,bitx+2):
    ans[i] = 1 + ans[i%bin(i).count('1')]
#print(ans)
l = []
bitp = bitx + 1
bitm = bitx - 1
xmp = 0
xmm = 0


if bitx != 1:
    for i in range(n):
        if X[i] == '1':
            xmp += pow(2, n-(i+1), bitp)
            xmm += pow(2, n-(i+1), bitm)
    for i in range(n):
        if X[i] == '1':
            xm = (xmm - pow(2,n-i-1,bitm)) % bitm
            l.append(str(1+ans[xm]))
        else:
            xm = (xmp + pow(2,n-i-1,bitp))%bitp
            l.append(str(1+ans[xm]))
 
else:
    for i in range(n):
        if X[i] == '1':
            xmp += pow(2, n-(i+1), bitp)
    for i in range(n):
        if X[i] == '1':
            l.append(str(0))
        else:
            xm = (xmp + pow(2,n-i-1,bitp))%bitp
            l.append(str(1+ans[xm]))
 
print('\n'.join(l))
n=int(input())
l=int(input())
ans=0
for i in range(0,len(l)):
    for j in range(i+1,len(l)):
        for k in range(j+1,len(l)):
            if l[i]>=l[j] and l[i]>=l[k]:
                if l[i]>l[j]+l[k]:
                    ans+=1
                else:
                    ans+=0
            if l[j]>=l[i] and l[j]>=l[k]:
                if l[j]>l[i]+l[k]:
                    ans+=1
                else:
                    ans+=0
            if l[k]>=l[i] and l[k]>=l[j]:
                if l[k]>l[i]+l[j]:
                    ans+=1
                else:
                    ans+=0   
print(ans)       

### FIXED CODE ###

import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(0,n-1):
  for j in range(i+1,n):
    x=l[i]+l[j]
    y=bisect.bisect_left(l,x)-1
    ans+=max((y-j),0)
    
print(ans)
a,b,c,d=map(int,input().spilt())
if a+b==c+d:
    print("Balanced")
elif (a+b)>(c+d):
    print("Left")
else:
    print("Right")


### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a+b==c+d:
    print("Balanced")
elif a+b>c+d:
    print("Left")
elif a+b<c+d:
    print("Right")
while true:
  a, b = map(int, input().split())
  if a == 0 and b == 0:
      break
  for i in range(a):
      print('#' * b)
  print()

### FIXED CODE ###

while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    for i in range(a):
        print('#' * b)
    print()
N,R=map(int, input().split()) 

if N => 10
print(R)
else
print(R - 100*(10-N))

### FIXED CODE ###

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

if N >= 10:
  print(R)
else:
  print(R + 100*(10-N))
#C - Walking Takahashi

x, k, d = map(int, input().split())

p = abs(x)

if p/d < k:
  k = k - (p // d)
  p = p % d

  if k % 2 == 0:
    print(abs(p))
  elif p < 0:
    print(abs(p + d))
  else:
    print(abs(p - d))

elif x >= 0:
  print(abs(x - (k * d)))
else:
  print(abs(x + (k * d)))




### FIXED CODE ###

s = input()

if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)
n = int(input())
x_ = list(map(int,input().split()))

cnt = 0
res_ = []
for i in range(1,x_[n-1]):
    cnt = 0
    for j in range(len(x_)):
        cnt += (x_[j] - i)**2
    res_.append(cnt)
print(min(res_))


### FIXED CODE ###

n = int(input())
x_ = list(map(int,input().split()))

if n ==1:
    print(0)
else:
    cnt = 0
    res_ = []
    for i in range(100):
        cnt = 0
        for j in range(len(x_)):
            cnt += (x_[j] - i)**2
        res_.append(cnt)

    print(min(res_))