Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03998 (python)

Fixed submission:
#オブジェクト指向忘れてた
#関数内は別物、参照作成なので
#def next_turn(s):
#    s0=s[0]
#    s=s[1:]
#    return s0

sa=input()
sb=input()
sc=input()

k=sa[0]
sa=sa[1:]
while True:
    #print(sa)
    #print(sb)
    #print(sc)
    if k=="a":
        if len(sa)==0:
            print("A")
            break
        else:
            k=sa[0]
            sa=sa[1:]
    elif k=="b":
        if len(sb)==0:
            print("B")
            break
        else:
            k=sb[0]
            sb=sb[1:]
    else:
        if len(sc)==0:
            print("C")
            break
        else:
            k=sc[0]
            sc=sc[1:]

Buggy submission (verdict: Runtime Error):
s=[input() for i in range(3)]
l=[len(s[i]) for i in range(3)]
abc=[0,0,0]
now=0
while True:
    if len(now)==abc[now]:
        break
    s_sub=s[now][abc[now]]
    now=(0 if s_sub=="a" else 1 if s_sub=="b" else 2)
    abc[now]+=1
print("A" if now==0 else "B" if now==1 else "C")
Problem p04032 (python)

Fixed submission:
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
s1=list(input())
l=len(s1)
s2=groupby(s1)
now=0
for i in s2:
    now+=i[1]
    if i[1]!=1:
        print(str(now-i[1]+1)+" "+str(now))
        break
else:
    if l==2:
        print("-1 -1")
    else:
        for i in range(l-2):
            if s1[i]==s1[i+2]:
                print(str(i+1)+" "+str(i+3))
                break
        else:
            print("-1 -1")

Buggy submission (verdict: Runtime Error):
import exit from sys
s=input()
l=len(s)
for i in range(l-2):
    if s[i]==s[i+2]:
        print(str(i+1)+" "+str(i+3))
        exit()
    if s[i]==s[i+1]:
        print(str(i+1)+" "+str(i+2))
        exit()
if s[l-2]==s[l-1]:
    print(str(l-1)+" "+str(l))
else:
    print("-1 -1")
Problem p02706 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=sum(A)

if N>=B:
    print(N-B)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))

if N>=sum(A):
    print(N-A)
else:
    print(-1)
Problem p03086 (python)

Fixed submission:
s=input()

tmp=0
length=[]

for i in range(len(s)):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        tmp+=1
        if i==len(s)-1:
            length.append(tmp)
    else:
        length.append(tmp)
        tmp=0
print(max(length))

Buggy submission (verdict: Runtime Error):
s=input()

tmp=0
length=[]

for i in range(len(s)):
    if s[i]=="A" or s[i]=="C" or s[i]=="G" or s[i]=="T":
        tmp+=1
    else:
        length.append(tmp)
        tmp=0
print(max(length))
Problem p02582 (python)

Fixed submission:
w=input()
count=0

if w=="SSS":
 print(0)
if w=="SSR":
 print(1)
if w=="SRR":
 print(2)
if w=="RRS":
 print(2)
if w=="RSR":
 print(1)
if w=="SRS":
 print(1)
if w=="RSS":
 print(1)
if w=="RRR":
 print(3)

Buggy submission (verdict: Runtime Error):
import numpy

e=input().split()
for i in range(len(e)):
  e[i]=int(e[i])
x=e[0]
k=e[1]
d=e[2]
t=k
if k>10000:
 if k%2==0:
   t=10000
 else:
   t=10001
kou=numpy.gcd(x,d)
x=int(x/kou)
d=int(d/kou)
if d>100 and d%2==0:
  d=100
if d>100 and d%2==1:
  d=1001
for i in range(t):
  if abs(x+d)<abs(x-d):
    x+=d
  else:
    x-=d
print(abs(x)*kou)
Problem p02612 (python)

Fixed submission:
N=int(input())

for i in range(10):
 if N>1000:
  N-=1000
 if N<1000:
  break

print(1000-N)

Buggy submission (verdict: Runtime Error):
for i in range(10):
 if N>1000:
  N-=1000
 if N<1000:
  break

print(1000-N)
Problem p02899 (python)

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

lis=[0]*n

for i in range(1,n+1):
    caca=int(a[i-1])
    lis[caca-1]=i

