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

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**6
seen = [[[inf for _ in range(4)] for _ in range(w)] for _ in range(h)]
seen[x1][y1] = [0,0,0,0]

dire = [[1,0],[-1,0],[0,1],[0,-1]]
def add(x,y,di,I,J,s):
  dx,dy = dire[di]
  if J == 0:
    if 0 <= x+dx < h and 0 <= y+dy < w:
      if raw[x+dx][y+dy] == '.' and seen[x+dx][y+dy][di] > s+I:
        now.append([s+I,x+dx,y+dy,di])
        seen[x+dx][y+dy][di] = s+I
  else:
    if seen[x][y][di] > s+I:
      nex.append([s+I,x,y,di])
      seen[x][y][di] = s+I

nex = [[0,x1,y1,d] for d in range(4)]
while nex:
  now = nex[:]
  nex = []
  for i in range(k):
    last = now[:]
    now = []
    for sxydi in last:
      s,x,y,di = sxydi
      if seen[x][y][di] < s:
        continue
      if x == x2 and y == y2:
        print(s)
        exit()
      add(x,y,di,1-int(bool(i)),0,s)
      for d in range(4):
        if di != d:
          add(x,y,d,0,1,s)
  nex += now
print(-1)

### FIXED CODE ###

#16:41
h,w,k = map(int,input().split())
x1,y1,x2,y2 = map(lambda x:int(x)-1, input().split())
raw = []
for _ in range(h):
  raw.append(input())
inf = 10**6
seen = [[inf for _ in range(w)] for _ in range(h)]
seen[x1][y1] = 0
from heapq import heappush as push
from heapq import heappop as pop
now = [[0,x1,y1]]

while now:
  s,x,y = pop(now)
  if x == x2 and y == y2:
    print(s)
    exit()
  for i in range(1,k+1):
    if x-i == -1 or raw[x-i][y] == '@' or seen[x-i][y] < s+1:
      break
    if seen[x-i][y] != s+1:
      seen[x-i][y] = s+1
      push(now,[s+1,x-i,y])
  for i in range(1,k+1):
    if y-i == -1 or raw[x][y-i] == '@' or seen[x][y-i] < s+1:
      break
    if seen[x][y-i] != s+1:
      seen[x][y-i] = s+1
      push(now,[s+1,x,y-i])
  for i in range(1,k+1):
    if x+i == h or raw[x+i][y] == '@' or seen[x+i][y] < s+1:
      break
    if seen[x+i][y] != s+1:
      seen[x+i][y] = s+1
      push(now,[s+1,x+i,y])
  for i in range(1,k+1):
    if y+i == w or raw[x][y+i] == '@' or seen[x][y+i] < s+1:
      break
    if seen[x][y+i] != s+1:
      seen[x][y+i] = s+1
      push(now,[s+1,x,y+i])
print(-1)
### BUGGY CODE ###

N = int(input())
l = list(map(int, input().split()))
l_2 = []
gusu_kisu = N % 2
end_F = 0
for i in range(N):
    if gusu_kisu == 1:
        An = l[i]
        if An % 2 == 1:
            end_F = 1
            break
        elif An == 0 and l_2.count(0) == 1:
            end_F = 1
            break
        elif l_2.count(An) == 2:
            end_F = 1
            break
        else:
            l_2.append(An)
    else:
        An = l[i]
        if An % 2 == 0:
            end_F = 1
            break
        elif l_2.count(An) == 2:
            end_F = 1
            break
        else:
            l_2.append(An)
