Harryxun/stf_run huggingface dataset:
import cmath
import math
n=int(input())
a=[]
b=[]
#偏角ソートの方が楽
for i in range(n):
    x,y=map(int,input().split())
    a.append(complex(x,y))
    b.append(cmath.phase(a[i]))
#a.sort(key=cmath.phase)
m=0
#math.piに注意
for i in range(n):
    za,zb=0,0
    if a[i]!=complex(0,0):
        for j in range(n):
            p=cmath.phase(a[j]/a[i])
            if -math.pi<=p<=0:
                za+=a[j]
            if 0<=p<=math.pi:
                zb+=a[j]
    m=max([abs(za),abs(zb),abs(za-a[i]),abs(zb-a[j]),m])
print(m)


### FIXED CODE ###

import cmath
import math
n=int(input())
a=[]
b=[]
#偏角ソートの方が楽
for i in range(n):
    x,y=map(int,input().split())
    a.append(complex(x,y))
    b.append(cmath.phase(a[i]))
#a.sort(key=cmath.phase)
ma=0
#math.piに注意
for i in range(n):
    z=a[i]
    c=b[i]-math.pi/2
    d=b[i]+math.pi/2
    l=max([c,-math.pi])
    r=min([d,math.pi])
    #(0,0)の時は偏角が0になってしまうし、除く
    #あとは-piとpiどっちになるか→piになる
    if a[i]!=complex(0,0):
        for j in range(n):
            if j!=i:
                #境界条件の場合分けがむずい
                if l<=b[j]<=r or (c<=-math.pi and c+2*math.pi<=b[j]<=math.pi) or (d>=math.pi and -math.pi<=b[j]<=d-2*math.pi):
                    z+=a[j]
    ma=max([abs(z),ma])
m=0
#math.piに注意
for i in range(n):
    if a[i]!=complex(0,0):
        za,zb=complex(0,0),complex(0,0)
        for j in range(n):
            p=cmath.phase(a[j]/a[i])
            if -math.pi<=p<=0:
                za+=a[j]
            if 0<=p<=math.pi:
                zb+=a[j]
        m=max([m,abs(za),abs(zb)])
        if i!=n-1 and a[i]+a[i+1]!=0:
            zc,zd=complex(0,0),complex(0,0)
            for j in range(n):
                p=cmath.phase(a[j]/((a[i]+a[i+1])/2))
                if -math.pi<=p<=0:
                    zc+=a[j]
                if 0<=p<=math.pi:
                    zd+=a[j]
            m=max([m,abs(zc),abs(zd)])

print(max([m,ma]))
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
h, w = map(int, input().split())
tmp = [None]*h
for i in range(w):
    tmp[i] = input()
# print(tmp)
for i in range(h):
    for j in range(w):
        if tmp[i][j] == '#':
            if (i != 0 and tmp[i-1][j] == '#')or(i != h-1 and tmp[i+1][j] == '#') or(j != 0 and tmp[i][j-1] == '#')or(j != w-1 and tmp[i][j+1] == '#'):
                continue

            print('No')
            exit()
print('Yes')


### FIXED CODE ###

import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

H, W = map(int, input().split())
s = [None]*H
for i in range(H):
    s[i] = input()
    # print(s[i])
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            #print(i, j)
            if (i != 0 and s[i-1][j] == '#') or(i != H-1 and s[i+1][j] == '#')or(j != 0 and s[i][j-1] == '#') or(j != W-1 and s[i][j+1] == '#'):
                continue
            else:
                print('No')
                exit()
print('Yes')
for i in range(input()):
	hex=raw_input()
	bit=""
	for j in b:
		bit+=format(int(j,16),"b").zfill(4)
	ans=0.0
	for i in range(1,32):
		ans+=int(bit[i])*2.0**(24-i)
	print (-1)**int(bit[0])*ans

### FIXED CODE ###

for i in range(input()):    
	b=int(raw_input(),16)
	s=1<<31
	p=""
	if b&s!=0:
		b^=s
		p="-"
	a=int(b*1.0/(1<<7))
	print p+str(a)+str(abs(b*1.0/(1<<7)-a))[1:]
