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

Fixed submission:
m = input().split()
N = int(m[0])
Y = int(m[1])
if Y > 10000*N:
  print(-1,-1,-1)
else:
  frag = 0
  for i in range(N+1):
    for j in range(N-i+1):
      if frag == 0 and 10000*i + 5000*j + 1000*(N-i-j) == Y:
        frag = 1
        print(i,j,N-i-j)
        break
  if frag == 0:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
m = input().split()
N = int(m[0])
Y = int(m[1])
if Y > 10000*N:
  print(-1,-1,-1)
else:
  frag = 1
  for i in range(N+1):
    for j in range(N-i+1):
      if frag == 1 and 10000*i + 5000*j + 1000*(N-i-j) == Y:
        frag == 0
        print(i,j,k)
        break
  if frag == 1:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
m = input().split()
N = int(m[0])
Y = int(m[1])
if Y > 10000*N:
  print(-1,-1,-1)
else:
  frag == 1
  for i in range(N+1):
    for j in range(N-i+1):
      if frag == 1 and 10000*i + 5000*j + 1000*(N-i-j) == Y:
        frag == 0
        print(i,j,k)
        break
  if frag == 1:
    print(-1,-1,-1)
Problem p03478 (python)

Fixed submission:
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  p = str(i)
  q = [str(c) for c in p]
  q = list(map(int,q))
  for j in range(len(q)):
    S = S + q[j]
  if A <= S <= B:
    k = k + i
print(k)

Buggy submission (verdict: Runtime Error):
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])
k = 0
for i in range(1,N+1):
  S = 0
  while l >= 1:
    l = i
    p = l%10
    l = l//10
    S = S + p
  if A <= S <= B:
    k = k + i
print(k)
Problem p03486 (python)

Fixed submission:
s = input()
t = input()
s1 = [str(a) for a in s]
t1 = [str(a) for a in t]
s1.sort()
t1.sort()
import copy
t2 = copy.copy(t1)
for i in range(len(t1)):
  t1[i] = t2[len(t1)-i-1]

n = 0
l = 0
i = 0
while n==0 and i <= min(len(t),len(s))-1:
  if s1[i] == t1[i]:
    l = l + 1
    i = i + 1
  elif s1[i] < t1[i]:
    n = n + 1
    print('Yes')
  elif s1[i] > t1[i]:
    n = n + 1
    print('No')
if l == len(t) and len(t) <= len(s):
  print('No')
elif l == len(s) and len(s) < len(t):
  print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s1 = [str(a) for a in s]
t1 = [str(a) for a in t]
s1.sort()
t1.sort()
import copy
t2 = copy.copy(t1)
for i in range(len(t1)):
  t1[i] = t2[len(t1)-i-1]

n = 0
l = 0
i = 0
while n==0 and i <= min(len(t),len(s)):
  if s1[i] == t1[i]:
    l = l + 1
    i = i + 1
  elif s1[i] < t1[i]:
    n = n + 1
    print('Yes')
  elif s1[i] > t1[i]:
    n = n + 1
    print('No')
if l == len(t) and len(t) <= len(s):
  print('No')
elif l == len(s) and len(s) < len(t):
  print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s1 = [str(a) for a in s]
t1 = [str(a) for a in t]
s1.sort()
t1.sort()
import copy
t2 = copy.copy(t1)
for i in range(len(t1)):
  t1[i] = t2[len(t1)-i-1]
if len(s) < len(t):
  k = 0
  for i in range(len(s)):
    if s1[i] == t1[i]:
      k = k + 1
  if k = len(s):
    print('Yes')
  else:
    print('No')
else:
  n = 0
  l = 0
  i = 0
  while n==0 and i < len(t):
    if s1[i] == t1[i]:
      l = l + 1
      i = i + 1
    elif s1[i] < t1[i]:
      n = n + 1
      print('Yes')
    elif s1[i] > t1[i]:
      n = n + 1
      print('No')
  if l = len(t):
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
s1 = [str(a) for a in s]
t1 = [str(a) for a in t]
s1.sort()
t1.sort()
import copy
t2 = copy.copy(t1)
for i in range(len(t1)):
  t1[i] = t2[len(t1)-i-1]
