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

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
for i in range(N):
    if X[i]<=Y[N//2-1]:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
for i in range(N):
    if X[i]<=Y[N//2-1]:
        print(Y[N//2])
    else:
        print(Y[N//2-1
Problem p03471 (python)

Fixed submission:
N,Y=map(int,input().split())
Y=Y//1000
error='-1 -1 -1'

for x in range(N+1):
    for y in range(N+1-x):
            z=N-x-y
            if 10*x+5*y+z==Y and z>=0:
                print(str(x)+' '+str(y)+' '+str(z))
                exit()
print(error)

Buggy submission (verdict: Runtime Error):
N,Y=map(int,input().split())
Y=Y//1000
error='-1 -1 -1'

for x in range(N+1):
    for y in range(N+1-x):
            z=N-x-y
            if 10*x+5*y+z==Y and z>=0:
                ans=str(x[0])+' '+str(y[0])+' '+str(z[0])
                exit()
print(error)
Problem p03557 (python)

Fixed submission:
import bisect

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
count=0

for j in b:
   x=bisect.bisect_left(a,j)
   y=bisect.bisect_right(c,j)
   count+=x*(N-y)
print(count)

Buggy submission (verdict: Runtime Error):
import bisect

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
count=0

for j in b:
   x=bisect.bisect_left(a,j)
   y=bisect.bisect_right(c,j)
   ans+=x*(N-l)
print(count)
Problem p03627 (python)

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
an=[]
for b,count in c.items():
    for _ in range(count//2):
        an.append(b)
an.sort(reverse=True)
if len(an)<2:
    print(0)
else:
    print(an[0]*an[1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)
sa=list(set(a))
sa=sorted(sa,reverse=True)
anew=[]
for i in range(len(sa)):
    if a.count(sa[i])>=2:
        anew.append(sa[i])
        if len(anew)==2:
            break
print(anew[0]*anew[1])
Problem p03635 (python)

Fixed submission:
n,m=map(int,input().split()) 
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split()) print((n-1)*(m-1))
Problem p03680 (python)

Fixed submission:
n=int(input())
a=[int(input())-1 for _ in range(n)]
ans=-1
l=0
for i in range(n):
    l=a[l]
    if l==1:
        ans=i+1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input())-1 for _ in range(n)]
ans=-1
l=0
for i in range(n):
    l=a[l]
    cnt[l]+=1
    if l==1:
        ans=i+1
        break
print(ans)
Problem p03738 (python)

Fixed submission:
a=int(input())
b=int(input())
ans='LESS'
if a>b:
    ans='GREATER'
elif a==b:
    ans='EQUAL'
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans='LESS'
if a>b:
    ans='GREATER'
elif a==b:
    ans='EQUAL'
print(ans)
Problem p03796 (python)

Fixed submission:
n=int(input())
ans=1
for i in range(1,n+1):
    ans=(ans*i)%(1e9+7)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
print(math.factorial(n)%(1e9+7))n=int(input())
ans=1
for i in range(1,n+1):
    ans=(ans*i)%(1e9+7)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
print(math.factorial(n)%(1e9+7))n=int(input())
ans=1
for i in range(1,n+1):
    ans=(ans*i)%(1e9+7)
print(ans)
Problem p03848 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
if N % 2 == 1:
    if A[0] != 0:
        print(0)
        exit()
    for i in range(N // 2):
        if A[2 * i + 1] != 2 * (i + 1) or A[2 * i + 2] != 2 * (i + 1):
            print(0)
            exit()
    print(pow(2, N // 2) % (10 ** 9 + 7))
else:
    for i in range(N // 2):
        if A[2 * i] != 2 * i + 1 or A[2 * i + 1] != 2 * i + 1:
            print(0)
            exit()
    print((pow(2, N // 2)) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print((pow(2,n//2))%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(((pow(2,n//2))%(1e9+7)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print(int(pow(2,n//2)%(1e9+7)))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(int(pow(2,n//2)%(1e9+7)))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    if a[0]!=0:
        print(0)
        exit()
    for i in range(n//2):
        if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
            print(0)
            exit()
    print(pow(2,n//2)%(1e9+7))
else:
    for i in range(n//2):
        if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
            print(0)
            exit()
    print(pow(2,n//2)%(1e9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
a.sort()
la=list(set(a))
if n%2==0:
    for i in range(1,n,2):
        if a.count(i)==2:
            ans*=2
            ans%=1e9+7
        else:
            ans=0
            break
else:
    if a[0]==0 and a[1]!=0:
        a=a[1:]
        for i in range(2,n,2):
            if a.count(i)==2:
                ans*=2
                ans%=1e9+7
            else:
                ans=0
                break
    else:
        ans=0
print(int(ans))
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
s=[input() for i in range(n)]
print(''.join(sorted(s)))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=[input() for i in range(n)]
print(''.join(sorted(s))
Problem p02797 (python)

Fixed submission:
n, k ,s = map(int, input().split())
ans = []

if s<10**9:
    for i in range(n):
        if i <= k-1:
            ans.append(s)
        else:
            ans.append(s+1)
elif s==10**9:
    for j in range(n):
        if j <= k-1:
            ans.append(s)
        else:
            ans.append(1)
ans = map(str, ans)
print(' '.join(ans))

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

if s<10**9:
    for i in range(n):
        if i <= k-1:
            ans.append(s)
        else:
            ans.append(s+1)
elif s==10**9:
    for j in range(n):
        if i <= k-1:
            ans.append(s)
        else:
            ans.append(1)
ans = map(str, ans)
print(' '.join(ans))

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

if s<10**9:
    for i in range(n):
        if i <= k:
            ans.append(s)
        else:
            ans.append(s+1)
elif s==10**9:
    for j in range(n):
        if i <= k:
            ans.append(s)
        else:
            ans.append(1)
ans = map(str, ans)
print(' '.join(ans))
Problem p02801 (python)

Fixed submission:
import string
c = input()

upper = string.ascii_lowercase
ind = upper.index(c)
print(upper[ind+1])

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


li = []

for i in range(m):
    p,q = map(str, input().split())
    li.append((int(p),q))

wa = 0

se = {i for i in li if i[1]=='AC'}
ac = len(se)

flag = True
for i in range(m-1):
    if li[i][0]!=li[i+1][0]:
        flag = True
    elif li[i][0]==li[i+1][0] and li[i][1]=='AC':
        flag = False
    elif li[i][0]==li[i+1][0] and li[i][1]=='WA' and flag:
        wa += 1

print(ac, wa)
Problem p02802 (python)

Fixed submission:
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*(N+1)
    AC = [False]*(N+1)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p] == True:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*max(N, M)
    AC = [False]*max(N, M)

    if N==0:
        print(0, 0)
        exit()

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p]:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N, M = map(int, input().split())
    WAnum = 0
    ACnum = 0
    WA = [0]*max(N, M)
    AC = [False]*max(N, M)

    for _ in range(M):
        p, S = map(str, input().split())
        p = int(p)
        if AC[p]:
            continue
        if S == 'AC':
            AC[p] = True
            ACnum += 1
            WAnum += WA[p]
        elif S == 'WA':
            WA[p] += 1
        #print(AC, WA)
    #print(AC,WA)
    print(ACnum, WAnum)

solve()

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


li = []

for i in range(m):
    p,q = map(str, input().split())
    li.append((int(p),q))

wa = 0

se = {i for i in li if i[1]=='AC'}
ac = len(se)

flag = True
for i in range(m-1):
    if li[i][0]!=li[i+1][0]:
        flag = True
    elif li[i][0]==li[i+1][0] and li[i][1]=='AC':
        flag = False
    elif li[i][0]==li[i+1][0] and li[i][1]=='WA' and flag:
        wa += 1
    elif li[len(li)-1]==li[len(li-2)] and li[i][1]=='WA' and flag:
        wa += 1

print(ac, wa)
Problem p02813 (python)

Fixed submission:
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

r = list(itertools.permutations(range(1,n+1)))

print(abs(r.index(p)-r.index(q)))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

r = list(itertools.permutations(range(1,n+1)))
r.sort()

for i in range(len(r)):
    if r[i] == p:
        a = i+1
    elif r[i] == q:
        b = i+1

print(abs(a-b))
Problem p02844 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
S = input()

d1 = defaultdict(int)
d2 = defaultdict(int)
d3 = defaultdict(int)

for s in S:
    for x in d2:
        d3[x+s]+=1
    for y in d1:
        d2[y+s]+=1
    d1[s]+=1

print(len(d3))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(input())

tb = [False]*10**2
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            l = int(''.join(S[i]+S[j]+S[k]))
            tb[l] = True
print(tb.count(True))
Problem p02848 (python)

Fixed submission:
import string
import numpy as np
N = int(input())
S = list(input())
A2Z = string.ascii_uppercase

str_index = np.full(len(S), 0)
mod_26 = np.full(len(S), 26)
#print(str_index)

for i in range(len(S)):
    str_index[i] = A2Z.index(S[i])
str_index = (str_index+N) % mod_26
#print(str_index)

tmp = ['']*len(S)
for i in range(len(S)):
    index = int(str_index[i])
    tmp[i] = A2Z[index]
answer = ''.join(tmp)
print(answer)

Buggy submission (verdict: Runtime Error):
import string
import numpy as np
N = int(input())
S = list(input())
A2Z = string.ascii_uppercase

str_index = np.full(len(S), 0)
mod26 = np.full(len(S), 26)
#print(str_index)

for i in range(len(S)):
    str_index[i] = A2Z.index(S[i])
str_index = (str_index+N) % mod26
#print(str_index)

tmp = ['']*len(S)
for i in range(len(S)):
    tmp[i] = A2Z[str_index[i]]
answer = ''.join(tmp)
print(answer)
Problem p02924 (python)

Fixed submission:
n=int(input())
#total=0
#l = list(range(2,n+1)) + [1]
#for i in range(n):
#    total+=(i+1)%l[i]
#print(total)
# 1+2+3+...+n-1
print(n*(n-1)//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
total=0
l = list(range(2,n+1)) + [1]
for i in range(n):
  total+=(i+1)%l[i]
print(total)

Buggy submission (verdict: Runtime Error):
n=int(input())
total=0
l = list(range(2,n+1)) + [1]
for i in range(n):
  total+=(i+1)%l[i]
print(total)
Problem p03000 (python)

Fixed submission:
import itertools
N, X = map(int, input().split())
l = list(map(int, input().split()))
l.insert(0,0)
l_acc = list(itertools.accumulate(l))
answer = [x for x in l_acc if x<=X]
print(len(answer))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
l = list(map(int, input().split()))
d = 0
answer = 0
for i in range(N+1):
    if d <= X:
        answer += 1
        d += l[i]
    else:
        break
print(answer)
Problem p03030 (python)

Fixed submission:
from operator import itemgetter

# input
N = int(input())
S, P = ['0']*N, [0]*N
SP = []
for i in range(N):
    tmp_s, tmp_p = map(str, input().split())
    S[i], P[i] = tmp_s, tmp_p
    SP.append((tmp_s,int(tmp_p)))

# 点数で逆順ソート
SSP = sorted(SP, key=itemgetter(1), reverse=True)
# 名前で昇順ソート
SSP = sorted(SSP, key=itemgetter(0))

answer = [0]*N
for i in range(N):
    for j in range(N):
        if SSP[i] == SP[j]:
            answer[i] = j+1

for i in answer:
    print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, P = ['0']*N, [0]*N
SP = []
for i in range(N):
    tmp_s, tmp_p = map(str, input().split())
    S[i], P[i] = tmp_s, tmp_p
    SP.append((tmp_s,int(tmp_p)))

# 点数で逆順ソート
SSP = sorted(SP, key=itemgetter(1), reverse=True)
# 名前で昇順ソート
SSP = sorted(SSP, key=itemgetter(0))

answer = [0]*N
for i in range(N):
    for j in range(N):
        if SSP[i] == SP[j]:
            answer[i] = j+1

for i in answer:
    print(i)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
l, r = [0]*Q, [0]*Q
for i in range(Q):
    l[i], r[i] = map(int,input().split())
    l[i] -= 1
    r[i] -= 1
lr = zip(l,r)

R = [0]*(N+1)
for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        R[i] = R[i-1]+1
    else:
        R[i] = R[i-1]

for i,j in lr:
    print(R[j] - R[i])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
l, r = [0]*Q, [0]*Q
for i in range(Q):
    l[i], r[i] = map(int,input().split())
    l[i] -= 1
    r[i] -= 1
lr = zip(l,r)

R = [0]*(N+1)
for i in range(1,N+1):
    if S[i-1]=='A' and S[i]=='C':
        R[i] = R[i-1]+1
    else:
        R[i] = R[i-1]

for i,j in lr:
    print(R[j] - R[i])
Problem p03161 (python)

Fixed submission:
def chmin(a,b):
    if a > b:
        return b
    else:
        return a


N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * N
dp[0] = 0


for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def chmin(a,b):
    if a > b:
        return b
    else:
        return a


N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * (10)
dp[0] = 0


for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])
Problem p03162 (python)

Fixed submission:
N = int(input())
a = [[0 for _ in range(3)] for _ in range(N)]
for i in range(N):
    t = list(map(int, input().split()))
    for j in range(3):
        a[i][j] = t[j]

dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
#print(dp)


answer = 0
for j in range(3):
    answer = max(answer, dp[N][j])

print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
INF = float('inf')
MAX_N = 10**5

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

# dp table
# dp[i][j] := 状態jにおけるi日目に得る幸福度の総和の最大値
dp = np.array([[0]*3 for _ in range(N)])

dp[0][0],dp[0][1],dp[0][2] = a[0],b[0],c[0]

for i in range(1,N):
    for j in range(3):
        if j==0:
            dp[i][j] = max(dp[i-1][j+1]+a[i],dp[i-1][j+2]+a[i])
        if j==1:
            dp[i][j] = max(dp[i-1][j-1]+b[i],dp[i-1][j+1]+b[i])
        if j==2:
            dp[i][j] = max(dp[i-1][j-2]+c[i],dp[i-1][j-1]+c[i])
print(max(dp[N-1]))
Problem p03163 (python)

Fixed submission:
INF = float('inf')
MAX_N = 110
MAX_W = 10**5 + 100

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

dp = [[0]*MAX_W for _ in range(MAX_N)]

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

        dp[i][j] = max(dp[i][j], dp[i-1][j])

print(dp[N][W])

Buggy submission (verdict: Runtime Error):
INF = float('inf')
MAX_N = 110
MAX_W = 10**5 + 1000

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

dp = [[0]*MAX_N for _ in range(MAX_W)]

for i in range(1,N+1):
    for j in range(W+1):
        if j-w[i-1]>=0:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1])
        dp[i][j] = max(dp[i][j], dp[i-1][j])
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
INF = float('inf')
MAX_N = 110
MAX_W = 10**5 + 1

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

# dp table
# dp[i][j] := i-1番目までの品物から重さがjを超えないように選んだ時の、価値の最大値
dp = [[0]*MAX_N for _ in range(MAX_W)]

for i in range(1,N+1):
    for j in range(W+1):
        # i番目の品物を選ぶ
        if j-w[i-1]>=0:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w[i-1]]+v[i-1])
        # i番目の品物を選ばない場合
        dp[i][j] = max(dp[i][j], dp[i-1][j])

print(dp[N][W])
Problem p03274 (python)

Fixed submission:
n,k=map(int,input().split())
x=list(map(int,input().split()))
a=[]
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))
print(min(a))

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

ans = float('inf')
for l in range(K):
    r = l + K - 1
    if r>N:
        continue
    ans = min(ans, min(abs(x[l]), abs(x[r])) + x[r] - x[l])
print(ans)
Problem p03308 (python)

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
li.sort()
print(abs(li[-1]-li[0]))

Buggy submission (verdict: Runtime Error):
n = int(input())
li = map(int,input().split())
li.sort()
print(abs(li[-1]-li[0]))
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())

ak = [i for i in range(a, min(b + 1, a + k))]
bk = [i for i in range(max(a, b - k + 1), b + 1)]

answer = list(set(ak) | set(bk))
answer.sort()
print(*answer, sep='\n')

Buggy submission (verdict: Runtime Error):
A,B,K = map(int, input().split())
tmp = list(range(A,B+1))
answer = list(set(tmp[:K])|set(tmp[-K:]))
answer.sort()
print(*answer, sep='\n')

Buggy submission (verdict: Runtime Error):
A,B,K = map(int, input().split())
tmp = list(range(A,B+1))
answer = list(set(tmp[0:K]+tmp[-K:]))
answer.sort()
print(*answer, sep='\n')

Buggy submission (verdict: Runtime Error):
A,B,K = map(int, input().split())
tmp = list(range(A,B+1))
answer = list(set(tmp[0:K]+tmp[-K:]))
print(*answer, sep='\n')
Problem p03611 (python)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
num = []
for i in range(N):
    num.append(A[i])
    num.append(A[i] + 1)
    num.append(A[i] - 1)
#print(num)
num_count = collections.Counter(num)
#print(num_count.values())
print(max(num_count.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

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

li_conut = defaultdict(int)

# 要素ごとの出現数を記録
for a in li:
    li_count[a] += 1

max_x_count = 0

for x in range(1, 10**5):
    # xにできるやつの個数
    x_conut = li_conut[x-1] + li_conut[x] + li_conut[x+1]
    max_x_count = max(max_x_count, x_conut)
print(max_x_count)
Problem p03625 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
i = 0
while i+1<N:
    if len(b)==2:
        break
    if a[i] == a[i+1]:
        b += [a[i]]
        i += 2
    else:
        i += 1

if len(b)<2:
    print(0)
else:
    print(b[0]*b[1])

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = []
i = 0
while i+1<N:
    if len(b)==2:
        break
    if a[i] == a[i+1]:
        b += [a[i]]
        i += 2
    else:
        i += 1
print(b[0]*b[1])
Problem p03657 (python)

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

if (a+b)%3==0 or a%3==0 or b%3==0:
    print('Possible')
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
M = sum(a)
snk = 0
ans = float('inf')
for i in range(N-1):
    snk += a[i]
    ari = M - snk
    ans = min(ans,abs(snk-ari))
print(ans)
Problem p03781 (python)

Fixed submission:
X=int(input())
res=0
for i in range(X+1):
  if i*(i+1)//2>=X:
    res=i
    break
print(res)

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

X = int(input())
L = list(range(X))
L = list(itertools.accumulate(L))

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

tmp = getNearestValue(L, X)
tmp1 = abs(X-tmp)
print(L.index(tmp)+tmp1)
Problem p03145 (python)

Fixed submission:
ab, bc, ca = map(int,input().split())

print(int(ab * bc / 2))

Buggy submission (verdict: Runtime Error):
ab, bc, ca = map(int(i) for i in input().split)

print(ab * bc / 2)

Buggy submission (verdict: Runtime Error):
ab, bc, ca = list(map(int(i) for i in input().split))

print(ab * bc / 2)
Problem p03160 (python)

Fixed submission:
n=int(input())
l1=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
    if i==1:
        dp[i]=abs(l1[i]-l1[i-1])
    else :
        dp[i]=min(dp[i-1]+abs(l1[i]-l1[i-1]),dp[i-2]+abs(l1[i]-l1[i-2]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
l1=list(map(int,input().split()))
totalcost=0
dp=[0]*n
def solve(dp,i,l1):
    if i==0:
        return 0
    if dp[i]!=0:
        return(dp[i])
    if i>1:
        dp[i]=min(solve(dp,i-2,l1)+abs(l1[i]-l1[i-2]),solve(dp,i-1,l1)+abs(l1[i]-l1[i-1]))
        return(dp[i])
    else :
        dp[i]=solve(dp,0,l1)+abs(l1[1]-l1[0])
        return(dp[i])
solve(dp,n-1,l1)
print(dp[n-1])