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

import sys
from collections import deque
input = sys.stdin.readline
h, w = [int(x) for x in input().strip().split()]
g = [[x for x in list(input().strip())] for _ in range(h)]

ans = -1
q = deque([])
for i in range(h):
    for j in range(w):
        if g[i][j] == '#':
            q.append((i, j))
vec = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while q:
    q_ = q
    q = deque([])
    ans += 1
    while q_:
        i, j = q_.pop()
        for x, y in vec:
            ti, tj = i+x, j+y
            if 0 <= ti < h and 0 <= tj < w:
                if g[ti][tj] == '.':
                    g[ti][tj] = '#'
                    q.append((ti, tj))
print(ans)

### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
h, w = [int(x) for x in input().strip().split()]
g = [[x for x in list(input().strip())] for _ in range(h)]

ans = -1
q = []
for i in range(h):
    for j in range(w):
        if g[i][j] == '#':
            q.append((i, j))
vec = [(0, 1), (1, 0), (0, -1), (-1, 0)]
while q:
    q_ = deque(q)
    q = deque([])
    ans += 1
    while q_:
        i, j = q_.pop()
        for x, y in vec:
            ti, tj = i+x, j+y
            if 0 <= ti < h and 0 <= tj < w:
                if g[ti][tj] == '.':
                    g[ti][tj] = '#'
                    q.append((ti, tj))
print(ans)
### BUGGY CODE ###

import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N+1)
lis[-1] = -1
for n in range(N):
    i = bisect.bisect(lis[::-1], A[n])    
    lis[N-i] = A[n]
print (bisect.bisect_left(lis[::-1], INF) - 1)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))
A = A[::-1]
INF = int(1e+9 + 10)
lis = [INF]* (N+1)
lis[0] = -1
for n in range(N):
    i = bisect.bisect(lis, A[n])    
    lis[i] = A[n]
print (bisect.bisect_left(lis, INF) - 1)
### BUGGY CODE ###

import sys

import numpy as np
from scipy.sparse import lil_matrix
from scipy.sparse.csgraph import dijkstra

sys.setrecursionlimit(10000)
INF = float('inf')

N, M, S, T = list(map(int, input().split()))
graph_yen = lil_matrix((N + 1, N + 1))
graph_snuke = lil_matrix((N + 1, N + 1))
for _ in range(M):
    u, v, a, b = list(map(int, input().split()))
    graph_yen[u, v] = a
    graph_snuke[u, v] = b

# yen_mins[i]: S から i まで行くときの最小金額
yen_mins = dijkstra(graph_yen.tocsr(), indices=S, directed=False, unweighted=False)
# snuke_mins[i]: T から i まで行くときの最小金額
snuke_mins = dijkstra(graph_snuke.tocsr(), indices=T, directed=False, unweighted=False)

# total_mins[i]: i で両替して S から T まで行くときの最小金額
total_mins = 10 ** 15 - (yen_mins + snuke_mins)[1:]

# 後ろから累積最大値とる
for a in np.maximum.accumulate(total_mins[::-1])[::-1]:
    print(int(a))


### FIXED CODE ###

import heapq
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')


def dijkstra(graph, start):
    """
    :param list of (list of (int, int)) graph:
    :param int start:
    :return:
    """
    dist = [INF for _ in range(len(graph))]
    dist[start] = 0
    heap = []
    heapq.heappush(heap, (0, start))

    while len(heap) > 0:
        w, v = heapq.heappop(heap)
        if w > dist[v]:
            continue
        for u, dw in graph[v]:
            if w + dw < dist[u]:
                dist[u] = w + dw
                heapq.heappush(heap, (w + dw, u))
    return dist


N, M, S, T = list(map(int, input().split()))
graph_yen = [[] for _ in range(N + 1)]
graph_snuuk = [[] for _ in range(N + 1)]
for _ in range(M):
    u, v, a, b = list(map(int, input().split()))
    graph_yen[u].append((v, a))
    graph_yen[v].append((u, a))
    graph_snuuk[u].append((v, b))
    graph_snuuk[v].append((u, b))

# yen_mins[i]: S から i まで行くときの最小金額
yen_mins = np.array(dijkstra(graph_yen, start=S))
# snuke_mins[i]: T から i まで行くときの最小金額
snuke_mins = np.array(dijkstra(graph_snuuk, start=T))

