Harryxun/stf_run huggingface dataset:
def main():
    import math
    n,k=map(int,input().split(" "))
    a=map(int,input().split(" "))
    g=a[0]
    m=max(a)
    for i in range(n):
        g=math.gcd(g,a[i])
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()

### FIXED CODE ###

def gcd(a,b):
    if a==0: return b
    else: return gcd(b%a,a)

def main():
    n,k=map(int,input().split(" "))
    a=list(map(int,input().split(" ")))
    g=a[0]
    m=a[0]
    for e in a:
        g=gcd(g,e)
        if m<e: m=e
    if k % g==0 and k<=m:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

main()
k, t = map(int, input().split())
a = list(map(int, input().split()))

ans = max(a)

for i in a:
    if i != max(a):
        ans -= i
print(max(0, ans)


### FIXED CODE ###

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

print(max(max(a)-1-sum(a)+max(a), 0))
x = int(raw_input())
y = int(raw_input())

if x>y:
  print(int(2*x-1))
elif x<y:
  print(int(2*y-1))
elif x == y:
  print(int(x+y))

### FIXED CODE ###

x,y = map(int,input().split())
if x>y:
  print(int(2*x-1))
elif x<y:
  print(int(2*y-1))
elif x == y:
  print(int(x+y))
class SegTree(object):
  def __init__(self,op,e,n,init_val):
    self.num = 1<<(300000-1).bit_length() 
    self.S = [e]*self.num*2
    self.op = op
    self.e = e
    for i,v in enumerate(init_val): self.S[self.num+i] = v
    for i in range(self.num-1,0,-1):
      self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
  def set(self,index,value):
    idx = self.num+index
    self.S[idx] = value
    while idx>0:
      self.S[idx>>1] = self.op(self.S[idx],self.S[idx^1])
      idx>>=1
  def prod(self,l,r):
    res = self.e
    r += self.num
    l += self.num
    while l<r:
      if l&1:
        res = self.op(res,self.S[l])
        l += 1
      if r&1:
        res = self.op(self.S[r-1],res)
      l >>= 1
      r >>= 1
    return res
        
N,K = map(int,input().split())
ST = SegTree(max,0,300000,[0]*300000)
ans = 1
for i in range(N):
  A = int(input())-1
  v = ST.prod(A-K,A+K+1)+1
  ans = max(ans,v)
  ST.set(A,v)
print(ans)

### FIXED CODE ###

class SegTree(object):
  def __init__(self,op,e,n,init_val):
    self.num = 1<<(n-1).bit_length() 
    self.S = [e]*self.num*2
    self.op = op
    self.e = e
    for i,v in enumerate(init_val): self.S[self.num+i] = v
    for i in range(self.num-1,0,-1):
      self.S[i] = self.op(self.S[i*2], self.S[i*2+1])
      
  def set(self,index,value):
    idx = self.num+index
    self.S[idx] = value
    while idx>0:
      self.S[idx>>1] = self.op(self.S[idx],self.S[idx^1])
      idx>>=1
      
  def prod(self,l,r):
    res = self.e
    l = max(0,l)+self.num
    r = min(r,self.num-1)+self.num
    while l<r:
      if l&1:
        res = self.op(res,self.S[l])
        l += 1
      if r&1:
        res = self.op(self.S[r-1],res)
      l >>= 1
      r >>= 1
    return res
        
N,K = map(int,input().split())
ST = SegTree(max,0,300001,[0]*300001)
ans = 1
for i in range(N):
  A = int(input())
  l,r = max(0,A-K),min(A+K,300000)
  v = ST.prod(l,r+1)+1
  ans = max(ans,v)
  ST.set(A,v)
print(ans)
N = int(input())
S = str(input())
K = int(input())
H = ""
for i in range(N):
  if(SS[i]==SS[K-1]):
    H+=SS[i]
  else:
    H+="*"
print(H)


### FIXED CODE ###

N = int(input())
S = str(input())
K = int(input())
H = ""
for i in range(N):
  if(S[i]==S[K-1]):
    H+=S[i]
  else:
    H+="*"
print(H)
from collections import deque

h, w = map(int, input().split())
lis = [] * h
for i in range(h):
    lis.append(tuple(map(int, input().split())))
flg = False
res = []

for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if not flg and lis[i][j] % 2 == 1:
                res.append(i+1)
                res.append(j+1)
                flg = not flg
            elif flg and lis[i][j] % 2 == 0:
                print(*res, i+1, j+1, sep=" ")
                res = []
                res.append(i+1)
                res.append(j+1)
            elif flg and lis[i][j] % 2 == 1:
                print(*res, i+1, j+1, sep=" ")
                res = []
                flg = not flg
    else:
        for j in range(w -1, -1, -1):
            if not flg and lis[i][j] % 2 == 1:
                res.append(i + 1)
                res.append(j + 1)
                flg = not flg
            elif flg and lis[i][j] % 2 == 0:
                print(*res, i + 1, j + 1, sep=" ")
                res = []
                res.append(i + 1)
                res.append(j + 1)
            elif flg and lis[i][j] % 2 == 1:
                print(*res, i + 1, j + 1, sep=" ")
                res = []
                flg = not flg


### FIXED CODE ###

h, w = map(int, input().split())
lis = [] * h
for i in range(h):
    lis.append(tuple(map(int, input().split())))
flg = False
res = []
ans = []
for i in range(h):
    if i % 2 == 0:
        for j in range(w):
            if not flg and lis[i][j] % 2 == 1:
                res.append(i+1)
                res.append(j+1)
                flg = not flg
            elif flg and lis[i][j] % 2 == 0:
                ans.append([res[0], res[1], i+1, j+1])
                res = []
                res.append(i+1)
                res.append(j+1)
            elif flg and lis[i][j] % 2 == 1:
                ans.append([res[0], res[1], i+1, j+1])
                res = []
                flg = not flg
    else:
        for j in range(w -1, -1, -1):
            if not flg and lis[i][j] % 2 == 1:
                res.append(i + 1)
                res.append(j + 1)
                flg = not flg
            elif flg and lis[i][j] % 2 == 0:
                ans.append([res[0], res[1], i+1, j+1])
                res = []
                res.append(i + 1)
                res.append(j + 1)
            elif flg and lis[i][j] % 2 == 1:
                ans.append([res[0], res[1], i+1, j+1])
                res = []
                flg = not flg
print(len(ans))
for a in ans:
    print(*a)
k,x = map(int,input().split())
if k*500 >= X:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

k,x = map(int,input().split())
if k*500 >= x:  
    print('Yes')
else:
    print('No')
S = input()
cnt = 0

for i in S:
    if i == 'R':
        cnt += 1
        cnt_max = cnt
    else:
        
        cnt = 0
print(cnt_max)

### FIXED CODE ###

S = input()
cnt = 0
cnt_max = 0

for i in S:
    if i == 'R':
        cnt += 1
        cnt_max = cnt
    else:
        
        cnt = 0
print(cnt_max)
S=input()
for i in range(0,int(len(S)):
  if S[2*i]!='L' and S[2*i+1]!='R':
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

S=input()
ans='Yes'

for i in range(0,int(len(S))):
  if i%2==0:
    if S[i]=='L':
        ans='No'
        break
  elif i%2==1:
    if S[i]=='R':
        ans='No'
        break
print(ans)
R = int,input()
print( float(R * 3.14 * 2))

### FIXED CODE ###

import math
R = int(input())
print(2*math.pi*R)
m,n = map(int,input().split())#m学生 nチェックポイント
student = []
checkpoint = []
for i in range(m):
    student.append(list(map(int,input().split())))
for i in range(n):
    checkpoint.append(list(map(int,input().split())))

for i in range(m):
    ans = 0 #答えの初期化
    tmp = 1000000000
    for j in range(n):
        if tmp > abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1]):
            ans = i
            tmp = abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1])
    print(ans+1)


