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

Fixed submission:
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Edge = [[] for i in range(N)]
    for i in range(1, N):
        Edge[i].append((0, i - 1))
    for _ in range(M):
        L, R, C = map(int, input().split())
        Edge[L-1].append((C, R-1))
    
    Dist = [-1] * N
    Q = []
    heapify(Q)
    heappush(Q, (0, 0))
    while Q:
        nowcost, nownode = heappop(Q)
        if Dist[nownode] == -1:
            Dist[nownode] = nowcost
            for addcost, nextnode in Edge[nownode]:
                if Dist[nextnode] == -1:
                    heappush(Q, (nowcost + addcost, nextnode))
    print(Dist[N-1])

    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Edge = [[] for i in range(N)]
    for i in range(1, N):
        Edge[i].append((0, i - 1))
    for _ in range(M):
        L, R, C = map(int, input().split())
        Edge[L-1].append((C, R-1))
    
    Dist = [-1] * N
    Q = []
    heapify(Q)
    heappush((0, 0))
    while Q:
        nowcost, nownode = heappop(Q)
        if Dist[nownode] == -1:
            Dist[nownode] = nowcost
            for addcost, nextnode in Edge[nownode]:
                if Dist[nownode] == -1:
                    heappush(Q, (nowcost + addcost, nextnode))
    print(Dist[N-1])

    return 0

if __name__ == "__main__":
    solve()
Problem p02882 (python)

Fixed submission:
import sys
import math

def solve():
    input = sys.stdin.readline
    a, b, x = map(int, input().split())
    total = b * a
    if b * a * a == x: print(0)
    elif x >= 0.5 * b * a * a: #傾きが浅い
        x /= a
        ans = 2 * (total - x) / a
        print(math.degrees(math.atan(ans / a)))
    else: #傾きが大きい
        x /= a
        ans = 2 * x / b
        print(math.degrees(math.atan(b / ans)))
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import math

def solve():
    input = sys.stdin.readline
    a, b, x = map(int, input().split())
    if b * a * a == x: print(0)
    elif x >= 0.5 * b * a * a: #傾きが浅い
        x /= a
        ans = 2 * (total - x) / a
        print(math.degrees(math.atan(ans / a)))
    else: #傾きが大きい
        x /= a
        ans = 2 * x / b
        print(math.degrees(math.atan(b / ans)))
    return 0

if __name__ == "__main__":
    solve()
Problem p02889 (python)

Fixed submission:
import sys

def solve():
	input=sys.stdin.readline
	n, m, l = map(int, input().split())
	edge = [[] for _ in range(n)]
	for _ in range(m):
		a, b, c = map(int, input().split())
		if c <= l:
			edge[a-1].append((c, b-1))
			edge[b-1].append((c, a-1))
	inf = 10 ** 20
	dist = [[inf for _ in range(n)]for i in range(n)]
	for i in range(n):
		dist[i][i]=0
		for c, b in edge[i]:
			dist[i][b]=c
			
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
				
	dist2 = [[n+50 for j in range(n)] for i in range(n)]
	for i in range(n):
		dist2[i][i] = 0
		for j in range(i+1, n):
			if dist[i][j] <= l:
				dist2[i][j] = 1
				dist2[j][i] = 1
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist2[i][j] = min(dist2[i][k] + dist2[k][j], dist2[i][j])
	q = int(input())		
	for i in range(q):
		s, t = map(int, input().split())
		print(dist2[s-1][t-1] - 1 if dist2[s-1][t-1] < n+50 else -1)
	return 0
	
if __name__ == '__main__':
	solve()

Buggy submission (verdict: Runtime Error):
import sys

def solve():
	input=sys.stdin.readline
	n, m, l = map(int, input().split())
	edge = [[] for _ in range(n)]
	for _ in range(m):
		a, b, c = map(int, input().split())
		if c <= l:
			edge[a-1].append((c, b-1))
			edge[b-1].append((c, a-1))
	inf = 10 ** 20
	dist = [[inf for _ in range(n)]for i in range(n)]
	for i in range(n):
		dist[i][i]=0
		for c, b in edge[i]:
			dist[i][b]=c
			
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])
				
	dist2 = [[n+50 for j in range(n)] for i in range(n)]
	for i in range(n):
		dist2[i][i] = 0
		for j in range(i+1, n):
			if dist[i][j] <= l:
				dist2[i][j] = 1
				dist2[j][i] = 1
	for k in range(n):
		for i in range(n):
			for j in range(n):
				dist2[i][j] = min(dist2[i][k] + dist2[k][j])
	q = int(input())		
	for i in range(q):
		s, t = map(int, input().split())
		print(dist2[s-1][t-1] - 1)
	return 0
	
