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

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

ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

if n > 2:
    if m == 1:
        ans = n-2
    elif m == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)
    



print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [[0]*m for i in range(n)]
ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

if n > 2:
    if m == 1:
        ans = n-2
    elif m == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)
    



print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [[0]*m for i in range(n)]
ans = 0
if n == 1:
    if m == 1:
        ans = 1
    elif m == 2:
        ans = 0
    else:
        ans = m - 2

if n == 2:
    ans = 0

if n > 2:
    if m == 1:
        ans = n-2
    elif m == 2:
        ans = 0
    else:
        ans = (n-2)*(m-2)
    



print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [[0]*m for i in range(n)]
def rev(k):
    if k==1:
        return 0
    else:
        return 1
for i in range(n):
    for j in range(m):
        a[i][j] = rev(a[i][j])
        if j > 0:
            a[i][j-1] = rev(a[i][j-1])
        if j < m-1:
            a[i][j+1] = rev(a[i][j+1])
        if i > 0:
            a[i-1][j] = rev(a[i-1][j])
            if j > 0:
                a[i-1][j-1] = rev(a[i-1][j-1])
            if j < m-1:
                a[i-1][j+1] = rev(a[i-1][j+1])
        if i < n-1:
            a[i+1][j] = rev(a[i+1][j])
            if j > 0:
                a[i+1][j-1] = rev(a[i+1][j-1])
            if j < m-1:
                a[i+1][j+1] = rev(a[i+1][j+1])

ans = 0
for i in range(n):
    for j in range(m):
        ans += a[i][j]
print(ans)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0] + str(len(s) - 2) + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
print(f"{s[0]}{len(s) - 2}{s[-1]}")

Buggy submission (verdict: Runtime Error):
str = input()
print(f"{str[0]}{len(str) - 2}{str[-1]}")
Problem p02675 (python)

Fixed submission:
N = (input())
N = N[-1]

hon = [str(n) for n in list([2,4,5,7,9])]
pon = [str(n) for n in list([0,1,6,8])]
bon = ["3"]

if N in hon:
  print('hon')
elif N in pon:
  print("pon")
elif N in bon:
  print("bon") 
else:
  print("booom")

Buggy submission (verdict: Runtime Error):
N = str(N)
N = N[-1]

hon = [str(n) for n in list([2,4,5,7,9])]
pon = [str(n) for n in list([0,1,6,8])]
bon = ["3"]

if N in hon:
  print('hon')
elif N in pon:
  print("pon")
elif N in bon:
  print("bon") 
else:
  print("booom")

Buggy submission (verdict: Runtime Error):
N = N[-1]

hon = [str(n) for n in list([2,4,5,7,9])]
pon = [str(n) for n in list([0,1,6,8])]
bon = ["3"]

if N in hon:
  print('hon')
elif N in pon:
  print("pon")
elif N in bon:
  print("bon") 
else:
  print("booom")
Problem p02675 (python)

Fixed submission:
temp = input()
if temp[-1] in {'2','4','5','7','9'}:
  print('hon')
elif temp[-1] in {'3'}:
  print('bon')
else:
  print('pon')

Buggy submission (verdict: Runtime Error):
temp = input()
if temp[-1] in {'2','4','5','7','9'}:
  return 'hon'
elif temp[-1] in {'3'}:
  return 'bon'
else:
  return 'pon'
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if a % 2 == 0 or b % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
if a % 2 == 0 or b % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
a, b = map(int, raw_input().split())
if a%2 == 0 or b%2 == 0:
    print('no')
else:
    print('yes')
Problem p02677 (python)

Fixed submission:
import math
def squared(x):
    return x**2

def theta(h, m):
    mr = 6 * m
    hr = 30 * h + m / 2
    r = abs(float(hr) - float(mr))
    return r

def length(a, b, h, m):
    return math.sqrt(squared(a) + squared(b) - 2 * a * b * math.cos(math.radians(theta(h, m))))


