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

Fixed submission:
s = str(input())
s = list(s)
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
    print("Bad")
else:
    print("Good")

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

def gcd(x,y):
    while y !=0:
        x,y = y,x%y
    return x

def sums(x):
    S1 = x//c
    S2 = x//d
    S3 = x// (c*d//gcd(c,d))
    return x - S1 - S2 + S3


print(sums(b)-sums(a-1))

Buggy submission (verdict: Runtime Error):
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]
cnt = 0
for j in range(a,b+1):
    if j%c != 0 and j%d != 0:
        cnt += 1
    else:
        pass
print(cnt)

Buggy submission (verdict: Runtime Error):
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]
cnt = 0
for j in range(a,b+1):
    if j%c != 0 and j%d != 0:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]
cnt = 0
t = [j for j in range(a,b+1) if j%c != 0 and j%d != 0]

for i in t:
    if (i//c-i/c != 0) and (i//d-i/d != 0):
        cnt += 1
    else:
        pass
print(cnt)

Buggy submission (verdict: Runtime Error):
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]

cnt = 0
for i in range(a,b+1):
    if (int(i/c)-i/c != 0) and (int(i/d)-i/d != 0):
        cnt += 1

print(cnt)
Problem p02995 (python)

Fixed submission:
e = list(map(int,input().split()))
a,b,c,d = e

def gcd(x,y):
    while y !=0:
        x,y = y,x%y
    return x

def sums(x):
    S1 = x//c
    S2 = x//d
    S3 = x// (c*d//gcd(c,d))
    return x - S1 - S2 + S3


print(sums(b)-sums(a-1))

Buggy submission (verdict: Runtime Error):
e = list(map(int,input().split()))
a = e[0]
b = e[1]
c = e[2]
d = e[3]
cnt = 0
for j in range(a,b+1):
    if j%c != 0 and j%d != 0
        cnt += 1
print(cnt)
Problem p02999 (python)

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

if x < a:
    print(0)
else:
    print(10)

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

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y < W*H / 2:
    S1 = W*y
elif W*y == W*H / 2:
    S1 = int(W*y)
else:
    S1 = W*H - W*y

if H*x < W*H / 2:
    S2 = H*x
elif H*x == W*H / 2:
    S2 = int(H*x)
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(Sm,co)

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

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y < W*H / 2:
    S1 = W*y
elif W*y == W*H / 2:
    pass
else:
    S1 = W*H - W*y

if H*x < W*H / 2:
    S2 = H*x
elif H*x == W*H / 2:
    pass
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(Sm,co)

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

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y <= W*H / 2:
    S1 = W*y
else:
    S1 = W*H - W*y

if H*x <= W*H / 2:
    S2 = H*x
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(float(Sm),co)

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

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y <= float(W*H)/2:
    S1 = W*y
else:
    S1 = W*H - W*y

if H*x <= float(W*H)/2:
    S2 = H*x
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(Sm,co)

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

W = c[0]
H = c[1]
x = c[2]
y = c[3]



if W*y <= float((W*H)/2):
    S1 = W*y
else:
    S1 = W*H - W*y

if H*x <= float((W*H)/2):
    S2 = H*x
else:
    S2 = W*H - H*x

if S1 < S2:
    Sm = S2
    co = 0
elif S1 > S2:
    Sm = S1
    co = 0
else:
    Sm = S1
    co = 1
    
print(Sm,co)
Problem p03029 (python)

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

p = 3*a + p

pi = p // 2

print(pi)

Buggy submission (verdict: Runtime Error):
a = []
n = int(input())
for i in range(n):
    key,value = input().split()
    a.append((key,value,int(i+1)))
a.sort(key=lambda x:(x[0],reverse = not x[1]))
for i in range(n):
    print(a[i][2])
Problem p03085 (python)

Fixed submission:
b = str(input())

if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
elif b == "C":
    print("G")

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
for i in range(q):
    l,r = map(int,input().split())
    print(s[l-1:r].count("AC"))
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i] += count[i-1]
    if s[i-1:i+1] == "AC":count[i] += 1
