Harryxun/stf_run huggingface dataset:
import numpy as np
n, c = list(map(int, input().split()))
for i in range(n):
    xv = list(list(map(int, input().split())) for i in range(n))
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
sum1, sum2 = 0, 0
for x, v in xv:
    sum1 += v
    sushi1.append(max(sum1 - x, sushi1[-1]))
    max1.append(max(sum1 - 2*x, max1[-2]))
for x, v in xv[::-1]:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = np.array(sushi1) + np.array(max2[::-1])
ans2 = np.array(sushi2) + np.array(max1[::-1])
print(max(0, ans1, ans2))

### FIXED CODE ###

import numpy as np
n, c = list(map(int, input().split()))
xv = list(list(map(int, input().split())) for i in range(n))
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
sum1, sum2 = 0, 0
for x, v in xv:
    sum1 += v
    sushi1.append(max(sum1 - x, sushi1[-1]))
    max1.append(max(sum1 - 2*x, max1[-1]))
for x, v in xv[::-1]:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi2[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = max(np.array(sushi1) + np.array(max2[::-1]))
ans2 = max(np.array(sushi2) + np.array(max1[::-1]))
print(max(0, ans1, ans2))
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
ans = 0
while True:
    if len(set(a_list)) > k:
        if len(set(a_list)) == k+1:
            a_list.pop()
            ans += 1
        else:
            a_list = set(a_list).pop()
            ans += 1
            
print(ans)

### FIXED CODE ###

import collections
n, k = map(int, input().split())
a_list = list(map(int, input().split()))
b = collections.Counter(a_list)
d = b.most_common()[k:]
sum = 0
for i in d:
    sum += i[1]
print(sum)
from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    if judge>0:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif judge==0:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x,y),)
    else:
        return (-100,-100)

def maxNum(P,L):
    ans=1
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points!=(-100,-100):
                P.extend(points)
    print maxNum(P,L)

### FIXED CODE ###

from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    EPS=1e-5
    if c==a:
        y=(pow(a,2)+pow(b,2)-pow(c,2)-pow(d,2))/(2*(b-d))
        bd=pow(b-d,2)
        a1=4*bd
        b1=-8*a*bd
        c1=4*a*a*bd+pow(a*a-b*b-c*c-d*d+2*b*d,2)-4*bd
        inroot=pow(b1,2)-4*a1*c1
        if inroot<0:
            return None
        x1=(-b1+math.sqrt(inroot))/(2*a1)
        x2=(-b1-math.sqrt(inroot))/(2*a1)
        return ((x1,y),(x2,y))

    if judge>EPS:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif -EPS<=judge<=EPS:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x,y),)
    else:
        return None

def maxNum(P,L):
    ans=1
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points:
                P.extend(points)
    print maxNum(P,L)
N =int(input())
S = list(input())
K = int(input())

for i in range(N):
    if S[i] == S[K]:
        pass
    else:
        S[i] = '*'

print(''.join(S))


### FIXED CODE ###

N =int(input())
S = list(input())
K = int(input())

for i in range(N):
    if S[i] == S[K-1]:
        pass
    else:
        S[i] = '*'

print(''.join(S))
import numpy as np
h,n=map(int,input().split)
p=[list(map(int,input().split())) for _ in range(n)]
m=max(p[:,0])
dp=[0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i]=min(dp[i-a]+b for a,b in p)
print(dp[h+m])

### FIXED CODE ###

import numpy as np
h,n=map(int,input().split())
p=[list(map(int,input().split())) for _ in range(n)]
m=10**4
dp=[0]*(h+m+1)
for i in range(m+1,h+m+1):
  dp[i]=min(dp[i-a]+b for a,b in p)
print(dp[h+m])
n,m=map(int,input().split())
nod=[[]]
check=[[0,0]]
for i in range(n-1):
  nod.append([])
  check.append([10**10,0])
for i in range(m):
  a,b=map(int,input().split())
  nod[a-1].append(b)
  nod[b-1].append(a)


def dfs(k):
  count=check[k-1][0]+1
  uselist=nod[k-1]
  for x in uselist:
    if count<check[x-1][0]:
      check[x-1][0]=count
      check[x-1][1]=k
      dfs(x)
    else:
      continue

dfs(1)
for i in range(n-1):
  print(check[i+1][1])

### FIXED CODE ###

from collections import deque
dic={}
n,m=map(int,input().split())
nod=[[]]
keep=[0]*n
for i in range(n-1):
  nod.append([])
for i in range(m):
  a,b=map(int,input().split())
  nod[a-1].append(b)
  nod[b-1].append(a)
