Harryxun/stf_run huggingface dataset:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
X = (['1']*(10**5))[::-1]
#X = s()[::-1]
num1 = 1
num2 = 1
num3 = 0
num4 = 0
cnt = 0
for i in range(N):
    if X[i] == '1':
        cnt += 1
cnt1 = cnt+1#0用
cnt2 = cnt-1#1用
nums = []
ans = []
for i in range(N):
    if X[i] == '0':
        nums.append(num1)
    else:
        num3 += num1
        num4 += num2
        nums.append(num2)
    num1 = (num1*2)%cnt1
    num2 = (num2*2)%cnt2
num3 %= cnt1
num4 %= cnt2
for i in range(N):
    if X[i] == '0':
        ans.append((num3+nums[i])%cnt1)
    else:
        ans.append((num4-nums[i])%cnt2)
ans.reverse()
tans = [1]*N
def f(n):
    if n == 0:
        return
    tans[i] += 1
    c = n%(list(bin(n)[2:]).count('1'))
    f(c)
for i in range(N):
    f(ans[i])
for i in range(N):
    print(tans[i])

### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
fact = math.factorial
sys.setrecursionlimit(10**9)
INF = 10**9
mod = 10**9+7

N = i()
X = s()[::-1]
num1 = 1
num2 = 1
num3 = 0
num4 = 0
cnt = 0
for i in range(N):
    if X[i] == '1':
        cnt += 1
cnt1 = cnt+1#0用
cnt2 = cnt-1#1用
nums = []
ans = []
tans = [1]*N
for i in range(N):
    if X[i] == '0':
        nums.append(num1)
    else:
        num3 += num1
        num4 += num2
        nums.append(num2)
    if cnt1 != 0:
        num1 = (num1*2)%cnt1
    if cnt2 != 0:
        num2 = (num2*2)%cnt2
if cnt1 != 0:
    num3 %= cnt1
if cnt2 != 0:
    num4 %= cnt2
for i in range(N):
    if X[i] == '0':
        if cnt1 != 0: 
            ans.append((num3+nums[i])%cnt1)
        else:
            ans.append(0)
            tans[i] = 0
    else:
        if cnt2 != 0:    
            ans.append((num4-nums[i])%cnt2)
        else:
            ans.append(0)
            tans[i] = 0
ans.reverse()
tans.reverse()
def f(n):
    if n == 0:
        return
    tans[i] += 1
    c = n%(list(bin(n)[2:]).count('1'))
    f(c)
for i in range(N):
    f(ans[i])
for i in range(N):
    print(tans[i])
import sys
input = sys.stdin.buffer.readline

