Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
A = []
for _ in range(N):
  A += [int(input())]
for i in range(N):
  print(max([A[j] for j in range(N) if j != i])) 

### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
  A += [int(input())]
Amax = max(A)
Amax2 = sorted(A, reverse=True)[1]
for i in A:
  print(Amax if i != Amax else Amax2)
### BUGGY CODE ###

N = int(input())
nos = list(map(int, input().split()))
count = 1
for j in range(1,N):
  if min(nos[0:j+1]) == nos[j]:
    count += 1
print(count)

### FIXED CODE ###

N = int(input())
nos = list(map(int, input().split()))
count = 1
min = nos[0]
for j in range(1,N):
  if nos[j] <= min:
    count += 1
    min = nos[j]
print(count)
### BUGGY CODE ###

import bisect
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(M):
    p = A.pop()
    p //= 2
    index = bisect.bisect_left(A, p)
    A.insert(index, p)
print(sum(A))

### FIXED CODE ###

import heapq
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [(-x, x) for x in A]
heapq.heapify(A)
for i in range(M):
    P = heapq.heappop(A)
    p = P[1] // 2
    heapq.heappush(A, (-p, p))
s = 0
for i in range(N):
    s += A[i][1]
print(s)
### BUGGY CODE ###

import bisect
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(m):
    a = A[-1]//2
    A=A[:-1]
    bisect.insort(A,a)
print(sum(A))


### FIXED CODE ###

import heapq
n, m = map(int, input().split())
A = sorted(map(lambda x: -int(x), input().split()))
for _ in range(m):
    a = heapq.heappop(A)
    a = -(-a//2)
    heapq.heappush(A, a)

print(-sum(A))
### BUGGY CODE ###

n,m=(int(i) for i in input().split(' '))
i=m//n
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1

### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
### BUGGY CODE ###

def calc(value):
    return value*(value-1)//2


n = int(input())
array = [int(x) for x in input().split()]

tmp_sum = 0
sum_array = []

for i in array:
    tmp_sum += i
    sum_array.append(tmp_sum)

sum_dict = {x:sum_array.count(x) for x in set(sum_array)}
if 0 in sum_dict.keys():
    sum_dict[0] += 1

res = 0
for key, value in sum_dict.items():
    if value >= 2:
        res += calc(value)

print(res)



### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=0
b=[]
sum=0
for i in range(n):
    sum+=a[i]
    b.append(sum)
b=sorted(b)
b.append(float("inf"))
k=0
for i in range(n):
    if b[i]==b[i+1]:
        k+=1
    else:
        if not k==0:
            ans+=k*(k+1)//2
        k=0
for i in range(n):
    if b[i]==0:
        ans+=1
print(ans)
### BUGGY CODE ###

N=int(input())
L=list(map(int,input().split()))
c=0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j]:
        c=c+1
print(c)

### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
L.sort()
c=0
for i in range(N-2):
  k=i+2
  for j in range(i+1,N-1):
    s=L[i]+L[j]
    c=c+k-j-1
    while L[k]<s and k<=N-2:
      k=k+1
      c=c+1
    if k==j+1 and s<=L[k]:
      k=k+1
    if k==N-1 and L[k]<s:
      c=c+1
print(c)
### BUGGY CODE ###


n = int(input())

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

_max = 10 ** (18)

ans = 1

for _a in a:
    ans *= _a

if ans > _max:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

from math import log10 as log10

n = int(input())

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

_max = 10 ** (18)

ans = a[0]
min_a = min(a)

for _a in a[1:]:
    if min_a == 0:
        break
    if ans > _max:
        break


    ans *= _a

if (ans > _max):
    print(-1)
elif min_a == 0:
    print(0)
else:
    print(ans)
### BUGGY CODE ###