### FIXED CODE ###

n,m = map(int,input().split())#n学生 mチェックポイント
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(n):
    ans = 0 #答えの初期化
    tmp = 100000000000 #距離初期化
    for j in range(m):
        if tmp > abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1]):
            ans = j
            tmp = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1])
    print(ans+1)
N=int(input())
B=sorted([list(map(int,input().split())) for i in range(N)])
d={}
for i in range(N):
    for j in range(i+1,N):
        x=(B[j][0]-B[i][0],B[j][1]-B[i][1])
        if x in d:
            d[x]+=1
        else:
            d[x]=1
print(N-max(d.values()))

### FIXED CODE ###

N=int(input())
B=sorted([list(map(int,input().split())) for i in range(N)])
d={}
for i in range(N):
    for j in range(i+1,N):
        x=(B[j][0]-B[i][0],B[j][1]-B[i][1])
        if x in d:
            d[x]+=1
        else:
            d[x]=1
if N==1:
    print(1)
else:
    print(N-max(d.values()))
s,t=str(input())
a=t+s
print(a)

### FIXED CODE ###

s,t=map(str,input().split())
a=t+s
print(a)
N, M = map(int, input().split(' '))

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

a_p = int(input())
sum = fib(a_p%1000000007)
sum %= 1000000007
for i in range(M-1):
    a = int(input())
    diff = a - a_p
    if diff == 1:
        print('0')
        exit()
    sum *= fib((diff-1)%1000000007)
    sum %= 1000000007
    a_p = a