if __name__ == '__main__':
	solve()
Problem p02901 (python)

Fixed submission:
import sys
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    cost = dict()
    for i in range(2 ** N): cost[i] = -1
    cost[0] = 0
    for i in range(M):
        a, b = map(int, input().split())
        c = [int(c) for c in input().split()]
        bit = 0
        for j in c: bit += 2 ** (j - 1)
        for i in range(2 ** N):
            if cost[i] > -1:
                if cost[i | bit] > -1:
                    cost[i | bit] = min(cost[i | bit], cost[i] + a)
                else: cost[i | bit] = cost[i] + a

    #print(cost)

    print(cost[2 ** N - 1])
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import heapq
sys.setrecursionlimit(10000000)

def knap(i, used, cost, N, M, Key, K_cost):
    if i == N - 1:
        take = used | Key[i]
        take_cost = cost + K_cost[i]
        a = set([int(i) for i in range(N)])
        if  used == a: return cost
        elif take == a: return take_cost
        else: return -1
    else:
        take = used | Key[i]
        take_cost = knap(i+1, take, cost + K_cost[i], N, M, Key, K_cost)
        not_take_cost = knap(i+1, used, cost, N, M, Key, K_cost)
        if take_cost == not_take_cost == -1: return -1
        elif take_cost == -1: return not_take_cost
        elif not_take_cost == -1: return take_cost
        else: return min(take_cost, not_take_cost)
        

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Key = dict()
    K_cost = dict()
    for i in range(M):
        a, b = map(int, input().split())
        K_cost[i] = a
        Key[i] = set([int(c) - 1 for c in input().split()])

    print(knap(0, set(), 0, N, M, Key, K_cost))
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import heapq

def knap(i, used, cost, N, M, Key, K_cost):
    if i == N - 1:
        take = used | Key[i]
        take_cost = cost + K_cost[i]
        a = set([int(i) for i in range(N)])
        if  used == a: return cost
        elif take == a: return take_cost
        else: return -1
    else:
        take = used | Key[i]
        take_cost = knap(i+1, take, cost + K_cost[i], N, M, Key, K_cost)
        not_take_cost = knap(i+1, used, cost, N, M, Key, K_cost)
        if take_cost == not_take_cost == -1: return -1
        elif take_cost == -1: return not_take_cost
        elif not_take_cost == -1: return take_cost
        else: return min(take_cost, not_take_cost)
        

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    Key = dict()
    K_cost = dict()
    for i in range(M):
        a, b = map(int, input().split())
        K_cost[i] = a
        Key[i] = set([int(c) - 1 for c in input().split()])

    print(knap(0, set(), 0, N, M, Key, K_cost))
    return 0

if __name__ == "__main__":
    solve()
Problem p02945 (python)

Fixed submission:
A, B = map(int, input().split())
l = [A + B, A - B, A * B]
print(max(l))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max([A + b, A - B, A * B]))
Problem p02972 (python)

Fixed submission:
import sys

