Gaius Julius Caesar, a famous general, loved to line up his soldiers. Overall the army had n1 footmen and n2 horsemen. Caesar thought that an arrangement is not beautiful if somewhere in the line there are strictly more that k1 footmen standing successively one after another, or there are strictly more than k2 horsemen standing successively one after another. Find the number of beautiful arrangements of the soldiers. Note that all n1 + n2 warriors should be present at each arrangement. All footmen are considered indistinguishable among themselves. Similarly, all horsemen are considered indistinguishable among themselves.

The only line contains four space-separated integers n1, n2, k1, k2 (1 ≤ n1, n2 ≤ 100, 1 ≤ k1, k2 ≤ 10) which represent how many footmen and horsemen there are and the largest acceptable number of footmen and horsemen standing in succession, correspondingly.

Print the number of beautiful arrangements of the army modulo 100000000 (108). That is, print the number of such ways to line up the soldiers, that no more than k1 footmen stand successively, and no more than k2 horsemen stand successively.

NoteLet's mark a footman as 1, and a horseman as 2.In the first sample the only beautiful line-up is: 121In the second sample 5 beautiful line-ups exist: 12122, 12212, 21212, 21221, 22121

var  dpf = new Array(101);
var dph = new Array(101);
var n1, n2, k1, k2, input;
var M = 100000000;

for (var i = 0; i < 101; i++) {
    dpf[i] = new Array(101).fill(-1);
    dph[i] = new Array(101).fill(-1);
}

input = readline();

n1 = Number(input.split(" ")[0]);n2 = Number(input.split(" ")[1]);
k1 = Number(input.split(" ")[0]);k2 = Number(input.split(" ")[0]);

print((footMan(n1, n2) + horseMan(n1, n2)) % M);

function footMan(f, h) {
    // footman을 먼저 세우기 시작하여 배치할 수 있는 모든 경우의 수
    if (f == 0) {// 풋맨이 더 이상 없다면
        return (h == 0) ? 1 : 0;
    }
    var ret = dpf[f][h];
    if (ret != -1) {
        return ret;
    }
    var sum = 0;
    for (var i = 1; i <= min(k1, f); i++) {
        sum += horseMan(f - i, h);
        sum  %= M;
    }
    return sum;

}
function horseMan(f, h) {
    // horseman을 먼저 세우기 시작하여 배치할 수 있는 모든 경우의 수
    if (h == 0) {// 홀스맨이 더 이상 없다면
        return (f == 0) ? 1 : 0;
    }
    var ret = dph[f][h];
    if (ret != -1) {
        return ret;
    }
    var sum = 0;
    for (var i = 1; i <= min(k2, h); i++) {
        sum += footMan(f, h - i);
        sum %= M;
    }
    return sum;
}
function min(x, y) {
  return (x < y) ? x : y;
}


The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $$$n$$$ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are $$$m$$$ cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?Could you help her with this curiosity?You can see the examples and their descriptions with pictures in the "Note" section.

The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 1000$$$, $$$0 \leq m \leq n$$$) — the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.

Print a single integer — the maximum number of groups of cats at the moment Katie observes.

NoteIn the first example, originally there are $$$7$$$ cats sitting as shown below, creating a single group:  At the observed moment, $$$4$$$ cats have left the table. Suppose the cats $$$2$$$, $$$3$$$, $$$5$$$ and $$$7$$$ have left, then there are $$$3$$$ groups remaining. It is possible to show that it is the maximum possible number of groups remaining.  In the second example, there are $$$6$$$ cats sitting as shown below:  At the observed moment, $$$2$$$ cats have left the table. Suppose the cats numbered $$$3$$$ and $$$6$$$ left, then there will be $$$2$$$ groups remaining ($$$\{1, 2\}$$$ and $$$\{4, 5\}$$$). It is impossible to have more than $$$2$$$ groups of cats remaining.  In the third example, no cats have left, so there is $$$1$$$ group consisting of all cats.In the fourth example, all cats have left the circle, so there are $$$0$$$ groups.

var firstLine = readline().split(' ');
var rdy = false
if(+firstLine[1] === 0) print(1);
if(+firstLine[1] !== 0) {
if(+firstLine[1] === +firstLine[0]){ rdy = true; print(0);}
if((+firstLine[0] - +firstLine[1] >= +firstLine[1]) && !rdy){rdy = true; print(+firstLine[1]);}
if((+firstLine[0] - +firstLine[1] < +firstLine[1]) && !rdy) print(+firstLine[0] - +firstLine[1]);
}

ip = readline().split(' ').map(Number);
n = ip[0], k = ip[1];
if (k === 0){
    print(1);
}else
if (k <= n/2){
    print(k)
} else {
    print(n-k);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (n === 0 || n === m) {
    print(0);
} else if (m === 0){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1] - m);
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  const [n, m] = d.split(' ').map(Number);

  if (m === 0 || m === 1) {
    console.log(1);
  }
  else if (n === m) {
    console.log(0);
  }
  else if (n / 2 > m) {
    console.log(m);
  }
  else {
    console.log(n - m);
  }

  c++;
});

var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    n--;
    let gcount  = 1;
    for(let i = 0; i < m; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else if (n === 2) {
            n-=2;
        } else {
            gcount++;
            n-=2;
        }
    }
    return gcount;
 }

var firstLine = readline().split(' ');
if(+firstLine[1] === +firstLine[0]) print(0);
if(+firstLine[0] / +firstLine[1] === +firstLine[1]) print(+firstLine[1]);
if(+firstLine[0] / +firstLine[1] > +firstLine[1]) print(+firstLine[1]);
if(+firstLine[0] / +firstLine[1] < +firstLine[1]) print(+firstLine[0] - +firstLine[1]);

var firstLine = readline().split(' ');
if(+firstLine[1] === 0) print(1);
if(+firstLine[1] === +firstLine[0]) print(0);
if(+firstLine[0] / +firstLine[1] === +firstLine[1]) print(+firstLine[1]);
if(+firstLine[0] / +firstLine[1] > +firstLine[1]) print(+firstLine[1]);
if(+firstLine[0] / +firstLine[1] < +firstLine[1]) print(+firstLine[0] - +firstLine[1]);

var firstLine = readline().split(' ');
if(+firstLine[1] === 0) print(1);
if(+firstLine[1] !== 0) {
    if(+firstLine[1] === +firstLine[0]) print(0);
    if(+firstLine[0] / +firstLine[1] >= +firstLine[1]) print(+firstLine[1]);
    if(+firstLine[0] / +firstLine[1] < +firstLine[1]) print(+firstLine[0] - +firstLine[1]);
}

var firstLine = readline().split(' ');
var rdy = false
if(+firstLine[1] === 0) print(1);
if(+firstLine[1] !== 0) {
if(+firstLine[1] === +firstLine[0]){ rdy = true; print(0);}
if((+firstLine[0] / +firstLine[1] >= +firstLine[1]) && !rdy) print(+firstLine[1]);
if((+firstLine[0] / +firstLine[1] < +firstLine[1]) && !rdy) print(+firstLine[0] - +firstLine[1]);
}