if (N - a_p == 1):
    print('0')
    exit()

sum *= fib(N - a_p)
sum %= 1000000007
print(sum)


### FIXED CODE ###

N, M = map(int, input().split(' '))

MOD = 1000000007

def fib(n):
    a, b = 0, 1
    for i in range(0, n):
        a, b = b, a + b
    return a

broken_step = []
p_a = -1
for i in range(M):
    a = int(input())
    if (a - p_a == 1):
        print("0")
        exit()
    else:
        p_a = a
    broken_step.append(a-1)

count_0 = 0
count_1 = 1
next_broken = 0
pre_is_broken = False
for i in range(N):
    if (next_broken >= len(broken_step) or i != broken_step[next_broken]):
        if (pre_is_broken):
            count_0 = 0
            pre_is_broken = False
        else:
            count_0, count_1 = count_1, count_0 + count_1
            count_0 %= MOD
            count_1 %= MOD
    else:
        next_broken+=1
        count_0 = 0
        pre_is_broken = True

print(count_1)
def resolve():
    n = input()
    l = len(n)
    if n[:1] == "9" * l-1: #c9999...99のとき
        print(int(n[0]) + 9*(l-1))
    else:
        print((int(n[0])-1) + (9*(l-1)))
resolve()

### FIXED CODE ###

def resolve():
    n = input()
    l = len(n)
    if n[1:] == "9" * (l-1): #c9999...99のとき
        print(int(n[0]) + 9*(l-1))
    else:
        print((int(n[0])-1) + (9*(l-1)))
resolve()
import math
r = int(input())
print(22, 222)

### FIXED CODE ###

import math
r = float(input())
print(r * r * math.pi, 2 * r * math.pi)
n = int(input())
a = [int(input()) for i in range(n)]

def minkou(a1,a2):
  mod = a1 % a2
  if mod == 0:
    return a2
  else:
    return(minkou(a2,mod))

a1 = a[0]
if len(a) == 1:
  print(a[0])
  exit()
else:
  for i in a[1:]:
    maxkou = a1*i / minkou(a1,i)
    a1 = maxkou
print(int(maxkou))

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

 #最小公倍数
def lcm(a,b):
  return a*b//gcd(a,b)

if len(a) ==0:
  print(a[0])
  exit()
else:
  a1 = a[0]
  for i in a:
    a2 = lcm(a1,i)
    a1 = a2
