jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
// atcoder/code-festival-2017-qualc/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;
    int cnt = 0;
    for (int bit = 0; bit < (1 << (2 * n)); ++bit) {
      vec<int> b;
      int x = bit;
      for (int i = 0; i < n; ++i) {
        int y = x % 4;
        if (y == 0) b.push_back(a[i]);
        if (y == 1) b.push_back(a[i] + 1);
        if (y == 2) b.push_back(a[i] - 1);
        x /= 4;
      }
      if (a.size() != b.size()) continue;
      int p = 1;
      each (i, b) p *= i;
      cnt += (p % 2 == 0);
    }
    cout << cnt << endl;
  }

  return 0;
}
//  [cpp]
#include<bits/stdc++.h>

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;



vector<vi> can(11 , vi());

set<vi> s;

inline vi viadd(vi v , int val){
	v.pb(val);
	return v;
}

void rec(int ev , int p , int n , vi cur){
	if(p == n){
		s.insert(cur);
	}else{
		if(ev == p){
			rep(i , 3){
				if(can[p][i] % 2 == 0){
					rec(ev , p + 1 , n , viadd(cur , can[p][i]));
				}
			}	
		}else{
			rep(i , 3){
				rec(ev , p + 1 , n , viadd(cur , can[p][i]));
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 

	int n;
	cin >> n;
	
	vi v(n);
	rep(i , n){
		cin >> v[i];
	}
	
	rep(i , n){
		can[i].pb(v[i] - 1);
		can[i].pb(v[i] + 1);
		can[i].pb(v[i]);
	}
	
	rep(i , n){
		rec(i , 0 , n , vi());	
	}
	
	cout << sz(s);

	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define isOdd(a) ((a) % 2 == 1)

int main(int argc, char *argv[]){

	int N;

	scanf("%d", &N);

	int A[N];

	int peternNum = 1;
	int allOddPeternNum = 1;
	int i;
	for(i=0;i<N;i++){
		scanf("%d", &A[i]);

		peternNum *= 3;

		if(!isOdd(A[i])){
			allOddPeternNum *= 2;
		}
	}

	printf("%d\n", peternNum - allOddPeternNum);

	return 0;
}
//  [c]
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,i,a[131072],x=1,r=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++){scanf("%d",&a[i]);
        x*=3;
        if(a[i]%2 == 0){r*=2;}
    }
    printf("%d\n",x-r);
    return 0;
}
//  [c]
#include<stdio.h>

int main(){
  int all=1,N,i,ptn=1;
  int A[10];

  scanf("%d",&N);

  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  for(i=0;i<N;i++){
    if(A[i] % 2 == 0)
      ptn *= 2;
  }

  for(i=0;i<N;i++)
    all *= 3;

  printf("%d\n",all - ptn);


  return 0;
}
//  [c]
#include<stdio.h>
#

int main(){

int N,A,odd=1,exp=1;
scanf("%d",&N);
for (int i = 0; i < N; i++){
    scanf("%d",&A);
    if (A%2==0){ odd*=2;}
}

for (int i = 1; i <= N; i++){exp*=3;}

printf("%d",exp-odd);

return 0;

}
//  [c]
#include<stdio.h>
#include<math.h>
int main(){
    int n, x;
    int a[10] = {};
    scanf("%d", &n);
    x = 0;
    
    for (int i=0; i<n; i++){
        scanf("%d", &a[i]);
        if (a[i]%2 == 0){
            x += 1;
        }
    }
    
    int ans = pow(3, n)-pow(2, x);
    printf("%d", ans);
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
  int N,i,odd = 0,even = 0,ans;
  char s[1000],a1[5],a2[5],a3[5],a4[5],a5[5],a6[5],a7[5],a8[5],a9[5],a10[5];

  int A[20];

  scanf("%d\n",&N);
  fgets(s,1000,stdin);
  sscanf(s,"%s %s %s %s %s %s %s %s %s %s",a1,a2,a3,a4,a5,a6,a7,a8,a9,a10);

  A[0] = 0;
  A[1] = atoi(a1);
  A[2] = atoi(a2);
  A[3] = atoi(a3);
  A[4] = atoi(a4);
  A[5] = atoi(a5);
  A[6] = atoi(a6);
  A[7] = atoi(a7);
  A[8] = atoi(a8);
  A[9] = atoi(a9);
  A[10] = atoi(a10);
 for(i = 1;i < N + 1;i++)
    {
      if(A[i]%2 == 1)
        odd = odd + 1;
      else
        even = even + 1;
     
      ans = pow(3,N) - pow(2,even);
    }

  //  printf("odd = %d even = %d",odd,even);
  //printf("%d\n",pow(3,N) - pow(2,even));
  printf("%d\n",ans);
  //printf("%s %s %s",a1,a2,a3);
  //  for(i = 1;i < N + 1;i++)
  // printf("A[%d] = %d\n",i,A[i]);


  return 0;
}
//  [javascript]
function Main(input){
    input = input.split("\n");
  var n = Math.pow(3,input[0]);
  var sum = 1;
  var arr = input[1].split(" ").map(Number);
  arr.forEach(function(val){if(val%2==0)sum *= 2});
  console.log(n-sum);
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = lines[0];
    const list = lines[1].split(" ").map(v=>v-0);
    const cnt = list.filter(v=>v%2==0).length;
    console.log(Math.pow(3,N)-Math.pow(2,cnt));
});
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}
function Main(input) {
  input = myconv(input,3);
  var N = myconv(input[0],1);
  var list = myconv(input[1],4);
  var output = Math.pow(3,N);
  var even = 1;
  for(var i = 0; i < N; i++){
    if(list[i] % 2 == 0){
       even *= 2;
    }
  }
  myout(output - even);
}
Main(myin());
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {
    var n = parseInt(input[0], 10);
    var inputA = input[1].split(' ');
    var a = new Array(n);
    for (var i = 0; i < n; i++) {
        a[i] = parseInt(inputA[i], 10);
    }
    var ans = dfs(0, a);
    console.log(ans);

    return 0;
}

