Harryxun/stf_run huggingface dataset:
H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [2**50 for _ in range(H+1)]
ans = 2**60
for i in range(N):
    a,b = map(int,input().split(" "))
    dp[a] = b
    if a >= H:
        ans = min(ans,b)
    lis_append([a,b])


for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[H] = min(dp[H],dp[i]+b)

ans = min(ans,dp[H])
print(ans)

### FIXED CODE ###

H,N = map(int,input().split(" "))
lis = []
lis_append = lis.append
dp = [2**50 for _ in range(H+1)]
ans = 2**60
for i in range(N):
    a,b = map(int,input().split(" "))
    if a >= H:
        ans = min(ans,b)
    lis_append([a,b])

dp[0] = 0
for i in range(H+1):
    for a,b in lis:
        if i + a <= H:
            dp[i+a] = min(dp[i+a],dp[i]+b)
        else:
            dp[H] = min(dp[H],dp[i]+b)

ans = min(ans,dp[H])
print(ans)
import os

def main():
        num = int(input())
        dict_list = {}
        for i in range(num):
                strings = input()
                if strings in dict_list.keys():
                        dict_list[strings] += 1
                else:
                        dict_list[strings] = 1 

        max_num = max(dict_list.values())
        result = []
        
        for k,v in dict_list.items():
                if v == max_num:
                        result.append(k)
        result.sort()
        for i in result:
                print(i)

if __name__ == "__main__":
        main()



### FIXED CODE ###

import os
import math

def main():
    num = int(input())
    x_list = list(map(int, input().split()))
    min_num = 10**10    
    for i in range(100):
        result = 0  
        for j in x_list:
            result += pow((i - j), 2)
        
        if result < min_num:
            min_num = result
    print(min_num)

if __name__ == "__main__":
    main()
N = int(input())

a = [list(map(int,input().split())) for _ in range(N)]
def count(a1,a2,n,a):
    count = [0 for i in range(len(a) - n)]
    #print(count)
    x1 = a1[0]
    y1 = a1[1]
    x2 = a2[0]
    y2 = a2[1]
    if x1 != x2:
        #print(1)
        for j in range(len(a)-n):
            #print(a[j][1] - ((y1 - y2)/(x1 - x2))*(a[j][0] - x1) - y1)
            if (a[j][1] - ((y1 - y2)/(x1 - x2))*(a[j][0] - x1) - y1) == 0:
                count[j] += 1
    else:
        for j in range(n,len(a)):
            if a[j][0] == x1:
                count[j] += 1
    if len(count) != 0:
        return max(count)
    else:
        return 0
if N == 1 or N == 2:
    print(1)
    exit()
ans = []
for i in range(N):
    for j in range(i+1,N):
        ans.append(count(a[i],a[j],j+1,a))
        #print(count(a[i],a[j],j+1,a))
