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

def comp(a,b):
  r=""
  for x,y in zip(a,b):
    if x==y:
      r += x
    elif y=="?":
      r += x
    elif x=="?":
      r += y
    else:
      return False
  return r

def merge(a,b):
  for i in range(len(a)-len(b)+1):
    m = comp(a[i:],b)
    if m:
      yield a[:i]+m+a[i+len(b):]
  
  for i in range(1,len(b)):
    m = comp(b[i:], a)
    if m:
      yield  b[:i]+m+a[len(b)-i:]
    m = comp(b, a[-len(b)+i:])
    if m:
      yield a[:-len(b)+i]+m+b[-i:]
  yield a+b
  yield b+a

a=input()
b=input()
c=input()
a,b,c=sorted([a,b,c],key=len,reverse=True)

abc = float("inf")
for d in merge(a,b):
  if len(d) > abc:
    break
  l = len(next(merge(d, c)))
  abc = min(abc, l)

for d in merge(a,c):
  if len(d) > abc:
    break
  l = len(next(merge(d, b)))
  abc = min(abc, l)

print(abc)



### FIXED CODE ###

from itertools import *
from heapq import *

def comp(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

def comp3(a,b,c):
  return 

def comp3(i,j,k,a,b,c):
  m = max(i,j,k)
  n = min(i+len(a),j+len(b),k+len(c))
  return all(len({x,y,z}-{"?"}) <= 1 for x,y,z in zip(a[m-i:n-i],b[m-j:n-j],c[m-k:n-k]))

def _merge_mid(a,b):
  la, lb = map(len,[a,b])
  for i in range(la-lb+1):
    if comp(a[i:],b):
      yield i

def merge_mid(a,b):
  return list(_merge_mid(a,b))

def _merge_right(a,b):
  la, lb = map(len,[a,b])
  for i in range(max(la-lb+1, 1),la):
    if comp(b, a[i-la:]):
      yield i
  yield la

def merge_right(a,b):
  return list(_merge_right(a,b))

class K(int):
  def __new__(cls, *args, **kwargs):
    cb = kwargs.pop("cb")
    i = int.__new__(cls, *args, **kwargs)
    i.cb = cb
    return i

def min_merge(a,b,c):
  keys = sorted([a,b,c],key=len,reverse=True)
  len_keys = list(map(len, keys))
  mid = {(i,j):merge_mid(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  right = {(i,j):merge_right(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  
  for i in mid[0,1]:
    for j in mid[0,2]:
      if j+len_keys[2] <= i or i+len_keys[2] <= j or (j-i in mid[1,2] or j-i in right[1,2] or i-j in right[2,1]):
        return len_keys[0]
  
  def candicates(a,b,c):
    return chain(
      (K(i+len_keys[b], cb=lambda:(
       (mid[a,c] and mid[a,c][0]+len_keys[c] <= i) or (mid[b,c] and len_keys[a] <= i+mid[b,c][-1]) or 
       any((i-j in right[c,b] if i>j else j-i in mid[b,c]) and comp3(0,i,j,keys[a],keys[b],keys[c]) for j in dropwhile((i-len_keys[c]).__gt__, mid[a,c]+right[a,c]))
      )) for i in dropwhile((len_keys[c]-len_keys[b]+1).__gt__, right[a,b])),
      (K(min(i+next(dropwhile((len_keys[a]-i+1).__gt__, y))+len_keys[b] for i in x), cb=lambda:True) for (x, y) in [sorted((right[a,c], right[c,b]), key=len)]),
    )
  
  can = merge(*(candicates(x,y,z) for x,y,z in permutations(range(3),3)))
  
  for k in can:
    if k.cb():
      return k
  
  return sum(len_keys)

a=input()
b=input()
c=input()

print(min_merge(a,b,c))
### BUGGY CODE ###

N = int(input())
count = 0
for A in range(1,N):
  for B in range(1,int(N/A)+1+1):
    if N - A * B >= 1:
      count += 1
print(count)

### FIXED CODE ###

N = int(input())
count = 0
for A in range(1,int((N)**0.5)+2):
  for B in range(A,int((N)/A)+2):
    if A*B < N:
      count += 1
      if A != B:
        count += 1
print(count)
### BUGGY CODE ###

S =input()
l=len(S)
N=int(S,2)
a=0b1
b=0b0
for i in range(1,l):
  if i%2==0:
    a=a+0b10**i
  else:
  	b=b+0b10**i
aN=a ^ N
bN=b ^ N
apopcount=0
bpopcount=0
for i in range(0,l):
  if (aN & 0b10**i)!=0:
    apopcount+=1
  if (bN & 0b10**i)!=0:
    bpopcount+=1
if apopcount<bpopcount:print(apopcount)
else:print(bpopcount)
    



### FIXED CODE ###

S =input()
l=len(S)

    
apopcount=0
bpopcount=0
for i in range(0,l):
  if i%2==0:
    if int(S[i])==1:
   		apopcount+=1
    else:
      	bpopcount+=1
  else:
    if int(S[i])==1:
    	bpopcount+=1
    else:
      	apopcount+=1
if apopcount<bpopcount:print(apopcount)
else:print(bpopcount)
### BUGGY CODE ###

N = int(input())
P = input().split(" ")

t = 1
for i in range(1,N):
    list = []
    for j in range(i + 1):
        list.append(int(P[j]))
    m = min(list)
    if m == int(P[i]):
        t = t + 1

print(t)

### FIXED CODE ###

N = int(input())
P = input().split(" ")

t = 1
list = []
for i in range(N):
    list.append(int(P[i]))
    if i == 0:
        m = int(P[0])
    elif int(P[i]) < m:
        m = int(P[i])
        t = t + 1
        
print(t)
### BUGGY CODE ###

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

count=0
if p==2:
    for i in range(n):
        if int(s[i])%2==0:
            count+=i+1
elif p==5:
    for i in range(n):
        if int(s[i])%5==0:
            count+=i+1
else:
    unum=[1]
    for i in range(p-1):
        unum.append(0)
    for i in range(n):
        unum[int(s[i:n])%p]+=1
    for i in range(p):
        unumi=unum[i]
        count+=(unumi*(unumi-1))*0.5
print(round(count))

### FIXED CODE ###

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

count=0
if p==2:
    for i in range(n):
        if int(s[i])%2==0:
            count+=i+1
elif p==5:
    for i in range(n):
        if int(s[i])%5==0:
            count+=i+1
else:
    lis=[1]
    for i in range(n-1):
        lis.append((lis[i]*10)%p)
    lis.reverse()
    for i in range(n):
        lis[i]=(int(s[i])*lis[i])%p
    unum=[1]
    for i in range(p-1):
        unum.append(0)
    num=0
    for i in range(n):
        num=(num+lis[n-i-1])%p
        unum[num]+=1
    for i in range(p):
        unumi=unum[i]
        count+=(unumi*(unumi-1))*0.5
print(round(count))
### BUGGY CODE ###

import numpy as np

R, C, K = map(int, input().split())
rcvs = [list(map(int, input().split())) for _ in range(K)]

rcvs = np.array(rcvs, dtype = "int16")

for i in range(len(rcvs)):
    rcvs[i][0] -= 1
    rcvs[i][1] -= 1

rewards = np.array([[0 for _ in range(C)] for _ in range(R)], dtype="int16")


for rcv in rcvs:
    rewards[rcv[0],rcv[1]] = rcv[2]

dp = [[[0 for _ in range(4)] for _ in range(C+1)] for _ in range(R+1)]
dp = np.array(dp)
answer = 0

for i in range(R):
    for j in range(C):
        reward = rewards[i][j]
        dp[i+1,j+1,0] = max(dp[i,j+1])
        dp[i+1,j+1,1] = dp[i+1,j+1,0] + reward
        
        for k in range(4): # move downside without selecting
            candidate = dp[i+1,j,k]
            dp[i+1,j+1,k] = max(dp[i+1,j,k], dp[i+1,j+1,k])
        for k in range(3):
            dp[i+1,j+1,k+1] = max(dp[i+1,j,k]+reward,dp[i+1,j+1,k+1])
print(max(dp[-1,-1]))

### FIXED CODE ###

import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
import sys

R, C, K = map(int, input().split())
rcvs = [list(map(int, input().split())) for _ in range(K)]
rcvs = np.array(rcvs, dtype=np.int64)

@njit(i8(i8[:,:]), cache=True)
def main(rcvs):
    rewards = np.zeros((R, C), dtype=np.int64)
    
    for i in range(len(rcvs)):
        rewards[rcvs[i][0]-1][rcvs[i][1]-1] = rcvs[i][2]
    
    dp = np.zeros((R+1, C+1, 4), dtype=np.int64)
    
    for i in range(R):
        for j in range(C):
            reward = rewards[i][j]
            dp[i+1][j+1][0] = max(dp[i][j+1])
            dp[i+1][j+1][1] = dp[i+1][j+1][0] + reward
            
            for k in range(4): # move downside without selecting
                dp[i+1][j+1][k] = max(dp[i+1][j][k], dp[i+1][j+1][k])
            if reward > 0:
                for k in range(3):
                    dp[i+1][j+1][k+1] = max(dp[i+1][j][k]+reward,dp[i+1][j+1][k+1])
    return max(dp[-1][-1])

print(main(rcvs))
### BUGGY CODE ###

import numpy as np

def solve(N, M, Q, L, R, p, q):
    A = np.zeros((N+2, N+2), dtype=int)
    S = np.zeros((N+2, N+2), dtype=int)
    for i in range(M):
        A[L[i], R[i]] += 1
    S[0,0] = A[0,0]
    for i in range(1, N+1):
        S[i,:] = S[i-1,:] + A[i,:]
    res = []
    D = {}
    for i in range(Q):
        x1, x2 = p[i], q[i]
        if not (x1, x2) in D:
            a = sum(S[p[i]-1,p[i]:q[i]+1])
            b = sum(S[q[i],  p[i]:q[i]+1])
            D[x1, x2] = b - a
        res.append(D[x1, x2])
    return "\n".join(map(str, res))

N, M, Q = map(int, input().split())
L, R = [0]*M, [0]*M
for i in range(M):
    L[i], R[i] = map(int, input().split())
p, q = [0]*Q, [0]*Q
for i in range(Q):
    p[i], q[i] = map(int, input().split())
print(solve(N, M, Q, L, R, p, q))

### FIXED CODE ###

import numpy as np

def solve(N, M, Q, L, R, p, q):
    A = np.zeros((N+1, N+1), dtype=int)
    for i in range(M):
        A[L[i], R[i]] += 1
    S = np.zeros((N+1, N+1), dtype=int)
    S[0,0] = A[0,0]
    for i in range(1, N+1):
        S[i,:] = S[i-1,:] + A[i,:]
    for j in range(1, N+1):
        S[:,j] += S[:,j-1]
    res = []
    for i in range(Q):
        x1, x2 = p[i]-1, q[i]
        a = S[x2,x2]
        b = S[x1,x2]
        c = S[x2,x1]
        d = S[x1,x1]
        res.append(a - b - c + d)
    return "\n".join(map(str, res))

N, M, Q = map(int, input().split())
L, R = [0]*M, [0]*M
for i in range(M):
    L[i], R[i] = map(int, input().split())
p, q = [0]*Q, [0]*Q
for i in range(Q):
    p[i], q[i] = map(int, input().split())
print(solve(N, M, Q, L, R, p, q))
### BUGGY CODE ###

N, Q = map(int, input().split(" "))
S = input()
l=[]
r=[]
for i in range(Q):
  _l, _r = map(int, input().split(" "))
  l.append(_l)
  r.append(_r)
#print(l, r)

carsol = 0
for i in range(Q):
  counter = 0
  s = S[l[i]-1:r[i]]
  for j in range(len(s)-1):
    if s[j] + s[j+1] == "AC":
      counter += 1
  print(counter)



### FIXED CODE ###

N, Q = map(int, input().split(" "))
S = input()
l=[]
r=[]
for i in range(Q):
  _l, _r = map(int, input().split(" "))
  l.append(_l)
  r.append(_r)
#print(l, r)

total_list = []
total=0
S = ' ' + S
for i in range(1, len(S)):
  if S[i-1] + S[i] == "AC":
    total += 1
  total_list.append(total)
#print(total_list)
for j in range(Q):
  num_r = total_list[r[j]-1]
  num_l = total_list[l[j]-1]
  num = num_r - num_l
  print(num)
### BUGGY CODE ###

N = int(input())
for i in range(1, N+1):
    C = 0
    for x in range(1, i):
        if 6 * x**2 > i:
            break
        for y in range(x, i):
            if x**2 + 3 * y**2 + 2*x*y > i:
                break
            for z in range(y, i):
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    if x == y == z:
                        C += 1
                    elif x == y < z:
                        C += 3
                    elif x < y == z:
                        C += 3
                    else:
                        C += 6
                elif x**2 + y**2 + z**2 > i:
                    break
    print(C)

### FIXED CODE ###

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

import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = np.array(A)
res_list = np.zeros(N)
for j in range(N):
    A_copy = A.copy()
    A_copy = A_copy % A[j]
    A_copy[j] += 1
    A_copy = np.where(A_copy > 0, 1, 0)
    res_list += A_copy
res_list /= len(A)
print(np.count_nonzero(res_list == 1)) 

### FIXED CODE ###

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

max_A = A[-1]
# df[i]...数字iが条件満たす:1、条件満たさない:0
df = [True for _ in range(max_A + 1)]

for i, a in enumerate(A):
    if i > 0:
        if A[i] == A[i - 1]:
            df[a] = False
            continue
    if df[a]:
        for num in range(2*a, max_A+1, a):
            df[num] = False
count = 0
for a in A:
    if df[a]:
        count += 1
print(count)
### BUGGY CODE ###

def lagrange_interpolation(X, Y, mod):
    # ラグランジュ補間
    # n 個の条件から n-1 次多項式を作る
    n = len(X)
    g = [0]*(n+1)
    g[0] = 1
    for i, x in enumerate(X):
        for j in range(i, -1, -1):
            g[j+1] += g[j] * (-x) % mod
    res = [0]*n
    for x, y in zip(X, Y):
        # f = g / (x - x_i) を組立除法で求める
        f = g[:]
        denom = 0
        for i in range(n):
            f_i = f[i]
            f[i+1] += f_i * x % mod
            denom = (denom + f_i * pow(x, n-1-i, mod)) % mod
        denom_inv = pow(denom, p-2, mod)
        for i, f_i in enumerate(f[:n]):
            res[i] = (res[i] + f_i * y * denom_inv) % mod  # mod が大きいと 64bit に収まらなくなるのでひとつずつ mod 取った方がいいか？
    return res

p = int(input())
A = list(map(int, input().split()))
if p==2 and A==[1, 0]:  # AC 回避
    while True:
        print(-1)
ans = lagrange_interpolation(list(range(p)), A, p)
print(*ans[::-1])


### FIXED CODE ###

# AC 回避した https://atcoder.jp/contests/abc137/submissions/6845103 の再提出

def lagrange_interpolation(X, Y, mod):
    # ラグランジュ補間
    # n 個の条件から n-1 次多項式を作る
    n = len(X)
    g = [0]*(n+1)
    g[0] = 1
    for i, x in enumerate(X):
        for j in range(i, -1, -1):
            g[j+1] += g[j] * (-x) % mod
    res = [0]*n
    for x, y in zip(X, Y):
        f = g[:]
        denom = 0
        v = 1
        pow_x = [1]  # x の idx 乗
        for _ in range(n-1):
            v = v * x % mod
            pow_x.append(v)
        pow_x.reverse()  # n-1 乗 ~ 0 乗
        for i, po in enumerate(pow_x):
            f_i = f[i]
            f[i+1] += f_i * x % mod  # f = g / (x - x_i) を組立除法で求める
            denom = (denom + f_i * po)# % mod
        denom_inv = pow(denom, mod-2, mod)
        for i, f_i in enumerate(f[:n]):
            res[i] += (f_i * y * denom_inv)# % mod # 逐次除算したほうが良いかは場合によりそう
    return [v % mod for v in res]

p = int(input())
A = list(map(int, input().split()))
ans = lagrange_interpolation(list(range(p)), A, p)
print(" ".join(map(str, ans[::-1])))
### BUGGY CODE ###

import math


def cf(x1, x2):
    cf = []
    for i in range(1, min(x1, x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf


def isPrime(num):
    if num == 1 or num == 2:
        return True
    elif num % 2 == 0:
        return False

    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False

    return True


def main():
    A, B = map(int, input().split())
    X = cf(A, B)
    ans = 0
    for i in X:
        ans += isPrime(i)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    A, B = map(int, input().split())
    X = prime_decomposition(gcd(A, B))
    print(len(set(X))+1)


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n /= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


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

N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

def judge(now,weight,value):
    if weight > W:
        return 0
    if now == N-1:
        if weight+w[now] <= W:
            return value+v[now]
        elif weight <= W:
            return value
        
    else:
        return max(judge(now+1,weight+w[now],value+v[now]),judge(now+1,weight,value))


r=judge(0,0,0)
print(r)

### FIXED CODE ###

N,W = map(int,input().split())
v = [0]*N;w = [0]*N

for i in range(N):
    v[i],w[i] = map(int,input().split())

value = [0 for i in range(W+1)]
for i in range(N):
    for j in range(W,-1,-1):
        if j<w[i]:
            value[j] = value[j]
        else:
            value[j] = max(value[j],value[j-w[i]]+v[i])

print(value[W])
### BUGGY CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s = list(input())
    n = len(s)
    dp = [[[0 for _ in range(2019)] for _ in range(2)] for _ in range(n+1)]
    for i in range(n):
        for j in range(2019):
            dp[i+1][1][j] += dp[i][0][j]
            dp[i+1][1][j] += dp[i][1][j]
            dp[i+1][0][((j*10)+int(s[i]))%2019] += dp[i][0][j]
        dp[i+1][0][int(s[i])] += 1
    print(dp[n][0][0]+dp[n][1][0])
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    s = input()
    n = len(s)
    dp = [0 for _ in range(2019)]
    dp[0] += 1
    x = 0
    for i in range(n):
        x = (x+int(s[n-1-i])*pow(10,i,2019))%2019
        dp[x] += 1
    ans = 0
    for i in range(2019):
        ans += (dp[i]*(dp[i]-1))//2
    print(ans)

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

from bisect import bisect_left,bisect_right
import string 
dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    c = s[j-1]
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    for vs in dic.values():
      if bisect_left(vs,int(l)) != bisect_right(vs,int(r)):
        ans += 1
    print(ans)

### FIXED CODE ###

from bisect import bisect_left,bisect_right
import string 

dic = {c:[] for c in string.ascii_lowercase}

n = int(input())
s = list(input())
q = int(input())

for i,c in enumerate(s,start=1):
  dic[c].append(i)
  
for i in range(q):
  p,l,r = map(str,input().split())
  if p =='1':
    j = int(l)
    if r == s[j-1]:
      continue
    c = s[j-1]    
    dic[c].pop(bisect_left(dic[c],j))
    dic[r].insert(bisect_left(dic[r],j),j)
    s[j-1] = r
  else:
    ans = 0
    l = int(l)
    r = int(r)
    for c in string.ascii_lowercase:
      pl = bisect_left(dic[c],l)
      if pl < len(dic[c]):
        if dic[c][pl] <= r:
          ans += 1
    print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
D - Practical Skill Test
https://beta.atcoder.jp/contests/abc089/tasks/abc089_d

"""
import sys
from sys import stdin
input = stdin.readline


def solve(numbers, queries, D):
    for l, r in queries:
        ans = 0
        while True:
            if l == r:
                break
            sx, sy = numbers[l]
            gx, gy = numbers[l+D]
            ans += abs(sx - gx) + abs(sy - gy)
            l += D
        print(ans)


def main(args):
    H, W, D = map(int, input().split())
    board = []
    for _ in range(H):
        board.append([int(x) for x in input().split()])
    Q = int(input())
    queries = []
    for _ in range(Q):
        queries.append([int(x) for x in input().split()])

    numbers = dict()
    for y, row in enumerate(board, start=1):
        for x, i in enumerate(row, start=1):
            numbers[i] = [x, y]

    solve(numbers, queries, D)


if __name__ == '__main__':
    main(sys.argv[1:])
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
D - Practical Skill Test
https://beta.atcoder.jp/contests/abc089/tasks/abc089_d

"""
import sys
from sys import stdin
input = stdin.readline


def sub_solve(l, r):
    sx, sy = numbers[l]
    gx, gy = numbers[r]
    return abs(sx - gx) + abs(sy - gy)


def solve(queries, H, W, D):
    dp = [0] * (H*W+1)
    for i in range(D+1, H*W+1):
        dp[i] = dp[i-D] + sub_solve(i-D, i)

    for l, r in queries:
        ans = dp[r] - dp[l]
        print(ans)


numbers = dict()
def main(args):
    global numbers
    H, W, D = map(int, input().split())

    for y in range(1, H+1):
        tmp = [int(x) for x in input().split()]
        for x, i in enumerate(tmp, start=1):
            numbers[i] = (x, y)

    Q = int(input())
    queries = []
    for _ in range(Q):
        queries.append([int(x) for x in input().split()])

    solve(queries, H, W, D)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

#!/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))
for i in range(1, n + 1):
    if i not in not_good:
        ans += 1
        # print(i, end=" ")
print(ans)


### FIXED CODE ###

#!/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)
### BUGGY CODE ###

from collections import deque

h , w = map(int,input().split())
cou = 0
ma = []
for i in range(h):
    kar = list(input())
    cou += kar.count("#")
    ma.append(kar)


ans = [[-1 for i in range(w)] for j in range(h)]
ans[0][0] = 1
q = deque([(0,0)])
xy = [(1,0),(-1,0),(0,1),(0,-1)]

while q:
    x , y = q.popleft()
    ma[x][y] = "#"
    for i in range(4):
        nx = x + xy[i][0]
        ny = y + xy[i][1]
        if 0 <= nx <= h-1 and 0 <= ny <= w-1:
            if ma[nx][ny] == ".":
                q.append((nx,ny))
                ans[nx][ny] = ans[x][y] + 1
                ma[nx][ny] == "#"
        if nx == h-1 and ny == w-1:
            break

if ans[h-1][w-1] == -1:
    print(-1)
else:
    print(h*w - cou - ans[h-1][w-1])


### FIXED CODE ###

from collections import deque
 
h , w = map(int,input().split())
cou = 0
ma = []
for i in range(h):
    kar = list(input())
    cou += kar.count("#")
    ma.append(kar)
 
 
ans = [[-1 for i in range(w)] for j in range(h)]
ans[0][0] = 1
q = deque([(0,0)])
xy = [(1,0),(-1,0),(0,1),(0,-1)]
 
while q:
    x , y = q.popleft()
    for i in range(4):
        nx = x + xy[i][0]
        ny = y + xy[i][1]
        if 0 <= nx <= h-1 and 0 <= ny <= w-1 and ans[nx][ny] == -1:
            if ma[nx][ny] == ".":
                q.append((nx,ny))
                ans[nx][ny] = ans[x][y] + 1
        if nx == h-1 and ny == w-1:
            break
 
if ans[h-1][w-1] == -1:
    print(-1)
else:
    print(h*w - cou - ans[h-1][w-1])
### BUGGY CODE ###

import numpy as np

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = np.array(list(map(int, input().split(' '))))

print(N - sum([np.any(P[:i+1] < P[i]) for i in range(N)]))


### FIXED CODE ###

N = int(input())
# P = np.array(input().split(' '), dtype = int)
P = list(map(int, input().split(' ')))

p_min = P[0]
ans = 0
for p in P:
    if p <= p_min:
        p_min = p
        ans += 1
print(ans)
### BUGGY CODE ###

k = int(input())
ans = 0
import math
import itertools
from functools import reduce

def gcd(num):
    return reduce(math.gcd, num)

numlist = list(range(1, k+1))
l = list(itertools.product(numlist, repeat=3))

ans = sum(map(gcd, l))

print(ans)

### FIXED CODE ###

k = int(input())
ans = 0
import math
from functools import reduce

def gcd(*num):
    return reduce(math.gcd, num)

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(a, b, c)
print(ans)