problem
stringlengths
29
9.39k
language
int64
1
3
solution
stringlengths
7
465k
There are two sisters Alice and Betty. You have n candies. You want to distribute these n candies between two sisters in such a way that: * Alice will get a (a > 0) candies; * Betty will get b (b > 0) candies; * each sister will get some integer number of candies; * Alice will get a greater amount of candie...
3
for _ in range(int(input())): n=int(input()) if(n<=2): print(0) elif(n%2==0): print(n//2-1) elif(n%2!=0): print(n//2)
One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are sure about the solution....
3
tiller = 0 for i in range(int(input())): if sum([int(i) for i in input().split()]) >= 2: tiller += 1 print(tiller)
Given is a sequence of integers A_1, A_2, ..., A_N. If its elements are pairwise distinct, print `YES`; otherwise, print `NO`. Constraints * 2 ≀ N ≀ 200000 * 1 ≀ A_i ≀ 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N A_1 ... A_N Output If the elements...
3
n = int(input()) a = set(input().split()) if n == len(a): print('YES') else: print('NO')
You are given two integers n and m (m < n). Consider a convex regular polygon of n vertices. Recall that a regular polygon is a polygon that is equiangular (all angles are equal in measure) and equilateral (all sides have the same length). <image> Examples of convex regular polygons Your task is to say if it is poss...
3
for i in range(int(input())): n, m = map(int, input().split()) print('YES' if n % m == 0 else 'NO')
Given are 1-digit positive integers a and b. Consider these two strings: the concatenation of b copies of the digit a, and the concatenation of a copies of the digit b. Which of these is lexicographically smaller? Constraints * 1 \leq a \leq 9 * 1 \leq b \leq 9 * a and b are integers. Input Input is given from Stan...
3
ab = input().split(' ') print(min(ab[0]*int(ab[1]), ab[1]*int(ab[0])))
Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. Empirically Polycarp learned that the dog needs at least k walks for any two consecutive days in order to feel good. For example, if k = 5 and yesterday Polycarp went for a...
1
n, k = map(int, raw_input().split()) a = list(map(int, raw_input().split())) s = 0 for i in range(1, len(a)): d = max(0, k - a[i-1] - a[i]) s += d a[i] += d print s for x in a: print x,
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox. In one minute each friend independently from other friends can change the position x by 1 to the...
3
t = int(input()) for _ in range(t): a,b,c= map (int , input().split()) i = abs(a-b) + abs(b-c) + abs (a-c) if i <=4 : print(0) else : print(i-4)
There are n boxers, the weight of the i-th boxer is a_i. Each of them can change the weight by no more than 1 before the competition (the weight cannot become equal to zero, that is, it must remain positive). Weight is always an integer number. It is necessary to choose the largest boxing team in terms of the number o...
3
import math import sys from collections import defaultdict #input = sys.stdin.readline def main(): n = int(input()) a = list(map(int, input().split())) a.sort() next_min = 1 res = 0 for i in range(n): if a[i] == next_min: res += 1 next_min += 1 elif a[i] ...
Boboniu gives you * r red balls, * g green balls, * b blue balls, * w white balls. He allows you to do the following operation as many times as you want: * Pick a red ball, a green ball, and a blue ball and then change their color to white. You should answer if it's possible to arrange all the b...
3
def check(r,g,b,w): return False if r%2 + g%2 + b%2 + w%2 > 1 else True #check whether there are less than or equal to one odd number in r, b, g, w, then you can order them to be a palindrome. t=int(input()) for i in range(t): r,g,b,w=map(int,input().split()) if check(r,g,b,w): print('Yes') elif...
There are n athletes in front of you. Athletes are numbered from 1 to n from left to right. You know the strength of each athlete β€” the athlete number i has the strength s_i. You want to split all athletes into two teams. Each team must have at least one athlete, and each athlete must be exactly in one team. You want...
3
t = int(input()) for _ in range(t): n = int(input()) strength = list(map(int,input().split())) strength = sorted(strength) m = 1001 for i in range(1,n): diff = strength[i] - strength[i-1] if diff == 0: m = 0 break m = min(diff,m) print(m)
Kolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle. More formally, there are 3n gnomes sitting in a circle. Each gnome can have from 1 to 3 coins. Let's number the places in the order they occur in the ci...
3
n=int(input()) mod=10**9+7 print((pow(3,3*n,mod)-pow(7,n,mod))%mod)
You are playing a variation of game 2048. Initially you have a multiset s of n integers. Every integer in this multiset is a power of two. You may perform any number (possibly, zero) operations with this multiset. During each operation you choose two equal integers from s, remove them from s and insert the number eq...
3
# -*- coding: utf-8 -*- """Untitled64.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1zA8FWwgFqsNBhUVzwcHCFdtRPCg4FF0G """ for _ in range(int(input())): n=int(input()) l=[int(x) for x in input().split()] l.sort(reverse=True) sum=0 flag...
You are given a bracket sequence s of length n, where n is even (divisible by two). The string s consists of n/2 opening brackets '(' and n/2 closing brackets ')'. In one move, you can choose exactly one bracket and move it to the beginning of the string or to the end of the string (i.e. you choose some index i, remov...
3
for _ in range(int(input())): s=[] n=int(input()) l=input() for i in l: if not s: s.append(i) elif s[-1]=='(' and i==")": s.pop() else: s.append(i) print(len(s)//2)
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
3
H,W,K = map(int,input().split()) s = [list(input()) for i in range(H)] ans = 0 for i in range(1<<H): for j in range(1<<W): cnt = 0 for h in range(H): for w in range(W): if (i>>h)&1 == 1 and (j>>w)&1==1: if s[h][w]=='#': cnt += 1 if cnt==K: ans += 1 print(ans)
Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a player takes a non-empty mug of water and pours all water from it into the cup. If the cup overfills, then we assume that...
3
n, s = map(int, input().split()) arr = list(map(int, input().split())) print("NO" if sum(arr) - max(arr) > s else "YES")
To stay woke and attentive during classes, Karen needs some coffee! <image> Karen, a coffee aficionado, wants to know the optimal temperature for brewing the perfect cup of coffee. Indeed, she has spent some time reading several recipe books, including the universally acclaimed "The Art of the Covfefe". She knows n ...
3
import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def tinput(): return input().split() def rinput(): return map(int, tinput()) def rlinput(): return list(rinput()) n,k,q = rinput() nums = [0] * 200002 for _ in range(n): l,r = rinput(...
Polycarp wants to buy exactly n shovels. The shop sells packages with shovels. The store has k types of packages: the package of the i-th type consists of exactly i shovels (1 ≀ i ≀ k). The store has an infinite number of packages of each type. Polycarp wants to choose one type of packages and then buy several (one or...
3
# Template 1.0 import sys, re, math from collections import deque, defaultdict, Counter, OrderedDict from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from heapq import heappush, heappop, heapify, nlargest, nsmallest import re def STR(): return list(input()) def INT(): return int(input()) def MA...
There are quite a lot of ways to have fun with inflatable balloons. For example, you can fill them with water and see what happens. Grigory and Andrew have the same opinion. So, once upon a time, they went to the shop and bought n packets with inflatable balloons, where i-th of them has exactly a_i balloons inside. T...
1
n = int(raw_input()) packages = list(map(int, raw_input().split())) if n == 1: print -1 elif n == 2 and len(set(packages)) == 1: print -1 elif packages[0] * 2 == sum(packages): print 2 print 1, 2 else: print 1 print 1
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two ac...
3
N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = 0 for i in range(N): if b[i] - a[i] > 0: c += (b[i] - a[i])//2 elif b[i] - a[i] < 0: c += b[i] - a[i] if c >= 0: print("Yes") else: print("No")
An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x > 0) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order ...
3
x =int(input()) t = x // 5 r = x % 5 if r > 0 : t+= 1 print(t) # Sun Sep 15 2019 11:43:05 GMT+0300 (MSK)
Amugae has a hotel consisting of 10 rooms. The rooms are numbered from 0 to 9 from left to right. The hotel has two entrances β€” one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similar...
3
m = "0000000000" m = list(m) def house(c): if(c == "L"): for i in range(10): if(m[i] == '0'): m[i] = '1' break else: for i in range(10): if(m[9-i] == '0'): m[9-i] = '1' break def proc(c): if(c == "L"): ...
Alice has a string s. She really likes the letter "a". She calls a string good if strictly more than half of the characters in that string are "a"s. For example "aaabb", "axaa" are good strings, and "baca", "awwwa", "" (empty string) are not. Alice can erase some characters from her string s. She would like to know wh...
3
S = str(input()) numA = 0 numOther = 0 total = len(S) for i in range(0, len(S)): if(S[i] == 'a'): numA += 1 else: numOther += 1 if(numOther >= numA): total = 2*numA - 1 print(total)
Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left. For example, numbers 131 and 2010200 are quasi-palindromic, they can be transformed to strin...
3
n=input().rstrip("0");print("YES" if n==n[::-1] else "NO")
You play your favourite game yet another time. You chose the character you didn't play before. It has str points of strength and int points of intelligence. Also, at start, the character has exp free experience points you can invest either in strength or in intelligence (by investing one point you can either raise stre...
3
INT_MAX=10**20+7 MOD=10**9+7 from sys import stdin,stdout def INPUT():return list(int(i) for i in stdin.readline().split()) import math def inp():return stdin.readline() def out(x):return stdout.write(x) #================================================================== for i in range(int(inp())): s,x,e=INPUT() ...
One foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any longer, so he decided to get some food in the house. Karlsson's gaze immediately fell on n wooden ...
1
from sys import stdin rr = lambda: stdin.readline().strip() rrm = lambda: map(int, rr().split()) N = int(rr()) L = R = 0 for _ in xrange(N): l, r = rrm() L += l R += r print min(L, N-L) + min(R, N-R)
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is n. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains 2 apartments, every other floor contains x apartments each. Apartments are numbered starting from one, from...
3
t = int(input()) for _ in range(t): line = input().split() n = int(line[0]) - 2 if n < 1: print(1) else: x = int(line[1]) if n % x == 0: print(n // x + 1) else: print(n // x + 2)
Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your first year at summer camp, and you are asked to solve the following problem. All integers starting with 1 are written in one line. The prefix of these line is "123456789101112131415...". Your task is to...
3
seq = [] indx = 0 for i in range(1, 1001): curr = str(i) for j in curr: seq.append(j) indx += 1 print(seq[int(input()) - 1])
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
3
n= int(input()) y =[] for i in range (n): y .append(int(input())) ctr =1 for i in range (0,n-1): if y[i] != y[i+1]: ctr+=1 print(ctr)
Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the examiner will be... To prepare for the exam, one has to study proofs of n theorems...
1
n, k = map(int, raw_input().split()) a = map(int, raw_input().split()) q = input() h = set([]) mi = 10 ** 10 ma = 0 for i in xrange(q): t = tuple(sorted(map(int, raw_input().split()))) if t in h: continue h.add(t) s = 0.0 for j in t: s += a[j - 1] a[j - 1] = None mi = min(mi, s / (n / k)) ma =...
You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n. For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10. Input The first line contains an integer t (1 ≀ t ≀ 1000) β€” the ...
3
def solve(): n, k = map(int, input().split()) print(k + (k - 1) // (n - 1)) for _ in range(int(input())): solve()
The only difference between easy and hard versions is constraints. You are given a sequence a consisting of n positive integers. Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are a and b, a can be equal b) and is as follows: [\underbrace{a, a, ...
3
import sys # import bisect # from collections import deque Ri = lambda : [int(x) for x in sys.stdin.readline().split()] ri = lambda : sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in...
Iahub got bored, so he invented a game to be played on paper. He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≀ i ≀ j ≀ n) and flips all values ak for which their positions are in range [i, j] (that is i ≀ k ≀ j)...
1
n = input() arr = map(int,raw_input().strip().split()) if n==1: if arr[0]==1: print 0 else: print 1 else: count = [0]*n count[0] = arr[0] for i in range(1,n): count[i] = count[i-1]+int(arr[i]==1) ans = 0 for i in range(n): for j in range(i,n): if i...
Student Valera is an undergraduate student at the University. His end of term exams are approaching and he is to pass exactly n exams. Valera is a smart guy, so he will be able to pass any exam he takes on his first try. Besides, he can take several exams on one day, and in any order. According to the schedule, a stud...
3
n = int(input()) a = [] for i in range(n): x, y = map(int, input().split()) a.append((x, y)) a.sort() min_b = -1 for i in range(n): if min_b <= a[i][1]: min_b = a[i][1] else: min_b = a[i][0] print(min_b)
Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered to be an ancestor of node Y if node Y is a child of node X or if there is ...
1
# Root of the Problem.py import sys if __name__=="__main__": inputs = sys.stdin.readline().split() T = int(inputs[0]) for i in range(T): inputs = sys.stdin.readline().split() # N = int(inputs[0]) p=[] M= int(inputs[0]) for qw in xrange(M): p.extend([int(x) for x in sys.stdin.readline().split()]) ...
While sailing on a boat, Inessa noticed a beautiful water lily flower above the lake's surface. She came closer and it turned out that the lily was exactly H centimeters above the water surface. Inessa grabbed the flower and sailed the distance of L centimeters. Exactly at this point the flower touched the water surfac...
1
H, L = map(float, raw_input().split()) print (L**2 - H**2) / (2 * H)
You are given the array a consisting of n positive (greater than zero) integers. In one move, you can choose two indices i and j (i β‰  j) such that the absolute difference between a_i and a_j is no more than one (|a_i - a_j| ≀ 1) and remove the smallest of these two elements. If two elements are equal, you can remove a...
3
for i in range(int(input())): n = int(input()) arr = [int(elem) for elem in input().split()] counter_even, counter_odd = 0, 0 for elem in arr: if elem % 2 == 0: counter_odd+=1 else: counter_even+=1 if counter_even % 2 == 1 or counter_even*counter_odd > 0: ...
Long story short, shashlik is Miroslav's favorite food. Shashlik is prepared on several skewers simultaneously. There are two states for each skewer: initial and turned over. This time Miroslav laid out n skewers parallel to each other, and enumerated them with consecutive integers from 1 to n in order from left to ri...
3
import sys import math import collections import heapq input=sys.stdin.readline n,k=(int(i) for i in input().split()) i=k if(k>=n-1): print(1) print(1) else: ans=[] prev=-1 print(math.ceil(n/(2*k+1))) for j in range(math.ceil(n/(2*k+1))): ans.append(i+1) prev=i i+=k ...
John Smith knows that his son, Thomas Smith, is among the best students in his class and even in his school. After the students of the school took the exams in English, German, Math, and History, a table of results was formed. There are n students, each of them has a unique id (from 1 to n). Thomas's id is 1. Every st...
3
l1 = [] for i in range(int(input())): l = list(map(int, input().split())) l1.append(sum(l)) c = 0 for i in range(1, len(l1)): if(l1[0] < l1[i]): c += 1 print(c + 1)
You are given an array a_1, a_2, ... , a_n. Array is good if for each pair of indexes i < j the condition j - a_j β‰  i - a_i holds. Can you shuffle this array so that it becomes good? To shuffle an array means to reorder its elements arbitrarily (leaving the initial order is also an option). For example, if a = [1, 1, ...
3
t=int(input()) for i in range(0,t): n=int(input()) a=list(map(int,input().split())) if(len(a)==1): print(a[0]) else: a.sort(reverse=True) for j in range(0,n): print(a[j],end=" ") print()
You're given an array a_1, …, a_n of n non-negative integers. Let's call it sharpened if and only if there exists an integer 1 ≀ k ≀ n such that a_1 < a_2 < … < a_k and a_k > a_{k+1} > … > a_n. In particular, any strictly increasing or strictly decreasing array is sharpened. For example: * The arrays [4], [0, 1], [...
3
from sys import stdin input = stdin.readline def read(): n = int(input()) a = list(map(int, input().split())) return n, a def solve(n, a): i = 0 while i < n and a[i] - i >= 0: i += 1 i -= 1 j = n - 1 while j >= 0 and a[j] - (n - 1 - j) >= 0: j -= 1 j += 1 ret...
There are n dormitories in Berland State University, they are numbered with integers from 1 to n. Each dormitory consists of rooms, there are a_i rooms in i-th dormitory. The rooms in i-th dormitory are numbered from 1 to a_i. A postman delivers letters. Sometimes there is no specific dormitory and room number in it o...
3
import bisect n,m = [int(x) for x in input().split()] a = [int(x) for x in input().split()] aa = [] ss = {} s = 0 for i in a: aa.append(s+i) ss[s+i]=1 s+=i #print(aa) b = [int(x) for x in input().split()] #print(b) for i in range(m): dd = 0 rr = 0 x = bisect.bisect(aa,b[i]) if b[i] in ss: ...
Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 ... s_{n} of length n where each letter is either R, S or P. While initializing, the bot is choosing a starting index pos (1 ≀ pos ≀ n), and then it can play any numbe...
3
from sys import stdin, stdout import math,sys from itertools import permutations, combinations from collections import defaultdict,deque,OrderedDict from os import path import bisect as bi import heapq def yes():print('YES') def no():print('NO') if (path.exists('input.txt')): #------------------Sublime-----------...
You are given three positive (i.e. strictly greater than zero) integers x, y and z. Your task is to find positive integers a, b and c such that x = max(a, b), y = max(a, c) and z = max(b, c), or determine that it is impossible to find such a, b and c. You have to answer t independent test cases. Print required a, b a...
3
for _ in range(int(input())): lst = list(map(int, input().split())) mx, mn = max(lst), min(lst) cnt = 0 for v in lst: cnt += (v == mx) if cnt < 2: print('NO') continue print('YES') print(mx, mn, mn)
You are given an array a consisting of n integers. You can remove at most one element from this array. Thus, the final length of the array is n-1 or n. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subarray a wi...
3
# HEY STALKER n = int(input()) l = list(map(int, input().split())) ans = [] v = [] x = [] for t in range(len(l)): if len(v) == 0: v.append(l[t]) elif l[t] > l[t-1]: v.append(l[t]) else: ans.append(v) v = [l[t]] if t == len(l)-1: ans.append(v) # print(*ans) x.appen...
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to...
1
s=[int(x) for x in raw_input().split()] s=sorted(s) d=s[1]-s[0] d=d+s[2]-s[1] print d
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. <image> Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the ...
3
a, b = input().split('e') a = a[:1]+a[2:] b = int(b) a += '0' * 200 a = a[:b+1] + '.' + a[b+1:] while a[-1] == '0': a = a[:-1] if a[-1] == '.': a = a[:-1] print(a)
You are given three integers x, y and n. Your task is to find the maximum integer k such that 0 ≀ k ≀ n that k mod x = y, where mod is modulo operation. Many programming languages use percent operator % to implement it. In other words, with given x, y and n you need to find the maximum possible integer from 0 to n tha...
3
t = int(input()) for i in range(t): x, y, n = list(map(int, input().split())) j = n // x if j*x + y > n: while j*x + y >n: j-=1 print(j*x+y) else: print(j*x+y)
You are given an array A, consisting of n positive integers a_1, a_2, ..., a_n, and an array B, consisting of m positive integers b_1, b_2, ..., b_m. Choose some element a of A and some element b of B such that a+b doesn't belong to A and doesn't belong to B. For example, if A = [2, 1, 7] and B = [1, 3, 4], we can ...
3
n = int(input()) nlist = set(map(int, input().split())) m = int(input()) mlist = set(map(int, input().split())) for n in nlist: for m in mlist: a = m + n if a in nlist or a in mlist: continue else: print(n, m) exit(0)
Alice has a string s. She really likes the letter "a". She calls a string good if strictly more than half of the characters in that string are "a"s. For example "aaabb", "axaa" are good strings, and "baca", "awwwa", "" (empty string) are not. Alice can erase some characters from her string s. She would like to know wh...
3
stringa = input() aantalcaracter = len(stringa) aantala = 0 aantalander = 0 for i in stringa: if i == "a": aantala += 1 else: aantalander += 1 if aantala > aantalander: print(aantalcaracter) else: print(aantala + aantala - 1)
The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person. You are given the first and ...
3
A,B=input().split() ans=[] leng=len(A) i=1 while i<leng: if A[i]>=B[0]: break i+=1 print(A[:i]+B[0])
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pers...
1
a, b, k = map(int, raw_input().split()) for i in range(k/2): a /= 2 b += a b /= 2 a += b if k % 2 == 1: a /= 2 b += a print('{} {}'.format(a, b))
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1. Constraints * 0 \leq N \...
3
d,l = [list(map(int, s.split())) for s in open(0)] d = d[0] ans = 0 v_max = [1] for i in range(d+1): if v_max[i] - l[i] < 0: ans = -1 break v_max.append((v_max[i] - l[i])*2) else: _max = 0 for i in range(d, -1, -1): _max = min(_max + l[i], v_max[i]) ans += _max print(ans...
There are two popular keyboard layouts in Berland, they differ only in letters positions. All the other keys are the same. In Berland they use alphabet with 26 letters which coincides with English alphabet. You are given two strings consisting of 26 distinct letters each: all keys of the first and the second layouts i...
3
p=input() q=input() t=input() s="" for i in range(len(t)): if(ord(t[i])>=65 and ord(t[i])<=90): x=t[i].lower() s=s+q[p.find(x)].upper() elif(ord(t[i])>=97 and ord(t[i])<=122): s=s+q[p.find(t[i])] else: s=s+t[i] print(s)
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o...
3
class A: def solve(self): n = int(input()) other = n - 2 if other > 0 and other % 2 == 0: print("YES") else: print("NO") class B: def solve(self): [d, w] = [int(x) for x in input().split(" ")] times = [] for i in range(d): ...
You are given an array a consisting of n integers. Each a_i is one of the six following numbers: 4, 8, 15, 16, 23, 42. Your task is to remove the minimum number of elements to make this array good. An array of length k is called good if k is divisible by 6 and it is possible to split it into k/6 subsequences 4, 8, 15...
1
import sys n = int(sys.stdin.readline()) nums = map(int, sys.stdin.readline().split()) els = [4,8,15,16,23,42] indexes = {4: 0, 8: 1, 15: 2, 16: 3, 23: 4, 42: 5} counts = {} for a in nums: if a == 4: if a not in counts: counts[a] = 1 else: counts[a] += 1 else: if a not in counts: if els[indexes[a]-1...
We just discovered a new data structure in our research group: a suffix three! It's very useful for natural language processing. Given three languages and three suffixes, a suffix three can determine which language a sentence is written in. It's super simple, 100% accurate, and doesn't involve advanced machine learni...
3
t = int(input()) for i in range(t): s = input() if s[-2:] == "po": print("FILIPINO") elif s[-4:] == "masu" or s[-4:] == "desu": print("JAPANESE") elif s[-5:] == "mnida": print("KOREAN" )
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbe...
1
dict = {} N = int(raw_input()) for i in range(0,N): j = raw_input() try: del dict[j] except: dict[j]=1 print len(dict)
You are given an array a consisting of n integers a_1, a_2, ... , a_n. In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array [2, 1, 4] you can obtain the following arrays: [3, 4],...
1
for _ in range(input()): n=input() arr=map(int,raw_input().split()) d={0:0,1:0,2:0} for i in arr: d[i%3]+=1 s=min(d[1],d[2]) print d[0]+s+((d[1]-s)/3)+((d[2]-s)/3)
Iahub and his friend Floyd have started painting a wall. Iahub is painting the wall red and Floyd is painting it pink. You can consider the wall being made of a very large number of bricks, numbered 1, 2, 3 and so on. Iahub has the following scheme of painting: he skips x - 1 consecutive bricks, then he paints the x-...
1
x,y,a,b = map(int,raw_input().split()) from fractions import gcd lcm=x*y/gcd(x,y) print (b)/lcm - (a-1)/lcm
There are n left boots and n right boots. Each boot has a color which is denoted as a lowercase Latin letter or a question mark ('?'). Thus, you are given two strings l and r, both of length n. The character l_i stands for the color of the i-th left boot and the character r_i stands for the color of the i-th right boot...
3
from collections import defaultdict left,right=defaultdict(list),defaultdict(list) indexs=[] n=int(input()) l=input() r=input() for i in range(n): left[l[i]].append(i) right[r[i]].append(i) alpha='abcdefghijklmnopqrstuvwxyz' pairs=[] for i in alpha: while left[i] and right[i]: pairs.append([left[i]....
Tokitsukaze is one of the characters in the game "Kantai Collection". In this game, every character has a common attribute β€” health points, shortened to HP. In general, different values of HP are grouped into 4 categories: * Category A if HP is in the form of (4 n + 1), that is, when divided by 4, the remainder is ...
3
dct = {1: ['A', 0], 3:['B', 2], 2:['C', 1] , 0:['D', 1]} def upgrade(n): x = n%4 _next = dct[x][1] return _next, dct[(x+_next)%4][0] n = int(input()) x, y = upgrade(n) print(x, y)
In order to pass the entrance examination tomorrow, Taro has to study for T more hours. Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A). While (X \times t) hours pass in World B, t hours pass in World A. How many hours will pass in World A while Taro studies fo...
3
T,X = list(map(int,input().split())) print(T/X)
Polycarp has n coins, the value of the i-th coin is a_i. Polycarp wants to distribute all the coins between his pockets, but he cannot put two coins with the same value into the same pocket. For example, if Polycarp has got six coins represented as an array a = [1, 2, 4, 3, 3, 2], he can distribute the coins into two ...
3
n = int(input()) l = list(map(int, input().split())) ans = 0 k = set(l) for i in k: c = l.count(i) if c > ans: ans = c else: continue print(ans)
Several ages ago Berland was a kingdom. The King of Berland adored math. That's why, when he first visited one of his many palaces, he first of all paid attention to the floor in one hall. The floor was tiled with hexagonal tiles. The hall also turned out hexagonal in its shape. The King walked along the perimeter of ...
1
i = sorted(map(int, raw_input().split(" "))) a,b,c = i print a*b + b*c + a *c - a - b - c + 1
There are n emotes in very popular digital collectible card game (the game is pretty famous so we won't say its name). The i-th emote increases the opponent's happiness by a_i units (we all know that emotes in this game are used to make opponents happy). You have time to use some emotes only m times. You are allowed t...
3
n,m,k = map(int, input().split()) A = list(map(int, input().split())) Max = 0 SMax = 0 ind = 0 for i in range(n): if A[i] > Max: Max = A[i] ind = i if k >= m: print(Max*m) else: for j in range(n): if A[j] > SMax and j != ind: SMax = A[j] c = m//(k+1) d = m%(k+1) print(int(Max*((c*k)+d))+int(SMax*c))
A guy named Vasya attends the final grade of a high school. One day Vasya decided to watch a match of his favorite hockey team. And, as the boy loves hockey very much, even more than physics, he forgot to do the homework. Specifically, he forgot to complete his physics tasks. Next day the teacher got very angry at Vasy...
3
n=int(input()) count1=0 count2=0 count3=0 for i in range(0,n): a,b,c=map(int,input().split(" ")) count1=count1+a count2=count2+b count3=count3+c if count1==count2==count3==0 : print("YES") else: print("NO")
Nicholas has an array a that contains n distinct integers from 1 to n. In other words, Nicholas has a permutation of size n. Nicholas want the minimum element (integer 1) and the maximum element (integer n) to be as far as possible from each other. He wants to perform exactly one swap in order to maximize the distance...
3
n = int(input()) a = [int(i) for i in input().split()] for i in range(n): if a[i] == 1: pos1 = i if a[i] == n: posn = i print(max(posn, pos1, n - pos1 - 1, n - posn - 1))
You are given a positive integer x. Find any such 2 positive integers a and b such that GCD(a,b)+LCM(a,b)=x. As a reminder, GCD(a,b) is the greatest integer that divides both a and b. Similarly, LCM(a,b) is the smallest integer such that both a and b divide it. It's guaranteed that the solution always exists. If ther...
3
t = int(input()) for _ in range(t): print(f'1 {int(input())-1} ')
ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed disappear! More formally, if you typed a word at second a and then the next word at second b, then if b - a ≀ c, just the new word is appended to other words on the screen. If b - a > c, then ever...
3
n,c=map(int,input().split()) l=list(map(int,input().split())) d=1 for i in range(1,n): if (l[i]-l[i-1])<=c: d+=1 else: d=1 print(d)
The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a Birlandish word edoc....
3
s = input() t = s[::-1] s = input() if s == t: print('YES') else: print('NO')
Sereja loves integer sequences very much. He especially likes stairs. Sequence a1, a2, ..., a|a| (|a| is the length of the sequence) is stairs if there is such index i (1 ≀ i ≀ |a|), that the following condition is met: a1 < a2 < ... < ai - 1 < ai > ai + 1 > ... > a|a| - 1 > a|a|. For example, sequences [1, 2, 3, 2...
1
import sys n=int(sys.stdin.readline()) x=map(int,sys.stdin.readline().strip('\n').split()) x=sorted(x,reverse=True) i=0 t=[1]*len(x) s=[] i=len(x)-2 now=x[-1] s.append(now) t[-1]=0 while i>=0: if x[i]>now and t[i]==1: now=x[i] s.append(now) t[i]=0 i-=1 i=0 now=x[0] while i<len(x): ...
Alice and Bob play ping-pong with simplified rules. During the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't make a return. The one ...
3
a=int(input()) for i in range(0,a): s1,s2=map(int,input().split()) if(s2>s1): print(s1-1,s2) elif(s1>s2): print(s1-1,s2) else: print(s1-1,s2)
DZY loves chemistry, and he enjoys mixing chemicals. DZY has n chemicals, and m pairs of them will react. He wants to pour these chemicals into a test tube, and he needs to pour them in one by one, in any order. Let's consider the danger of a test tube. Danger of an empty test tube is 1. And every time when DZY pour...
3
import sys input = sys.stdin.readline from collections import deque class Graph(object): """docstring for Graph""" def __init__(self,n,d): # Number of nodes and d is True if directed self.n = n self.graph = [[] for i in range(n)] self.parent = [-1 for i in range(n)] self.directed = d def addEdge(self,x,y...
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two...
1
x,y,z = map(int, raw_input().split()) x -= z res = x / (y+z) print res
Ann has recently started commuting by subway. We know that a one ride subway ticket costs a rubles. Besides, Ann found out that she can buy a special ticket for m rides (she can buy it several times). It costs b rubles. Ann did the math; she will need to use subway n times. Help Ann, tell her what is the minimum sum of...
3
#solve for both even and odd n on paper with simple excample s = input().split() n = int(s[0]) m = int(s[1]) a = int(s[2]) b = int(s[3]) ans = -1 if n<m: ans = min(n*a,b) else: ans = 1000*1000 div = n//m for i in range(div+2): left = n-i*m if(n-i*m < 0): left = 0 #...
There are two sisters Alice and Betty. You have n candies. You want to distribute these n candies between two sisters in such a way that: * Alice will get a (a > 0) candies; * Betty will get b (b > 0) candies; * each sister will get some integer number of candies; * Alice will get a greater amount of candie...
3
t = int(input()) for _ in range(t): x = int(input()) if x==1 or x==2: print(0) continue if x%2==0: print((x//2) -1) else: print(x//2)
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 thro...
3
a = int(input()) print(8 - (a - 400) // 200)
You have a given picture with size w Γ— h. Determine if the given picture has a single "+" shape or not. A "+" shape is described below: * A "+" shape has one center nonempty cell. * There should be some (at least one) consecutive non-empty cells in each direction (left, right, up, down) from the center. In other ...
3
import sys input = sys.stdin.readline h,w=map(int,input().split()) MAP=[list(input()) for i in range(h)] flag=0 for i in range(1,h-1): for j in range(1,w-1): if MAP[i][j]==MAP[i-1][j]==MAP[i+1][j]==MAP[i][j-1]==MAP[i][j+1]=="*": CI=i CJ=j flag=1 break i...
You are given three positive (i.e. strictly greater than zero) integers x, y and z. Your task is to find positive integers a, b and c such that x = max(a, b), y = max(a, c) and z = max(b, c), or determine that it is impossible to find such a, b and c. You have to answer t independent test cases. Print required a, b a...
3
import collections def solve(arr): arr.sort() if arr[1] == arr[2]: print('YES') if arr[0] == 1: print(arr[0], end=" ") print(arr[0], end=" ") print(arr[1], end=" ") else: print(arr[0]-1, end=" ") print(arr[0], end="...
Takahashi is standing on a multiplication table with infinitely many rows and columns. The square (i,j) contains the integer i \times j. Initially, Takahashi is standing at (1,1). In one move, he can move from (i,j) to either (i+1,j) or (i,j+1). Given an integer N, find the minimum number of moves needed to reach a ...
3
n = int(input()) i = 1 while i * i <= n: if n % i == 0: x = i y = n // i i += 1 print(x + y - 2)
You are given a string s of even length n. String s is binary, in other words, consists only of 0's and 1's. String s has exactly n/2 zeroes and n/2 ones (n is even). In one operation you can reverse any substring of s. A substring of a string is a contiguous subsequence of that string. What is the minimum number of...
3
t = int(input()) for _ in range(t): n, s = int(input()), input() c = sum(1 for i in range(n-1) if s[i] == s[i+1]) print((c + 1) // 2)
Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system. The term is coming to an end and students start thinking about their grades. Today, a professor told his students that...
3
n = int(input()) arr = list(map(int, input().split())) arr.sort(reverse = True) x = sum(arr) ans = 0 while x < 4.5 * n: x += (5 - arr[-1]) arr.pop() ans += 1 print(ans)
Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5Β·i minutes to solve the i-th...
3
n,m=[int(x) for x in input().split()] ans=0 for i in range(1,n+1): if(m+i*5<=240): m+=i*5 ans+=1 print(ans)
You are given a special jigsaw puzzle consisting of nβ‹… m identical pieces. Every piece has three tabs and one blank, as pictured below. <image> The jigsaw puzzle is considered solved if the following conditions hold: 1. The pieces are arranged into a grid with n rows and m columns. 2. For any two pieces that sh...
3
# -*- coding: utf-8 -*- t=int(input()) for i in range(t): x = input() x1 = x.split() n = int(x1[0]) m = int(x1[1]) if min(m,n)>1: if max(m,n)<=2: print("YES") else: print("NO") else: print("YES")
The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of numerous small, often oddl...
3
s=[int(i) for i in input().split(" ")] n=s[0] m=s[1] b=[] a=[int(n) for n in input().split(" ")] a=sorted(a) for i in range(m-n+1): b.append(a[i+n-1]-a[i]) print(min(b))
In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second β€” number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 β€” AB, column 52 is marked by AZ. After ZZ there follow th...
3
import re n = int(input()) for i in range(n): s = input() if re.match('R\d+C\d+', s): r = s[s.index('R') + 1: s.index('C')] c = int(s[s.index('C') + 1: ]) s = '' q = 1 l = 0 while c > q: l += 1 c -= q q *= 26 for i in range(l): s += chr(ord('A') + c % 26) c //= 26 print(s[::-1] + r) el...
You will be given an integer a and a string s consisting of lowercase English letters as input. Write a program that prints s if a is not less than 3200 and prints `red` if a is less than 3200. Constraints * 2800 \leq a < 5000 * s is a string of length between 1 and 10 (inclusive). * Each character of s is a lowerca...
3
a,s = int(input()), input() if a >= 3200: print(s) else: print('red')
So, the New Year holidays are over. Santa Claus and his colleagues can take a rest and have guests at last. When two "New Year and Christmas Men" meet, thear assistants cut out of cardboard the letters from the guest's name and the host's name in honor of this event. Then the hung the letters above the main entrance. O...
3
string1 = input() string2 = input() string3 = input() l1 = [0]*26 l2 = [0]*26 for char in string1: l1[ord(char)-65] += 1 for char in string2: l1[ord(char)-65] += 1 for char in string3: l2[ord(char)-65] += 1 flag = 0 for i in range(len(l1)): if l1[i]!=l2[i]: flag=1 break if flag==0: ...
Write a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2). Input Four real numbers x1, y1, x2 and y2 are given in a line. Output Print the distance in real number. The output should not contain an absolute error greater than 10-4. Example Input 0 0 1 1 Output 1.41421356
3
import math x1, y1, x2, y2 = (float(i) for i in input().split()) print(math.sqrt((x1-x2)**2+(y1-y2)**2))
[THE SxPLAY & KIVΞ› - 漂桁](https://soundcloud.com/kivawu/hyouryu) [KIVΞ› & Nikki Simmons - Perspectives](https://soundcloud.com/kivawu/perspectives) With a new body, our idol Aroma White (or should we call her Kaori Minamiya?) begins to uncover her lost past through the OS space. The space can be considered a 2D plane,...
3
if __name__ == '__main__': x0, y0, ax, ay, bx, by = tuple(map(int, input().split())) xs, ys, t = tuple(map(int, input().split())) kapa, napa = x0, y0 L = [] L.append((kapa, napa)) dupli = 0 for _ in range(60): if (kapa, napa) == (xs, ys): dupli = 1 x = ax*kapa+bx...
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second. One day in 230 AD Shapur was trying to find out if any one can possibly do...
3
s=input() p=input() res="" for i in range(0,len(s)): if s[i]==p[i]: res=res+"0" else: res=res+"1" print(res)
The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times. The ...
3
n,k=map(int,input().split()) a=list(map(int,input().split())) x=0 a.sort() for i in range(0,n-2,3): if a[i]+k<=5 and a[i+1]+k<=5 and a[i+2]+k<=5: x+=1 print(x)
problem Taro often shop at JOI general stores. At JOI general stores, there are enough coins of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen, and we always pay the change so that the number of coins is the smallest. Create a program to find the number of coins included in the change you receive when Taro goes sh...
1
coins = (500, 100, 50, 10, 5, 1) def count(x, y): ret = 0 while x >= y: x -= y ret += 1 return x, ret while True: n = input() if n == 0: break ans = 0 n = 1000 - n for val in coins: n, t = count(n, val) ans += t print(ans)
β€” Hey folks, how do you like this problem? β€” That'll do it. BThero is a powerful magician. He has got n piles of candies, the i-th pile initially contains a_i candies. BThero can cast a copy-paste spell as follows: 1. He chooses two piles (i, j) such that 1 ≀ i, j ≀ n and i β‰  j. 2. All candies from pile i are...
3
'''Author- Akshit Monga''' t=int(input()) for _ in range(t): n,k=map(int,input().split()) arr=[int(x) for x in input().split()] m=min(arr) ans=0 for i in arr: ans+=(k-i)//m print(ans-(k-m)//m)
Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network. Bu...
3
s=input() s=set(s) if len(s)==1: print("IGNORE HIM!") if len(s)%2==0: print("CHAT WITH HER!") else: print("IGNORE HIM!")
Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers. Unfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the following question correctly:...
3
n = int(input()) a = [int(i) for i in input().split()] x = 0 y = 0 c = False k = 0 answ = 'yes' for i in range(1, n): if a[i] == a[i - 1]: print('no') break if a[i] < a[i - 1]: if k == 0 and c: print('no') break elif not c: x = i - 1 ...
There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not. Taro is trying to make N pairs, each consisting of a man and a woman...
3
N = int(input()) to = [[] for _ in range(N)] for i in range(N): a = list(map(int, input().split())) for j in range(N): if a[j]==1: to[i].append(j) dp = [0]*(1<<N) dp[0] = 1 MOD = 10**9+7 for i in range((1<<N)-1): c = 0 for j in range(N): if (i>>j)&1: ...
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the eve...
3
n,m=map(int,input().split()) s=n i=0 while s>0: s=s-1 i=i+1 if i%m==0: s=s+1 print(i)
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks. According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot. Every day Vasya puts on new socks in the morning and ...
3
stuff = input().split() a = int(stuff[0]) b = int(stuff[1]) maxNum = min(a, b) daysLeft = (max(a, b) - min(a, b)) // 2 print( str(maxNum) + ' ' + str(daysLeft) )
There is a special offer in Vasya's favourite supermarket: if the customer buys a chocolate bars, he or she may take b additional bars for free. This special offer can be used any number of times. Vasya currently has s roubles, and he wants to get as many chocolate bars for free. Each chocolate bar costs c roubles. He...
3
t=int(input()) res=[] for i in range(t): s,a,b,c=map(int,input().split()) sum1=s//c l=sum1//a d=s-(a*c*l) e=d//c w=sum1//a x=w*a y=w*b res.append(x+y+e) for i in range (t): print(res[i])