var firstLine = readline().split(' ');
var rdy = false
if(+firstLine[1] === 0) print(1);
if(+firstLine[1] !== 0) {
if(+firstLine[1] === +firstLine[0]){ rdy = true; print(0);}
if((+firstLine[0] / +firstLine[1] >= +firstLine[1]) && !rdy){rdy = true; print(+firstLine[1]);}
if((+firstLine[0] / +firstLine[1] < +firstLine[1]) && !rdy) print(+firstLine[0] - +firstLine[1]);
}

ip = readline().split(' ').map(Number);
n = ip[0], k = ip[1];
if (k <= n/2){
    print(k)
} else {
    print(n-k);
}

ip = readline().split(' ').map(Number);
n = ip[0], k = ip[1];
if (k <= n/2 && k !== 0){
    print(k)
} else {
    print(n-k);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (n === 0 || n === m) {
    print(0);
} else if (m === 0){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1]);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (m === 0 || n === m) {
    print(0);
} else if (m === 0){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1]);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (m === 0 || n === m) {
    print(0);
} else if (m === 0){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr);
    print(arr.filter(x => x).length - arr[arr.length - 1]);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (m === 0 || n === m) {
    print(0);
} else if (m === 1){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1]);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (m === 0 || n === m) {
    print(0);
} else if (m === 0){
    print(1);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1] - m);
}

var n, m;
readline().split(' ').forEach(function(v, i){
    if (i === 0) {
        n = parseInt(v);
    } else {
        m = parseInt(v);
    }
});

if (m === 0 || m === 1 || n === m) {
    print(0);
} else {
    arr = [];

    for(var i = 0; i < n; i++) {
        if (!arr[i - 1] && m > 0) {
            arr[i] = 1;
            m--;
        } else {
            arr[i] = 0;
        }
    }

    print(arr.filter(x => x).length - arr[arr.length - 1]);
}

var firstLine = readline().split(' ');
if(+firstLine[1] === +firstLine[0]) print(0);
if(+firstLine[0] / +firstLine[1] === +firstLine[1]) print(+firstLine[1]);
if(+firstLine[0] / +firstLine[1] > +firstLine[1]) print(+firstLine[0] - +firstLine[1]);
if(+firstLine[0] / +firstLine[1] < +firstLine[1]) print(+firstLine[1]);

var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    let gcount  = 1;
    for(let i = 0; i < m-1; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else {
            gcount++;
            n-=2;
        }
    }
    return gcount;
 }

var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    let gcount  = 0;
    for(let i = 0; i < m-1; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else {
            gcount++;
            n-=2;
        }
    }
    return n;
 }

var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    let gcount  = 1;
    for(let i = 0; i < m-1; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else {
            gcount++;
            n-=2;
        }
    }
    return n;
 }

var stdin = process.openStdin();

stdin.addListener("data", function(d) {
    const arr = d.toString().trim().split(" ");
    console.log(findg(parseInt(arr[0]), parseInt(arr[1])));
  });

 function findg(n, m){
    if(n === m){
        return 0;
    } else if(m === 0){
        return 1;
    }
    m--;
    let gcount  = 1;
    for(let i = 0; i < m; i++){
        if(n === 0 || n === 1){
            gcount--;
        } else {
            gcount++;
            n-=2;
        }
    }
    return gcount;
 }


There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.The presenter has m chips. The presenter stands in the middle of the circle and starts giving the chips to the walruses starting from walrus number 1 and moving clockwise. The walrus number i gets i chips. If the presenter can't give the current walrus the required number of chips, then the presenter takes the remaining chips and the process ends. Determine by the given n and m how many chips the presenter will get in the end.

The first line contains two integers n and m (1 ≤ n ≤ 50, 1 ≤ m ≤ 104) — the number of walruses and the number of chips correspondingly.

Print the number of chips the presenter ended up with.

NoteIn the first sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, four chips to the walrus number 4, then again one chip to the walrus number 1. After that the presenter runs out of chips. He can't give anything to the walrus number 2 and the process finishes.In the third sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, then again one chip to the walrus number 1. The presenter has one chip left and he can't give two chips to the walrus number 2, that's why the presenter takes the last chip.

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  const [n, m] = d.split(' ').map(Number);
  let ans = m;
  let iter = 1;

  while (ans >= iter) {
    ans -= iter;
    iter++;

    if (iter > n) {
      iter = 1;
    }
  }

  console.log(ans);

  c++;
});

print(function(n,m){
	m%=(n*n+n)/2
	for(var i=1; m>=i; m-=i++);
	return m;
}.apply(0, readline().split(' ').map(Number)))

var line = readline().split(" ");
var a = parseInt(line[0]);
var b = parseInt(line[1]);

// var a = 4
// var b = 11

var j = 0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
var i = 1;

while (b>=i) {
	b-=i;
	i++;
}
print(b)

;(function () {
	var n = readline().split(' ').map(Number),
		i = 1;

	while (n[1] >= i) {
		n[1] -= i;
		if (i == n[0]) i = 0;
		else i = i + 1;
	}

	print(n[1]);

}).call(this)

var nm = readline();
nm = nm.split(" ");
nm[0] = parseInt(nm[0]);
nm[1] = parseInt(nm[1]);
var i = 1;
while(8)
{
    if(nm[1] - i < 0){print(nm[1]); break;}
    nm[1] -= i;
    i++;
    if(i > nm[0]){i = 1;}
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  const [n, m] = d.split(' ').map(Number);
  let ans = m;
  let iter = 1;

  while (ans > iter) {
    ans -= iter;
    iter++;

    if (iter > n) {
      iter = 1;
    }

    if (iter === 1 && ans === 1) {
      ans = 0;
    }
  }

  console.log(ans);

  c++;
});

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);
// var a = 4
// var b = 11

var j = 0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
var i = 1;

while (b>=i) {
	b-=i;
	i++;
}
print(b)

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);

var j=0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
i=1;

while (b>=i) {
	b-=i;
	i++;
}
print(b+"\n");

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);
var a = 4
var b = 11

var j=0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
i=1;

while (b>=i) {
	b-=i;
	i++;
}
print(line)

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);
var a = 4
var b = 11

var j = 0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
var i = 1;

while (b>=i) {
	b-=i;
	i++;
}
print(b)

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);

var j=0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
i=1;

while (b>=i) {
	b-=i;
	i++;
}
print(b);

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);

// var a = 4
// var b = 11

var j = 0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
var i = 1;

while (b>=i) {
	b-=i;
	i++;
}
print(line[0], line[1])

var line = readline().split();
var a = parseInt(line[0]);
var b = parseInt(line[1]);
// var a = 4
// var b = 11

var j=0;
for (var i = 1; i <= a; i++) {
	j += i;
}

b = b % j;
i=1;

while (b>=i) {
	b-=i;
	i++;
}
print(b.toString()+"\n");

var line = readline().split()
var a = parseInt(line[0])
var b = parseInt(line[1])

var j=0
for (var i = 1; i <= a; i++) {
	j += i
}

b = b % j
i=1

while (b>=i) {
	b-=i
	i++
}
print(b)


You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons. Three balloons attached to some table shouldn't have the same color. What maximum number t of tables can be decorated if we know number of balloons of each color?Your task is to write a program that for given values r, g and b will find the maximum number t of tables, that can be decorated in the required manner.