function dfs(i, a) {
    if (i >= a.length) {
        return 0;
    }
    var ans1 = 1;
    for (var j = i + 1; j < a.length; j++) {
        ans1 *= 3;
    }
    var ans2 = dfs(i + 1, a);
    var ans = 0;
    if (a[i] % 2 == 0) {
        ans = ans1 + 2 * ans2;
    }
    else {
        ans = 2 * ans1 + ans2;
    }
    return ans;
}
//  [javascript]
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t){e.exports=function(e){for(var t=e.split("\n"),r=Number(t[0]),n=t[1].split(" ").map(function(e){return Number(e)}),o=0,u=0;u<r;u++)n[u]%2==0&&(o+=1);var i=Math.pow(3,r)-Math.pow(2,o);console.log(i)}},function(e,t){e.exports=require("fs")}]);
//  [javascript]
"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const A = arg[1].split(" ").map(n=>parseInt(n));
    
    let k = 1;
    
    for(let i in A) {
        if(A[i] % 2 === 0) {
            k *= 2;
        }
    }
    
    console.log(Math.pow(3, N) - k);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	total := int(math.Pow(3, float64(n)))
	odd := 1
	for i := 0; i < n; i++ {
		if list[i]%2 == 0 {
			odd *= 2
		} else {
			odd *= 1
		}
	}
	fmt.Println(total - odd)

}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	all := 1
	odd := 1
	for i := 0; i < n; i++ {
		all *= 3
		a := scanInt()
		if a%2 == 0 {
			odd *= 2
		}
	}
	fmt.Println(all - odd)
}
//  [go]
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	r := 1
	for i := 0; i < N; i++ {
		if A[i]%2 == 0 {
			r *= 2
		} else {
			r *= 1
		}
	}
	fmt.Println(powInt(3, N) - r)
}
//  [go]
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	return n, as
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int, as []int) int {
	// even is includes even item more than or equal to 1
	// all case - all odd
	all := pow(3, n)
	cases := 1
	for i := 0; i < len(as); i++ {
		if as[i]%2 == 0 {
			cases *= 2
		}
	}
	return all - cases
}

