Harryxun/stf_run huggingface dataset:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = 0
    b_max = 0
    for i in range(len(a_time)):
        if a_time[i] > k:
            break
        else:
            a_max = i
    for i in range(len(b_time)):
        if b_time[i] > k:
            break
        else:
            b_max = i

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            a_max -= 1
    for i in range(len(a_time)):
        if b_time[b_max] + a_time[i] <= k:
            ans = max(ans, b_max + i)
        else:
            b_max -= 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = 0
    a_time = [0]
    b_time = [0]
    for i in range(1, len(a) + 1):
        a_time.append(a_time[i - 1] + a[i - 1])
    for i in range(1, len(b) + 1):
        b_time.append(b_time[i - 1] + b[i - 1])

    a_max = 0
    b_max = 0
    for i in range(len(a_time)):
        if a_time[i] > k:
            break
        else:
            a_max = i
    for i in range(len(b_time)):
        if b_time[i] > k:
            break
        else:
            b_max = i

    for i in range(len(b_time)):
        if a_time[a_max] + b_time[i] <= k:
            ans = max(ans, a_max + i)
        else:
            if a_max > 0:
                a_max -= 1
    for i in range(len(a_time)):
        if b_time[b_max] + a_time[i] <= k:
            ans = max(ans, b_max + i)
        else:
            if b_max > 0:
                b_max -= 1

    print(ans)

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

N, K, Q = map(int, input())
A = list(map(int, input().split))

players_score = np.array([k for i in range(n)])
for item in a:
    players_score -= 1
    players_score[item-1] += 1

indict = ['No' if i <= 0 else 'Yes' for i in players_score ]
for i in indict:
    print(i)



### FIXED CODE ###

import numpy as np

n, k, q = map(int, input().split())
a = np.array([int(input()) for i in range(q)])

players_score = np.full(n, k-q)

for item in a:
    players_score[item-1] += 1

for i in players_score:
    if i <= 0:
        print("No")
    else:
        print("Yes")
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
win = []
ans = 0
for i in range(n):
    if t[i] == "r":
        win.append("p")
    elif t[i] == "s":
        win.append("r")
    else:
        win.append("s")
for i in range(n):
    if i >= k:
        if win[i] == win[i - k]:
            if i + k > n:
                pass
            elif win[i + k] != t[i]:
                win[i] = t[i]
            else:
                if win[i] != r and [i + k] != r:
                    win[i] = r
                elif win[i] != s and [i + k] != s:
                    win[i] = s
                elif win[i] != p and [i + k] != p:
                    win[i] = p
        else:
            if win[i] == "r":
                ans += r
            elif win[i] == "s":
                ans += s
            else:
                ans += p
    else:
        if win[i] == "r":
            ans += r
        elif win[i] == "s":
            ans += s
        else:
            ans += p
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
win = []
ans = 0
for i in range(n):
    if t[i] == "r":
        win.append("p")
    elif t[i] == "s":
        win.append("r")
    else:
        win.append("s")
for i in range(n):
    if i >= k:
        if win[i] == win[i - k]:
            if i + k >= n:
                pass
            elif win[i + k] != t[i]:
                win[i] = t[i]
            else:
                if win[i] != r and [i + k] != r:
                    win[i] = r
                elif win[i] != s and [i + k] != s:
                    win[i] = s
                elif win[i] != p and [i + k] != p:
                    win[i] = p
        else:
            if win[i] == "r":
                ans += r
            elif win[i] == "s":
                ans += s
            else:
                ans += p
    else:
        if win[i] == "r":
            ans += r
        elif win[i] == "s":
            ans += s
        else:
            ans += p
print(ans)
A, B = map(int, input().split())
ans = 0
for x in range(A, B+1):
    if str(x) == str(x).reverse():
        ans += 1
print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
ans = 0
for x in range(A, B+1):
    if str(x) == str(x)[::-1]:
        ans += 1
print(ans)
nums = input()
print(sum(nums)-sum(set(nums)))

### FIXED CODE ###

nums = map(int, input().split())
d = {}
for n in nums:
  d.setdefault(n, 0)
  d[n] += 1
print(list(d.keys())[list(d.values()).index(1)])
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000)
n,q=map(int,input().split())
g=[[i] for i in range(n+1)]

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

c=[0]*(n+1)
def dfs(p,x):
    for i in g[p]:
        if r[i]:
            r[i]=0
            c[i]+=x
            dfs(i,x)