# totals[i]: i で両替して S から T まで行くときの最大金額
totals = 10 ** 15 - (yen_mins + snuke_mins)[1:]
# 後ろから累積最大値とる
for a in np.maximum.accumulate(totals[::-1])[::-1]:
    print(int(a))
### BUGGY CODE ###

from fractions import gcd
n = int(input())
gcdf = 0
for i in range (1, n+1):
  for j in range (1, n+1):
    for k in range (1, n+1):
      gcdf  = gcdf + gcd(i,gcd(j,k))
      
print(gcdf)

### FIXED CODE ###

from math import gcd
N = int(input())
ans = 0
for i in range(1,N+1):
  for j in range(1,N+1):
    for k in range(1,N+1):
      ans += gcd(gcd(i,j),k)
print(ans)
### BUGGY CODE ###

import sys
X, Y = map(int, input().split())
if X == Y:
    print(-1)
    sys.exit()

for i in range(2, 10 ** 18 + 1):
    ans = i * X
    if ans % Y != 0:
        print(ans)
        sys.exit()

### FIXED CODE ###

import sys
X, Y = map(int, input().split())
if X % Y == 0:
    print(-1)
    sys.exit()

for i in range(2, 10 ** 18 + 1):
    ans = i * X
    if ans % Y != 0:
        print(ans)
        sys.exit()
### BUGGY CODE ###

_, M = map(int, input().split())
A = list(map(int, input().split()))
opes = [tuple(map(int, input().split())) for _ in range(M)]
opes.sort(reverse=True)

for B, C in opes:
    if min(A) > C:
        continue
    A.sort()
    for i in range(B):
        if A[i] < C:
            A[i] = C
        else:
            break

print(sum(A))


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
opes = [tuple(map(int, input().split())) for _ in range(M)]
opes.sort(key=lambda x:-x[1])

D = []
lenD = 0
for B, C in opes:
    D += [C]*B
    lenD += B
    if lenD >= N:
        break

A.sort()
for i, d in enumerate(D[:N]):
    if A[i] >= d:
        break
    A[i] = d

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

n=int(input())
s=input()

r=s.count('R')
g=s.count('G')
b=s.count('B')

ng=0

all=r*g*b

#NGパターン数の洗い出し
for i in range(0,n-2):
  for j in range(i,n-1):
    for k in range(j,n):
#      print(i,j,k)
      if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
        if j-i==k-j:
          ng+=1
print(all-ng)

### FIXED CODE ###

n=int(input())
s=input()

#r=s.count('R')
#g=s.count('G')
#b=s.count('B')

r,g,b=0,0,0

for i in range(0,n):
  if s[i]=='R':
    r+=1
  elif s[i]=='G':
    g+=1
  else:
    b+=1

ng=0

all=r*g*b

#NGパターン数の洗い出し
for i in range(0,n-2):
  for j in range(i,n-1):
    if s[i]==s[j]:
      continue
    else:
      if j*2-i<=n-1:
#        print(i,j,j*2-i)
        if s[j]!=s[j*2-i] and s[j*2-i]!=s[i]:
          ng+=1