def main():
    n, *a = map(int, open(0).read().split())
    b = set(a)
    c = list(b)
    ans = 0
    for i in c:
        ans += a.count(i) % 2 == 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import Counter
    n, *a = map(int, open(0).read().split())
    b = Counter(a)
    ans = sum(v%2==1 for v in b.values())
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2 == 0 for i in a):
    a = [i % 2 for i in  a]
    cnt += 1
print(cnt)


### FIXED CODE ###

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    mn = 1e5
    for i in range(1 << D):
        score = 0
        count = 0
        for j in range(D):
            if i >> j & 1 == 1:
                score += p[j] * 100 * (j+1) + c[j]
                count += p[j]
        while(score < G):
            flag = True
            for k in range(D):
                j = D - k - 1
                if i >> j & 1 == 0:
                    if score + 100*(j+1)*(p[j]-1) >= G:
                        count += math.ceil((G - score) / (100*(j+1)))
                        flag = False
                        break
                    else:
                        score += 100*(j+1)*(p[j]-1)
                        count += p[j] - 1
            if not flag:
                break
        mn = min(mn, count)
    print(mn)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]" 
    c = [int()] * (D)  # type: "List[int]" 
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):
    mn = 1e5
    for i in range(1 << D):
        score = 0
        count = 0
        for j in range(D):
            if i >> j & 1 == 1:
                score += p[j] * 100 * (j+1) + c[j]
                count += p[j]
        if score >= G:
            mn = min(mn, count)
            continue
        for k in range(D):
            j = D - k - 1
            if i >> j & 1 == 0:
                if score + 100*(j+1)*(p[j]-1) >= G:
                    count += math.ceil((G - score) / (100*(j+1)))
                    score += 100*(j+1)*count
                    break
                else:
                    score += 100*(j+1)*(p[j]-1)
                    count += p[j] - 1
        # print(score, count)
        if score >= G:
            mn = min(mn, count)
    print(mn)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]" 
    c = [int()] * (D)  # type: "List[int]" 
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(E[i] + SUM / p)
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)

### FIXED CODE ###

from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    E.append(E[i] + ((1+p) / 2))
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)
### BUGGY CODE ###

import collections
 
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)
### BUGGY CODE ###

from functools import reduce
from operator import add, mul
n = map(int, input().split())
a = list(map(int, input().split()))
ans = reduce(mul, a)
if ans > 10**18:
    print(-1)
else :
    print(ans)


### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
if 0 in a:
  print(0)
  exit()
ans = 1
for x in a:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
### BUGGY CODE ###

import bisect

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)

# ans=0
# for i in range(N):
#     part1=A[i]
#     part2_pos=bisect.bisect_right(B,part1)
#     for j in range(part2_pos,N):
#         part2=B[j]
#         part3_pos=bisect.bisect_right(C,part2)
#         # print(i,j,part3_spos,": ",A[i],B[j],C[part3_pos])
#         ans+=(N-part3_pos)
# print(ans)

AtoB_Pos=[]
BtoC_Pos=[]
ans=0
for i in range(N):
    B_Pos=bisect.bisect_right(B,A[i])
    AtoB_Pos.append(B_Pos)

for i in range(N):
    C_Pos=bisect.bisect_right(C,B[i])
    BtoC_Pos.append(C_Pos)
# print(AtoB_Pos)
# print(BtoC_Pos)
for i in range(N):
    for j in range(AtoB_Pos[i],N):
        # print(i,j,": ",A[i],B[j])
        # print(N-AtoB_Pos[i],N-BtoC_Pos[j])
        ans+=(N-BtoC_Pos[j])
print(ans)


### FIXED CODE ###

import bisect

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
# print(A)
# print(B)
# print(C)

ans=0
for j in range(N):
    a_num=bisect.bisect_left(A,B[j])
    c_num=bisect.bisect_right(C,B[j])
    # print(B[j],A[:a_num],C[c_num:])
    # print(a_num,c_num)
    ans+=a_num*(N-c_num)
print(ans)
### BUGGY CODE ###

import numpy as np


def func(x):
    if x == '.':
        return 2000
    else:
        return 0