for _ in range(q):
    r=[1]*(n+1)
    p,x=map(int,input().split())
    dfs(p,x)


print(*c[1:])


### FIXED CODE ###

a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")
from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [-1] * (w * h)  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[i + (w * j)] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[i + (w * j)] < 0:
                dist[i + (w * j)] = dist[x + (w * y)] + 1
                que.append((i, j))
    return dist[x + (w * y)]


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))


### FIXED CODE ###

from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [[-1] * w for _ in range(h)]  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[i][j] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:
                dist[i][j] = dist[x][y] + 1
                que.append((i, j))
    return dist[x][y]


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))
import sys

r,c,k=map(int,input().split())
dp=[[[0 for kk in range(4)] for jj in range(c+1)] for ii in range(r+1)]

g=[[0 for j in range(c)] for i in range(r)]
for i in range(k):
    rr,cc,v=map(int,input().split())
    rr-=1
    cc-=1
    g[rr][cc]=v
for i in range(1,r+1):
    for j in range(1,c+1):
        for k in range(4):
            dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k])#,dp[i][j-1][k])
            dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k])
            if k>0:
                if dp[i][j][k]<dp[i][j-1][k-1]+g[i-1][j-1]:
                    dp[i][j][k]=dp[i][j-1][k-1]+g[i-1][j-1]
            if dp[i][j][1]<dp[i-1][j][k]+g[i-1][j-1]:
                dp[i][j][1]=dp[i-1][j][k]+g[i-1][j-1]
print(max(dp[r][c]))



### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
    p[i]-=1
ans=max(c)
for i in range(n):
    f=i
    r=0
    l=[]
    while True:
        f=p[f]
        l.append(c[f])
        r+=c[f]
        if f==i:
            break
    t=0
    for j in range(len(l)):
        t+=l[j]
        if j+1>k:
            break
        ret=t
        if r>0:
            e=(k-j-1)//len(l)
            ret+=r*e
        ans=max(ans,ret)
print(ans)
from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q_walk = deque()
    q_warp = deque()
    q_walk.append((x, y))
    while q_walk > 0:
        x, y = q_walk.popleft() 
        q_warp.append((x, y))
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q_walk.append((nx, ny))
        if len(q_wark) == 0:
            while len(q_warp) > 0:
                x2, y2 = q_warp.popleft()
                for dxx in range(-2, 3):
                    for dyy in range(-2, 3):
                        nxx = x2 + dxx
                        nyy = y2 + dyy 
                        if not 0 <= nxx < h or not 0 <= nyy < w:
                            continue
                        if maze[nxx][nyy] == "#":
                            continue
                        if dist[nxx][nyy] <= d+1:
                            continue
                        dist[nxx][nyy] = d+1
                        q_warp.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])    



### FIXED CODE ###

from collections import deque
h, w = map(int, input().split())
c_h, c_w = map(int, input().split())
d_h, d_w = map(int, input().split())
#スタートとゴールの座標を設定
start_h = c_h - 1
start_w = c_w - 1
goal_h = d_h - 1
goal_w = d_w - 1
#迷路の読み込み
maze = [input() for _ in range(h)]
inf = float("inf")
dist = [[inf] * w for _ in range(h)]



