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

Fixed submission:
i = [int(each) for each in input().split()]
print(min(i[1], i[2]), max(i[1] + i[2] - i[0], 0))

Buggy submission (verdict: Runtime Error):
n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] - tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    tmp_point = -1
    dish = None
    for tmp_dish in dishes:
        if dish is None:
            dish = tmp_dish
        elif tmp_point > dish[0]:
            break
        else:
            if dish[player + 1] > tmp_dish[player + 1] and tmp_dish[player + 1] - tmp_dish[int(not player) + 1] >= 0:
                dish = tmp_dish
            else:
                pass
    # print(dish)
    dishes.remove(dish)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])

Buggy submission (verdict: Runtime Error):
if args is None:
    i = [int(each) for each in input().split()]
else:
    i = [int(each) for each in args.split()]
print(min(i[1], i[2]), max(i[1] + i[2] - i[0], 0))
Problem p03141 (python)

Fixed submission:
n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((abs(tmp[0] + tmp[1]), tmp[0], tmp[1]))

dishes = sorted(dishes, key=lambda x: x[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes) > 0:
    dish = dishes.pop(0)
    point[player] += dish[player + 1]
    player = int(not player)
print(point[0] - point[1])

Buggy submission (verdict: Runtime Error):
n = input()
dishes = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dishes.append((tmp[0] - tmp[1], tmp[0], tmp[1]))

sorted(dishes, key=lambda v: v[0], reverse=True)

point = [0, 0]
player = 0
while len(dishes[0]) > 0:
    if player == 0:
        dish = dishes.pop(0)
    else:
        dish = dishes.pop(len(dishes) - 1)

    # remove dish
    dishes.remove(dish)

    point[player] += dish[player + 2]
    player = int(not player)
print(point[0] - point[1])

Buggy submission (verdict: Runtime Error):
n = input()
dish = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dish.append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1]))

point = [0, 0]

player = 0
while len(dish) > 0:
    # print(player.__str__(), player)

    sorted(dish, key=lambda v: dish[player], reverse=True)
    # print(dish[0])
    point[player] += dish.pop(0)[player + 2]
    player = int(not player)
    # print('point', point)

print(point[0] - point[1])

Buggy submission (verdict: Runtime Error):
n = input()
dish = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dish.append((tmp[0] - tmp[1], tmp[1] - tmp[0], tmp[0], tmp[1]))

point = [0, 0]

player = 0
while len(dish) > 0:

    sorted(dish, key=lambda v: dish[player], reverse=True)
    point[player] = dish.pop(0)[player + 2]
    player = int(not player)


print(point[0] - point[1])

Buggy submission (verdict: Runtime Error):
n = input()
dish = []
for i in range(int(n)):
    tmp = [int(each) for each in input().split()]
    dish.append((tmp[0] - tmp[1], tmp[1] - tmp[0]))

point = [0, 0]

player = 0
while len(dish) > 0:

    sorted(dish, key=lambda v: dish[player], reverse=True)
    point[player] += point[player]
    player = int(not player)
print(point[0] - point[1])
Problem p03074 (python)

Fixed submission:
n,k = map(int,input().split())
s = list(input())
a = []
switch = 0
tmp = 0
for i in range(n):
    if switch == 0:
        if s[i] == "1":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 1
    else:
        if s[i] == "0":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 0
a.append(tmp)

tmp = 0
if k*2 <= len(a):
    tmp = k
else:
    if len(a)%2 == 0:
        tmp = int(len(a)/2)
    else:
        tmp = len(a)//2 


ans = sum(a[0:tmp*2+1])
tmpans = sum(a[0:tmp*2+1])
i = 2
while i+tmp*2<=len(a):
    tmpans -= a[i-2]+a[i-1]
    if i+tmp*2 == len(a):
        tmpans += a[i+tmp*2-1]
    else:
        tmpans += a[i+tmp*2-1]+a[i+tmp*2] 
    ans = max(ans,tmpans)
    i+=2
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = list(input())
a = []
switch = 0
tmp = 0
for i in range(n):
    if switch == 0:
        if s[i] == "1":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 1
    else:
        if s[i] == "0":
            tmp += 1
        else:
            a.append(tmp)
            tmp = 1
            switch = 0