H, W = map(int, input().split())
b = []
for _ in range(H):
    b.append(list(map(func, input())))
a = np.array(b)

for i in range(H - 1):
    a[1+i:, :] = np.minimum(a[1+i:, :], a[i:-1, :] + 1)
for i in range(H - 1):
    a[:-1-i, :] = np.minimum(a[:-1-i, :], a[1:H-i, :] + 1)
for j in range(W - 1):
    a[:, 1+j:] = np.minimum(a[:, 1+j:], a[:, j:-1] + 1)
for j in range(W - 1):
    a[:, :-1-j] = np.minimum(a[:, :-1-j], a[:, 1:W-j] + 1)

print(np.max(a))

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
a = [[0] * W for _ in range(H)]
q = deque([])
for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            a[i][j] = 1
            q.appendleft((i, j, 0))

while True:
    try:
        i, j, val = q.pop()
        if i > 0 and a[i - 1][j] == 0:
            q.appendleft((i - 1, j, val + 1))
            a[i - 1][j] = 1
        if i < H - 1 and a[i + 1][j] == 0:
            q.appendleft((i + 1, j, val + 1))
            a[i + 1][j] = 1
        if j > 0 and a[i][j - 1] == 0:
            q.appendleft((i, j - 1, val + 1))
            a[i][j - 1] = 1
        if j < W - 1 and a[i][j + 1] == 0:
            q.appendleft((i, j + 1, val + 1))
            a[i][j + 1] = 1
    except:
        print(val)
        break
### BUGGY CODE ###

import numpy as np
def dfs(start, G):
    stack = [start]
    visited = [0]*len(G)
    while stack:
        label = stack.pop(0)
        visited[label-1]= 1
        for i in G[label-1]:
          if not visited[i-1]:
            #visited[label-1]= 1
            stack.append(i)
    return visited    

N, M =map(int, input().split())
G  = [[] for _ in range(N)]
for i in range(M):
    a,b ,_= map(int, input().split())
    G[a-1].append(b)
    G[b-1].append(a)

count = 0
visit = np.array([0]*N)
for i in range(1,N+1):
  if visit[i-1]:
    continue
  if G[i-1]:  
    v_temp = dfs(i,G)
    visit = np.logical_or(visit, v_temp)
  else:
    visit[i-1] = 1
  count += 1


print(count)

### FIXED CODE ###

import numpy as np
import sys
sys.setrecursionlimit(10**5+1)
input = sys.stdin.readline

def dfs(v,G,visit):
    visit[v-1]=1    
    for next in G[v-1]:        
        if visit[next-1]:
            continue
        _ = dfs(next,G,visit) 
 
N, M =map(int, input().split())
G  = [[] for _ in range(N)]
for i in range(M):
    a,b ,_= map(int, input().split())
    G[a-1].append(b)
    G[b-1].append(a)
 
count = 0

visit = np.array([0]*N)
for i in range(1,N+1):
  if visit[i-1]:
    continue
  if G[i-1]:  
    _ = dfs(i,G,visit)
  else:
    visit[i-1] = 1
  count += 1

print(count)
### BUGGY CODE ###

from collections import deque
n=int(input())
a=deque([int(input()) for _ in range(n)])
for _ in range(n):
    ans=a
    x=ans.popleft()
    print(max(ans))
    ans.append(x)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = [int(input()) for _ in range(n)]
ans=max(a)
if a.count(ans)>1:
    for _ in range(n):
        print(ans)
else:
    for i in range(n):
        print(ans if a[i]!=ans else sorted(a)[-2])
### BUGGY CODE ###

e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[[]for _ in range(w)]
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    x-=y
    t=set()
    add=t.add
    if j:
      for v in dp[j-1]:
        add(v+x)
        add(v-x)
    if i:
      for v in dp[j]:
        add(v+x)
        add(v-x)
    if i+j:dp[j]=t
    else:dp[j]={x}
