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

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,k = map(int, input().split())
x1,y1,x2,y2 = map(lambda x: int(x)-1, input().split())
s = [None]*h
for i in range(h):
    s[i] = input()
    
from heapq import heappop as hpp, heappush as hp
q = []
hp(q, (0,x1,y1,(0,0),0))

dx = [0,1,0,-1]
dy = [1,0,-1,0]
dist = [[None]*w for _ in range(h)]
dist[x1][y1] = 0
done = [[0]*w for _ in range(h)]
done[0][0] = 15

while q:
    d, x, y, t, td = hpp(q)
    for i,(xx, yy) in enumerate(zip(dx,dy)):
        if (-xx,-yy)==t:
            continue
        nx, ny = xx+x, yy+y
        if nx<0 or nx>=h or ny<0 or ny>=w:
            continue
        if s[nx][ny]=="@":
            continue
        if (xx,yy)==t and td<k:
            nd = d
            ntd = td+1
        else:
            nd = d+1
            ntd = 1
        if dist[nx][ny] is None or nd<dist[nx][ny]:
            hp(q, (nd,nx,ny,(xx,yy),ntd))
            dist[nx][ny] = nd
            done[nx][ny] = 1<<(i+1)
        elif (nd==dist[nx][ny]and ((done[nx][ny]&1<<(i+1))==0)):
            hp(q, (nd,nx,ny,(xx,yy),ntd))
            done[nx][ny] |= 1<<(i+1)
            
if dist[x2][y2] is None:
    print(-1)
else:
    print(dist[x2][y2])

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

h,w,k = map(int, input().split())
x1,y1,x2,y2 = map(lambda x: int(x)-1, input().split())
s = [None]*h
for i in range(h):
    s[i] = input()
    
from queue import deque
q0 = deque([(0,x1,y1,(0,0),0)])
q1 = deque()

dx = [0,1,0,-1]
dy = [1,0,-1,0]
# dist = [[None]*w for _ in range(h)]
dist = [None]*(w*h)
dist[x1*w+y1] = 0
# done = [[0]*w for _ in range(h)]
done = [0]*(w*h)
done[x1*w+y1] = 15

while q0 or q1:
    if not q0:
        q0 = q1
        q1 = deque()
    d, x, y, t, td = q0.popleft()
    for i,(xx, yy) in enumerate(zip(dx,dy)):
        if (-xx,-yy)==t:
            continue
        nx, ny = xx+x, yy+y
        if nx<0 or nx>=h or ny<0 or ny>=w or s[nx][ny]=="@":
            continue
        if (xx,yy)==t and td<k:
            nd = d
            ntd = td+1
            q = q0
        else:
            nd = d+1
            ntd = 1
            q = q1
        if dist[nx*w+ny] is None or nd<dist[nx*w+ny]:
            q.append((nd,nx,ny,(xx,yy),ntd))
            dist[nx*w+ny] = nd
            done[nx*w+ny] = 1<<(i)
        elif nd==dist[nx*w+ny]and ((done[nx*w+ny]&1<<(i))==0):
            q.append((nd,nx,ny,(xx,yy),ntd))
            done[nx*w+ny] |= 1<<(i)
            
if dist[x2*w+y2] is None:
    print(-1)
else:
    print(dist[x2*w+y2])
### BUGGY CODE ###

n = int(input())
a = [0] + [int(input()) for _ in range(n)]

pos = 1
cnt = 0
while True:
    cnt += 1
    if a[pos] == 1:
        print(-1)
        break
    elif a[pos] == 2:
        print(cnt)
        break
    pos = a[pos]


### FIXED CODE ###

n = int(input())
a = [0] + [int(input()) for _ in range(n)]

pos = 1
for i in range(n):
    pos = a[pos]
    if pos == 2:
        print(i+1)
        break
else:
    print(-1)
### BUGGY CODE ###

n, m = (int(x) for x in input().split())
l = []
d = {}
ds = []
for _ in range(m):
    l.append([int(x) for x in input().split()])
for li in l:
    k = str(li[0])
    if k not in ds:
        d[k] = [li[1]]
        ds.append(k)
    else:
        d[k].append(li[1])