a.append(tmp)

tmp = 0
if k*2 <= len(a):
    tmp = k
else:
    if len(a)%2 == 0:
        tmp = len(a)/2
    else:
        tmp = len(a)//2 


ans = sum(a[0:tmp*2+1])
tmpans = sum(a[0:tmp*2+1])
i = 2
while i+tmp*2<=len(a):
    tmpans -= a[i-2]+a[i-1]
    if i+tmp*2 == len(a):
        tmpans += a[i+tmp*2-1]
    else:
        tmpans += a[i+tmp*2-1]+a[i+tmp*2] 
    ans = max(ans,tmpans)
    i+=2
print(ans)
Problem p03112 (python)

Fixed submission:
import bisect as bi
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) ]

for i in range(q):
    Q = x[i]
    ans_s = []
    ans_t = []
    ans_s.append(s[bi.bisect_left(s,Q)-1])
    ans_t.append(t[bi.bisect_left(t,Q)-1])
    ans = 10**11
    
    if bi.bisect_right(s,Q) == len(s):
        ans_s.append(s[bi.bisect_left(s,Q)-1])
    else:
        ans_s.append(s[bi.bisect_left(s,Q)])
        
    if bi.bisect_right(t,Q) == len(t):
        ans_t.append(t[bi.bisect_left(t,Q)-1])
    else:
        ans_t.append(t[bi.bisect_left(t,Q)])
    
    for i in range(2):
        for j in range(2):
            ans = min(ans,abs(ans_s[i]-Q)+abs(ans_s[i]-ans_t[j]),abs(ans_t[j]-Q)+abs(ans_s[i]-ans_t[j]))
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect as bi
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 = sorted([int(input()) for i in range(q) ])

for i in range(q):
    Q = x[i]
    ans_s = []
    ans_t = []
    ans_s.append(s[bi.bisect_left(s,Q)])
    ans_t.append(t[bi.bisect_left(t,Q)])
    ans = 10**11
    
    if bi.bisect_right(s,Q) == len(s):
        ans_s.append(s[bi.bisect_left(s,Q)-1])
    else:
        ans_s.append(s[bi.bisect_left(s,Q)])
        
    if bi.bisect_right(t,Q) == len(t):
        ans_t.append(t[bi.bisect_left(t,Q)-1])
    else:
        ans_t.append(t[bi.bisect_left(t,Q)])
    
    for i in range(2):
        for j in range(2):
            ans = max(ans,abs(ans_s[i]-Q)+abs(ans_s[i]-ans_t[j]),abs(ans_t[j]-Q)+abs(ans_s[i]-ans_t[j]))
    
    print(ans)
Problem p03126 (python)

Fixed submission:
n,m = map(int ,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = set()
for i in range(n):
    a[i].pop(0)
b = set(a[0])
for i in range(n):
    c = set(a[i])
    b = b&c
print(len(list(b)))

Buggy submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(n)]
b = set()
for i in range(n):
    a[i].pop(0)
b = set(a[0])
for i in range(n):
    c = set(a[i])
    b = b&c
print(len(list(b)))
Problem p03244 (python)

Fixed submission:
import collections
n = int(input())
v = list(map(int,input().split()))
a = v[0::2]
b = v[1::2]
a = collections.Counter(a)
a = a.most_common()
b = collections.Counter(b)
b = b.most_common()
c = n//2
if a[0][0] != b[0][0]:
    ans = c-a[0][1] + c-b[0][1]
    print(ans)
else: 
    if len(a) == 1:
        tmpa = 0
    else:
        tmpa = a[1][1]
    if len(b) == 1:
        tmpb = 0
    else:
        tmpb = b[1][1]
    ans1 = c-tmpa + c-b[0][1]
    ans2 = c-a[0][1] + c-tmpb
    print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int,input().split()))
