Harryxun/stf_run huggingface dataset:
c=0
x=[-1,0,1,0]
y=[0,-1,0,1]
buf=[]
p=0
def count(h,w,S,table,H,W):
    global buf,x,y,p
    if buf or p==0:
        for i in range(4):
            if h+y[i]>=0 and h+y[i]<H and w+x[i]>=0 and w+x[i]<W:
                if table[h+y[i]][w+x[i]]==-1:
                    if S[h][w]=='.' and S[h+y[i]][w+x[i]]=='#':
                        table[h+y[i]][w+x[i]]=table[h][w]+1
                        buf.append([h+y[i],w+x[i]])
                    elif S[h][w]=='#' and S[h+y[i]][w+x[i]]=='.':
                        table[h+y[i]][w+x[i]]=table[h][w]+1
                        buf.append([h+y[i],w+x[i]])
        if buf:
            a=buf.pop(0)
            count(a[0],a[1],S,table,H,W)
    elif not(buf) and p==0:
        p+=1
        count(h,w,S,table,H,W)

H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())
for h in range(H):
    for w in range(W):
        if S[h][w]=='#':
            table=[[-1 for j in range(W)] for i in range(H)]
            table[h][w]=0
            p=0
            count(h,w,S,table,H,W)
            for k in range(H):
                for l in range(W):
                    if table[k][l]%2==1 and table[k][l]!=-1:
                        c+=1
print(c)



### FIXED CODE ###

import sys
c=0
b=0
wi=0
x=[-1,0,1,0]
y=[0,-1,0,1]
buf=[]
def one():
    return -1
def count(h,w,S,table,H,W,index):
    global buf,x,y,b,wi
    if index==1:
        b+=1
    else:
        wi+=1
    if index==1:
        S[h][w]='@'
    for i in range(4):
        if h+y[i]>=0 and h+y[i]<H and w+x[i]>=0 and w+x[i]<W:
            if table[h+y[i]][w+x[i]]==-1:
                if index==0 and S[h+y[i]][w+x[i]]=='#':
                    table[h+y[i]][w+x[i]]=1
                    buf.append([h+y[i],w+x[i],1])
                elif index==1 and S[h+y[i]][w+x[i]]=='.':
                    table[h+y[i]][w+x[i]]=1
                    buf.append([h+y[i],w+x[i],0])
    if buf:
        a=buf.pop(0)
        count(a[0],a[1],S,table,H,W,a[2])
sys.setrecursionlimit(10000000)
H,W=map(int,input().split())
T=[]
table=[[-1 for j in range(W)] for i in range(H)]
for i in range(H):
    T.append(input())
S=[['' for j in range(W)]for i in range(H)]
for h in range(H):
    for w in range(W):
        S[h][w]=T[h][w]
for h in range(H):
    for w in range(W):
        if S[h][w]=='#':
            table[h][w]=0
            count(h,w,S,table,H,W,1)
            c+=b*wi
            b=0
            wi=0
print(c)
a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())

ans="NO"
if v>w:
  f=v-w
  hoge=hoge(a-b)
  if f*t>=hoge:
    ans="YES"
    
print(ans)

  

### FIXED CODE ###

a,v=map(int, input().split())
b,w=map(int, input().split())
t=int(input())

ans="NO"
if v>w:
  f=v-w
  hoge=abs(a-b)
  if f*t>=hoge:
    ans="YES"
    
