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


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

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

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


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

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

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

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)


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


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

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

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


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

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

a = str(ans[0])
for j in range(1, len(ans)):
  a += ' '+ str(ans[j])
print(a)
#! -*- coding:utf-8 -*-
def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)
 
def lcm(a, b):
    return a * b / gcd(a, b)

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

p = lcm(a[0],a[1])
for i in range(n):
    p = lcm(p,a[i])
print(int(p))


### FIXED CODE ###

#! -*- coding:utf-8 -*-
def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a
 
def lcm(a, b):
    return a * b // gcd(a, b)

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

if n == 1:
    print(k[0])
else:
    p = lcm(k[0],k[1])
    for i in range(n):
        p = lcm(p,k[i])
    print(int(p))
import sys
import math

r = int(sys.stdin.readline())
area = r ** 2 * math.pi
circumference = r * 2 * math.pi

print(round(area, 5), round(circumference, 5))

### FIXED CODE ###

import sys
import math
from decimal import Decimal

r = Decimal(sys.stdin.readline())
area = r ** Decimal(2) * Decimal(math.pi)
circumference = r * Decimal(2) * Decimal(math.pi)

print(round(area, 5), round(circumference, 5))
A, B, C, D = map(int,input().split())
x = max(A, C)
y = min(B, D)
if(y-x > 0):
  print(y - x)
else:
  print(0)


### FIXED CODE ###

N = input()
if(N == N[::-1]):
  print("Yes")
else:
  print("No")
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n, x, y;
  cin >> n >> x >> y;
  vector<vector<int>> distance(n, vector<int>(n, n));
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      distance[i][j] = abs(i-j);
    }
  }
  
  distance[x-1][y-1] = 1;
  distance[y-1][x-1] = 1;
  
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] > distance[i][x-1]+distance[x-1][j]){
        distance[i][j] = distance[i][x-1]+distance[x-1][j];
      }
    }
  }
  
  
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] > distance[i][y-1]+distance[y-1][j]){
        distance[i][j] = distance[i][y-1]+distance[y-1][j];
      }
    }
  }
  
  vector<int> ans(n-1, 0);
  int key;
  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      if (distance[i][j] == n){
        continue;
      }
      key = distance[i][j];
      ans[key-1]++;
    }
  }
  for (int i = 0; i < n-1; i++){
    cout << ans[i]/2 << endl;
  }
  
}


### FIXED CODE ###