def bfs(x, y):
    dist[x][y] = 0
    q = deque()
    q.append((x, y))
    while q:
        x, y = q.popleft() 
        d = dist[x][y]
        for dx, dy in [(0,1),(1,0),(0,-1),(-1,0)]:
            nx = x + dx
            ny = y + dy 
            if not 0 <= nx < h or not 0 <= ny < w:
                continue
            if maze[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d:
                continue
            dist[nx][ny] = d           
            q.appendleft((nx, ny))

        for dxx in range(-2, 3):
            for dyy in range(-2, 3):
                 nxx = x + dxx
                 nyy = y + dyy 
                 if not 0 <= nxx < h or not 0 <= nyy < w:
                    continue
                 if maze[nxx][nyy] == "#":
                    continue
                 if dist[nxx][nyy] <= d+1:
                    continue
                 dist[nxx][nyy] = d+1
                 q.append((nxx, nyy))
                



bfs(start_h, start_w)
if dist[goal_h][goal_w] == inf:
    print("-1")
else:
    print(dist[goal_h][goal_w])
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read
MOD = 10**9 + 7

n = int(input())
a = np.array(readline().split(), dtype=np.uint64)
r = np.cumsum(a[::-1])[::-1]
r &= MOD
x = a[:-1] * r[1:]
x %= MOD
ans = int(np.sum(x) % MOD)
print(ans)


### FIXED CODE ###

d, t, s = map(int, input().split())
ans = "No" if d > t * s else "Yes"
print(ans)
n = int(input())
p = list(map(int, input().split()))

count = 0

for i in range(n-1):
  if p[i]<p[i+1]<p[i+2] or p[i+2]<p[i+1]<p[i]:
    count += 1
    
print(count)


### FIXED CODE ###

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

count = 0

for i in range(n-2):
  if p[i]<p[i+1]<p[i+2] or p[i+2]<p[i+1]<p[i]:
    count += 1
    
print(count)
x=int(input())
if x==7 or x==5 or x==3:
    print(YES)
else:
    print(NO)

### FIXED CODE ###

x=int(input())
if x==7 or x==5 or x==3:
    print("YES")
else:
    print("NO")
n = int(input())
a = list(map(int, input().split()))
hai, tya midori = 0, 0, 0
miz, ao, ki = 0, 0, 0
yanagi, aka, got = 0, 0, 0

for i in a:
  if i<=399:
    hai = 1
  elif i<=799:
    tya = 1
  elif i<=1199:
    midori = 1
  elif i <= 1599:
    miz = 1
  elif i <= 1999:
    ao = 1
  elif i <= 2399:
      ki = 1
  elif i <= 2799:
      yanagi = 1
  elif i <= 3199:
      aka = 1
  elif i <= 4800:
    got += 1
minn = hai+tya+midori+miz+ao+ki+yanagi+aka
if minn + got >= 8:
  maxx = 8
else:
  maxx = minn+got
print(minn, maxx)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
hai, tya, midori = 0, 0, 0
miz, ao, ki = 0, 0, 0
yanagi, aka, got = 0, 0, 0

for i in a:
  if i<=399:
    hai = 1
  elif i<=799:
    tya = 1
  elif i<=1199:
    midori = 1
  elif i <= 1599:
    miz = 1
  elif i <= 1999:
    ao = 1
  elif i <= 2399:
      ki = 1
  elif i <= 2799:
      yanagi = 1
  elif i <= 3199:
      aka = 1
  elif i <= 4800:
    got += 1
minn = hai+tya+midori+miz+ao+ki+yanagi+aka
maxx = minn+got
if minn==0:
    minn = 1
print(minn, maxx)
import sys

a = []
for line in sys.stdin:
    a.append(int(line))
    
del a[0]
del a[len(a)-1]
b = []
for line in sys.stdin:
    b.append(int(line))
del b[0]
del b[0]
print(max(b)-min(a))
    



### FIXED CODE ###

import sys

a = []
b = []
for line in sys.stdin:
    a.append(int(line))
    b.append(int(line))

del a[0]
del a[len(a)-1]
del b[0]
del b[0]

maxv = -1000000000
minv = a[0]
for i in range(len(a)):
    maxv = max(maxv,b[i]-minv)
    minv = min(minv,b[i])
print(maxv)
S = input()
if S[0] == S[1] and s[1] == S[2]:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

S = input()
if S[0] == S[1] and S[1] == S[2]:
  print('No')
else:
  print('Yes')
N,K=map(int,input().split())
A=list(map(int,input().split()))
done=[0 for _ in range(N)]
done[0]=1
W=[0]
loop=0
city=0
for i in range(N):
    if done[A[i]-1]==2:
        init=W.index(A[i]-1)
        loop=i-init
        break
    city=A[city]-1
    W.append(city)
    done[city]+=1

if min(done)>0:
    init=0
    loop=N

print(W[(K-init)%loop+init]+1)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
done=[-1 for _ in range(N)]
done[0]=0
n=0
now=0
init=0
loop=N
log=[0]

while n<N:
    log.append(A[log[-1]]-1)
    n+=1
    if done[log[-1]]>-1:
        init=done[log[-1]]
        loop=n-done[log[-1]]
        break
    done[log[-1]]=n

if K<init:
    print(log[K]+1)
else:
    num=init+(K-init)%loop
    print(log[num]+1)
N, K=map(int,input().split())
A=list(map(int,input().split()))
B=sorted([(a,abs(a)) for a in A],key=lambda x:x[1],reverse=True)
R=10**9+7
P=1
minus=0
last_neg=-1
last_pos=-1
for i in range(K):
    if i!=0:
        P=P*B[i-1][1]
    if B[i][0]>0:
        last_pos=i
    else:
        minus+=1
        last_neg=i
if minus%2==1:
    first_neg=-1
    first_pos=-1
    count=[0,0]
    for i in range(K,N):
        if count[0]==0 and B[i][0]>0:
            first_pos=i
            count[0]=1
            if last_neg<last_pos:
                count[1]=1
                break
        elif count[1]==0 and B[i][0]<0:
            first_neg=i
            count[1]=1
            if last_pos<last_neg:
                count[0]=1
                break
        elif count==[1,1]:
            break
    if last_pos==-1 and first_pos==-1:
        P=1
        for i in range(K):
            P=(P*B[N-i-1][0]) %R
        print(P)
        exit()
    list_product=[]
    if first_neg!=-1:
        list_product.append((P*B[first_neg][1]) %R)
    if first_pos!=-1:
        list_product.append((P*B[first_pos][1]) %R)
    print(max(list_product))
else:
    print(P*B[K-1][1] %R)

### FIXED CODE ###

import copy
N, K=map(int,input().split())
A=list(map(int,input().split()))
B=sorted([(a,abs(a)) for a in A],key=lambda x:x[1],reverse=True)
R=10**9+7
P=1
minus=0
last_neg=-1
last_pos=-1
for i in range(K):
    if B[i][0]>0:
        if last_pos != -1:
            P = (P * B[last_pos][1]) % R
        last_pos=i
    elif B[i][0]<0:
        if last_neg != -1:
            P = (P * B[last_neg][1]) % R
        minus+=1
        last_neg=i
    else:
        print(0)
        exit()
F=copy.copy(P)
if last_pos!=-1:
    F=(F*B[last_pos][1]) % R
if last_neg!=-1:
    F=(F*B[last_neg][1]) % R
if minus%2==1:
    if K == N:
        print(-F %R)
        exit()
    first_neg=-1
    first_pos=-1
    count=[0,0]
    for i in range(K,N):
        if count[0]==0 and B[i][0]>0:
            first_pos=i
            count[0]=1
        elif count[1]==0 and B[i][0]<0:
            first_neg=i
            count[1]=1
        elif count==[1,1]:
            break
    if first_pos==-1 and last_pos==-1:
        P = 1
        for i in range(K):
           P = (P * B[N - i - 1][0]) % R
        print(P)
        exit()
    if first_pos==-1 and first_neg==-1:
        print(0)
        exit()
    list_product=[]
    if first_neg!=-1 and last_pos!=-1:
        list_product.append(B[last_neg][1]*B[first_neg][1])
    if first_pos!=-1:
        P1=B[first_pos][1]
        if last_pos!=-1:
            P1=P1*B[last_pos][1]
        list_product.append(P1)
    print(max(list_product)*P %R)
else:
    print(F)
from collections import deque
n = int(input())
i = 2
a = []
x = n
while(i * i <= n):
    if (n % i == 0):
        a.append(i)
        n //= i
        while(n % i == 0):
            n //= i
            a.append(a[-1] * i)
    i += 1
if (n != 1):
    a.append(n)
a.sort(reverse = True)
ans = 0
while(x != 1):
    while(x % a[-1]):
        a.pop()
    x /= a[-1]
    a.pop()
    ans += 1
print(ans)
    


### FIXED CODE ###

from collections import deque
n = int(input())
i = 2
a = []
x = n
while(i * i <= n):
    if (n % i == 0):
        a.append(i)
        n //= i
        while(n % i == 0):
            n //= i
            a.append(a[-1] * i)
    i += 1
if (n != 1):
    a.append(n)
a.sort(reverse = True)
ans = 0
while(x != 1 and len(a)):
    while(x % a[-1]):
        a.pop()
        if (len(a) == 0):
            break
    if (len(a) == 0):
        break
    x //= a[-1]
    a.pop()
    ans += 1
print(ans)
rom bisect import bisect
def inpl(): return list(map(int, input().split()))

N, L = inpl()
DP = [1e9]*(10**5 + 2)
DP[0] = 0
for i in range(N):
    DP2 = [1e9]*(10**5 + 2)
    w, v = inpl()

    for i in range(10**5, v-1, -1):
        DP2[i] = min(DP[i-v] + w, DP[i], DP2[i+1])
    for i in range(v-1, -1, -1):
        DP2[i] = min(DP[i], DP2[i+1])
    DP = DP2
print(bisect(DP, L)-1)

### FIXED CODE ###

from bisect import bisect
def inpl(): return list(map(int, input().split()))

N, L = inpl()
DP = [1e10]*(10**5 + 2)
DP[0] = 0
for i in range(N):
    DP2 = [1e10]*(10**5 + 2)
    w, v = inpl()

    for i in range(10**5, v-1, -1):
        DP2[i] = min(DP[i-v] + w, DP[i], DP2[i+1])
    for i in range(v-1, -1, -1):
        DP2[i] = min(DP[i], DP2[i+1])
    DP = DP2
print(bisect(DP, L)-1)
dat =list(input().split())

for i in dat:
	i = int(i)

dat.sort(reverse=True)

asum = 0
bsum = 0
sum = 0

for i in range(len(dat)):
      sum = sum + dat[i]
		
print(sum)

### FIXED CODE ###

n = int(input())
dat = list(input().split())

dat = list(map(int,dat))

dat.sort(reverse=True)

asum = 0
bsum = 0

for i in range(n):
	if i % 2 == 0:
		asum = asum + dat[i]
	else:
		bsum = bsum + dat[i]
		
print(asum-bsum)
A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10
		
	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	print(min_r,min_d,i,sm)


print(sm - (10-min_r))

### FIXED CODE ###

A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
min_r = 10
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))
#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
not_good = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:  # bはダメ
        not_good.append(b)
    elif h[a - 1] == h[b - 1]:
        not_good.append(a)
        not_good.append(b)
    else:
        not_good.append(a)