print(ans)
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
maxi=max(a)
mini=min(a)
num=[0]*100000000
maxi=max(a)
for i in range(N):
  w.append(1+i+a[i])
  s.append(1+i-a[i])
  num[1+i-a[i]+(maxi-mini+N+N)//2]+=1
for i in range(N):
  count+=num[w[i]+(maxi-mini+N+N)//2]
print(count)

### FIXED CODE ###

N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(1+i-a[i])
  if 1+i+a[i]<N:
    num[1+i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)
n, q = map(int, input().split())
tree = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b)
    tree[b-1].append(a)
ans = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    ans[p-1] += x
def dfs(c, parent):
    for child in tree[c-1]:
        if child == parent:
            continue
        else:
            ans[child-1] += ans[c-1]
            dfs(child, c)
dfs(1, 0)
print(*ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
n = int(input())
long sum = 0
for i in range(1, n):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        sum+= i
print(sum)

### FIXED CODE ###

n = int(input())
sum = 0
for i in range(1, n + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)
a = input().split()
ans = []
for i in a:
  if a == "1":
    ans.append("9")
  elif a == "9":
    ans.append("1")
  else:
    ans.append(a)
print(ans.join())

### FIXED CODE ###

a = list(input())
ans = []
for i in a:
  if i == "1":
    ans.append("9")
  elif i == "9":
    ans.append("1")
  else:
    ans.append(i)
print(''.join(ans))
N, M = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
rank = [0] * N
parent = [i for i in range(N)]


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = parent[x]
    y = parent[y]

    if rank[x] > rank[y]:
        parent[y] = x
    else:
        parent[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


for i in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

num = 0
for i in range(N):
    num += same(i, P[i])

print(num)

### FIXED CODE ###

N, M = map(int, input().split())
P = list(map(lambda x: int(x) - 1, input().split()))
rank = [0] * N
parent = [i for i in range(N)]


def find(i):
    if parent[i] == i:
        return i
    else:
        parent[i] = find(parent[i])
        return parent[i]


def same(x, y):
    return find(x) == find(y)


def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return

    if rank[x] > rank[y]:
        parent[y] = x
    else:
        parent[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1


for i in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)

num = 0
for i in range(N):
    num += same(i, P[i])

print(num)
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True):
ans = 0
for i in range(k,n):
  ans += h[i]
print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
ans = 0
if(k>=n):
  ans = 0
else:
  for i in range(k,n):
    ans += h[i]
print(ans)
S, T = input().split()
s_i, t_i = map(int, input().split())
U = input()

if U == S:
    print(str(s_i - 1) + " " + str(t_i))
else
    print(str(s_i) + " " + str(t_i - 1))

### FIXED CODE ###

S, T = input().split()
s_i, t_i = map(int, input().split())
U = input()

if U == S:
    print(str(s_i - 1) + " " + str(t_i))
else:
    print(str(s_i) + " " + str(t_i - 1))
sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
while True:
    inputed_line = input()
    data_str = inputed_line.split(' ')
    data = [int(i) for i in data_str]
    data.sort()
    if data[-1] < data[0] + data[1]:
            sankaku += 1
        if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
            tyokkaku += 1
        elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
            eikaku += 1
        elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
            donkaku += 1
    else:
        break

answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_str = ' '.join(answer_list)
print(answer_str)



### FIXED CODE ###

sankaku = 0
tyokkaku = 0
eikaku = 0
donkaku = 0
while True:
    inputed_line = input()
    data_str = inputed_line.split(' ')
    data = [int(i) for i in data_str]
    data.sort()
    if data[-1] < data[0] + data[1]:
        sankaku += 1
        if data[-1] ** 2 == data[0] ** 2 + data[1] ** 2:
            tyokkaku += 1
        elif data[-1] ** 2 < data[0] ** 2 + data[1] ** 2:
            eikaku += 1
        elif data[-1] ** 2 > data[0] ** 2 + data[1] ** 2:
            donkaku += 1
    else:
        break

answer_list = [sankaku, tyokkaku, eikaku, donkaku]
answer_list_str = [str(i) for i in answer_list]
answer_str = ' '.join(answer_list_str)
print(answer_str)
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

ss = nn()
a = 'No' if ss[0] == ss[1] and ss[1] == ss[2] else 'Yes'
print(a)

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()
ss = list(s)
a = 'No' if ss[0] == ss[1] and ss[1] == ss[2] else 'Yes'
print(a)
A,B =map(int.input().split())
print(A*B)

### FIXED CODE ###

A,B =input().split()
a=int(A)
b=int(B)
print(a*b)
w,h,x,y=map(int,input().split())
s=w*h/2
i=1 if x=w/2 and y=h/2 else 0
print(s,i)

### FIXED CODE ###

w,h,x,y=map(int,input().split())
s=w*h/2
i=1 if x==w/2 and y==h/2 else 0
print(s,i)
import math
n = int(input())
res = "%.6f" % float(n * math.pi)
print(res)

### FIXED CODE ###

import math
n = float(input())
area = "%.6f" % float(n **2 *  math.pi)
circ = "%.6f" % float(n * 2 * math.pi)
print(area, circ)
tx = [map(int, input().split())]
cx = [sorted(tx)]

for i in range(2):
    if cx[i] == cx[i+1]:
        print(sum(cx) - 2*cx[i])

### FIXED CODE ###

a, b, c = map(int, input().split())
lst = sorted([a, b, c])

for i in range(2):
    if lst[i] == lst[i+1]:
        print(sum(lst) - 2*lst[i])
N,K = map(int,input().split(" "))
List = sorted([int(i) for i in input().split(" ")],reverse=True)
h=0
while(List[h]>=K):
    h+=1
print(h)

### FIXED CODE ###

N,K = map(int,input().split(" "))
List = [int(i) for i in input().split(" ") if int(i)>=K]
print(len(List))
N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N/2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)

### FIXED CODE ###

N = int(input())
s = input()
ans = 'No'
if N % 2 == 0:
    n = N//2
    a = s[:n]
    b = s[n:]
    if a == b:
        ans = 'Yes'
print(ans)
N,M=(int(x) for x in input().split())
A=list(map(int, input().split()))
A=np.array(A)
B=A[1:]-A[:-1]
b=max(B)
c=A[-1]-A[0]
if c > N/2:
    c=int(c-N/2)
else:
    c=c
d=max(b,c)
print(N-d)

### FIXED CODE ###

import numpy as np

N,M=(int(x) for x in input().split())
A=list(map(int, input().split()))
A=np.array(A)
B=A[1:]-A[:-1]
b=max(B)
c=A[-1]-A[0]
if c > N/2:
    d=int(N-c)
else:
    d=c
e=max(b,d)
f=N-e

print(f)
import sys
n,m = map(int,input().split())
ans = [-1 for i in range(n)]
for i in range(m):
    s,c = map(int,input().split())
    s-=1
    if ans[s] == -1:
        ans[s] = c
    else:
        if c == ans[s]:
            continue
        else:
            print(-1)
            sys.exit()
    if n != 1:
        if ans[s] == 0:
            print(-1)
            sys.exit()
for i in range(n):
    if ans[i] == -1:
        ans[i] = 0
fans = ""
for i in range(n):
    fans += ans[i]
print(fans)


### FIXED CODE ###

import sys
n,m = map(int,input().split())
ans = [-1 for i in range(n)]
if n == 1:
    if m == 0:
        print(0)
        sys.exit()
    else:
        for i in range(m):
            s,c = map(int,input().split())
            if ans[s-1] == -1:
                ans[s-1] = c
            else:
                if c == ans[s-1]:
                    continue
                else:
                    print(-1)
                    sys.exit()
        print(ans[0])
else:
    for i in range(m):
        s,c = map(int,input().split())
        if s-1 == 0:
            if c == 0:
                print(-1)
                sys.exit()
            else:
                if ans[s-1] == -1:
                    ans[s-1] = c
                else:
                    if c == ans[s-1]:
                        continue
                    else:
                        print(-1)
                        sys.exit()
        else:
            if ans[s-1] == -1:
                    ans[s-1] = c
            else:
                if c == ans[s-1]:
                        continue
                else:
                    print(-1)
                    sys.exit()
    if ans[0] == -1:
        ans[0] = 1
    for i in range(n):
        if ans[i] == -1:
            ans[i] = 0
    ans2 = ""
    for i in range(n):
        ans2 += str(ans[i])
    print(ans2)
import math
n=int(input())
A=[int(i) for i in input().split()]
B=[]
for a in A:
  B.append(a)
A.sort(reverse=True)
count=0
for i in range(n):
  cur=A[i]
  if cur in B:
    k=int(math.log2(cur))+1
    pair=2**k-cur
    if pair in B:
      B.remove(pair)
      count+=1
print(count)

### FIXED CODE ###

import bisect
import collections
def f(n):
  return n.bit_length()
n=int(input())
A=[int(i) for i in input().split()]
D=dict(collections.Counter(A))
C=sorted(list(D.keys()))
ans=0
for i in range(len(C)):
  pair=2**f(C[-(i+1)])-C[-(i+1)]
  k=bisect.bisect_left(C,pair)
  if C[k]==pair:
    if k==len(C)-(i+1):
      ans+=D[pair]//2
      D[pair]%=2
    else:
      aa=min(D[pair],D[C[-(i+1)]])
      ans+=aa
      D[pair]-=aa
      D[C[-(i+1)]]-=aa
print(ans)
n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(b[::2])-sum(b[1::2]))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(a[::2])-sum(a[1::2]))
x = int(input())
n = 2