print(' '.join(map(str, lis)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

for i in range(1,n+1):
    caca=int(a[i-1])
    lis[caca-1]=i

print(' '.join(map(str, lis)))
Problem p02939 (python)

Fixed submission:
s=input()
l=len(s)
S=str()

cnt=0
ck=0

for i in range(l):
    if ck==l-1:
        if s[ck]==S:
            break
        else:
            cnt+=1
        break
    if i==0:
        cnt=cnt+1
        S=s[0]
        ck+=1
        continue
    if s[ck]==S:
        S=s[ck]+s[ck+1]
        ck=ck+2
        cnt=cnt+1
        if ck==l:
            break
        else:
            continue
    if s[ck]!=S:
        S=s[ck]
        ck=ck+1
        cnt=cnt+1
        continue

print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
S=str()

cnt=0
ck=0
for i in range(l):
    if ck==l-1:
        if s[ck]==S:
            break
        else:
            cnt+=1
        break
    if i==0:
        cnt=cnt+1
        S=s[0]
        ck+=1
        continue
    if s[ck]==S:
        S=s[ck]+s[ck+1]
        ck=ck+2
        cnt=cnt+1
        continue
    if s[ck]!=S:
        S=s[ck]
        ck=ck+1
        cnt=cnt+1
        continue

print(cnt)
Problem p02958 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))

c=0
d=0
for i in range(n):
    if p[i]==i+1:
        continue
    else:
        c=c+1
        if c>=3:
            break
        if d==0:
            d=i+1
            continue
        if d!=0:
            if d!=p[i]:
                c=3
                break

if c<=2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=map(int,input().split())

c=0
for i in range(1,n):
    if p[i-1]>p[i]:
        c=c+1

if c<=1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
p=map(int,input().split())

c=0:
for i in range(1,n):
    if p[i-1]>p[i]:
        c=c+1

if c<=1:
    print("YES")
else:
    print("NO")
Problem p02996 (python)

Fixed submission:
import numpy as np

n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())

A=np.array(b)
c=A.argsort()

time=0

for i in range(n):
    time=time+a[c[i]]
    if time>b[c[i]]:
        print('No')
        break
    if i==n-1 and time<=b[c[i]]:
        print('Yes')

Buggy submission (verdict: Runtime Error):
import numpy as np

n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())

A=np.array(b)
c=A.argsort()

time=0

for i in range(n):
    time=time+a[c[i]]
    if time>b[c[i]]:
        print('No')
        break
    if i==n-1 and time<=b[c[i]]:
        print('Yes')
Problem p03085 (python)

Fixed submission:
a=input()

if a=="A" or "T":
    if a=="T":
        b="A"
    if a=="A":
        b="T"

if a=="C" or "G":
    if a=="C":
        b="G"
    if a=="G":
        b="C"

print(b)

Buggy submission (verdict: Runtime Error):
a=input()

if a="A" or "T":
    if a=="T":
        b="A"
    if a=="A":
        b="T"

if a="C" or "G":
    if a=="C":
        b="G"
    if a=="G":
        b="C"

print(b)
Problem p02665 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

B = []

if N == 0:
    if A[0] != 1:
        print(-1)
        exit()
    else:
        print(1)
        exit()

else:
    if A[0] != 0:
        print(-1)
        exit()
    else:
        B.append(1)
        for i in range(1, N + 1):
            B.append((B[i - 1] - A[i - 1]) * 2)
            if (A[i] > B[i] or (A[i] == B[i] and i != N)):
                print(-1)
                exit()

        ans = 0
        ans += A[N]
        B[N] = A[N]
        for i in range(N - 1, -1, -1):
            ans += min(B[i], B[i + 1] + A[i])
            B[i] = min(B[i], B[i + 1] + A[i])

        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N + 1);
  for (auto &it : A)
    cin >> it;
  vector<ll> th(N + 1);
  if (N == 0)
  {
    if (A[0] != 1)
    {
      cout << -1 << endl;
      return 0;
    }
    else
    {
      cout << 1 << endl;
      return 0;
    }
  }
  else
  {
    if (A[0] != 0)
    {
      cout << -1 << endl;
      return 0;
    }
    else
    {
      th[0] = 1;
      for (int i = 1; i < N + 1; i++)
      {
        th[i] = min(INF / 2, (th[i - 1] - A[i - 1]) * 2);
        if (A[i] > th[i] || (A[i] == th[i] && i != N))
        {
          cout << -1 << endl;
          return 0;
        }
      }
      ll ans = 0;
      ans += A[N];
      th[N] = A[N];
      for (int i = N - 1; i >= 0; i--)
      {
        ans += min(th[i], th[i + 1] + A[i]);
        th[i] = min(th[i], th[i + 1] + A[i]);
      }
      cout << ans << endl;
    }
  }
  return 0;
}