print(int(N//2) + 1 - max(ans))

### FIXED CODE ###

#!/usr/bin/env python3
#diverta B

import sys

def main():
	N = int(input())
	xy = []
	for i in range(N):
		x, y = map(int, input().split(" "))
		xy.append((x, y))

	if N == 1:
		print(1)
		sys.exit()

	re = {}
	for i, val in enumerate(xy):
		x, y = val
		for j, vol in enumerate(xy):
			if i == j:
				continue
			nx, ny = vol
			p = nx - x
			q = ny -y
			if (p, q) in re:
				re[(p, q)] += 1
			else:
				re[(p, q)] = 1


	ans = N - max(re.values())

	print(ans)


if __name__ == "__main__":
	main()
import sys
c = 1
for i in sys.stdin.readline() :
    if (! i == 0) :
        print("Case " + str(c) + ":" + " " + str(i))
        c = c + 1
    else :
        break

### FIXED CODE ###

import sys
c = 1
for i in sys.stdin.readlines() :
    if i.strip() == "0" :
        break
    else :
        print("Case " + str(c) + ":" + " " + str(i.strip()))
        c = c + 1
A, B, C = map(int, input().split())

if A == B == C and all(lambda x: x%2==0, [A, B, C]):
    print(-1)
else:
    ans = 0
    cookie = A+B+C
    while True:
        if all(map(lambda x: x%2==0, [A, B, C])):
            ans += 1
        else:
            print(ans)
            break
        A = (cookie-A) / 2
        B = (cookie-B) / 2
        C = (cookie-C) / 2

### FIXED CODE ###

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

if A == B == C and all(map(lambda x: x%2==0, [A, B, C])):
    print(-1)
else:
    ans = 0
    cookie = A+B+C
    while True:
        if all(map(lambda x: x%2==0, [A, B, C])):
            ans += 1
        else:
            print(ans)
            break
        A = (cookie-A) / 2
        B = (cookie-B) / 2
        C = (cookie-C) / 2
n = int(input())
ans = 0
for i in range(1, n+1):
    if (i // 10 + 1) % 2 == 1:
        ans +=1
print(ans

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n+1):
    if (len(str(i))) % 2 == 1:
        ans +=1
print(ans)
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])


for x in range(2):
  if x == 0:
    _ = A+B
    op1 = '+'
  else:
    _ = A-B
    op1 = '-'
  for y in range(2):
    if y == 0:
      _ += C
      op2 = '+'
    else:
      _ -= C
      op2 = '-'      
    for z in range(2):
      if z == 0:
        _ += D
        op3 = '+'
      else:
        _ -= D
        op3 = '-'      
      if _ == 7:
        ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)

### FIXED CODE ###

ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])


def get_op(num):
  if num == -1:
    _ = '-'
  else:
    _ = '+'

  return _
  

for x in [-1,1]:
  for y in [-1,1]:
    for z in [-1,1]:
      _ = A+x*B+y*C+z*D
      if _ == 7:
        op1 = get_op(x)
        op2 = get_op(y)
        op3 = get_op(z)        
        ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)
# coding: utf-8
import os
import time
import re
import math


def main():
    global N,M,A,mod,memo
    N,M=map(int,input().split())
    A=[int(input()) for  a in range(M)] #a (1段~N-1段)
    start=time.time();#
    memo=[-1]*(N+1)
    
    mod=10**9+7
    print(dp(0))
    #print("{}ms".format(math.floor(time.time()*1000-start*1000)))#

def dp(index):
    global N,M,A,mod,memo
    if(index>N):memo[index]=0
    if(index==N):memo[index]=1
    if(A.count(index)>0):memo[index]=0
    if memo[index]==-1:
        memo[index]=(dp(index+1)+dp(index+2))%mod
    return memo[index]

main()


### FIXED CODE ###

# coding: utf-8
import os
import time
import re
import math


def main():
    N,M=map(int,input().split())
    A=[int(input()) for  a in range(M)] #a (1段~N-1段)
    start=time.time();#
    memo=[0]*(N+1)
    memo[0]=1
    ban=[False]*(N+1)
    for a in A:
        ban[a]=True
    mod=1000000007
    for a in range(1,N+1):
        if ban[a]:
            memo[a]=0
        else:
            if a>1:
                memo[a]=(memo[a-1]+memo[a-2])%mod
            else:
                memo[a]=1



    print(memo[-1]%mod)
    #print("{}ms".format(math.floor(time.time()*1000-start*1000)))#


main()
a,b,k=map(int,input().split())
 
cnt=0
 
for i in range(1,max(a,b)):
	ans=0
	if a%i==0 and b%i==0:
		ans+=i
		cnt+=1
	if cnt==k:
		break
print(ans)

### FIXED CODE ###

a,b,k=map(int,input().split())
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]

arr=[str(i) for i in range(10**(n-1),10**n)]

for x in arr:
  flag=[False]*n
  for i,tmp in enumerate(l):
    s,c=tmp
    if x[s-1]==str(c):
      flag[i]=True
  if all(flag):
    print(x)
    exit()
print(-1)

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]

arr=[str(i) for i in range(10**(n-1) if n>1 else 0,10**n)]

for x in arr:
  for i,tmp in enumerate(l):
    s,c=tmp
    if x[s-1]!=str(c):
      break
  else:
    print(x)
    exit()