use=deque()
use.append(1)
for i in range(0,10**100):
  if bool(use):
    sss=use.popleft()
    for j in nod[sss-1]:
      if not j in dic:
        keep[j-1]=sss
        use.append(j)
        dic[j]=1
  else:
    break

keep.pop(0)
print("Yes")
for x in keep:
  print(x)
def main():
	n,m,q = map(int,input().split())
	qu = [list(map(int,input().split())) for x in range(q)]
	ans = 0
	import itertools

	ans_list = set()
	for i in list(itertools.product([1,2,3,4,5,6,7,8,9,10],repeat = m)):
		for qul in range(q):
			if i[ qu[qul][1]-1 ] - i[ qu[qul][0]-1 ] == qu[qul][2] and list(i) == sorted(i):
				ans += qu[qul][3]
		ans_list.add(ans)
		ans = 0
	print(max(ans_list))

if __name__ == '__main__':
	main()

### FIXED CODE ###

def main():
	n,m,q = map(int,input().split())
	qu = [list(map(int,input().split())) for x in range(q)]
	ans = 0
	import itertools

	ans_list = set()
	for i in itertools.combinations_with_replacement(list(range(1,m+1)),n):
		for qul in range(q):
			if i[ qu[qul][1]-1 ] - i[ qu[qul][0]-1 ] == qu[qul][2]:
				ans += qu[qul][3]
		ans_list.add(ans)
		ans = 0
	print(max(ans_list))

if __name__ == '__main__':
	main()
n = input()

for i in range(len(n)):
  if n[i] = '7':
    count += 1
    
if count > 0:
  print('Yes')
  
else:
  print('No')

### FIXED CODE ###

n = input()
count = 0

for i in range(3):
  if n[i] == '7':
    count += 1
    
if count > 0:
  print('Yes')
  
else:
  print('No')
import math
A,B = map(int,input().split())

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

print(lcd(A,B))


### FIXED CODE ###

import fractions as fr
A,B = map(int,input().split())
 
def lcd(x,y):
  return (x*y)//fr.gcd(x,y)
 
print(lcd(A,B))
N, M = list(map(int, input().split(' ')))
result_list = [input().split(' ') for i in range(M)]
AC_total = 0
WA_total = 0
ac_list = []
wa_dict = {}
for p, s in result_list:
    if p not in ac_list:
        if s == 'WA':
            if p in wa_dict:
                wa_dict[p] += 1
            else:
                wa_dict[p] = 1
        else:
            AC_total += 1
            ac_list.append(p)
for p in wa_dict:
    if p in ac_list:
        WA_total += wa
print('{} {}'.format(AC_total, WA_total))

### FIXED CODE ###

N, M = list(map(int, input().split(' ')))
AC_total = 0
WA_total = 0
ac_list = [False] * N
wa_list = [0] * N
for i in range(M):
    p, s = input().split(' ')
    p = int(p) - 1
    if not ac_list[p]:
        if s == 'WA':
            wa_list[p] += 1
        else:
            AC_total += 1
            WA_total += wa_list[p]
            ac_list[p] = True
print('{} {}'.format(AC_total, WA_total))
from __future__ import print_function
import sys
import numpy as np

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N,Q = map(int,input().split())  # Nは文字列Sの長さ．Qは質問の個数．
S = input()
S=S+"0"

cnt=np.zeros(100000)
now_x=0
for i in range(1,N+1):
    if S[i-1]=='A' and S[i]=='C':
        cnt[i]=now_x+1
        now_x=cnt[i]
    else:
        cnt[i]=now_x

for i in range(Q):
    left,right=map(int,input().split())
    left-=1
    right-=1
    print(cnt[right]-cnt[left])
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #


### FIXED CODE ###

from __future__ import print_function
import sys
import numpy as np

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N,Q = map(int,input().split())  # Nは文字列Sの長さ．Qは質問の個数．
S = input()
S=S+"0"

cnt=np.zeros(100000,dtype='int')
now_x=0
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        cnt[i]=now_x+1
        now_x=cnt[i]
    else:
        cnt[i]=now_x

