TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = list(in_na())

    ans = 0
    for i in range(N):
        if A[i] >= 3:
            if A[i] % 2 == 0:
                ans += (A[i] - 2) // 2
                A[i] = 2
            else:
                ans += (A[i] - 1) // 2
                A[i] = 1

    for i in range(N - 1):
        if A[i] == 2 and A[i + 1] == 0:
            A[i] = 0
            ans += 1
        elif A[i] == 2 and A[i + 1] == 1:
            A[i], A[i + 1] = 0, 1
            ans += 1
        elif A[i] == 2 and A[i + 1] == 2:
            A[i], A[i + 1] = 0, 0
            ans += 2
        elif A[i] == 1 and A[i + 1] == 1:
            A[i], A[i + 1] = 0, 0
            ans += 1
        elif A[i] == 1 and A[i + 1] == 2:
            A[i], A[i + 1] = 0, 1
            ans += 1

    print(A)
    print(ans)


if __name__ == '__main__':
    main()


import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    A = list(in_na())

    if N == 1:
        print(A[0] // 2)
        exit()

    ans = 0
    for i in range(N):
        if A[i] >= 3:
            if A[i] % 2 == 0:
                ans += (A[i] - 2) // 2
                A[i] = 2
            else:
                ans += (A[i] - 1) // 2
                A[i] = 1

    for i in range(N - 1):
        if A[i] == 2 and A[i + 1] == 0:
            A[i] = 0
            ans += 1
        elif A[i] == 2 and A[i + 1] == 1:
            A[i], A[i + 1] = 0, 1
            ans += 1
        elif A[i] == 2 and A[i + 1] == 2:
            A[i], A[i + 1] = 0, 0
            ans += 2
        elif A[i] == 1 and A[i + 1] == 1:
            A[i], A[i + 1] = 0, 0
            ans += 1
        elif A[i] == 1 and A[i + 1] == 2:
            A[i], A[i + 1] = 0, 1
            ans += 1
        elif A[i] == 0 and A[i + 1] == 2:
            A[i], A[i + 1] = 0, 0
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
rest = 0
for a in A:
    if rest == 0:
        ans += a // 2
        rest = a % 2
    else:
        if (a + rest) % 2 == 0:
            ans += (a + rest) // 2
            rest = (a + rest) % 2
        else:
            ans += a % 2
            rest = 0

print(ans)


N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
rest = 0
for i, a in enumerate(A):
    if rest == 0:
        ans += a // 2
        rest = a % 2
    else:
        if (a + rest) % 2 == 0:
            ans += (a + rest) // 2
            rest = 0
        else:
            ans += (rest + a) // 2
            rest = 1 if a != 0 else 0

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]

count = 0
m = -1
for i in range(n):
    if lis[i]%2 == 0:
        count += l[i]//2
    else:
        if lis[i+1] > 1:
            count += lis[i]//2+1
            lis[i+1] -= 1
        else:
            count += lis[i]//2
print(count)

n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]

count = 0

for i in range(n):
    if lis[i]%2 == 0:
        count += lis[i]//2
    else:
        if lis[i+1] > 1:
            count += lis[i]//2+1
            lis[i+1] -= 1
        else:
            count += lis[i]//2
print(count)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
k,s=open(0);n,r=map(int,k.split());a=0
while n>0:
 n-=1
 if s[n]<"o":n-=~-r;a=-~max(a,n)
print(a)

from itertools import*
_, *a = map(int, open(0))
print(sum(sum(l)//2 for _, l in groupby(a, key=lambda x:x>0)))

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]


ans = 0
tmp = 0
for a in A:
    if a == 0:
        ans += tmp//2
        tmp = 0
    else:
        tmp += a
print(ans)


# -*- coding: utf-8 -*-
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
L = [int(input()) for _ in range(N)]
ans = 0
prev = 0
for a in L:
    if a == 0:
        prev = 0
        continue

    a += prev
    ans += a//2
    prev = a % 2
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
tmp = 0

for i in A:
    if i != 0:
        tmp += i
    else:
        ans += tmp//2
        tmp = 0

print(ans)

N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
tmp = 0

for i in A:
    if i != 0:
        tmp += i
    else:
        ans += tmp//2
        tmp = 0

ans += tmp//2

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))
    