print(-1)
high, width, y, x = map(int, input().split())

def nCr(n, r):
    return ((((fact[n]*finv[n-r])%mod)*finv[r])%mod)
def powmod(a, n, m):
    if n == 0:
        return 1
    elif n == 1:
        return a
    if n%2 == 0:
        temp = (powmod(a, n/2, m) ** 2) % m
        return temp
    else:
        temp = (((powmod(a, n/2, m) ** 2) % m) * a) % m
        return temp

mod = 10**9 + 7
inv = mod - 2
maxn = high + width - 2
fact = [0] * (maxn+1)
finv = [0] * (maxn+1)
fact[0] = fact[1] = 1
finv[0] = finv[1] = 1

# 階乗を求める
for i in range(2, maxn+1):
    fact[i] = (fact[i-1] * i) % mod

# 階乗の逆元を求める
for i in range(2, maxn+1):
    finv[i] = powmod(fact[i], inv, mod)

route = 0
for i in range(1, high-y+1):
        route += (nCr(x+i-2, i-1) * nCr(width+high-x-1-i, high-i)) % mod
        route = route % mod
print(int(route))

### FIXED CODE ###

high, width, y, x = map(int, input().split())

def nCr(n, r):
    return ((((fact[n]*finv[n-r])%mod)*finv[r])%mod)

mod = 10**9 + 7
inv = mod - 2
maxn = high + width - 2
fact = [0] * (maxn+1)
finv = [0] * (maxn+1)
fact[0] = fact[1] = 1
finv[0] = finv[1] = 1

# 階乗を求める
for i in range(2, maxn+1):
    fact[i] = (fact[i-1] * i) % mod

# 階乗の逆元を求める
for i in range(2, maxn+1):
    finv[i] = pow(fact[i], inv, mod)

route = 0
for i in range(1, high-y+1):
        route += (nCr(x+i-2, i-1) * nCr(width+high-x-1-i, high-i)) % mod
        route = route % mod
print(int(route))
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

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

x.sort()

z = []
for i in range(len(x) - 1):
    z.append(abs(x[i] - x[i + 1]))

z.sort()
for _ in range(n - 1):
    z.pop()

print(sum(z))

### FIXED CODE ###

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

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

x.sort()

z = []
for i in range(len(x) - 1):
    z.append(abs(x[i] - x[i + 1]))

z.sort()
for _ in range(n - 1):
    if len(z) > 0:
        z.pop()

print(sum(z))
a = int(input)
if a >= 30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = int(input())
if a >= 30:
  print("Yes")
else:
  print("No")
import re
s1 = input()
t = input()
pre = ""
count = 0
ans = ""
start = 0
end = 0
it = ""

for w in s1:
  if w == t[count]:
    count += 1
    it += w
  elif w != "?" and pre == "?":
    pre = w
    count = 0
    it = ""
  elif w == "?" and pre == "?":
    count += 1
    it += w
  else:
    if w == "?":
      pre = w
      count += 1
      it += w
  # if count >= len(t):
  #   print("きたよ")
  #   print(w)
  #   end = s1.index(w)
  #   start = end - len(t)
#print(f"count is {count}")
#print("endは" + end)
#replace = "?" * len(t)
#print("replace is" + it)
if count >= len(t):
  it = it.replace("?","\?")
  # 合致した最も後方のものを置換
  ans = re.sub(it,t,s1)
  ans = ans.replace("?","a")
  #print(ans)
  # if end < len(s1) - 1:
  #   ans = s1[:start] + t + s1[end+1:]
  #   # 全てaに置換
  #   ans = ans.replace("?","a")
  #   print(ans)
  # else:
  #   ans = s1[:start] + t
  #   ans = ans.replace("?","a")
  print(ans)
else:
  print("UNRESTORABLE")

### FIXED CODE ###

# pythonはindexでstringの文字を変更できない
s = list(input())
t = list(input())
x = 0
ans = []
gotk = False

# pythonて関数にするとスコープの外の変数参照できないんだっけ？

