We present a method for a robot to automatically arrange objects using task and motion planning. To arrange objects automatically using a robot, we need a target layout of objects, which guides the robot where to place those objects. We synthesize such a target layout by considering hierarchical and spatial relationships between parent and child objects, and pairwise relationships. These relationships are pre-extracted from positive examples as a training step. Once we have the target layout, we can use any task and motion planner to reach the target layout from an arbitrary object layout. Given this overall approach, we also propose a priority layer to arrange objects efficiently. The priority layer estimates costs of moving objects and processes an object in a greedy manner to reduce the overall execution time. For estimating such costs, our method estimates the distance traveled by the robot and the number of actions a robot will take to reach the target position. We tested our method in five different scenes with varying numbers of cluttered objects and applied our method to two well-known task planners with target layouts computed by our layout computation method. As a result, our method enables a PR2 robot to arrange cluttered objects by considering positive examples. Additionally, we found that our priority layer reduces the total running time up to two times over prior task planners used with our computed layouts.