a, b, h, m = [x for x in map(int, input().split())]

print(length(a, b, h, m))

Buggy submission (verdict: Runtime Error):
def squared(x):
    return x**2

def theta(h, m):
    mr = 6 * m
    hr = 30 * h + m / 2
    r = abs(float(hr) - float(mr))
    return r

def length(a, b, h, m):
    return math.sqrt(squared(a) + squared(b) - 2 * a * b * math.cos(math.radians(theta(h, m))))


a, b, h, m = [x for x in map(int, input().split())]

print(length(a, b, h, m))
Problem p02675 (python)

Fixed submission:
a = int(input())
s = a % 10
print("hon" if s ==2 or s == 4 or s == 5 or 
      s == 7 or s == 9 else "pon" if 
      s == 0 or s == 1 or s == 6 or s == 8
      else "bon")

Buggy submission (verdict: Runtime Error):
import math as ma

a,b,h,m = map(int,input().split())

al = h*30
bl = m*6
dec = al-bl
dec = dec % 180
if dec < 0:
  dec *= -1
rad = dec * ma.pi / 180
r = ma.sqrt(a**2 + b**2 -2*a*b*ma.cos(rad))
print(r)

Buggy submission (verdict: Runtime Error):
a = input()
s = a % 10
print("hon" if s ==2 or s == 4 or s == 5 or 
      s == 7 or s == 9 else "pon" if 
      s == 0 or s == 1 or s == 6 or s == 8
      else "bon")
Problem p02900 (python)

Fixed submission:
import fractions

A,B=map(int,input().split())
gcd=fractions.gcd(A,B)
ans=1

if gcd > 1:
  fact = 2
  tmp = gcd
  while(fact * fact <= gcd):
    if tmp % fact == 0:
      ans += 1
      while(tmp % fact == 0):
        tmp //= fact
    fact += 1
  if tmp > 1:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A,B=map(int,input().split())
gcd=math.gcd(A,B)
ans=1