func pow(n, ex int) int {
	cur := 1
	for i := 0; i < ex; i++ {
		cur *= n
	}
	return cur
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}
//  [ruby]
n=gets.to_i
as=gets.split(" ").map(&:to_i)
p(3**n-2**(as.select(&:even?).count))
//  [ruby]
N,*as=$<.read.split.map(&:to_i)

n = 3**N
n -= as.inject(1) {|s,a| a.odd? ? s*1 : s*2 }
puts n
//  [ruby]
def main(argv)
  n = gets.chomp.to_i
  a = gets.chomp.split(' ').map(&:to_i)

  k = 0
  n.times{ |i| k += 1 if a[i] % 2 == 0 }

  s = (3 ** n) - (2 ** k)
  puts s.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end
//  [ruby]
n = gets.to_i
a = gets.split.map(&:to_i)
h = %w[0 1 2].zip([-1, 0, 1]).to_h
count = 0

(3**n).times do |i|
  bit = format("%0#{n}d", i.to_s(3))
  prod = 1

  bit.each_char.with_index do |b, idx|
    prod *= (a[idx] + h[b])
  end

  count += 1 if prod.even?
end

puts count
//  [ruby]
n = gets.chomp.to_i #=> d.size
a = gets.chomp.split(" ").map(&:to_i)
arr = []
a.each do |i|
  arr << [i-1,i,i+1]
end

if a.size == 1
  puts a[0] % 2 == 0 ? "1" : "2"
  exit
end

cp = []
arr.each_with_index do |carr,i|
  if i == 0
    cp = carr
  else
    cp = cp.product(carr)
  end
end

cp.each do |c|
  c.flatten!
end

count = 0
cp.each do |arr|
  if arr.count{|item| item % 2 == 0} > 0
    count += 1
  end
end

puts count

#puts cp.count do |arr|
#  arr.count{|item| item % 2 == 0} > 0
#end
//  [ruby]
def ascan; gets.split.map(&:to_i);end

n = gets.to_i

aa = ascan

c = 0
(-1..1).to_a.repeated_permutation(n) do |zz|
    a = aa.clone
    n.times do |i|
        a[i] += zz[i]
    end
    c+=1 if a.reduce(:*).even?
end


p c
//  [rust]
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<u64>();

    let odd = a.iter().filter(|x| **x%2 == 1).count();
    let even = n - odd;

    println!("{}", 3u64.pow(n as u32) - 2u64.pow(even as u32));
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::{i32, i64, u32, u64, f64};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashMap, BTreeMap, HashSet, BTreeSet};
#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};
#[allow(unused_imports)]
use std::mem::{swap};
//#[allow(unused_imports)]
//use proconio::marker::{Isize1, Usize1, Bytes, Chars};

//#[proconio::fastout]
fn main() {
    input!{
        n: usize,
        a: [i32; n],
    }
    println!("{}", 3i32.pow(n as u32) - a.iter().map(|i| { 2 - (i % 2)} ).product::<i32>());
}
//  [rust]
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn dfs(idx: i64, n: i64, a: &Vec<i64>, sum: i64) -> i64 {
   if idx == n {
       if sum %2 == 0 { return 1; }
       else { return 0; }
   }

   let mut res:i64 = 0;
   for i in -1..2 {
       res += dfs(idx+1, n, a, sum*(a[idx as usize]+i as i64));
   }
   return res;
}

fn main() {
    input!{n:usize, a:[i64; n]};
    let ans = dfs(0, n as i64, &a, 1);
    println!("{}", ans);
}
//  [rust]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