n, x, y = map(int, input().split())
ans = [[n]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    ans[i][j] = abs(i-j)

ans[x-1][y-1] = 1
ans[y-1][x-1] = 1
for i in range(n):
  for j in range(n):
    if ans[i][j] > ans[i][x-1]+ans[x-1][j]:
      ans[i][j] = ans[i][x-1]+ans[x-1][j]
    
for i in range(n):
  for j in range(n):
    if ans[i][j] > ans[i][y-1]+ans[y-1][j]:
      ans[i][j] = ans[i][y-1]+ans[y-1][j]

answer = [0]*(n-1)
for i in range(n):
  for j in range(n):
    if ans[i][j] == n or ans[i][j] == 0:
      continue
    answer[ans[i][j]-1] += 1
for i in range(n-1):
  print(answer[i]//2)
import sys
sys.setrecursionlimit(10**5 + 10)

MOD = 10**9 + 7

n, k = map(int, input().split())
e = [[] for i  in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)

visited = [False for i in range(n)]
def dfs(v, npv, nppv):
    global visited
    ans = max(k - npv - nppv, 0)
    visited[v] = True
    i = 0
    for nv in e[v]:
        if visited[nv]:
            continue

        ans *= dfs(nv, 1, npv+i)
        ans = ans % MOD
        i += 1

    return ans

for i in range(n):
    if len(e[i]) == 1:
        # print(i)
        s = i
        break

print(dfs(s, 0, 0))

# print(e)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7 + 10)

MOD = 10**9 + 7

n, k = map(int, input().split())
e = [[] for i  in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)

if n == 1:
    print(k)
else:
    visited = [False for i in range(n)]
    def dfs(v, npv, nppv):
        global visited
        ans = max(k - npv - nppv, 0)
        visited[v] = True
        i = 0
        for nv in e[v]:
            if visited[nv]:
                continue

            ans *= dfs(nv, 1, npv+i)
            ans = ans % MOD
            i += 1

        return ans

    for i in range(n):
        if len(e[i]) == 1:
            # print(i)
            s = i
            break

    print(dfs(s, 0, 0))

    # print(e)
for i in range(5):
    I=list(int(input()))
k=int(input())
if max(I)-min(I)<=k:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

I=[]
for i in range(5):
    I.append(int(input()))
k=int(input())
if I[4]-I[0]<=k:
    print("Yay!")
else:
    print(":(")
while True:
    h, w = map(int, input().split())
    if a == 0: break

    for i in range(h)
        for j in range(w)
            if (i+j) % 2 == 0 : print("#")
            else : print(".")
        print() 
    print()


### FIXED CODE ###


while True:
    h, w = map(int, input().split())
    if h == 0: break

    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0 : print("#",end="")
            else : print(".",end="")
        print() 
    print()
A,B = map(int, input().split())
ans = 0
b = A
for i in range(21):
    ans += 1
    if b >= B:
        break
    b += A-1
print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 0
ansk = 0
tmp = -1
while tmp < N:
    tmp += 1
    if ans > 0:
        tmp += ans-1
        ans = 0
        continue
    for j in range(tmp+1,N):
            if H[j-1] < H[j]:
                ansk = max(ansk,ans)
                break
            ans += 1
            if j == N-1:
                ansk = max(ansk,ans)
                tmp = N
                break
print(ansk)
h, n = map(int, input().split())
a = input().split()

a.sort(reverse=True)

sum=0
for i in range(n):
  sum += a[i]
  
if sum>=h:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

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

a.sort(reverse=True)

sum=0
for i in range(n):
  sum += a[i]
  
if sum>=h:
  print("Yes")
else:
  print("No")
N=10
A=[]
for i in range(N):
    A.append(int(input()))
sorted(A)
for i in range(3):
    print(a[i])

### FIXED CODE ###

N=10
A=[int(input()) for i in range(N)]
A.sort(reverse=True)
for i in range(3):
    print(A[i])
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

mod = 10**9+7

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)

cnt = [0]*n
def dfs(cur, prev):
    tmp = 1
    for to in G[cur]:
        if to != prev:
            tmp += dfs(to, cur)
    cnt[cur] = tmp
    return tmp

dfs(0, -1)

power = [0]*(n)
powe2_n = pow(2, n, mod)
powe2_n = pow(powe2_n, mod-2, mod)
power[n-1] = powe2_n
for i in reversed(range(n-1)):
    powe2_n *= 2
    powe2_n %= mod
    power[i] = powe2_n
ans = 0
from collections import deque
que = deque()
que.append((0, -1))

while que:
    cur, prev = que.pop()
    if len(G[cur]) == 1:
        if prev == -1:
            que.append((G[cur][0], cur))
        continue

    prob = 1
    prob -= power[n-2]

    for to in G[cur]:
        if to == prev:
            bubun_cnt = n-cnt[cur]
        else:
            que.append((to, cur))
            bubun_cnt = cnt[to]
        tmp = 1-power[bubun_cnt-1]
        tmp *= power[n-1-bubun_cnt-1]
        prob -= tmp
    prob %= mod
    ans += power[0]*prob
    ans %= mod

print(ans)


### FIXED CODE ###

import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

from collections import deque

mod = 10**9+7

n = int(input())
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)

que = deque()
dep = [0]*n
que.append((0,-1, 0))
order = []
while que:
    cur, prev, d = que.popleft()
    dep[cur] = d
    order.append(cur)
    for to in G[cur]:
        if to != prev:
            que.append((to, cur, d+1))

cnt = [1]*n
for i in reversed(order):
    for to in G[i]:
        if dep[to] < dep[i]:
            cnt[to] += cnt[i]

power = [0]*(n)
powe2_n = pow(2, n, mod)
powe2_n = pow(powe2_n, mod-2, mod)
power[n-1] = powe2_n
for i in reversed(range(n-1)):
    powe2_n *= 2
    powe2_n %= mod
    power[i] = powe2_n
ans = 0
que = deque()
que.append((0, -1))

while que:
    cur, prev = que.pop()
    if len(G[cur]) == 1:
        if prev == -1:
            que.append((G[cur][0], cur))
        continue

    prob = 1
    prob -= power[n-2]

    for to in G[cur]:
        if to == prev:
            bubun_cnt = n-cnt[cur]
        else:
            que.append((to, cur))
            bubun_cnt = cnt[to]
        tmp = 1-power[bubun_cnt-1]
        tmp *= power[n-1-bubun_cnt-1]
        prob -= tmp
    prob %= mod
    ans += power[0]*prob
    ans %= mod