print(a2)
A = 0
B = 0
C = 0
D = 0


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    g = gcd(a, b)
    return a * (b // g)


def f(n):
    return n - n // C - n // D + n // lcm(C, D)


def main():
    global A, B, C, D
    A, B, C, D = map(int, input().split())
    print(f(B) - f(A - 1))
    return


main()


### FIXED CODE ###

def main():
    N, *d = map(int, open(0).read().split())
    d.sort()
    print(d[N // 2] - d[N // 2 - 1])
    return


main()
import time
print((time.time()%10)^int(input()))

### FIXED CODE ###

print(int(input())^1)
n = int(input())
cards = [s + " " + str(i) for i in range(1,14)] for s in ["S","H","C","D"]]
for _ in range(n):
    suit, num = input().split(" ")
    if suit == "S":
        cards[0][int(num) - 1] = 0
    elif suit == "H":
        cards[1][int(num) - 1] = 0
    elif suit == "C":
        cards[2][int(num) - 1] = 0
    elif suit == "D":
        cards[3][int(num) - 1] = 0
for s in cards:
    for i in s:
        if i != 0:
            print(i)

### FIXED CODE ###

n = int(input())
cards =[ [s + " " + str(i) for i in range(1,14)] for s in ["S","H","C","D"]]
for _ in range(n):
    suit, num = input().split(" ")
    if suit == "S":
        cards[0][int(num) - 1] = 0
    elif suit == "H":
        cards[1][int(num) - 1] = 0
    elif suit == "C":
        cards[2][int(num) - 1] = 0
    elif suit == "D":
        cards[3][int(num) - 1] = 0
for s in cards:
    for i in s:
        if i != 0:
            print(i)
from time import time

start = time()
D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]
t = []
for i in scores:
    t.append(i.index(max(i))+1)
DC = [0]*26

def calcScore(t):
    score = []
    S = 0
    last = [0]*26
    for d in range(1,D+1):
        S += scores[d-1][t[d-1]-1]
        last[t[d-1]-1] = d
        for i in range(26):
            S -= C[i] * (d - last[i])
            DC[i] += (d - last[i])
        score.append(S)
    return score[-1]

ts = calcScore(t)
i = D
j = 1
while time() - start < 1.95:
    d,q = i, j
    temp = [t[i] if d-1 != i else q for i in range(D)]
    j += 1
    if calcScore(temp) > ts:
        t = temp
        i -= 1
        j = 1

print("\n".join(map(str, t)))

### FIXED CODE ###

D = int(input())
C = [int(i) for i in input().split()]
scores = [[int(i) for i in input().split()] for j in range(D)]

for i in scores:
    print(i.index(max(i))+1)
s = input()
print(s[0] + (len(s) - 2) + s[-1])

### FIXED CODE ###

s = input()
print(s[0] + str((len(s) - 2)) + s[-1])
import itertools
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
b = np.abs(a)
b.sort(reverse = True)
b_k = b[k-1] 
a_new = [a[i] for i in range(len(a)) if np.abs(a)[i] >= b_k]
 
comb = itertools.combinations(a_new,k)  
l = [list(_) for _ in comb]  
A = (functools.reduce(operator.mul,l[_]) for _ in range(len(l)))
l_max = max(A)
waru = 10**9 + 7
print(l_max % waru)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
x,y =map(int,input().split())
print(x/t)

### FIXED CODE ###

x,y =map(int,input().split())
print(x/y)
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  if(A.islower()):print("AC")
  else:print("WA")

### FIXED CODE ###

A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  S="".join(A)
  if(S.islower()):print("AC")
  else:print("WA")
da = list(map(int,input().split()))

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] != 0 and da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())
		su += k[i][0] * k[i][1]


	sorted(k,key = lambda x: x[1],reverse = True)
	while da[1] > 0 and j != i + 1:
		if da[1] >= k[j][0] and j != i
			su -= k[j][0] * k[j][1]
			da[1] -= k[j][0]
			j += 1
		elif j == i + 1:
			da[1] = 0
		else:
			su -= da[1] * k[j][1]
			da[1] = 0

	print(su)

	da = list(map(int,input().split()))
	if da[0] == 0 and da[1] == 0:
		break
	k = [[0 for i in range(2)]for j in range(10001)]