// 下から見ていく

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

B = []

if N == 0:
    if A[0] != 1:
        print(-1)
        exit()
    else:
        print(1)
        exit()

else:
    if A[0] != 0:
        print(-1)
        exit()
    else:
        B.append(1)
        for i in range(1, N + 1):
            B.append((B[i - 1] - A[i - 1]) * 2)
            if (A[i] > B[i] or (A[i] == B[i] and i != N)):
                print(-1)
                exit()

        ans = 0
        ans += A[N]
        B[N] = A[N]
        for i in range(N, -1, -1):
            ans += min(B[i], B[i + 1] + A[i])
            B[i] = min(B[i], B[i + 1] + A[i])

        print(ans)
        exit()
Problem p03035 (python)

Fixed submission:
A,B = map(int,input().split())
if A<=5:
  print(0)
elif A<=12:
  print(B//2)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().sprit())
if A<=5:
  print(0)
elif A<=12:
  print(B//2)
else:
  print(B)
Problem p02909 (python)

Fixed submission:
if __name__ == '__main__':
    weathers = [
        'Sunny',
        'Cloudy',
        'Rainy'
    ]

    s = str(input())

    index = 0
    next_index = 0

    for w in weathers:
        if w == s:
            next_index = (index + 1) % 3
            break
        else:
            index += 1

    print(weathers[next_index])

Buggy submission (verdict: Runtime Error):
weathers = [
   'Sunny',
   'Cloudy',
   'Rainy'
]

  s = str(input())

  index = 0
  next_index = 0

  for w in weathers:
    if w == s:
      next_index = (index + 1) % 3
      break
      else:
        index += 1

  print(weathers[next_index])

Buggy submission (verdict: Runtime Error):
weathers = [
        'Sunny',
        'Cloudy',
        'Rainy'
    ]

    s = str(input())

    index = 0
    next_index = 0

    for w in weathers:
        if w == s:
            next_index = (index + 1) % 3
            break
        else:
            index += 1

    print(weathers[next_index])
Problem p02553 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
ac = a*c
ad = a*d
bc = b*c
bd = b*d

if ac>ad and ac>bc and ac>bd:
  print(ac)
elif ad >bc and ad>bd and ad>ac:
  print(ad)
elif bc>ac and bc>ad and bc>bd:
  print(bc)
else:
  print(bd)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(10**n-9**n-8**n-9**n)
Problem p02554 (python)

Fixed submission:
n = int(input())
if n == 1:
  print(0)
  exit()

print((10**n-9**n+8**n-9**n)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(10**n=9**n-8**n-9**n)
Problem p02576 (python)

Fixed submission:
import math
z,x,t=map(int, input().split())

ans =math.ceil(z/x)*t
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%9 == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
z, x, t = map(int, input().split())

ans = math.ceil(z/x)*t
Problem p02582 (python)

Fixed submission:
s = input()

if 'RRR' in s:
  print(3)
elif 'RR' in s:
  print(2)
elif 'R' in s:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
s = input()

if 'RRR' in s:
  ans == 3
elif 'RR' in s:
  ans = 2
elif 'R' in s:
  ans = 1
else:
  ans = 0

print(str(ans))

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
if s == 'RSR':
  ans == 1
else:
  for i in s:
  if i == 'R':
    ans +=1

print(ans)
Problem p02628 (python)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans = 0


p.sort()

for i in range(k):
  ans += p[i]

print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list[]
ans = 0

for i in range (n):
  p[i] = int(input())

p.sort()

for i in range(k):
  ans += p[i]

print(ans)
Problem p02639 (python)

Fixed submission:
x= list(map(int,input().split()))

for i in range(5):
  if x[i] == 0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())

if y%2 == 0 and x*2<=y<=x*4:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x= list(map(int,input().split()))

for i in range(%):
  if x[i] == 0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
x= list(map(int,input().split()))
for i in x:
  if x[i] == 0:
    print(i+1)
Problem p02640 (python)

Fixed submission:
x,y = map(int,input().split())

if y%2 == 0 and x*2 <=y <=x*4:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())

if y%2 == 0 and x*2=<y<=x*4:
  print('Yes')
else:
  print('No')
Problem p02641 (python)

Fixed submission:
X,N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]:
    a = X + s * d
    if p.count(a) == 0:
      print(a)
      exit(0)