print(min(map(abs,dp[w-1])))

### FIXED CODE ###

e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[0]*w
c=13000
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    x=abs(x-y)
    if i==j==0:
      dp[j]=2**c<<x
      continue
    t=0
    if j:
      t|=dp[j-1]<<x
      t|=dp[j-1]>>x
    if i:
      t|=dp[j]<<x
      t|=dp[j]>>x
    dp[j]=t
*a,=map(int,(bin(dp[w-1])[2:]).zfill(26001))
print(min([i for i,f in e(a[13000:])if f]+[i for i,f in e(a[13000::-1])if f]))
### BUGGY CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx,sy,0)]
for i in range(n):
    data.append(tuple(map(int,input().split())))
data.append((gx,gy,0))
for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=((data[i][0]-data[j][0])**2+(data[i][1]-data[j][1])**2)**0.5-data[i][2]-data[j][2]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(len(g))]
dist[0]=0
que=[]
heappush(que,(0,0))
while len(que):
    c,v=heappop(que)
    if dist[v]<c:
        continue
    for i in range(len(g[v])):
        tmp=max(g[v][i][0],0)+c
        if tmp<dist[g[v][i][1]]:
            dist[g[v][i][1]]=tmp
            heappush(que,(tmp,g[v][i][1]))
print(dist[n+1])


### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

import math
import copy
N, K = map(int, (input().split()))

mod = 10**9 + 7

ans_array = []
divide_max = N

for i in range(2, math.floor(math.sqrt(N)) + 2):
    divide = math.floor(N / i)
    ans_array.append(divide_max - divide)
    divide_max = divide

for i in range(divide):
    ans_array.append(1)
ans_array = ans_array[::-1]
ans_count = copy.deepcopy(ans_array)
# print(ans_count)
ans_length = len(ans_array)
ans_acc = [0] * ans_length

for k in range(2, K + 1):
    ans_acc[0] = ans_array[0]
    for i in range(1, ans_length):
        ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod
    # print(ans_array)
    # print(ans_acc)
    for i in range(ans_length):
        ans_array[i] = ans_acc[ans_length-i-1] * ans_count[i] % mod

ans_acc[0] = ans_array[0]
for i in range(1, ans_length):
    ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod

print(ans_acc[-1])

### FIXED CODE ###

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

mod = 10**9 + 7

ans_array = []
divide_max = N
divide_count = []

for i in range(2, math.floor(math.sqrt(N)) + 2):
    divide = math.floor(N / i)
    ans_array.append(divide_max - divide)
    divide_count.append(divide_max - divide)
    divide_max = divide

for i in range(divide):
    ans_array.append(1)
ans_array = ans_array[::-1]
# print(ans_count)
ans_length = len(ans_array)
ans_acc = [0] * ans_length

for k in range(2, K + 1):
    ans_acc[0] = ans_array[0]
    for i in range(1, ans_length):
        ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod
    # print(ans_array)
    # print(ans_acc)
    for i in range(divide):
        ans_array[i] = ans_acc[ans_length - i - 1]
    for i in range(divide, ans_length):
        ans_array[i] = ans_acc[ans_length - i - 1] * divide_count[
            ans_length - 1 - i] % mod

ans_acc[0] = ans_array[0]
for i in range(1, ans_length):
    ans_acc[i] = (ans_acc[i - 1] + ans_array[i]) % mod