### FIXED CODE ###

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

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] + da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())


	k = sorted(k,key = lambda x: x[1],reverse = True)

	while j != i + 1:
		if da[1] > k[j][0]:
			da[1] -= k[j][0]
			j += 1
		elif da[1] <= k[j][0] and da[1] > 0:
			su += (k[j][0] - da[1]) * k[j][1]
			da[1] = 0
			j += 1
		else:
			su += k[j][0] * k[j][1]
			j += 1

	print(su)

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

	k = [[0 for i in range(2)]for j in range(10001)]
N = int(input())
S = list(map(int, input().split()))

ans = [0]*N
for i in range(Nh):
    ans[S[i]-1] = i+1
print(" ".join(map(str, ans)))

### FIXED CODE ###

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

ans = [0]*N
for i in range(N):
    ans[S[i]-1] = i+1
print(" ".join(map(str, ans)))
import decimal
getcontext().prec = 20
S = decimal.Decimal(input()) 
s = S/3
print(decimal.Decimal(s**3))

### FIXED CODE ###

import decimal
decimal.getcontext().prec = 20
S = decimal.Decimal(input()) 
s = S/3
print(decimal.Decimal(s**3))
# AOJ ITP1_8_C

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    counts = []
    for i in range(26): counts.append(0)
    string = input()
    for c in range(len(string)):
        if 97 <= ord(c) <= 122:
            counts[ord(c) - 97] += 1
        elif 65 <= ord(c) <= 90:
            counts[ord(c) - 65] += 1
    for i in range(26):
        print(chr(97 + i) + " : " + str(counts[i]))

if __name__ == "__main__":
    main()


### FIXED CODE ###

# AOJ ITP1_8_C

import sys

def main():
    counts = []
    for i in range(26): counts.append(0)

    lines = sys.stdin.readlines()

    for i in range(len(lines)):
        string = lines[i]
        for k in range(len(string)):
            c = string[k]
            if 97 <= ord(c) <= 122:
                counts[ord(c) - 97] += 1
            elif 65 <= ord(c) <= 90:
                counts[ord(c) - 65] += 1

    # 結果を出力。
    for i in range(26):
        print(chr(97 + i) + " : " + str(counts[i]))

if __name__ == "__main__":
    main()

# Accepted.
# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = int((n - 2) * (n - 1) / 2)
k_min =

if k > k_max:
    print(-1)
    sys.exit()

edges = list()

for i in range(2, n + 1):
    edges.append((1, i))

cnt = k_max
exit_flag = False
for i in range(2, n):
    for j in range(i + 1, n + 1):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            exit_flag = True
            break
    if exit_flag:
        break

print(len(edges))
for u, v in edges:
    print(u, v)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
n, k = map(int, input().split())
k_max = (n - 2) * (n - 1) // 2

if k > k_max:
    print(-1)
    sys.exit()

m = n - 1 + k_max - k

print(m)
cnt = 0
exit_flag = False
for i in range(1, n):
    for j in range(i + 1, n + 1):
        print(i, j)
        cnt += 1
        if cnt == m:
            exit_flag = True
            break
    if exit_flag:
        break
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0, s == "AC":
    acs[p] += 1
    a += 1
    w += was[p] 
  elif ac[p] == 0, s == "WA":
    was[p] += 1
print(a,w)

### FIXED CODE ###

n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0 and s == "AC":
    ac[p] += 1
    a += 1
    w += wa[p] 
  elif ac[p] == 0 and s == "WA":
    wa[p] += 1
print(a,w)
s = [int(k) for k in list(input())]
s1 = 10*int(s[0])+int(s[1])
s2 = 10*int(s[2])+int(s[3])
if s2 == 0:
    print("NA")
elif s1 <= 12 and s2 <= 12:
    print("AMBIGUOUS")
elif s1 <= 12 and s2 >= 12:
    print("MMYY") 
else:
    print("YYMM")