for i in range(Q):
    left,right=map(int,input().split())
    left-=1
    right-=1
    print(cnt[right]-cnt[left])
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
a,b,c=map(int,input().split(" "))
print("YES") if b-a==c-b else print("NO)

### FIXED CODE ###

a,b,c=map(int,input().split(" "))
print("YES") if b-a==c-b else print("NO")
n=int(input())

import numpy as np
dist=np.full((n,n),-1,dtype=int)
for i in range(n-1):
  dist[i][i]=0
  a,b,c=map(int,input().split())
  dist[a-1][b-1]=c
  dist[b-1][a-1]=c

Q,K=map(int,input().split())
distFromK=np.full(n,-1,dtype=int)

# start from K
stack=[]
stack.append([K-1,0,-1])
while stack:
  node=stack.pop()
  num=node[0]
  d=node[1]
  parent=node[2]
  if distFromK[num]==-1:
    distFromK[num]=d
  else:
    distFromK[num]=min(d,distFromK[num])
  targets=dist[num]
  for i in range(len(targets)):
    if i==parent or i==num:
      continue
    if targets[i]==-1:
      continue
    stack.append([i,targets[i]+d,num])
    
for i in range(Q):
  x,y=map(int,input().split())
  print(distFromK[x-1]+distFromK[y-1])


### FIXED CODE ###

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

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

INF=10**9+1
distFromK=[-1 for i in range(n)]

# start from K
stack=[]
stack.append([K-1,0,-1])
while stack:
  node=stack.pop()
  v=node[0]
  d=node[1]
  parent=node[2]
  if distFromK[v]==-1:
    distFromK[v]=d
  else:
    distFromK[v]=min(distFromK[v],d)
  targets=dist[v]
  for child in targets:
    if child[0]==parent or child[0]==v:
      continue
    stack.append([child[0],d+child[1],v])

for i in range(Q):
  x,y=map(int,input().split())
  print(distFromK[x-1]+distFromK[y-1])
def insection_sort(lst):
    lens=len(lst)
    ans=0
    for i in xrange(lens):
        mn=i
        for j in xrange(i+1,lens):
            if(lst[j]<lst[mn]):
                mn=j
        if(mn!=i):lens
            tmp=lst[i]
            lst[i]=lst[mn]
            lst[mn]=tmp
            ans+=1
    return ans
num=int(raw_input().strip())
arr=map(int,raw_input().strip().split())
ans=insection_sort(arr)
print " ".join(str(pp) for pp in arr)
print ans



### FIXED CODE ###

def insection_sort(lst):
    lens=len(lst)
    ans=0
    for i in xrange(lens):
        mn=i
        for j in xrange(i+1,lens):
            if(lst[j]<lst[mn]):
                mn=j
        if(mn!=i):
            tmp=lst[i]
            lst[i]=lst[mn]
            lst[mn]=tmp
            ans+=1
    return ans
num=int(raw_input().strip())
arr=map(int,raw_input().strip().split())
ans=insection_sort(arr)
print " ".join(str(pp) for pp in arr)
print ans
import math
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
tmp = [[0 for i in range(6)] for j in range(n+1)]
absDiff = abs(x[0]-y[0])
tmp[0][3] = tmp[0][0] = absDiff
tmp[0][4] = tmp[0][1] = absDiff ** 2
tmp[0][5] = tmp[0][2] = absDiff ** 3
max = absDiff
for i in range(1, n, 1):
    absDiff = abs(x[i]-y[i])
    tmp[i][0] = absDiff
    tmp[i][1] = absDiff ** 2
    tmp[i][2] = absDiff ** 3
    tmp[i][3] = tmp[i-1][3] + tmp[i][0]
    tmp[i][4] = tmp[i-1][4] + tmp[i][1]
    tmp[i][5] = tmp[i-1][5] + tmp[i][2]
    if absDiff > max:
        max = absDiff
print(tmp[i][3])
print(math.sqrt(tmp[i][4]))
print(tmp[i][5] ** (1/3))
print(max)

### FIXED CODE ###

n = int(input())
x = [0] + list(map(int, input().split()))
y = [0] + list(map(int, input().split()))
tmp = [[0 for i in range(3)] for j in range(n+1)]
max = 0
for i in range(1, n+1, 1):
    absDiff = abs(x[i]-y[i])
    absDiff2 = absDiff * absDiff
    absDiff3 = absDiff2 * absDiff
    tmp[i][0] = tmp[i-1][0] + absDiff
    tmp[i][1] = tmp[i-1][1] + absDiff2
    tmp[i][2] = tmp[i-1][2] + absDiff3
    if absDiff > max:
        max = absDiff
print(tmp[n][0])
print(tmp[n][1] ** (1/2))
print(tmp[n][2] ** (1/3))
print(max)
N = int(input())

if N % 2 == 1:
    ans = 0
else:
    count = 1
    num5 = 0
    while N//2 >= 5**count:
        num5 += N//(2*5**count)
        count+=1

print(num5)


### FIXED CODE ###

N = int(input())

if N % 2 == 1:
    ans = 0
else:
    count = 1
    ans = 0
    while N//2 >= 5**count:
        ans += N//(2*5**count)
        count+=1

print(ans)
S = str(input())
T = str(input())
 
if len(S) + 1 == len(T) and S = T[:-1]:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

S = str(input())
T = str(input())
 
if len(S) + 1 == len(T) and S == T[:-1]:
  print("Yes")
else:
  print("No")
N = int(input())
X = input()

memo = {}


def popcount(n):
    return bin(n).count('1')


def f(n):
    if n == 0:
        return 0
    if n in memo:
        return memo[n]
    memo[n] = 1 + f(n % popcount(n))
    return memo[n]


Xint = int(X, 2)
p = popcount(Xint)
x1 = Xint % (p - 1) if 1 < p else None
x2 = Xint % (p + 1)
ans = []
b = 1
bmod1 = b % (p - 1) if 1 < p else None
bmod2 = b % (p + 1)
for i in range(N):
    if X[-1 - i] == '1':
        if 1 < p:
            ans.append(1 + f((x1 - bmod1) % (p - 1)))
        else:
            ans.append(1)
    else:
        ans.append(1 + f((x2 + bmod2) % (p + 1)))
    b <<= 1
    bmod1 = bmod1 * 2 % (p - 1) if 0 < p else None
    bmod2 = bmod2 * 2 % (p + 1)
for a in reversed(ans):
    print(a)

### FIXED CODE ###

N = int(input())
X = input()

memo = {}


def popcount(n):
    return bin(n).count('1')


def f(n):
    if n == 0:
        return 0
    if n in memo:
        return memo[n]
    memo[n] = 1 + f(n % popcount(n))
    return memo[n]


def solve(N, X):
    Xint = int(X, 2)
    p = popcount(Xint)
    if 1 < p:
        x1 = Xint % (p - 1)
    x2 = Xint % (p + 1)
    ans = []
    b = 1
    if 1 < p:
        bmod1 = b % (p - 1)
    bmod2 = b % (p + 1)
    for i in range(N):
        if X[-1 - i] == '1':
            if 1 < p:
                ans.append(1 + f((x1 - bmod1) % (p - 1)))
            else:
                ans.append(0)
        else:
            ans.append(1 + f((x2 + bmod2) % (p + 1)))
        b <<= 1
        if 1 < p:
            bmod1 = bmod1 * 2 % (p - 1)
        bmod2 = bmod2 * 2 % (p + 1)

    return list(reversed(ans))


for x in solve(N, X):
    print(x)
import headq
n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input()split()))
headq.heaify(a)
for i in range(m):
  min = heapq.heapppop(a)
  heapq.heappush(a, (-min//2)*(-1))
print(-sum(a))

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
  min = heapq.heappop(a)
  heapq.heappush(a, (-min//2)*(-1))
print(-sum(a))
# -*- coding: utf-8 -*-
# 整数の入力
# from functools import reduce
from collections import defaultdict


def main():
    # n, q
    n, q = map(int, input().split())

    # a, b
    a = []
    b = []
    for _ in range(0, n - 1):
        ai, bi = map(int, input().split())
        a.append(ai)
        b.append(bi)

    # p, x
    p = []
    x = []
    for _ in range(0, q):
        pi, xi = map(int, input().split())
        p.append(pi)
        x.append(xi)

    print(process(n, q, a, b, p, x))


def process(n, q, a, b, p, x):
    points = [0] * (n + 1)
    graph = defaultdict(list)
    for i in range(0, n - 1):
        graph[a[i]].append(b[i])

    for i in range(0, q):
        target = p[i]
        xi = x[i]
        subtree(points, target, graph, xi)

    # print(points)
    points.pop(0)

    points_sorted = map(str, points)
    return ' '.join(points_sorted)


def subtree(points, target, graph, x):
    points[target] += x
    for i in graph[target]:
        subtree(points, i, graph, x)


if __name__ == "__main__":
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
# from functools import reduce
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)


def main():
    # n, q
    n, q = map(int, input().split())

    trees = [[] for i in range(n+1)]
    # a, b
    for _ in range(0, n - 1):
        a, b = map(int, input().split())
        trees[a].append(b)
        trees[b].append(a)

    values = [0 for i in range(n+1)]
    # p, x
    for _ in range(0, q):
        p, x = map(int, input().split())
        values[p] += x
    process(1, -1, trees, values)
    print(*values[1:])


def process(i, parent, trees, values):
    for j in trees[i]:
        if j == parent:
            continue
        values[j] += values[i]
        process(j, i, trees, values)


if __name__ == "__main__":
    main()
import numpy as np

N,W = list(map(int,input().split()))
w_l = []
v_l = []
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    w,v = list(map(int,input().split()))
    dp[w:] = np.maximum(dp[w:],dp[:-w] + v)
    w_l.append(w)
    v_l.append(v)
print(dp[W])

### FIXED CODE ###

import numpy as np

N,W = list(map(int,input().split()))
dp = np.zeros(W+1,dtype = int)
for i in range(N):
    w,v = list(map(int,input().split()))
    dp[w:] = np.maximum(dp[w:],dp[:-w] + v)
print(dp[-1])
N, i = map(int, input().split())

if N = 1:
    print(N)
else:
    print(N - i + 1)

### FIXED CODE ###

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

if N == 1:
    print(N)
else:
    print(N - i + 1)
loop = input()
a = map(int, input().split())
cnt = 0
 
while(1):
  flg = 0
  for i in a:
    if(a%2 == 1):
      flg = 1
      
  if(flg == 0):
    a = map(lambda x:x/2, a)
    cnt += 1
  else:
    break
 
print(cnt)

### FIXED CODE ###

a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)
r = int(input())
prinrt(2*r*3.141592)

### FIXED CODE ###

import math
r = int(input())
pi = math.pi
print(r*2*pi)
int A,B,C

if

### FIXED CODE ###

L=list(map(int,input().split()))
L.sort()
if L==[5,5,7]:
    print('YES')
else:
    print('NO')
import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
flag = True
l = []
r = set(list(range(n)))
N = n*(n-1) // 2
if _ in range(N)
    if l and not r:
        print(ans)
        break
    ne = set()
    for j in r:
        if not a[j]:
            continue
        c = a[j][0]
        if c == "-":
            continue
        if j + 1 == a[c-1][0]:
            a[j][0] = "-"
            a[c-1][0] = "-"
            ne.add(j)
            ne.add(c-1)
    l = list(ne)
    for j in l:
        if a[j]:
            if a[j][0] == "-":
                a[j] = a[j][1:]
                flag = False
                if not a[j]:
                    ne.remove(j)
    if flag:
        print(-1)
        break
    else:
        r = ne
        ans += 1


### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
r = set(list(range(n)))
N = n*(n-1) // 2 + 1
for _ in range(N):
    if not r:
        print(_)
        break
    ne = set()
    flag = True
    for j in r:
        if not a[j]:
            continue
        c = a[j][0]
        if c == "-":
            continue
        if j + 1 == a[c-1][0]:
            a[j][0] = "-"
            a[c-1][0] = "-"
            ne.add(j)
            ne.add(c-1)
    for j in list(ne):
        if a[j]:
            if a[j][0] == "-":
                a[j].pop(0)
                flag = False
                if not a[j]:
                    ne.remove(j)
    if flag:
        print(-1)
        break
    else:
        r = ne
N = int(input())
    # t, x, y = 0, 0, 0
    for __ in range(N):
        t, x, y = map(int, input().split())
        if (x + y) > t or (x + y + t) % 2 != 0:
            print("No")
            sys.exit()

    print("Yes")

### FIXED CODE ###

t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

res = res_arr[-1]+res_arr[-2]
if n == 1:
    res = res_arr[1]
elif n == 2:
    res = 1 + res_arr[1]
amari = res % 1000000007
print(amari)


### FIXED CODE ###

n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
res_arr = [-1] * n

for i in a:
    res_arr[i] = 0

for i in range(1, n):
    if res_arr[i] == 0:
        next
    elif i == 1:
        res_arr[i] = 1
    elif i == 2:
        res_arr[i] = 1 + res_arr[i-1]
    else:
        res_arr[i] = res_arr[i-1] + res_arr[i-2]

if n == 1:
    res = 1
elif n == 2:
    res = 1 + res_arr[1]
else:
    res = res_arr[-1]+res_arr[-2]
amari = res % 1000000007
print(amari)
# coding: utf-8
import math


def test(n,dict):
    left = n - 1
    right = n - 2
    leftValue = 0
    rightValue = 0
    if left in dict:
        leftValue = dict[left]
    else:
        leftValue = test(left, dict)

    if right in dict:
        rightValue = dict[right]
    else:
        rightValue = test(right, dict)


    return leftValue + rightValue



if __name__ == "__main__":
    n = int(input())
    dict = {0:2, 1:1}
    print(test(n, dict))

### FIXED CODE ###

# coding: utf-8
from functools import lru_cache


@lru_cache(maxsize=1000)
def test2(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    else:
        return test2(n-1) + test2(n-2)


if __name__ == "__main__":
    n = int(input())
    dict = {0:2, 1:1}
    print(test2(n))
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])


### FIXED CODE ###

r = int(input())
print(3*r*r)