for key in ds:
    d[key].sort()
for li in l:
    print(str(li[0]).zfill(6) + str(d[str(li[0])].index(li[1]) + 1).zfill(6))

### FIXED CODE ###

import bisect as bis
n, m = map(int, input().split())
idx = lambda x: x-1
p, y = [], []
for _ in range(m):
    p_, y_ = map(int, input().split())
    p.append(p_)
    y.append(y_)
val = [[] for _ in range(n)]
for i, j in zip(p, y):
    val[idx(i)].append(j)
for i in range(n):
    val[i].sort()
for i in range(m):
    v = p[i]
    id = bis.bisect_right(val[idx(v)], y[i])
    print(str(v).zfill(6) + str(id).zfill(6))
### BUGGY CODE ###

R=range
M=998244353
n,m,k=map(int,input().split())
f=1
for i in R(n):f*=i+1
r=[pow(f,-1,M)]
for i in R(n):r+=r[i]*(n-i)%M,
print(sum(f//n*m*r[i-n]*r[~i]*pow(m-1,~i+n,M)for i in R(k+1))%M)

### FIXED CODE ###

M=998244353
class Factorial:
    def __init__(self,n):
        self.f=f=[0]*(n+1)
        f[0]=b=1
        for i in range(1,n+1):f[i]=b=b*i%M
        self.inv=inv=[0]*(n+1)
        inv[n]=b=pow(self.f[n],-1,M)
        for i in range(n,0,-1):inv[i-1]=b=b*i%M
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.inv[i]
    def comb(self,n,k):
        if n>=k:return self.f[n]*self.inv[n-k]*self.inv[k]%M
        else:return 0
comb=Factorial(10**5*5).comb
n,m,k=map(int,input().split())
print(sum(m*comb(n-1,i)*pow(m-1,~i+n,M)for i in range(k+1))%M)
### BUGGY CODE ###

N = int(input())
S = input()
result = min([ S[:i].count("W") + S[i+1:].count("E") for i in range(N) ])
print(result)

### FIXED CODE ###

N = int(input())
S = input()
left_w_count = 0
right_e_count = S[1:].count("E")
result = right_e_count
for i in range(1, N):
    if S[i - 1] == "W":
        left_w_count += 1
    if S[i] == "E":
        right_e_count -= 1
    r = left_w_count + right_e_count
    if r < result:
        result = r
print(result)
### BUGGY CODE ###

p = int(input())
a_list = list(map(int, input().split()))
r_list = [0] * p

fact = [0] * p
fact[0] = 1
for i in range(1, p):
    fact[i] = fact[i - 1] * i % p

fact_inv = [pow(fact[i], p-2, p) for i in range(p)]

ncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]

for j in range(p):
    if a_list[j] == 0:
        continue
    for i in range(p):
        s = (ncr[i] * pow(-j, p-1-i, p)) % p
        r_list[i] -= s
    r_list[0] += 1


print(" ".join([str(r % p) for r in r_list]))


### FIXED CODE ###

p = int(input())
a_list = list(map(int, input().split()))
r_list = [0] * p

fact = [0] * p
fact[0] = 1
for i in range(1, p):
    fact[i] = fact[i - 1] * i % p

fact_inv = [0] * p
fact_inv[-1] = pow(fact[-1], p-2, p)
for i in range(p-2, -1 ,-1):
    fact_inv[i] = (fact_inv[i+1] * (i+1)) % p

ncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]

for j in range(p):
    if a_list[j] == 0:
        continue
    k = 1
    for i in range(p-1, -1, -1):
        r_list[i] -= ncr[i] * k
        r_list[i] %= p
        k *= -j
        k %= p
    r_list[0] += 1

r_list[0] %= p
print(*r_list)
### BUGGY CODE ###

n, d, a = map(int, input().split())
lst = []
for i in range(n):
    xi, hi = map(int, input().split())
    if hi % a == 0:
        hi = hi // a
    else:
        hi = hi // a + 1
    lst.append([xi, hi])
lst.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(lst[i][0])
    h.append(lst[i][1])

x.append(10**11)
h.append(0)