a = v[0::2]
suma = len(a)
b = v[1::2]
sumb = len(b)
a = collections.Counter(a)
a = a.most_common()
b = collections.Counter(b)
b = b.most_common()

if a[0][0] != b[0][0]:
        ans = suma-a[0][1] + sumb-b[0][1]
        print(ans)
else:  
        ans1 = suma-a[1][1] + sumb-b[0][1]
        ans2 = suma-a[0][1] + sumb-b[1][1]
        print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
a = []
x = []
b = []
y = []

for i in range(n):
        if i%2==1:
                if v[i] in a:
                        x[a.index(v[i])] += 1
                else:
                        a.append(v[i])
                        x.append(1)
        else:
                if v[i] in b:
                        y[b.index(v[i])] += 1
                else:
                        b.append(v[i])
                        y.append(1)

if a[x.index(max(x))] != b[y.index(max(y))]:
        x=sorted(x)[::-1]
        y=sorted(y)[::-1]

        sumx = sum(x)
        sumy = sum(y)

        changea = sumx-x[0]
        changeb = sumy-y[0]
        print(changea + changeb)
else:  
        x=sorted(x)[::-1]
        y=sorted(y)[::-1]
        sumx = sum(x)
        sumy = sum(y)

        ans1 = sumx-x[0] + sumy-y[1]
        ans2 = sumx-x[1] + sumy-y[0]
        print(min(ans1,ans2))
Problem p03323 (python)

Fixed submission:
a,b= map(int ,input().split())
if a>8 or b>8:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input()) 
b = int(input())
if a>9 or b>9:
    print(":(")
else:
    print("Yay!")
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
s = list(s)
x = 0
for i in range(1,n):
  a = set(s[:i])
  b = set(s[i:])
  c = len(list(a&b))
  if x<c:
    x = c
print(x)

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
x=[]
y=[]
count=[]
for i in range (a):
    for j in range (i):
        x[j]=s[j]
    for k in range (a-i):
        y[k]=s[i+k]
    for l in range (i):
        for m in range (a-i):
            if x[l] == y[m]:
                count[i]+=1
                break
print(max(count))
Problem p03262 (python)

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

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
xn = map(int, input().split())
dxn = [abs(x-X) for x in xn]
import fractions
a, b = dxn[0], dxn[1]
for i in range(N-1):
    c = fractions.gcd(a, b)
    a = b
    b = c
print(c)
Problem p03435 (python)

Fixed submission:
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

bs = []
for a1 in range(0, 101):
    for b1 in range(0, 101):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 101):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 101):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 101):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 101):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

bs = []
for a1 in range(0, 100):
    for b1 in range(0, 100):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 100):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 100):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 100):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 100):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")
Problem p03112 (python)

Fixed submission:
import sys
import bisect
input = sys.stdin.readline

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

s = [-1 for i in range(a)]
t = [-1 for i in range(b)]

for i in range(a):
	S = int(input())
	s[i] = S
    
for i in range(b):
	T = int(input())
	t[i] = T
    
s.sort()
t.sort()
for i in range(q):
	x = int(input())

	slidx = bisect.bisect_left(s, x) -1
	tlidx = bisect.bisect_left(t, x) -1
	sl = -20000000000
	tl = -20000000000
	sr = 20000000000
	tr = 20000000000
	if slidx >= 0:
		sl = s[slidx]
	if tlidx >= 0:
		tl = t[tlidx]

	if slidx < a-1:
		sr = s[slidx+1]
	if tlidx < b-1:
		tr = t[tlidx+1]
	sl = x - sl
	tl = x - tl
	sr = sr - x
	tr = tr - x
	#print([sl,tl,sr,tr])
	dist = min( [max(sl,tl), max(sr,tr), min(sr, sl)*2 + min(tr,tl), min(tr,tl)*2 + min(sr,sl)])
	print(dist)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int, input().split())
s = [-1 for i in range(a)]
t = [-1 for i in range(b)]

for i in range(a):
	S = int(input())
    s[i] = S
    
for i in range(b):
	T = int(input())
    t[i] = T
    