print(all-ng)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(map(int, input().split()), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB = sorted(AB, reverse=True)
if K < len(AB):
    AB = AB[:K]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(ab + c)

ABC = sorted(ABC, reverse=True)
ABC = ABC[:K]

print("\n".join(map(str, ABC)))


### FIXED CODE ###

# -*- coding: utf-8 -*-

X, Y, Z, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
B = sorted(map(int, input().split()), reverse=True)
C = sorted(map(int, input().split()), reverse=True)

ABC = []

for x in range(X):
    for y in range(Y):
        if (x + 1) * (y + 1) > K:
            break
        for z in range(Z):
            if (x + 1) * (y + 1) * (z + 1) > K:
                break
            ABC.append(A[x] + B[y] + C[z])

ABC = sorted(ABC, reverse=True)

ABC = ABC[:K]
ABC = [str(abc) for abc in ABC]

print("\n".join(ABC))
### BUGGY CODE ###

from fractions import gcd
A,B=map(int,input().split())
C=gcd(A,B)

if C==1:
   print(1)
else:
   count=1

   n=2
   while C!=1:
      flag=True
      flag2=False
      while flag:
         if C%n==0:
            flag2=True
            C//=n
         else:
            if flag2:
               flag=False
               flag2=False
               n=n+1 if n==2 else n+2
               count+=1
            else:
               flag=False
               n=n+1 if n==2 else n+2

   print(count)

### FIXED CODE ###

from fractions import gcd
A,B=map(int,input().split())
C=gcd(A,B)

if C==1:
   print(1)
else:
   count=1
   C_copy=C
   n=2
   while n**2<=C:
      flag=False
      while C_copy%n==0:
         C_copy//=n
         flag=True
      if flag:
         count+=1
         n=n+1 if n==2 else n+2
      else:
         n=n+1 if n==2 else n+2
   
   if C_copy!=1:
      count+=1

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

N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    left = S[l - 1]
    num = 0
    for i in range(l, r):
        right = S[i]
        if left == "A" and right == "C":
            num += 1
    print(num)


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
lr = [tuple(map(int, input().split())) for _ in range(Q)]
acindex_list = []
ac = 0
old = ""
for c in S:
    if old == "A" and c == "C":
        ac += 1
    old = c
    acindex_list.append(ac)
for l, r in lr:
    print(acindex_list[r - 1] - acindex_list[l - 1])
### BUGGY CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        for j in range(1, min(k+1, n-i)):
            num = dp[i]+abs(h[i]-h[i+j])
            if num < dp[i+j]:
                dp[i+j] = num
    print(dp[-1])

main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*n
    dp[0] = 0
    for i in range(n):
        a = h[i]
        for j in range(1, min(k+1, n-i)):
            num = dp[i]+abs(a-h[i+j])
            if num < dp[i+j]:
                dp[i+j] = num
    print(dp[-1])

main()
### BUGGY CODE ###

#coding:utf-8
S=raw_input()

all=1
a=ab=abc=0

for _ in range(len(S)):
    i=_+1
    c=S[_]
    if c=="A":
        a+=all
    if c=="B":
        ab+=a
    if c=="C":
        abc+=ab
    if c=="?":
        abc=abc*3+ab
        ab=ab*3+a
        a=a*3+all
        all*=3
print(abc%((10**9)+7))

    














### FIXED CODE ###

#coding:utf-8
S=raw_input()

all=1
a=ab=abc=0
MOD=(10**9)+7
for _ in range(len(S)):
    i=_+1
    c=S[_]
    if c=="A":
        a+=all
    if c=="B":
        ab+=a
    if c=="C":
        abc+=ab
    if c=="?":
        abc=abc*3+ab
        ab=ab*3+a
        a=a*3+all
        all*=3
    a%=MOD
    ab%=MOD
    abc%=MOD
    all%=MOD
print(abc%((10**9)+7))
### BUGGY CODE ###

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

for i in range(len(A)):
  ans *= A[i]
  
if ans > 10**18:
  ans = -1
  
print(ans)

### FIXED CODE ###

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

if 0 in A:
  ans = 0
  N = 0
  
for i in range(N):
  ans *= A[i]
  if ans > 10**18:
    ans = -1
    break
    
print(ans)
### BUGGY CODE ###

a, b, x = map(int, input().split())
count = 0

for i in range(a, b+1):
    if i % x == 0:
        count += 1
print(count)

### FIXED CODE ###

a,b,x = map(int,input().split())
print(b//x - (a-1)//x)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

while M:
	A.sort()
	A[-1] //= 2
	M -= 1

print(sum(A))

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
A = LIST()

A = [-x for x in A]
A.sort()

for i in range(M):
	a = heappop(A)
	heappush(A, -(-a//2))
	

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

import sys
input = sys.stdin.readline
from math import ceil
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
X,H = map(list, zip(*XH))

ans = 0
for i in range(N):
    if H[i] > 0:
        num = ceil(H[i]/A)
        for j in range(i,N):
            if X[j] <= X[i]+2*D:
                H[j] -= A*num
            else:
                break
        ans += num
print(ans)


### FIXED CODE ###

#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
from math import ceil
from collections import deque
N,D,A = map(int, input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)
### BUGGY CODE ###

import math
N=int(input())
def f(n):
  ans=0
  K=int(math.sqrt(n))
  K2=int(math.sqrt(n/6))
  for x in range(K2,K+1):
    L=min(x,int(math.sqrt(n-x**2)))
    L2=int(math.sqrt((n-x**2)/5))
    for y in range(L2,L+1):
      z=min(y,round(math.sqrt(n-x**2-y**2-x*y+(x+y)**2/4)-(x+y)/2))
      if x**2+y**2+z**2+x*y+y*z+z*x==n and z>=1:
        if x==z:
          ans+=1
        elif x==y or y==z:
          ans+=3
        else:
          ans+=6
  return ans

for i in range(1,N+1):
  print(f(i))

### FIXED CODE ###

N=int(input())
A=[0]*N
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x**2+y**2+z**2+x*y+y*z+z*x<=N:
        A[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1
for i in range(N):
  print(A[i])
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()

for i  in range(1,N + 1):
    ans = A.count(i)
    print(ans)

### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
ans_list = [0] * N
for a in A:
    ans_list[a - 1] += 1
for i in range(N):
    print(ans_list[i])
### BUGGY CODE ###

import numpy as np
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

dp = np.array([10**5]*n)
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = np.min(np.array([dp[i-j]+abs(h[i]-h[i-j]) 
                        for j in range(1, min(k, i)+1)]))

print(dp[n-1])

### FIXED CODE ###

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(h[1]-h[0])

for i in range(2, n): 
    dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(k, i)+1)])

print(dp[n-1])
### BUGGY CODE ###

n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f2(x,y):
  return nCr_mod(x+y-1,y-1)
def f(x,y):
  return f2(x-y,y)
r=n-k
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i-1)
  red+=(f(r,i)*2)
  red+=f(r,i+1)
  if i==1:
    print((bule*red)%mod-1)
  else:
    print((bule*red)%mod)

### FIXED CODE ###

n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f(x,y):
  return nCr_mod(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)
### BUGGY CODE ###

K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    for m in range(K+1):
      if i+j+m==S:
        count+=1
print(count)

### FIXED CODE ###

K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    if 0 <= S-i-j <= K:
      count += 1
print(count)
### BUGGY CODE ###

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

ans=-100
for i in range(min(As)-1,max(As)+1):
  tmp=As.count(i+1)+As.count(i)+As.count(i-1)
  if ans<tmp:
    ans=tmp
print(ans)

### FIXED CODE ###

from itertools import chain
from collections import Counter
n=int(input())
As=list(map(int,input().split()))
As = [[a-1, a, a+1] for a in As]
As = list(chain.from_iterable(As))

result_cntr = Counter(As).most_common()
print(result_cntr[0][1])
### BUGGY CODE ###

import heapq
import sys
H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

INF = 1e10
maze = []

dh = [-1,0,1,0]
dw = [0,1,0,-1]

def input():
    return sys.stdin.readline()[:-1]

for i in range(H):
    tmp = list(input())
    maze.append(tmp)

reached = [[INF]*W for _ in range(H)]

def dikstra(sh, sw):
    reached[sh][sw] = 0
    tmp = [(0, sh, sw)]
    heapq.heapify(tmp)
    while tmp:
        c, h, w = heapq.heappop(tmp)
        if c > reached[h][w]:
            continue
        for i in range(4):
            cost = 0
            nh = h + dh[i]
            nw = w + dw[i]
            if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
                continue
            if maze[nh][nw] == "#":
                continue
            if reached[nh][nw] <= reached[h][w]:
                continue
            reached[nh][nw] = reached[h][w]
            heapq.heappush(tmp,(reached[nh][nw], nh, nw))
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                cost = 1
                nh = h + i
                nw = w + j
                if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
                    continue
                if maze[nh][nw] == "#":
                    continue
                if reached[nh][nw] <= reached[h][w] + cost:
                    continue
                reached[nh][nw] = reached[h][w] + cost
                heapq.heappush(tmp,(reached[nh][nw], nh, nw))
                

dikstra(Ch, Cw)
ans = reached[Dh][Dw]
if ans != INF:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

INF = 1e10
maze = []

dh = [-1,0,1,0]
dw = [0,1,0,-1]

for i in range(H):
    tmp = list(input())
    maze.append(tmp)

reached = [[INF]*W for _ in range(H)]

l = deque()
l.appendleft((Ch, Cw))
reached[Ch][Cw] = 0
while l:
    h, w = l.popleft()
    d = reached[h][w]
    for i in range(4):
        nh = h + dh[i]
        nw = w + dw[i]
        if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
            continue
        if not maze[nh][nw] != "#":
            continue
        if not reached[nh][nw] > d:
            continue
        reached[nh][nw] = d
        l.appendleft((nh, nw))
    for i in range(-2, 3):
        for j in range(-2, 3):
            nh = h + i
            nw = w + j
            if not (0 <= nh <= H-1 and 0 <= nw <= W-1):
                continue
            if not maze[nh][nw] != "#":
                continue
            if not reached[nh][nw] > d + 1:
                continue
            reached[nh][nw] = d + 1
            l.append((nh, nw))

ans = reached[Dh][Dw]
if ans != INF:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

n = int(input())
s = (list(input()))
cnt = 0
#print(s)
S = set()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            S.add(s[i]+s[j]+s[k])
            #print(s[i]+s[j]+s[k],i,j,k)
print(len(S))

### FIXED CODE ###

n = int(input())
s = input()

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))
### BUGGY CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def ReadInput():
	return [int(i) for i in input().split(" ")]