The single line contains three integers r, g and b (0 ≤ r, g, b ≤ 2·109) — the number of red, green and blue baloons respectively. The numbers are separated by exactly one space.

Print a single integer t — the maximum number of tables that can be decorated in the required manner.

NoteIn the first sample you can decorate the tables with the following balloon sets: "rgg", "gbb", "brr", "rrg", where "r", "g" and "b" represent the red, green and blue balls, respectively.

const readline = require('readline');

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

rl.on('line', input => {
  console.log(min(input.split(' ')));
  process.exit();
});

const min = input => {
  const r = parseInt(input[0]);
  const g = parseInt(input[1]);
  const b = parseInt(input[2]);

  return Math.floor(Math.min((r+g+b)/3, (r+b+g)-Math.max(r,g,b)));
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
inp = inp.sort(function(a,b){return a > b;})
print(Math.min((Math.floor((inp[0]+inp[1]+inp[2])/3)), inp[0]+inp[1]));

var a = readline().split(" ");
for(var i=0; i<a.length; i++) { a[i] =(parseInt(a[i], 10));}

function compareNumbers(a, b)
{
    return a-b;
}
a.sort(compareNumbers);
if(a[2]>(a[0]+a[1])*2)a[2]=2*(a[0]+a[1]);
print(Math.floor((a[2]+a[1]+a[0])/3));

var main = function(r, b, g) {
    print(Math.min((r+g), (b+g), (r+b), Math.floor((r+b+g)/3)));
}

main.apply(0, readline().split(' ').map(Number));

var nums = readline().split(' ');
var a = new Array();
for(var i=0;i<3;i++)
{
    a[i] = parseInt(nums[i]);
}

a.sort(sortNum);
var b = false;
if(a[0]>2*(a[1]+a[2]))
{
    print(a[1]+a[2]);
}
else
{
    var x = a[0]+a[1]+a[2];
	print((x-x%3)/3);
}

function sortNum(a, b)
{
    return b - a;
}

const readline = require('readline');

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

rl.on('line', input => {
  console.log(min(input.split(' ')));
  process.exit();
});

const min = input => {
  return parseInt(input.reduce((ant, act) => parseInt(ant) + parseInt(act)) / input.length);
}

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var r = inp[0];
var g = inp[1];
var b = inp[2];

print(Math.floor((r+g+b) % 3));

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var r = inp[0];
var g = inp[1];
var b = inp[2];

print(Math.max(Math.min(r + g, b),Math.min(r +b, g),Math.min(b +g ,r)));

var inp = readline().split(" ").map(function(x){return parseInt(x);});
var r = inp[0];
var g = inp[1];
var b = inp[2];

print((r+g+b) % 3);

var inp = readline().split(" ").map(function(x){return parseInt(x);});
inp = inp.sort(function(a,b){return a > b;})

print(Math.max((Math.floor((inp[0]+inp[1]+inp[2])/3)), inp[0]+inp[1]));

var inp = readline().split(" ").map(function(x){return parseInt(x);});
inp = inp.sort(function(a,b){return a > b;})
var res = inp[0];
if (inp[1] - inp[0] != 0){
	res+=Math.min(inp[1]-inp[0], Math.floor((inp[2] - inp[0])/2));
}

print(res);

var main = function(r, b, g) {
    print(Math.min((r+g), (b+g), (r+g), Math.floor((r+b+g)/3)));
}

main.apply(0, readline().split(' ').map(Number));


Alena has successfully passed the entrance exams to the university and is now looking forward to start studying.One two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic hours (an academic hour is equal to 45 minutes).The University works in such a way that every day it holds exactly n lessons. Depending on the schedule of a particular group of students, on a given day, some pairs may actually contain classes, but some may be empty (such pairs are called breaks).The official website of the university has already published the schedule for tomorrow for Alena's group. Thus, for each of the n pairs she knows if there will be a class at that time or not.Alena's House is far from the university, so if there are breaks, she doesn't always go home. Alena has time to go home only if the break consists of at least two free pairs in a row, otherwise she waits for the next pair at the university.Of course, Alena does not want to be sleepy during pairs, so she will sleep as long as possible, and will only come to the first pair that is presented in her schedule. Similarly, if there are no more pairs, then Alena immediately goes home.Alena appreciates the time spent at home, so she always goes home when it is possible, and returns to the university only at the beginning of the next pair. Help Alena determine for how many pairs she will stay at the university. Note that during some pairs Alena may be at the university waiting for the upcoming pair.

The first line of the input contains a positive integer n (1 ≤ n ≤ 100) — the number of lessons at the university.  The second line contains n numbers ai (0 ≤ ai ≤ 1). Number ai equals 0, if Alena doesn't have the i-th pairs, otherwise it is equal to 1. Numbers a1, a2, ..., an are separated by spaces.

Print a single number — the number of pairs during which Alena stays at the university.

NoteIn the first sample Alena stays at the university from the second to the fifth pair, inclusive, during the third pair she will be it the university waiting for the next pair. In the last sample Alena doesn't have a single pair, so she spends all the time at home.

n = +readline();
a = readline().split(" ").map(Number);

answer = 0;
last_i = -100;
for (var i = 0; i < n; i++) {
	if (a[i] == 1) {
		if (last_i >=0 && last_i+2 == i) {
			// a[i-1] == 0
			answer += 1;
		}
		answer += 1;
		last_i = i;
	}
}
write(answer);

function checkPairs (pairs) {
  pairs = pairs.split(" ").join("");
  pairs = pairs.replace(/0+$/g, ""); // strip trailing zeros
  pairs = pairs.replace(/^0+/g, ""); // strip first zeros
  pairs = pairs.replace(/0{2,}/g, ""); //strip 00

  return pairs.length;
}

var smth = readline(),
    input = readline();

var output = checkPairs.call(null, input);

write(output);

function checkPairs (pairs) {
  pairs = pairs.split(" ").join("");
  pairs = pairs.replace(/0+$/g, ""); // strip trailing zeros
  pairs = pairs.replace(/^0+/g, ""); // strip first zeros
  pairs = pairs.replace(/00/g, ""); //strip 00

  return pairs.length;
}

var input = readline();

var output = checkPairs.call(null, input);

write(output);

function checkPairs (pairs) {
  pairs = pairs.split(" ").join("");
  pairs = pairs.replace(/0+$/g, ""); // strip trailing zeros
  pairs = pairs.replace(/^0+/g, ""); // strip first zeros
  pairs = pairs.replace(/00/g, ""); //strip 00

  return pairs.length;
}

var smth = readline(),
    input = readline();

var output = checkPairs.call(null, input);

write(output);


At a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with integer coordinates, and joined them with segments of straight lines, then he showed the triangle to Peter. Peter said that Bob's triangle is not right-angled, but is almost right-angled: the triangle itself is not right-angled, but it is possible to move one of the points exactly by distance 1 so, that all the coordinates remain integer, and the triangle become right-angled. Bob asks you to help him and find out if Peter tricks him. By the given coordinates of the triangle you should find out if it is right-angled, almost right-angled, or neither of these.

The first input line contains 6 space-separated integers x1, y1, x2, y2, x3, y3 — coordinates of the triangle's vertices. All the coordinates are integer and don't exceed 100 in absolute value. It's guaranteed that the triangle is nondegenerate, i.e. its total area is not zero.

If the given triangle is right-angled, output RIGHT, if it is almost right-angled, output ALMOST, and if it is neither of these, output NEITHER.

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var input = tokenizeIntegers(readline());

	function isRightTriangle(input) {
		var squares = [];
		for (var i = 0; i < 3; i += 1) {
			squares.push(Math.pow(input[(2*i+2)%6]-input[2*i], 2) +
					   Math.pow(input[(2*i+3)%6]-input[2*i+1], 2));
		}
		squares.sort(function(a, b) {
			return a-b;
		});
		if (squares[0] == 0) {
			return false;
		}
		return (squares[2] == squares[1] + squares[0]);
	}

	if (isRightTriangle(input)) {
		print("RIGHT");
		return;
	}

	var dx = [0, 1, 0, -1], dy = [-1, 0, 1, 0];
	for (var i = 0; i < 3; i += 1) {
		for (var j = 0; j < 4; j += 1) {
			input[2*i] += dx[j];
			input[2*i+1] += dy[j];
			if (isRightTriangle(input)) {
				print("ALMOST");
				return;
			}
			input[2*i] -= dx[j];
			input[2*i+1] -= dy[j];
		}
	}

	print("NEITHER");
}