Buggy submission (verdict: Runtime Error):
N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
  for s in [-1, +1]:
    a = X + s * d
    if p.count(a) == 0:
      print(a)
      exit(0)
Problem p02658 (python)

Fixed submission:
n = input()
a = list(map(int,input().split()))
ans = 1
t = False

for i in a:
  if i == 0:
    ans = 0
    t = True

if t != True:
  for i in a:
    ans *=i
    if ans>10**18:
      ans = -1
      break
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int,input().split()))
ans = 1
for i in a:
  ans *=i
  if ans>10**18:
  ans = -1
  break

print(ans)
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m= map(int, input().split())

hr = 30*h+0.5*m
mr = 6*m
ans = a**2+b**2-2*a*b*math.cos(math.radians(hr-mr))
print(math.sqrt(ans))

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m = map(int,input().split())
t = h*60+m
mt = 720
rh = math.radians(t/60/720)
rm = math.radians()
r= rh-rm
print(rh)
Problem p02700 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
while a>0 and b>0:
  a-=d
  c-=b

if a <= 0 and c<=0:
  print('Yes')
elif c <= 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,cd = map(int,input().split())
while a>=0 and b>=0:
  b-=c
  d-=a
if d == 0 and b==0:
  print('Yes')
elif b == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c.d = map(int,input().split())
while a>=0 and b>=0:
  b-=c
  d-=a
if a == 0 and b==0:
  print('Yes')
elif b == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c.d = map(int,input().split())
while a>=0 ans b>=0:
  b-=c
  d-=a
if a == 0 and b==0:
  print('Yes')
elif b == 0:
  print('Yes')
else:
  print('No')
Problem p02765 (python)

Fixed submission:
n,r=map(int,input().split())
ans = r
if n<10:
  ans = r+100*(10-n)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
print(math.ceil(n/2))
Problem p02630 (python)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
cnt = collections.Counter(A)
Q = int(input())
ans = []
s = sum(A)
for _ in range(Q):
    b, c = map(int, input().split())
    n = cnt[b]
    if b in cnt:
        cnt[c] += cnt[b]
        del cnt[b]
    s += (c-b)*n
    print(s)

Buggy submission (verdict: Runtime Error):
mport sys
N = int(input())
A = list(map(int, input().split()))
Q = int(input())


for q in range(Q):
    b, c = map(int, input().split())
    for n in range(N):
        if b == A[n]:
            A[n] = c
    print(sum(A))
Problem p02646 (python)

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

a = V*T+A
b = W*T+B

if V > W:
    if abs(A-B)/(V-W) <= T:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

a = V*T+A
b = W*T+B

if V >= W:
    if abs(A-B)/(V-W) <= T:
        print("YES")
    else:
        print("NO")
else:
    print("NO")
Problem p02683 (python)

Fixed submission:
import itertools as it

N,M,X=map(int,input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	bag = [0] * (M+1)
	for i in range(N):
		if comb[i] == 0:
			continue
		else:
			for j in range(M+1):
				bag[j]+=book[i][j]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print(-1)
else:
	print(min(prices))

Buggy submission (verdict: Runtime Error):
from operator import sub, add
import sys
N, M, X = map(int, input().split())
AC = []
for _ in range(N):
    AC.append(list(map(int, input().split())))

S = [sum(x) for x in zip(*AC)]
s = [sum(x) for x in zip(*AC)]
for m in range(1, M+1):
    if s[m] < X:
        print(-1)
        sys.exit(0)
        
AC.sort(reverse=True)        
for n in range(N):
    ac = AC[n]
    s = list(map(sub, s, ac))
    for m in range(1, M+1):
        if s[m] < X:
            s = list(map(add, s, ac))
            break
            
print(min(S, s[0]))
Problem p02719 (python)

Fixed submission:
#coding:utf-8

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

r1 = n % k
r2 = abs(k - r1)

ans = min(r1,r2)

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

if abs(N-K) < N:
    if N >= K:
        if K/(N%K) >= 1:
            print(K%(N%K))
        else:
            print(N % K)
    else:
        if N/(K%N) >= 1:
            print(N%(K%N))
        else:
            print(K % N)
else:
    print(N)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

if N >= K:
    print(N % K)
else:
    print(K % N)
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

cnt = 1
mini = P[0]
for i in range(1, N):
    if P[i] <= mini:
        mini = P[i]
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))