for i in range(q):
    l,r = map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
count = [0]*n
for i in range(1,n):
    count[i] += count[i-1]
    if s[i-1:i+1] == "AC":count += 1
for i in range(q):
    l,r = map(int,input().split())
    print(count[r-1]-count[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
for i in range(n):
    l,r = map(int,input().split())
    print(s[l-1:r].count("AC"))
Problem p03128 (python)

Fixed submission:
#解答例
N,M=map(int,input().split())
A=list(map(int,input().split()))#使える数字の種類
weight=[0,2,5,5,4,5,6,3,7,6]#作るのに何本必要か、また0は作れないので0になっている
dp=[-1]*(N+1)#とりあえずこれくらい確保しておけばok
dp[0]=0#0本では0しか作れない
#dp[i]はちょうどi本で作れる最高の数を入れることにする
for i in range(N+1):#N本あるから、一本ずつ増やしていって最大N本
    for a in A:
        if i+weight[a]<N+1:#今あるi本にa本を加えてもN本を超えないか
            dp[i+weight[a]]=max(dp[i+weight[a]],dp[i]*10+a)#今まで作ったi+weight[a]のときのdpの値と、今作ったdp[i]*10+aの値を比べ、大きい方を格納する
                                                           #なぜdp[i]*10+aになるのかに関しては、右から数字を追加していく場合のみを考えることで、重複せずに全通り試せるから
print(dp[N])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
weight = [2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)
dp[0] = 0
for i in range(N+1):
    if dp[i] == -1:continue
    for a in A:
        if i+weight[a]<N+1:
            dp[i+weight[a]] = max(dp[i+weight[a]],dp[i]*10+a)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#解答例
N,M=map(int,input().split())
A=list(map(int,input().split()))#使える数字の種類
weight=[0,2,5,5,4,5,6,3,7,6]#作るのに何本必要か、また0は作れないので0になっている
dp=[-1]*(N+1)#とりあえずこれくらい確保しておけばok
dp[0]=0#0本では0しか作れない
#dp[i]はちょうどi本で作れる最高の数を入れることにする
for i in range(N+1):#N本あるから、一本ずつ増やしていって最大N本
    if dp[i] == -1:continue
    for a in A:
        if i+weight[a]<N+1:#今あるi本にa本を加えてもN本を超えないか
            dp[i+weight[a]]=max(dp[i+weight[a]],dp[i]*10+a)#今まで作ったi+weight[a]のときのdpの値と、今作ったdp[i]*10+aの値を比べ、大きい方を格納する
                                                           #なぜdp[i]*10+aになるのかに関しては、右から数字を追加していく場合のみを考えることで、重複せずに全通り試せるから
                                                        　 #もし一通りもなかった場合、-1が格納されたままになるため問題がない
print(dp[N])
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = [abs(a-x) for a in X]
print(reduce(gcd,X))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = [abs(x-X[0]) for x in X]
print(reduce(gcd,X))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
n,x = map(int,input().split())
X = list(map(int,input().split()))
X = [x-X[0] for x in X]
print(reduce(gcd,X))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,x = map(int,input().split())
X = list(map(int,input().split()))
a = X[0]
X = np.array(X)
print(np.gcd.reduce(X-a))
Problem p03284 (python)

Fixed submission:
n,k = map(int,input().split())
if n % k == 0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n = int(input())
print("Yes" if any([4*i+7*j == n for i in range(n//4+1) for j in range(n//7+1)]) else "No")
Problem p03407 (python)

Fixed submission:
s = list(map(int,input().split()))
a = s[0]
b = s[1]
c = s[2]
if a + b >= c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = list(map(int,input()))
a = s[0]
b = s[1]
c = s[2]
if a + b >= c:
    print("Yes")
else:
    print("No")
Problem p03408 (python)

Fixed submission:
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))

print(max(0,max([n.count(l[i]) - m.count(l[i]) for i in range(len(l))])))

Buggy submission (verdict: Runtime Error):
n = [input() for _ in range(int(input()))]
m = [input() for _ in range(int(input()))]
l = list(set(n))

print(max(0,max([n.count(l[i]) - m.count(l[i]) for i in range(len(n))])))
Problem p03455 (python)

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

if(a*b % 2 == 0):
    print("Even")
else:
    print("Odd")

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

if(a*b % 2 == 0):
    print("Even")
else:
    print("Odd")
Problem p03469 (python)

Fixed submission:
s = str(input())
s1 = s.replace("7","8",1)
print(s1)

Buggy submission (verdict: Runtime Error):
print(len(set(int(input()) for _ in range(int(input())))))
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
c,s = 1,a[0]
while s != 2 and c < n:c,s = c+1,a[s-1]
print(c if c < n else "-1")

Buggy submission (verdict: Runtime Error):
a = [int(input()) for _ in range(int(input()))]
c,s = 1,a[0]
if s != 2 and c < n: c,s = c+1,a[n-1]
print(c if c < n else "-1")
Problem p03719 (python)

Fixed submission:
a,b,c = map(int,input().split())
print("Yes" if a<=c<=b else "No")

Buggy submission (verdict: Runtime Error):
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;

    cin >> a >> b >> c;

    if(a <= c && c <= b)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
}
Problem p03862 (python)

Fixed submission:
N,x=map(int,input().split())
A=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
    eated=max(0,A[i]+A[i-1]-x)
    ans+=eated
    A[i]-=eated
print(ans)

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
    eated=max(0,A[i]+A[i-1]-x)
    ans+=eated
    A[i]-=eated
print(ans)
Problem p03998 (python)

Fixed submission:
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())

Buggy submission (verdict: Runtime Error):
s = {c:list(input()) for c in "abc"}
s = "a"
while S[s]:s = S[s].pop(0)
print(s.upper())
Problem p04043 (python)

Fixed submission:
n = input().split()
print("YES" if n.count("5") == 2 and n.count("7") == 1 else "NO")

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
S = sorted([input() for _ in range(n)])
print(*S,sep="")
Problem p02918 (python)

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

largest = 0
largest_left_index = -1

sum_list = list()

count = 0
for i in range(N):
    if S[i] == "L":
        if count <= 0:
            count = count - 1
        else:
            sum_list.append(count)
            count = -1
    elif S[i] == "R":
        if count >= 0:
            count = count + 1
        else:
            sum_list.append(-count)
            count = 1
else:
    sum_list.append(count) if count > 0 else sum_list.append(-count)

happines = 0
for i in range(len(sum_list)):
    happines = happines + sum_list[i] - 1

length = len(sum_list)

for i in range(K):
    if length > 2:
        happines = happines + 2
        length = length - 2
    elif length == 2:
        happines = happines + 1
        length = length - 1

print(happines)

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

largest = 0
largest_left_index = -1

sum_list = list()

count = 0
for i in range(N):
    if S[i] == "L":
        if count <= 0:
            count = count - 1
        else:
            sum_list.append(count)
            count = -1
    elif S[i] == "R":
        if count >= 0:
            count = count + 1
        else:
            sum_list.append(-count)
            count = 1
else:
    sum_list.append(count) if count > 0 else sum_list.append(-count)

length = len(sum_list)
current_max = 0
current_max_index = 0
for j in range(length):
    current_sum = sum_list[j]
    if j < length - 1:
        current_sum = current_sum + sum_list[j+1]
    if j < length - 2:
        current_sum = current_sum + sum_list[j+2]

    if current_sum > current_max:
        current_max = current_sum
        current_max_index = j

if current_max_index < length - 2:
    sum_list.pop(current_max_index + 2)
if current_max_index < length - 1:
    sum_list.pop(current_max_index + 1)
sum_list.pop(current_max_index)
sum_list.insert(current_max_index, current_max)

for i in range(K-1):
    left = sum_list[current_max_index]
    if current_max_index > 1:
        left = left + sum_list[current_max_index - 1]
    if current_max_index > 2:
        left = left + sum_list[current_max_index - 2]

    right = sum_list[current_max_index]
    if current_max_index < len(sum_list) - 1:
        right = right + sum_list[current_max_index + 1]
    if current_max_index < len(sum_list) - 2:
        right = right + sum_list[current_max_index + 2]

    if left >= right:
        sum_list.pop(current_max_index)
        sum_list.insert(current_max_index, left)
        if current_max_index > 1:
            sum_list.pop(current_max_index - 1)
        if current_max_index > 2:
            sum_list.pop(current_max_index - 2)
    else:
        length = len(sum_list)
        if current_max_index < length - 2:
            sum_list.pop(current_max_index + 2)
        if current_max_index < length - 1:
            sum_list.pop(current_max_index + 1)
        sum_list.pop(current_max_index)
        sum_list.insert(current_max_index, right)

res = 0
for i in range(len(sum_list)):
    res = res + sum_list[i] - 1

print(res)
Problem p02783 (python)

Fixed submission:


H, A = map(int, input().split())


ans = 0
while H > 0:
  ans += 1
  H -= A

print(ans)

Buggy submission (verdict: Runtime Error):
# http://drken1215.hatenablog.com/entry/2020/01/26/225000

H, N = map(int, input().split())
dp = [float("inf") for i in range(H+1)]

dp[0] = 0

for i in range(N):
  a, b = map(int, input().split())
  
  for j in range(H):
    dp[min(j+a, H)] = min(dp[min(j+a, H)], dp[j] + b)


print(dp[H])
Problem p02924 (python)

Fixed submission:
N = int(input())

print((N) * (N-1) // 2)

Buggy submission (verdict: Runtime Error):

N = int(input())
L = list(range(1, N))

from functools import reduce
from operator import add

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

print(reduce(add, L))

Buggy submission (verdict: Runtime Error):

N = int(input())

X = list(range(1, N+1))
Y = X[:]
Y.append(Y.pop(0))

ans = 0
for i in range(N):
  ans += X[i] % Y[i]

print(ans)
Problem p03059 (python)

Fixed submission:
a, b, t = map(int, input().split())
print(int((t + 0.5) / a) * b)

Buggy submission (verdict: Runtime Error):


from math import gcd
from functools import reduce # reduceの使い方覚える、ついでにaccumulateも

def divider(numbers):
  return reduce(gcd, numbers)

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

result = []
for i in range(n):
  numbers = A[:]
  numbers.pop(i)
  result.append(divider(numbers))
print(max(result))
Problem p03061 (python)

Fixed submission:
# 参考1: https://atcoder.jp/contests/abc125/submissions/8965716
# 参考2: https://qiita.com/hkrutknouch/items/e71488de4a0c8e83ee97

from fractions import gcd
from itertools import accumulate

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

left = list(accumulate(A, gcd))
right = list(accumulate(A[::-1], gcd))[::-1]

ans = 0
for i in range(n):
  if i == 0:
    tmp = right[1]
  elif i == n - 1:
    tmp = left[-2]
  else:
    tmp = gcd(left[i-1], right[i+1])
  ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):


from math import gcd
from functools import reduce # reduceの使い方覚える、ついでにaccumulateも

def divider(numbers):
  return reduce(gcd, numbers)

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

result = []
for i in range(n):
  numbers = A[:]
  numbers.pop(i)
  result.append(divider(numbers))
print(max(result))
Problem p03109 (python)

Fixed submission:
import datetime

s = input()
base = datetime.datetime.strptime("2019/4/30", '%Y/%m/%d')
dt = datetime.datetime.strptime(s, '%Y/%m/%d')
print("Heisei" if base >= dt else "TBD")

Buggy submission (verdict: Runtime Error):
# TLEするので、自前で用意せずに、ライブラリ使おう
# https://juppy.hatenablog.com/entry/2019/02/24/ABC119_-D_Lazy_Faith-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder

import bisect
A, B, Q = map(int, input().split())
S = sorted([int(input()) for i in range(A)])
T = sorted([int(input()) for i in range(B)])
X = [int(input()) for i in range(Q)]

s_size = A
t_size = B
inf = 99999999999999

for x in X:
  s_index = bisect.bisect_left(S, x)
  s_left = S[s_index - 1] if s_index > 0 else None
  s_right = S[s_index] if s_index < s_size else None
  t_index = bisect.bisect_left(T, x)
  t_left = T[t_index - 1] if t_index > 0 else None
  t_right = T[t_index] if t_index < t_size else None

  ans = inf

  sl = [s_left, s_right]
  tl = [t_left, t_right]

  for s in sl:
    if not s: continue
    c1 = abs(x - s)
    for t in tl:
      if not t: continue
      ans = min(ans, c1 + abs(s-t))


  for t in tl:
    if not t: continue
    c1 = abs(x - t)
    for s in sl:
      if not s: continue
      ans = min(ans, c1 + abs(s-t))

  print(ans)
Problem p03112 (python)

Fixed submission:
# TLEするので、自前で用意せずに、ライブラリ使おう
# https://juppy.hatenablog.com/entry/2019/02/24/ABC119_-D_Lazy_Faith-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder

import bisect
A, B, Q = map(int, input().split())
S = sorted([int(input()) for i in range(A)])
T = sorted([int(input()) for i in range(B)])
X = [int(input()) for i in range(Q)]

s_size = A
t_size = B
inf = 99999999999999

for x in X:
  s_index = bisect.bisect_left(S, x)
  s_left = S[s_index - 1] if s_index > 0 else None
  s_right = S[s_index] if s_index < s_size else None
  t_index = bisect.bisect_left(T, x)
  t_left = T[t_index - 1] if t_index > 0 else None
  t_right = T[t_index] if t_index < t_size else None

  ans = inf

  sl = [s_left, s_right]
  tl = [t_left, t_right]

  for s in sl:
    if not s: continue
    c1 = abs(x - s)
    for t in tl:
      if not t: continue
      ans = min(ans, c1 + abs(s-t))


  for t in tl:
    if not t: continue
    c1 = abs(x - t)
    for s in sl:
      if not s: continue
      ans = min(ans, c1 + abs(s-t))

  print(ans)

Buggy submission (verdict: Runtime Error):

A, B, Q = map(int, input().split())
S = [int(input()) for i in range(A)]
T = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]

def binary_search(target, N, left, right):
  if right - left <= 1:
    return (left, right)

  mid = (left + right) // 2

  if target == N[mid]:
    return mid

  if target <= N[mid]:
    return binary_search(target, N, left, mid)
  else:
    return binary_search(target, N, mid, right)

s_size = len(S)
t_size = len(T)
inf = 999999999999999999999

for x in X:
  s_left, s_right = binary_search(x, S, 0, s_size)
  t_left, t_right = binary_search(x, T, 0, s_size)

  slv = S[s_left] if s_left < s_size else inf
  srv = S[s_right] if s_right < s_size else inf
  tlv = T[t_left] if t_left < t_size else inf
  trv = T[t_right] if t_right < t_size else inf

  sl = [slv, srv]
  tl = [tlv, trv]
  mini = inf

  for n in [slv, srv]:
    c1 = abs(x - n)
    for m in [tlv, trv]:
      c2 = abs(n-m)
      mini = min(mini, c1+c2)

  for n in [tlv, trv]:
    c1 = abs(x - n)
    for m in [slv, srv]:
      c2 = abs(n-m)
      mini = min(mini, c1+c2)
  print(mini)
Problem p03128 (python)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
weight = [0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)
dp[0] = 0

for i in range(N+1):
  if dp[i] == -1: continue
  for a in A:
    if i+weight[a]<N+1:
      dp[i+weight[a]] = max(dp[i+weight[a]],dp[i]*10+a)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
weight = [0,2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)
dp[0] = 0

for i in range(N+1):
  if dp[i] == -1: continue
  for a in A:
    if i+weight[a]<N+1:
      dp[i+weight[a]] = max(dp[i+weight[a]],dp[i]*10+a)
      print(dp)

print(dp[-1])

Buggy submission (verdict: Runtime Error):

from heapq import heappop, heappush
N, M = map(int, input().split())
A = list(map(int, input().split()))

queue = []

for a in A:
  if a == 1:
    heappush(queue, (2, 1))
  elif a == 2:
    heappush(queue, (5, 2))
  elif a == 3:
    heappush(queue, (5, 3))
  elif a == 4:
    heappush(queue, (4, 4))
  elif a == 5:
    heappush(queue, (5, 5))
  elif a == 6:
    heappush(queue, (6, 6))
  elif a == 7:
    heappush(queue, (3, 7))
  elif a == 8:
    heappush(queue, (7, 8))
  elif a == 9:
    heappush(queue, (6, 9))

x, y = heappop(queue)
mod = N % x
ans = [y] * ((N - N % x) // x)
baseX = x

while mod != 0:
  ans = ans[1:]
  mod += baseX
  x, y = heappop(queue)
  ans.append(y)
  mod %= x

for a in sorted(ans, reverse=True):
  print(a, end="")
Problem p03240 (python)

Fixed submission:
# 全探索を試みるもWAを解決できず
# ゼロの扱いに対する思考が足りなかった

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    for i in range(N):
      x, y, h = map(int, C[i])
      if h > 0:
        htop = abs(x-X) + abs(y-Y) + h
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0:
        if htop - (abs(x-X) + abs(y-Y)) > 0:
          break
      if h > 0:
        if htop - (abs(x-X) + abs(y-Y)) != h:
          break
    else:
      print(X, Y, htop)
      exit()

Buggy submission (verdict: Runtime Error):

N = int(input())

P = []

for i in range(N):
  x, y, h = map(int, input().split())
  P.append((x,y,h))

for x in range(101):
  for y in range(101):
    height = -1
    for p in range(N):
      (cx, cy, ch) = P[p]
      if height == -1:
        height = ch + abs(cx - x) + abs(cy - y)
        if height < 1:
          height = -1
      elif height == -2:
        break
      else:
        tmp = ch + abs(cx - x) + abs(cy - y)
        if tmp != height:
          height = -2
    
    if height != -2:
      valid = True
      for p in range(N):
        (cx, cy, ch) = P[p]
        if ch == 0:
          if height - abs(cx - x) - abs(cy - y) > 0:
            valid = False
        else
          if max(0, height - abs(cx - x) - abs(cy - y)) != ch:
            valid = False
      if valid:
        print(x, y, height)
        exit()
Problem p03244 (python)

Fixed submission:

n = int(input())
V = list(map(int, input().split()))
A = [] # 偶数
B = [] # 奇数

import collections

for i in range(n):
  if i % 2 == 0:
    A.append(V[i])
  else:
    B.append(V[i])

A = collections.Counter(A).most_common()[:2]
B = collections.Counter(B).most_common()[:2]
count = 0

if A[0][0] == B[0][0]:
  count += max(A[0][1], B[0][1])
  if A[0][1] == B[0][1]:
    if len(A) > 1 and len(B) > 1:
      count += max(A[1][1], B[1][1])
    elif len(A) > 1:
      count += max(A[1][1])
    elif len(B) > 1:
      count += max(B[1][1])
else:
  count += A[0][1] + B[0][1]

print(n-count)

Buggy submission (verdict: Runtime Error):

n = int(input())
V = list(map(int, input().split()))
A = [] # 偶数
B = [] # 奇数

inf = 999999999999999999999

import collections

for i in range(n):
  if i % 2 == 0:
    A.append(V[i])
  else:
    B.append(V[i])

A = collections.Counter(A).most_common()
B = collections.Counter(B).most_common()

count = 0

if A[0][0] == B[0][0]:
  count += min(A[0][1], B[0][1])
  if A[0][1] == B[0][1]:
    if A[1][1] > B[1][1]:
      A.pop(0)
    else:
      B.pop(0)
    

A.pop(0)
B.pop(0)

for key, value in A:
  count += value

for  key, value in B:
  count += value

print(count)