main();

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var input = tokenizeIntegers(readline());

	function isRightTriangle(input) {
		var squares = [];
		for (var i = 0; i < 3; i += 1) {
			squares.push(Math.pow(input[(2*i+2)%6]-input[2*i], 2) +
					   Math.pow(input[(2*i+3)%6]-input[2*i+1], 2));
		}
		squares.sort(function(a, b) {
			return a-b;
		});
		return (squares[2] == squares[1] + squares[0]);
	}

	if (isRightTriangle(input)) {
		print("RIGHT");
		return;
	}

	var dx = [0, 1, 0, -1], dy = [-1, 0, 1, 0];
	for (var i = 0; i < 3; i += 1) {
		input[2*i] += dx[i];
		input[2*i+1] += dy[i];
		if (isRightTriangle(input)) {
			print("ALMOST");
			return;
		}
		input[2*i] -= dx[i];
		input[2*i+1] -= dy[i];
	}

	print("NEITHER");
}

main();


Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!Sonya is an owl and she sleeps during the day and stay awake from minute l1 to minute r1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.Filya works a lot and he plans to visit Sonya from minute l2 to minute r2 inclusive.Calculate the number of minutes they will be able to spend together.

The only line of the input contains integers l1, r1, l2, r2 and k (1 ≤ l1, r1, l2, r2, k ≤ 1018, l1 ≤ r1, l2 ≤ r2), providing the segments of time for Sonya and Filya and the moment of time when Sonya prinks.

Print one integer — the number of minutes Sonya and Filya will be able to spend together.

NoteIn the first sample, they will be together during minutes 9 and 10.In the second sample, they will be together from minute 50 to minute 74 and from minute 76 to minute 100.

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    else carry = 0
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)||'0'
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]

if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd('1', strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    else carry = 0
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)||'0'
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]
print(normz,start,end)
if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd('1', strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]
print(start,end)
if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd('1', strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)||'0'
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]

if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd('1', strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]

if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd('1', strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/

function stradd(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) + (parseInt(b[j])||0) + carry
    carry = tmp >= 10 ? 1 : 0
    res = (tmp%10).toString() + res
  }
  return carry ? '1'+res : res
}

function strsub(a, b) {
  var res = "",
      carry = 0,
      tmp = 0
  for (var i = a.length-1, j = b.length-1 ; i >= 0 || j >= 0 ; i--, j--) {
    tmp = (parseInt(a[i])||0) - (parseInt(b[j])||0) - carry
    if (tmp < 0) tmp += 10, carry = 1
    res = tmp.toString() + res
  }
  return res
}

function strz(a, n) {
  if (a.length >= n) return a
  var res = a
  for (var i = a.length ; i < n ; i++) {
    res = '0' + res
  }
  return res
}

function trimz(a) {
  var i = 0
  while (a[i] === '0') i++
  return a.substr(i)
}

var given = readline().split(' '),
    length = given.reduce((p,v,i,a)=>{return Math.max(p,v.length)}, 0),
    normz = given.map((v,i,a)=>{return strz(v, length)}),
    start = normz[0] > normz[2] ? normz[0] : normz[2],
    end = normz[1] > normz[3] ? normz[3] : normz [1]

if (end < start) print('0')
else if (normz[4] >= start && normz[4] <= end) print(trimz(strsub(end,start)))
else print(trimz(stradd(1, strsub(end, start))))

/*
function readIntTabLine(n) {
  var l = readline().split(' ')
  for (var i = 0 ; i < n ; i++) {
    l[i] = parseInt(l[i])
  }
  return l
}

var given = readIntTabLine(5)

var start = Math.max(given[0],given[2]),
    end = Math.min(given[1],given[3])

if (end < start) print(0)
else if (given[4] >= start && given[4] <= end) print(end - start)
else print(end - start + 1)
*/


Valera has got n domino pieces in a row. Each piece consists of two halves — the upper one and the lower one. Each of the halves contains a number from 1 to 6. Valera loves even integers very much, so he wants the sum of the numbers on the upper halves and the sum of the numbers on the lower halves to be even.To do that, Valera can rotate the dominoes by 180 degrees. After the rotation the upper and the lower halves swap places. This action takes one second. Help Valera find out the minimum time he must spend rotating dominoes to make his wish come true.

The first line contains integer n (1 ≤ n ≤ 100), denoting the number of dominoes Valera has. Next n lines contain two space-separated integers xi, yi (1 ≤ xi, yi ≤ 6). Number xi is initially written on the upper half of the i-th domino, yi is initially written on the lower half.

Print a single number — the minimum required number of seconds. If Valera can't do the task in any time, print  - 1.

NoteIn the first test case the sum of the numbers on the upper halves equals 10 and the sum of the numbers on the lower halves equals 6. Both numbers are even, so Valera doesn't required to do anything.In the second sample Valera has only one piece of domino. It is written 3 on the one of its halves, therefore one of the sums will always be odd.In the third case Valera can rotate the first piece, and after that the sum on the upper halves will be equal to 10, and the sum on the lower halves will be equal to 8.

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStd => inputString += inputStd);
process.stdin.on('end', () => {
    inputString = inputString.trim().split('\n').map(str => str.trim());
    solve();
});
let readLine = () => inputString[currentLine++];

function solve(){
    const n = +(readLine());
    let a = [], b = [];
    let suma = 0, sumb = 0;
    for(let i = 0; i < n; i++){
        let line = readLine();
        a.push(+(line[0]));
        b.push(+(line[2]));
        suma += a[i];
        sumb += b[i];
    }
    let check = (s,t) => s%2 == 0 && t%2 == 0;
    let bool = false;
    if(check(suma, sumb)){
        console.log(0);
        return;
    }
    for(let i = 0; i < n; i++){
        let at = suma, bt = sumb;
        at -= a[i];
        bt -= b[i];
        at += b[i];
        bt += a[i];
        if(check(at, bt)){
            console.log(1);
            return;
        }
    }
    console.log(-1);
}