### FIXED CODE ###

import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n,k = i2()
s = l()
s[k-1] = s[k-1].lower()
for k in s:
    print(k,end="")
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
read = sys.stdin.buffer.read

@njit((i8, i8, i8, i8[:]), cache=True)
def solve(R,C,K,XYV):
  item = np.zeros((R + 1, C + 1), dtype=np.int64)
    for i in range(0, 3 * K, 3):
      x, y, v = XYV[i:i + 3]
      item[x - 1, y - 1] = v
  dp = np.zeros((C+1,4), dtype=np.int64)
  for i in range(1,R+1):
    new_dp = np.zeros((C+1,4), dtype=np.int64)
    #上から移動
    for k in range(4):
      new_dp[:,0] = np.maximum(new_dp[:,0], dp[:,k])
    dp = new_dp
    for j in range(1,C+1):
      #横から移動
      new_dp[j] = np.maximum(new_dp[j],new_dp[j-1])
      #アイテムを取る
      for k in range(2,-1,-1):
        dp[j,k+1] = np.maximum(dp[j,k+1],dp[j,k]+item[i-1,j-1])
  ans = dp[-1].max()
  return ans

R, C, K = map(int, input().split())
XYV = np.array(read().split(), np.int64)
print(solve(R,C,K,XYV))


### FIXED CODE ###

import sys
input = sys.stdin.readline
def solve():
  R, C, K = map(int, input().split())
  item = [[0]*C for _ in range(R)]
  for i in range(K):
    r,c,v = map(int, input().split())
    item[r-1][c-1] = v
  dp = [[[0]*(C+1) for _ in range(R+1)] for _ in range(4)]
  for i in range(1,R+1):
    for j in range(1,C+1):
      for k in range(4): #横から取らない
        dp[k][i][j] = dp[k][i][j-1]
      #上から取らない
      dp[0][i][j] = max(dp[0][i][j],dp[-1][i-1][j])
      if item[i-1][j-1]>0:
        #上からとる
        dp[1][i][j] = max(dp[1][i][j],dp[-1][i-1][j]+item[i-1][j-1])
        for k in range(1,4): #横から取る
          dp[k][i][j] = max(dp[k][i][j],dp[k-1][i][j-1]+item[i-1][j-1])
      for k in range(1,4):
        dp[k][i][j] = max(dp[k-1][i][j],dp[k][i][j])
  ans = 0
  for k in range(4):
    ans = max(ans,dp[k][-1][-1])
  return ans
print(solve())
#A
n=input()
if n%2=0:
    ans=int(n/2)
else:
    ans=int(n/2)+1
print(ans)

### FIXED CODE ###

#A
n=int(input())
if n%2==0:
    ans=int(n/2)
else:
    ans=int(n/2)+1
print(ans)
n = int(input())

a = {}
r = []
for i in range(n):
  s = int(input())
  if s in a:
    a[s] += 1
    if a[s] % 2 == 0:
      r.remove(s)
  else:
    a[s] = 1
    r.append(s)
    
print(len(r))

### FIXED CODE ###

import collections
n = int(input())

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

c = collections.Counter(r)
count = 0
for key, v in c.items():
  if v % 2 != 0:
    count += 1
print(count)
x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
xi = num
for _ in range(100):
   xi = (xi + (num / xi)) / 2.0
print xi

### FIXED CODE ###

x1, y1, x2, y2 = map(float, raw_input().split())
num = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
if num == 0:
    print 0
else:
    xi = num
    for _ in range(100):
        xi = (xi + (num / xi)) / 2.0
    print xi
N = int(input())
T,A = int(i) for i in input().split()
Hi = [int(i) for i in input().split()]
Ave = [T - i*0.006 for i in Hi]
Result = [abs(i) for i in Ave - A]
print(index(min(result)) + 1)


### FIXED CODE ###

N = int(input())
T,A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
sub = [0 for i in range(N)]
for i in range(N):
    sub[i] = abs(A - (T - 0.006*H[i]))
print(sub.index(min(sub))+1)