kougeki_start = 0
kougeki_end = 0
cnt = 0
i = 0
while i <= n:
    left = i # 可能
    right = n # 不可能
    while left+1 < right:
        mid = (left + right) // 2
        if x[mid] - x[i] <= 2*d:
            left = mid
        else:
            right = mid
    cnt += h[i]
    hiku = h[i]
    bit = 0
    next_i = i
    for j in range(i, left+1):
        h[j] -= hiku
        if bit == 0 and h[j] > 0:
            next_i = j
            bit = 1
    if next_i == i:
        i = left + 1
    else:
        i = next_i

print(cnt)

### FIXED CODE ###

n, d, a = map(int, input().split())
lst = []
for i in range(n):
    xi, hi = map(int, input().split())
    if hi % a == 0:
        hi = hi // a
    else:
        hi = hi // a + 1
    lst.append([xi, hi])
lst.sort(key=lambda x: x[0])
x, h = [], []
for i in range(n):
    x.append(lst[i][0])
    h.append(lst[i][1])

x.append(10**11)
h.append(0)

# 攻撃に巻き込めるインデックスを求める
left = 0 # 可能
right = n # 不可能
while left+1 < right:
    mid = (left + right) // 2
    if x[mid] - x[0] <= 2*d:
        left = mid
    else:
        right = mid
makikomi = [left]
right = left
for i in range(1, n):
    while x[right] - x[i] <= 2*d:
        right += 1
    right -= 1
    makikomi.append(right)

cnt = [0 for i in range(n)]
left = 0
already = 0
for i in range(n):
    while x[makikomi[left]] < x[i]:
        already -= cnt[left]
        left += 1
    cnt[i] = max(h[i] - already, 0)
    already += cnt[i]

print(sum(cnt))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
i = 0
p = 1
while i < n:
    p *= a[i]
    i += 1

if p <= 10**18:
    print(p)
else:
    print("-1")


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
i = 0
p = 1

if 0 in a:
    print("0")
else:
    while i < n:
        p *= a[i]
        if p > 10**18:
            break
        i += 1
    if p <= 10**18:
        print(p)
    else:
        print("-1")
### BUGGY CODE ###

ans = []
i = 0
for i in range(int(input())):
    now = input()
    if now in ans:
        ans.remove(now)
    else:
        ans.append(now)
print(len(ans))


### FIXED CODE ###

time = int(input())
ans = []
n = 0
for i in range(time):
    ans.append(input())
ans.sort(key=int)
while n+1 < len(ans):
    if ans[n] == ans[int(n + 1)]:
        ans.pop(n)
        ans.pop(n)
    else:
        n += 1
print(len(ans))
### BUGGY CODE ###

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

def DIF(N):
  global K
  return abs(N-K)

if N < DIF(N):
  print(N)
else:
  if N % K == 0:
    print(0)
  else:
    while N >= DIF(N):
      N = DIF(N)
    print(N)

### FIXED CODE ###

N, K = map(int,input().split())
print(min(N%K,K-N%K))


'''
def DIF(N):
  global K
  return abs(N-K)

if N < DIF(N):
  print(N)
else:
  if N % K == 0:
    print(0)
  else:
    while N >= DIF(N):
      N = DIF(N)
    print(N)
'''
### BUGGY CODE ###

K = int(input())
count = 1
n = 7
if K % 2 == 0 or K % 5 == 0:
    count = -1
    print(count)
else:
    while True:
        if n % K == 0:
            break
        n += 7*10**count
        count += 1
    print(count)

### FIXED CODE ###

K = int(input())
count = 1
n = 0
if K % 2 == 0 or K % 5 == 0:
    count = -1
    print(count)
else:
    while True:
        n = (n*10+7)%K
        if n == 0:
            break
        count += 1
    print(count)
### BUGGY CODE ###

import sys


def main():
    _ = int(input())

    imps = sys.stdin.readlines()

    db = []
    for imp in imps:
        command = imp.split(' ')
        if command[0] == 'insert':
            db.append(command[1])
        else:
            if command[1] in db:
                print('yes')
            else:
                print('no')


main()

### FIXED CODE ###

import sys