# 0 <= k <= s - t
def match(k):
  for i in range(len(t)):
    if s[i + k] != t[i] and s[i + k] != "?":
      return False
  return True

def construct(k,s):
  for i in range(len(t)):
    s[i + k] = t[i]
  for i in range(len(s)):
    if s[i] == "?":
      s[i] = "a"
  return s

# 大きいkから探せば良い(今回逆順にしてるためrangeの第二引数が直前まで処理されることに注意！)
for i in range(len(s) - len(t),-1,-1):
  if match(i):
    x = i
    gotk = True
    break

if gotk == True:
  ans = construct(x,s)
  print("".join(ans))
else:
  print("UNRESTORABLE")
print('Yes' if int(input()) % 500 <= a else 'No')

### FIXED CODE ###

n = int(input())
a = int(input())
print('Yes' if n % 500 <= a else 'No')
a, b, c, d = map(int, input().split())


for x in (a, b):
    for y in (c, d):
        ans = max(ans, x * y)

print(ans)

### FIXED CODE ###

a, b, c, d = map(int, input().split())
res = []
res.append(a*c)
res.append(a*d)
res.append(b*c)
res.append(b*d)
print(max(res))
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = []
for i in a:
  for j in b:
    for k in c:
      d.append(i+j+k)
d.sort(reverse=True)
for i in range(k):
  print(d[i])


### FIXED CODE ###

import heapq
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
q = []
heapq.heapify(q)
heapq.heappush(q,(-(A[0] + B[0] + C[0]),0,0,0))
for _ in range(K):
    m, i, j, k = heapq.heappop(q) #mに和、ijkにインデックス
    print(-m) #親から取り出すが、親は子よりも小さい、大きい順にするために-を入れている
    if i + 1 < X: #最初にiには０が挿入されている,pythonではインデックスが０から始まるから<xでいい
        s = (-(A[i+1] + B[j] + C[k]), i+1, j, k)
        if s not in q:
            heapq.heappush(q,s)
    if j + 1 < Y:
        s = (-(A[i] + B[j+1] + C[k]), i, j+1, k)
        if s not in q:
            heapq.heappush(q, s)
    if k + 1 < Z:
        s = (-(A[i] + B[j] + C[k+1]), i, j, k+1)
        if s not in q:
            heapq.heappush(q,s)
D = int(input())
c = [int(x) for x in input().split()]
s = []
for i in range(D):
    s.append([int(x) for x in input().split()])
kotae = 0
k2 = 0
for k in range(26):
    ans = 0
    nissuu = [0] * 26
    for i in range(D):
        t = (i+k) % 26 + 1
        for j in range(26):
            if j == t-1:
                nissuu[j] = 0
            else:
                nissuu[j] += 1
            ans -= c[j]*nissuu[j]
        ans += s[i][t-1]
    if kotae <= ans:
        kotae = ans
        key = k
for i in range(D):
    print((i+key) % 26 + 1)

### FIXED CODE ###

for i in range(365):
  print(1)
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()


for i in range(n):
        sum=sum(a[2*i+1])
print(sum)

### FIXED CODE ###

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

a_li=a[1:2*n:2]
print(sum(a_li))
f __name__ == '__main__':
    N, K = map(int, input().split())
    people_hight = list(input().split())
    ok = 0

    for person_hight in people_hight:
        if K <= int(person_hight) :
            ok = ok + 1
    print(ok)


### FIXED CODE ###

if __name__ == '__main__':
    N, K = map(int, input().split())
    people_hight = list(input().split())
    ok = 0

    for person_hight in people_hight:
        if K <= int(person_hight) :
            ok = ok + 1
    print(ok)
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

# https://atcoder.jp/contests/abc100/tasks/abc100_d
# 定式化 M個のidxの集合idsに対して、
# max(|sum_ids (x_i)| +|sum_ids (y_i)| + |sum_ids (z_i)|) という問題
# 各項について正負を仮定すると、どのケーキを取ればいいのか優先度が決まる(ソート)
# bit全探索とソートの合わせ技
N, M = read_ints()
XYZ = read_tuple(N)