if gcd > 1:
  for i in range(2,math.sqrt(gcd)//1 + 1):
    if gcd % i == 0:
      ans += 1
      while(gcd % i == 0):
        gcd /= i
print(ans)
Problem p02923 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
ans=0
i = 0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp +1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
ans=0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp +1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
ans=0

while i < N-1:
  tmp=0
  for j in range(i,N-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
  ans = max(ans,tmp)
  i = i + tmp
print(ans)
Problem p03605 (python)

Fixed submission:
N = int(input())
n10 = N//10
n1 = N%10
if n10 == 9 or n1 == 9:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from itertools import permutations

N, M, R = map(int, input().split())
r = map(int, input().split())
 
INF = float("inf")
d = [[INF] * (N + 1) for _ in range(N + 1)]
for n in range(1, N + 1):
    d[n][n] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c

for k in range(1, N + 1):
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

ans = INF
for p in permutations(r):
    cnt = 0
    for i in range(len(p) - 1):
        p1, p2 = p[i:i + 2]
        cnt += d[p1][p2]
    ans = min(cnt, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
 
N,M,R = map(int, input().split())
r = list(map(int,input().split()))
 
dis = [[float('inf')]*(N+1) for _ in range(N+1)]
for i in range(1, N+1):
	dis[i][i] = 0
for i in range(M):
    Ai, Bi, Ci = map(int, input().split())
    if dis[Ai][Bi] > Ci:
        dis[Ai][Bi] = Ci
        dis[Bi][Ai] = Ci
for k in range(1, N+1):    # Warshall-Floyd
    for i in range(1, N+1):
        for j in range(i, N+1):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]
 
ans = float('inf')
for p in permutations(r):
    cnt = 0
    for i in range(len(p)-1):
        cnt += dis[p[i]][p[i+1]]
    ans = min(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
 
N,M,R = map(int, input().split())
r = list(map(int,input().split()))
 
dis = [[float('inf')]*(N+1) for _ in range(N+1)]
for i in range(N+1):
	dis[i][i] = 0
for i in range(M):
    Ai, Bi, Ci = map(int, input().split())
    if dis[Ai][Bi] > Ci:
        dis[Ai][Bi] = Ci
        dis[Bi][Ai] = Ci
for k in range(1, N+1):    # Warshall-Floyd
    for i in range(1, N+1):
        for j in range(i, N+1):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]
 
ans = float('inf')
for p in permutations(r):
    cnt = 0
    for i in range(len(p)-1):
        cnt += dis[p[i]][p[i+1]]
    ans = min(ans, cnt)
print(ans)
Problem p02789 (python)

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

if N == M:
    print('Yes')
else:
    print('No')

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

if N == M:
    print('Yes')
else
    print('No')
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
  for j in range(i, n-1):
    k = 2*j - i
    if k >= n:
      continue
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = s.count('B') * s.coufnt('G') * s.count('R')
for i in range(n):
  for j in range(i, n-1):
    k = 2*j - i
    if k >= n:
      continue
    if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
      ans -= 1

print(ans)
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

alist = []

for i in range(1 << N):
    mlist = []
    slist = []
    plist = [0] * M # 0要素の数M個のリスト

    for j in range(N):

        if (i >> j) & 1 == 1:
            mlist.append(C[j])
            slist.append(A[j])

    for j in range(len(slist)):
        if len(slist)==1:
            plist = slist[j]
        else:
            plist = [a + b for a, b in zip(plist, slist[j])]

    if all((x >= X for x in plist)) == True:
        alist.append(sum(mlist))

if len(alist) != 0:
    print(min(alist))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
#
C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

# N, M, X = 3, 3, 10
# C = [60,70,50]
# A = [[2,2,4],[8,7,9],[2,3,9]]

alist = []

for i in range(1 << N):
    mlist = []
    slist = []
    plist = [0] * M # 0要素の数M個のリスト

    for j in range(N):

        if (i >> j) & 1 == 1:
            mlist.append(C[j])
            slist.append(A[j])
    # print(i,mlist,slist,len(slist))

    for j in range(len(slist)):
        if len(slist)==1:
            plist = slist[j]
        else:
            plist = [a + b for a, b in zip(plist, slist[j])]

    if all((x >= X for x in plist)) == True:
        alist.append(sum(mlist))
        # print(i,plist)

print(min(alist))
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
d = [[] for i in range(n)]    


for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    d[p].append(s)

ac_cnt, w_cnt = 0, 0
for l in d:
    if len(l) != 0 and "AC" in l:
        w_cnt += l.index("AC")

    if "AC" in l:
        ac_cnt += 1

print(ac_cnt, w_cnt)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = [[] for i in range(n)]    


for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    d[p].append(s)

ac_cnt, w_cnt = 0, 0
for l in d:
    if len(l) != 0:
        w_cnt += l.index("AC")

    if "AC" in l:
        ac_cnt += 1

print(ac_cnt, w_cnt)
Problem p02814 (python)

Fixed submission:
from functools import reduce

n, m = map(int, input().split())
A =[i//2 for i in list(map(int, input().split()))]

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

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


def cntTwo(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

if len(set(map(cntTwo, A))) != 1:
    print(0)
    exit()

def merge(a, b):
    l = lcm(a, b)
    if l > 10 ** 9:
        return 0
    return l

x = reduce(merge, A)
if x == 0:
    print(0)
else:
    print(m//x - m//(x*2))

Buggy submission (verdict: Runtime Error):
from functools import reduce

n, m = map(int, input().split())
A =[i//2 for i in list(map(int, input().split()))]

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

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


def cntTwo(n):
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    return cnt

if len(set(map(cntTwo, A))) != 1:
    print(0)
    exit()

def merge(a, b):
    l = lcm(a, b)
    if l > 10 ** 9:
        return 0
    return l

x = int(reduce(merge, A))
print(m//x - m//(x*2))
Problem p02837 (python)

Fixed submission:
from itertools import product
N=int(input())
XYs = []
for i in range(N):
    A = int(input())
    XYs.append([tuple(map(int, input().split())) for _ in range(A)])

n=0
for ts in product([1,0], repeat=N):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in XYs[i]):
                break
    else:
        n=max(n,sum(ts))
print(n)

Buggy submission (verdict: Runtime Error):
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    for j in range(a):
        xy.append([tuple(map(int, input().split()))])

ans = 0

for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product

n = int(input())
xy = []
for i in range(n):
    a = int(input())
    for j in range(a):
        xy.append([tuple(map(int, input().split()))])

ans = 0

for ts in product([1,0], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[x-1] == y for x, y in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)
Problem p02838 (python)

Fixed submission:
import numpy as np

n = int(input())
arr = np.array(list(map(int, input().split())))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    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())
arr = np.array(map(int, input().split()))

mod = 10 ** 9 + 7

ans = 0
for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    ans += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(ans%mod)
Problem p02854 (python)

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

total = sum(A)

s = 0
for a in A:
	s += a
	if 2 * s >= total:
		break

B = A[::-1]
t = 0
for b in B:
	t += b
	if 2 * t >= total:
		break

print(min(2*s-total, 2*t-total))

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

i, s = 0, 0
while True:
	s += a[i]
	i += 1
	if s >= sum(a) // 2:
		break

b = a[::-1]
j, t = 0, 0
while True:
	t += b[j]
	j += 1
	if t >= sum(a) // 2:
 
print(min(s-(sum(a)-s), t-(sum(a)-t)))
Problem p02888 (python)

Fixed submission:
from bisect import *

n = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        lower = max(j+1, bisect_right(l, b-a))
        upper = bisect_left(l, a+b)
        cnt += max(0, upper-lower)

print(cnt)

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

n = int(input())
l = sorted(list(map(int, input().split())))
nl = np.array(l)

cnt = 0

for i in range(n):
    a = l[i]
    for j in range(i+1, n):
        b = l[j]
        cnt += sum(nl[j+1:] < a + b)

print(cnt)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

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

tree = [[] for _ in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

add = [0] * n

for i in range(q):
    p, x = map(int, input().split())
    add[p-1] += x

ans = [0] * n

def dfs(v, p, value):
    value += add[v]
    ans[v] = value
    for c in tree[v]:
        if c == p:
            continue
        dfs(c, v, value)

dfs(0, -1, 0)

print(*ans)

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

tree = [[] for _ in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

add = [0] * n

for i in range(q):
    p, x = map(int, input().split())
    add[p-1] += x

ans = [0] * n

def dfs(v, p, value):
    value += add[v]
    ans[v] = value
    for c in tree[v]:
        if c == p:
            continue
        dfs(c, v, value)

dfs(0, -1, 0)

print(*ans)
Problem p02946 (python)

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

for i in range(x-(k-1), x + (k-1)+1):
  print(i, end=" ")

Buggy submission (verdict: Runtime Error):
import java.util.Scanner;

public class Main<i> {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int s = x - (k - 1);
        int e = x + (k - 1);

        for (int i = s; i <= e; i++) {
            System.out.println(i);
        }
    }
}
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(a)[-2]

for i in range(n):
  if a[i] != ma:
    print(ma)
  else:
    print(sma)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
ma = max(a)
sma = sorted(A)[-2]

for i in range(n):
  if a[i] != a:
    print(ma)
  else:
    print(sma)
Problem p03000 (python)

Fixed submission:
n, x = input().split()
l = [0] + [int(i) for i in input().split()]
x = int(x)

c = 0

for i in range(len(l)):
    if sum(l[:i+1]) <= x:
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
L = [0] + [int(i) for i in input().split()]

c = 0

for i in range(len(l)):
    if sum(L[:i+1]) <= x:
        c += 1
print(c)
Problem p03231 (python)

Fixed submission:
def gcd(a, b):
     while b:
         a, b = b, a%b
     return a

n, m = map(int, input().split())
s, t = input(), input()

l = n*m//gcd(n, m)

a = [i*(l//n) for i in range(n)]
b = [i*(l//m) for i in range(m)]

x = set(a) & set(b)

for i in x:
    if s[a.index(i)] != t[b.index(i)]:
        print(-1)
        exit()

print(l)

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

n, m = map(int, input().split())
s, t = input(), input()

l = n*m // gcd(n, m)

x = [0] * l
a, b = [], []

for i in range(n):
    x[i*(l//n)] = s[i]
    a.append(i*(l//n))

for j in range(m):
    x[j*(l//m)] = t[j]
    b.append(j*(l//m))

if "".join([x[i] for i in a]) == s and ("".join([x[j] for j in b])) == t:
    print(l)
else:
    print(-1)

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

n, m = map(int, input().split())
s, t = input(), input()

l = n*m // gcd(n, m)

x = [" "] * l
a, b = [], []
for i in range(n):
    x[i*(l//n)] = s[i]
    a.append(i*(l//n))
for j in range(m):
    x[j*(l//m)] = t[j]
    b.append(j*(l//m))

if "".join([x[i] for i in a]) == s and ("".join([x[j] for j in b])) == t:
    print(l)
else:
    print(-1)
Problem p03296 (python)

Fixed submission:
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

  else:
    end += 1


print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)
Problem p03328 (python)

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

print(int(((((1+ (b - a)) * (b - a)) / 2 - b))))

Buggy submission (verdict: Runtime Error):
def height(n):
    return sum([i for i in range(n+1)])

tower = []

for i in range(1, 1000):
    tower.append(height(i))

a, b = map(int, input().split())

for i in tower:
    if tower[i] > a:
        ind = i-1
        break

print(abs(tower[ind] - a))

Buggy submission (verdict: Runtime Error):
def height(n):
    return sum([i for i in range(n+1)])

tower = []

for i in range(1, 1000):
    tower.append(height(i))

a, b = map(int, input().split())

for i in tower:
    if tower[i] > a:
        ind = i-1
        break

print(abs(tower[ind] - a))
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())

temp = "0" * (w+2)

s = [temp]

for i in range(h):
    s.append("0" + input() + "0")

s.append(temp)

for i in range(h+2):
    for j in range(w+2):
        flag = False
        if s[i][j] == "#":
            if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                flag = True
            if not flag:
                print("No")
                exit()

print("Yes")

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

temp = "0" * (h+2)

s = [temp]

for i in range(h):
    s.append("0" + input() + "0")

s.append(temp)

# print(s)

for i in range(h+2):
    for j in range(w+2):
        flag = False
        if s[i][j] == "#":
            if s[i-1][j] == "#" or s[i+1][j] == "#" or s[i][j+1] == "#" or s[i][j-1] == "#":
                flag = True
            if not flag:
                print("No")
                exit()

print("Yes")
Problem p03386 (python)

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

if (abs(a-b) + 1) / 2 <= k:
  for i in range(a, b+1):
    print(i)
  exit()

for i in range(k):
  print(a+i)

for i in sorted([b - i for i in range(k)]):
  print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

l = []

for k in i:
    l.append(k)

for k in j:
    l.append(k)

for i in sorted(list(set(l))):
    print(i)

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

x = list(range(a, b+1))

i = x[:k]
j = x[-k:]

for k in i:
    print(k)

for k in j:
    print(k)
Problem p03471 (python)

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        if 10000 * a + 5000 * b + 1000 * (n-(a+b)) == y:
            print(a, b, n-(a+b))
            exit()

print("-1 -1 -1")

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

for i in range(n+1):
    for j in range(n-i+1):
        if 10000 * a + 5000 + b + 1000 * (n-(a+b)) == y:
            print(a, b, n-(a+b))
            exit()

print(-1, -1, -1)