def main():
    _ = int(input())

    imps = sys.stdin.readlines()

    db = {}
    for imp in imps:
        c, k = imp.split(' ')
        if c == 'insert':
            db[k] = 0
        elif k in db:
            print('yes')
        else:
            print('no')


main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
#print(a)
import functools
import operator

result = functools.reduce(operator.mul, a)

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
result = 1
for i in range(len(a)):
  result = result*a[i]
  if result == 0:
    break
  elif result > 1000000000000000000:
    break

if result <= 1000000000000000000:
  print(result)
else:
  print(-1)
### BUGGY CODE ###

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

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

ls_mu = []
for i in range(n):
    mu = (p[i]+1)/2
    ls_mu.append(mu)

# print(ls_mu)

M = 0
for i in range(n-k+1):
    m = sum(ls_mu[i:i+k])
    M = max(m,M)

print(M)

### FIXED CODE ###

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

ls_mu = []
for i in range(n):
    mu = (p[i]+1)/2
    ls_mu.append(mu)
# print(ls_mu)
m = 0
M = 0
for i in range(n-k+1):
    if i==0:
        for j in range(k):
            m += ls_mu[j]
        M += m
    else:
        l = ls_mu[i-1]
        r = ls_mu[i+k-1]
        m = m - l + r
        M = max(m,M)

print(M)
### BUGGY CODE ###

import numpy as np


n = int(input())
count = np.zeros(n+1, dtype=np.int64)
for num in range(1, n+1):
    count[num::num] += 1

print((np.arange(n+1) * count).sum())

### FIXED CODE ###

n = int(input())

ans = 0
for num in range(1, n+1):
    count = n // num
    last = count * num
    total = count * (num + last) // 2
    ans += total

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = [a-1 for a in LIST()]

MAX = 64
nxt = list2d(MAX, N, -1)
for i, a in enumerate(A):
    nxt[0][i] = a

for k in range(1, MAX):
    for i in range(N):
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]

ans = 0
for k in range(MAX-1, -1, -1):
    if K >> k & 1:
        ans = nxt[k][ans]
print(ans+1)


### FIXED CODE ###

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = [a-1 for a in LIST()]

MAX = 64
nxt = list2d(MAX, N, -1)
for i, a in enumerate(A):
    nxt[0][i] = a

for k in range(1, MAX):
    for i in range(N):
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]

ans = 0
for k in range(MAX-1, -1, -1):
    if K >> k & 1:
        ans = nxt[k][ans]
print(ans+1)
### BUGGY CODE ###

import numpy as np
N,C = map(int,input().split())
D = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]

strange = np.array([[0]*C for _ in range(3)])
for i in range(N):
    for j in range(N):
        strange[(i+j)%3] += D[c[i][j]-1]

ans = 1000*N**2
for c1 in range(C):
    for c2 in range(C):
        for c3 in range(C):
            if c1 != c2 and c2 != c3 and c3 != c1:
                ans = min(ans,strange[0][c1]+strange[1][c2]+strange[2][c3])
print(ans)

### FIXED CODE ###

import numpy as np
D = []
c = []
d0 = {}
d1 = {}
d2 = {}

N,C = map(int,input().split())
a = np.zeros((3,C))
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

D = np.array(D)
c = np.array(c)

for i in range(N):
    for j in range(N):
        a[(i+j)%3] += D[c[i][j]-1]

l = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                l.append(a[0][C1]+a[1][C2]+a[2][C3])

print(int(min(l)))
### BUGGY CODE ###

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

def cmb(n, k, mod, fac, ifac):
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def tables(mod, n):
    fac = [1, 1] 
    ifac = [1, 1] 
    inverse = [0, 1] 

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

mo = 10 ** 9 +7
fac, ifac = tables(mo, N)
ans = (pow(2, N) - 1 - cmb(N, A, mo, fac, ifac) - cmb(N, B, mo, fac, ifac)) % mo
print(ans)

### FIXED CODE ###

N, A, B = map(int, input().split())
mo = 1000000007
A_val = 1
for i in range(A):
    A_val = ((A_val * (N - i) * pow(i+1, mo-2, mo))) % mo
B_val = 1
for i in range(B):
    B_val = ((B_val * (N - i) * pow(i+1, mo-2, mo))) % mo
    