// std::cmp::Reverse doesn't have Clone.
#[derive(Eq, PartialEq, Clone)]
struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn main() {
    let n: usize = util::get();
    let a: Vec<usize> = util::gets();

    let total = (0..n).map(|_| 3).fold(1, |a, b| a * b);
    let odd = a.iter().map(|x| if x % 2 == 0 { 2 } else { 1 }).fold(
        1,
        |a, b| a * b,
    );

    println!("{}", total - odd);
}
//  [swift]
import CoreFoundation
print(Int(pow(3,Double(readLine()!)!)-pow(2,Double(readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count))))
//  [swift]
func pow(x:Int,_ y:Int)->Int{return (0..<y).reduce(1){i,_ in i*x}}
print(pow(3,Int(readLine()!)!)-pow(2,readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count))
//  [swift]
func pow(x: Int, _ y: Int) -> Int {
  return (0..<y).reduce(1){i,_ in i*x}
}
let N = Int(readLine()!)!
let n = readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count
print(pow(3,N)-pow(2,n))
//  [swift]
func pow(x: Int, _ y: Int) -> Int {
  return (0..<y).reduce(1){i,_ in i*x}
}
print(pow(3,Int(readLine()!)!)-pow(2,readLine()!.characters.split(" ").filter{Int(String($0))!%2==0}.count))
//  [typescript]
function solve(lines: string): void {
  const n = parseInt(lines[0].trim(), 10);
  const xs = lines[1].trim().split(' ').map( (x) => parseInt(x, 10) );
  let ans = 1;
  for (let i = 0; i < n; i++) {
    ans *= 3;
  }
  let pat = 1;
  for (let x of xs) {
    if (x % 2 === 0) {
      pat *= 2;
    }
  }
  ans -= pat;
  console.log(ans);
}
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  const s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  solve(buf.trim().split("\n"));
});
//  [python]
import numpy as np


def check(t_diff, x_diff, y_diff):
    l1 = abs(x_diff) + abs(y_diff)
    if l1 > t_diff:
        return False
    elif (t_diff - l1) % 2 == 1:
        return False
    else:
        return True

N = int(input())
t = np.zeros(N+1,)
x = np.zeros(N+1,)
y = np.zeros(N+1,)
for i in range(N+1):
    if i != 0:
        t[i], x[i], y[i] = tuple(map(int, input().split()))

for j in range(N):
    t_diff = t[j+1] - t[j]
    x_diff = x[j+1] - x[j]
    y_diff = y[j+1] - y[j]
    if not check(t_diff, x_diff, y_diff):
        print("No")
        exit()

print("Yes")
//  [python]
N=int(input())
TXY=[list(map(int,input().split())) for i in range(N)]

Next=TXY.pop(0)
Flag=1

for i in range(N):
    D=Next[0]-abs(Next[1])-abs(Next[2])
    if D<0 or D%2!=0:
        Flag=0
        break
    else:
        if TXY==[]:
            break
        else:
            Next2=TXY.pop(0)
            Next=[Next2[0]-Next[0],Next2[1]-Next[1],Next2[2]-Next[2]]

print(['No','Yes'][Flag])
//  [python]
import numpy as np
N = int(input())
S = []
for i in range(N):
    S.append(list(map(int,input().split())))
now = [0,0]
time = 0
flag = True
for i in range(N):
    dis = abs(S[i][1]-now[0])+abs(S[i][2]-now[1])
    if(dis > S[i][0] or (S[i][0]-time)%2 != dis%2):
        flag = False
        break
    now[0] = S[i][1]
    now[1] = S[i][2]
    time = S[i][0]
    
if flag:
    print("Yes")
else:
    print("No")
//  [java]
import java.util.*;
import java.util.stream.*;

public class Main{
	public static void main(String... args){ new Main().solve(); }