ans = 0
not_good = list(set(not_good))
not_good.sort()
# print(not_good)
idx = 0
for i in range(1, n + 1):
    if i < not_good[idx]:
        ans += 1
        # print(i, end=" ")
    elif i == not_good[idx]:
        idx += 1
        if idx == len(not_good):
            ans += n - i
            break
    else:
        pass
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import bisect

n = int(input())
a = list(map(int, input().split()))
# b = a -1 とすると、bi+bj = -2*i or -2+j となるi,jを見つける
# sortして2分探索すると解ける
b = [a[i] - (1 + i) for i in range(0, n)]
b, idx = zip(*sorted(zip(b, range(1, n + 1))))
# print(b)
ans = 0
for i in range(n):
    # b[i]を固定して二分探索
    r = bisect.bisect_right(b, -b[i] - 2 * idx[i])
    l = bisect.bisect_left(b, -b[i] - 2 * idx[i])
    ans += r - l
    # if r - l != 0:
    # print(i, r, l, -b[i] - 2 * idx[i])
print(ans)
n = int(input())
a = [input() for i in range(n)]
margin = max(a) - min(a)
print(min(a))



### FIXED CODE ###

n = int(input())
R = [int(input()) for i in range(n)]

minv = R[0]
maxv = R[1] - R[0]
for j in range(1, n):
	if (maxv < R[j] - minv):
		maxv = R[j] - minv
	if (R[j] < minv):
		minv = R[j]
    