(R, C) = ReadInput()
N = int(input())
VectorSet = set() 
Grid = defaultdict(list)
for i in range(N):
	(r, c, a) = ReadInput()
	Grid[("R", r)].append((("C", c), a))
	Grid[("C", c)].append((("R", r), a))
	VectorSet.add(("R", r))
	VectorSet.add(("C", c))

def iteration(vector):
	VectorSet.discard(vector)
	for (v, a) in Grid[vector]:
		temp = a - VectorCover[vector]
		if (v in VectorCover):
			if(temp != VectorCover[v]):
				print("No")
				exit()
		else:
			VectorCover[v] = temp
			iteration(v) 

while(len(VectorSet) != 0):
	vector = VectorSet.pop()
	VectorCover = dict() 
	VectorCover[vector] = 0
	iteration(vector)
	minR = min(a for (p, a) in VectorCover.items() if (p[0] == "R"))
	minC = min(a for (p, a) in VectorCover.items() if (p[0] == "C"))
	if (minR + minC < 0):
		print("No")
		exit()

print("Yes")

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def ReadInput():
	return [int(i) for i in input().split(" ")]

(R, C) = ReadInput()
N = int(input())
VectorSet = set() 
Grid = defaultdict(list)
for i in range(N):
	(r, c, a) = ReadInput()
	Grid[("R", r)].append((("C", c), a))
	Grid[("C", c)].append((("R", r), a))
	VectorSet.add(("R", r))
	VectorSet.add(("C", c))