def divisor(N, B):
    i = 1
    d = []
    while i ** 2 <= N:
        if N % i == 0:
            B[i-1] = (B[i-1] + 1) % 2
            if i ** 2 < N: B[N // i - 1] = (B[N//i - 1] + 1) % 2 
        i += 1
    return 0


def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    B = [0] * N
    ans = []
    M = 0

    for i in reversed(range(N)):
        if B[i] != A[i]:
            divisor(i+1, B)
            M += 1
            ans.append(i+1)

    print(M)
    print(" ".join(map(str, ans)))

    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    Count = [0] * N
    In = []
    add = 0
    for i in reversed(range(N)):
        k = i + 1
        if A[i] != Count[i]:
            Count[i] = (Count[i] + 1) % 2
            In.append(i + 1)
            add += 1
            Count[1] = (Count[1] + 1) % 2
            for div in range(2, k):
                if div ** 2 > k: break
                if k % div == 0:
                    if div ** 2 == k: Count[div - 1] = (Count[div - 1] + 1) % 2
                    else:
                        Count[div - 1] = (Count[div - 1] + 1) % 2
                        Count[(k % div) - 1] = (Count[(k % div) - 1] + 1) % 2
    if Count[0] != A[0]: print(-1)
    else:
        print(add)
        print(" ".join(map(str, In)))

    return 0

if __name__ == "__main__":
    solve()
Problem p02985 (python)

Fixed submission:
import sys, collections
sys.setrecursionlimit(10000000)

def permutation(k, r, fact, revfact, mod):
    return (fact[k] * revfact[k-r]) % mod

def dfs(now, parent, edge, mod, K, fact, revfact):
    son = 0
    ans = 1
    for next in edge[now]:
        if next != parent:
            son += 1
            ans *= dfs(next, now, edge, mod, K, fact, revfact)
            ans %= mod
    if K-2 < son: ans = 0
    elif son > 0:
        ans *= permutation(K-2, son, fact, revfact, mod)
        ans %= mod
    return ans
    

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    mod = 7 + 10 ** 9

    fact = [1] * (K + 1)
    for i in range(2, K+1):
        fact[i] = (i * fact[i-1]) % mod
    revfact = [1] * (K+1)
    revfact[K] = pow(fact[K], mod - 2, mod)
    for i in reversed(range(1, K)):
        revfact[i] = ((i+1) * revfact[i+1]) % mod

    ans = K
    son = 0
    for next in edge[0]:
        son += 1
        ans *= dfs(next, 0, edge, mod, K, fact, revfact)
        ans %= mod
    ans *= permutation(K-1, son, fact, revfact, mod)
    ans %= mod

    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys, collections
sys.setrecursionlimit(10000000)

def comb(n, r, fact, revfact, mod):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

def dfs(now, edge, visited, mod, N, fact, revfact):
    visited[now] = True
    son = 0
    ans = 1
    for next in edge[now]:
        if not visited[next]:
            son += 1
            ans *= dfs(next, edge, visited, mod, N, fact, revfact)
            ans %= mod
    if son == 0: return 1
    else:
        ans *= comb(N-2, son, fact, revfact, mod)
        ans %= mod
        return ans

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    edge = [[] for i in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edge[a-1].append(b-1)
        edge[b-1].append(a-1)
    mod = 7 + 10 ** 9

    fact = [1] * (K + 1)
    for i in range(2, K+1):
        fact[i] = (i * fact[i-1]) % mod
    revfact = [1] * (K+1)
    revfact[K] = pow(fact[K], mod - 2, mod)
    for i in reversed(range(1, K)):
        revfact[i] = ((i+1) * revfact[i+1]) % mod

    visited = [False] * N
    visited[0] = True
    ans = 1
    son = 0
    for next in edge[0]:
        son += 1
        ans *= dfs(next, edge, visited, mod, K, fact, revfact)
        ans %= mod
    ans *= (comb(K-1, son, fact, revfact, mod) * K) % mod
    ans %= mod

    print(ans)

    return 0

if __name__ == "__main__":
    solve()
Problem p03040 (python)

Fixed submission:
import sys, math, collections, heapq, itertools
from bisect import bisect_left
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    Q = int(single_input())
    n, a, b = map(int, line_input())
    left, right = [-a], [a]
    heapq.heapify(left)
    heapq.heapify(right)
    minans =  b
    for i in range(1, Q):
        queri = [int(i) for i in line_input()]
        if queri[0] == 1:
            a, b = queri[1:]
            minans += b
            left_upper = -1 * heapq.heappop(left)
            right_lower = heapq.heappop(right)
            if left_upper <= a <= right_lower:
                heapq.heappush(left, -a)
                heapq.heappush(left, -1 * left_upper)
                heapq.heappush(right, a)
                heapq.heappush(right, right_lower)
            elif a < left_upper:
                minans += left_upper - a
                heapq.heappush(left, -a)
                heapq.heappush(left, -a)
                heapq.heappush(right, left_upper)
                heapq.heappush(right, right_lower)
            else:
                minans += a - right_lower
                heapq.heappush(left, -1 * left_upper)
                heapq.heappush(left, -1 * right_lower)
                heapq.heappush(right, a)
                heapq.heappush(right, a)
        else:
            left_lower = -1 * heapq.heappop(left)
            print(left_lower, minans)
            heapq.heappush(left, -1 * left_lower)
    return 0
  
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
import sys, math, collections, heapq, itertools
from bisect import bisect_left
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
  
def solve():
    Q = int(single_input())
    n, a, b = map(int, line_input())
    left, right = collections.deque([a]), collections.deque([a])
    minans =  b
    for i in range(1, Q):
        queri = [int(i) for i in line_input()]
        if queri[0] == 1:
            a, b = queri[1:]
            minans += b
            if left[-1] <= a <= right[0]:
                left.append(a)
                right.appendleft(a)
            elif a < left[-1]:
                minans += left[-1] - a
                insertpos = bisect_left(left, a)
                left.insert(insertpos, a)
                left.insert(insertpos, a)
                right.appendleft(left.pop())
            else:
                minans += a - right[0]
                insertpos = bisect_left(right, a)
                right.insert(insertpos, a)
                right.insert(insertpos, a)
                left.append(right.popleft())
        else: print(left[-1], minans)
    return 0
  
if __name__ == "__main__":
    solve()
Problem p03078 (python)

Fixed submission:
import heapq
X, Y, Z, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A.sort(reverse = True)
A.append(-10**20)
B.sort(reverse = True)
B.append(-10**20)
C.sort(reverse = True)
C.append(-10**20)

Q = []
heapq.heapify(Q)
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), 0, 0, 0))
count = 0
fin = {}
while count < K:
    value, a, b, c = heapq.heappop(Q)
    if (a, b, c) not in fin:
        fin[(a, b, c)] = 1
        print(-value)
        heapq.heappush(Q, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        heapq.heappush(Q, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        heapq.heappush(Q, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        count += 1

Buggy submission (verdict: Runtime Error):
import heapq
X, Y, Z, K = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
A.sort(reverse = True)
A.append(-100000)
B.sort(reverse = True)
B.append(-100000)
C.sort(reverse = True)
C.append(-100000)

Q = []
heapq.heapify(Q)
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), 0, 0, 0))
count = 0
fin = {}
while count < K:
    value, a, b, c = heapq.heappop(Q)
    if (a, b, c) not in fin:
        fin[(a, b, c)] = 1
        print(-value)
        heapq.heappush(Q, (-(A[a+1]+B[b]+C[c]), a+1, b, c))
        heapq.heappush(Q, (-(A[a]+B[b+1]+C[c]), a, b+1, c))
        heapq.heappush(Q, (-(A[a]+B[b]+C[c+1]), a, b, c+1))
        count += 1