if len(s) < len(t):
  k = 0
  for i in range(len(s)):
    if s1[i] == t1[i]:
      k = k + 1
  if k = len(s):
    print('Yes')
  else:
    print('No')
else:
  n = 0
  l = 0
  i = 0
  while n==0 and i < len(t):
    if s1[i] == t1[i]:
      l = l + 1
      i = i + 1
    elif s1[i] < t1[i]:
      n = n + 1
      print('Yes')
    elif s1[i] > t1[i]:
      n = n + 1
      print('No')
  if l = len(t):
    print('No')
Problem p03493 (python)

Fixed submission:
s = (input())
p = [int(c) for c in s]
k = 0
for i in range(3):
  if p[i] == 1:
    k = k + 1
print(k)

Buggy submission (verdict: Runtime Error):
s = input().split()
k = 0
for i in range(3):
  if s[i] == '1':
    k = k + 1
print(k)
Problem p03494 (python)

Fixed submission:
N = int(input())
a = input().split()
a = list(map(int,a))
n = 0
p = N
while p == N:
  p = 0
  for i in range(N):
    if a[i]%2 == 0:
      p = p + 1
  if p == N:
    a = list(map(lambda x: x/2,a))
    n = n + 1
print(n)

Buggy submission (verdict: Runtime Error):
N = input()
a = input().split()
a = list(map(int,a))
n = 0
p = N
while p == N:
  p = 0
  for i in range(N):
    if a[i]%2 == 0:
      p = p + 1
  if p == N:
    a = list(map(lambda x: x/2,a))
    n = n + 1
print(n)
Problem p02718 (python)

Fixed submission:
n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
s = 1/(4*m)*sum(i for i in a)
for i in range(n):
    if a[i] < s:
        print("No")
        break
    if i == m-1:
        print("Yes")
        break

Buggy submission (verdict: Runtime Error):
n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
for i in range(n):
  if a[i] < 1/4m:
    print("No")
    break
  if i == m-1:
    print("Yes")
    break

Buggy submission (verdict: Runtime Error):
n, m = input().split()
n, m = int(n), int(m)
a = input().split()
a = [int(i) for i in a]
a.sort()
a.reverse()
for i in range(n):
  if a[i] < 1/4m:
    print("No")
    break
  if i == m:
    print("Yes")
    break
Problem p02727 (python)

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

a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
b_list = list(map(int, input().split()))
b_list.sort(reverse=True)
c_list = list(map(int, input().split()))
c_list.sort(reverse=True)

a_index =0
b_index =0
c_index = 0
count = 0
for i in range(x+y):
    if (a_index < x) and \
        (b_index >= y or a_list[a_index] >= b_list[b_index]) and \
        (c_index >= c or a_list[a_index] >= c_list[c_index]):
        count += a_list[a_index]
        a_index += 1
    elif (b_index < y) and \
        (a_index >= x or b_list[b_index] >= a_list[a_index]) and \
        (c_index >= c or b_list[b_index] >= c_list[c_index]):
        count += b_list[b_index]
        b_index += 1
    elif (c_index < c) and \
        (a_index >= x or c_list[c_index] >= a_list[a_index]) and \
        (b_index >= y or c_list[c_index] >= b_list[b_index]):
        count += c_list[c_index]
        c_index += 1
    
print(count)

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

a_list = list(map(int, input().split()))
a_list.sort()
b_list = list(map(int, input().split()))
b_list.sort()
c_list = list(map(int, input().split()))
c_list.sort()