print(maxv)
L = list(map(int,input().split()))

print(L[0]*l[1]//2)

### FIXED CODE ###

L = list(map(int,input().split()))
     
print(L[0]*L[1]//2)
def dfs(n,arr,visited):
    for i in graph[n]:
        if visited[i]==False:
            arr[n]=max(arr[n],dfs(i,arr,visited)+1)
            visited[i]=True
        else:
            arr[n]=max(arr[n],arr[i]+1)
    return arr[n]

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

graph=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if a!=b:
        graph[a-1].append(b-1)

visited=[False for i in range(n)]

arr=[0 for i in range(n)]

for i in range(n):
    if visited[i]==False:
        dfs(i,arr,visited)
print(max(arr))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)

def dfs(n,arr,visited):
    for i in graph[n]:
        if visited[i]==False:
            arr[n]=max(arr[n],dfs(i,arr,visited)+1)
            visited[i]=True
        else:
            arr[n]=max(arr[n],arr[i]+1)
    return arr[n]

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

graph=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    if a!=b:
        graph[a-1].append(b-1)

visited=[False for i in range(n)]

arr=[0 for i in range(n)]

for i in range(n):
    if visited[i]==False:
        dfs(i,arr,visited)
print(max(arr))
from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
import math

n = input()

for i in range(n):
    a = int(math.sqrt(n - i))
    b = n - i
    if a**2 == b:
        print(b)
        break
    else:
        pass


### FIXED CODE ###

import numpy

n = int(input())

for i in range(n):
    a = int(numpy.sqrt(n - i))
    b = n - i
    if a**2 == b:
        print(b)
        break
    else:
        pass