var n=+readline();
var f=false;
var low=0;
var high=0;
while(n--){
	(function(x, y){
		if(x%2!==y%2) f=true;
		low+=x;
		high+=y;
	}).apply(0, readline().split(' ').map(Number));
}
if(low%2===high%2){
	if(low%2===0){
		print(0);
	}else if(f){
		print(1);
	}else{
		print(-1);
	}
}else{
	print(-1);
}

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return Number(readline()); }

var n = rdn();
var l = 0, r = 0, dif = false;
for(var i = 0; i < n; i++){
    var inp = rda();
    l += inp[0];
    r += inp[1];
    if( (inp[0]%2 == 1 && inp[1]%2 == 0) || (inp[1]%2 == 1 && inp[0]%2 == 0) ){
        dif = true;
    }
}

var ans;
if(l%2 == 0 && r%2 == 0){
    ans = 0;
}else if(l%2 == 1 && r%2 == 1 && dif){
    ans = 1;
}else{
    ans = -1;
}

write(ans);

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var numDominoes = parseInt(readline(), 10);
	var sums = [0, 0],
		parity = [0, 1, 0, 1, 0, 1, 0],
		foundImbalancedDomino = false;

	for (var dominoIndex = 0; dominoIndex < numDominoes; ++dominoIndex) {
		var domino = tokenizeIntegers(readline());
		sums[0] += domino[0];
		sums[1] += domino[1];
		if (!foundImbalancedDomino && parity[domino[0]] != parity[domino[1]]) {
			foundImbalancedDomino = true;
		}
	}

	var left = sums[0] % 2, right = sums[1] % 2;

	if (left == 0 && right == 0) {
		print(0);
	}
	else if (left == 1 && right == 1) {
		print(foundImbalancedDomino ? 1 : -1);
	}
	else {
		print(-1);
	}
}

main();

(function (){
    var i, j, n = parseInt(readline());
    var a = [], sumup = 0, sumlow = 0;
    for(i = 0 ; i < n ; ++i){
        a[i] = readline().split(' ');
        a[i][0] = parseInt(a[i][0]);
        a[i][1] = parseInt(a[i][1]);
        sumup += a[i][0];
        sumlow += a[i][1];
    }
    var time = 0;
    if ( sumup % 2 + sumlow % 2 == 2 ){
        for(i = 0 ; i < n ; ++i){
            if ( a[i][0] % 2 + a[i][1] % 2 == 1 ){
                time = 1;
                break;
            }
        }
        if ( time == 0 ) --time;
    }else if ( sumup % 2 + sumlow % 2 == 1 ){
        time = -1;
    }
    print(time);

})();

;(function () {
	var n = +readline();
	var d = [];

	var s = 0;
	for (var i = 0; i < n; i++) d.push( readline().split(' ').map(function (e) { e = +e; s += e; return e; }) );

	if (s % 2) {
		print(-1);
		return;
	}

	s = d.reduce(function (p, e) { return p + e[0]; }, 0);
	print( s%2 ? 1 : ( n != 1 ? 0 : -1 ) );

}).call(this);

;(function () {
	var n = +readline();
	var d = [];

	var s = 0;
	for (var i = 0; i < n; i++) d.push( readline().split(' ').map(function (e) { e = +e; s += e; return e; }) );

	if (s % 2) {
		print(-1);
		return;
	}

	s = d.reduce(function (p, e) { return p + e[0]; }, 0);
	print( s%2 ? 1 : 0 );

}).call(this);

;(function () {
	var n = +readline();
	var d = [];

	var s = 0;
	for (var i = 0; i < n; i++) d.push( readline().split(' ').map(function (e) { e = +e; s += e; return e; }) );

	if (s % 2 || n == 1) {
		print(-1);
		return;
	}

	s = d.reduce(function (p, e) { return p + e[0]; }, 0);
	print( s%2 ? 1 : 0 );

}).call(this);

;(function () {
	var n = +readline();
	var d = [];

	for (var i = 0; i < n; i++) d.push( readline().split(' ').map( Number ) );

	var s = 0;
	s = d.reduce( function (p, e) { return p + e[0] + e[1]; }, 0 );

	if (s % 2) {
		print(-1);
		return;
	}

	var t = 0;
	t = d.reduce(function (p, e) { return p + ( e[0] % 2 && e[1] % 2 ); }, 0);

	if (!(t % 2) && t != 0) {
		print(-1);
		return;
	}

	print( d.reduce( function (p, e) { return p + e[0]; }, 0 ) % 2 ? 1 : 0 );

}).call(this);

(function (){
    var i, j, n = parseInt(readline());
    var a = [], sumup = 0, sumlow = 0;
    for(i = 0 ; i < n ; ++i){
        a[i] = readline().split(' ');
        sumup += a[i][0];
        sumlow += a[i][1];
    }
    var time = 0;
    if ( sumup % 2 + sumlow % 2 == 2 ){
        for(i = 0 ; i < n ; ++i){
            if ( a[i][0] % 2 + a[i][1] % 2 == 1 ){
                time = 1;
                break;
            }
        }
    }else if ( sumup % 2 + sumlow % 2 == 1 ){
        time = -1;
    }
    print(time);

})();

(function (){
    var i, j, n = parseInt(readline());
    var a = [], sumup = 0, sumlow = 0;
    for(i = 0 ; i < n ; ++i){
        a[i] = readline().split(' ');
        sumup += a[i][0];
        sumlow += a[i][1];
    }
    var time = 0;
    if ( sumup % 2 + sumlow % 2 == 2 ){
        for(i = 0 ; i < n ; ++i){
            if ( a[i][0] % 2 + a[i] % 2 == 1 ){
                time = 1;
                break;
            }
        }
    }else if ( sumup % 2 + sumlow % 2 == 1 ){
        time = -1;
    }
    print(time);

})();

(function (){
    var i, j, n = parseInt(readline());
    var a = [], sumup = 0, sumlow = 0;
    for(i = 0 ; i < n ; ++i){
        a[i] = readline().split(' ');
        a[i][0] = parseInt(a[i][0]);
        a[i][1] = parseInt(a[i][1]);
        sumup += a[i][0];
        sumlow += a[i][1];
    }
    var time = 0;
    if ( sumup % 2 + sumlow % 2 == 2 ){
        for(i = 0 ; i < n ; ++i){
            if ( a[i][0] % 2 + a[i][1] % 2 == 1 ){
                time = 1;
                break;
            }
        }
    }else if ( sumup % 2 + sumlow % 2 == 1 ){
        time = -1;
    }
    print(time);

})();


Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a "war"-like card game. The rules are following. On each turn a fight happens. Each of them picks card from the top of his stack and puts on the table. The one whose card value is bigger wins this fight and takes both cards from the table to the bottom of his stack. More precisely, he first takes his opponent's card and puts to the bottom of his stack, and then he puts his card to the bottom of his stack. If after some turn one of the player's stack becomes empty, he loses and the other one wins. You have to calculate how many fights will happen and who will win the game, or state that game won't end.