ans = (pow(2, N, mo) - 1 - A_val - B_val) % mo
print(ans)
### BUGGY CODE ###

# # 整数の入力
# a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# # 文字列の入力
# s = input()
# a = []
# a = list(map(int, input().split()))
# import math

# 解説参照済み

n, k = map(int, input().split())
a = []
a = list(map(int, input().split()))
f = []
f = list(map(int, input().split()))

a.sort()
f.sort(reverse=True)
ans = 0

maxaf = 0
for i in range(n):
    maxaf = max(maxaf, a[i] * f[i])

left = 0
right = maxaf

while left < right:
    # print(left, right)
    mid = (left + right) // 2
    ktemp = k
    renewleft = False
    for i in range(n):
        if a[i] * f[i] > mid:
            if (a[i] * f[i] - mid + f[i] - 1) // f[i] > ktemp:
                left = mid + 1
                renewleft = True
                break
            else:
                ktemp -= (a[i] * f[i] - mid + f[i] - 1) // f[i]
    if not renewleft:
        right = mid

print(left)


### FIXED CODE ###

# # 整数の入力
# a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# # 文字列の入力
# s = input()
# a = []
# a = list(map(int, input().split()))
# import math
 
# 解説参照済み
 
n, k = map(int, input().split())
a = []
a = list(map(int, input().split()))
f = []
f = list(map(int, input().split()))
 
a.sort()
f.sort(reverse=True)
ans = 0
 
maxaf = 0
for i in range(n):
    maxaf = max(maxaf, a[i] * f[i])
 
left = 0
right = maxaf
 
while left < right:
    # print(left, right)
    mid = (left + right) // 2
    ktemp = k
    renewleft = False
    for i in range(n):
        if a[i] * f[i] > mid:
            if (a[i] * f[i] - mid + f[i] - 1) // f[i] > ktemp:
                left = mid + 1
                renewleft = True
                break
            else:
                ktemp -= (a[i] * f[i] - mid + f[i] - 1) // f[i]
    if not renewleft:
        right = mid
 
print(left)
### BUGGY CODE ###

h,w=map(int,input().split())
s=[[]*w for i in range(h)]
for i in range(h):
    s[i]=list(input())

#h,w=4,6
#s=[['#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '.']]    

ww=[[0]*w for i in range(h)]
for i in range(h):
    jsum=0
    jst=0
    jed=0
    for j in range(w):
        if s[i][j]==".":
            jsum+=1
            jst=min(j,jst)
            jed=max(j,jed)
        else:
#            print(jsum,jst,jed)
            for jj in range(jst,jed+1):
                ww[i][jj]=jsum
            jsum=0
            jst=j+1
            jed=j+1
        if jst<w:
            for jj in range(jst,jed+1):
                ww[i][jj]=jsum
                
hh=[[0]*w for i in range(h)]
for j in range(w):
    isum=0
    ist=0
    ied=0
    for i in range(h):
        if s[i][j]==".":
            isum+=1
            ist=min(i,ist)
            ied=max(i,ied)
        else:
#            print(isum,ist,ied)
            for ii in range(ist,ied+1):
                hh[ii][j]=isum
            isum=0
            ist=i+1
            ied=i+1
        if ist<h:
            for ii in range(ist,ied+1):
                hh[ii][j]=isum
            
ijmax=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ijmax=max(ijmax,ww[i][j]+hh[i][j]-1)

print(ijmax)
                


### FIXED CODE ###

import sys
input = sys.stdin.readline

h,w=map(int,input().split())
s=[[] for i in range(h)]
for i in range(h):
    si=input()
    s[i]=si
"""
h,w=4,6
s=[['#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '.']]    
"""
ww=[[0]*w for i in range(h)]
#www=[[0]*w for i in range(h)]
www=[0]*w
for i in range(h):
    jsum=0
    jcnt=1
    jj=[0]*(w+1)
    for j in range(w):
        if s[i][j]==".":
#            www[i][j]=jcnt
            www[j]=jcnt
            if j<w-1 and s[i][j+1]=="#":
                jcnt+=1
            jsum+=1
        else:
