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

Fixed submission:
H,W = map(int,input().split())
MIN = 10**11
S1 = 0
S2 =  0
S3 = 0
if H%3 == 0 or W %3==0:
    print(0)
else:
    for i in range(1,H):
        S1 = i * W
        S2 = (H-i)*(W//2)
        S3 = (H-i)*(W - W//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for i in range(1,W):
        S1 = i * H
        S2 = (W-i)*(H//2)
        S3 = (W-i)*(H - H//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for i in range(1,H):
        S1 = i*W
        S2 = ((H-i)//2)*W
        S3 = H*W - S1-S2
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
    
    for i in range(1,H):
        S1 = i*H
        S2 = ((W-i)//2) *H
        S3 = H*W - S1-S2
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    print(MIN)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
MIN = 10**11
S1 = 0
S2 =  0
S3 = 0
if H%3 == 0 or W %3==0:
    print(0)
else:
    for i in range(1,H):
        S1 = i * W
        S2 = (H-i)*(W//2)
        S3 = (H-i)*(W - W//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for i in range(1,W):
        S1 = i * H
        S2 = (W-i)*(H//2)
        S3 = (W-i)*(H - H//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for i in range(1,H):
        S1 = i*W
        S2 = ((H-i)//2)*W
        S3 = H*W - S1-S2
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
    
     for i in range(1,H):
        S1 = i*H
        S2 = ((W-i)//2) *H
        S3 = H*W - S1-S2
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    print(MIN)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
MIN = 10**11
S1 = 0
S2 =  0
S3 = 0
if H%3 == 0 or W %3==0:
    print(0)
else:
    for i in range(1,H):
        S1 = i * W
        S2 = (H-i)*(W//2)
        S3 = (H-i)*(W - W//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for  i in range(1,W):
        S1 = i * H
        S2 = (W-i)*(H//2)
        S3 = (W-i)*(H - H//2)
        MIN = min(MIN, max(S1,S2,S3)- min(S1,S2,S3))
        
    for i in range()
        
    print(MIN)
Problem p02609 (python)

Fixed submission:
def cin():
    return input().split()
def qpow(a,b,p):
    if p == 1 or p == 0:
        return 0
    a = (a%p+p)%p
    ans = 1
    while b!=0:
        if (b&1) != 0:
            ans = (ans * a) % p
        b >>= 1
        a = a * a  % p
    return ans

def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1

n = int(input())
x = list(input())
x = x[::-1]
cnt = 0;l = len(x)
r1 = 0;r2 = 0
for i in x:
    if i == '1':
        cnt += 1
i = 0
while i < l:
    if x[i] == '1':
        r1 += qpow(2,i,cnt+1)
        r2 += qpow(2,i,cnt-1)
    i += 1
i = 0
a = []
while i < l:
    if x[i] == '0':
        t = f((r1+qpow(2,i,cnt+1))%(cnt+1))+ 1
    else:
        if cnt-1 !=  0:
            t = f((r2-qpow(2,i,cnt-1)+(cnt-1))%(cnt-1)) + 1
        else:
            t = 0
    i += 1
    a.append(t)
a = a[::-1]
for i in a:
    print(i)

Buggy submission (verdict: Runtime Error):
def cin():
    return input().split()
def qpow(a,b,p):
    if p == 1:
        return 0
    a = (a%p+p)%p
    ans = 1
    while b!=0:
        if (b&1) != 0:
            ans = (ans * a) % p
        b >>= 1
        a = a * a  % p
    return ans

def f(x):
    ans = 0
    if x == 0:
        return ans
    for i in range(31):
        if ((x>>i)&1) == 1:
            ans += 1
    return f(x%ans) + 1

n = int(input())
x = list(input())
x = x[::-1]
cnt = 0;l = len(x)
r1 = 0;r2 = 0
for i in x:
    if i == '1':
        cnt += 1
i = 0
while i < l:
    if x[i] == '1':
        r1 += qpow(2,i,cnt+1)
        r2 += qpow(2,i,cnt-1)
    i += 1
i = 0
a = []
while i < l:
    if x[i] == '0':
        t = f((r1+qpow(2,i,cnt+1))%(cnt+1))+ 1
    else:
        t = f((r1-qpow(2,i,cnt-1)+(cnt-1))%(cnt-1)) + 1
    i += 1
    a.append(t)
a = a[::-1]
for i in a:
    print(i)
Problem p02761 (python)

Fixed submission:
def solution():
    n, m = map(int, input().split())
    cs = [list(map(int, input().split())) for i in range(m)]
    if m == 0:
        if n > 1:
            print(10**(n-1))
        else:
            print("0")
        return
    ans = [-1 for i in range(n)]
    for w in cs:
        s, c = w[0], w[1]
        if (s == 1) and (c == 0) and (n > 1):
            print('-1')
            return
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != c:
            print('-1')
            return
    ansb = [str(i) if i != -1 else str(0) for i in ans]
    if (ansb[0] == '0') and (len(ansb) > 1):
        ansb[0] = '1'
    anss = ''
    for s in ansb:
        anss = anss + s
    print(anss)

solution()

Buggy submission (verdict: Runtime Error):
def solution():
    n, m = map(int, input().split())
    cs = [list(map(int, input().split())) for i in range(m)]
    if m == 0:
        if n > 1:
            print("-1")
        else:
            print("0")
        return
    ans = [-1 for i in range(n)]
    for w in cs:
        s = w[0]
        c = w[1]
        if (s == 1) and (c == 0) and (n > 1):
            print('-1')
            return
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != c:
            print('-1')
            return
    ansb = [str(i) if i != -1 else str(0) for i in ans]
    if ansb[0] == '0':
        ansb[0] = '1'
    for s in ansb:
        anss = anss + s
    print(int(anss))

solution()

Buggy submission (verdict: Runtime Error):
def solution():
    n, m = map(int, input().split())
    cs = [list(map(int, input().split())) for i in range(m)]
    if m == 0:
        if n > 1:
            print("-1")
        else:
            print("0")
        return
    ans = [-1 for i in range(n)]
    for w in cs:
        s = w[0]
        c = w[1]
        if (s == 1) and (c == 0) and (n > 1):
            print('-1')
            return
        if ans[s-1] == -1:
            ans[s-1] = c
        elif ans[s-1] != c:
            print('-1')
            return
    ans = [str(i) if i != -1 else str(0) for i in str(ans)]
    anss = ''
    for s in ans:
        anss = anss + s
    print(int(anss))

solution()
Problem p02784 (python)

Fixed submission:
h, n = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) >= h:
   print("Yes")
else:
   print("No")

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

if h <= sum(a):
   print("yes")
else:
   print("no")
Problem p02817 (python)

Fixed submission:
s, t = input().split()
print("{}{}".format(t, s))

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
print("{}{}".format(t, s))
Problem p02818 (python)

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

if k != 0:
    diva = a / k
    if diva >= 1:
        a -= k
    else:
        k -= a
        a = 0
        b -= k
        if b < 0:
            b = 0
print("{} {}".format(a, b))

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
for i in range(k):
  if a >= 1:
    a -= 1
  elif b >= 1:
    for i in range(k-i)
      b -= 1
      elif b >= 1:
        break
    break
  else
    break
print("{} {}".format(a, b))
Problem p03854 (python)

Fixed submission:
def solution():
    s = input()
    T = ['dreamer', 'dream', 'eraser', 'erase']

    while True:
        match = False
        for ss in T:
            if s.endswith(ss) :
                s = s[:-1*len(ss)]
                if not s:
                    print('YES')
                    return
                match = True
                break
        if not match:
            print('NO')
            return

solution()

Buggy submission (verdict: Runtime Error):
s = input()
T = ['dream', 'dreamer', 'erase', 'eraser']

def solution():
    while True:
        match = False
        for ss in T:
            if s.startswith(ss):
                s = s.lstrip(ss)
                if not s:
                    print('YES')
                    return
                match = True
                break
        if not match:
            print('NO')
            return

solution()
Problem p03160 (python)

Fixed submission:
n=int(input())
a= list(map(int,input().split()))
from collections import defaultdict as dd
dp=dd(int)

dp[1]=0
dp[2]=abs(a[0]-a[1])

for i in range(3,n+1):
    dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2])
print(dp[n])

Buggy submission (verdict: Runtime Error):

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> h(n);
    for(int &x:h)
    {
        scanf("%d",&x);
    }
    vector<int> dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

    }

   cout<<dp[n-1];

    return 0;
}
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

if x <= len(p):
    pp = p[:x]
else:
    pp = p + r[:x-len(p)]

if y <= len(q):
    qq = q[:y]
else:
    qq = q + r[:y-len(q)]
    
rr = []
for k in r:
    if len(pp) >= 1 and len(qq) >= 1:
        if pp[-1] < qq[-1]:
            if pp[-1] < k:
                pp.pop()
                rr.append(k)
            else:
                break
        else:
            if qq[-1] < k:
                qq.pop()
                rr.append(k)
            else:
                break
    elif len(pp) >= 1:
        if pp[-1] < k:
            pp.pop()
            rr.append(k)
        else:
            break
    elif len(qq) >= 1:
        if qq[-1] < k:
            qq.pop()
            rr.append(l)
        else:
            break
    else:
        break

print(sum(pp)+sum(qq)+sum(rr))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

pp = p[:x]
qq = q[:y]
rr = []
for k in r:
    if pp[-1] < qq[-1]:
        if pp[-1] < k:
            pp.pop()
            rr.append(k)
        else:
            break
    else:
        if qq[-1] < k:
            qq.pop()
            rr.append(k)
        else:
            break

print(sum(pp)+sum(qq)+sum(rr))
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
aa = (a+b-c)**2
bb = 4*a*b
if a + b <= c:
    if aa > bb:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
2 3 10
Problem p02630 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
count = Counter(A) #not dict!!
temp_sum = sum(A)
for _ in range(Q):
    before, after = map(int, input().split())
    temp_sum += (after - before) * count[before]
    count[after] += count[before]
    count[before] = 0
    print(temp_sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
dis_list = []
for i in range(Q):
    s = list(map(int, input().split()))
    dis_list.append(s)
for j in dis_list:
Problem p03658 (python)

Fixed submission:
N, K = map(int, input().split())
l = list(map(int, input().split()))
x = sorted(l)[::-1]
print(sum(x[:K]))

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

Fixed submission:
from collections import Counter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(1, N + 1):
    my_count[i] = 0
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in range(N):
    print(my_count[i][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in range(N):
    print(my_count[i][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
from operator import itemgetter
N, M = map(int, input().split())
dis_list = []
my_count = Counter()
for i in range(M):
    a, b = map(int, input().split())
    my_count[a] += 1
    my_count[b] += 1
my_count = sorted(my_count.items())
for i in N:
    print(i[1])
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
total = 1
if 0 < A.count(0):
    print(0)
else:
    for i in range(N):
        total *= A[i]
        if 10 ** 18 < total:
            break
    if 10**18 < total:
        print("-1")
    else:
        print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
total = 1
for i in range(N):
    total *= A[i]
    if 10 ** 18 < total:
        break

if 10**18 < total:
    print("-1")
else:
Problem p02677 (python)

Fixed submission:
import math
A,B,H,M = map(int,input().split())
a = 30*H + 0.5*M
b = M*6
if abs(a-b) < 180:
    ab = abs(a-b)
else:
    ab = 360 - abs(a-b)
ab1 = round(math.cos(math.radians(ab)),20)
ans = round(math.sqrt(A**2 + B**2 - 2 * A* B*ab1),20)
print(round(ans,20))

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
a = 30*H + 0.5*M
b = M*6
if abs(a-b) < 180:
    ab = abs(a-b)
else:
    ab = abs(360-a-b)
ab1 = round(math.cos(math.radians(ab)),20)
ans = round(math.sqrt(A**2 + B**2 - 2 * A* B*ab1),20)
print(round(ans,10)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
a = 30*H + 0.5*M
b = M*6
F  = 0

ab = min(abs(a-b),abs(360-a-b))
ab1 = math.cos(math.radians(ab))
print(ab)
ab_angle = -2*A*B*ab1
ans = (A2 + B2 +ab_angle)**0.5
if ab  == 0:
    print(abs(A-B))
elif ab == 180:
    printF(A+B)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
a = 30*H + 0.5*M
b = M*6
F  = 0

ab = min(abs(a-b),abs(360-a-b))
ab1 = math.cos(math.radians(ab))
print(ab)
ab_angle = -2*A*B*ab1
ans = (A2 + B2 +ab_angle)**0.5
if ab  == 0:
    print(abs(A-B))
elif ab == 180:
    printF(A+B)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
a = 30*H + 0.5*M
b = M*6
F  = 0

ab = min(abs(a-b),abs(360-a-b))
ab_angle = -2*A*B*ab
ans = math.sqrt(A2 + B2 +ab_angle)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
pi = round(math.pi,20)
a = 30*H + 0.5*M
b = M*6
F  = 0
if abs(a-b) == 180:
    F = 1
    print(A+B)
elif abs(a-b) ==0:
    F = 1
    print(abs(A-B))
elif abs(a-b) < 180 and 0 < abs(A-B):
    angle = round(math.cos(math.radians(abs(a-b))),20)
elif 180 < abs(a-b):
    angle = round(math.cos(math.radians(abs(360-a-b))),20)

if F == 0:
    ab_angle = round(2*A*B*angle,20)
    print(round((A2 + B2 - ab_angle)**0.5,20))

Buggy submission (verdict: Runtime Error):
import math
A,B,H,M = map(int,input().split())
A2 = A**2
B2 = B**2
pi = round(math.pi,20)
a = 30*H + 0.5*M
b = M*6
F  = 0
if abs(a-b) == 180:
    F = 1
    print(A+B)
elif abs(a-b) ==0:
    F = 1
    print(0)
elif abs(A-B) < 180:
    angle = round(math.cos(math.radians(abs(a-b))),20)
elif 180 < abs(a-b) and 0 < abs(a-b):
    angle = round(math.cos(math.radians(abs(360-a-b))),20)

if F == 0:
    ab_angle = round(2*A*B*angle,20)
    print(round((A2 + B2 - ab_angle)**0.5,20))
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
B = list()
a = int()
b = int()
c = int()
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(i,j,k)
print(ans)

Buggy submission (verdict: Runtime Error):
ort math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
K = int(input())
B = list()
a = int()
b = int()
c = int()
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(i,j,k)
print(ans)
Problem p02743 (python)

Fixed submission:
a,b,c = list(map(int,input().split()))
X = c-a-b
if X > 0 and X*X > 4*a*b:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
import math
a,b,c = list(map(int,Decimal(input().split())))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
A = Decimal(math.sqrt(a))
B = Decimal(math.sqrt(b))
C = Decimal(math.sqrt(c))
AB = Decimal(A+B)
if AB < C:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a,b,c = list(map(int,input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
A = a**0.5
B = b**0.5
C = c**0.5
AB = A+B
if AB < C:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a,b,c = list(map(int,input().split()))
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
A = a**0.5
B = b**0.5
C = c**0.5
if AB < C:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a,b,c = list(map(int,input().split()))
A = math.sqrt(a)
B = math.sqrt(b)
C = math.sqrt(c)
AB = Decimal(A+B)
if AB < C:
    print("Yes")
else:
    print("No")
Problem p02767 (python)

Fixed submission:
import math
from statistics import mean, median,variance,stdev
N = int(input())
X = list(map(int,input().split()))
a = sum(X)
ave = round(a/N)
b = 0
for i in range(N):
    b +=(X[i]-ave)**2
print(b)

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

N = int(input())
X = list(map(int,input().split()))

a = mean(X)
print(a)
b = 0
for i in range(N):
    b +=(X[i]-a)**2
print(b)
Problem p02783 (python)

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

while(a>b) :
    a -= b
    cnt +=1


print(cnt)

Buggy submission (verdict: Runtime Error):
i = input()
a,b = map(int, i.split())
c = 1

while a > b:
    a -= b
    c += 1
    else:
      print(c)
Problem p02789 (python)

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

if a>b:
 print("No")
elif a<b:
 print("No")
else:
 print("Yes")

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

if a == b:
  print("Yes")
  
  else:
    print("No")

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

M,N = map(int,a.split())
if M == N:
  print("Yes")
  
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = input()
M,N = map(int,a.spliit())

if M == N:
  print(Yes)

else:
  print(No)
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
c = P[0]
ans = 1
for i in range(1,N):
    if P[i] < c:
        c = P[i]
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
a = 0
if A[0] == 1:
    print(1)
else:
    for i in range(N-1):
        if A[0]
Problem p02811 (python)

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

if 500*x-y>=0:
    print("Yes")
else:
        print("No")

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

if 500*x-y >= 0:
  print("Yes")
  
  else:
    print("No")
Problem p02899 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0] * N
for i in range(N):
    B[A[i]-1] = i+1
print(' '.join(map(str,B)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    B.append(A.index(i)+1)
print(' '.join(map(str,B)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N+1):
    B.append(A.index(i)+1)
print(' '.join(map(int,B)))
Problem p02909 (python)

Fixed submission:
S = input()
if S == "Sunny":
  print("Cloudy")
elif S ==  "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
S = input()
if S == Sunny:
  print("Cloudy")
elif S ==  Cloudy:
  print("Rainy")
else:
  print("Sunny")
Problem p02922 (python)

Fixed submission:
import math
A,B  = list(map(int,input().split()))
ans  = 1
c = 0
if B ==1:
    print("0")
elif B <= A:
    print("1")
else:
    while ans < B:
        ans += A-1
        c += 1
    print(c)

Buggy submission (verdict: Runtime Error):
if B < A:
    print("0")
elif B ==A:
    print("1")
else:
    while ans < B:
        ans += A
        ans -= 1
        c += 1
    print(c)
Problem p03625 (python)

Fixed submission:
M = int(input())
A = list(map(int,input().split()))
B = {}
C = [0]*2
D = [0]*2

for i in range(len(A)):
	a = str(A[i])
	# 存在したらカウントアップ
	if (a in B): B[ str(A[i]) ] += 1 # カウント
	# 存在しなかったら 1 で初期化
	else: B[ str(A[i]) ] = 1 # カウント
	# {"1":2, "2":3, "3":1}

for i in B:
	# 一個しかなかったら条件を満たさないのでスルー
	# i: string, B[i] = count
	if B[i] < 2: continue

	# 2個以上あれば長方形にスタック
	C.append(int(i))

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: D.append(int(i))

# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))

Buggy submission (verdict: Runtime Error):
M = int(input())
A = list(map(int,input().split()))
B = [0]*(M+1)
C = [0]*2
D = [0]*2

for i in range(len(A)):
	B[ A[i] ] += 1 # カウント

for i in range(len(B)):
	# 一個しかなかったら条件を満たさないのでするー
	if B[i] < 2: 
        continue

	# 2個以上あれば長方形にスタック
	C.append(i)

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: 
        D.append(i)
# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))

Buggy submission (verdict: Runtime Error):
M = int(input())
A = list(map(int,input().split()))
B = [0]*(M+1)
C = [0]*2
D = [0]*2

for i in range(len(A)):
	B[ A[i] ] += 1 # カウント

for i in range(len(B)):
	# 一個しかなかったら条件を満たさないのでするー
	if B[i] < 2: continue

	# 2個以上あれば長方形にスタック
	C.append(i)

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: D.append(i)
# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))

Buggy submission (verdict: Runtime Error):
M = int(input())
A = list(map(int,input().split()))
B = [0]*(M+1)
C = [0]*2
D = [0]*2

for i in range(len(A)):
		B[ A[i] ] += 1 # カウント

		# Ai = 1, 1, 2, 3, 2, 4
		# B[1] = 2
		# B[2] = 2
		# B[3] = 1
		# B[4] = 1
		# B[100000] = ***

for i in range(len(B)):
	# 一個しかなかったら条件を満たさないのでするー
	if B[i] < 2: continue

	# 2個以上あれば長方形にスタック
	C.append(i)

	# 4個以上あれば正方形にスタック
	if B[i] >= 4: D.append(i)
# C を降順でソート
C = sorted(C, reverse=True)

rect = C[0] * C[1]
s = max(D)
square = s * s

print(max(rect,square))
Problem p03637 (python)

Fixed submission:
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four:
  print("Yes")
elif a-two/2 <= four:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int,input().split()))
l = list()
ll = list()
for i in range(len(A)):
  if A[i]%4 == 0:
    l.append(A[i])
  if A[i]%2 == 0:
    ll.append(A[i])
four = len(l)
two = len(ll)-four
zero = N-two
a = math.floor(N/2)
if a <= four and b == 0:
  print("Yes")
elif a-two <= four:
  print("Yes")
else:
  print("No")