input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
a_sorted = sorted(a)
a_v = list(Counter(a_sorted).values())
a_k = list(Counter(a_sorted).keys())
count_max = a_v[0]
for i in range(1, len(a_v)):
count = 0
if a_k[i] - a_k[i - 1] == 1:
count += a_v[i -... | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
a_c = Counter(sorted(a))
a_v = list(a_c.values())
a_k = list(a_c.keys())
count_max = a_v[0]
for i in range(1, len(a_v)):
count = 0
if a_k[i] - a_k[i - 1] == 1:
count += a_v[i - 1]
if i < (len(a_v... | p03611 |
N = int(eval(input()))
a = list(map(int, input().split()))
num = [0 for i in range(3)]
num[0] = a.count(0)
num[1] = a.count(1)
ans = 0
for X in range(1, 100000):
num[(X % 3) - 2] = a.count(X + 1)
ans = max(ans, sum(num))
print(ans)
| N = int(eval(input()))
a = list(map(int, input().split()))
num = [0 for i in range(100000)]
for aa in a:
num[aa] += 1
ans = 0
for X in range(1, 99999):
ans = max(ans, sum(num[X-1:X+2]))
print(ans)
| p03611 |
from collections import defaultdict
N = eval(input())
counts = defaultdict(int)
values = set()
for a in map(int, input().split()):
counts[a] += 1
values.add(a)
ans = 0
for x in values:
ans = max(ans, counts[x - 1] + counts[x] + counts[x + 1])
print(ans)
| from collections import defaultdict
_ = eval(input())
counts = defaultdict(int)
for a in map(int, input().split()):
counts[a] += 1
counts[a - 1] += 1
counts[a + 1] += 1
print((max(counts.values())))
| p03611 |
from collections import defaultdict
N = eval(input())
a_raw = list(map(int, input().split()))
a_plus = [num + 1 for num in a_raw]
a_minus = [num - 1 for num in a_raw]
numbers = set(a_raw) | set(a_minus) | set(a_plus)
num_count = list()
for number in numbers:
num_count.append(a_raw.count(number) + a_plus.cou... | from collections import defaultdict as dd
N = eval(input())
a_raw = list(map(int, input().split()))
num_count = dd(int)
for item in a_raw:
num_count[item] += 1
num_count[item-1] += 1
num_count[item+1] += 1
print((max(num_count.values()))) | p03611 |
def main():
_ = int(eval(input()))
A = [int(i) for i in input().split()]
A.sort()
from collections import Counter, defaultdict
c = defaultdict(int)
for k, v in list(Counter(A).items()):
c[k] = v
ans = 0
for i in range(10**5+1):
if i != 0:
cur = c[i]... | def main():
_ = int(eval(input()))
A = [int(i) for i in input().split()]
from collections import Counter, defaultdict
c = defaultdict(int)
for k, v in list(Counter(A).items()):
c[k] = v
ans = 0
for i in range(max(A) + 1):
if i != 0:
cur = c[i] + c[i-1] +... | p03611 |
def main():
_ = int(eval(input()))
A = [int(i) for i in input().split()]
from collections import Counter, defaultdict
c = defaultdict(int)
for k, v in list(Counter(A).items()):
c[k] = v
ans = 0
for i in range(max(A) + 1):
if i != 0:
cur = c[i] + c[i-1] +... | def main():
N = int(eval(input()))
A = [int(i) for i in input().split()]
max_A = max(A)
counts = [0] * (max_A + 2)
for a in A:
if a > 0:
counts[a-1] += 1
counts[a] += 1
counts[a+1] += 1
print((max(counts)))
if __name__ == '__main__':
main()... | p03611 |
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
numcnt = {i:0 for i in range(100001)}
for i in a:
numcnt[i]+=1
for x in range(1,100000):
subans = numcnt[x-1]+numcnt[x]+numcnt[x+1]
ans = max(ans,subans)
print(ans) | N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
numcnt = [0]*100001
for i in a:
numcnt[i]+=1
for x in range(1,100000):
subans = numcnt[x-1]+numcnt[x]+numcnt[x+1]
ans = max(ans,subans)
print(ans) | p03611 |
N = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(1,100000):
cnt =0
for x in a:
if abs(i-x) <= 1:
cnt += 1
ans = max(ans,cnt)
print(ans) | import collections
N = int(eval(input()))
a = list(map(int,input().split()))
dic = collections.Counter(a)
ans = 0
for i in range(min(a),max(a)+1):
cnt = dic[i-1]+dic[i]+dic[i+1]
ans = max(ans,cnt)
print(ans) | p03611 |
n = int(eval(input()))
a = [int(i) for i in input().split()]
cnt_a = [0] * (10**5 + 2)
for i in range(n):
cnt_a[a[i]] += 1
max_cnt = 0
for i in range(1, 10**5 + 1):
max_cnt = max(max_cnt, sum(cnt_a[i - 1:i + 2]))
print(max_cnt) | n = int(eval(input()))
a = [int(i) for i in input().split()]
cnt_x = [0] * (10**5 + 2)
for i in range(n):
cnt_x[a[i] - 1] += 1
cnt_x[a[i]] += 1
cnt_x[a[i] + 1] += 1
print((max(cnt_x))) | p03611 |
n = int(eval(input()))
a = list(map(int,input().split(" ")))
mmax = max(a)
mmin = min(a)
mcount = 0
for i in range(mmin, mmax + 1):
count = 0
count += a.count(i)
count += a.count(i + 1)
count += a.count(i - 1)
if mcount < count:
mcount = count
print(mcount)
| n = int(eval(input()))
a = list(map(int,input().split(" ")))
c_dic = {}
for i in a:
if i not in c_dic:
c_dic[i] = 1
else:
c_dic[i] += 1
if i + 1 not in c_dic:
c_dic[i + 1] = 1
else:
c_dic[i + 1] += 1
if i - 1 not in c_dic:
c_dic[i - 1] =... | p03611 |
def main():
N = int(eval(input()))
a = list(map(int, input().split()))
ans = [0] * (10 ** 5 + 1)
for X in range(10 ** 5 + 1):
if X == 0:
ans[0] += a.count(0)
ans[0] += a.count(1)
elif X == 10 ** 5:
ans[10 ** 5] += a.count(10 ** 5 - 1)
ans[10 ** 5] += a.count(10 ** 5 + 1)
else:
a... | def main():
N = int(eval(input()))
a = list(map(int, input().split()))
a_lst = [0] * (10 ** 5 + 1)
for num in a:
a_lst[num] += 1
ans = 0
for X in range(10 ** 5 + 1):
cnt = 0
if X == 0:
cnt += a_lst[X]
cnt += a_lst[X + 1]
elif X == 10 ** 5:
cnt += a_lst[X - 1]
cnt += a_lst[... | p03611 |
from collections import defaultdict
n = int(eval(input()))
a_lis = list(map(int,input().split()))
A_dict = defaultdict(int)
for i in a_lis:
A_dict[i] += 1
max_cnt = 0
for j in range(1, 10**5):
tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
max_cnt = max(max_cnt, tmp)
print(max_cnt) | from collections import defaultdict
n = int(eval(input()))
ans = 0
a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)
for i in a_lis:
A_dict[i] += 1
for j in range(1,10**5):
tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
if tmp > ans:
ans = tmp
print(ans) | p03611 |
from collections import defaultdict
n = int(eval(input()))
ans = 0
a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)
for i in a_lis:
A_dict[i] += 1
for j in range(1,10**5):
tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
if tmp > ans:
ans = tmp
print(ans) | def main():
n = int(eval(input()))
ans = 0
a_lis = list(map(int,input().split()))
A_dict = [0]*(10**5+1)
for i in a_lis:
A_dict[i] += 1
for j in range(1,10**5):
tmp = A_dict[j-1]+A_dict[j]+A_dict[j+1]
if tmp > ans:
ans = tmp
print(ans)
if __name__=='__main__':
main() | p03611 |
n = int(eval(input()))
a = list(map(int, input().split()))
w = max(a) - min(a) + 3
abucket = [0] * w
for i in range(n):
abucket[a[i] - min(a)] += 1
abucket[a[i] - 1 - min(a)] += 1
abucket[a[i] + 1 - min(a)] += 1
print((max(abucket))) | n = int(eval(input()))
a = list(map(int, input().split()))
mina = min(a)
maxa = max(a)
w = maxa - mina + 3
abucket = [0] * w
for i in range(n):
abucket[a[i] - mina] += 1
abucket[a[i] - 1 - mina] += 1
abucket[a[i] + 1 - mina] += 1
print((max(abucket))) | p03611 |
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
def count(i):
res = 0
for x in a[i:]:
if x - a[i] <= 1:
res += 1
for y in a[:i]:
if a[i] - y <= 1:
res += 1
return res
for i in range(n):
ans = max(ans,count(i))
print(... | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
s = [0]*(a[-1]+1)
for i in range(n):
s[a[i]] += 1
ans = 0
if a[-1] - 1 > 0:
for i in range(1,a[-1]):
ans = max(ans, s[i] + s[i-1] + s[i+1])
print(ans)
else:
print((max(s))) | p03611 |
from collections import Counter
N = int(eval(input()))
A = Counter(list(map(int, input().split())))
cnt = 0
for i in A:
sums = A[i] + A[i+1] + A[i+2]
if sums > cnt:
cnt = sums
print(cnt) | N = int(eval(input()))
a = list(map(int, input().split()))
x = [0]*((10**5) + 2)
for i in a:
x[i+1] += 1
x[i] += 1
x[i+2] += 1
print((max(x))) | p03611 |
import collections
n = int(eval(input()))
a = list(map(int, input().split()))
a_processed = []
for i in a:
a_processed[n:n] = [i-1, i, i+1]
print((a_processed.count(collections.Counter(a_processed).most_common()[0][0])))
| n = int(eval(input()))
a = list(map(int, input().split()))
ans_l = [0]*(10**5 + 2)
for i in a:
ans_l[i-1] += 1
ans_l[i] += 1
ans_l[i+1] += 1
print((max(ans_l)))
| p03611 |
N = int(eval(input()))
L = list(map(int, input().split()))
res = 0
for i in range(10**5):
count = L.count(i) + L.count(i+1) + L.count(i+2)
if count > res:
res = count
print(res) | N = int(eval(input()))
L = list(map(int, input().split()))
K = [ 0 for i in range(10**5)]
for i in range(N):
K[L[i]] += 1
a = []
res = 0
for i in range(len(K)):
a.append(K[i])
if len(a) > 3:
a.pop(0)
if sum(a) > res:
res =sum(a)
print(res) | p03611 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
count_a = Counter(a)
result = []
for i in range(min(a),max(a)+1):
result.append(count_a[i]+count_a[i-1]+count_a[i+1])
print((max(result))) | from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
set_a = list(set(a))
#set_a = sorted(set_a)
count_a = Counter(a)
result = []
for i in set_a:
result.append(count_a[i]+count_a[i-1]+count_a[i+1])
print((max(result))) | p03611 |
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
c = []
for i in A:
c.extend([i-1,i,i+1])
ans = Counter(c).most_common()
print((ans[0][1])) | N = int(eval(input()))
A = list(map(int, input().split()))
d = {}
for a in A:
d[a-1] = d.setdefault(a-1,0) + 1
d[a] = d.setdefault(a,0) + 1
d[a+1] = d.setdefault(a+1,0) + 1
print((max(d.values()))) | p03611 |
N = int(eval(input()))
a = [int(i) for i in input().split()]
Min = min(a)-1
Max = max(a)+1
num = [[0 for i in range(N)] for j in range(Min, Max+1)]
idx = 0
for i in a:
num[i-Min-1][idx] = 1
num[i-Min][idx] = 1
num[i-Min+1][idx] = 1
idx += 1
ct = -1
for i in num:
tmp = i.count(1)
... | N = int(eval(input()))
a = [int(i) for i in input().split()]
Min = min(a)-1
Max = max(a)+1
ans = [0 for i in range(Min, Max+1)]
for i in a:
ans[i-Min-1] += 1
ans[i-Min] += 1
ans[i-Min+1] += 1
print((max(ans)))
| p03611 |
N = int(eval(input()))
a = list(map(int,input().split()))
count = [0]*(10**5+1)
ans = 0
for X in range(10**5+2):
for i in range(N):
if X == a[i] or X == a[i]+1 or X == a[i]-1:
count[X] += 1
ans = max(count)
print(ans) | import collections
N = int(eval(input()))
a = list(map(int,input().split()))
count = []
ans = 0
for i in range(N):
count.append(a[i]-1)
count.append(a[i])
count.append(a[i]+1)
ans = max(collections.Counter(count).values())
print(ans) | p03611 |
n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
ans = 1
dic = {}
for i in range(10**5):
dic[i] = 0
for i in a:
dic[i] += 1
for i in range(1,10**5-1):
ans = max(ans, dic[i-1] + dic[i] + dic[i+1])
print(ans) | n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = [0] * 10**5
ans = 1
if n == 2:
if abs(a[0] - a[1]) <= 2:
ans = 2
for i in range(n):
b[a[i]] += 1
for i in range(n-2):
ans = max(ans, b[i]+b[i+1]+b[i+2])
print(ans) | p03611 |
N = int(eval(input()))
P = list(map(int,input().split()))
cnt = 0
tmp = []
for i in range(N):
for j in range(N):
if P[i] - 1 <= P[j] <= P[i] + 1:
cnt += 1
tmp.append(cnt)
cnt = 0
print((max(tmp))) | N = int(eval(input()))
A = list(map(int, input().split()))
ans = [0] * (max(A) + 2)
for a in A:
if a == 0:
ans[a] += 1
ans[a + 1] += 1
if a != 0:
ans[a - 1] += 1
ans[a] += 1
ans[a + 1] += 1
print((max(ans))) | p03611 |
#
# abc072 c
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
ou... | #
# abc072 c
#
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
ou... | p03611 |
#ABC 072 C
N=int(eval(input()))
A=[int(j) for j in input().split()]
cnt=[0]*(10**6)
for a in A:
cnt[a]+=1
cnt[a+1]+=1
cnt[a+2]+=1
print((max(cnt))) | #ABC 072 C
N=int(eval(input()))
A=[int(j) for j in input().split()]
cnt=[0]*(10**5+10)
for a in A:
cnt[a]+=1
cnt[a+1]+=1
cnt[a+2]+=1
print((max(cnt))) | p03611 |
n=int(eval(input()))
a=list([int(x) for x in input().split()])
ans=0
for i in range(2,100000):
tmp = a.count(i-1)+a.count(i)+a.count(i+1)
if ans < tmp:
ans=tmp
print(ans) | n=int(eval(input()))
a=list([int(x) for x in input().split()])
dic={}
for i in a:
dic[i]=dic.get(i,0)+1
tmp=dic.get(0,0)+dic.get(1,0)
ans=0
for i in range(2,100000):
tmp+=dic.get(i,0)
if tmp>ans:
ans=tmp
tmp-=dic.get(i-2,0)
print(ans) | p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
num = [A.count(A[i]) + A.count(A[i]-1) + A.count(A[i]+1) for i in range(N)]
print((max(num))) | N = int(eval(input()))
A = list(map(int, input().split()))
maximum = max(A)
count = [0]*(maximum + 2)
for i in range(N):
if A[i] == 0:
count[0] += 1
count[1] += 1
elif A[i] == maximum:
count[A[i]] += 1
count[A[i] - 1] += 1
else:
count[A... | p03611 |
N = int(eval(input()))
inlis = list(map(int,input().split()))
donelis =[]
numlis=[]
for i in inlis:
donelis.append(i+1)
donelis.append(i)
donelis.append(i-1)
if not i in numlis:
numlis.append(i)
if not i+1 in numlis:
numlis.append(i+1)
if not i-1 in numlis:
... | n = int(eval(input()))
inlis = list(map(int,input().split()))
donelis =[]
numlis=[]
for i in inlis:
donelis.append(i+1)
donelis.append(i)
donelis.append(i-1)
estc =0
donelis.sort()
a = -2
count=0
for i in donelis:
if a != i:
if count > estc:
estc = count
c... | p03611 |
n = int(eval(input()))
a = list(map(int,input().split()))
#dics min max
dicsmin = min(a)
dicsmax = max(a)
counter = []
for i in range(dicsmin,dicsmax + 1):
xcount = 0
x = i
for k in range(len(a)):
if a[k] == x or a[k] == x-1 or a[k] == x + 1:
xcount = xcount + 1
c... | n = int(eval(input()))
a = list(map(int,input().split()))
aa = []
amax = max(a) + 100
for i in range(amax + 1):
aa.append(0)
for i in range(len(a)):
aa[a[i]] = aa[a[i]] + 1
kouho = 1
for j in range(len(aa) - 2):
if kouho < aa[j] + aa[j + 1] + aa[j + 2]:
kouho = aa[j] + aa[... | p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(100000):
B = [j for j in A if i-1 <= j <= i+1]
if ans < len(B):
ans = len(B)
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
A.sort()
a=0
b=0
c=1
for i in range(N-1):
if A[i] == A[i+1]:
a += 1
b += 1
c += 1
elif A[i]+1 == A[i+1]:
if ans < a:
ans = a
a = b
a += 1
b = c
b += 1
c = 1
elif A[i]+2 == A[i+1]:
... | p03611 |
N = int(eval(input()))
A = [int(i) for i in input().split()]
check = [0] * (10**5+1)
check[0] = A.count(0)+A.count(1)
for i in range(1, 10**5+1):
check[i] = check[i-1] - A.count(i-2) + A.count(i+1)
print((max(check))) | import bisect
N = int(eval(input()))
A = sorted([int(i) for i in input().split()])
ans = 0
for i in set(A):
l = bisect.bisect_left(A, i-1)
r = bisect.bisect_right(A, i+1)
ans = max(ans, r-l)
print(ans) | p03611 |
from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
counter += Counter([i-1,i,i+1])
print((counter.most_common(1)[0][1])) | from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
counter[i-1] += 1
counter[i] += 1
counter[i+1] += 1
print((counter.most_common(1)[0][1]))
| p03611 |
import copy
N = int(eval(input()))
a = [int(x) for x in input().split()]
a.sort()
ans = 1
for i in range(len(a)):
cnt = 1
b = copy.deepcopy(a)
rm = a[i]
b.remove(rm)
cnt += b.count(rm-1)+b.count(rm+1)
ans = max(ans, cnt)
print(ans) | N = int(eval(input()))
a = [int(x) for x in input().split()]
memo = [0]*(10**5+2)
ans = 1
for i in range(N):
memo[a[i]] += 1
memo[a[i]+1] += 1
memo[a[i]-1] += 1
print((max(memo))) | p03611 |
N = int(eval(input()))
a = list(map(int,input().split()))
amin = min(a)
amax = max(a)
suma = []
for i in range(amin,amax+1):
sumb = a.count(i) + a.count(i-1) + a.count(i+1)
suma.append(sumb)
print((max(suma))) | import bisect
N = int(eval(input()))
a = sorted(list(map(int,input().split())))
amin = a[0]
amax = a[-1]
suma = []
for i in range(amin,amax+1):
sumb = bisect.bisect_right(a,i+1) - bisect.bisect_left(a,i-1)
suma.append(sumb)
print((max(suma))) | p03611 |
import bisect
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
ans = 1
def search(A,a,b):
import bisect
ans = bisect.bisect_right(A,b) - bisect.bisect_left(A,a)
return ans
for i in range(A[-1]+1):
ans = max(ans,search(A,i-1,i+1))
print(ans) | import bisect
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
ans = 1
for i in range(A[-1]+1):
ans = max(ans,bisect.bisect_right(A,i+1) - bisect.bisect_left(A,i-1))
print(ans) | p03611 |
N = int(eval(input()))
a_lst = [int(x) for x in input().split()]
max_a = -1
max_cnt = -1
for a in a_lst:
if max_a < a:
max_a = a
for x in range(max_a + 1):
cnt = 0
for a in a_lst:
if x - 1 <= a and a <= x + 1:
cnt += 1
if max_cnt < cnt:
max_cnt = cnt
... | N = int(eval(input()))
a_lst = [int(x) for x in input().split()]
dict = {}
for a in a_lst:
if not a - 1 in list(dict.keys()):
dict[a - 1] = 1
else:
dict[a - 1] += 1
if not a in list(dict.keys()):
dict[a] = 1
else:
dict[a] += 1
if not a + 1 in list(dict... | p03611 |
N=int(eval(input()))
A=list(map(int,input().split()))
max_x=max(A)+2
min_x=min(A)-1
l=set()
for x in range(min_x,max_x):
cnt=0
for a in A:
if abs(x-a)<=1:
cnt+=1
l.add(cnt)
print((max(l))) | N=int(eval(input()))
A=list(map(int,input().split()))
ans=[0]*(max(A)+3)
for a in A:
ans[a-1]+=1
ans[a]+=1
ans[a+1]+=1
print((max(ans))) | p03611 |
n = int(eval(input()))
ls = list(map(int, input().split()))
ls_plus1 = list([x + 1 for x in ls])
ls_minus1 = list([x - 1 for x in ls])
dic = {}
for a in ls_minus1 + ls + ls_plus1:
dic[a] = dic.get(a, 0) + 1
print((sorted(dic.values())[-1]))
| n = int(eval(input()))
ls = list(map(int, input().split()))
ls_plus1 = list([x + 1 for x in ls])
ls_minus1 = list([x - 1 for x in ls])
dic = {}
for a in ls_minus1 + ls + ls_plus1:
dic[a] = dic.get(a, 0) + 1
print((max(dic.values())))
| p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A)
a_min = min(A)
dummy = -float("inf")
for x in range(a_min, a_max+1):
cnt = 0
A_replace = [l for l in A if l -1 <= x and l + 1 >= x]
if dummy < len(A_replace):
dummy = len(A_replace)
ans = dummy
print(ans... | N = int(eval(input()))
A = list(map(int, input().split()))
a_max = max(A)
a_min = min(A)
cnt_dict = {}
for i in range(a_min-1, a_max+2):
cnt_dict[i] = 0
for i in range(len(A)):
cnt_dict[A[i]-1] += 1
cnt_dict[A[i]] += 1
cnt_dict[A[i]+1] += 1
print((max(list(cnt_dict.items()), key = lambd... | p03611 |
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
num_count = [0]*(10**5+1)
for x in a:
num_count[x] += 1
for i in range(10**5+1):
if i+2<=10**5:
ans = max(ans,sum(num_count[i:i+3]))
pr... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
num_count = [0]*(10**5+2)
for x in a:
num_count[x-1] += 1
num_count[x] += 1
num_count[x+1] += 1
print((max(num_count)))
| p03611 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for x in range(min(a), max(a)+1):
res = c[x] + c[x+1] + c[x-1]
ans = max(ans, res)
print(ans) | n=int(eval(input()))
a=list(map(int,input().split()))
data=[0]*(10**5+2)
for i in a:
data[i]+=1
data[i+1]+=1
data[i+2]+=1
print((max(data))) | p03611 |
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
for i in range(1,100001):
tmp=0
tmp+=a.count(i-1)
tmp+=a.count(i)
tmp+=a.count(i+1)
if tmp>ans:
ans=tmp
print(ans) | n=int(eval(input()))
b=[0 for i in range(100002)]
a=list(map(int,input().split()))
a.sort()
for i in range(n):
b[a[i]]+=1
ans=0
for i in range(1,100001):
tmp=b[i-1]+b[i]+b[i+1]
if tmp>ans:
ans=tmp
print(ans) | p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 0
for i in range(1, 10**5-2):
if ans < A.count(i) + A.count(i+1) + A.count(i+2):
ans = A.count(i) + A.count(i+1) + A.count(i+2)
print(ans) | def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
count = [0] * 10 ** 5
for i in A:
if i > 1:
count[i - 1] += 1
count[i] += 1
if i < 10**5-1:
count[i + 1] += 1
print((max(count)))
resolve() | p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
m = {}
for a in sorted(set(A)):
m[a] = A.count(a)
r = 0
for n in m:
t = m[n]
if n + 1 in m:
t += m[n + 1]
if n + 2 in m:
t += m[n + 2]
r = max(r, t)
print(r)
| N = int(eval(input()))
A = list(map(int, input().split()))
m = {}
for a in A:
if a not in m:
m[a] = 1
else:
m[a] += 1
r = 0
for n in m:
t = m[n]
if n + 1 in m:
t += m[n + 1]
if n + 2 in m:
t += m[n + 2]
r = max(r, t)
print(r)
| p03611 |
import collections
N = int(eval(input()))
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
num = cand_list[i][0]
count = cand[num]
if num + 1 in a:
count += cand[num + 1]
if num - 1 in a:
count +=... | import collections
N = int(eval(input()))
a = list(map(int, input().split()))
cand = collections.Counter(a)
cand_list = cand.most_common(len(set(a)))
ans = 0
for i in range(len(set(a))):
num = cand_list[i][0]
count = cand[num] + cand[num + 1] + cand[num - 1]
ans = max(ans,count)
print(ans) | p03611 |
#import sys
#input = sys.stdin.readline
n=int(eval(input()))
a=[int(i) for i in input().split()]
#print(a)
ans=0
if n==1:
ans=1
else:
for i in range(1,100000+1):
cnt=0
for j in a:
if j==i or j==i-1 or j==i+1:
cnt+=1
if ans <= cnt:
ans = cnt
print(ans)
| from collections import Counter
#tmp_list = [1, 1, 1, 1, 0, 1, 1]
n=int(eval(input()))
a=[int(i) for i in input().split()]
b=[i-1 for i in a]
c=[i+1 for i in a]
d=a+b+c
counter = Counter(d)
print((counter.most_common()[0][1]))
| p03611 |
n=int(eval(input()))
a=list(map(int,input().split()))
at=list(set(a))
ans=0
for i in range(len(at)):
cnt=0
for j in range(n):
if a[j]==at[i] or a[j]==at[i]+1 or a[j]==at[i]-1:
cnt=cnt+1
ans=max(ans,cnt)
print(ans) | n=int(eval(input()))
a=list(map(int,input().split()))
temp=[0]*(max(a)+1)
for i in range(n):
temp[a[i]]=temp[a[i]]+1
ans=0
if max(a)==0 or max(a)==1:
print(n)
else:
for i in range(1,max(a)):
ans=max(ans,temp[i-1]+temp[i]+temp[i+1])
print(ans) | p03611 |
N = int(eval(input()))
a = list(map(int, input().split()))
A = []
for i in range(N):
A.append(a[i]-1)
A.append(a[i])
A.append(a[i]+1)
ans = 0
for a in A:
if ans < A.count(a):
ans = A.count(a)
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
oldi = 0
m = a[0]
M = 0
ans = 0
if N == 1:
ans = 1
for i in range(1, N):
M = a[i]
while M - m > 2:
oldi += 1
m = a[oldi]
if i - oldi + 1 > ans:
ans = i - oldi + 1
print(ans)
| p03611 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
A_p1 = [a+1 for a in A]
A_m1 = [a-1 for a in A]
cnt = Counter(A_p1)
cnt += Counter(A)
cnt += Counter(A_m1)
print((max(list(cnt.values())))) | import sys
stdin = sys.stdin
def li(): return list(map(int, stdin.readline().split()))
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return list(map(float, stdin.readline().split()))
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return... | p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
B = [0] * len(A)
C = [0] * len(A)
for i in range(len(A)):
B[i] = A[i] + 1
C[i] = A[i] - 1
t= 0
m = 0
for X in range(1 ,10 ** 5 + 1):
t = A.count(X) + B.count(X) + C.count(X)
m = max(m,t)
print(m) | N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+1)
for a in As:
nums[a]+=1
for i in range(1,len(nums)):
if i == len(nums)-1:
t = nums[i - 1] + nums[i]
else:
t = nums[i-1]+nums[i]+nums[i+1]
c = max(c,t)
print(c)
| p03611 |
N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+1)
for a in As:
nums[a]+=1
for i in range(1,len(nums)):
if i == len(nums)-1:
t = nums[i - 1] + nums[i]
else:
t = nums[i-1]+nums[i]+nums[i+1]
c = max(c,t)
print(c)
| N = int(eval(input()))
As = list(map(int,input().split()))
c = 0
nums = [0]*(10**5+2)
for a in As:
nums[a]+=1
for i in range(1,len(nums)-1):
t = nums[i-1]+nums[i]+nums[i+1]
c = max(c,t)
print(c)
| p03611 |
from bisect import bisect_right
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
cmax = 0
for i in range(N):
a = A[i]
ind = bisect_right(A,a+2)
cmax = max(cmax,ind-i)
print(cmax) | N = int(eval(input()))
A = list(map(int,input().split()))
C = {}
for i in range(N):
if A[i] not in C:
C[A[i]] = 0
C[A[i]] += 1
cmax = 0
for a in A:
cnt = C[a]
if a-1 in C:
cnt += C[a-1]
if a+1 in C:
cnt += C[a+1]
cmax = max(cmax,cnt)
print(cmax) | p03611 |
def main():
n=eval(input())
a=tuple(map(int,input().split()))
cnt=[0]*(pow(10,5)+2)
for i in a:
cnt[i-1]+=1
cnt[i]+=1
cnt[i+1]+=1
print((max(set(cnt))))
if __name__=='__main__':
main() | def main():
import sys
input = sys.stdin.readline
n=eval(input())
a=tuple(map(int,input().split()))
cnt=[0]*(pow(10,5)+2)
for i in a:
cnt[i-1]+=1
cnt[i]+=1
cnt[i+1]+=1
print((max(set(cnt))))
if __name__=='__main__':
main() | p03611 |
def main():
import sys
input = sys.stdin.readline
n=eval(input())
a=tuple(map(int,input().split()))
cnt=[0]*(pow(10,5)+2)
for i in a:
cnt[i-1]+=1
cnt[i]+=1
cnt[i+1]+=1
print((max(set(cnt))))
if __name__=='__main__':
main() | def main():
import sys
input = sys.stdin.readline
n=eval(input())
a=tuple(map(int,input().split()))
cnt=[0]*(max(a)+3)
for i in a:
cnt[i]+= 1
x,y,z=cnt,cnt[1:],cnt[2:]
print((max(list(map(sum,list(zip(x,y,z)))))))
if __name__=='__main__':
main() | p03611 |
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
cur = a[0]
ans1 = 1
ans = 1
for i in range(n - 1):
if a[i + 1] - a[i] <= 2:
cur = a[i]
ans1 = a.count(cur) + a.count(cur + 1) + a.count(cur + 2)
if ans < ans1:
ans = ans1
ans1 = 0
pri... | n = int(eval(input()))
a = list(map(int, input().split()))
max_a = max(a)
b = [0]*(max_a + 2)
for i in a:
b[i] += 1
ans = 0
for i in range(max_a + 1):
tmp = b[i-1] + b[i] + b[i+1]
ans = max(ans, tmp)
print(ans) | p03611 |
def main():
n = int(eval(input()))
a = list(map(int,input().split()))
lst = [0 for i in range(n*3)]
for i in range(n):
lst[3*i] = a[i]
lst[3*i+1] = a[i]+1
lst[3*i+2] = a[i]+2
ans = -1
for i in set(lst):
ans = max(lst.count(i),ans)
print(ans)... |
def main():
n = int(eval(input()))
a = list(map(int,input().split()))
#lst = [0 for i in range(n*3)]
ans_lst = [0 for i in range(max(a)+4)]
"""
for i in range(n):
lst[3*i] = a[i]
lst[3*i+1] = a[i]+1
lst[3*i+2] = a[i]+2
"""
for i in a:
ans... | p03611 |
n = int(eval(input()))
a = [int(x) for x in input().split()]
ans = 0
for x in range(100000):
cnt = 0
for elem in a:
if elem == x-1 or elem == x or elem == x + 1:
cnt += 1
ans = max(ans, cnt)
print(ans)
| n = int(eval(input()))
a = [int(x) for x in input().split()]
counta = [0 for _ in range(100000)]
ans = 0
for elem in a:
counta[elem] += 1
for x in range(1, 100000 - 1):
ans = max(ans, counta[x-1] + counta[x] + counta[x+1])
print(ans)
| p03611 |
from bisect import*
n = int(eval(input()))
*a,=list(map(int,input().split()))
a.sort()
ans = 0
for i in range(1,10**5):
ans = max(ans,bisect(a,i+1)-bisect_left(a,i-1))
print(ans) | from bisect import*;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(bisect(a,i+1)-bisect(a,i-2) for i in range(10**5)))) | p03611 |
from bisect import*;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(bisect(a,i+1)-bisect(a,i-2) for i in range(10**5)))) | from bisect import*;b=bisect;n,a=open(0);*a,=sorted(map(int,a.split()));print((max(b(a,i)-b(a,i-3)for i in range(10**5)))) | p03611 |
from collections import Counter
def solve():
ans = 0
N = int(eval(input()))
A = list(map(int, input().split()))
c = Counter(A)
for i in range(1,10**5-1):
cnt = 0
if i-1 in c:
cnt += c[i-1]
if i in c:
cnt += c[i]
if i+1 in c:
... | def solve():
ans = 0
N = int(eval(input()))
A = list(map(int, input().split()))
lis = [0]*(10**5+2)
for i in range(N):
lis[A[i]-1] += 1
lis[A[i]] += 1
lis[A[i]+1] += 1
ans = max(lis)
return ans
print((solve())) | p03611 |
from collections import Counter
c = Counter()
N = int(eval(input()))
for x in input().split():
c[int(x)] += 1
A_uniq = sorted(c.keys())
def gen_candiate(seq):
s = set()
for n in seq:
s.add(n-1)
s.add(n)
s.add(n+1)
return sorted(s)
result = 0
for n in gen_c... | N=int(eval(input()))
an=sorted(list(map(int,input().split())))
dic={}
for ai in an:
if ai not in dic:dic[ai]=1
else:dic[ai]+=1
pass
max_v=0
for x in range(an[0],an[-1]+1):
v=0
if x-1 in dic: v+=dic[x-1]
if x in dic: v+=dic[x]
if x+1 in dic: v+=dic[x+1]
max_v=max(max_v,v)
print(max_v) | p03611 |
N = int(eval(input()))
a = [int(i) for i in input().split()]
i = 0
b = []
while i <= 100000:
n = a.count(i)
b.append(n)
i += 1
l = len(b)
j = 1
c = []
while j < l-1:
nn = b[j-1]+b[j]+b[j+1]
c.append(nn)
j += 1
print((max(c))) | N = int(eval(input()))
A = list(map(int, input().split()))
dic = {}
for nums in A:
if nums in dic:
dic[nums] += 1
else:
dic[nums] = 1
if nums-1 in dic:
dic[nums-1] += 1
else:
dic[nums-1] = 1
if nums+1 in dic:
dic[nums+1] += 1
else:
dic[nums+1] = 1
b = list(dic.values(... | p03611 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for i in range(100000):
ans = max(C[i] + C[i-1] + C[i+1], ans)
print(ans)
| from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
C = Counter(A)
ans = 0
for i in range(max(A)+1):
ans = max(C[i] + C[i-1] + C[i+1], ans)
print(ans)
| p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for X in range(1, 10 ** 5 + 2):
cnt = 0
for i in range(N):
if X - 1 <= A[i] <= X + 1:
cnt += 1
ans = max(ans, cnt)
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
count = [0] * (10 ** 5 + 1)
for a in A:
count[a] += 1
ans = 0
for i in range(1, 10 ** 5):
X = count[i-1] + count[i] + count[i+1]
ans = max(ans, X)
print(ans) | p03611 |
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
# 0が混ざってる場合に対応して、1ずつ足しておく
a = [i+1 for i in a]
# 10**5だと99999がコーナーケースになる
l = [0] * 10 ** 6
# いもす法
for i in a:
l[i-1] += 1
l[i+2] -= 1
b = accumulate(l)
print((max(list(b)))) | from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i+1 for i in a]
imos = [0] * (10**5 + 3)
for i in a:
imos[i-1] += 1
imos[i+2] -= 1
i = accumulate(imos)
print((max(i)))
| p03611 |
from itertools import accumulate
n = int(eval(input()))
a = list(map(int, input().split()))
a = [i+1 for i in a]
imos = [0] * (10**5 + 3)
for i in a:
imos[i-1] += 1
imos[i+2] -= 1
i = accumulate(imos)
print((max(i)))
| N = int(eval(input()))
A = list(map(int, input().split()))
A = [i + 1 for i in A]
bucket = [0] * (10 ** 5 + 10)
for a in A:
bucket[a - 1] += 1
bucket[a] += 1
bucket[a+1] += 1
print((max(bucket))) | p03611 |
N = int(eval(input()))
a = list(map(int, input().split()))
a_set = set(a)
# aiの各値の個数を数える
a_dict = {}
for i in a_set:
a_dict[i] = a.count(i)
ans = 0
for i in range(1, 10 ** 5):
work = 0
if (i - 1) in a_set:
work += a_dict[i - 1]
if i in a_set:
work += a_dict[i]
if (i... | N = int(eval(input()))
a = list(map(int, input().split()))
# ある値がaに存在するとき、その+ー1の値を足す
## ans_list[-1]となる場合向けにlistは1個余分に値を設けておく
ans_list = [0] * (10 ** 5 + 2)
for i in a:
ans_list[i] += 1
ans_list[i + 1] += 1
ans_list[i - 1] += 1
ans = max(ans_list)
print(ans)
| p03611 |
N = int(eval(input()))
a = list(map(int, input().split()))
b = [a.count(i) for i in range(10 ** 5 + 1)]
ans = 0
for i in range(1, 10 ** 5):
ans = max(ans, b[i-1] + b[i] + b[i+1])
print(ans) | N = int(eval(input()))
a = list(map(int, input().split()))
b = [0 for i in range(10 ** 5 + 1)]
d = {}
for key in a:
if key in d:
d[key] += 1
else:
d[key] = 1
ans = 0
for i in range(10 ** 5 + 1):
if i in d:
b[i] = d[i]
for i in range(1, 10 ** 5):
ans = max(ans,... | p03611 |
# C
n = int(eval(input()))
l = list(map(int, input().split()))
m = 0
for i in range(1, 10**5):
if m < l.count(i-1)+l.count(i)+l.count(i+1):
m = l.count(i-1)+l.count(i)+l.count(i+1)
print(m) | # C
n = int(eval(input()))
a = list(map(int, input().split()))
l = [0]*(10**5+10)
for i in range(n):
l[a[i]] += 1
s = 0
for j in range(1, len(l)-1):
if s < l[j-1] + l[j] + l[j+1]:
s = l[j-1] + l[j] + l[j+1]
print(s) | p03611 |
from collections import Counter
eval(input())
A = list(map(int, input().split()))
C = Counter(A)
def get(i): return C[i] if i in C else 0
print((max(sum(get(x) for x in range(i-1,i+2)) for i in range(10**5)))) | N,*A=list(map(int, open(0).read().split()))
C=[0]*(10**5+5)
for a in A:
C[a-1]+=1
C[a]+=1
C[a+1]+=1
print((max(C[i] for i in range(10**5+1))))
| p03611 |
from collections import Counter
n = int(eval(input()))
a = list(map(int,input().split()))
ac = Counter(a)
m = max(a)
ans = 0
for i in range(1,m+10):
ans = max(ans, ac[i-1]+ac[i]+ac[i+1])
print(ans) | from collections import Counter
n = int(eval(input()))
a = list(map(int,input().split()))
ac = Counter(a)
m = max(a)
ans = 0
for i in range(m+1):
ans = max(ans, ac[i-1]+ac[i]+ac[i+1])
print(ans) | p03611 |
N = int(eval(input()))
A = (10**5+2)*[0]
for a in map(int,input().split()):
A[a-1]+=1
A[a]+=1
A[a+1]+=1
print((max(A))) | N = int(eval(input()))
A = 100002*[0]
for a in map(int,input().split()):
A[a-1]+=1
A[a]+=1
A[a+1]+=1
print((max(A))) | p03611 |
from collections import Counter
N = int(eval(input()))
src = list(map(int,input().split()))
ctr = Counter(src)
mx = max(src)
ans = 0
for i in range(mx+1):
ans = max(ans, ctr[i] + ctr[i+1] + ctr[i+2])
print(ans)
| N = int(eval(input()))
src = list(map(int,input().split()))
mem = [0] * (10**5+2)
for a in src:
mem[a] += 1
mem[a+1] += 1
mem[a+2] += 1
print((max(mem))) | p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
ans = 0
for i in range(10**5):
tmp = ctr[i-1] + ctr[i] + ctr[i+1]
ans = max(ans,tmp)
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
ans = 0
for i in range(10**5+1):
t = ctr[i-1] + ctr[i] + ctr[i+1]
ans = max(ans,t)
print(ans) | p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
ans = 0
for i in range(10**5+1):
t = ctr[i-1] + ctr[i] + ctr[i+1]
ans = max(ans,t)
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
from collections import Counter
ctr = Counter(A)
ans = 0
for x in range(10**5+2):
t = ctr[x-1] + ctr[x] + ctr[x+1]
ans = max(t,ans)
print(ans) | p03611 |
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
X = []
for k in a:
X.append(k+1)
X.append(k)
X.append(k-1)
for i in X:
tmplist = []
for j in a:
tmplist.append(i-j)
if cnt < tmplist.count(1) + tmplist.count(0) + tmplist.count(-1):
cnt ... | # 辞書を用意して最大値を取得する
N = int(eval(input()))
a = list(map(int, input().split()))
cnt = {}
for i in a:
for j in [-1,0,1]:
cnt.setdefault(i+j, 0)
cnt[i+j] += 1
print((max(cnt.values()))) | p03611 |
n = int(eval(input()))
a = list(map(int, input().split()))
num_list = [0] * (max(a) + 2)
for i in range(n):
num_list[a[i]] += 1
if i == n:
continue
elif a[i] == 0:
continue
else:
num_list[a[i]-1] += 1
if i == 0 or a[i] == max(a):
continue
else:
... | n = int(eval(input()))
a = list(map(int, input().split()))
t = max(a)
num_list = [0] * (t + 2)
for i in range(n):
num_list[a[i]] += 1
if a[i] == 0:
continue
else:
num_list[a[i]-1] += 1
if a[i] == t:
continue
else:
num_list[a[i]+1] += 1
print((max(n... | p03611 |
n=int(eval(input()))
ans=0
hoge=list(map(int,input().split()))
for i in range(100000):
huga=hoge.count(i-1)+hoge.count(i)+hoge.count(i+1)
if(huga>=ans):
ans=huga
print(ans) | n=int(eval(input()))
hoge=list(map(int,input().split()))
huga=[0]*(10**5+1)
for i in hoge:
if(i==10**5):
huga[i-1]+=1
huga[i]+=1
elif(i==0):
huga[i]+=1
huga[i+1]+=1
else:
huga[i-1]+=1
huga[i]+=1
huga[i+1]+=1
print((max(huga))) | p03611 |
from collections import Counter
N = int(eval(input()))
input_list = sorted([int(i) for i in input().split()])
inupt_dict = (Counter(input_list))
result = 0
input_dict_keys = list(inupt_dict.keys())
if N == 1:
result = 1
elif N == 2 and input_list[0] == input_list[1]:
result = 2
elif N == 2 and inp... | from collections import Counter
N = int(eval(input()))
input_list = sorted([int(i) for i in input().split()])
inupt_dict = (Counter(input_list))
result = 0
input_dict_keys = list(inupt_dict.keys())
if N == 1:
result = 1
elif N == 2 and input_list[0] == input_list[1]:
result = 2
elif N == 2 and inp... | p03611 |
import collections
N = int(eval(input()))
a = (list(map(int, input().split())))
for i in range(N):
a.append(a[i] - 1)
a.append(a[i] + 1)
c = collections.Counter(a)
print((c.most_common()[0][1]))
| N = int(eval(input()))
a = list(map(int, input().split()))
A = [0] * (10 ** 5 + 5)
for ai in a:
A[ai - 1] += 1
A[ai] += 1
A[ai + 1] += 1
print((max(A))) | p03611 |
from collections import Counter
N = int(eval(input()))
A = list(map(int,input().split()))
C = Counter(A)
ans = 0
for i in range(10**5):
c = C[i-1] + C[i] + C[i+1]
ans = max(c,ans)
print(ans) | import collections
n = int(eval(input()))
a = list(map(int,input().split()))
lst = collections.defaultdict(int)
for i in a:
lst[i] += 1
lst[i-1] += 1
lst[i+1] += 1
lst = sorted(list(lst.items()),reverse=True,key=lambda x:x[1])
print((lst[0][1])) | p03611 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
ca = Counter(a)
maxa = a[-1]
mina = a[0]
ans = 0
for i in range(mina, maxa+1):
cnt = sum([v for k, v in list(ca.items()) if i - 1 <= k <= i + 1])
if ans < cnt:
ans = cnt
print(ans) | eval(input())
C = [0] * 100002
for i in map(int, input().split()):
C[i - 1] += 1
C[i] += 1
C[i + 1] += 1
print((max(C))) | p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
setA = set(A)
ans = 0
c = 0
for x in setA:
for a in A:
if a == x-1 or a == x or a == x+1:
c += 1
ans = max(ans, c)
c = 0
print(ans) | N = int(eval(input()))
A = list(map(int, input().split()))
DA = {}
for a in A:
if a in list(DA.keys()):
DA[a] += 1
else:
DA[a] = 1
ans = 0
c = 0
for k, v in list(DA.items()):
c += v
if k+1 in DA:
c += DA[k+1]
if k-1 in DA:
c += DA[k-1]
ans = ma... | p03611 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
ans = 0
c = Counter(a).most_common()
for i in range(min(a), max(a) + 1):
temp = [value if abs(i - key) <= 1 else 0 for key, value in c]
ans = max(ans, sum(temp))
print(ans)
| from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
x = []
for i in a:
x.append(i)
x.append(i + 1)
x.append(i - 1)
ans = max(Counter(x).values())
print(ans)
| p03611 |
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in range(0, 10**5+1):
count = 0
for j in l:
if j == i or j == i+1 or j == i-1:
count += 1
if count > ans:
ans = count
print(ans) | n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
count = {}
for i in range(0, 10**5+1):
count[i] = 0
for i in l:
count[i] = count[i] + 1
for i in range(0, 10**5+1):
if i == 0:
temp = count[i] + count[i+1]
elif i == 10**5:
temp = count[i] + count[i-1]
else:
temp ... | p03611 |
from sys import stdin
import sys
import math
n = int(eval(input()))
#a = list(map(int, stdin.readline().rstrip().split()))
a = sorted(list(map(int, stdin.readline().rstrip().split())))
count_max = 1
count_prev = 0
count_curr = 1
count_next = 0
current_value = a[0]
for i in range(1, n):
if a[i]... | from sys import stdin
import sys
import math
n = int(eval(input()))
a = list(map(int, stdin.readline().rstrip().split()))
dict_count = {}
for i in a:
dict_count[i] = 0
for j in a:
dict_count[j] += 1
#print(dict_count)
max_count = 0
for key in list(dict_count.keys()):
max_count = max... | p03611 |
n = int(eval(input()))
a = list(map(int, input().split()))
ans = [0 for _ in range(10**5 + 2)]
for i in a:
ans[i] += 1
ans[i+1] += 1
ans[i-1] += 1
print((max(ans))) | n = int(eval(input()))
l = list(map(int,input().split()))
l0 = [0]*(10**5+2)
for i in l:
l0[i] += 1
l0[i+1] += 1
l0[i-1] += 1
print((max(l0))) | p03611 |
N = int(eval(input()))
A = list(map(int, input().split()))
count_list = []
for i in range(10**5):
count_list.append(A.count(i))
Max = 0
for i in range(10**5-2):
Max = max(Max, count_list[i]+count_list[i+1]+count_list[i+2])
print(Max)
| N = int(eval(input()))
A = list(map(int, input().split()))
count_list = [0]*10**5
for i in range(N):
count_list[A[i]] += 1
Max = 0
for i in range(10**5-2):
Max = max(Max, count_list[i]+count_list[i+1]+count_list[i+2])
print(Max)
| p03611 |
from collections import Counter
N = int(eval(input()))
a = list(map(int, input().split()))
for i in range(N):
a.append(a[i]+1)
a.append(a[i]-1)
ans = Counter(a)
print((ans.most_common()[0][1])) | from collections import defaultdict
n = int(eval(input()))
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
d[x] += 1
d[x - 1] += 1
d[x + 1] += 1
result = [y for x, y in list(d.items())]
print((max(result))) | p03611 |
from collections import defaultdict
n = int(eval(input()))
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
d[x] += 1
d[x - 1] += 1
d[x + 1] += 1
result = [y for x, y in list(d.items())]
print((max(result))) | from collections import defaultdict
n = int(eval(input()))
arr = list(map(int, input().split()))
d = defaultdict(int)
for x in arr:
d[x] += 1
a = d[0] + d[1] + d[2]
ans = [a]
for i in range(max(arr) - 2):
a -= d[i]
a += d[i + 3]
ans.append(a)
print((max(ans))) | p03611 |
n=int(eval(input()))
a=list(map(int,input().split()))
ans=0
r=a[:]
r.extend([i-1 for i in a])
r.extend([i+1 for i in a])
for i in set(r):
x=0
for ai in a:
if ai==i or ai-1==i or ai+1==i:
x+=1
ans=max(ans,x)
print(ans) | n=int(eval(input()))
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
if i!=0:
an[i-1]+=1
an[i+1]+=1
an[i]+=1
print((max(an))) | p03611 |
N=int(eval(input()))
A=list(map(int,input().split()))
number_of_items=[]
for X in range(min(A)-1, max(A)+1):
number_of_items.append(A.count(X)+A.count(X-1)+A.count(X+1))
print((max(number_of_items))) | N=int(eval(input()))
A=list(map(int,input().split()))
bucket=[0]*(max(A)+1)
answer=0
for number in A:
bucket[number]+=1
if len(bucket)<3:
answer=sum(bucket)
for i in range(1,max(A)):
candidate=bucket[i-1]+bucket[i]+bucket[i+1]
if candidate>answer:
answer=candidate
print(answer) | p03611 |
N = int(eval(input()))
A = [int(i) for i in input().split()]
max_count = 0
for X in range(1, 10**5):
count = 0
for i in A:
if X-1 <= i <= X+1:
count += 1
if count > max_count:
max_count = count
print(max_count) | N = int(eval(input()))
A = [int(i) for i in input().split()]
A_count = [0] * (max(A)+1)
for i in A:
A_count[i] += 1
max_count = 0
if len(A_count) < 4:
print((sum(A_count)))
else:
for X in range(1, len(A_count)-1):
count = A_count[X-1] + A_count[X] + A_count[X+1]
if count > max... | p03611 |
N = int(eval(input()))
A = list(map(int,input().split()))
nums = [0]*(10**5+10)
for a in A:
nums[a] += 1
nums[a-1] += 1
nums[a+1] += 1
print((max(nums))) | N = int(eval(input()))
A = list(map(int,input().split()))
result = [0]*(10**5+10)
for a in A:
result[a] += 1
result[a-1] += 1
result[a+1] += 1
print((max(result))) | p03611 |
N = int(eval(input()))
a = [int(c) for c in input().split()]
#ループしてX候補を求める
ma = 0
tmp = 0
for i in range(N):
tmp = a.count(a[i]-1)+a.count(a[i])+a.count(a[i]+1)
if ma < tmp:
ma = tmp
print(ma) | N = int(eval(input()))
a = sorted([int(c) for c in input().split()])
#2回の変わり目を記憶
c1,c2,c3 = [0,0,0]
ma = 1
for i in range(N):
if i > 0:
if a[i]==a[i-1]+1:
c1 = c2
c2 = c3
c3 = i
elif a[i]!=a[i-1]:
c1,c2,c3=[i,i,i]
if ma < i - c1+1:
... | p03611 |
n = int(eval(input()))
a_list = list(map(int, input().split()))
nums = set(a_list)
r_list = [0]*(10**5+2)
for n in nums:
count = a_list.count(n)
r_list[n] += count
r_list[n+1] += count
if n > 0:
r_list[n-1] += count
print((max(r_list))) | n = int(eval(input()))
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
r_list[n] += 1
r_list[n+1] += 1
if n > 0:
r_list[n-1] += 1
print((max(r_list))) | p03611 |
n = int(eval(input()))
a = list(map(int,input().split()))
check = [0]*((10**5)+1)
for i in a:check[i] += 1
ans = check[0] + check[1]
for i in range(len(check)-2):ans = max(ans,check[i]+check[i+1]+check[i+2])
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
count = [0]*(10**5+5)
for v in a:
count[v] += 1
maxX = 0
maxV = 0
for i in range(10**5+1):
val = count[i-1] + count[i] + count[i+1]
if val > maxV:
maxV = val
maxX = i
print(maxV) | p03611 |
import collections
n = int(eval(input()))
m = list(map(int,input().split()))
zen = m
cou = 0
for x in range(n):
zen.append(m[x]-1)
for x in range(n):
zen.append(m[x]+1)
a = collections.Counter(zen)
for k in range(n):
if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] -1... | import collections
n = int(eval(input()))
m = list(map(int,input().split()))
zen = m
cou = 0
for x in range(n):
zen.append(m[x]-1)
for x in range(n):
zen.append(m[x]+1)
a = collections.Counter(zen)
#for k in range(n):
# if a.most_common()[0][0] == m[k] or a.most_common()[0][0] == m[k] ... | p03611 |
from collections import Counter
def main()->None:
N = int(eval(input()))
a = list(map(int, input().split()))
a_dict = Counter(a)
keys = list(a_dict.keys())
max_count = 0
for key in keys:
tmp_count = 0
for i in keys:
if key + 1 == i or key - 1 == i or k... | import sys
def main()->None:
N = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
max_a = max(a)
# print(max_a)
l = [0 for _ in range(max_a+2)] # 配列の初期化、固定長、位置が配列の数字で要素がカウント
for i in a:
l[i] += 1
res = 0
for i in range(0, max_a+1):
... | p03611 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.