	public void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int pt = 0;
		int px = 0;
		int py = 0;
		int ct = 0;
		int cx = 0;
		int cy = 0;
		int condition[][] = new int[n][2];
		for(int i=0; i<n; i++){
			ct = sc.nextInt();
			cx = sc.nextInt();
			cy = sc.nextInt();
			condition[i][0] = ct - pt;
			condition[i][1] = Math.abs(cx - px) + Math.abs(cy - py);
			pt = ct;
			px = cx;
			py = cy;
		}
		Optional<int[]> oia = Arrays.asList(condition).stream()
			.filter(a -> {
				if(((a[0] & 1) != (a[1] & 1)) || a[0] < a[1]) return true;
				return false;
			})
			.findFirst();
		if(oia.isPresent()) System.out.println("No");
		else System.out.println("Yes");
	}
}
//  [java]
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[][] points = new int[NUM+1][3];
        points[0] = new int[]{0, 0, 0};
        for(int i = 1; i <= NUM; i++){
            points[i][0] = scan.nextInt();
            points[i][1] = scan.nextInt();
            points[i][2] = scan.nextInt();
        }

        // sort
        Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0]));

        // search
        String answer = "Yes";
        for(int i = 1; i <= NUM; i++){
            int grace = points[i][0] - points[i - 1][0];
            int distance = Math.abs(points[i][1] - points[i-1][1]) + Math.abs(points[i][2] - points[i-1][2]);
            if(grace >= distance ){
                if((grace % 2 == 0 && distance % 2 == 0) || (grace % 2 == 1 && distance % 2 == 1) ){
                    
                } else {
                    answer = "No";
                    break;
                }
            } else {
                answer = "No";
                break;
            }
        }

        // answer
        System.out.println(answer);

    }
}
//  [java]

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;



public class Main{

	public static void main(String[] args){


		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		scan.nextLine();

		Map<Integer, Integer> map = new LinkedHashMap<>(N);

        for(int i=0; i<N; i++) {

	   		int t = scan.nextInt();
			int x = scan.nextInt();
			int y = scan.nextInt();
			int point = x+y;

			map.put(t,point);

	       }

    	int flagk =0;
    	int flagv =0;

    	int count =0;


	    for (Map.Entry<Integer, Integer> entry : map.entrySet()) {

	       // System.out.println(entry.getKey() + " : " + entry.getValue());
	    	int key = entry.getKey().intValue();
	    	int val = entry.getValue().intValue();

	    	//System.out.println("process: key" + key + "val" + val);


	    	if ( (key>=val) && (key%2==val%2) && ( Math.abs(key-flagk) >=Math.abs(val-flagv) ) ) {
	    		flagk = key;
	    		flagv = val;
	    	}
	    	else {
	    		System.out.println("No");
	    		//System.out.println("key" + (key-flagk) + "val" + Math.abs(val-flagv));
	    		//System.out.println("key" + key + "val" + val);
	    		break;
	    	}

	    	++count;
	    	if (count ==N) {
	    		System.out.println("Yes");
	    	}

	    }

	}
}
//  [cpp]
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> t, vector<long long> x,
           vector<long long> y) {
  ll preT = 0;
  ll preX, preY;
  preX = preY = 0;

  REP(i, N) {
    ll diffT = t[i] - preT;
    ll diffP = abs(preX - x[i]) + abs(preY - y[i]);
    dump(t[i], preT, preX, preY, x[i], y[i], diffT, diffP);
    if (diffP <= diffT && abs(diffP - diffT) % 2 == 0) {
    } else {
      cout << "No" << endl;
      return;
    }
    preT = t[i];
    preX = x[i];
    preY = y[i];
  }
  cout << "Yes" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> t(N - 1 + 1);
  vector<long long> x(N - 1 + 1);
  vector<long long> y(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> t[i];
    cin >> x[i];
    cin >> y[i];
  }
  solve(N, t, x, y);
  return 0;
}
//  [cpp]
#include <iostream>/*{{{*/
#include <bits/stdc++.h>
#define REP(i, x) for(int i = 0; i < (int)(x); i++)
#define REPS(i,x) for(int i = 1; i <= (int)(x); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x,y) memset(x,y,sizeof(x))
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define PB(a) push_back(a)
#define debug(x) cerr << __LINE__ << ": " << #x << " -> " << x << '\n'
#define INF 999999999
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};/*}}}*/

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  int t[n+1], x[n+1], y[n+1];
  t[0] = 0; x[0] = 0; y[0] = 0;
  debug(n);
  REPS(i, n){
    debug(i);
    cin >> t[i] >> x[i] >> y[i];
  }

  int diff;
  REPS(i, n){
    diff = 0;

    diff += abs(x[i] - x[i-1]);
    diff += abs(y[i] - y[i-1]);
    debug(diff);
    if (diff > abs(t[i]-t[i-1]) or (abs(t[i]-t[i-1])-diff)%2!=0){
      puts("No");
      return 0;
    }
  }
  puts("Yes");

  return 0;
}
//  [cpp]
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int n;

  cin >> n ; //nは10の5乗数

  vector<long> t(n);
  vector<long> x(n);
  vector<long> y(n);
  for (int i = 0; i < n; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }



  bool ans=true;
  int px=0,py=0;
  int pt=0;

  for (int i = 0; i < n; ++i){
    cerr  << "t:" <<t[i] - pt  <<"   x:" <<abs(px-x[i]) <<"   y:" <<abs(py-y[i]) <<endl;
    if (t[i] - pt >= abs(px-x[i]) + abs(py-y[i])  && (t[i] - pt + abs(px-x[i]) + abs(py-y[i]) )%2 ==0 ){
      px = x[i];
      py = y[i];
      pt =t[i];
    }else{
      ans=false;
      break;
    }
  }


  cout <<(ans?"Yes":"No");


  return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
    int N;
    int t[100000],x[100000],y[100000];
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    int can=1;
    for(int i=0;i<N;i++){
        int can2=0;
        for(int n=0;x[i]+y[i]+2*n<=t[i];n++){
            if(x[i]+y[i]+2*n==t[i]){
                can2=1;
                //printf("n=%d ok\n",n);
            }
        }
        //printf("can2=%d\n",can2);
        if(can2==0){
            can=0;
            break;
        }
    }
    if(can==1)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}