ans = -1 * 10**13 - 100
for is_mina_x, is_mina_y, is_mina_z in product(range(2), repeat=3):
    is_mina_x = -1 if is_mina_x else 1
    is_mina_y = -1 if is_mina_y else 1
    is_mina_z = -1 if is_mina_z else 1

    XYZ.sort(key=lambda x: is_mina_x *
             x[0] + is_mina_y * x[1] + is_mina_z * x[2], reverse=True)
    x_sum = 0
    y_sum = 0
    z_sum = 0
    for x, y, z in XYZ[:M]:
        x_sum += x
        y_sum += y
        z_sum += z
    ans = max(ans, abs(x_sum) + abs(y_sum) + abs(z_sum))

print(ans)


### FIXED CODE ###

# https://atcoder.jp/contests/abc100/tasks/abc100_d

# もし正の数だけだったら簡単→それぞれの合計値でソートすれば良い
# Nはたかだか1000→N^2でも間に合う

# 突っ込んだときに良くなるものを貪欲に選べばよいのでは？
# だめだ。-3 1 1 1 1とかのときに1が選ばれなくなる
# 正負の仮定を8パターン列挙しておいて、それぞれに貪欲にやる←行けそう

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


N, M = read_ints()
XYZ = read_tuple(N)


def iter_p_adic(p, length):
    '''
    連続して増加するp進数をリストとして返す。lengthはリストの長さ
    return
    ----------
    所望のp進数リストを次々返してくれるiterator
    '''
    from itertools import product
    tmp = [range(p)] * length
    return product(*tmp)


def sort_and_ret_score(p):
    a = [-1, 1]
    XYZ.sort(reverse=True, key=lambda x: (
        a[p[0]] * x[0] + a[p[1]] * x[1] + a[p[2]] * x[2]))  # すべて正だとして仮定した場合の最大値
    tmp = 0
    for x, y, z in XYZ[:M]:
        tmp += a[p[0]] * x + a[p[1]] * y + a[p[2]] * z
    return tmp


ans = 0
for p in iter_p_adic(2, 3):
    ans = max(ans, sort_and_ret_score(p))


print(ans)
t, x = map(int, input(),split())
print(t/x)


### FIXED CODE ###

t, x = map(int, input().split())
print(t/x)
from collections import deque
import sys
input = sys.stdin.readline