def iteration(vector):
	VectorSet.discard(vector)
	for (v, a) in Grid[vector]:
		temp = a - VectorCover[vector]
		if (v in VectorCover):
			if(temp != VectorCover[v]):
				print("No")
				exit()
		else:
			VectorCover[v] = temp
			iteration(v) 

while(len(VectorSet) != 0):
	vector = VectorSet.pop()
	VectorCover = dict() 
	VectorCover[vector] = 0
	iteration(vector)
	minR = min(a for (p, a) in VectorCover.items() if (p[0] == "R"))
	minC = min(a for (p, a) in VectorCover.items() if (p[0] == "C"))
	if (minR + minC < 0):
		print("No")
		exit()

print("Yes")
### BUGGY CODE ###

import sys
N = r = int(sys.stdin.readline())
l = 0
print(0)
S = sys.stdin.readline().rstrip()
if S == "Vacant":
    sys.exit()
while l < r - 1:
    m = (l + r) // 2
    print(m)
    s = sys.stdin.readline().rstrip()
    if s == "Vacant":
        sys.exit()
    if l & 1 == m & 1 and S == s or l & 1 != m & 1 and S != s:
        l = m + 1
    else:
        r = m
print(l)
input()
sys.exit()

### FIXED CODE ###

N = r = int(input())
l = 0
print(0)
S = input()
if S == "Vacant":
    exit()
while l < r - 1:
    m = (l + r) // 2
    print(m)
    s = input()
    if s == "Vacant":
        exit()
    if l & 1 == m & 1 and S == s or l & 1 != m & 1 and S != s:
        l = m
        S = s
    else:
        r = m
print(l)
input()
exit()