#            print(jsum,jst,jed)
            if jsum!=0:
                jj[jcnt-1]=jsum
            jsum=0
    jcnt+=1
    jj[jcnt-1]=jsum
            
    for j in range(w):
        if s[i][j]==".":
#            ww[i][j]=jj[www[i][j]]
            ww[i][j]=jj[www[j]]
#    print(jj)
                
hh=[[0]*w for i in range(h)]
hhh=[0]*h
for j in range(w):
    isum=0
    icnt=1
    ii=[0]*(h+1)
    for i in range(h):
        if s[i][j]==".":
#            www[i][j]=jcnt
            hhh[i]=icnt
            if i<h-1 and s[i+1][j]=="#":
                icnt+=1
            isum+=1
        else:
#            print(jsum,jst,jed)
            if isum!=0:
                ii[icnt-1]=isum
            isum=0
    icnt+=1
    ii[icnt-1]=isum
            
    for i in range(h):
        if s[i][j]==".":
#            ww[i][j]=jj[www[i][j]]
            hh[i][j]=ii[hhh[i]]
#    print(jj)
            
ijmax=0
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            ijmax=max(ijmax,ww[i][j]+hh[i][j]-1)

print(ijmax)
### BUGGY CODE ###

N = int(input())
word = []
ans = 0
temp = 0
tmplist = []
m = 0
for i in range (0,N):
    temp = 0
    linp =  sorted(input())
    inp = ''.join(linp)
    for j in range (0,m):
        if word[j][0] == inp: 
            ans = ans + word[j][1]
            word [j][1] = word[j][1] + 1
            temp = 1
            break
    if temp == 0:
        tmplist = [inp, 1]
        word.append(tmplist) 
        m = m + 1
print(ans)

 


### FIXED CODE ###

n = int(input())
d = {}
ans = 0


for i in range (0,n):
    temp = 0
    linp =  sorted(input())
    inp = ''.join(linp)
    if inp in d:
        ans = ans + d[inp]
        d[inp] = d[inp] + 1
    else:
        d[inp] = 1
print(ans)
### BUGGY CODE ###

import bisect
def main():
    N = int(input())
    L = sorted(list(map(int,input().split())))
    Lind = []
    count = 0
    for i in reversed(range(2,N)):
        for j in reversed(range(1,i)):
            if L[i] < 2*L[j]:
                Lind.append([i,j])
    for l in Lind:
        cind = bisect.bisect_right(L,L[l[0]]-L[l[1]])
        for k in range(cind,l[1]):
            if L[l[0]]<L[l[1]]+L[k]:
                count += 1
    print(count)
main()

### FIXED CODE ###

import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()
### BUGGY CODE ###

n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
path=[]
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
    path.append(a-1)
    path.append(b-1)
path=set(path)
from itertools import permutations
def Long(args):
    ans=0
    c=0
    tmp=[]
    for i in args:
        tmp.append(i)
        if i in r:
            c+=1
        if c==len(r):
            break
    args=tmp
    for i in range(len(args)-1):
        if ans==float("inf"):
            return ans
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(path)))

### FIXED CODE ###

n,m,R=[int(x) for x in input().split()]
r=[int(x) -1 for x in input().split()]
d=[[float("inf") for _ in [0]*n] for _ in [0]*n]
for i in range(n):
    d[i][i]=0
for i in [0]*m:
    a,b,c=[int(x) for x in input().split()]
    d[a-1][b-1]=d[b-1][a-1]=c
from itertools import product,permutations
for k,i,j in product(range(n),range(n),range(n)):
    if d[i][j] >d[i][k]+d[k][j]:
        d[i][j]=d[i][k]+d[k][j]
def Long(args):
    ans=0
    for i in range(len(args)-1):
        ans+=d[args[i+1]][args[i]]
    return ans
print(min(Long(i) for i in permutations(r)))
### BUGGY CODE ###

n = int(input())
S = []
ans = []
for i in range(n):
    S.append(input())
for j in S:
    if j not in ans:
        ans.append(j)
print(len(ans))

### FIXED CODE ###

n = int(input())
S = []
for i in range(n):
    S.append(input())
print(len(list(set(S))))