B = A[:]
    
ans1 = 0

for j in range(N):
    ans1 += (A[j]//2)
    A[j] = (A[j]%2)
    
for k in range(1,N):
    ans1 += min(A[k-1],A[k])
    A[k] = A[k] - min(A[k-1],A[k])
    
ans2 = 0
tmp = min(B[0],B[1])

for l in range(1,N):
    ans2 += min(B[l-1],B[l])
    B[l] = B[l] - min(B[l-1],B[l])
    B[l-1] = B[l-1] - min(B[l-1],B[l])

B[0] -= tmp

for m in range(N):
    ans2 += (B[m]//2)

print(max(ans1,ans2))

from sys import stdin
N = int(stdin.readline().rstrip())
A = []
for i in range(N):
    A.append(int(input()))
    
ans = 0
for i in range(N-1):
    ans += (A[i]//2)
    A[i+1] -= min(A[i+1],A[i]%2)
    ans += min(A[i+1],A[i]%2)
ans += (A[-1]//2)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  long long res = 0, cur_sum = 0;
  for (int i = 0; i < N;)
  {
    int j = i;
    while (j < N && a[j])
      cur_sum += a[j++];
    res += cur_sum / 2;
    cur_sum = 0;
    i = j + 1;
  }
  cout << res << endl;
}

n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
cur_sum = 0  
for i in range(n):
    if a[i] == 0:
        ans += cur_sum // 2
        cur_sum = 0
    else:
        cur_sum += a[i]
ans += cur_sum // 2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N, *A = map(int, open('0').read().split())
ans = sum(c//2 for c in A)
A = [c%2 for c in A]
for i in range(N-2):
  if A[i]==A[i+1]==1:
    A[i+1] = 0
    ans += 1
print(ans)

N, *A = map(int, open(0).read().split())
ls = []
s = 0
ans = 0
for c in A:
  if c==0:
    ans += s//2
    s = 0
  else:
    s += c
ans += s//2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] // 2
A[0] = A[0] % 2
for i in range(1, N):
    if A[i-1] + A[i] >= 2:
        ans += 1; A[i] -= 1
    q, r = divmod(A[i], 2); A[i] = r
    ans += q
print(ans)

N = int(input())
A = [int(input()) for _ in range(N)]
ans = A[0] // 2
A[0] = A[0] % 2
for i in range(1, N):
    if A[i-1] > 0 and A[i-1] + A[i] >= 2:
        ans += 1; A[i] -= 1
    q, r = divmod(A[i], 2); A[i] = r
    ans += q
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if prev_A == i-1 and (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    elif prev_A == i-1 and (prev_card_num+A)%2 == 0:
        prev_card_num = 0
    else:
        prev_card_num = 1
        prev_A = i
print(ans)

N = int(input())
ans = 0
prev_A = -10
prev_card_num = 0
for i in range(1,N+1):
    A = int(input())
    ans += (prev_card_num + A)//2
    if prev_card_num == 1 and A == 0:
        prev_card_num = 0
    elif (prev_card_num+A)%2 == 1:
        prev_card_num = 1
        prev_A = i
    else:
        prev_card_num = 0
        prev_A = i
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n=int(input())
l=[0]
for i in range(n):
  l.append(int(input()))
count=0
for i in range(1,n):
  m=min(l[i-1],l[i])
  count+=m
  l[i-1]-=m
  l[i]-=m
for i in range(n):
  count+=l[i]//2
print(count)

n=int(input())
l=[0]
for i in range(n):
  l.append(int(input()))
count=0
for i in range(n-1):
  if l[i]%2==1 and l[i+1]>0:
    count+=1
    l[i]-=1
    l[i+1]-=1
for i in range(n):
  count+=l[i]//2
print(count)

n=int(input())
l=[]
for i in range(n):
  l.append(int(input()))
count=0
for i in range(n-1):
  if l[i]%2==1 and l[i+1]>0:
    count+=1
    l[i]=l[i]-1
    l[i+1]=l[i+1]-1
for i in range(n):
  count+=l[i]//2
print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    print(A)
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(A)
print(cnt)

import sys
stdin = sys.stdin
import itertools

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
A = list()
for _ in range(N):
    A.append(ni())
cnt = 0
if N==1:
    print(A[0]//2)
    quit()
for i in range(N-1):
    ccnt = (A[i] + A[i+1]) //2
    A[i+1] -= max(0, ccnt*2 - A[i])
    A[i] = max(0, A[i]-ccnt*2)
    cnt += ccnt
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import itertools
if __name__ == '__main__':
    n = int(input())
    a = [0]
    cards = []
    for i in range(n):
        a.append(int(input()))
    for i in range(1, n + 1):
        for j in range(a[i]):
            cards.append(i)
    l = list(itertools.combinations(cards, 2));
    fl = list(filter(lambda p:abs(p[0] - p[1]) <= 1, l))
    count = [0]*(n+1)
    ans = []
    for f in fl:
        print(f[0], f[1])
        count[f[0]] += 1
        count[f[1]] += 1
        if (count[f[0]] > a[f[0]]):
            count[f[0]] -= 1
            count[f[1]] -= 1
            continue
        if (count[f[1]] > a[f[1]]):
            count[f[0]] -= 1
            count[f[1]] -= 1
            continue
        ans.append(f)
    print(len(ans))


# -*- coding: utf-8 -*-
import math
from functools import reduce
from operator import add
if __name__ == '__main__':
    n = int(input())
    a = [0]
    ans = 0
    for i in range(n):
        tmp = int(input())
        a.append(tmp)
        if tmp == 0:
            ans += math.floor(reduce(add, a) // 2)
            a.clear()
            a.append(0)
    ans += math.floor(reduce(add, a) // 2)
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(check)

n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(check)


n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n = int(input())
ans = 0
a = []
for _ in range(n):
    ai = int(input())
    ans += ai//2
    a.append(ai%2)

for i in range(n-1):
    if a[i] == 1 and a[i+1] == 1:
        a[i+1] -= 1
        ans += 1
print(a, ans)

n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2 == 1 and a[i+1] == 1:
        a[i+1] -= 1
        ans += 1
print(ans)


n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0

for i in range(n-1):
    ans += a[i]//2
    if a[i]%2 == 1 and a[i+1] > 0:
        a[i+1]-=1
        ans += 1

ans += a[n-1]//2
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n = int(input())
lis = [int(input()) for i in range(n)]
cou = 0
num = 0
for i in range(n):
  if lis[i] == 0:
    cou += (num // 2)
    num = 0
  else:
    num += lis[i]
print(cou)

n = int(input())
lis = [int(input()) for i in range(n)]
cou = 0
num = 0
for i in range(n):
  if lis[i] == 0:
    cou += (num // 2)
    num = 0
  else:
    num += lis[i]
cou += (num // 2)
print(cou)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):

N = int(input())
ans = 0
flag = False
for _ in range(N):
    a = int(input())
    ans += a//2
    if flag and a % 2 == 1:
        ans += 1
    a -= 1
    if a % 2 == 1:
        flag = True
    else:
        flag = False
print(ans)


N = int(input())
A = [int(input()) for _ in range(N)]+[0]

ans = 0
for i in range(N):
    if A[i] % 2 == 0:
        ans += A[i]//2
        A[i] = 0
    else:
        ans += A[i]//2
        if A[i+1] > 0:
            ans += 1
            A[i+1] -= 1
            A[i] = 0
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(i>0)
print(s)

s=t=0
for _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(a>0)
print(s)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
import sys
n = int(sys.stdin.readline())
ans = 0
t = 0
for i in range(n):
    a = int(sys.stdin.readline())
    if a==0:
        ans += t//2
        t = 0
    else:
        t += a
if t>0: ans += t//2
pritn(ans)

import sys
n = int(sys.stdin.readline())
ans = 0
t = 0
for i in range(n):
    a = int(sys.stdin.readline())
    if a==0:
        ans += t//2
        t = 0
    else:
        t += a
if t>0: ans += t//2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
import sys

# import re
import math
import collections

import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    ans = 0
    cnt = 0
    for _ in range(n):
        ai = ni()
        if ai == 0:
            ans += n // 2
            n = 0
        else:
            n += ai
    ans += n // 2

    print(ans)


if __name__ == '__main__':
    main()


import sys

# import re
import math
import collections

import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    ans = 0
    cnt = 0
    for _ in range(n):
        ai = ni()
        if ai == 0:
            ans += cnt // 2
            cnt = 0
        else:
            cnt += ai
    ans += cnt // 2

    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
for i in range(n+1):
  if a[i]!=0:
    tmp += a[i]
  else:
    ans += tmp//2
    tmp = 0
print(ans)

import sys
input = sys.stdin.readline
n=int(input())
a = [int(input()) for i in range(n)]
a.append(0)
ans = 0
tmp = 0
for i in range(n+1):
  if a[i]!=0:
    tmp += a[i]
  else:
    ans += tmp//2
    tmp = 0
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7
mod = 998244353


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: int(x) - 1, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n)


def main():
    N = int(input())
    A = [(int(input()), n % 2) for n in range(N)]

    print(A)
    res = 0
    t = 0
    for i, (_, j) in enumerate(A):
        if j == 0:
            res += abs(i - (t * 2))
            t += 1

    print(res)


if __name__ == "__main__":
    main()


import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7
mod = 998244353


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: int(x) - 1, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n)


def main():
    N = int(input())
    A = [(int(input()), n % 2) for n in range(N)]
    A.sort()

    res = 0
    for i, (_, j) in enumerate(A):
        if i % 2 != j:
            res += 1

    print(res // 2)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

I,O,T,J,L,S,Z = map(int,input().split())







x = (I//2 + J//2 + L//2) * 2
if I>0 and J>0 and L>0:
    x = max(x,((I-1)//2 + (J-1)//2 + (L-1)//2) * 2 + 3)
x += O

print(x)

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = np.array(read().split(), np.int32)[1:]

to = A.argsort()

n = (to[::2] & 1).sum() + ((to[1::2] ^ 1) & 1).sum()
print(n // 2)

Verdicts: Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
#import sys
#from collections import defaultdict
input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = sorted(A)
    d = defaultdict( int)
    for i in range(N):
        d[B[i]] = i
    odd = 0
    for i in range(N):
        if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
            odd += 1
    print(odd)
    
if __name__ == '__main__':
    main()

# import sys
from collections import defaultdict
# input = sys.stdin.readline
def main():
    N = int( input())
    A = [ int( input()) for _ in range(N)]
    B = sorted(A)
    d = defaultdict( int)
    for i in range(N):
        d[B[i]] = i
    odd = 0
    for i in range(N):
        if (i+1)%2 == d[A[i]]%2 and d[A[i]]%2 == 1:
            odd += 1
    print(odd)
    
if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
n=int(input())
a=[int(input() for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
	if a[i]>a[i+1]:
		cnt+=1
		a[i],a[i+1]=a[i+1],a[i]
print(cnt)

from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i])-c[i])
	else:
		ans+=b[i]
print(ans)

n=int(input())
a=[int(input()) for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
c.sort()
a=[c[i] if i&1 else b[i] for i in range(n)]
cnt=0
for i in range(n-1):
	if a[i]>a[i+1]:
		cnt+=1
		a[i],a[i+1]=a[i+1],a[i]
print(cnt)

from bisect import bisect_left, bisect_right
n=int(input())
a=[int(input()) for i in range(n)]
b=a[::2]
c=a[1::2]
b.sort()
ans=0
for i in range(n//2):
	ans+=abs(min(bisect_left(b,c[i]),bisect_right(b,c[i]))-(i+1))
print(ans)

from collections import Counter
n=int(input())
a=[int(input()) for i in range(n)]
b=Counter(a[::2])
a.sort()
c=Counter(a[::2])

ans=0
for i in b:
	if i in c:
		ans+=abs(b[i]-c[i])
	else:
		ans+=b[i]
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
a=sorted([[int(input()),i]for i in range(int(input()))]);print(sum([(a[i][1]-i)%2for i in range(len(a))]))

n=int(input())
a=sorted([[int(input()),i]for i in range(n)])
print(sum([(a[i][1]-i)%2 for i in range(n)])//2)

Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
n = int(input())
nums = [int(input()) for _ in range(n)]
standard = nums[:]
standard.sort()
ans = 0

for i in range(n):
    p = nums[i]
    x = standard.index(p)
    if abs(x - i) % 2 == 1:
        ans += 1

print(ans)

n = int(input())
nums = [[int(input()), i] for i in range(n)]
nums.sort()
ans = 0

for i in range(n):
    if abs (i - nums[i][1]) % 2 == 1:
        ans += 1

print(ans // 2)

Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
N=int(input())
A=[]
B=[]
for i in range(N):
	if i%2==0:
		A.append(int(input()))
	else:
		B.append(int(input()))
		
A=sorted(A)
B=sorted(B)
C=sorted(A+B)

c=0
for a in A:
	if C.index(a)%2==1:
		c+=1
for b in B:
	if C.index(b)%2==0:
		c+=1
print(c)

N=int(input())
A=[]
B=[]
for i in range(N):
	if i%2==0:
		A.append(int(input()))
	else:
		B.append(int(input()))
		
A=sorted(A)
B=sorted(B)
C=sorted(A+B)

c=0
j=0
for i in range(C):
	if A[j]==C[i]:
		if i%2==1:
			c+=1
		j+=1
print(c)

N=int(input())
A=[]
B=[]
for i in range(N):
	if i%2==0:
		A.append(int(input()))
	else:
		B.append(int(input()))
		
A=sorted(A)
B=sorted(B)
C=sorted(A+B)

c=0
j=0
for i in range(N):
	if j>=len(A):
		break
	if A[j]==C[i]:
		if i%2==1:
			c+=1
		j+=1
print(c)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
N, *A = map(int, open('0').read().split())
ans = 0
B = sorted(A)
dic = {B[i]:i for i in range(N)}
for i,n in enumerate(A):
  if i%2!=dic[n]%2:
    ans += 1
print(ans//2)

N, *A = map(int, open(0).read().split())
B = sorted(A)
dic = {B[i]:i for i in range(N)}
ans = sum((i+1)%2==dic[n]%2 for i,n in enumerate(A))
print(ans//2)

Verdicts: Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
n=int(input())
a=[(int(input()),i) for i in range(n)]
#print(a)
a.sort()
#print(a)
ans=0

for i in range(n):
    ans+=(a[i][1]-i)%2
print(ans,ans//2)


n=int(input())
a=[(int(input()),i) for i in range(n)]
#print(a)
a.sort()
#print(a)
ans=0

for i in range(n):
    ans+=(a[i][1]-i)%2
print(ans//2)


Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
n = int(input())
s = [int(input()) for _ in range(n)]
ss = sorted(s)


def find(x):
    a, b = 0, len(ss) - 1
    while a != b:
        if ss[(a + b) // 2] <= x:
            b = (a + b) // 2
        else:
            a = (a + b) // 2 + 1
    return a


ans = 0
print(ss)
for i, j in enumerate(s):
    ans += i % 2 != find(j) % 2
print(ans)


n = int(input())
s = [int(input()) for _ in range(n)]
ss = sorted(s)
d = {ss[i]: i for i in range(n)}
ans = 0
for i, j in enumerate(s):
    ans += i % 2 != d[j] % 2
print(ans)


n = int(input())
a = [int(input()) for _ in range(n)]
b = {}
for i, j in enumerate(sorted(a)):
    b[j] = i
ans = 0
for i, j in enumerate(a):
    ans += (b[j] - i) % 2
print(ans // 2)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
x_to_i = {x:i for i, x in enumerate(sorted(A))}
rank = [x_to_i[x] for x in A]
answer = sum((i^x)&1 for i,x in enumerate(rank)) // 2
print(B)


import sys
import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
B = sorted(np.array(A))
C = [np.where(B == a)[0][0] for a in A]
answer = sum([i%2==1 and x%2!=1 for i, x in enumerate(C)])
print(answer)
# 41


import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
x_to_i = {x:i for i, x in enumerate(sorted(A))}
rank = [x_to_i[x] for x in A]
answer = sum((i^x)&1 for i,x in enumerate(rank)) // 2
print(answer)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
N, *A = map(int, open(0))
print(len(set(A[1::2] + sorted(A)[::2])))

N, *A = map(int, open(0))
print(len(set(A[1::2]) & set(sorted(A)[::2])))

Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
from collections import defaultdict as d
a=[int(input()) for i in range(int(input()))]
b=sorted(a)
c=d(int)
e=0
for i in range(0,n,2):
    d[b[i]]=1
for i in a[1::2]:
    e+=d[i]
print(e)

print(len([i for i in [i for i in range(int(input()))][::2] if i%2!=1]))

print(len([i for i in [i for i in range(int(input()))][::2] if i%2!=0]))


from collections import defaultdict as d
a=[int(input()) for i in range(int(input()))]
b=sorted(a)
c=d(int)
e=0
for i in b[::2]:
    c[i]=1
for i in a[1::2]:
    e+=c[i]
print(e)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
import sys
input = sys.stdin.buffer.readline

def main():
    N =  int(input())
    
    odd,al = [],[]
    for i in range(N):
        a = int(input())
        if i%2 == 0:
            odd.append(a)
        al.append(a)
            
    odd.sort()
    al.sort()
    print(odd,al)
    ans = 0
    for i in range(N//2):
        if al[2*i+1] in odd:
            ans += 1
            
    print(ans)

if __name__ == "__main__":
    main()

import sys
input = sys.stdin.buffer.readline
import bisect

def main():
    N =  int(input())
    
    odd,al = [],[]
    for i in range(N):
        a = int(input())
        if i%2 == 0:
            odd.append(a)
        al.append(a)
            
    odd.sort()
    al.sort()
    ans = 0
    for i in range(-(-N//2)):
        num = odd[i]
        index = bisect.bisect_left(al,num)
        if index%2 == 1:
            ans += 1
            
    print(ans)

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order:    * Operation 1: choose 2 consecutive elements, then reverse the order of those elements.   * Operation 2: choose 3 consecutive elements, then reverse the order of those elements.  Snuke likes Operation 2, but not Operation 1. Find the minimum number of Operation 1 that he has to perform in order to sort the sequence in increasing order.

Submission attempts (in order):
def main():
    n = int(input())
    a=[]
    b=[]
    if n == 1:
        a=int(input())
        print(0)
    else:
        for i in range(n//2):
            a.append(int(input()))
            b.append(int(input()))

        if n % 2 == 1:
            a.append(int(input()))

        a.sort()
        b.sort()
        ta=a[0]
        tb=b[0]
        if ta < tb:
            res = 0
        else:
            tb = ta
            res = 1

        for i in range(1,n//2+1):
            if a[i] < tb:
                ta = tb
                res += 1
            else:
                ta = a[i]
            if b[i] < ta:
                tb =ta
                res += 1
            else:
                tb = b[i]
        if n % 2 == 1:
            if a[-1] < tb:
                res += 1

        print(res)
main()

import bisect

def main():
    n = int(input())
    l = [[i,int(input())] for i in range(n)]
    l.sort(key=lambda x:x[1])
    res =0
    for i in range(n):
        if i % 2 != l[i][0] % 2:
            res += 1
    print(res // 2)


main()

Verdicts: Runtime Error

Accepted