print(ans)
sum=0
max=0
for i in range(5):
  x = int(input()）
  y = -(-x)//10
  sum+=y
  max=(y-x, max)
print(sum-max)

### FIXED CODE ###

X=[int(input()) for i in range(5)]
Y=[]
for x in X:
  Y.append(-(-x//10)*10-x)
print(sum(X)+sum(Y)-(max(Y)))
X, Y, Z, K  = map(int, input().split())

A = sorted(list(map(int, input().split())), reverse=True)[:K]
B = sorted(list(map(int, input().split())), reverse=True)[:K]
C = sorted(list(map(int, input().split())), reverse=True)[:K]

R  = [sum([A[0], B[0], C[0]])]
Q  = {(0, 0, 1), (0, 1, 0), (1, 0, 0)}
D  = {(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0)}
iS = [((a, b, c), sum([A[a], B[b], C[c]])) for a, b, c in Q]

while len(R) < K:
    iS = sorted(iS, key=lambda x: [x[1], x[0]], reverse=True)
    R.append(iS[0][1])
    abc = iS[0][0]
    del iS[0]
    if abc[0] + 1 < X:
        a, b, c = abc[0] + 1, abc[1], abc[2]
        if not (a, b, c) in D:
            iS.append(((a, b, c), sum([A[a], B[b], C[c]])))
            D.add(  (a, b, c))
    if abc[1] + 1 < Y:
        a, b, c = abc[0], abc[1] + 1, abc[2]
        if not (a, b, c) in D:
            iS.append(((a, b, c), sum([A[a], B[b], C[c]])))
            D.add(  (a, b, c))
    if abc[2] + 1 < Z:
        a, b, c = abc[0], abc[1], abc[2] + 1
        if not (a, b, c) in D:
            iS.append(((a, b, c), sum([A[a], B[b], C[c]])))
            D.add(  (a, b, c))

for r in R:
    print(r)


### FIXED CODE ###

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

A = sorted(list(map(int, input().split())), reverse=True)[:K]
B = sorted(list(map(int, input().split())), reverse=True)[:K]
C = sorted(list(map(int, input().split())), reverse=True)[:K]

R  = [sum([A[0], B[0], C[0]])]
Q  = {(0, 0, 1), (0, 1, 0), (1, 0, 0)}
D  = {(0, 0, 0), (0, 0, 1), (0, 1, 0), (1, 0, 0)}
iS = [((a, b, c), sum([A[a], B[b], C[c]])) for a, b, c in Q if (a < X) and (b < Y) and (c < Z)]
iS = sorted(iS, key=lambda x: [x[1], x[0]], reverse=True)

while len(R) < K:
    R.append(iS[0][1])
    abc     = iS[0][0]
    a, b, c = abc[0], abc[1], abc[2]
    iS      = iS[1:]
    if a + 1 < X:
        if not (a + 1, b, c) in D:
            s = sum([A[a + 1], B[b], C[c]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a + 1, b, c), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a + 1, b, c), s)]
            D.add((a + 1, b, c))
    if b + 1 < Y:
        if not (a, b + 1, c) in D:
            s = sum([A[a], B[b + 1], C[c]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a, b + 1, c), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a, b + 1, c), s)]
            D.add((a, b + 1, c))
    if c + 1 < Z:
        if not (a, b, c + 1) in D:
            s = sum([A[a], B[b], C[c + 1]])
            is_done = False
            for i in range(len(iS)):
                if iS[i][1] < s:
                    iS = iS[:i] + [((a, b, c + 1), s)] + iS[i:]
                    is_done = True
                    break
            if is_done == False:
                iS = iS + [((a, b, c + 1), s)]
            D.add((a, b, c + 1))

for r in R:
    print(r)
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
  plus = i+1 + A[i]
  AP.append(plus)
  minus = i+1 - A[i]
  AM.append(minus)
  
print(AP)
print(AM)
ans = 0 

for j in range(N):
  ans += AP.count(j) * AM.count(j)

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
AM = []
AP = []
AMlist = [0] * N
APlist = [0] * N

for i in range(N):
  plus = i+1 + A[i]
  AP.append(plus)  
  if AP[i] <= N:
    APlist[AP[i]-1] += 1
  minus = i+1 - A[i]
  AM.append(minus)
  if AM[i] > 0 and AM[i] <= N:
    AMlist[AM[i]-1] += 1
    
ans = 0

for j in range(N):
  ans += APlist[j] * AMlist[j]

print(ans)
n, a, b, c, d = map(int, input().split())
s = list(str(input()))

a = a - 1
b = b - 1
c = c - 1
d = d - 1