First line contains a single integer n (2 ≤ n ≤ 10), the number of cards. Second line contains integer k1 (1 ≤ k1 ≤ n - 1), the number of the first soldier's cards. Then follow k1 integers that are the values on the first soldier's cards, from top to bottom of his stack. Third line contains integer k2 (k1 + k2 = n), the number of the second soldier's cards. Then follow k2 integers that are the values on the second soldier's cards, from top to bottom of his stack. All card values are different.

If somebody wins in this game, print 2 integers where the first one stands for the number of fights before end of game and the second one is 1 or 2 showing which player has won. If the game won't end and will continue forever output  - 1.

function Stack(){this.a=[]}function Queue(){this.l=new Stack,this.r=new Stack}function Reader(){this.b=[],this.c=0}function Writer(){this.l=[""],this.c=0}Array.prototype.back=function(){return this[this.length-1]},Math.gcd=function(t,i){return i?gcd(i,t%i):t},Math.lcm=function(t,i){return t/gcd(t,i)*i},Math.sign=function(t){return(t>0)-(0>t)},Math.cmp=function(t,i){return(+t>+i)-(+i>+t)},Math.icmp=function(t,i){return(+i>+t)-(+t>+i)},Stack.prototype.empty=function(){return 0==this.a.length},Stack.prototype.push=function(t){this.a.push(t)},Stack.prototype.pop=function(){return this.empty()?void 0:this.a.pop()},Stack.prototype.top=function(){return this.empty()?void 0:this.a[this.a.length-1]},Stack.prototype.clear=function(){this.a=[]},Stack.prototype.size=function(){return this.a.length},Queue.prototype.push=function(t){this.l.push(t)},Queue.prototype.empty=function(){return this.r.empty()&&this.l.empty()},Queue.prototype.pop=function(){if(this.r.empty())for(;!this.l.empty();)this.r.push(this.l.pop());return this.r.empty()?void 0:this.r.pop()},Queue.prototype.front=function(){if(this.r.empty())for(;!this.l.empty();)this.r.push(this.l.pop());return this.r.empty()?void 0:this.r.top()},Queue.prototype.size=function(){return l.size()+r.size()},Queue.prototype.clear=function(){l.clear(),r.clear()},Reader.prototype.next=function(){return this.c==this.b.length&&(this.c=0,this.b=readline().split(" ")),this.b[this.c++]},Writer.prototype.print=function(t){this.l[this.c]+=t},Writer.prototype.println=function(t){this.l[this.c]+=t,this.l.push(""),++this.c},Writer.prototype.flush=function(){print(this.l.join("\n")),this.l=[]};

function main(cin, cout)
{
    var n = +cin.next();
    var k1 = +cin.next();
    var q1 = new Queue();
    var q2 = new Queue();
    var t;
    for(var i = 0; i < k1; ++i)
    {
        t = +cin.next();
        q1.push(t);
    }
    var k2 = +cin.next();
    for(var i = 0; i < k2; ++i)
    {
        t = +cin.next();
        q2.push(t);
    }
    var iter = 0;
    var c1, c2;

    while(!q1.empty() && !q2.empty())
    {
        c1 = q1.front();
        q1.pop();
        c2 = q2.front();
        q2.pop();
        if (c1 > c2)
        {
            q1.push(c2);
            q1.push(c1);
        } else
        {
            q2.push(c1);
            q2.push(c2);
        }
        iter++;
        if (iter == 10000000)
            break;
    }
    if (iter == 10000000)
        cout.print("-1");
    else
        cout.print(iter + " " + (q1.empty() ? 2 : 1));
}

var cin = new Reader();
var cout = new Writer();

main(cin, cout);

cout.flush();

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

    this.rec = function( arr , brr , firstFlag , cn ) {
    	var res , r1 , newArr , newBrr , fl , sz , i , sz1 , sz2 ;
    	if( cn > 1000 ) {
    		return -1 ;
    	}
    	if( firstFlag == false && arr.length == this.baseCaseArr.length && brr.length == this.baseCaseBrr.length ) {
    		fl = 1 ;
    		sz = arr.length ;
    		for( i = 0 ; i < sz ; i++ ) {
    			if( arr[ i ] != this.baseCaseArr[ i ] ) {
    				fl = 0 ;
    				break ;
    			}
    		}
    		sz = brr.length ;
    		for( i = 0 ; i < sz ; i++ ) {
    			if( brr[ i ] != this.baseCaseBrr[ i ] ) {
    				fl = 0 ;
    				break ;
    			}
    		}
    		if( fl == 1 ) {
    			return -1 ;
    		}
    	}
    	if( arr.length == 0 ) {
    		this.winner = 2 ;
    		return 0 ;
    	}
    	if( brr.length == 0 ) {
    		this.winner = 1 ;
    		return 0 ;
    	}
    	newArr = [] ;
    	newBrr = [] ;
    	sz1 = arr.length ;
    	sz2 = brr.length ;
    	for( i = 1 ; i < sz1 ; i++ ) {
			newArr.push( arr[ i ] ) ;
		}
		for( i = 1 ; i < sz2 ; i++ ) {
			newBrr.push( brr[ i ] ) ;
		}
    	if( arr[ 0 ] > brr[ 0 ] ) {
    		newArr.push( brr[ 0 ] ) ;
    		newArr.push( arr[ 0 ] ) ;
    	}
    	else {
    		newBrr.push( arr[ 0 ] ) ;
    		newBrr.push( brr[ 0 ] ) ;
    	}
    	r1 = this.rec( newArr , newBrr , false , cn + 1 ) ;
    	if( r1 == -1 ) {
    		res = -1 ;
    	}
    	else {
    		res = r1 + 1 ;
    	}
    	return res ;
    } ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 0 ;
        this.baseCaseArr = [] ;
        for( i = 0 ; i < this.k1 ; i++ ) {
        	this.baseCaseArr.push( this.arr[ i ] ) ;
        }
        this.baseCaseBrr = [] ;
        for( i = 0 ; i < this.k2 ; i++ ) {
        	this.baseCaseBrr.push( this.brr[ i ] ) ;
        }
        this.winner = -1 ;
        res = this.rec( this.arr , this.brr , true , 0 ) ;
        if( res == -1 ) {
        	print( res );
        }
        else {
        	print( res + ' ' + this.winner );
        }
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            this.k1 = irObj.nextInt();
            this.arr = [] ;
            for( i = 0 ; i < this.k1 ; i++ ) {
                this.arr.push( irObj.nextInt() ) ;
            }
            this.brr = [] ;
            this.k2 = irObj.nextInt();
            for( i = 0 ; i < this.k2 ; i++ ) {
                this.brr.push( irObj.nextInt() ) ;
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.In the given sequence moving up is described by character U and moving right is described by character R. Mikhail can replace any pair of consecutive moves RU or UR with a diagonal move (described as character D). After that, he can go on and do some other replacements, until there is no pair of consecutive moves RU or UR left.Your problem is to print the minimum possible length of the sequence of moves after the replacements.

The first line of the input contains one integer n (1 ≤ n ≤ 100) — the length of the sequence. The second line contains the sequence consisting of n characters U and R.

Print the minimum possible length of the sequence of moves after all replacements are done.

NoteIn the first test the shortened sequence of moves may be DUD (its length is 3).In the second test the shortened sequence of moves can be UUDRRRDUDDUUU (its length is 13).

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var N = nextInt();
	var s = next();
	var output = 0;
	for(var i = 0; i < N; i++){
		if(s[i] == "U" && s[i + 1] == "R" || s[i] == "R" && s[i + 1] == "U"){
			output++;
			i++;
		}else{
			output++;
		}
	}
	myout(output);
}

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let ans = 0;

  for (let i = 0; i < str.length; i++) {
    if (str[i] === 'R' && str[i + 1] === 'U' || str[i] === 'U' && str[i + 1] === 'R') {
      ans++;
      i++;
    }
    else {
      ans++;
    }
  }

  console.log(ans);

  c++;
});