for i in range(10^5):
  while x % n != 0 or n =< x/2:
      n += 1
  if n =< x/2:
    x += 1
    
  else:
    print(x)
    break
      


  	

### FIXED CODE ###

x = int(input())

while True:
  n = 2
  while x % n != 0 and n <= x/2:
    n += 1
  if n < x/2:
    x += 1
    
  else:
    print(x)
    break
import copy
(N,M) = map(int,input().split())
l = []
if M == 0:
    print(1)

else:
    for i in range(M):
        l.append([int(x) for x in input().split()])

    mn = 0
    for i in range(M):
        for j in range(2):
            mn = max(mn,l[i][j])

    s = [0 for i in range(mn+100)]
    k = [0 for i in range(M)]
    cnt = 0
    for i in range(M):
        if s[l[i][0]-1] == 0 and s[l[i][1]-1] == 0:
            cnt += 1
            s[l[i][0]-1] = cnt
            s[l[i][1]-1] = cnt
            k[cnt-1] += 2
        elif s[l[i][0]-1] == 0 and s[l[i][1]-1] != 0:
            s[l[i][0]-1] = s[l[i][1]-1]
            k[s[l[i][1]-1]-1] += 1
        elif s[l[i][0]-1] != 0 and s[l[i][1]-1] == 0:
            s[l[i][1]-1] = s[l[i][0]-1]
            k[s[l[i][0]-1]-1] += 1
        elif s[l[i][0]-1] != s[l[i][1]-1]:
            t = copy.deepcopy(s)
            s = [t[l[i][1]-1] for x in t if x == t[l[i][0]-1]]
            k[t[l[i][1]-1]-1] += k[t[l[i][0]-1]-1]

    print(max(k))



### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

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

root = [-1] * n

def r(x):
    if root[x] < 0:
        return x
    
    else:
        root[x] = r(root[x])
        return root[x]

def unite(x,y):
    x = r(x)
    y = r(y)
    if x == y:
        return
    root[x] += root[y]
    root[y] = x

def size(x):
    x = r(x)
    return -root[x]

for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    unite(x,y)


print(-min(root))
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=[0]
for i in range(K+1):
    #print(i)
    for j in range(i+1):
        if N<=j:
            temp=sorted(V)
        elif j-i!=0:
            temp=sorted(V[:j]+V[j-i:])
        else:
            temp=sorted(V[:j])
        t=0
        for k in range(i):
            if temp[k]>=0:
                t=k+1
                break
        #print(temp,t)
        #if t==0:
        #    print(":",0)
        if t>K-i:
            #print(":",temp[K-i:])
            ans.append(sum(temp[K-i:]))
        elif (K-1-t)%2==1:
            if t>=2:
                #print(":",max(sum(temp[t-2:]),sum(temp[t:])))
                ans.append(max(sum(temp[t-2:]),sum(temp[t:])))
            else:
                #print(":",sum(temp[t:]))
                ans.append(sum(temp[t:]))
        else:
            #print(":",sum(temp[t-1:]))
            ans.append(sum(temp[t-1:]))