//  [c]
#include <stdio.h>

int main(void)
{
    int N;
    int t[100000],x[100000],y[100000];
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    int can=1;
    for(int i=0;i<N;i++){
        int can2=0;
        for(int n=0;x[i]+y[i]+2*n<=t[i];n++){
            if(x[i]+y[i]+2*n==t[i]){
                can2=1;
            }
        }
        if(can2==0){
            can=0;
            break;
        }
    }
    if(can==1)
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int main(void) {
    int N;
    int x,y,t,ax=0,ay=0,at=0;
  	int dis;
    char buf[1000];

    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%d \n", &N);
  
  for(int i=0;i<N;i++){
        fgets(buf, sizeof(buf), stdin);
  	    sscanf(buf, "%d %d %d\n", &t,&x,&y);
   	    dis=abs(x-ax+y-ay)-t+at;
		if(dis>0||dis%2==-1){
	    printf("No");
        return 0;
        }
    	ax=x;
    	ay=y;
    	at=t;
  }
	printf("Yes");
    return 0;
}
//  [javascript]

function Main(input) {
    var N = parseInt(input[0], 10);
    var TXY = input.slice(1).map(txy => {
        var list = txy.split(/\s/)
        return {
            t: list[0],
            x: list[1],
            y: list[2]
        };
    });

    var time = 0;
    var isTimeEven = false;
    var dist = 0;

    for (var i = 0; i < N; i++) {
        if (i === 0) {
            time = TXY[i].t;
            isTimeEven = time % 2 === 0;
            dist = Math.abs(TXY[i].x) + Math.abs(TXY[i].y);
            if (dist > time) {
                return console.log('No');
            } else {
                if (isTimeEven) {
                    if (dist % 2 !== 0) {
                        return console.log('No');
                    }
                } else {
                    if (dist % 2 !== 1) {
                        return console.log('No');
                    }
                }
            }
        } else {
            time = TXY[i].t - TXY[i - 1].t;
            isTimeEven = time % 2 === 0;
            dist = Math.abs(TXY[i].x - TXY[i - 1].x) + Math.abs(TXY[i].y - TXY[i -1].y);
            if (dist > time) {
                return console.log('No');
            } else {
                if (isTimeEven) {
                    if (dist % 2 !== 0) {
                        return console.log('No');
                    }
                } else {
                    if (dist % 2 !== 1) {
                        return console.log('No');
                    }
                }
            }
        }
    }

    console.log('Yes');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));