let data = '';
process.stdin.on('data', c => data += c);
const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0], 10);
	let a = line[1].replace(/RU|UR/g,"D").trim();
	console.log(a.length);

};

process.stdin.on('end', solution);

function main() {
  var n = readline();
  var line = readline();

  line = line.replace(/(UR|RU)/g, 'D');

  print(line.length);
}

main();

readline();
var walk = readline();
var pointer = 0;
var counter = 0;
while (pointer < (walk.length - 1)) {
  if (walk[pointer] != walk[pointer + 1]) {
    counter++;
    pointer += 2;
  } else {
    pointer++;
  }
}
print(walk.length - counter);

n = readline();
str = readline().split('');

var count = 0;

for (var i = 0; i < n; i++) {
	if ((str[i] == 'R' && str[i + 1] == 'U') || (str[i] == 'U' && str[i + 1] == 'R')) {
		count++;
		i++;
	} else {
		count++;
	};
};

print(count);

let data = '';
process.stdin.on('data', c => data += c);
const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0], 10);
	let a = line[1].replace("RU","D").replace("UR","D");
	console.log(a.length);

};

process.stdin.on('end', solution);

let data = '';
process.stdin.on('data', c => data += c);
const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0], 10);
	let a = line[1].replace(/RU|UR/g,"D");
	console.log(a.length);

};

process.stdin.on('end', solution);

function main() {
  var n = readline();
  var line = readline();

  line = line.replace(/UR/g, 'D');
  line = line.replace(/RU/g, 'D');

  print(line.length);
}

main();


You are given a non-negative integer n, its decimal representation consists of at most 100 digits and doesn't contain leading zeroes.Your task is to determine if it is possible in this case to remove some of the digits (possibly not remove any digit at all) so that the result contains at least one digit, forms a non-negative integer, doesn't have leading zeroes and is divisible by 8. After the removing, it is forbidden to rearrange the digits.If a solution exists, you should print it.

The single line of the input contains a non-negative integer n. The representation of number n doesn't contain any leading zeroes and its length doesn't exceed 100 digits.

Print "NO" (without quotes), if there is no such way to remove some digits from number n.  Otherwise, print "YES" in the first line and the resulting number after removing digits from number n in the second line. The printed number must be divisible by 8. If there are multiple possible answers, you may print any of them.

function rda(){ return readline().split(" ").map(Number); }
function rdn(){ return +readline(); }

var n = readline().split("").map(Number);

var ans = "NO";

for(var i = 0; i < n.length; i++){
    if(ans != "NO") break;
    var x = n[i];
    if(x % 8 == 0){
        ans = "YES\n" + x;
        break;
    }
}

for(var i = 0; i < n.length; i++){
    if(ans != "NO") break;
    for(var j = i+1; j < n.length; j++){
        if(ans != "NO") break;
        var x = n[i]*10 + n[j];
        if(x % 8 == 0){
            ans = "YES\n" + x;
            break;
        }
    }
}

for(var i = 0; i < n.length; i++){
    if(ans != "NO") break;
    for(var j = i+1; j < n.length; j++){
        if(ans != "NO") break;
        for(var k = j+1; k < n.length; k++){
            if(ans != "NO") break;
            var x = n[i]*100 + n[j]*10 + n[k];
            if(x % 8 == 0){
                ans = "YES\n" + x;
                break;
            }
        }
    }
}

write(ans);