def rec(s, a, b, c, d):
    #ss = s.copy()
    #ss[a] = 'A'
    #ss[b] = 'B'
    #print(str(ss),a,b,c,d)
    if a > c or b > d:
        return False
    if a == c and b == d:
        return True

    if a+1 < len(s) and s[a + 1] == '.' and a+1 != b:
        if rec(s, a + 1, b, c, d):
            return True
    if a+2 < len(s) and s[a + 2] == '.' and a + 2 != b:
        if rec(s, a + 2, b, c, d):
            return True
    if b + 1 < len(s) and s[b + 1] == '.' and b + 1 != a:
        if rec(s, a, b + 1, c, d):
            return True
    if b+2 < len(s) and s[b + 2] == '.' and b + 2 != a:
        if rec(s, a, b + 2, c, d):
            return True

    return False

result = rec(s, a, b, c, d)
if result:
    print("Yes")
else:
    print("No")
    

### FIXED CODE ###

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

s = input()
s = '#' +s

def check(s, a, b):
    return not "##" in s[a:b]


def solve(s,a,b,c,d):
    can_swap = "..." in s[b - 1:d + 2]
    can_reach_each = check(s, a, c) and check(s, b, d)
    if not can_reach_each:
        return False
    if (a < b and c < d) or (b < a and d < c):
        return True
    else:
        if can_swap:
            return True
        else:
            return False

if solve(s, a, b, c, d):
    print("Yes")
else:
    print("No")
N=int(input())
A=int(input())
B=int(input())
if N==1:
    print('Hello World')
if N==2:
    print(A+B)

### FIXED CODE ###

N=int(input())
if N==1:
    print('Hello World')
if N==2:
    A=int(input())
    B=int(input())
    print(A+B)
import math


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

head = min(X)
tail = max(X)

min_score = math.inf
for p in range(head, tail+1):
    min_score = min(sum(map(lambda x: (x - p)**2, X)), min_score)

print(min_score)

### FIXED CODE ###

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

head = min(X)
tail = max(X)

min_score = float('inf')
for p in range(head, tail+1):
    min_score = min(sum(map(lambda x: (x - p)**2, X)), min_score)

print(min_score)
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
    print(0)
else:
    ans = 1
    for i in range(1,n):
        dp = d[i] - 1
        ans *= d.count(dp)
print(ans)


### FIXED CODE ###

from collections import Counter
mod = 998244353
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
    print(0)
    exit()

C = Counter(d)
C = dict(sorted(C.items()))

memo1 = C[1]
memo2 = 1
ans = 1

for i in range(1,n):
    if d[i] == 0:
        print(0)
        exit()

for key in C:
    if key >= 2:
        if memo2 + 1 != key: #道が途切れている場合はダメ
            print(0)
            exit()
        ans = (ans * memo1 ** C[key]) % mod #modは和について閉じているため先にわる
        memo1 = C[key]
        memo2 = key
print(ans)
n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
l=[0]*n
if k<=100000:
    for i in range(k):
        p=A[p-1]
        l[p-1]+=1
    print(p)
    exit()
else:
    for i in range(100001):
        p=A[p-1]
        l[p-1]+=1
        if l[p-1]==2:
            x=i
            break
    d=1
    for j in range(100001):
        d=A[d-1]
        if d==p:
            y=j
            break
    z=(k-y-1)%(y-x)
    for i in range(z):
        p=A[p-1]
    print(p)

### FIXED CODE ###

n,k=map(int,input().split())
A=list(map(int,input().split()))
p=1
l=[0]*n
#l[0]+=1
if k<=200000:
    for i in range(k):
        p=A[p-1]
        l[p-1]+=1
    print(p)
    exit()
else:
    for i in range(200001):
        p=A[p-1]#A[0]の番号の町に飛ぶ
        l[p-1]+=1
        #print(p)
        if l[p-1]==2:
            x=i
            break
    #print("p=",str(p))
    #print(l,x)

    d=1
    for j in range(200001):
        d=A[d-1]#A[0]の番号の町に飛ぶ
        if d==p:
            y=j
            break
    #print("y=",str(y))
    z=(k-x-1)%(x-y)#yから数えて残り回す回数
    #print(z)
    for i in range(z):
        p=A[p-1]
        #print(p)
    print(p)
#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.buffer.readline
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def LIR(n):
    res = [None] * n
    for i in range(n):
        l, r = map(int, input().split())
        res[i] = (l - 1, r - 1, i)
    return res

