## Two Robots

You have a warehouse with M containers filled with an infinite number of candies. The containers are arranged in a single row, equally spaced to be 1 meter apart. You also have 2 robots that can pick up 1 piece of candy and transport it between any two containers. The robots take instructions in the form of queries consisting of two integers, Ma and Mb, respectively. To execute a query, a robot travels to container Ma, picks up 1 candy, transports it to container Mb, and then stops at Mb unti

## Cut Tree

Given a tree T with n nodes, how many subtrees (T') of T have at most K edges connected to (T - T')? Input Format The first line contains two integers n and K followed by n-1 lines each containing two integers a & b denoting that there's an edge between a & b. Constraints 1 <= K <= n <= 50 Every node is indicated by a distinct number from 1 to n. Output Format A single integer which denotes the number of possible subtrees.

## Tara's Beautiful Permutations

Tara has an array, A, consisting of n integers where each integer occurs at most 2 times in the array. Let's define P to be a permutation of A where Pi is the ith element of permutation P. Tara thinks a permutation is beautiful if there is no index i such that Pi - P(i+1) = 0 where i ∈ [0, n-1). You are given q queries where each query consists of some array A. For each A, help Tara count the number of possible beautiful permutations of the n integers in A and print the count, modulo 10^9

## Wet Shark and Two Subsequences

One day, Wet Shark was given an array X = {x1, x2, ..., xm}. As always, he started playing with its subsequences. When you came to know about this habit, you presented him a task of finding all pairs of subsequences, (A,B), which satisfies all of the following constraints. We will represent a pair of subsequence as A = {xa1,xa2,...,xan} and B = {xb1,xb2,...,xbn} A and B must be of same length, i.e., |A| = |B|. Σ(xai + xbi) = r Σ(xai - xbi) = s Please help Wet Shark determine how many

## Nikita and the Game

Nikita just came up with a new array game. The rules are as follows: Initially, Nikita has an array of integers. In each move, Nikita must partition the array into 2 non-empty contiguous parts such that the sum of the elements in the left partition is equal to the sum of the elements in the right partition. If Nikita can make such a move, she gets 1 point; otherwise, the game ends. After each successful move, Nikita discards either the left partition or the right partition and continues