//  [javascript]
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.log(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main(input) {
  input = myconv(input,3);
  //次の地点に対して時間内にユークリッド距離で到達できること,かつ、t差と距離の偶奇が一致すること
  var N = myconv(input[0],1);
  var maeT = 0;
  var maeX = 0;
  var maeY = 0;
  for(var i = 1; i <= N; i++){
    var t = myconv(input[i],4)[0];
    var x = myconv(input[i],4)[1];
    var y = myconv(input[i],4)[2];
    var dt = Math.abs(t - maeT);
    var dx = Math.abs(x - maeX);
    var dy = Math.abs(y - maeY);
    if(dx + dy <= dt && (dx+dy) % 2 == dt % 2){
       maeT = t;
      maeX = x;
      maeY = y;
    }else{
      myout("No");
      return;
    }
  }
  myout("Yes");
}

Main(myin());
//  [javascript]
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0]); lines.shift();
    var txy = lines.map(i => i.split(" ").map(i => Number(i)));

    var t = txy[0][0], x = txy[0][1], y = txy[0][2]
    if (t < x + y || (t - (x + y)) % 2 !== 0) { console.log("No"); return (0); }

    for (var i = 1; i < N; i++) {
        t = Math.abs(t - txy[i][0]), x = Math.abs(x - txy[i][1]), y = Math.abs(y - txy[i][2]);

        if (t < x + y || (t - (x + y)) % 2 !== 0) { console.log("No"); return (0) }
    }

    console.log("Yes")
});
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	sx, sy := 0, 0
	prevTime := 0
	for i := 0; i < n;i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		diffDis := abs(x-sx) +abs(y -sy)
		diffTime := t - prevTime
		if diffTime >= diffDis {
			if diffTime % 2 == 0 && (abs(x-sx) +abs(y -sy)) %2 ==0 {
				sx = x
				sy = y
				prevTime = t
				continue
			} else if diffTime % 2 == 1 && diffDis%2 == 1 {
				sx = x
				sy = y
				prevTime = t
				continue
			}
		}
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n, x, y, t, prevX, prevY, prevT int
	fmt.Scan(&n)
	abs := func (x int) int {
		if x < 0 {
			return -x
		}
		return x
	}

	for i := 0; i < n; i++ {
		fmt.Scan(&t, &x, &y)
		dx := abs(x - prevX)
		dy := abs(y - prevY)
		dt := t - prevT
		if dist := dx + dy; dt < dist || dist % 2 != dt % 2 {
			fmt.Println("No")
			return
		}
		prevX, prevY, prevT = x, y, t
	}
	fmt.Println("Yes")

}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	prevt, prevx, prevy := 0, 0, 0
	// そこまでの距離と時間差の比較, 偶数と奇数の比較
	for i := 0; i < n; i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)

		if t-prevt < int(math.Abs(float64(x-prevx))+math.Abs(float64(y-prevy))) {
			fmt.Println("No")
			return
		}
		if (t-prevt)%2 != int(math.Abs(float64(x-prevx))+math.Abs(float64(y-prevy)))%2 {
			fmt.Println("No")
			return
		}
		prevt = t
		prevx = x
		prevy = y
	}
	fmt.Println("Yes")
	return
}
//  [ruby]
N = gets.to_i
t, x, y = 0, 0, 0
N.times{
    T, X, Y = gets.split.map(&:to_i)
    a = (x - X).abs + (y - Y).abs
    b = T - t
    if b < a || (a - b) % 2 != 0 then
        puts 'No'; exit
    end
    t, x, y = T, X, Y
}
puts 'Yes'
//  [ruby]
n = gets.to_i
points = []
n.times do
  points.push gets.split(/\s/).map{|x| x.to_i}
