A - Odd Position Sum
Source: atcoder
Difficulty: 100

Problem Statement
You are given a sequence of positive integers of length
N
:
A=(A_1,A_2,\dots,A_N)
.
Find the sum of the odd-indexed elements of
A
. That is, find
A_1 + A_3 + A_5 + \dots + A_m
, where
m
is the largest odd number not exceeding
N
.
Constraints
1 \le N \le 100
1 \le A_i \le 100
All input values are integers.
Input
The input is given from Standard Input in the following format:
N
A_1
A_2
\dots
A_N
Output
Print the answer.
Sample Input 1
7
3 1 4 1 5 9 2
Sample Output 1
14
The sum of the odd-indexed elements of
A
is
A_1+A_3+A_5+A_7=3+4+5+2=14
.
Sample Input 2
1
100
Sample Output 2
100
Sample Input 3
14
100 10 1 10 100 10 1 10 100 10 1 10 100 10
Sample Output 3
403

C++ solution:
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int a[n + 1];
int i;
for(i = 1;i <= n;i ++){
cin >> a[i];
}
long long sum = 0;
for(i = 1;i <= n;i ++){
if(i % 2 != 0){
sum = sum + a[i];
}
}
cout << sum << '\n';
return 0;
}

Go solution:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

const (
	inf = 1 << 60
	MOD = 998244353
)

func main() {
	/*** INIT ***/
	defer wt.Flush()
	sc.Buffer([]byte{}, inf)
	sc.Split(bufio.ScanWords)

	n := InputInt()
	ans := 0
	for i := 0; i < n; i++ {
		a := InputInt()
		if i%2 == 0 {
			ans += a
		}
	}

	OutInt(ans)
}

/*** I/O ***/
func InputInt() int {
	sc.Scan()
	val, _ := strconv.Atoi(sc.Text())
	return val
}

func InputString() string {
	sc.Scan()
	return sc.Text()
}

func OutInt(val int) {
	fmt.Fprintln(wt, val)
}

func OutString(s string) {
	fmt.Fprintln(wt, s)
}

Java solution:
import java.util.Scanner;
import java.lang.Number;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    scan.nextLine();
    String rawArr = scan.nextLine();
    int sum = 0;
    int c = 0;
    int i = 0;
    String currentNum = "";
    while (i < rawArr.length()) {
      String chr = rawArr.substring(i,i+1);
      if (chr.equals(" ")) {
        if (c % 2 == 0) sum += Integer.parseInt(currentNum);
        currentNum = "";
        c++;
      } else currentNum = currentNum + chr;
      i++;
    }
    if (currentNum.equals("") || c % 2 == 1) System.out.print(sum);
    else System.out.print(sum + Integer.parseInt(currentNum));
  }
}

JavaScript solution:
function Main(input) {
    const [[N], A] = input.split("\n").map(e => e.split(" ").map(Number));
    let ans = 0;
    for (let i = 0; i < N; i += 2) {
        ans += A[i];
    }
    console.log(ans);
}
Main(require("fs").readFileSync(0)+"")

Python solution:
N = int(input())
A = list(map(int, input().split()))

sum = 0
for i in range(0, N, 2):
  sum += A[i]
print(sum)

Ruby solution:
n = gets.to_i
a = gets.split.map(&:to_i)
ans = 0

a.each_with_index do |x, i|
  ans += x if (i+1).odd?
end

puts ans