N, Q = map(int, input().split())
table = [[] for i in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  table[a].append(b)
  table[b].append(a)
task = [0]*N
point = [-1]*N
point[0] = 0
for i in range(Q):
  p,x = map(int, input().split())
  p -= 1
  task[p] += x
H = deque()
H.append(0)

while H:
  p = H.popleft()
  point[p] += task[p]
  for np in table[p]:
    if point[np] == -1:
      H.append(np)
      point[np] = point[p]

print(" ".join(map(str, point[i])))


### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
table = [[] for i in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  table[a].append(b)
task = [0]*N
count = [0]*N
for i in range(Q):
  p,x = map(int,input().split())
  p -= 1
  task[p] += x
H = deque()
H.append(0)
while H:
  y = H.popleft()
  count[y] += task[y]
  for ny in table[y]:
    H.append(ny)
    count[ny] = count[y]
print(" ".join(map(str,count)))
import sys
import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import coo_matrix

read = sys.stdin.read
readline = sys.stdin.readline

n, m, s, t, *uvab = map(int, read().split())

s -= 1
t -= 1
u = np.array(uvab[::4], np.int64) - 1
v = np.array(uvab[1::4], np.int64) - 1
a = np.array(uvab[2::4], np.int64)
b = np.array(uvab[3::4], np.int64)

yen_matrix = coo_matrix((a, (u, v)), shape=(n, n))
snuuk_matrix = coo_matrix((b, (u, v)), shape=(n, n))

yen = dijkstra(yen_matrix, directed=False, indices=s, limit=10 ** 15)
snuuk = dijkstra(snuuk_matrix, directed=False, indices=t, limit=10 ** 15)

costs = (yen + snuuk).astype(int)
answer = 10 ** 15 - np.minimum.accumulate(costs[::-1])[::-1]
print(*answer.tolist(), sep='\n')


### FIXED CODE ###

import sys
input = sys.stdin.read
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T, *uvab = map(int,input().split())
graph = [[] for _ in range(N+1)]
for u,v,a,b in zip(*[iter(uvab)]*4):
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]
print('\n'.join(map(str, answer.tolist())))
H, A = map(int, input().split())

if (H % A) == 0:
    print(H // A)
else:
    print(H // A + 1)

### FIXED CODE ###

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

if N == M:
    print('Yes')
else:
    print(('No'))
b = str(input())

if b == A:
    print('T')
elif b == T:
    print(A)
elif b == G:
    print(C)
elif b == C:
    print(G)

### FIXED CODE ###

b = str(input())

if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'G':
    print('C')
elif b == 'C':
    print('G')
N = int(input())
count = 0
a = list(map(int,input().split()))


for i in range(1,N):
    if a[i] == a[i-1]:
        a[i] = a[i+1] + 1
        count = count + 1

print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
count = 0

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
k_max = 5001
score = [0] * N

for i in range(N):
  score_i = [-10**18-1] * k_max # iからスタートしてK回操作する場合の累積和
  score_i[0] = C[P[i]-1]
  index = P[i]-1
  for k in range(1, K):
    if index == i:
      # 既に進んだことがあるマスの場合
      
      # ループ終了インデックスからループ開始インデックスの累積和の差を確認
      loop_score = score_i[k-1] # 1ループで増えるスコア
      if loop_score > 0:
        loop_num = k # ループする要素数はk(indexが0 ~ k-1)
        
        tmp_score = [0] * k_max
        tmp_score[0] = (K//k -1) * loop_score
        tmp_index = index
        for j in range (1, loop_num + K%k):
          tmp_score[j] = tmp_score[j-1] + C[P[tmp_index]-1]
          tmp_index = P[tmp_index]-1
        score[i] = max(tmp_score)
      else:
        score[i] = max(score_i)
      break
    else:
      if k == K-1:
        score_i[k] = score_i[k-1] + C[P[index]-1]
        score[i] = max(score_i)
        break   
    score_i[k] = score_i[k-1] + C[P[index]-1]
    index = P[index]-1
print(max(score))

### FIXED CODE ###

# -*- coding: utf-8 -*-
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
k_max = 10100
score = [-10**18-1] * N

for i in range(N):
  score_i = [-10**18-1] * k_max # iからスタートしてK回操作する場合の累積和
  score_i[0] = C[P[i]-1]
  index = P[i]-1
  for k in range(1, K):
    if index == i:
      # 既に進んだことがあるマスの場合
      
      loop_score = score_i[k-1] # 1ループで増えるスコア
      if loop_score > 0:
        loop_num = k # ループする要素数はk(indexが0 ~ k-1)
        
        tmp_score = [-10**18-1] * k_max
        tmp_score[0] = (K//k -1) * loop_score
#        print("loop_score", loop_score)
#        print("tmp_score", tmp_score)
        tmp_index = index
#        print("loop_num + K%k + 1", loop_num + K%k + 1)
        for j in range (1, loop_num + K%k + 1):
          tmp_score[j] = tmp_score[j-1] + C[P[tmp_index]-1]
          tmp_index = P[tmp_index]-1
#        print("max(tmp_score)", max(tmp_score))
        score_i[k] = max(tmp_score)
      break
    score_i[k] = score_i[k-1] + C[P[index]-1]
    index = P[index]-1
  score[i] = max(score_i)
print(max(score))
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if i == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if n == 1:
            break
print("{} {} {}".format(cx, cy, H[0]))


### FIXED CODE ###

import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for t in range(n):
    if h[t] >= 1:
        break
for cx, cy in itertools.product(range(101), range(101)):
    H = h[t] + abs(x[t] - cx) + abs(y[t] - cy)
    if H < 1:
        continue
    for i in range(n + 1):
        if i == n:
            break
        if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
            break
    if i == n:
        break
print("{} {} {}".format(cx, cy, H))