s.sort()
t.sort()

for i in range(q):
	x = int(input())
    slidx = bisect.bisect_left(s, x)
    tlidx = bisect.bisect_left(t, x) 
	sl = x - s[slidx]
	tl = x - t[tlidx]
    tr = 90000000000 - x
    sr = 90000000000 - x
    if slidx < a-1:
      sr = s[slidx+1] - x
    if slidx < b-1:
      tr = t[tlidx+1] - x
    dist = min( [max(sl,tl), max(sr,tr), min(sr, sl)*2 + min(tr,tl), min(tr,tl)*2 + min(sr,sl)] )
    print(dist)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
input = sys.stdin.readline

a,b,q = map(int, input().split())
s = [-1 for i in range(a)]
t = [-1 for i in range(b)]

for i in range(a):
	S = int(input())
    s[i] = S
    
for i in range(b):
	T = int(input())
    t[i] = T
    
s.sort()
t.sort()

for i in range(q):
	x = int(input())
    slidx = bisect.bisect_left(s, x)
    tlidx = bisect.bisect_left(t, x) 
	sl = x - s[slidx]
	tl = x - t[tlidx]
    tr = 90000000000 - x
    sr = 90000000000 - x
    if slidx < a-1:
      sr = s[slidx+1] - x
    if slidx < b-1:
      tr = t[tlidx+1] - x
    dist = min( max(sl,tl), max(sr,tr), min(sr, sl)*2 + min(tr,tl), min(tr,tl)*2 + min(sr,sl))
    print(dist)
Problem p03559 (python)

Fixed submission:
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); b.sort(); c.sort()
dp = [0]*(n+1)
for i in range(n-1, -1, -1) :
    ins_c = bisect.bisect_right(c, b[i])
    dp[i] = dp[i+1] + (n-ins_c)
ans = 0
for i in range(n) :
    ins_b = bisect.bisect_right(b, a[i])
    ans += dp[ins_b]

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(); b.sort(); c.sort()
ins_c = [0]*n
ins_b = [0]*n
parts_comb = [0]*n
for i in range(n) :
    ins_c = bisect.bisect_right(c, b[i])
    ins_b = bisect.bisect_right(b, a[i])
ans = 0
for i in range(n) :
    for j in range(ins_b[i], n) :
        ans += n - r_c

print(ans)
Problem p03601 (python)

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

w = [i+j for i in range(0,f+1,100*a) for j in range(0,f+1,100*b) if i+j <= f]
s = [i+j for i in range(0,f+1,c) for j in range(0,f+1,d) if i+j <= f]

W = w[-1]
S = 0
for ww in w :
    for ss in s :
        if ww+ss > f or ww == 0:
            continue
        elif ss/(ss+ww) > S/(W+S) and e >= 100*ss/ww:
            W = ww
            S = ss

print(W+S, S)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n) :
    for j in range(i+1, n) :
        for k in range(n) :
            if i == k or j == k:
                continue
            
            d = A[i][k] + A[k][j]
            if d == A[i][j] :
                ans += d
            elif d < A[i][j] :
                print(-1)
                exit()

print(ans)