function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.dp = function( i , rem , fl ) {
		var ret , res , r1 , re , a ;
		if( i >= this.n ) {
			if( rem == 0 && fl == 1 ) {
				return 1 ;
			}
			return 0 ;
		}
		re = this.done[ i ][ rem ][ fl ] ;
		ret = this.memo[ i ][ rem ][ fl ] ;
		if( re == this.cc ) {
			return ret ;
		}
		this.done[ i ][ rem ][ fl ] = this.cc ;
		res = 0 ;
		r1 = this.dp( i + 1 , rem , fl ) ;
		res |= r1 ;
		a = this.s.charCodeAt( i ) - '0'.charCodeAt( 0 ) ;
		r1 = this.dp( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		res |= r1 ;
		this.memo[ i ][ rem ][ fl ] = res ;
		return res ;
	} ;

	this.dpPrint = function( i , rem , fl ) {
		var r1 , a ;
		if( i >= this.n ) {
			return '' ;
		}
		r1 = this.dp( i + 1 , rem , fl ) ;
		if( r1 == 1 ) {
			return this.dpPrint( i + 1 , rem , fl ) ;
		}
		a = this.s.charCodeAt( i ) - '0'.charCodeAt( 0 ) ;
		r1 = this.dp( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		if( r1 == 1 ) {
			return this.s.charAt( i ) + this.dpPrint( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		}
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , numberString , resNumber ;
        res = 0 ;
        this.n = this.s.length ;
        res = this.dp( 0 , 0 , 0 ) ;
        if( res == 0 ) {
        	print( 'NO' );
        }
        else {
        	print( 'YES' );
        	numberString = this.dpPrint( 0 , 0 , 0 ) ;
        	len = numberString.length ;
        	resNumber = '' ;
        	fl = 0 ;
        	for( i = 0 ; i < len ; i++ ) {
        		if( numberString.charCodeAt( i ) > '0'.charCodeAt( 0 ) ) {
        			fl = 1 ;
        		}
        		if( fl == 1 ) {
        			resNumber += numberString.charAt( i ) ;
        		}
        	}
        	if( resNumber == '' ) {
        		resNumber = '0' ;
        	}
        	print( resNumber );
        }
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adjList = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adjList.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adjList = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adjList.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( new Array() );
                this.done[ i ].push( new Array() );
                for( k = 0 ; k < 2 ; k++ ) {
                	this.memo[ i ][ j ].push( -1 );
                	this.done[ i ][ j ].push( 0 );
                }
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();

const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (n.length === 0) {
    return null;
  }
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  }
  if (n.length >= 3) {
    var arr = n.split('');
    for (var i = 1; i < 4; i++) {
      var sub = arr
        .slice(0, n.length - i)
        .concat(arr.slice(n.length - i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
  }
  if (n.length === 2) {
    if (n[0] === '0' || n[1] === '0') {
      return '0';
    }
    if (n[0] === '8' || n[1] === '8') {
      return '8';
    }
  }
  memo[n] = null;
  return null;
}

//test
const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);

const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (n.length === 0) {
    return null;
  }
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  }
  if (n.length >= 3) {
    var arr = n.split('');
    for (var i = 1; i < 4; i++) {
      var sub = arr
        .slice(0, n.length - i)
        .concat(arr.slice(n.length - i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
  }
  if (n.length === 2) {
    if (n[0] === '8' || n[1] === '8') {
      return '8';
    }
    if (n[0] === '0' || n[1] === '0') {
      return '0';
    }
  }
  memo[n] = null;
  return null;
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);

const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (n.length === 0) {
    return null;
  }
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  }
  if (n.length >= 3) {
    var arr = n.split('');
    for (var i = 1; i < 4; i++) {
      var sub = arr
        .slice(0, n.length - i)
        .concat(arr.slice(n.length - i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
  }
  if (n.length === 2) {
    if (n[0] === '0' || n[1] === '0') {
      return '0';
    }
    if (n[0] === '8' || n[1] === '8') {
      return '8';
    }
  }
  memo[n] = null;
  return null;
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);

var input = readline();
var check = [];
for (var i = 0;i<1000;i++){
    if (i%8 == 0){
      check.push(i.toString());
    }
}
var finded = false;
for (var k = 0 ;k<check.length;k++){
  var current = check[k];
  var result = '';
  var j = 0;
  for(var i = 0;i<input.length;i++){
    if(input[i] == current[j]){
      result+=current[j];
      j++;
      if (j==current.length && !finded){
        finded = true;
        print('YES');
        print(result);
        break;
      }
    }
  }
}
if(!finded){
  var nullsCount = 0;
  for (var i = 0 ;i<input.length;i++){
    if(input[i]==0)
      nullsCount++;
  }
  if(nullsCount>=3){
    print('YES');
    print(input[0]+'000');
  }
  else
    print('NO');
}

const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = n % 8;
  return remainder === 0;
}

function resolve(n) {
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  } else {
    var arr = n.split('');
    for (var i = 0; i < arr.length; i++) {
      var sub = arr
        .slice(0, i)
        .concat(arr.slice(i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
    memo[n] = null;
    return null;
  }
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);

const memo = {};

function resolve(n) {
  if (memo[n] === null) {
    return null;
  }
  if (parseInt(n, 10) % 8 === 0) {
    return n;
  } else {
    var arr = n.split('');
    for (var i = 0; i < arr.length; i++) {
      var sub = arr
        .slice(0, i)
        .concat(arr.slice(i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
    memo[n] = null;
    return null;
  }
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);


Someday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance in horizontal or vertical direction. In other words, from position (x, y) he can go to positions (x + 1, y), (x - 1, y), (x, y + 1) or (x, y - 1). Unfortunately, Drazil doesn't have sense of direction. So he randomly chooses the direction he will go to in each step. He may accidentally return back to his house during his travel. Drazil may even not notice that he has arrived to (a, b) and continue travelling. Luckily, Drazil arrived to the position (a, b) successfully. Drazil said to Varda: "It took me exactly s steps to travel from my house to yours". But Varda is confused about his words, she is not sure that it is possible to get from (0, 0) to (a, b) in exactly s steps. Can you find out if it is possible for Varda?

You are given three integers a, b, and s ( - 109 ≤ a, b ≤ 109, 1 ≤ s ≤ 2·109) in a single line.

If you think Drazil made a mistake and it is impossible to take exactly s steps and get from his home to Varda's home, print "No" (without quotes). Otherwise, print "Yes".

NoteIn fourth sample case one possible route is: .

var input = readline().split(" "), a = +input[0], b = +input[1], s = +input[2];

if( s < (Math.abs(a) + Math.abs(b)) ){
	write("No");
}
else if( s == (Math.abs(a) + Math.abs(b)) ){
	write("Yes");
}
else{
	s -= (Math.abs(a) + Math.abs(b));
	if(s % 2 == 0){
		write("Yes");
	}
	else{
		write("No");
	}
}

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

print((function () {

	var array = readNumbersArray();
	var a = Math.abs(array[0]), b = Math.abs(array[1]), s = array[2];

	if (a + b > s) return 'No';
	if (a + b === s) return 'Yes';
	return ((s - a - b) % 2 === 0) ? 'Yes' : 'No';
})());

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function main() {
        var a=nextInt();
var b=nextInt();
var s=nextInt();
var c=Math.abs(a)+Math.abs(b);
if(s>=c&&(s-c)%2==0){
print("Yes");
}else{
print("No");
}
}

main();

var data = readline().split(' ');
var dist1 = parseInt(data[0]);
var dist2 = parseInt(data[1]);
var dist3 = parseInt(data[2]);
calculate(dist1, dist2, dist3);

function calculate(a, b, s)
{
    var distance = Math.abs(a) + Math.abs(b);
    var extra = s - distance;
    if(extra < 0)
    {
        write('No');
        return;
    }
    if(extra % 2 !== 0)
    {
        write('No');
        return;
    }
    write('Yes');
}

        var app = {
            'main' : function main()    {
                var result = 'NO',
                    targetX, targetY, stepCount,
                    minStepCount;

                targetX = readline().split(/\s/gi).map(Number);
                targetY = Math.abs(targetX[1]);
                stepCount = targetX[2];
                targetX = Math.abs(targetX[0]);

                minStepCount = targetX + targetY;

                if(stepCount >= minStepCount)   {
                    if((stepCount - minStepCount) % 2 == 0) result = 'YES';
                    else    result = 'NO';
                }

                print(result);
            }
        };

app.main();

var input = readline().split(" "), a = +input[0], b = +input[1], s = +input[2];

if(s < a+b){
	write("No");
}
else if(s == a+b){
	write("Yes");
}
else{
	s -= a+b
	if(s % 2 == 0){
		write("Yes");
	}
	else{
		write("No");
	}
}

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

print((function () {

	var array = readNumbersArray();
	var a = array[0], b = array[1], s = array[2];

	if (a + b > s) return 'No';
	if (a + b === s) return 'Yes';
	return ((s - a - b) % 2 === 0) ? 'Yes' : 'No';
})());

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

print((function () {

	var array = readNumbersArray();
	var a = array[0], b = array[1], s = array[2];

	if (a + b > s) return 'No';
	if (a + b === s) return 'Yes';
	return ((s - a - b) % 2 === 0) ? 'No' : 'Yes';
})());

var tok = null;
var index = 0;
function next() {
    while (tok == null || index == tok.length) {
        tok = readline().split(' ');
        index = 0;
    }
    var res = tok[index++];
    return res;
}

function nextInt() {
    return parseInt(next());
}

function sortNumber(a, b) {
    return a - b;
}

function main() {
        var a=nextInt();
var b=nextInt();
var s=nextInt();
var c=a+b;
if(s>=c&&(s-c)%2==0){
print("Yes");
}else{
print("No");
}
}

main();

        var app = {
            'main' : function main()    {
                var result = 'NO',
                    targetX, targetY, stepCount,
                    minStepCount;

                targetX = readline().split(/\s/gi).map(Number);
                targetY = targetX[1];
                stepCount = targetX[2];
                targetX = targetX[0];

                minStepCount = targetX + targetY;

                if(stepCount >= minStepCount)   {
                    if((stepCount - minStepCount) % 2 == 0) result = 'YES';
                    else    result = 'NO';
                }

                print(result);
            }
        };

app.main();