print(max(ans))

### FIXED CODE ###

N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=[0]

for i in range(K+1):
    #print(i)
    for j in range(i+1):
        if N<=i:
            temp=sorted(V)
        elif j-i!=0:
            temp=sorted(V[:j]+V[j-i:])
        else:
            temp=sorted(V[:j])
        t=0
        for k in range(min(i,N)):
            if temp[k]>=0:
                t=k+1
                break
        #print(temp,t,j,j-i)
        #if t==0:
        #    print(":",0)
        if t>K-i:
            #print("1",temp[K-i:])
            #print("1",sum(temp[K-i:]))
            ans.append(sum(temp[K-i:]))
        elif (K-1-t)%2==1:
            if t>=2:
                #print("2",max(sum(temp[t-2:]),sum(temp[t:])))
                ans.append(max(sum(temp[t-2:]),sum(temp[t:])))
            else:
                #print("3",sum(temp[t:]))
                ans.append(sum(temp[t:]))
        else:
            #print("4",sum(temp[t-1:]))
            ans.append(sum(temp[t-1:]))
print(max(ans))
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
ti, ai = list(map(int, input().split()))
vp = ti + ai
tp = ti
ap = ai
for i in range(1,n):
    ti, ai = list(map(int, input().split()))
    niv = math.ceil(vp/(ti+ai))
    nit = math.ceil(tp/ti)
    nia = math.ceil(ap/ai)
    ni = max(niv, nit, nia)
    vi = ni*(ti+ai)
    #print(ni, vi)
    tp = ni*ti
    ap = ni*ai

