Harryxun/stf_run huggingface dataset:
import numpy as np
from collections import Counter
H,W,M=map(int,input().split())

X=[]
Y=[]
tt=[]
for i in range(M):
    inp=list(map(int,input().split()))
    X.append(inp[0])
    Y.append(inp[1])
    tt.append((inp[0],inp[1]))
Z1=Counter(X)
Z2=Counter(Y)
maxmax=0
for i in Z1.keys():
    for j in Z2.keys():
        aa=0
        if (i,j) in tt:
            aa=-1
        if maxmax<(aa+Z1[i]+Z2[j]):
            maxmax=(aa+Z1[i]+Z2[j])
print(maxmax)


### FIXED CODE ###

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

if N%X==0:
    print(str(((N//X))*T))
else:
    print(str(((N//X)+1)*T))
n = int(input())

if n <=999:
  print("ABC")
else:
  print("ABD"))

### FIXED CODE ###

n = int(input())
if n <=999:
  print("ABC")
else:
  print("ABD")
s= input()
print(s.replace('2017','2018')

### FIXED CODE ###

s= input()
print(s.replace('2017','2018'))
a,b,c,d,e,k=map(int,input().split())
print("Yay!" * (e-a > k) or ":(")

### FIXED CODE ###

a=int(input())
input()
input()
input()
e=int(input())
k=int(input())
print("Yay!" * (e-a <= k) or ":(")
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = a[0]
for num in a[1:]:
    l = lcm(num, l)

ans = 0
for num in a:
    ans += (l - 1) % num

print(ans)



### FIXED CODE ###

import fractions as math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

l = a[0]
for num in a[1:]:
    l = lcm(num, l)

ans = 0
for num in a:
    ans += (l - 1) % num

print(ans)
A = [int(i) for i in input().split()
A.sort()
mid = A[1]
s = [i for i in A if i != mid]
print(s[0])

### FIXED CODE ###

A = [int(i) for i in input().split()]
A.sort()
mid = A[1]
s = [i for i in A if i != mid]
print(s[0])
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
ans = 0
 
for xx in range(a+1):
    A = 500*xx
    for y in range(b+1):
        B = 100*y
        for z in range(c+1):
            C = 50*z
            if x == A+B+C:
                ans += 01
            else:
                continue
 
 
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
from itertools import product
import sys
 
 
def solve(AA: int, BB: int, CC: int, XX: int):
    print(sum(
        1
        for a, b, c in product(range(AA + 1), range(BB + 1), range(CC + 1))
        if a * 500 + b * 100 + c * 50 == XX
    ))
 
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, C, X)
 
 
if __name__ == '__main__':
    main()
N=int(input())
H=list(map(int, input().split()))
count=0
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
        Z=Z+1
        break
    if A == B:
        count=count+1
        if count == 2:
            print('No')
            Z=Z+1
            break
if Z == 0:
    print('Yes')

### FIXED CODE ###

N=int(input())
H=list(map(int, input().split()))
Z=0
count=0
for i in range(N-1):
    A=H[i+1]
    B=H[i]-1
    if A < B:
        print('No')
        Z=Z+1
        break
    if A == B:
        count=count+1
        if count >=2 and A < C:
            print('No')
            Z=Z+1
            break
        else:
            C=A
if Z == 0:
    print('Yes')
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")

MOD = 998244353
class Combination(object):
	def __init__(self, N, MOD):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1
 
		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % MOD
			self.inv[i] = self.inv[MOD % i] * (MOD - (MOD // i)) % MOD
			self.finv[i] = self.finv[i - 1] * self.inv[i] % MOD
 
	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % MOD


def main():
    N, M, K = map(int, input().split())

    Com = Combination(N-1, MOD)
    ans = 0
    for k in reversed(range(K+1)):
        ans += M * pow(M-1, N-k-1, MOD) * Com.com(N-1, k)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")

MOD = 998244353
class Combination(object):
	def __init__(self, N, MOD):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1
 
		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % MOD
			self.inv[i] = self.inv[MOD % i] * (MOD - (MOD // i)) % MOD
			self.finv[i] = self.finv[i - 1] * self.inv[i] % MOD
 
	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % MOD


def main():
    N, M, K = map(int, input().split())

    if N == 1:
        print(M)
        return

    Com = Combination(N-1, MOD)
    ans = 0
    for k in reversed(range(K+1)):
        ans += M * pow(M-1, N-k-1, MOD) * Com.com(N-1, k)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()
H, W = map(int, input().split())
maze = [input() for _ in range(H)]
seen = [[-1] * W for _ in range(H)]

from collections import deque

queue = deque()
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            queue.append([j, i, 0])
            seen[j][i] = 0

def bfs(maze, seen):
    while queue:
        y, x, c = queue.popleft()
        for i, j in [1, 0], [-1, 0], [0, 1], [0, -1]:
            dy = y + i
            dx = x + j
            if dy < 0 or H <= dy or dx < 0 or W <= dx:
                continue
            if seen[dy][dx] > -1:
                continue
            if maze[dy][dx] == '#':
                continue
            seen[dy][dx] = c + 1
            queue.append([dy, dx, c+1])

def check_max(seen):
    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, seen[i][j])
    return ans
    
bfs(maze, seen)
print(check_max(seen))

### FIXED CODE ###

from collections import deque



def bfs(maze, visited, queue, H, W):
    count = 0
    while queue:
        y, x = queue.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + i, x + j
            if -1 < new_y < H and -1 < new_x < W:
                if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                    visited[new_y][new_x] = visited[y][x] + 1
                    queue.append([new_y, new_x])

    ans = -1
    for i in range(H):
        for j in range(W):
            ans = max(ans,visited[i][j])
    return ans

H, W = map(int,input().split())

maze = [input() for i in range(H)]
visited = [[-1] * W for i in range(H)]

queue = deque([])
for i in range(H):
    for j in range(W):
        if maze[i][j] == "#":
            visited[i][j] = 0
            queue.append([i, j])

print(bfs(maze, visited, queue, H, W))
n, m = map(int, input().split())
adj = [[] for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    adj[a].append(b)
    adj[b].append(a)
# print(adj)
from collections import deque
q = deque([0])
dist = [-1]*n
ans = [0]*n

while q:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1: continue
        # ans[to] = now 
        dist[to] = dist[now] + 1
        q.append(to)
    # print(adj[now], dist, ans, q)
    
print('Yes')
for i in range(1,n):
    print(dist[i]+1)


### FIXED CODE ###

n, m = map(int ,input().split())
 
adj = [[] for _ in range(n)]
 
for i in range(m):
    a, b = map(int, input().split())
    a-=1
    b-=1
    adj[a].append(b)
    adj[b].append(a)
 
from collections import deque
q = deque()
 
dist = [-1] * n
ans = [0] * n
 
q.append(0)
while len(q) != 0:
    now = q.popleft()
    for to in adj[now]:
        if dist[to] != -1:continue
        dist[to] = dist[now] + 1
        q.append(to)
        ans[to] = now
 
print("Yes")
for i in range(1, n):
    print(ans[i] + 1)
import math
A, B = map(int,input().split())
LA = []
LB = []
for i in range(int(math.log2(A))+1):
    P = A % (2**(i+1))
    Q = P % (2**i)
    R = (P-Q)//(2**i)
    LA.append(R)
for i in range(int(math.log2(B))+1):
    P = B % (2**(i+1))
    Q = P % (2**i)
    R = (P-Q)//(2**i)
    LB.append(R)
LS = []
def Q(a,b):
    return (a%2,b%2)

if A == B:
    print(A)
elif Q(A,B) == (0,0):
    LS.append(((B-A)//2)%2)
    for i in range(1,len(LA)):
        LS.append(LB[i])
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(LB[i])
elif Q(A,B) == (0,1):
    LS.append(((B-A+1)//2)%2)
    for i in range(1,len(LA)):
        LS.append(0)
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(0)
elif Q(A,B) == (1,0):
    LS.append(((B-A+1)//2)%2)
    for i in range(1,len(LA)):
        LS.append((LA[i]+LB[i])%2)
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(LB[i])
else:
    LS.append(((B-A+2)//2)%2)
    for i in range(1,len(LA)):
        LS.append(LA[i])
    if len(LB) > len(LA):
        for i in range(len(LA),len(LB)):
            LS.append(0)
            
ANS = 0
for i in range(len(LS)):
    ANS += (2**i)*LS[i]
    
print(ANS)

### FIXED CODE ###

import math
A, B = map(int,input().split())
if A == 0:
    if B % 4 ==0:
        print(B)
    elif B % 4 == 1:
        print(1)
    elif B % 4 == 2:
        print(B+1)
    else:
        print(0)
elif A == B:
    print(A)
else:
    LA = []
    LB = []
    for i in range(int(math.log2(A))+1):
        P = A % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LA.append(R)
    for i in range(int(math.log2(B))+1):
        P = B % (2**(i+1))
        Q = P % (2**i)
        R = (P-Q)//(2**i)
        LB.append(R)
    LS = []
    def Q(a,b):
        return (a%2,b%2)
    if A == B-1:
        if Q(A,B) == (0,1):
            print(1)
        else:
            LS.append(1)
            if len(LA) == len(LB):
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            else:
                for i in range(len(LA)):
                    LS.append(1)
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
    else:
        if Q(A,B) == (0,0):
            if (B-A+1)%4 ==1:
                print(B)
            else:
                print(B+1)
        elif Q(A,B) == (0,1):
            if (B-A+1)%4 == 0:
                print(0)
            else:
                print(1)
        elif Q(A,B) == (1,0):
            if (B-A+1)%4 == 0:
                LS.append(0)
            else:
                LS.append(1)
            if len(LA) > 1:
                for i in range(1,len(LA)):
                    LS.append((LA[i]+LB[i])%2)
            if len(LB) > len(LA):
                for i in range(len(LA),len(LB)):
                    LS.append(LB[i])
            ANS = 0
            for i in range(len(LS)):
                ANS += (2**i)*LS[i]
            print(ANS)
        else:
            if (B-A+1)%4 == 1:
                print(A)
            else:
                print(A-1)
import sys
sys.setrecursionlimit(100000)
input=sys.stdin.readline


def calculate(num,pre=-1):
    for i in A[num]:
        if i==pre:continue
        node[i] +=node[num]
        calculate(i,num)


n,q=[int(_) for _ in input().split()]
A=[[] for i in range(n)]
node=[0]*n

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

for i in range(q):
    p,x=[int(_) for _ in input().split()]
    node[p-1] +=x

calculate(0)
print(*node)

### FIXED CODE ###

# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

#n = int(input())
n,q = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for i in range(n-1):
    a,b = [int(i) for i in readline().split()]
    g[a-1].append(b-1)
    g[b-1].append(a-1)

add = [0]*n
for _ in range(q):
    p,x = [int(i) for i in readline().split()]
    add[p-1] += x

ans = [0]*n
#ans[0] = add[0]

def dfs(v,p,value): #p: parent of v
    value += add[v]
    ans[v] = value
    for c in g[v]:
        if c == p: continue
        dfs(c,v,value)

dfs(0,-1,0)

#print(add)

print(*ans)
"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+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

import math
a, b = map(int, input().split())
li = factorization(math.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)

### FIXED CODE ###


"""nを素因数分解"""
"""2以上の整数n => [(素因数, 指数), ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(n**0.5)+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

import fractions
a, b = map(int, input().split())
li = factorization(fractions.gcd(a, b))

if li[0][0] == 1:
    print(1)
else:
    print(len(li)+1)
a, b = map(int, raw_input().split()):

if  a > b:
print 'a > b'
elif  a < b:
print 'a < b'
else:
print 'a == b'

### FIXED CODE ###

a,b=map(int,raw_input().split())
if a > b:
    print 'a > b'
elif a < b:
    print 'a < b'
else:
    print 'a == b'
N, K = map(int, input().split())

def runLength(s):
  if len(s) == 0: return []
  if len(s) == 1: return [(s, 1)]
  res = []
  lc = 1
  for i in range(1, len(s)):
    if s[i-1] == s[i]:
      lc += 1
    else:
      res.append((s[i-1], lc))
      lc = 1
  res.append((s[i], lc))
  return res

S = runLength(input())
accsum = [0] * (1 + (S[0][0] == "0"))
for i in range(len(S)):
  accsum.append(accsum[-1] + S[i][1])
if S[-1][0] == "0":
  accsum.append(accsum[-1])
print(max([accsum[i] - accsum[i-2*K-1] for i in range(2*K+1, len(accsum), 2)]) if N >= 2*K else N)

### FIXED CODE ###

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

def runLength(s):
  if len(s) == 0: return []
  if len(s) == 1: return [(s, 1)]
  res = []
  lc = 1
  for i in range(1, len(s)):
    if s[i-1] == s[i]:
      lc += 1
    else:
      res.append((s[i-1], lc))
      lc = 1
  res.append((s[i], lc))
  return res

S = runLength(input())
accsum = [0] * (1 + (S[0][0] == "0"))
for i in range(len(S)):
  accsum.append(accsum[-1] + S[i][1])
if S[-1][0] == "0":
  accsum.append(accsum[-1])
print(max([accsum[i] - accsum[i-2*K-1] for i in range(2*K+1, len(accsum), 2)]) if len(accsum) > 2*K+2 else N)
x, n = map(int, input().split())
P = list(map(int, input().split()))
if not P:
    print(x)
	exit(0)
for i in range(x, 102):
    if i not in P:
        upper = i
        break
    else:
        upper = 102
for i in range(x, -1, -1):
    if i not in P:
        lower = i
        break
    else:
        lower = 0
print(lower if x-lower <= upper - x else upper)

### FIXED CODE ###

x, n = map(int, input().split())
P = list(map(int, input().split()))
if not P:
    print(x)
    exit(0)
for i in range(x, 102):
    if i not in P:
        upper = i
        break
    else:
        upper = 102
for i in range(x, -1, -1):
    if i not in P:
        lower = i
        break
    else:
        lower = 0
print(lower if x-lower <= upper - x else upper)
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
def rle(s):#計算量N
    c = 0
    tmp, count, ans = s[0], 1, []
    for i in range(1,len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans.append((-1)*count)
            c += count-1
            count = 1
            tmp = s[i]
    if count > 1:
        ans.append(count*(-1))
        c += count-1
    return ans,c #最大2N文字
N,K = map(int,input().split())
S = input()
ans,c = rle(S)
n = len(ans)
import heapq
heapq.heapify(ans)
MIN = min(n.K)
for i in range(MIN):

    a = heapq.heappop(ans)
    c += 2
if c >= N:
    c = N-1
print(c)

### FIXED CODE ###

import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
def rle(s):#計算量N
    c = 0
    tmp, count, ans = s[0], 1, []
    for i in range(1,len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans.append((-1)*count)
            c += count-1
            count = 1
            tmp = s[i]
    if count > 1:
        ans.append(count*(-1))
        c += count-1
    return ans,c #最大2N文字
N,K = map(int,input().split())
S = input()
ans,c = rle(S)
n = len(ans)
import heapq
heapq.heapify(ans)
MIN = min(n,K)
for i in range(MIN):

    a = heapq.heappop(ans)
    c += 2
if c >= N:
    c = N-1
print(c)
a,b = map(int,input().split())
S = input()
def crazy(a,b,S):
    num = "0123456789"
    S = S[:A] + S[A+1:]
    if S[a] != "-":
        return False
    for i in S[:a]:
        if i not in num:
            return False
    return True

if crazy(a,b,S):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#coding: utf-8
M = int(input())
x = 24 + (24 - M) 
print(x)
N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n-k) % p
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p


memo = [[-1 for _ in range(K + 1)] for _ in range(K + 1)]


def dp(n, k):
    # n個のボールをk個のグループに分ける(空のグループを許容)
    if n <= 0 or k <= 1:
        return 1
    if memo[n][k] >= 0:
        return memo[n][k]
    memo[n][k] = 0
    for i in range(n, -1, -1):
        memo[n][k] += dp(n - i, k - 1) % MOD
    return memo[n][k]


for i in range(1, K + 1):
    print(comb(N - K + 1, i, MOD) * comb(K - 1, i - 1) % MOD)


### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10 ** 9 + 7


def comb(n, k, p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n < 0 or k < 0 or n < k:
        return 0
    if n == 0 or k == 0:
        return 1
    a = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n-k) % p
    return (a*power_func(b, p-2, p)*power_func(c, p-2, p)) % p


def power_func(a, b, p):
    """a^b mod p を求める"""
    if b == 0:
        return 1
    if b % 2 == 0:
        d = power_func(a, b//2, p)
        return d*d % p
    if b % 2 == 1:
        return (a*power_func(a, b-1, p)) % p


memo = [[-1 for _ in range(K + 1)] for _ in range(K + 1)]


def dp(n, k):
    # n個のボールをk個のグループに分ける(空のグループを許容)
    if n <= 0 or k <= 1:
        return 1
    if memo[n][k] >= 0:
        return memo[n][k]
    memo[n][k] = 0
    for i in range(n, -1, -1):
        memo[n][k] += dp(n - i, k - 1) % MOD
    return memo[n][k]


for i in range(1, K + 1):
    print(comb(N - K + 1, i, MOD) * comb(K - 1, i - 1, MOD) % MOD)
n = int(input())
y = 1

while y <= n :
    if(y % 3 == 0):
        print(' %d'%y,end='')
    else:
        p = y
        while(p != 0):
            if(p % 10 == 3):
                print(' %d'%y,end='')
                break
            p //= 10
    y+=1
print()



### FIXED CODE ###

n = int(input())
y = 1

while y <= n :
    if(y % 3 == 0):
        print(' %d'%y,end='')
    else:
        p = y
        while(p != 0):
            if(p % 10 == 3):
                print(' %d'%y,end='')
                break
            p //= 10
    y+=1
print()
K = input()
S = input()
if (len(S) <= K):
  print(S)


### FIXED CODE ###

k = int(input())
s = str(input())
if len(s) <= k:
    print(s)
else:
    print((s[:k]) + "...")
s=list(input())
for i in range(100):
    if s[i] == '1':
        continue
    else :
        print(s[i])
        break

### FIXED CODE ###

s=list(input())
k=int(input())
#print(s)
#print(len(s))
#print(k)
for i in range(len(s)):
    if s[i] != '1' or i == len(s)-1:
        if k <= i:
            print(s[k-1])
        else :
            print(s[i])
        break
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

for i in range(M):
    A[0] = int(A[0] / 2)
    if A[0] < A[1]:
        A.sort(reverse=True)

print(sum(A))


### FIXED CODE ###

def pushHeap(array, elem):
    n = len(array)
    array.append(elem)
    while n != 0:
        i = int((n - 1) / 2)
        if array[n] > array[i]:
            tmp = array[n]
            array[n] = array[i]
            array[i] = tmp
        n = i


def popHeap(array):
    n = len(array) - 1
    array[0] = array[n]
    del array[-1]
    i = 0
    while 2 * i + 1 < n:
        j = 2 * i + 1
        if j != n - 1 and array[j] < array[j + 1]:
            j += 1
        if array[i] < array[j]:
            tmp = array[j]
            array[j] = array[i]
            array[i] = tmp
        i = j


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

for a in A:
    pushHeap(heap_A, a)

for _ in range(M):
    discount_max = int(heap_A[0] / 2)
    popHeap(heap_A)
    pushHeap(heap_A, discount_max)

print(sum(heap_A))
x, k ,d = map(int, input().split())
a=[0]*(k+1)
a[0] = x
for i in range(1,k+1):
    a[i] = min(abs(a[i-1]-d), abs(a[i-1]+d))
print(a[k])

### FIXED CODE ###

x, k ,d = map(int, input().split())
x=abs(x)
if k*d <= x:
    print(x-k*d)
else:
    xx = x
    x -= min(k, x//d)*d
    k -= min(k, xx//d)
    if k % 2 != 0:
        ans = min(abs(x-d),abs(x+d))
    else:
        ans = min(abs(x), abs(x-2*d))
    print(ans)