Buggy submission (verdict: Runtime Error):
def main() :
    n = int(input())
    A = []
    for _ in range(n) :
        A.append(list(map(int, input().split())))

    ans = sum([sum(_A) for _A in A])
    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                if i == k :
                    break
                elif j == k :
                    continue
                
                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    ans -= d
                elif d < A[i][j] :
                    print(-1)
                    exit()

    print(ans//2)

main()

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

w = [i+j for i in range(0,f+1,100*a) for j in range(0,f+1,100*b) if i+j <= f]
s = [i+j for i in range(0,f+1,c) for j in range(0,f+1,d) if i+j <= f]

W = w[0]
S = 0
for ww in w :
    for ss in s :
        if ww+ss > f or ww == 0:
            continue
        elif ss/(ss+ww) > S/(W+S) and e >= 100*ss/ww:
            W = ww
            S = ss

print(W+S, S)

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

w = [i+j for i in range(0,f+1,100*a) for j in range(0,f+1,100*b) if i+j <= f]
s = [i+j for i in range(0,f+1,c) for j in range(0,f+1,d) if i+j <= f]

W = f//(100*b)
S = 0
for ww in w :
    for ss in s :
        if ww+ss > f or ww == 0:
            continue
        elif ss/(ss+ww) > S/(W+S) and e >= 100*ss/ww:
            W = ww
            S = ss

print(W+S, S)
Problem p03602 (python)

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

    ans = 0
    for i in range(n) :
        for j in range(i+1, n) :
            cost = A[i][j]
            for k in range(n) :
                if i == k or j == k:
                    continue

                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    cost = 0
                elif d < A[i][j] :
                    print(-1)
                    exit()
            ans += cost
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def main()
    n = int(input())
    A = []
    for _ in range(n) :
        A.append(list(map(int, input().split())))

    ans = sum([sum(_A) for _A in A])
    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                if i == k :
                    break
                elif j == k :
                    continue
                
                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    ans -= d
                elif d < A[i][j] :
                    print(-1)
                    exit()

    print(ans//2)

main()
Problem p03608 (python)

Fixed submission:
from itertools import permutations

def input_list() :
    return list(map(int, input().split()))

def main() :
    n, m ,r = input_list()
    road = input_list()
    road = [x-1 for x in road]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n) :
        d[i][i] = 0
    for i in range(m) :
        a, b, c = input_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c

    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                dist = d[i][k]+d[k][j]
                if d[i][j] > dist :
                    d[i][j] = dist

    ans = float('inf')
    for p in permutations(road) :
        dist = 0
        for i in range(r-1) :
            dist += d[p[i]][p[i+1]]
        if ans > dist :
            ans = dist

    print(ans)

main()

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

def input_list() :
    return list(map(int, input().split()))

n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
    d[i][i] = 0
for i in range(m) :
    a, b, c = input_list()
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n) :
    for i in range(n) :
        for j in range(n) :
            dist = d[i][k]+d[k][j]
            if d[i][j] > dist :
            d[i][j] = dist

ans = float('inf')
for p in permutations(road) :
    dist = 0
    for i in range(r-1) :
        dist += d[p[i]][p[i+1]]
    if ans > dist :
        ans = dist

print(ans)

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

def input_list() :
    return list(map(int, input().split()))

n, m ,r = input_list()
road = input_list()
road = [x-1 for x in road]
d = [[float('inf')] * n for i in range(n)]
for i in range(n) :
    d[i][i] = 0
for i in range(m) :
    a, b, c = input_list()
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c

for k in range(n) :
    for i in range(n) :
        for j in range(n) :
            dist = d[i][k]+d[k][j]
            if d[i][j] > dist
            d[i][j] = dist

ans = float('inf')
for p in permutations(road) :
    dist = 0
    for i in range(r-1) :
        dist += d[p[i]][p[i+1]]
    if ans > dist :
        ans = dist

print(ans)
Problem p03639 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 0
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')
Problem p03640 (python)

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

c = [[0 for i in range(w)] for j in range(h)]
fromL = True
x = 0
y = 0

for i in range(1, n+1) :
    for j in range(a[i-1]) :
        c[y][x] = i
        if w == 1 :
            y += 1
        elif fromL :
            if x == w - 1 :
                y += 1
                fromL = False
            else :
                x += 1
        else :
            if x == 0 :
                y += 1
                fromL = True
            else :
                x -= 1

for ci in c :
    print(*ci)

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

c = [[0 for i in range(w)] for j in range(h)]
fromL = True
x = 0
y = 0

for i in range(1, n+1) :
    for j in range(a[i-1]) :
        c[y][x] = i
        if w == 1 :
            y += 1
        elif j > 0 and x == w - 1 :
            y += 1
            fromL = False
        elif j > 0 and x == 0 :
            y += 1
            fromL = True
        elif fromL :
            x += 1
        else :
            x -= 1

for ci in c :
    print(*ci)