print(ans_acc[-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

def main():
    S = [int(s) for s in input()]
    N = len(S)
    K = 2019

    V = [0] * (N+1)
    count = [0] * 2020
    count[0] = 1
    ans = 0
    for i in reversed(range(N)):
        rev_i = (N-1)-i
        v = V[rev_i] + S[i] * (10**(rev_i+1))
        V[rev_i+1] = v
        u = v % K

        count[u] += 1
        cnt = count[u]
        ans -= (cnt-1) * (cnt-2) // 2
        ans += cnt * (cnt-1) // 2


    print(ans)

if __name__ == "__main__":
  main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

def main():
    S = [int(s) for s in input()]
    N = len(S)
    K = 2019

    V = [0] * (N+1)
    for i in reversed(range(N)):
        rev_i = (N-1)-i
        V[rev_i+1] = V[rev_i] + S[i] * (pow(10,rev_i+1,K))
        # print(V)

    dic = {} # value:count
    U = set()
    for v in V:
        u = v % K
        if u in U:
            dic[u] += 1
        else:
            dic[u] = 1
            U.add(u)

    ans = 0
    for u in U:
        u_count = dic[u]
        ans += u_count * (u_count-1) // 2

    # print(S)
    # print(V)
    # print(dic)
    print(ans)

if __name__ == "__main__":
  main()
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
  if i==0:
    cnt+=1
  else:
    if p[i]<=min(p[0:i]):
      cnt+=1
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(n):
  if i==0:
    cnt+=1
    f = p[i]
  else:
    if p[i]<=f:
      cnt+=1
      f = min(p[i], f)
print(cnt)
### BUGGY CODE ###

from operator import mul
from functools import reduce


def solve(string):
    n, m, k = map(int, string.split())
    base = n * m * ((n + 1) * (m + 1) * (n + m - 2) - n**2 - m**2 + 2) // 6 % (10**9 + 7)
    return str(base * reduce(mul, range(n * m - k + 1, n * m - 1)) //
               reduce(mul, range(1, k - 1)) % (10**9 + 7) if k > 2 else base)


if __name__ == '__main__':
    print(solve(input()))


### FIXED CODE ###

mod = 10**9 + 7


def comb(n, k):
    x, y = 1, 1
    k = min(k, n - k)
    for i in range(k):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod


def solve(string):
    n, m, k = map(int, string.split())
    base = n * m * ((n + 1) * (m + 1) * (n + m - 2) - n**2 - m**2 + 2) // 6 % mod
    return str(base * comb(n * m - 2, k - 2) % mod)


if __name__ == '__main__':
    print(solve(input()))
### BUGGY CODE ###

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


k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        tgcd = gcd(i, j)
        for k in range(1, k + 1):
            l = gcd(tgcd, k)
            ans += l

print(ans)


### FIXED CODE ###

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


k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        tgcd = gcd(i, j)
        for k in range(1, k + 1):
            l = gcd(tgcd, k)
            ans += l

print(ans)
### BUGGY CODE ###

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

limit = 10 ** 18
res = A[0]

if 0 in A:
    start_idx = max(
        [
            idx
            for idx, a in enumerate(A)
            if a == 0
        ]
    ) + 1

    if start_idx == N:
        print(0)
        exit(0)
else:
    start_idx = 1

for i in range(start_idx, N):
    res *= A[i]

if res > limit:
    print(-1)
else:
    print(res)

### FIXED CODE ###

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

limit = 10 ** 18
res = A[0]

if 0 in A:
    print(0)
    exit(0)
else:
    for i in range(1, N):
        res *= A[i]
        if res > limit:
            print(-1)
            exit(0)

print(res)
### BUGGY CODE ###

import math
A, B, N = map(int, input().split())
ans = 0

if N > 10000:
    for x in range(N+1, int(N / 100), -1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
else:
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)


### FIXED CODE ###

import math

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

if N < B:
    x = N
else:
    x = B - 1

def check(x):
    return math.floor((A * x) / B)
            
print(check(x))
### BUGGY CODE ###

n = int(input())
a = [0] * n

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

for i in range(n):
    new = list(a)
    del new[i]
    print(max(new))


### FIXED CODE ###

n = int(input())
a = [0] * n

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

#maxV = max(a)
sortedA = sorted(a)
maxV = sortedA[n-1]
maxV2 = sortedA[n-2]

for i in range(n):
    if a[i] == maxV:
        # new = list(a)
        # del new[i]
        # print(max(new))
        print(maxV2)
    else:
        print(maxV)