#     print(An)
# print(end_F)
if end_F == 0:
    print((2 ** (N // 2)) % 1000000007)
else:
    print(0)

### FIXED CODE ###

from collections import Counter

ans_0 = False
N = int(input())
l = list(map(int, input().split()))
l_Counter = Counter(l)
if N % 2 == 1:
    if l_Counter[0] != 1:
        ans_0 = True
    else:
        l_Counter[0] = 2
        for i in l_Counter.items():
            # print(i)
            if i[1] != 2 or i[0] % 2 == 1:
                ans_0 = True
                break
else:
    for i in l_Counter.items():
        # print(i)
        if i[1] != 2 or i[0] == 0 or i[0] % 2 == 0:
            ans_0 = True
            break
#     print(An)
# print(end_0)
if ans_0:
    print(0)
else:
    print((2 ** (N // 2)) % 1000000007)
### BUGGY CODE ###

def combi(n):
  return n*(n-1)//2
  
N = int(input())
A = input().split()
tmp = 0
idx = list(set(A))
value = [ A.count(_) for _ in idx ]
for n in value:
    tmp += combi(n)
#sum = 0
for i in A:
    j = idx.index(i)
    #sum += tmp - combi(j) + combi(j-1)
    print(int(tmp - combi(value[j]) + combi(value[j]-1)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
import collections
A_count = collections.Counter(A)
 
import math
sum_ = 0
for ai in A_count:
    sum_ += (A_count[ai] * (A_count[ai] - 1)) // 2
 
for ai in A:
    #print(sum_ - (A_count[ai] * (A_count[ai] - 1)) // 2 + (A_count[ai] - 1) * (A_count[ai] - 2)) // 2
    l = A_count[ai] * (A_count[ai] - 1) // 2
    m = (A_count[ai] - 1) * (A_count[ai] - 2) // 2
    print(sum_ - l + m)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
def rec(i):
    if i == 0:
        C[i] = 0
        return C[i]
    elif i == 1:
        C[i] = rec(i-1)+abs(H[i]-H[i-1])
        return C[i]
    # print(i, rec(i-1), rec(i-2))
    C[i] = min(rec(i-1)+abs(H[i]-H[i-1]), rec(i-2)+abs(H[i]-H[i-2]))
    return C[i]
INFTY = 10**13
N = int(input())
H = list(map(int, input().split()))
C = [INFTY for i in range(N)]
# C[0] = 0
# for i in range(N):
#     if i+1 < N:
#         C[i+1] = min(C[i] + abs(H[i+1]-H[i]), C[i+1])
#     if i+2 < N:
#         C[i+2] = min(C[i] + abs(H[i+2]-H[i]), C[i+2])
# print(C[-1])
print(rec(N-1))


### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
C = [10**13 for i in range(N)]
C[0] = 0
for i in range(N):
    if i+1 < N:
        C[i+1] = min(C[i] + abs(H[i+1]-H[i]), C[i+1])
    if i+2 < N:
        C[i+2] = min(C[i] + abs(H[i+2]-H[i]), C[i+2])
print(C[-1])
### BUGGY CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
class Member:
    def __init__(self, answer):
        self.answer = answer
    def judge(self):
        if self.answer <= q-k:
            return 'No'
        else:
            return 'Yes'  
members = [Member(a.count(i+1)) for i in range(n)]
for member in members:
    print(member.judge())

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]
p = [k for i in range(n)]
def judge(x):
    if p[x] - q <= 0:
        return 'No'
    else:
        return 'Yes'
for i in range(q):
    p[a[i] - 1] += 1
b = [judge(i) for i in range(n)]
print('\n'.join(b))
### BUGGY CODE ###

import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict

N,M=map(int, input().split())
city = defaultdict(list)
p = [0] * M
y = [0] * M

for i in range(M):
    P,Y=map(int, input().split())
    city[P].append(Y)
    p[i] = P
    y[i] = Y

city_sorted = defaultdict(list)
for key,v in city.items():
    city_sorted[key] = sorted(v)

for a in range(M):
    key = p[a]
    for (i,x) in enumerate(city_sorted[key]):
        if (y[a] == x):
            print(str(key).zfill(6)+str(i+1).zfill(6))

### FIXED CODE ###

import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict

N,M=map(int, input().split())
city = defaultdict(list)
p = [0] * M
y = [0] * M

for i in range(M):
    p[i],y[i]=map(int, input().split())
    city[p[i]].append(y[i])

year = defaultdict(list)
for key,v in city.items():
    for i,x in enumerate(sorted(v)):
        year[x] = i+1

for a in range(M):
    print(str(p[a]).zfill(6)+str(year[y[a]]).zfill(6))
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

memo={}

def f(n):
    if n==0:
        return 0
    elif n in memo:
        return memo[n]
    else:
        pc = format(n, 'b').count('1')
        nn=n%pc
        ret = f(nn)+1
        memo[n]=ret
        return ret

def main():
    N = int(input())
    X = list(input())
    for i in range(N):
        xi = X[:]
        if X[i]=='1':
            xi[i]='0'
        elif X[i]=='0':
            xi[i]='1'
        print(f(int(''.join(xi),2)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def pc(x):
    return format(x, 'b').count('1')

N = int(input())
X = input()
Xn = int(X,2)
p = pc(Xn)
X = list(X)

Xp = Xn%(p+1)
if p==1:
    Xm = 0
else:
    Xm = Xn%(p-1)

def f(i):
    if p==1 and X[i]=='1':
        #Xi == 0 > POPcount ==0
        return 0
    else:
        if X[i]=='1':
            # p->p-1
            ret = Xm - pow(2, N-1-i, p-1)
            ret %= p-1
        else:
            # p->p+1
            ret = Xp + pow(2, N-1-i, p+1)
            ret %= p+1
        cnt = 1
        while ret > 0:
            ret %= pc(ret)
            cnt += 1
        return cnt

def main():
    for i in range(N):
        ret = f(i)
        print(ret)

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

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

result= 0

for j in range(0,n):
  result += a[j]*sum(a[j+1:n])

print(result%(10**9+7))

### FIXED CODE ###

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

result= 0
asum = sum(a)
for j in range(0,n):
  asum -= a[j]
  result += a[j]*(asum)

print(result%(10**9+7))
### BUGGY CODE ###

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

class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*2**(self.K+1)#basementで初期化
 
        for i in range(self.n):
            self.seg[i+2**self.K-1] = lists[i]
 
        for i in range(2**(self.K)-2, -1, -1):
            self.seg[i] = self.func(self.seg[2*i+1], self.seg[2*i+2])
 
    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        k += 2**self.K-1
        self.seg[k] = value
        while k:
            k = (k-1)//2
            self.seg[k] = self.func(self.seg[k*2+1], self.seg[k*2+2])
 
    def query(self, p, q):
        # 0-indexで[p,q)の値を取得する
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res
 

n=int(input())
a=list(map(int,input().split()))
seg=SegTree(a,gcd,0)
ans=1
for i in range(n):
    ans=max(ans,gcd(seg.query(0,i),seg.query(i+1,n)))
print(ans)


### FIXED CODE ###

#abc125 c
n=int(input())
a=list(map(int,input().split()))

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

fl_gcd=[0]*(n+1)
fr_gcd=[0]*(n+1)

for i in range(n):
    fl_gcd[i+1]=gcd(fl_gcd[i],a[i])
    fr_gcd[n-i-1]=gcd(fr_gcd[n-i],a[n-1-i])
#print(fr_gcd)
#print(fl_gcd)

ans=0
for i in range(n):
    lr_gcd=gcd(fl_gcd[i],fr_gcd[i+1])
    ans=max(ans,lr_gcd)
print(ans)
### BUGGY CODE ###

import sys
from collections import deque
from copy import copy

N,K = list(map(int, input().split()))
V = deque(list(map(int, input().split())))

max_value = 0

def calc_max_value(V, k, l, r):
    store = []
    for i in range(l):
        if len(V)>0:
            store.append(V.popleft())
            continue
        else:
            break
    for i in range(r):
        if len(V)>0:
            store.append(V.pop())
            continue
        else:
            break
    store.sort()
    max_value = sum(store)
    for i in range(k-l-r):
        if len(store)>0:
            store.pop(0)
            max_value = max(max_value, sum(store))
        else:
            break
    return max_value

    
for k in range(K+1):
    for l in range(K+1):
        for r in range(K+1-l):
            max_value = max(max_value, calc_max_value(copy(V), k, l, r))

print(max_value)


### FIXED CODE ###

import sys
from collections import deque
from copy import copy

N,K = list(map(int, input().split()))
V = deque(list(map(int, input().split())))

max_value = 0

def calc_max_value(V, K, k, l, r):
    store = deque([])
    for i in range(l):
        if len(V)>0:
            store.append(V.popleft())
            continue
        else:
            break
    for i in range(r):
        if len(V)>0:
            store.append(V.pop())
            continue
        else:
            break
    store = deque(sorted(store))
    for i in range(K-l-r):
        if len(store)>0:
            e = store.popleft()
            if e < 0:
                continue
            else:
                store.appendleft(e)
                break
        else:
            break
    max_value = sum(store)
    return max_value

    
for k in range(min(K+1,N+1)):
    for l in range(k+1):
        for r in range(k+1-l):
            max_value = max(max_value, calc_max_value(copy(V), K, k, l, r))

print(max_value)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline

    INF = 1 << 30

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

    dp = [INF] * (10 ** 4 * 2 + 1)
    dp[0] = 0

    for _ in range(N):
        A, B = map(int, input().split())
        for j in range(H):
            dp[j + A] = min(dp[j + A], dp[j] + B)
    print(min(dp[H:]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys

    input = sys.stdin.readline

    inf = 10 ** 8 + 10

    h, n = map(int, input().split())
    *ab, = (list(map(int, input().split())) for _ in range(n))

    dp = [[inf] * (h + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    # dp[使った魔法][与えたダメージ]=最小魔法消費

    for i, (a, b) in enumerate(ab):
        for hp in range(h + 1):
            if hp < a:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][0] + b)
            else:
                dp[i + 1][hp] = min(dp[i][hp], dp[i + 1][hp - a] + b)

    print(dp[n][h])


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
### BUGGY CODE ###

from collections import defaultdict

N, M = map(int, input().split())
PY = [tuple(map(int, input().split())) for _ in range(M)]

Plist = defaultdict(list)

for p, y in PY:
    Plist[p].append(y)

for p, l in Plist.items():
    l.sort()

for p, y in PY:
    idx = Plist[p].index(y)
    print("{:06}{:06}".format(p, idx+1))


### FIXED CODE ###

from collections import defaultdict

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

years = []
for i in range(M):
    P, Y = map(int, input().split())
    years.append((P, Y))

d = defaultdict(int)
b = dict()
for p, y in sorted(years, key=lambda x: x[1]):
    d[p] += 1
    b[y] = '{:06d}{:06d}'.format(p, d[p])

for p, y in years:
    print(b[y])
### BUGGY CODE ###

from collections import deque
import numpy as np
n,m,k=map(int,input().split())
link=[[] for _ in range(n)]
block=[[]  for _ in range(n)]
ans=[]
s=[]
for i in range(m):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)
for i in range(k):
  a,b=map(int,input().split())
  block[a-1].append(b-1)
  block[b-1].append(a-1)
for i in range(n):#スタートの選び方
    visited=set()
    q=deque([i])
    while len(q)>0:
        x=q.pop()
        visited.add(x)
        for j in link[x]:
            if j in visited:
              continue
            elif j in q:
              continue
            else:q.append(j)
    ans.append(len(visited))
    s.append(visited)
res=[]
for i in range(n):
  l=len((set(link[i]+block[i])&set(s[i])))+1
  res.append(l)
print(*(np.array(ans)-np.array(res)))

### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
      self.n=n
      self.root=[-1]*(n+1)
      self.rank=[0]*(n+1)
      
    def find(self,x):
      if self.root[x]<0:
        return x
      else:
        self.root[x]=self.find(self.root[x])
        return self.root[x]
    
    def unite(self,x,y):
      x=self.find(x)
      y=self.find(y)
      if x==y:
        return 0
      elif self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      else:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
          
    def Same(self,x,y):
      return self.find(x)==self.find(y)
    
    def size(self,x):
      return -self.root[self.find(x)]
import sys
input=sys.stdin.buffer.readline
n,m,k=map(int,input().split())
link=UnionFind(n)
f=[0]*n
block=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    link.unite(a,b)
    f[a]+=1
    f[b]+=1
for _ in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
for i in range(n):
  ret=link.size(i)-f[i]-1
  for j in block[i]:
    if link.Same(i,j):
      ret-=1
  ans.append(ret)
print(*ans)
### BUGGY CODE ###

import fractions
from functools import reduce
import itertools
k = int(input()) 
l = list(range(1, k + 1))
ans = 0
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
for v in itertools.product(l, repeat=3):
    ans += gcd(*list(v))
print(ans)

### FIXED CODE ###

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

N, M = [int(s) for s in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))

counts = [0] * (N + 1)
for i in range(N + 1):
    if i == 0:
        counts[i] = 1
    elif i == 1:
        if i not in A:
            counts[i] = 1
    else:
        for j in [i - 2, i - 1]:
            if j not in A and i not in A:
                counts[i] += counts[j]
                counts[i] %= 1000000007

print(counts[N])


### FIXED CODE ###

N, M = [int(s) for s in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
A = set(A)

counts = [0] * (N + 1)
for i in range(N + 1):
    if i == 0:
        counts[i] = 1
    elif i == 1:
        if i not in A:
            counts[i] = 1
    else:
        if i not in A:
            for j in [i - 2, i - 1]:
                if j not in A:
                    counts[i] += counts[j]
                    counts[i] %= 1000000007

print(counts[N])
### BUGGY CODE ###


from sys import stdin

n = int(stdin.readline().rstrip())
ls = [int(x) for x in stdin.readline().rstrip().split()]

x = 0#位置
ans = 0
while x < n-2:
    a = ls[x]
    for y in range(x+1,n-1):
        b = ls[y]
        for z in range(y+1,n):
            c = ls[z]
            if a<b+c:
                if b<c+a:
                    if c<a+b:
                        ans += 1
    x += 1

print(ans)


### FIXED CODE ###

from sys import stdin
from collections import defaultdict, deque, Counter
import sys
from bisect import bisect_left
import heapq
import math

sys.setrecursionlimit(1000000000)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(stdin.buffer.readline().decode().rstrip()) for _ in range(h)]

l.sort()
ans = 0

for i in range(n):
    for j in range(i+1, n):
        t = l[i] + l[j]
        idx = bisect_left(l,t)
        ans += max(0,idx-j-1)

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

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

if n < m :
    print("NO")
else :
    for tt in t :
        if tt in d :
            idx = d.index(tt)
            d[idx] = -1
        else :
            print("NO")
            break
    else :
        print("YES")

### FIXED CODE ###

import collections

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))


if n < m :
    print("NO")
else :
    dic = collections.defaultdict(int)
    for dd in d :
        dic[dd] += 1
    
    for tt in t :
        dic[tt] -= 1
        if dic[tt] < 0 :
            print("NO")
            break
    else :
        print("YES")
### BUGGY CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]

a.sort()
bc.sort(key=lambda x:x[1],reverse=True)

for i in bc:
    k = 0
    for j in range(i[0]):
        if a[i[0]-j-1] < i[1]:
            k = i[0]-j
            break
    a = [i[1] for l in range(k)] + a[k:]
  #  print(a)
    a.sort()
print(sum(a))

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]

for i in a:
    bc.append([1,i])
bc.sort(key=lambda x:x[1],reverse=True)
#print(bc)
ans = 0
for i in bc:
    d = min(i[0],n)
 #   print(d)
    ans += i[1] * d
    n -= d
print(ans)
### BUGGY CODE ###

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

def cal(h, w, a):
    q = deque()
    counts = [[True for _ in range(w+2)]]+[[True]+[False for _ in range(w)]+[True] for _ in range(h)]+[[True for _ in range(w+2)]]
    loc = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for i in range(w):
        for j in range(h):
            if a[j][i] == '#':
                q.append([i, j, 0])
                counts[j+1][i+1] = True

    while q:
        x, y, z = q.popleft()
        for i, j in loc:
            x0 = x+j
            y0 = y+i
            if not counts[y0+1][x0+1]:
                counts[y0+1][x0+1] = True
                q.append([x0, y0, z+1])
    return z

print(cal(h, w, a))


### FIXED CODE ###

from collections import deque

def cal():
    h, w = map(int, input().split())
    q = deque()
    counts = [[True for _ in range(w+2)]]+[[True]+[False]*w+[True] for _ in range(h)]+[[True for _ in range(w+2)]]
    for i in range(h):
        a = input()
        for j in range(w):
            if a[j] == '#':
                q.append([i+1, j+1, 0])
                counts[i+1][j+1] = True

    while q:
        x, y, z = q.popleft()    
        if not counts[x+1][y]:
            counts[x+1][y] = True
            q.append([x+1, y, z+1])
        if not counts[x-1][y]:
            counts[x-1][y] = True
            q.append([x-1, y, z+1])
        if not counts[x][y+1]:
            counts[x][y+1] = True
            q.append([x, y+1, z+1])
        if not counts[x][y-1]:
            counts[x][y-1] = True
            q.append([x, y-1, z+1])
    print(z)
    

cal()
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
  x=int(input())
  if x not in a:a.append(x)
  else:a.remove(x)
print(len(a))

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
a=sorted(a)
x=a[0]
c=1
ct=0
for i in range(1,n):
  if a[i]==x:
    c+=1
    if i==n-1:
      if c%2==1:
        ct+=1
  else:
    if c%2==1:
      ct+=1
    x=a[i]
    c=1
    if i==n-1:
      ct+=1
print(ct)
### BUGGY CODE ###

import math
nums = [int(i) for i in input().split()]
n = nums[0]
x = nums[1]
y = nums[2]
res = {}
for i in range(1, n):
    res[i] = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        dis = j - i
        disI = min(abs(i-x), abs(i-y))
        disJ = min(abs(j-x), abs(j-y))
        dis = min(dis, disI+disJ+1)
        res[dis] += 1
for i in range(1, n):
    print(res[i])


### FIXED CODE ###

import math
nums = [int(i) for i in input().split()]
n = nums[0]
x = nums[1]
y = nums[2]
res = [0 for i in range(2010)]

for i in range(1, n+1):
    for j in range(i+1, n+1):
        dis = j - i
        dis = min(dis, abs(i-x)+abs(j-y)+1)
        res[dis] += 1
for i in range(1, n):
    print(res[i])
### BUGGY CODE ###

a, v = list(map(int, input().split()))
b, w = list(map(int, input().split()))
t = int(input())
for i in range(t):
  a += v
  b += w
if a >= b:
  print('YES')
else:
  print('NO')


### FIXED CODE ###

a, v = list(map(int, input().split()))
b, w = list(map(int, input().split()))
t = int(input())
if a > b:
  a, b = a-v*t, b-w*t
  # a = -1 * 10**9 if a < -1 * 10**9 else a
  # b = -1 * 10**9 if b < -1 * 10**9 else b
  if a <= b:
    print('YES')
  else:
    print('NO')
else:
  a, b = a+v*t, b+w*t
  # a = 10**9 if a > 10**9 else a
  # b = 10**9 if b > 10**9 else b
  if a >= b:
    print('YES')
  else:
    print('NO')