end
result = true
points.each do |point|
  sum = point[1] + point[2]
  cond1 = (point[0].odd? && sum.odd?) || (point[0].even? && sum.even?)
  cond2 = point[0] >= sum
  unless cond1 && cond2
    result = false
    break
  end
end
puts result ? "Yes" : "No"
//  [ruby]
n=gets.chomp.to_i
posit = []

n.times do |i|
  t,x,y=gets.chomp.split(" ").map { |e| e.to_i }
  posit[i] = {"t" => t,"x" => x,"y" => y}
end

def abs(n)
  return n if n>=0
  return -n
end

first = {"t"=>0,"x"=>0,"y"=>0 }


for i in 0..n-1 do
  xd = (abs(posit[i]["x"]-first["x"]) + abs(posit[i]["y"] - first["y"]))
  td = abs(posit[i]["t"] - first["t"])
  if  !(xd <= td && (td - xd)%2 == 0)
    puts "No"
    exit
  end
end

puts "Yes"
//  [rust]
use proconio::{input, fastout};
use proconio::marker::{Chars};
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        n: usize,
    }

    let mut t: Vec<usize> = vec![0;1];
    let mut ords: Vec<(usize,usize)> = vec![(0,0);1];
    for i in 0..n {
        input!{
            t_tmp: usize,
            x: usize,
            y: usize,
        }
        t.push(t_tmp);
        ords.push((x,y));
    }
    debug!(ords);
    debug!(t);
    for i in 0..n {
        let dis = (ords[i+1].0 as i64 - ords[i].0 as i64).abs()
                 +(ords[i+1].1 as i64 - ords[i].1 as i64).abs();
        let time = t[i+1]-t[i];
        debug!(dis);
        debug!(time);
        if time as i64 >=dis && (time as i64 - dis)%2==0{
            continue;
        } else {
            println!("No");
            return;
        }
    }

    println!("Yes");

}
//  [rust]
/**
 */

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Debug, Copy, Clone)]
struct Coord{
    time:u32,
    x:u32,
    y:u32
}

// impl Coord
// {
//     fn copy(&self) -> Coord
// }

fn main() {
    let n: u32 = read();

    // if (n < 1) || (100000 < n)
    // {
    //     eprintln!("ERROR!(1)¥n");
    //     return;
    // }

    let mut coord_org = Coord {
        time: 0,
        x: 0,
        y: 0
    };

    let mut can_move: bool = true;

    for _i in 0u32..n
    {
        eprintln!("Now pos:({},{})", coord_org.x, coord_org.y);

        let coord_new = Coord {
            time: read(),
            x: read(),
            y: read()
        };

        if can_move
        {
            // let mut coord_calc = Coord{
            //     time: coord_org.time,
            //     x: coord_org.x,
            //     y: coord_org.y
            // };
            let mut coord_calc = coord_org;

            for _j in coord_org.time+1..coord_new.time+1
            {
                if coord_calc.x < coord_new.x
                {
                    coord_calc.x += 1;
                }
                else if coord_calc.x > coord_new.x
                {
                    coord_calc.x -= 1;
                }
                else
                {
                    // xが同じ
                    if coord_calc.y < coord_new.y
                    {
                        coord_calc.y += 1;
                    }
                    else if coord_calc.y > coord_new.y
                    {
                        coord_calc.y -= 1;
                    }
                    else
                    {
                        // xもyも同じ
                        coord_calc.x -= 1;
                    }
                }

                eprintln!("Calc pos({}):({},{})", _j, coord_calc.x, coord_calc.y);
            }

            if (coord_calc.x == coord_new.x) && (coord_calc.y == coord_new.y)
            {
                // coord_org.time = coord_new.time;
                // coord_org.x = coord_new.x;
                // coord_org.y = coord_org.y;
                coord_org = coord_new;
            }
            else
            {
                can_move = false;
            }
        }
    }

    if can_move
    {
        println!("Yes");
    }
    else
    {
        println!("No");
    }
}