import string
lc = string.ascii_lowercase
n = int(input())

lst = [0]
for i in range(1, 1000):
    tmp = pow(26, i)
    lst.append(tmp)
    if tmp > n:
        break
cum = [lst[0]]
for i in range(1, len(lst)):
    cum.append(cum[-1] + lst[i])
idx = 0
while True:
    if n-1 < cum[idx]:
        break
    idx += 1
num = n - lst[idx-1] - 1
ans = ''
for i in range(idx)[::-1]:
    tmp = pow(26, i)
    if num >= tmp:
        k = num // tmp
        num = num - 26*k
    else:
        k = num
    ans += lc[k]
print(ans)

### FIXED CODE ###

import string
lc = string.ascii_lowercase
n = int(input())

lst = [0]
for i in range(1, 100000):
    tmp = pow(26, i)
    lst.append(tmp)
    if tmp > n:
        break
cum = [lst[0]]
for i in range(1, len(lst)):
    cum.append(cum[-1] + lst[i])
idx = 0
while True:
    if n-1 < cum[idx]:
        break
    idx += 1
num = n - cum[idx-1] - 1
ans = ''
for i in range(idx)[::-1]:
    tmp = pow(26, i)
    k = num // tmp
    num = num - tmp *k
    ans += lc[k]
print(ans)
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))


for i in range(x, 0, -1):
  if not i in p:
    a1 = i
    break

for i in range(x, 100 + 2):
  if not i in p:
    a2 = i
    break

if x - a1 <= a2 - x:
  print(a1)
else:
  print(a2)


### FIXED CODE ###

x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

q = set(range(-1, 100 + 2)) - set(p)

f = []

for e in q:
  f.append((abs(e - x), e - x))

print(x + min(f)[1])
S = {}
S['a'] = input()
S['b'] = input()
S['c'] = input()


next = 'a'
lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])}
counts = {'a':0, 'b':0, 'c':0}

while True:
  now = next
  if counts[now] == lens[now]:
    print(now)
    exit()
  counts[now] += 1
  next = S[now][counts[now]]


### FIXED CODE ###

S = {}
S['a'] = input()
S['b'] = input()
S['c'] = input()


next = 'a'
lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])}
counts = {'a':0, 'b':0, 'c':0}

while True:
  now = next
  counts[now]
  if counts[now] == lens[now]:
    print(now.upper())
    exit()
  next = S[now][counts[now]]
  counts[now] += 1
if input() == "Sunny":
    print("Cloudy")
elif input() == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

### FIXED CODE ###

S = str(input())
if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    b = int(input())
    a.append(b)
d = [0 for i in range(n+1)]
d[0] = 1
d[1] = 1
d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
d.append(0)
ans = 1
if a[0] == 1:
    ans = 1
else:
    ans = ans*d[a[0]-1]%mod
for i in range(m-1):
    ans = ans*d[a[i+1]-a[i]-2]%mod
ans = ans*d[n-a[m-1]-1]%mod
print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = []
mod = 10**9+7
d = [0 for i in range(n+1)]
d[0] = 1
d[1] = 1
if n >1 :
    d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
if m != 0:
    d.append(0)
    for i in range(m):
        b = int(input())
        a.append(b)
    ans = 1
    if a[0] == 1:
        ans = 1
    else:
        ans = ans*d[a[0]-1]%mod
    for i in range(m-1):
        ans = ans*d[a[i+1]-a[i]-2]%mod
    ans = ans*d[n-a[m-1]-1]%mod
else:
    ans = d[n]%mod
print(ans)
import sys
sys.setrecursionlimit(100000)
def doritto(vrijednost):
    global kameni
    global memo
    if memo[vrijednost] != -1:
        return memo[vrijednost]
    if vrijednost == len(kameni) -2:
        return abs(kameni[vrijednost] - kameni[vrijednost+1])
    elif vrijednost == len(kameni) -1:
        return 0
    a = abs(kameni[vrijednost] - kameni[vrijednost+1]) + doritto(vrijednost+1)
    b = abs(kameni[vrijednost] - kameni[vrijednost+2]) + doritto(vrijednost+2)
    memo[vrijednost] = min(a,b)
    return memo[vrijednost]