cnt = 1
after = [P[i-1] for i in range(1, N)]
for a in after:
    if a < P[i]:
        break
else:
    cnt += 1
print(cnt)
Problem p02924 (python)

Fixed submission:
N = int(input())
print((N-1)*N//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(range(1, N+1))

M = []
for i in range(1, N+1):
    m = list(map(lambda x : i%x, P))
    #print(m)
    M.append(max(m))
    #print(m.index(max(m)))
    del P[m.index(max(m))]
print(sum(M))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(range(1, N+1))

M = []
for i in range(1, N+1):
    m = [i%x for x in P]
    M.append(max(m))
    del P[m.index(max(m))]
print(sum(M))
Problem p03485 (python)

Fixed submission:
import math
a,b=map(int,input().split())
x = (int(a) + int(b)) / 2
print(math.ceil(x))

Buggy submission (verdict: Runtime Error):
import math
a = input()
b = input()
x = (int(a) + int(b)) / 2
print(math.ceil(x))
Problem p03523 (python)

Fixed submission:
import sys
S = list(input())

L = list("KIHBR")
for l in L:
    if not l in "".join(S):
        print("NO")
        sys.exit(0)

N = []
for i in range(len(S)-1):
    if S[i] == "H" or S[i] == "B" or S[i] == "R":
        if S[i+1] != "A":
            N.append(i+1)

i = 0
for n in N:
    S.insert(n+i, "A")
    i += 1
    
if "".join(S) in "AKIHABARA":
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
import sys
S = list(input())

L = list("KIHBR")
for l in L:
    if not l in "".join(S):
        print("NO")
        sys.exit(0)

        N = []
for i in range(len(S)-1):
    if S[i] == "H" or S[i] == "B" or S[i] == "R":
        if S[i+1] != "A":
            N.append(i+1)

i = 0
for n in N:
    S.insert(n+i, "A")
    i += 1
    
if "".join(S) in "AKIHABARA":
    print("YES")
else:
    print("NO")
Problem p03611 (python)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    sys.exit(0)
    
cnt = [0 for _ in range(10**5+1)]
for a in A:
    if a == 0:
        cnt[a] += 1
        cnt[a+1] += 1
    else:
        cnt[a-1] += 1
        cnt[a] += 1
        cnt[a+1] += 1
    
print(max(cnt))

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    sys.exit(0)
    
cnt = [0 for _ in range(10**5)]
for a in A:
    if a == 0:
        cnt[a] += 1
        cnt[a+1] += 1
    else:
        cnt[a-1] += 1
        cnt[a] += 1
        cnt[a+1] += 1
    
print(max(cnt))
Problem p03695 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

cnt = [0]*8
c = 0
for a in A:
    if a <= 399:
        cnt[0] += 1
    elif a >= 400 and a <= 799:
        cnt[1] += 1
    elif a >= 800 and a <= 1199:
        cnt[2] += 1
    elif a >= 1200 and a <= 1599:
        cnt[3] += 1
    elif a >= 1600 and a <= 1999:
        cnt[4] += 1
    elif a >= 2000 and a <= 2399:
        cnt[5] += 1
    elif a >= 2400 and a <= 2799:
        cnt[6] += 1
    elif a >= 2800 and a <= 3199:
        cnt[7] += 1
    else:
        c += 1
        
Min = len([i for i in cnt if i != 0])
if c == 0:
    print(Min, Min)
else:
    Max = Min+c
    if Min == 0:
        print(1, Max)
    else:
        print(Min, Max)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

cnt = [0]*8
c = 0
for a in A:
    if a <= 399:
        cnt[0] += 1
    elif a >= 400 and a <= 799:
        cnt[1] += 1
    elif a >= 800 and a <= 1199:
        cnt[2] += 1
    elif a >= 1200 and a <= 1599:
        cnt[3] += 1
    elif a >= 1600 and a <= 1999:
        cnt[4] += 1
    elif a >= 2000 and a <= 2399:
        cnt[5] += 1
    elif a >= 2400 and a <= 2799:
        cnt[6] += 1
    elif a >= 2800 and a <= 3199:
        cnt[7] += 1
    else:
        c += 1
        
Min = len([i for i in cnt if i != 0]), 0
if c == 0:
    print(Min, Min)
else:
    Max = min(8, Min+c)
    if Min == 0:
        print(1, Max)
    else:
        print(Min, Max)