print(vi)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 11 14:44:47 2018
ABC046C
@author: maezawa
"""
import math
n = int(input())
tp = 1
ap = 1
for i in range(n):
    ti, ai = list(map(int, input().split()))
    #nit = math.ceil(tp/ti)
    #nia = math.ceil(ap/ai)
    nit = -tp//ti
    nia = -ap//ai
    ni = max(-nit, -nia)
    vi = ni*(ti+ai)
    #print(ni, vi)
    tp = ni*ti
    ap = ni*ai

print(vi)
a = list(input())

for i in a:
    if i == "a":
        c1 = 1
    elif i == "b":
        c2 = 1
    elif i == "c":
        c3 = 1
if c1 == 1 and c2 == 1 and c3 == 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a = list(input())
if a[0] == a[1] or a[1] == a[2] or a[2] == a[0]:
    print("No")
else:
    print("Yes")
n=int(input())
t=[0]*n+1
x=[0]*n+1
y=[0]*n+1
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i]
  if a<0 or a%2==1:
    d='No'
    break
print(d)

### FIXED CODE ###

n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
t[0],x[0],y[0]=0,0,0
for i in range(1,n+1):
  t[i],x[i],y[i]=map(int, input().split())
d='Yes'
for i in range(n):
  a=t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
  if a<0 or a%2==1:
    d='No'
    break
print(d)
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
else:

    ans = 1
    i = 0
    while (ans < 10 ** 18):
        ans *= a[i]
        i += 1

    if i == n - 1:
        print(ans)
    else:
        print(-1)


### FIXED CODE ###

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

if 0 in a:
    print(0)
else:

    ans = 1
    i = 0
    while (i <= n - 1):
        if ans <= 10 ** 18:
            ans *= a[i]
            i += 1
        else:
            break

    #print(i)
    if ans <= 10 ** 18:
        print(ans)
    else:
        print(-1)
def main():
    n = int(input())
    *v, = map(int, input().split())

    v0 = assemble(v[::2])
    v1 = assemble(v[1::2])

    if len(v0) == 1 and len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(n // 2)
        else:
            print(0)
        return
    elif len(v0) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v1, 0))
        else:
            print(sum_v(v1, 1))
        return
    elif len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v0, 0))
        else:
            print(sum_v(v0, 1))

    score = [[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            score[i][j] = sum_v(v0, i) + sum_v(v1, j)
            if v0[i][0] == v1[j][0]:
                score[i][j] = 10 ** 9
    print(min([min(s) for s in score]))


def assemble(v):
    dct = {}
    for vel in v:
        if vel in dct:
            dct[vel] += 1
        else:
            dct[vel] = 1
    return sorted(list(dct.items()), key=lambda x: x[1], reverse=True)


def sum_v(v, ii):
    return sum([vv[1] for i, vv in enumerate(v) if i != ii])


main()


### FIXED CODE ###

def main():
    n = int(input())
    *v, = map(int, input().split())

    v0 = assemble(v[::2])
    v1 = assemble(v[1::2])

    if len(v0) == 1 and len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(n // 2)
        else:
            print(0)
        return
    elif len(v0) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v1, 1))
        else:
            print(sum_v(v1, 0))
        return
    elif len(v1) == 1:
        if v0[0][0] == v1[0][0]:
            print(sum_v(v0, 1))
        else:
            print(sum_v(v0, 0))
        return

    score = [[0, 0], [0, 0]]
    for i in range(2):
        for j in range(2):
            score[i][j] = sum_v(v0, i) + sum_v(v1, j)
            if v0[i][0] == v1[j][0]:
                score[i][j] = 10 ** 9
    print(min([min(s) for s in score]))


def assemble(v):
    dct = {}
    for vel in v:
        if vel in dct:
            dct[vel] += 1
        else:
            dct[vel] = 1
    return sorted(list(dct.items()), key=lambda x: x[1], reverse=True)


def sum_v(v, ii):
    return sum([vv[1] for i, vv in enumerate(v) if i != ii])


main()
import sys

while True:
	x = input()
	num, ans = [], []
	if x == 0: break
	else:
		for j in xrange(x):
			num.append(input())
		for j in xrange(x):
			if num[j] > 0:
				for k in xrange(j + 1,x + 1):
# 					print num[j:k]
# 					print sum(num[j:k])
 					ans.append(sum(num[j:k]))
			else:
				pass
		print max(ans)

### FIXED CODE ###

while True:
    n = input()
    if n == 0: break
    a = [ input() for i in xrange(n) ]
    m = -100000
    for i in xrange(n):
        s = 0
        for j in xrange(i, n):
            s += a[j]
            m = max(m, s)
    print m
A,V = map(int,input().split()) 
B,W = map(int,input().split())
T = int(input())
P = 0
if (-10**9 <= A <= 10**9) and (-10**9 <= B <= 10**9) and (1 <= V <= 10**9) \
and  (1 <= W <= 10**9) and (1 <= T <= 10**9) and (A != B) and type(A) == int and\
type(B) == int and type(V) == int and type(W) == int and type(T) == int:
    
    while P != T: 
        if A > B:
            A -= V
            B -= W
            P+=1
        
        elif A < B:
            A += V
            B += W
            P+=1

        else:
            print("YES")
            break
    
    if A != B:
        print("NO")


### FIXED CODE ###

import random

name = str(input())
a = len(name)

if  3<= a <= 20:
    b = random.randint(0,a-3) 
    
    ada_1 = name[b]
    ada_2 = name[b+1]
    ada_3 = name[b+2]
    
    print(ada_1+ada_2+ada_3)
else:
    None
n,m=(int(i) for i in input().split(' '))
i=m%n
if m==2147483647:
  print(1)
  exit()
while True:
  if i==1:
    print(i)
    break
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1


### FIXED CODE ###

import random

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

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