N = int(input())
kameni = list(map(int,input().split()))
memo = []
for i in range(N):
    memo.append(-1)
print(doritto(0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
def doritto(vrijednost):
    global kameni
    global memo
    if memo[vrijednost] != -1:
        return memo[vrijednost]
    if vrijednost == len(kameni) -2:
        return abs(kameni[vrijednost] - kameni[vrijednost+1])
    elif vrijednost == len(kameni) -1:
        return 0
    a = abs(kameni[vrijednost] - kameni[vrijednost+1]) + doritto(vrijednost+1)
    b = abs(kameni[vrijednost] - kameni[vrijednost+2]) + doritto(vrijednost+2)
    memo[vrijednost] = min(a,b)
    return memo[vrijednost]
N = int(input())
kameni = list(map(int,input().split()))
memo = []
for i in range(N):
    memo.append(-1)
print(doritto(0))
import sys
N = int(input())
s = []
for l in sys.stdin:
    s.append(int(l))
    
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")

print("AC"+"x"+a)
print("WA"+"x"+b)
print("TLE"+"x"+c)
print("RE"+"x"+d)

### FIXED CODE ###

import sys
N = int(input())
s = [input() for i in range(N)]
    
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
 
print("AC"+" x "+str(a))
print("WA"+" x "+str(b))
print("TLE"+" x "+str(c))
print("RE"+" x "+str(d))
n,s=map(int, input().split())
N=[]
for _ in range(n):
    N.append(int(input()))
N=sorted(N)
for i in range(s-1,len(N)):
    diff_list.append(N[i]-N[i-s+1])
print(min(diff_list))

### FIXED CODE ###

n,s=map(int, input().split())
N=[]
for _ in range(n):
    N.append(int(input()))
N=sorted(N)
diff_list=[]
for i in range(s-1,len(N)):
    diff_list.append(N[i]-N[i-s+1])
print(min(diff_list))
H, W = map(int, input().split())
HW = [0] * H
for i in range(H):
  HW[i] = str(input())

visited = [[0] * W for i in range(H)]
def bfs(x, y, strock):
  #now = HW[x][y]
  if visited[x][y] == 1:
    return 0
  visited[x][y] = 1
  if HW[x][y] == ".":
    return 0
  strock += 1
  queue = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  tt = 0
  for i, j in queue:
    if (0 <= x + i < H) and (0 <= y + j < W):
      if HW[x + i][y + j] == "#":
        tt = 1
        bfs(x + i, y + j, strock)
  if tt == 0:
    return strock
  
for i in range(H):
  for j in range(W):
    st = bfs(i, j, 0)
    #print(st)
    if st == 1:
      print("No")
      quit()
      
print("Yes")
  
  
      
  
  
  

### FIXED CODE ###

H, W = map(int, input().split())
HW = [0] * H
for i in range(H):
  HW[i] = str(input())
#print(HW)
visited = [[0] * W for i in range(H)]
def bfs(x, y):
  #now = HW[x][y]
  if visited[x][y] == 1:
    return 0
  visited[x][y] = 1
  
  if HW[x][y] == ".":
    return 0
    
  queue = [[0, 1], [0, -1], [1, 0], [-1, 0]]
  tt = 0
  for i, j in queue:
    if (0 <= x + i < H) and (0 <= y + j < W):
      if HW[x + i][y + j] == "#":
        tt = 1
        #print(x, y, x + i, y + j, strock)
  if tt == 0:
    return 1
  return 0
  
for i in range(H):
  for j in range(W):
    #print(i, j)
    st = bfs(i, j)
    #print(st)
    if st == 1:
      print("No")
      quit()
      
print("Yes")
mod = 10 ** 9 + 7

# フィボナッチ数列
fib_memo = {}
def fib(N):
    if N < 2: return 1
    if N not in fib_memo:
        fib_memo[N] = fib(N-1) + fib(N-2)
    return fib_memo[N]

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

tmp_list = [0] * (M+1)
now_kaidan = 0
for i in range(M):
    tmp_list[i] = (A[i] - 1) - now_kaidan
    now_kaidan = A[i] + 1
tmp_list[-1] = N-now_kaidan
ans = 1

for v in tmp_list:
    if v == -1:     # 壊れた階段が連続している時は0移動方法がない
        print(0)
        exit()
    ans *= fib(v)
    ans %= mod

print(ans%mod)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 5 + 10)
mod = 10 ** 9 + 7

# フィボナッチ数列
fib_memo = {}
def fib(N):
    if N < 2: return 1
    if N not in fib_memo:
        fib_memo[N] = fib(N-1) + fib(N-2)
    return fib_memo[N]

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

tmp_list = [0] * (M+1)
now_kaidan = 0
for i in range(M):
    tmp_list[i] = (A[i] - 1) - now_kaidan
    now_kaidan = A[i] + 1
tmp_list[-1] = N-now_kaidan
ans = 1

for v in tmp_list:
    if v == -1:     # 壊れた階段が連続している時は0移動方法がない
        print(0)
        exit()
    ans *= fib(v)
    ans %= mod

print(ans%mod)
import sys
sys.setrecursionlimit(5000)
def solve(a, b, ab_list):

    route = {}

    for a, b in ab_list:
        if a not in route:
            route[a] = []
        if b not in route:
            route[b] = []

        route[a].append(b)
        route[b].append(a)

    route_memo = {}
    def func(x, memo):
        if x in route_memo:
            memo = route_memo[x]
            return True

        if  1 in route[x]:
            route_memo[x] = memo
            return True
        else:
            tmp = False
            for y in route[x]:
                if y not in memo:
                    memo.append(y)
                    tmp = func(y, memo)
                if tmp:
                    return True
            return False
    ans = []
    flg = True
    for i in range(2, n+1):
        memo = []
        if func(i, memo):
            if len(memo) == 0:
                memo.append(1)
            ans.append(memo[-1])
        else:
            flg = False
            break

    if flg:
        print("Yes")
        for i in ans:
            print(i)
    else:
        print("No")

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    ab_list = [[int(i) for i in input().split()] for j in range(m)]
    solve(n, m, ab_list)


### FIXED CODE ###

import collections
def solve(a, b, ab_list):

    route = {}

    for a, b in ab_list:
        if a not in route:
            route[a] = []
        if b not in route:
            route[b] = []

        route[a].append(b)
        route[b].append(a)

    deque = collections.deque()
    deque.extend(route[1])
    route_memo = {i:1 for i in route[1]}
    while len(deque) > 0:
        room = deque.popleft()
        for i in route[room]:
            if i != 1 and i not in route_memo:
                route_memo[i] = room
                deque.append(i)

    if len(route_memo.keys()) == n-1:
        print("Yes")
        tmp = sorted(route_memo.items())
        for i in tmp:
            print(i[1])
    else:
        print("No")

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    ab_list = [[int(i) for i in input().split()] for j in range(m)]
    solve(n, m, ab_list)
r, d, x_2000 = map(int, input().split())
ans = []*11
ans[0] = x_2000
for i in range(1, 11):
    ans[i] = r * ans[i-1] - d
    print(ans[i])

### FIXED CODE ###

r, d, x_2000 = map(int, input().split())
ans = [0]*11
ans[0] = x_2000
for i in range(1, 11):
    ans[i] = r * ans[i-1] - d
    print(ans[i])
N=int(input())
L=list(map(int,input().split()))
count=0
for i in range N:
	if L[i]%2==1:
		count+=1
if count%2==1:
	print("NO")
else:
	print("YES")

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
count=0
for i in range (N):
	if L[i]%2==1:
		count+=1
if count%2==1:
	print("NO")
else:
	print("YES")
a, b, c = map(int, input().split())
ans = 0
for i in range(1, a+1):
    N = [int(x) for x in str(i)]
    sum = sum(N)
    if (b <= sum and sum <= c):
        ans += sum

print(ans)


### FIXED CODE ###

A, B, C, D = map(int, input().split())
L = A+B
R = C+D
if L > R:
    print('Left')
elif L < R:
    print('Right')
else:
    print('Balanced')
K, S = map(int, input().split())

result = 0
for X in range(K+1):
    for Y in range(K+1):
        Z = S-X-Y
        if Z<0:
            continue
        elif K<Z:
            continue
        elif S == X+Y+Z:
            result += 1
print(result)



### FIXED CODE ###

print(*input().split(","))
from collections import Counter
class Combination:
    _maxNum = 0
    _divider = 0
    _fact = []
    _inv = []
    _finv = []

    def __init__(self, maxNum, divider):
        self._maxNum = maxNum
        self._divider = divider
 
        _fact = [0] * (maxNum + 1)
        _fact[0] = _fact[1] = 1


        if divider != 0:
            _inv = [0] * (maxNum + 1)
            _finv = [0] * (maxNum + 1)
            _inv[0] = _inv[1] = _finv[0] = _finv[1] = 1
        else:
            _inv = []
            _finv = []

        for i in range(2, maxNum + 1):
            _fact[i] = _fact[i - 1] * i;
            if divider != 0:
                _fact[i] %= _divider
                _inv[i] = _divider - _inv[_divider % i] * (_divider // i) % _divider
                _finv[i] = _finv[i - 1] * _inv[i] % _divider

        self._fact = _fact
        self._inv = _inv
        self._finv = _finv

    def nPk(self, n, k):
        if(k > self._maxNum) or (n > self._maxNum) or (k > n) or (k < 0) or (n < 0):
            return 0
        return(self._fact[n] // self._fact[n - k])

    def nCk(self, n, k):
        ans = 0
        if(k > self._maxNum) or (n > self._maxNum) or (k > n) or (k < 0) or (n < 0):
            ans = 0
        elif self._divider == 0:
            ans = self.nPk(n, k)
            ans //= self._fact[k]
        else:
            ans = self._fact[n] * (self._finv[k] * self._finv[n - k] % self._divider) % self._divider

        return ans

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        di[s] += 1
    
    cmb = Combination(max(di.values()), 0)

    ans = 0
    for num in di.values():
#        ans += cmb.nCk(num, 2)

    print(ans)


def main():
    ABC137C_GreenBin()

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    ans = 0
    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        
        if s in di:
            ans += di[s]

        di[s] += 1
    
    print(ans)


def main():
    ABC137C_GreenBin()

if __name__ == "__main__":
    main()
a,b =map(int,input().split())

ans = b * 10
status = ''
for i in range(10):
  8*(ans + i)//100
  if(a == 8*(ans + i)//100):
    ans += i
    status = 'ok'
    break;

if status =='ok':
  print(ans)
  
else:
  print(-1)

### FIXED CODE ###

a,b,c=input()
if a==b and b==c:
  print("No")
else:
  print("Yes")
n,m=map(int,input().split())

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

sum=0
count=0
for i in a:
  sum+=a
  
for i in a:
  if a>=(sum/4*m):
    count+=1
    
if(count>=m):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
s=0
b=True
for i in a:
  s+=i

  
for i in range(0,m):
  if a[i]>=s/4/m:
    b=True
  else:
    b=False
    
if b:
  print('Yes')
else:
  print('No')
import numpy as np
import itertools

H, W, K = map(int, input().split())
x = [list(input().split()) for l in range(H)]

listH = list(range(H))
Hcombi = []
for n in range(len(listH)+1):
    a = list(itertools.combinations(listH,n))
    Hcombi.extend(a)

listW = list(range(W))
Wcombi = []
for n in range(len(listW)+1):
    a = list(itertools.combinations(listW,n))
    Wcombi.extend(a)

N = 0

for h in Hcombi:
    for w in Wcombi:
        X = np.array(x)
        X[[h],:] = 'n'
        X[:,[w]] = 'n'
        count = np.sum(X == '#')
        if count == K:
            N +=1        
print(N)

### FIXED CODE ###

from itertools import product

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if (c[row][col] == '#') and ((row_bit[row] == 0) and (col_bit[col] == 0)):
                    cnt += 1   
        if cnt == k:
            ans += 1
print(ans)
n, k = map(int, input().split())
s = str(input())
head = s[0]

counts = []
_hd = head
_cnt = 0
for _s in s:
  if _s == _hd:
    _cnt += 1
  else:
    counts.append(_cnt)
    _hd = _s
    _cnt = 1
else:
  counts.append(_cnt)

acc = [0]
for c in counts:
  acc.append(acc[-1] + c)

if len(counts) <= 2*k:
  ans = len(s)
else:
  if head == '1':
    for i in range(2*k+1, len(counts)+1, 2):
      p = acc[i] - acc[i - (2*k+1)]
      ans = max(ans, p)
  else:
    for i in range(2*k, len(counts)+1, 2):
      p = acc[i] - acc[max(0, i-(2*k+1))]
      ans = max(ans, p)

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
s = str(input())
head = s[0]

counts = []
_hd = head
_cnt = 0
for _s in s:
  if _s == _hd:
    _cnt += 1
  else:
    counts.append(_cnt)
    _hd = _s
    _cnt = 1
else:
  counts.append(_cnt)

acc = [0]
for c in counts:
  acc.append(acc[-1] + c)
if s[-1] == '0':
  acc.append(acc[-1])

ans = 1
if len(counts) <= 2*k:
  ans = len(s)
else:
  if head == '1':
    for i in range(2*k+1, len(acc)+1, 2):
      p = acc[i] - acc[i - (2*k+1)]
      ans = max(ans, p)
  else:
    for i in range(2*k, len(acc)+1, 2):
      p = acc[i] - acc[max(0, i-(2*k+1))]
      ans = max(ans, p)

print(ans)
#!/usr/bin/env python3

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


X = int(input())

F = factorization(X)

ans = []

Y = 0
#while Y < 10**9:
f2 = False
nex = F[0][0]
b = - X//nex
a = b + nex
ans = []
while Y<10**9:
    Y = a**5 - b**5
    if X == Y:
        ans = [a,b]
        break
    a += nex
    b += nex


print(str(ans[0]) + ' ' + str(ans[1]))


### FIXED CODE ###

#!/usr/bin/env python3

X = int(input())


ans = {}

for a in range(-200, 201):
    for b in range(-200, 201):
        Y = a**5 - b**5
        ans[Y] = [a, b]

print(str(ans[X][0]) + ' ' + str(ans[X][1]))
from heapq import heappush, heappop, merge

N, Q = map(int, input().split())
events = []
for _ in range(N):
    s, t, x = map(int, input().split())
    events.append((s-x, 1, x))
    events.append((t-x, -1, x))
events = sorted(events)
constructions = []
i = 0
for _ in range(Q):
    d = int(input())
    while i < 2*N and events[i][0] <= d:
        if events[i][1] > 0:
            heappush(constructions, events[i][2])
        else:
            temp = []
            while constructions[0] != events[i][2]:
                heappush(temp, heappop(constructions))
            heappop(constructions)
            merge([temp, constructions])
        i += 1
    print(constructions[0] if constructions else -1)

### FIXED CODE ###

from heapq import heappush, heappop, merge
from collections import defaultdict
import sys
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, Q = map(int, line_input())
    events = []
    for _ in range(N):
        s, t, x = map(int, line_input())
        events.append((s-x, 1, x))
        events.append((t-x, -1, x))
    for _ in range(Q):
        d = int(single_input())
        events.append((d, 2, d))
    events = sorted(events)

    constructions = []
    under_construction = defaultdict(bool)
    ans = ''
    for _, flag, coord in events:
        if flag == 1:
            heappush(constructions, coord)
            under_construction[coord] = True
        elif flag == -1:
            under_construction[coord] = False
        else:
            while constructions:
                x = heappop(constructions)
                if under_construction[x]: # x is the minimum coordinate under construction
                    heappush(constructions, x)
                    ans += str(x) + '\n'
                    break
            else: # no constructions
                ans += '-1\n'
    print(ans)
    
if __name__ == "__main__":
    solve()
S = list(map(int,input().split()
print(S)             
        


### FIXED CODE ###

S = int(input())
K = int(input())

lst = []
while S > 0:
    lst.append(S%10)
    S //= 10 
lst.reverse()

if len(lst) == lst.count(1):
	print(1)

elif K == lst[:K].count(1):
	print(1)
  
else:
	for i in range(K):
		if lst[i] != 1:
			print(lst[i])
			break