def main():
    H,W,D = map(int,input().split())
    a = [list(map(int,input().split())) for _ in range(H)]
    pos = [[-1,-1] for _ in range(H*W)]
    for i in range(H):
        for j in range(W):
            pos[a[i][j]-1][0] = i
            pos[a[i][j]-1][1] = j
    
    def manhattan_dist(x1,y1,x2,y2):
        return abs(x2-x1)+abs(y2-y1)

    ans_list = [[0] for _ in range(D)]
    for i in range(D):
        do = -(-(H*W-i)//D)
        for j in range(do-1):
            x1,y1 = pos[D*j+i]
            x2,y2 = pos[D*(j+1)+i]
            md = manhattan_dist(x1,y1,x2,y2)
            ans_list[i].append(ans_list[i][-1]+md)
    
    Q = int(input())
    for _ in range(Q):
        a,b = map(int,input().split())
        mod = (a-1)%D
        print(ans_list[mod][(b-mod)//D]-ans_list[mod][(a-mod)//D])

if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

def main():
    H,W,D = map(int,input().split())
    A = [list(map(int,input().split())) for _ in range(H)]
    Q = int(input())
    test = [list(map(int,input().split())) for _ in range(Q)]
    
    at = [None for _ in range(H*W)]
    for x in range(H):
        for y in range(W):
            at[A[x][y]-1] = (x,y)
            
    def move(x,y):
        dx = abs(at[y][0]-at[x][0])
        dy = abs(at[y][1]-at[x][1])
        return dx + dy
            
    cost = [[0 for _ in range(-(-H*W//D))] for _ in range(D)]
    for i in range(D):
        do = -(-(H*W-i)//D)
        for j in range(do-1):
            cost[i][j+1] = cost[i][j] + move(D*j+i,D*(j+1)+i)
            
    for i in range(Q):
        start,goal = test[i]
        v = start % D - 1
        u = -(-start // D) - 1
        w = -(-goal // D) - 1
        print(cost[v][w]-cost[v][u])
    
if __name__ == "__main__":
    main()
n = int(input())
s = input()
flag = 0
if n%2 == 0:
    m = n/2
    for i in range(m):
        if s[i] != s[m+i]:
            flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
    
else:
    print("No")

### FIXED CODE ###

n = int(input())
s = input()
flag = 0
if n%2 == 0:
    m = int(n/2)
    for i in range(m):
        if s[i] != s[m+i]:
            flag = 1

    if flag == 1:
        print("No")
    else:
        print("Yes")

else:
    print("No")
N = int(input())
def amari(n):
    if n==1:return 1
    return (n*amari(n-1)) % 1000000007
print(amari(N))

### FIXED CODE ###

mod = 10**9+7

N = int(input())
a = 1
for n in range(N):
    a = a*(n+1)%mod
print(a)
from collections import deque
import numpy as np


def main():
    h, w, m = map(int, input().split())
    base = np.zeros((h, w), dtype=int)
    B = []
    for n in range(m):
        h1, w1 = map(int, input().split())
        B.append((h1-1, w1-1))
        base[h1-1][w1-1] = 1
    hs, ws = [], []
    for n in range(h):
        hs.append(sum(base[n]))
    for n in range(w):
        ws.append(sum(base[:, n]))
    hs = np.array(hs)
    ws = np.array(ws)
    h_maxindex = [i for i, x in enumerate(hs) if x == max(hs)]
    w_maxindex = [i for i, x in enumerate(ws) if x == max(ws)]
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if hs[i] == max(hs) and ws[j] == max(ws):
            cnt += 1
    ans = max(hs) + max(ws) - (cnt == k)
    print(ans)
    
    
    
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    h, w, m = map(int, input().split())
    bombs_h = [0] * h
    bombs_w = [0] * w
    B = []
    for n in range(m):
        h1, w1 = map(lambda x: int(x)-1, input().split())
        B.append((h1, w1))
        bombs_w[w1] += 1
        bombs_h[h1] += 1
    max_h = max(bombs_h)
    max_w = max(bombs_w)
    h_maxindex = [i for i, x in enumerate(bombs_h) if x == max_h]
    w_maxindex = [i for i, x in enumerate(bombs_w) if x == max_w]
    cnt = 0
    k = len(h_maxindex) * len(w_maxindex)
    for i, j in B:
        if bombs_h[i] == max_h and bombs_w[j] == max_w:
            cnt += 1
    ans = max_h + max_w - (cnt == k)
    print(ans)
    
    
if __name__ == "__main__":
    main()
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
j = 0
k = len(a)-1
if 1 == a[j]:
    dp.append(0)
    j = min(k,j+1)
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j = min(k,j+1)
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))

### FIXED CODE ###

n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))
dp = []
dp.append(1)
if m == 0:
    a.append(-1)
j = 0
k = len(a)-1
if 1 == a[j]:
    dp.append(0)
    j = min(k,j+1)
else:
    dp.append(1)

for i in range(2,n+1):
    if i == a[j]:
        dp.append(0)
        j = min(k,j+1)
    else:
        dp.append(dp[i-1] + dp[i-2])

print(dp[n]%(1000000007))
a = list(map(int,input().split()))
b = [0]*a[0]
 
for i in range(a[1]):
	m,n = map(int,input().split())
 
	b[m-1] += 1
	b[n-1] -= 1
ma = b[0]
for i in range(1,a[0]):
	b[i] += b[i-1]
	if b[i] >= ma:
		ma = b[i]
		k = i
 
print(a[1] - ma+1)

### FIXED CODE ###

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

print(abs(a[0]-a[1])+abs(a[1]-a[2]))
N,Q = map(int,input().split())
node = [[]for i in range(0,N+1,1)]
for i in range(0,N-1,1):
    a,b = map(int,input().split())
    node[a].append(b)
node_score = [0]*(N+1)#スコア
for i in range(0,Q,1):
    p,x = map(int,input().split())
    node_score[p] += x

ans = [0]*(N+1)
def bfs(n,preN):
    ans[n] = ans[preN]+node_score[n]
    for to in node[n]:
        if to != preN:
            bfs(to,n)
bfs(1,0)
print(" ".join(list(map(str,ans[1:N+1]))))

### FIXED CODE ###

from collections import deque 
#スタック
s = deque([])

N,Q = map(int,input().split())
node = [[]for i in range(0,N+1,1)]
for i in range(0,N-1,1):
    a,b = map(int,input().split())
    node[a].append(b)
    node[b].append(a)
node_score = [0]*(N+1)#スコア
for i in range(0,Q,1):
    p,x = map(int,input().split())
    node_score[p] += x

ans = [0]*(N+1)

s.append([1,0])
while len(s) > 0:
    n,preN = s.pop()
    ans[n] = ans[preN]+node_score[n]
    for to in node[n]:
        if to != preN:
            s.append([to,n])

print(" ".join(list(map(str,ans[1:N+1]))))
A,B = map(int,input().split())

if B == 1:
  return 0

if B <= A:
  return 1

B -= A
ans = 1

while B >= 0:
  B -= (A - 1)
  ans += 1
  
print(ans)
exit()


### FIXED CODE ###

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

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

if B <= A:
  print(1)
  exit()

B -= A
ans = 1

while B > 0:
  B -= (A - 1)
  ans += 1
  
print(ans)
exit()
#N, M = list(map(int, input().strip().split()))
X = int(input())

for i in range(-100, 101):
  for j in range(-100, 101):
    if i**5 - j**5 == X:
      A, B = i, j
      break
print(A, B)

### FIXED CODE ###

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

start = -200
end = 201

for i in range(start, end):
  for j in range(start, end):
    if i**5 - j**5 == X:
      A, B = i, j
      break
print(A, B)
N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0]*(M+2)
flag=1
ans=float('inf')
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0]*N

if cnt==0:
  print(-1)
else:
  print(ans)
      



### FIXED CODE ###

N,M,X=[int(x) for x in input().rstrip().split()]
l=[]
for i in range(N):
  ca=[int(x) for x in input().rstrip().split()]
  l.append(ca)

A=[0 for i in range(M+2)]
flag=1
ans=10**10
cnt=0
for i in range(2**N):
  flag=1
  cost=0
  for j in range(N):
    if i>>j & 1:
      now=l[N-j-1]
      cost+=now[0]
      for s in range(M):
        A[s]+=now[s+1]
  for t in range(M):
    if X<=A[t]:
      continue
    else:
      flag=0
      break
  if flag==1:
    ans=min(ans,cost)
    cnt+=1

  A=[0 for v in range(M+2)]

if cnt==0:
  print(-1)
else:
  print(ans)
nn = int(input())
s=[]
for i in range(nn):
    s.append(input())

list_s = []
for j in range(nn):
    #list_s.append(sorted(list(s[j])))
    list_s.append(''.join(sorted(s[j])))

m = {}
for i in range(nn):
    if list_s[i] not in m:
        m[list_s[i]] = 1
    else:
        m[list_s[i]] += 1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
  
count = 0
for k in range(len(m)):
        count += cmb( m[list_s[k]], 2 )


print(count)

### FIXED CODE ###

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

list_s = []
for j in range(n):
    #list_s.append(sorted(list(s[j])))
    list_s.append(''.join(sorted(s[j])))

m = {}
for i in range(n):
    if list_s[i] not in m:
        m[list_s[i]] = 1
    else:
        m[list_s[i]] += 1

def cmb(num):
    if num == 1:
        return 0
    elif num == 2:
        return 1
    else:
        return (num * (num-1) // 2)
  
count = 0
for k in m.keys():
        count += cmb( m[k] )


print(count)
N = int(input())
g = {i:[] for i in range(N)}
AB = []
K = -float('inf')
for _ in range(N-1):
  a,b = map(int,input().split())
  AB.append([a-1,b-1])
  g[a-1].append(b-1)
  g[b-1].append(a-1)
  K = max(K,len(g[a-1]), len(g[b-1]))

print(K)
k = 1
print(k)
for i in range(1,N-1):
  a,b = AB[i]
  if (AB[i][0] in g[a-1] and AB[i][0] in g[b-1]) or (AB[i][1] in g[a-1] and AB[i][1] in g[b-1]):
    k +=1
    k = 1 if k==5 else k
  print(k)

### FIXED CODE ###

from collections import deque
def bfs(si):
  q = deque()
  q.append([si,-1])
  used.add(si)
  while len(q)>0:
    prvi, prvcol = q.popleft()
    col = 1 
    for i in g[prvi]:
      if i in used:continue
      if col == prvcol: col += 1
      cols[eds[str(min(prvi,i))+'-'+str(max(prvi,i))]] = col
      q.append([i,col])
      used.add(i)
      col += 1

N = int(input())
g = {i:[] for i in range(N)}
eds = {}
for i in range(N-1):
  a,b = map(int,input().split())
  eds[str(a-1)+'-'+str(b-1)] = i
  g[a-1].append(b-1)
  g[b-1].append(a-1)

used = set([])
cols = [-1 for _ in range(N-1)]  
bfs(0)
print(max(cols))
[print(col) for col in cols]
import os
input = os.stdin.readline
A, B, C = map(int, input().split())

flag = False

for i in range(B + 1):
    if A * i %B == c:
        flag = True
        break

print('YES' if flag else 'NO')
    


### FIXED CODE ###

A, B, C = map(int, input().split())

flag = False

for i in range(B + 1):
    if A * i % B == C:
        flag = True
        break

print('YES' if flag else 'NO')
def Input():
    return mapt(int, input().split(" "))

def main():
    a, b = Input()
    print(0 if a < b else 10)

main()

### FIXED CODE ###

def main():
    a, b = map(int, input().split(" "))
    print(0 if a < b else 10)

main()
n,m=map(int, input().split())
d = {}
flag = True
for _ in range(m):
    s, c = input().split()
    if d.get(s):
        if d.get(s) == c:
            continue
        else:
            flag = False
            break
    else:
        d[s] = c
if flag:
    if max(map(int, d.keys())) == n:
        l = ['0']*n
        for i in range(1,n+1):
            if d.get(str(i)):
                l[i-1] = d.get(str(i))
        if l[0] == '0':
            print(-1)
        else:
            print(''.join(l))
    else:
        print(-1)
else:
    print(-1)


### FIXED CODE ###

n,m=map(int, input().split())
l = [None]*n
msg=''
for _ in range(m):
    s, c = input().split()
    index = int(s)-1
    if l[index] is None:
        l[index] = c
    else:
        if l[index] == c:
            continue
        else:
            msg=-1
            break
if l[0] is None and len(l) != 1:
    l[0]='1'
l = list(map(lambda x: '0' if x is None else x, l))
if msg == -1:
    print(msg)
elif l[0] == '0' and len(l) != 1:
    print(-1)
else:
    print(msg.join(l))
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    A = list(map(int, input().split()))[::-1]

    if A[0] != 2:
        print(-1)
    else:
        prev_min, prev_max = 2, 3
        for i in range(1, k):
            a = A[i]
            if a > prev_max:
                print(-1)
                break
            else:
                if prev_min % a == 0:
                    now_min = prev_min
                else:
                    now_min = (prev_min // a) * a + a
                now_max = now_min + a - 1
                prev_min, prev_max = now_min, now_max
        else:
            print(now_min, now_max)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    k = int(input())
    A = list(map(int, input().split()))[::-1]

    if A[0] != 2:
        print(-1)
    else:
        prev_min, prev_max = 2, 3
        for i in range(1, k):
            a = A[i]
            if a > prev_max:
                print(-1)
                break
            else:
                if prev_min % a == 0:
                    now_min = prev_min
                else:
                    now_min = (prev_min // a + 1) * a
                if now_min > prev_max:
                    print(-1)
                    break
                diff = prev_max - now_min
                now_max = now_min + (diff // a + 1) * a - 1
                prev_min, prev_max = now_min, now_max
        else:
            print(prev_min, prev_max)


if __name__ == '__main__':
    resolve()
N,M = map(int, input().split())
a = [0]*(M+1)
for i in range(M): a[i] = int(input())
a[M] = N+1

inf = 10**9+7

def comb(cur,ai):
    if ai - cur == 1:
        return 1
    elif ai - cur == 2:
        return 2
    elif ai <= cur:
        return 0
    return((comb(cur, ai-1)+comb(cur,ai-2))%inf)

cur = 0
if a[0] == 1: cur += 2
cnt = 1
for i in range(M+1):
    if a[0] == 1 and i == 0: continue
    if cur == a[i]:
        cnt = 0
        break
    cnt *= comb(cur,a[i]-1)%inf
    cnt = cnt%inf
    cur = a[i]+1

print(cnt%inf)


### FIXED CODE ###

N,M = map(int, input().split())
a = [-1]*(M+2)
a[M+1] = N+1
diff = 0
for i in range(1,M+2):
    if i != M+1: a[i] = int(input())
    diff = max(diff, a[i]-a[i-1])

inf = 10**9+7

dp = [0]*diff
dp[0] = 0
dp[1] = 1
for i in range(2,diff):
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] = dp[i]%inf

cnt = 1
for i in range(1,M+2):
    da = a[i]-a[i-1]-1
    if da == 0:
        cnt = 0
        break
    else:
        cnt *= dp[da]
        cnt = cnt%inf

print(cnt%inf)
n,m,x=map(int,input().split())
l=[0]*n
for i in range(n):
    long=list(map(int,input().split()))
    l[i]=long

ans=10**7
for i in range(1<<n):
    money=0
    a=[0]*n
    for j in range(n):
        if (i>>j)%2==1:
            money+=l[j][0]
            for k in range(m):
                a[k]+=l[j][k+1]
    cnt=0
    for p in a:
        if p>=x:
            cnt+=1
            if cnt==m:
                ans=min(ans,money)
if ans==10**9:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

n, m, X = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
    
for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)
def resolve():
    N, M, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    sumA = 0
    ai, bi = 0, 0
    while sumA <= K:
        if ai < N and A[ai] < B[bi] and sumA + A[ai] <= K:
            sumA += A[ai]
            ai += 1
        elif bi < M and sumA + B[bi] <= K:
            sumA += B[bi]
            bi += 1
        else:
            break
    print(ai + bi)


resolve()


### FIXED CODE ###

def check(A, mid, K):
    return A[mid] <= K


def binMax(A, K):
    ok = -1  # maxVal when minimize
    ng = len(A)  # maxVal when maximize
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(A, mid, K):
            ok = mid
        else:
            ng = mid
    return ok


def resolve():
    N, M, K = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    B = [int(i) for i in input().split()]
    presumA = [0 for _ in range(N + 1)]
    for i in range(N):
        presumA[i + 1] = presumA[i] + A[i]
    presumB = [0 for _ in range(M + 1)]
    for i in range(M):
        presumB[i + 1] = presumB[i] + B[i]
    startA = binMax(presumA, K)
    maxA = 0
    for ai in range(startA, -1, -1):
        maxA = max(maxA, ai + binMax(presumB, K - presumA[ai]))
    print(maxA)

resolve()
a,b = map(int,input().split())
if b<=a:
  if a = 1:
    print(a)
  else:
    print(a+1)
else:
  print(a)

### FIXED CODE ###

a,b = map(int,input().split())
c = a - 1
if b<a :
  print(c)
else:
  print(a)
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)
n=int(input())
ab=[]
root=[[] for i in range(n)] 
for i in range(n-1):
    a,b=map(int,input().split())
    root[a-1].append((i,b-1))
    root[b-1].append((i,a-1))
c=0
for i in range(n):
    c=max(c,len(root[i]))
print(c)
color=[0]*(n-1)

def dfs(node,par,c):
    if c!=1:
        i=1
    else:
        i=2
    for idx,x in root[node]:
        if x==par:
            continue
        if color[idx]==0:
            color[idx]=i
            dfs(x,node,i)
            i+=1
            if i==c:
                i+=1
dfs(0,-1,0)
for i in range(n-1):
    print(color[i])
import numpy as np
h,w,m=map(int,input().split())

hb=[0]*h
wb=[0]*w
mp=np.zeros((h,w))
for i in range(m):
  hh,ww=map(int,input().split())
  hh-=1
  ww-=1
  hb[hh]+=1
  wb[ww]+=1
  mp[hh][ww]=1

hmx=[i for i, x in enumerate(hb) if x == max(hb)]
wmx=[i for i, x in enumerate(wb) if x == max(wb)]
mhb=max(hb)
mwb=max(wb)
fl=False
for i in hmx:
  for j in wmx:
    if mp[i][j]!=1:
      print(mhb+mwb)
      fl=True
      break
  if fl:
    break
else:
  print(mhb+mwb-1)



### FIXED CODE ###

#import random

def putmx(lis,mx):
  ret=[]
  for (i,j) in zip(range(len(lis)),lis):
    if j==mx:
      ret.append(i)
  return ret
  

h,w,m=map(int,input().split())
hb=[0]*h
wb=[0]*w
bmb=[]
for i in range(h):
  bmb.append({-1})
for i in range(m):
  hh,ww=map(int,input().split())
  hh-=1
  ww-=1
  bmb[hh].add(ww)
  hb[hh]+=1
  wb[ww]+=1
mhb=max(hb)
mwb=max(wb)
hmx=putmx(hb,mhb)
wmx=set(putmx(wb,mwb))

#print(hb,wb,hmx,wmx)
fl=False
for i in hmx:
  if wmx|bmb[i]!=bmb[i]:
    print(mhb+mwb)
    break
else:
  print(mhb+mwb-1)

#print(hmx,wmx,bmb)
s = input()
if s == 'ABC':
	print('ARC)
else:
	print('ARC')


### FIXED CODE ###

s = input()
if s == 'ABC':
	print('ARC')
else:
	print('ABC')
H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(W):
    s.append(input())

for i in range(H-1):
    for j in range(W-1):
        if s[i][j]=='#':
            if s[i][j+1]=='.' and s[i+1][j]=='.':
                print('No')
                exit()
print(ans)

### FIXED CODE ###

H,W  = map(int,input().split())
s = []
ans = 'Yes'
for _ in range(H):
    s.append(input())

for i in range(1,H-1):
    for j in range(1,W-1):
        if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':
                print('No')
                exit()
print(ans)
n = int(input())
h = [int(i) for i in input().split()]
m = [0]
for i in range(1,n-1):
  if h[i-1] < h[i] and h[i] >= h[i+1]:
    m.append(h.index(h[i]))
m.append(n-1)
l = [m[i] - m[i-1] for i in range(1,len(m))]
if m == [0,n-1] and h[0] < h[1]:
  print("0")
else:
  print(max(l))


### FIXED CODE ###

n = int(input())
h = [int(i) for i in input().split()]
ans = []
a = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    a += 1
  else:
    ans.append(a)
    a = 0
ans.append(a)
print(max(ans))
N=int(input())
a=list(map(1/int(),input().split()))

print(1/sum(a))

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
for i in range(0,N):
	a[i]=1/a[i]
print(1/sum(a))
s = list(map(lambda x: int(x), input().split(" "))).sum()
if s>=10:
  print("error")
else:
  print(s)

### FIXED CODE ###

a,b = list(map(lambda x: int(x), input().split(" ")))
if a+b>=10:
  print("error")
else:
  print(a+b)
S=int(input())
W=10
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S=W:
	print("unsafe")


### FIXED CODE ###

S,W=map(int, input().split())
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S==W:
	print("unsafe")
# n, k: 数値　s: 文字列　が与えられる
# k文字目を入れ替えよ

n, k = map(int, input().split())
s = input()

dic = {"A":"a", "B":"b", "C":"c"}

# キーとなる文字　文字列のインデックスは0から
# s[k-1]

# 小文字にする表現がある
# print(s[:k] + )

# [開始インデックス:終了インデックス] 数値は　より大　と　未満
print(s[:k-1] + dic.get("{s[k-1]}") + s[k-1:])

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
print(s[:k-1] + s[k-1].lower() + s[k:])