Problem p03095 (python)

Fixed submission:
N = int(input())
S = input()
mod = 7 + 10 ** 9

word = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"\
    ,"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y","z"]
count = [1] * 26
for i in range(N):
    count[word.index(S[i])] += 1
Total = 1
for c in count:
    Total *= c
    Total %= mod
print(Total - 1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
N = int(input())
C = [int(input())]
cindex = {C[0]:[0]}
mod = 7 + 10 ** 9
counter = 0
for _ in range(N-1):
    c = int(input())
    if c != C[-1]:
        C.append(c)
        counter += 1
        if c in cindex:
            cindex[c].append(counter)
        else:
            cindex[c] = [counter]

def variation(i, memo = {}):
    if i == len(C)-1: return 1
    try:
        return memo[i]
    except KeyError:
        total = 0
        L = cindex[C[i]]
        for l in L:
            if l > i:
                total += variation(l, memo) #lまで塗る
                total %= mod
                break
        total += variation(i + 1, memo)
        total %= mod
        memo[i] = total
        return total
 
memo = {}
print(variation(0, memo))
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
if 1 in A:
    if 4 in A: A.remove(4)
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 3 in A:
    if 2 in A: A.remove(2)
if 5 in A:
    if 3 in A: A.remove(3)
    if 2 in A: A.remove(2)
if 7 in A:
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 9 in A:
    if 6 in A: A.remove(6)

def MatchNum(i):
    if i == 1: return 2
    elif i == 4: return 4
    elif i in [2, 3, 5]: return 5
    elif i == 7: return 3
    elif i == 8: return 7
    elif i in [6, 9]: return 6

MatchUse = []
for a in A:
    MatchUse.append((a, MatchNum(a)))

DP = [-1] * (N+1)
for a, num in MatchUse:
    if num <= N: DP[num] = a

for i in range(2, N):
    if DP[i] > 0:
        temp = DP[i]*10
        for a, num in MatchUse:
            if i + num <= N:
                DP[i + num] = max(DP[i + num], a + temp)
print(DP[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
if 1 in A:
    if 4 in A: A.remove(4)
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 3 in A:
    if 2 in A: A.remove(2)
if 5 in A:
    if 3 in A: A.remove(3)
    if 2 in A: A.remove(2)
if 7 in A:
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 9 in A:
    if 6 in A: A.remove(6)

def MatchNum(i):
    if i == 1: return 2
    elif i == 4: return 4
    elif i in [2, 3, 5]: return 5
    elif i == 7: return 3
    elif i == 8: return 7
    elif i in [6, 9]: return 6

MatchUse = []
for a in A:
    MatchUse.append((a, MatchNum(a)))

DP = [-1] * (N+1)
for a, num in MatchUse:
    DP[num] = a

for i in range(2, N):
    if DP[i] > 0:
        temp = DP[i]*10
        for a, num in MatchUse:
            if i + num <= N:
                DP[i + num] = max(DP[i + num], a + temp)
print(DP[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
if 1 in A:
    if 4 in A: A.remove(4)
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 3 in A:
    if 2 in A: A.remove(2)
if 5 in A:
    if 3 in A: A.remove(3)
    if 2 in A: A.remove(2)
if 7 in A:
    if 6 in A: A.remove(6)
    if 9 in A: A.remove(9)
if 9 in A:
    if 6 in A: A.remove(6)

def MatchNum(i):
    if i == 1: return 2
    elif i == 4: return 4
    elif i in [2, 3, 5]: return 5
    elif i == 7: return 3
    elif i == 8: return 7
    elif i in [6, 9]: return 6

DP = [""] * (N+1)
for key in A:
    DP[MatchNum(key)] = str(key)

for i in range(1, N):
    if DP[i]:
        for key in A:
            if i + MatchNum(key) <= N:
                if not DP[i + MatchNum(key)]:  DP[i + MatchNum(key)] = str(key) + DP[i] 
                elif int(DP[i + MatchNum(key)]) < int(str(key) + DP[i]):
                    DP[i + MatchNum(key)] = str(key) + DP[i]
print(DP[N])
Problem p03132 (python)

Fixed submission:
L = int(input())
A = [int(input()) for _ in range(L)]
INF = 10**20
DP = [[INF for i in range(5)] for _ in range(L)]
DP[0][0] = A[0]
DP[0][1] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][2] = (1 if A[0] % 2 == 0 else 0)
DP[0][3] = (2 if A[0] == 0 else 1 if A[0] % 2 == 1 else 0)
DP[0][4] = A[0]

for i in range(1, L):
    a = A[i]
    DP[i][0] = DP[i-1][0] + a
    DP[i][1] = min(DP[i-1][:2]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][2] = min(DP[i-1][:3]) + (1 if a % 2 == 0 else 0)
    DP[i][3] = min(DP[i-1][:4]) + (2 if a == 0 else 1 if a % 2 == 1 else 0)
    DP[i][4] = min(DP[i-1]) + a

print(min(DP[L-1]))

Buggy submission (verdict: Runtime Error):
from math import ceil
L = int(input())
A = [int(input()) for _ in range(L)]
even = 0
start, end = 0, L-1
if A[0] == 0:
	for i in range(1, L):
		if A[i] != 0:
			start = i
			break
if A[-1] == 0:
	for i in reversed(range(L-1)):
		if A[i] != 0:
			end = i
			break
for a in A[start:end+1]:
	if a % 2 == 0:
		even += 1
if A[start] % 2 == 0 and A[start+1] % 2 == 1:
	even -= 1
if A[end-1] % 2 == 1 and A[end] % 2 == 0:
	even -= 1
		
print(ceil(even/2))