a_index = a-x
b_index = b-y
for c_data in c_list:
    if a_index < a and a_list[a_index] < b_list[b_index]:
        if(a_list[a_index] < c_data):
            a_list[a_index] = c_data
            a_index += 1
    elif b_index < b:
        if(b_list[b_index] < c_data):
            b_list[b_index] = c_data
            b_index += 1
    else:
        break

count = 0
for i in range(a-1, a-x-1, -1):
    count += a_list[i]
for i in range(b-1, b-y-1, -1):
    count += b_list[i]
print(count)
Problem p02975 (python)

Fixed submission:
# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0]] == N//3 and input_dict[input_list[1]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)

Buggy submission (verdict: Runtime Error):
# 1.Nが三の倍数でない場合、全てが0でなければならない.(a_i=Σa_k∧a_(i-1)+a_(i+1)=a_iとなるのはa_i=0のみ)
# 2.Nが3の倍数の場合、a,b,a+bを満たす三種類以下の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
string = "No"
input_dict = {}
for i in map(int, input().split()):
    if(i in input_dict):
        input_dict[i] += 1
    else:
        input_dict[i] = 1
if((N % 3) == 0):
    num_count = len(input_dict.keys())
    if(num_count == 3 ):
        input_list = list(input_dict.keys())
        if(input_list[0] ^ input_list[1] == input_list[2] and input_dict[input_list[0] == N//3 and input_dict[input_list[1]]] == N//3):
            string = "Yes"
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            string = "Yes"
    elif(num_count == 1):
        if(0 in input_dict):
            string = "Yes"
else:
    if(0 in input_dict and input_dict[0] == N):
        string = "Yes"
print(string)

Buggy submission (verdict: Runtime Error):
# 1.Nが三の倍数でない場合、全てが0でなければならない.(総排他的論理和が各数と等しくならねばならず、その中でa_(i-1)+a_(i+1)=a_iとなるのは0のみ)
# 2.Nが3の倍数の場合、a,b,a+bの三種類の数字で構成されていなければならず、かつそれであればよい。

N = int(input())
if(N%3 == 0):
    input_dict = {}
    for i in map(int, input().split()):
        if(i in input_dict):
            input_dict[i] += 1
        else:
           input_dict[i] = 1
    num_count = len(input_dict.keys())
    if(num_count > 3 ):
        print("No")
    elif(num_count == 2):
        if(0 in input_dict and input_dict[0] == N//3):
            print("Yes")
        else:
            print("No")
    elif(num_count == 1):
        if(0 in input_dict):
            print("Yes")
        else:
            print("No")
    else:
        if(input_list[0] ^ input_list[1] == input_list[2]):
            print("Yes")
        else:
            print("No")
else:
    for i in map(int, input().split()):
        if(i != 0):
            print("No")
            break
    else:
        print("Yes")
Problem p03061 (python)

Fixed submission:

import fractions
a = int(input())
num_list = list(map(int, input().split()))
head_gcd_list = [0]
tail_gcd_list = [0]
for i in range(a - 1):
    head_gcd_list.append(fractions.gcd(head_gcd_list[i], num_list[i]))
    tail_gcd_list.append(fractions.gcd(tail_gcd_list[i], num_list[(i*-1) - 1]))
max_gcd = 0
for i,j in zip(head_gcd_list, reversed(tail_gcd_list)):
    current_gcd = fractions.gcd(i, j)
    if(current_gcd > max_gcd):
        max_gcd = current_gcd
print(max_gcd)

Buggy submission (verdict: Runtime Error):

import math
a = int(input())
num_list = list(map(int, input().split()))
head_gcd_list = [num_list[0]]
tail_gcd_list = [num_list[-1]]
for i in range(a - 2):
    head_gcd_list.append(math.gcd(head_gcd_list[i], num_list[i+1]))
    tail_gcd_list.append(math.gcd(tail_gcd_list[(i*-1) - 1], num_list[(i*-1) - 2]))
max_gcd = max(head_gcd_list.pop(-1), tail_gcd_list.pop(-1))
for i,j in zip(head_gcd_list, reversed(tail_gcd_list)):
    current_gcd = math.gcd(i, j)
    if(current_gcd > max_gcd):
        max_gcd = current_gcd
print(max_gcd)

Buggy submission (verdict: Runtime Error):

import math
input()
num_list = list(map(int, input().split()))
head_gcd_list = [num_list[0]]
tail_gcd_list = [num_list[-1]]
for i in range(len(num_list) - 1):
    head_gcd_list.append(math.gcd(head_gcd_list[i], num_list[i+1]))
    tail_gcd_list.append(math.gcd(tail_gcd_list[(i*-1) - 1], num_list[(i*-1) - 2]))
max_gcd = 0
for i,j in zip(head_gcd_list, reversed(tail_gdc_list)):
    current_gcd = math.gcd(i, j)
    if(current_gcd > max_gcd):
        max_gcd = current_gcd
print(max_gcd)
Problem p03125 (python)

Fixed submission:
a, b = map(int, input().split())
if b // a == b / a:
  print(a+b)
else:
  print(b-a)

Buggy submission (verdict: Runtime Error):
a, b  map(int, input().split())
if b // a == b / a:
  print(a+b)
else:
  print(a-b)
Problem p03280 (python)

Fixed submission:
B, C = map(int, input().split())
print(B*C-B-C+1)

Buggy submission (verdict: Runtime Error):
b, c = map(int, input().split())
print(B*C-B-C+1)
Problem p03543 (python)

Fixed submission:
s = input()
if(s[0] == s[1]):
    if(s[1] == s[2]):
        print("Yes")
        exit()
if(s[1] == s[2]):
    if(s[2] == s[3]):
        print("Yes")
        exit()
print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if(s[0] == s[1]):
    if(s[1] == s[2]):
        print("Yes")
        return
if(s[1] == s[2]):
    if(s[2] == s[3]):
        print("Yes")
        return
print("No")
Problem p03962 (python)

Fixed submission:
a,b,c=map(int, input().split())
print(max((a!=b)+(b!=c)+(c!=a),1))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
print(max((a!=b)+(b!=c)+(c!=a),1)
Problem p03997 (python)

Fixed submission:
print((int(input())+int(input()))*int(input())//2)

Buggy submission (verdict: Runtime Error):
print((int(input())+int(input())*int(input())//2)

Buggy submission (verdict: Runtime Error):
print((input()+input())*input()//2)
Problem p02802 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * N
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
for i in range(N):
    if AC[i] == 0:
        WA[i] = 0
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
p = []; S = []
for _ in range(M):
    p_tmp, S_tmp = input().split()
    p.append(int(p_tmp))
    S.append(str(S_tmp))

AC = [0] * N
WA = [0] * M
for i in range(M):
    if AC[p[i] - 1] == 1:
        continue
    if S[i] == 'AC':
        AC[p[i] - 1] = 1
    else:
        WA[p[i] - 1] += 1
AC_count = sum(AC)
WA_count = sum(WA)
print(AC_count, WA_count)
Problem p02900 (python)

Fixed submission:
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def factorize(n):
    a = 2
    lst = []
    while a * a <= n:
        if n % a == 0:
            n = n / a
            lst.append(a)
        else:
            a += 1
    if n > 1:
        lst.append(n)
    return lst

A, B = [int(x) for x in input().split()]
lst = factorize(gcd(A, B))
print(len(set(lst)) + 1)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)

def factorize(n):
    result = {}
    dev = 2
    while dev ** 2 <= n:
        cnt = 0
        while n % dev == 0:
            n //= dev
            cnt += 1
        result[dev] = cnt
        dev += 1
    if n > 1:
        if max(result) == n:
            result[n] += 1
        else:
            result[n] = 1
    return result

A, B = [int(x) for x in input().split()]
fct = factorize(gcd(A, B))
print(len(fct) + 1)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a > b:
        big = a
        small = b
    else:
        big = b
        small = a
    while True:
        remain = big % small
        if remain == 0:
            break
        big = small
        small = remain
    return small

def factorize(n):
    result = {}
    dev = 2
    while dev ** 2 <= n:
        cnt = 0
        while n % dev == 0:
            n //= dev
            cnt += 1
        result[dev] = cnt
        dev += 1
    if n > 1:
        if max(result) == n:
            result[n] += 1
        else:
            result[n] = 1
    return result

A, B = [int(x) for x in input().split()]
gcd_AB = gcd(A, B)
fct = factorize(gcd_AB)
print(len(fct) + 1)
Problem p02983 (python)

Fixed submission:
l, r = [int(x) for x in input().split()]

l_mod = l % 2019
if r - l >= 2019:
    r_mod = l_mod + (r - l - 2019) % 2019 + 2019
else:
    r_mod = l_mod + (r - l) % 2019

ans = 2019
for i in range(l_mod, r_mod):
    for j in range(i + 1, r_mod + 1):
        tmp = (i * j) % 2019
        if tmp < ans:
            ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
l, r = [int(x) for x in input().split()]

l_mod = l % 2019
r_mod = l_mod + (r - l + 1) % 2019 - 1

for i in range(l_mod, r_mod):
    for j in range(i + 1, r_mod + 1):
        tmp = (i * j) % 2019
        if (i = l_mod and j = i + 1) or tmp < ans:
            ans = tmp

print(ans)
Problem p02813 (python)

Fixed submission:
import itertools

n = int(input())
p = input().replace(" ", "")
q = input().replace(" ", "")
m = ""
for i in range(1, n + 1):
    m += str(i)
anagram_list = ["".join(v) for v in itertools.permutations(m)]

pa = 0
qa = 0

for i in range(len(anagram_list)):
    if anagram_list[i] == p:
        pa = i+1
    if anagram_list[i] == q:
        qa = i+1
print(abs(pa-qa))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
p = input().replace(" ", "")
q = input().replace(" ", "")
m = ""
for i in range(1, n + 1):
    m += str(i)
anagram_list = ["".join(v) for v in itertools.permutations(m)]

pa = 0
qa = 0

for i in range(len(anagram_list)):
    if anagram_list[i] == p:
        pa = i+1
    if anagram_list[i] == q:
        qa = i+1a
print(abs(pa-qa))
Problem p02838 (python)

Fixed submission:
import numpy as np

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)

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

n = int(input())
s = input().split()
a = []
for i in range(n):
    a.append(int(s[i]))
arr = np.array(a)
# arr = np.array([int(i) for i in input().split()])

mod = 10 ** 9 + 7
ans = 0

for i in range(60):
    #arrについて2進数を右へ論理シフトした値になる？
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans % mod)
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(min(A * N, B))

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
mod = 2019
ans = mod + 100

if R - L >= 3000:
    print(0)
else:
    L %= mod
    R %= mod
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % mod
            if m < ans:
                ans = m
print(ans)
Problem p03086 (python)

Fixed submission:
S = input()
count = 0
c = [0]
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        c.append(count)
        count = 0
c.append(count)
print(max(c))

Buggy submission (verdict: Runtime Error):
S = input()
count = 0
c = []
for i in range(len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
    else:
        c.append(count)
        count = 0
print(max(c))
Problem p03160 (python)

Fixed submission:
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i] = min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if i>1:
        dp[i] = min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/dp/tasks/dp_b

N,K = map(int,input().split())
h = [int(x) for x in input().split()]

dp = [0] * (N)
dp[0] = 0

# 参考：https://atcoder.jp/contests/dp/submissions/10181844
for i in range(1, N):
    tmp = [dp[k] + abs(h[i] - h[k]) for k in range(max(0, i - K), i)]
    dp[i] = min(tmp)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#メモ化再帰
#入力
h = [0]*100010
dp = [float("inf")]*100010

def rec(i):
    #DPの値が更新されていたらそのままリターン
    if dp[i]<float("inf"):
        return dp[i]
    if i==0:
        return 0
    res = float("inf")
    res = min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:
        res = min(res, rec(i - 2) + abs(h[i] - h[i - 2]))
    dp[i]=res
    return dp[i]

#入力
N=int(input())
H=list(map(int,input().split()))
for i in range(N):
    h[i] = H[i]

print(rec(N-1))

Buggy submission (verdict: Runtime Error):
#配るDP
N=int(input())
h=[int(i) for i in input().split()]

#DPテーブル＆最小化問題なのでINFに初期化
dp = [float("inf")]*N
#初期条件
dp[0] = 0
#ループ
for i in range(N):
    dp[i+1] = min(dp[i],dp[i]+abs(h[i]-h[i+1]))
    if i>1:
        dp[i+2] = min(dp[i],dp[i]+abs(h[i]-h[i+2]))

print(dp[-1])
Problem p03324 (python)

Fixed submission:
D, N = map(int, input().split())
if N == 100:
    print(100**D*N+100**D)
else:
    print(100**D*N)

Buggy submission (verdict: Runtime Error):
D,N = map(int,input().split())
ans = []
for i in range(1,N+1):
    tmp = (100**D)*i
    if tmp // 100 == 100**D:
        continue
    else:
        ans.append(tmp)
print(ans[N-1])
Problem p03331 (python)

Fixed submission:
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(1,n):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))

Buggy submission (verdict: Runtime Error):
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(2,n):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))
Problem p03361 (python)

Fixed submission:
import sys

H,W = map(int,input().split())
s = [list(input()) for i in range(H)]
a = [["."]*W for _ in range(H)]
for i in range(H):
    for j in range(1,W):
        if s[i][j-1] == "#" and s[i][j] == "#":
            a[i][j-1] = "#"
            a[i][j] = "#"

sT = list(zip(*s))
aT = [list(x) for x in zip(*a)]

for i in range(W):
    for j in range(1,H):
        if sT[i][j-1] == "#" and sT[i][j] == "#":
            aT[i][j-1] = "#"
            aT[i][j] = "#"

ans = list(zip(*aT))

for i in range(H):
    for j in range(W):
        if s[i][j] != ans[i][j]:
            print("No")
            sys.exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import sys

H,W = map(int,input().split())
s = [list(input()) for i in range(W)]
a = [["."]*H for _ in range(W)]
for i in range(H):
    for j in range(1,W):
        if s[i][j-1] == "#" and s[i][j] == "#":
            a[i][j-1] = "#"
            a[i][j] = "#"

sT = list(zip(*s))
aT = [list(x) for x in zip(*a)]

for i in range(H):
    for j in range(1,W):
        if sT[i][j-1] == "#" and sT[i][j] == "#":
            aT[i][j-1] = "#"
            aT[i][j] = "#"

ans = list(zip(*aT))

for i in range(H):
    for j in range(W):
        if s[i][j] != ans[i][j]:
            print("No")
            sys.exit()
print("Yes")
Problem p03494 (python)

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

count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
for i in range(n):
    A[i]=int(input())
count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [0]*n
for i in range(n):
    A[i]=int(input())
count = 0
f = True
while(True):
    flag = True
    for i in range(n):
        if A[i]%2 !=0:
            flag=False
    if flag == False:
        break
    for i in range(n):
        if A[i]%2 == 0:
            A[i]/=2
    count+=1
print(count)
Problem p03680 (python)

Fixed submission:
import sys

N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
s = 1
for i in range(N):
    tmp = a[s]
    if tmp == 2:
        print(i+1)
        sys.exit()
    else:
        s = tmp
print(-1)

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))
s = [0] * max(a)
s[0] = 1
count = 0
for _ in range(N):
    for i in range(N):
        if s[i] == 1:
            s[i] = 0
            s[a[i]-1] = 1
            break
    count += 1
    if s[1] == 1:
        print(count)
        sys.exit()
print(-1)