#solve
def solve():
    n, q = LI()
    c = LI()
    lr = [None] * n
    for i in range(n):
        l, r = map(int, input().split())
        lr[i] = (l - 1, r - 1, i)
    ans = [None] * q
    lr.sort(key=lambda x: x[1])
    dp = [-1] * (max(c) + 1)
    bit = [0] * (n + 1)
    def add(i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= n:
            bit[x - 1] += w
            x += x & -x
        return
    def sum(i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += bit[x - 1]
            x -= x & -x
        return res
    t = 0
    def f(t):
        l, r, j = lr[t]
        xr = sum(r)
        xl = sum(l-1)
        tmp = xr - xl
        ans[j] = tmp
        
    for i in range(n):
        ci = c[i]
        l = dp[ci]
        add(i, 1)
        dp[ci] = i
        if l != -1:
            add(l, -1)
        while t < q and lr[t][1]<= i:
            f(t)
            t += 1
        if t == q:
            break
    for ai in ans:
        print(ai) 
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
import sys
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def LIR(n):
    res = [None] * n
    for i in range(n):
        l, r = map(int, input().split())
        res[i] = (l-1, r-1, i)
    return res

#solve
def solve():
    n, q = LI()
    c = LI()
    lr = LIR(q)
    ans = [None] * q
    lr.sort(key=lambda x: x[1])
    dp = [-1] * (max(c) + 1)
    bit = [0] * (n + 1)
    def add(i, w):
        """
        i番目にwを加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= n:
            bit[x - 1] += w
            x += x & -x
        return
    def sum(i):
        """
        [0,i]の合計
        :param int i:
        :return:
        """
        res = 0
        x = i + 1
        while x > 0:
            res += bit[x - 1]
            x -= x & -x
        return res
    t = 0
    def f(t):
        l, r, j = lr[t]
        xr = sum(r)
        xl = sum(l-1)
        tmp = xr - xl
        ans[j] = tmp
        
    for i in range(n):
        ci = c[i]
        l = dp[ci]
        add(i, 1)
        dp[ci] = i
        if l != -1:
            add(l, -1)
        while t < q and lr[t][1]<= i:
            f(t)
            t += 1
        if t == q:
            break
    for ai in ans:
        print(ai) 
    return


#main
if __name__ == '__main__':
    solve()
s=input()
k=int(input())
if s[:k]=="1"*k:
    print("1")
else:
    i=0
    while True:
        if s[i]!="1":
            print(s[i])
            break
        i+=1


### FIXED CODE ###

import sys
s=input()
k=int(input())
if k<105:
    if s[:k]=="1"*k:
        print("1")
        sys.exit(0)
i=0
while True:
    if s[i]!="1":
        print(s[i])
        break
    i+=1
N,T=map(int,input().split())
L=[]
for i in range(N):
  a,b=map(int,input().split())
  L.append((a,b))
L.sort()

DP=[[0 for i in range(T)] for j in range(N+1)]

for i in range(N):
  for j in range(T):
    if j-L[i][0]>=0 and i>0:
      DP[i][j]=max(DP[i-1][j-L[i-1][0]]+L[i-1][1],DP[i-1][j])
ans=0
for i in range(N):
  if i!=N:
    ans=max(ans,DP[i][T-1]+L[i][1])
  else:
    ans=max(ans,DP[i][T-1])

print(ans)


### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
import math
def isok(n):
  sum=0
  for i in range(N):
    sum+=max(0,A[i]-n//F[i])
  return sum<=K
ma=0
for i in range(N):
  ma=max(ma,A[i]*F[i])
start,end=-1,ma
while end-start>1:
  mid=(start+end)//2
  if isok(mid):
    end=mid
  else:
    start=mid
print(end)
import sys
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]

t0,x0,y0 = 0,0,0

for i in range(N):
    print(t0,x0,y0," ",t,x,y)
    if t-t0 >= abs(x-x0)+abs(y-y0) and (t-t0)%2 == abs(x-x0+y-y0)%2:
        t0,x0,y0 = t,x,y
        continue
    else:
        print("No")
        sys.exit()

print("Yes")

### FIXED CODE ###

N = int(input())
S = "Yes"
A = [(0,0,0)]
for i in range(N):
    t,x,y = map(int,input().split())
    A.append((t,x,y))
A = sorted(A)
for i in range(N):
    t1,x1,y1 = A[i]
    t2,x2,y2 = A[i+1]
    if abs(x2-x1)+abs(y2-y1) > t2-t1  or   (abs(x2-x1)+abs(y2-y1))%2 != (t2-t1)%2:
        S = "No"
        break
print(S)
n=input()
k=0
while k < n:
    k += 1000
print(k-n)

### FIXED CODE ###

n=int(input())
k=0
while k < n:
    k += 1000
print(k-n)