Harryxun/testdata huggingface dataset:
Buggy python 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])

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 python 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])

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 python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = float('inf')
for i in range(N-K+1):
    ans = min(ans,h[i:i+K][-1]-h[i:i+K][0])
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = float('inf')
for i in range(N-K+1):
    ans = min(ans,h[i+K-1]-h[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = float('inf')
for i in range(N-K+1):
    m = min(h[i:i+K])
    M = max(h[i:i+K])
    ans = min(ans,M-m)
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = float('inf')
for i in range(N-K+1):
    ans = min(ans,h[i+K-1]-h[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = 10**9
for i in range(N-K+1,N+1):
    m = min(h[i-K:i])
    M = max(h[i-K:i])
    ans = min(ans,M-m)
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()

ans = float('inf')
for i in range(N-K+1):
    ans = min(ans,h[i+K-1]-h[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

cnt = 0
for i in range(1,N+1,2):
    tmp = set(str(i))
    if len(tmp)==3 and '7' in tmp and '5' in tmp and '3' in tmp:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if '7' in s and '5' in s and '3' in s else 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, M = map(int, input().split())
PY = []
PYd = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    PYd[x].append(y)
    PY.append((x,y))

for i in PYd.keys():
    PYd[i].sort()

for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(1 + PYd[p].index(y)).zfill(6)
    print(str_p + index)

Fixed submission:
from collections import defaultdict
import bisect
N, M = map(int, input().split())
PY = []
PYd = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    PYd[x].append(y)
    PY.append((x,y))

for i in PYd.keys():
    PYd[i].sort()

for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p],y)).zfill(6)
    print(str_p + index)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, M = map(int, input().split())
PY = []
PYd = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    PYd[x].append(y)
    PY.append((x,y))

for i in PYd.keys():
    PYd[i].sort()

for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(1 + PYd[p].index(y)).zfill(6)
    print(str_p + index)

Fixed submission:
from collections import defaultdict
import bisect
N, M = map(int, input().split())
PY = []
PYd = defaultdict(list)
for i in range(M):
    x, y = map(int, input().split())
    PYd[x].append(y)
    PY.append((x,y))

for i in PYd.keys():
    PYd[i].sort()

for p,y in PY:
    str_p = str(p).zfill(6)
    index = str(bisect.bisect(PYd[p],y)).zfill(6)
    print(str_p + index)
Buggy python 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)

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 python submission (verdict: Time Limit Exceeded):
import fractions
import functools
N = int(input())
a = list(map(int, input().split()))

def lcm(a,b):
    return (a*b)/fractions.gcd(a,b)

def lcm_list(lst):
    return functools.reduce(lcm,lst)

lcma = lcm_list(a)-1
res = 0
for i in a:
    res += lcma%i
print(int(res))

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

res = 0
for i in a:
    res += i-1
print(int(res))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
li.sort()
print(abs(li[-1]-li[0]))


Fixed submission:
n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(2 * n)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
#a*b=gcd(a,b)*lcm(a,b)
lcm = 2*n//math.gcd(2,n)
print(lcm)

Fixed submission:
n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(2 * n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = map(int,input().split())
li.sort()
print(abs(li[-1]-li[0]))

Fixed submission:
n = int(input())
li = list(map(int,input().split()))
li.sort()
print(abs(li[-1]-li[0]))
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B,K = map(int, input().split())

MOD = 998244353 # prime
fact_inv, inv = [0]*10**6, [0]*10**6

def init_nCk():
    fact_inv[0] = fact_inv[1] = 1
    inv[1] = 1
    for i in range(2,10**6):
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        fact_inv[i] = fact_inv[i-1] * inv[i] % MOD

def nCk(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    ans = 1
    for i in range(n, n-k+1 - 1, -1):
        ans *= i
        ans %= MOD
    return ans * fact_inv[k] % MOD

# WAKARAN
res = 0
init_nCk()
for a in range(0,N+1):
    # 割り切れることを確認
    if (K - A*a)%B == 0 and (K -A*a)//B >= 0:
        b = (K -A*a)//B
        res += nCk(N,a)*nCk(N,b)
        res %= MOD
print(res)

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

MOD = 998244353 # prime
MAX = 10**6

fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX

def init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def C(n, k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n]%MOD * (finv[k] * finv[n-k] % MOD) % MOD

res = 0
init()
for a in range(0,N+1):
    # 割り切れることを確認
    if (K - A*a)%B == 0 and (K -A*a)//B >= 0:
        b = (K -A*a)//B
        res += C(N,a)*C(N,b)
        res %= MOD
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N,A,B,K = map(int, input().split())

MOD = 998244353 # prime
fact_inv, inv = [0]*10**6, [0]*10**6

def init_nCk():
    fact_inv[0] = fact_inv[1] = 1
    inv[1] = 1
    for i in range(2,10**6):
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        fact_inv[i] = fact_inv[i-1] * inv[i] % MOD

def nCk(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    ans = 1
    for i in range(n, n-k+1 - 1, -1):
        ans *= i
        ans %= MOD
    return ans * fact_inv[k] % MOD

res = 0
init_nCk()
for a in range(0,N+1):
    # 割り切れることを確認
    if (K - A*a)%B == 0 and (K -A*a)//B >= 0:
        b = (K -A*a)//B
        res += nCk(N,a)*nCk(N,b)
        res %= MOD
print(res)

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

MOD = 998244353 # prime
MAX = 10**6

fac = [0]*MAX
finv = [0]*MAX
inv = [0]*MAX

def init():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD

def C(n, k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n]%MOD * (finv[k] * finv[n-k] % MOD) % MOD

res = 0
init()
for a in range(0,N+1):
    # 割り切れることを確認
    if (K - A*a)%B == 0 and (K -A*a)//B >= 0:
        b = (K -A*a)//B
        res += C(N,a)*C(N,b)
        res %= MOD
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = input()

left = [0]*N
right = [0]*N
for i in range(N):
    tmp1 = S[:i]
    tmp2 = S[i+1:]
    left[i] = tmp1.count('W')
    right[i] = tmp2.count('E')

left = np.array(left)
right = np.array(right)
ans = (left+right).min()
print(ans)


Fixed submission:
import numpy as np
N = int(input())
S = input()

left = [0]*N
right = [0]*N
for i in range(1,N):
    if S[i-1]=='W':
        left[i] += left[i-1] + 1
    else:
        left[i] += left[i-1]
left = np.array(left)

for i in range(1,N):
    if S[N-i]=='E':
        right[i] += right[i-1] + 1
    else:
        right[i] += right[i-1]
right = np.array(right[::-1])

ans = (left+right).min()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S = list(input())

ans = float('inf')
for i in range(N):
    left = Counter(S[:i])
    right = Counter(S[i+1:])
    tmp = left['W'] + right['E']
    ans = min(ans,tmp)
print(ans)

Fixed submission:
import numpy as np
N = int(input())
S = input()

left = [0]*N
right = [0]*N
for i in range(1,N):
    if S[i-1]=='W':
        left[i] += left[i-1] + 1
    else:
        left[i] += left[i-1]
left = np.array(left)

for i in range(1,N):
    if S[N-i]=='E':
        right[i] += right[i-1] + 1
    else:
        right[i] += right[i-1]
right = np.array(right[::-1])

ans = (left+right).min()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

ans = float('inf')
for i in range(N):
    left = S[:i]
    right = S[i+1:]
    tmp = left.count('W') + right.count('E')
    ans = min(ans,tmp)
print(ans)


Fixed submission:
import numpy as np
N = int(input())
S = input()

left = [0]*N
right = [0]*N
for i in range(1,N):
    if S[i-1]=='W':
        left[i] += left[i-1] + 1
    else:
        left[i] += left[i-1]
left = np.array(left)

for i in range(1,N):
    if S[N-i]=='E':
        right[i] += right[i-1] + 1
    else:
        right[i] += right[i-1]
right = np.array(right[::-1])

ans = (left+right).min()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
k=int(input())
se=set()
for i in range(len(s)+1):
  for j in range(i,len(s)+1):
    se.add(''.join(s[i:j]))
se.remove('')
l=sorted(list(se))
print(l[k-1])

Fixed submission:
s = input()
k = int(input())

se = set()
for i in range(len(s)):
    for j in range(1,k+1):
        se.add(s[i:i+j])

li = list(se)
li.sort()
print(li[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    tmp = np.array(X[:i]+X[i+1:])
    med = np.median(tmp)
    print(int(med))

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)

for i in range(N):
    ans = 0
    if X[i] <= Y[N//2-1]:
        ans = Y[N//2]
    else:
        ans = Y[N//2-1]
    print(ans)
Buggy python 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')

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 python 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')

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 python 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')

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 python submission (verdict: Time Limit Exceeded):
# c_00 c_01 c_02
# c_10 c_11 c_12
# c_20 c_21 c_22
# a_0+b_0 a_0+b_1 a_0+b_2
# a_1+b_0 a_2+b_2 a_1+b_2
# a_2+b_0 a_2+b_1 a_2+b_2

c_0 = list(map(int, input().split()))
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c = [c_0,c_1,c_2]

for a_0 in range(100+1):
    for a_1 in range(100+1):
        for a_2 in range(100+1):
            b_0 = c[0][0] - a_0
            b_1 = c[0][1] - a_0
            b_2 = c[0][2] - a_0

            a = [a_0,a_1,a_2]
            b = [b_0,b_1,b_2]
            flag = True
            for i in range(3):
                for j in range(3):
                    if c[i][j] == a[i] + b[j]:
                        continue
                    else:
                        flag = False
            if flag:
                print('Yes')
                exit()
print('No')

Fixed submission:
A = [list(map(int, input().split())) for _ in range(3)]

b2_1 = A[0][1] - A[0][0]
b3_1 = A[0][2] - A[0][0]

if any([b2_1 != A[x][1] - A[x][0] for x in [1, 2]]) or any([b3_1 != A[x][2] - A[x][0] for x in [1,2]]):
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

L = list(itertools.product(A,B,C,repeat=1))
cnt = 0
for i,j,k in L:
    if i<j<k:
        cnt += 1
print(cnt)

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()
B.sort()
C.sort()

ans = 0
for x in B:
    # 小さい
    sm = bisect.bisect_left(A,x)
    # 大きい
    bi = len(C) - bisect.bisect_right(C,x)
    ans += sm*bi
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list([int(input()) for _ in range(N)])
ans = []

for a in A:
    if a not in ans:
        ans.append(a)
    else:
        ans.remove(a)
print(len(ans))


Fixed submission:
import collections

N = int(input())
A = list([int(input()) for _ in range(N)])
A = collections.Counter(A).values()

ans = [x for x in A if x&1]
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list([int(input()) for _ in range(N)])
ans = []

for a in A:
    if a not in ans:
        ans.append(a)
    else:
        ans.remove(a)
print(len(ans))


Fixed submission:
import collections

N = int(input())
A = list([int(input()) for _ in range(N)])
A = collections.Counter(A).values()

ans = [x for x in A if x&1]
print(len(ans))
Buggy python 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)

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 python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = []

for x in A:
    cnt = 0
    tmp = [x-1, x, x+1]
    for y in A:
        if y in tmp:
            cnt += 1
    ans.append(cnt)
#print(ans)
print(max(ans))

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 python 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])

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 python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
d = [x for x in d.items() if x[1]>=2]

ans = 0
for i1,j1 in d:
    for i2,j2 in d:
        if j1 >= 2 and j2 >= 2 and i1 != i2:
            ans = max(ans,i1*i2)
        elif i1==i2 and j1>=4 and j2>=4:
            ans = max(ans,i1*i2)
print(ans)


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 python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
d = [x for x in d.items() if x[1]>=2]

ans = 0
for i1,j1 in d:
    for i2,j2 in d:
        if j1 >= 2 and j2 >= 2 and i1 != i2:
            ans = max(ans,i1*i2)
        elif i1==i2 and j1>=4 and j2>=4:
            ans = max(ans,i1*i2)
print(ans)


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 python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1

ans = 0
for i1,j1 in d.items():
    for i2,j2 in d.items():
        if j1 >= 2 and j2 >= 2 and i1 != i2:
            ans = max(ans,i1*i2)
        elif i1==i2 and j1>=4 and j2>=4:
            ans = max(ans,i1*i2)
print(ans)

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 python submission (verdict: Time Limit Exceeded):
from math import floor
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
for i in a:
    if i%4==0:
        cnt_4 += 1
        a.remove(i)

cnt_2 = 0
for i in a:
    if i%2==0:
        cnt_2 += 1

if floor(N//2)<=cnt_4+(cnt_2//2):
    print('Yes')
else:
    print('No')

Fixed submission:
from math import floor
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
for i in a:
    if i%4==0:
        cnt_4 += 1

cnt_2 = 0
for i in a:
    if i%2==0 and i%4!=0:
        cnt_2 += 1

if floor(N//2)<=cnt_4+(cnt_2//2):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
N, M = map(int, input().split())
ab = []
for i in range(M):
    a,b = map(int, input().split())
    ab.append((a,b))

fl = False
for i,j in ab:
    if i!=1:
        continue
    for k,l in ab:
        if i==1 and (j!=k or l!=N):
            continue
        else:
            fl = True
print('POSSIBLE') if fl else print('IMPOSSIBLE')

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)
for i in range(M):
    a,b = map(int, input().split())
    d[a].append(b)

for i,j in list(d.items()):
    if i!=1:
        continue
    for k in j:
        if N in d[k]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter
N, M = map(int, input().split())
ab = []
for i in range(M):
    a,b = map(int, input().split())
    ab.append((a,b))
ab.sort(key=itemgetter(0))

fl = False
for i,j in ab:
    if i!=1:
        continue
    for k,l in ab:
        if i==1 and (j!=k or l!=N):
            continue
        else:
            fl = True
print('POSSIBLE') if fl else print('IMPOSSIBLE')

Fixed submission:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)
for i in range(M):
    a,b = map(int, input().split())
    d[a].append(b)

for i,j in list(d.items()):
    if i!=1:
        continue
    for k in j:
        if N in d[k]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')
Buggy python 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)


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 python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()

#強さを出力
def T(x,y,z):
    ma = max(x,y,z)
    mi = min(x,y,z)
    return (x+y+z) - (ma+mi)

b = a[0::2]
c = a[1::2]


ans = 0
for i in range(0,3*n//2,3):
    #print(b[i:i+3],c[i:i+3])
    ans += T(*b[i:i+3]) + T(*c[i:i+3])
print(ans)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = sum(a[n::2])
print(ans)

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

#強さを出力
def T(x,y,z):
    ma = max(x,y,z)
    mi = min(x,y,z)
    return (x+y+z) - (ma+mi)

b = a[0::2]
c = a[1::2]


ans = 0
for i in range(0,3*n//2,3):
    print(b[i:i+3],c[i:i+3])
    ans += T(*b[i:i+3]) + T(*c[i:i+3])
print(ans)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = sum(a[n::2])
print(ans)
Buggy python 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)

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