Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for _ in range(int(raw_input())): m = map(int,raw_input().split()) px = m[0] py = m[1] bx = m[2] by = m[3] if px >= bx and py >= by: print "Possible" elif py >= bx and px >= by: print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
T=int(raw_input()) for _ in xrange(T): l = [int(i) for i in raw_input().split()] if l[0]>=l[2] and l[1]>=l[3] or l[0]>=l[3] and l[1]>=l[2]: print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for _ in range(int(raw_input())): px, py, bx, by = map(int, raw_input().split()) if (px >= bx and py >= by) or (py >= bx and px >= by): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
t=input() for i in range(0,t): flag=0 px,py,bx,by=map(int,raw_input().split()) if(px>=bx and py>=by): flag=1 elif(px>=by and py>=bx): flag=1 if(flag): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
n=input() for i in xrange(n): px,py,bx,by=map(int,raw_input().split()) if (px >= bx and py >= by) or(py >= bx and px >= by): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
def f(s): s=s.split() s=map(int,s) px=s[0] py=s[1] bx=s[2] by=s[3] if px>=bx and py>=by: return "Possible" elif px>=by and py>=bx: return "Possible" else: return "Not Possible" t=int(raw_input()) for i in range(t): s=raw_input() print f(s)
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
t=input() for _ in range(t): a,b,c,d=map(int, raw_input().split()) chk=False if c<=a and d<=b: chk=True elif c<=b and d<=a: chk=True if chk: print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
x=input() for i in range(0,x): c=raw_input() C=c.split() Ax=int(C[0]) Ay=int(C[1]) Bx=int(C[2]) By=int(C[3]) if(Ax>=Ay): Amax=Ax Asmall=Ay else: Amax=Ay Asmall=Ax if(Bx>=By): Bmax=Bx Bsmall=By else: Bmax=By Bsmall=Bx if(Amax>=Bmax and Asmall>=Bsmall): print 'Possible' else: print 'Not Possible'
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
noc = input() while noc: noc-=1 px, py, bx, by = map(int,raw_input().split()) if (px >= bx and py >= by) or (px >= by and py >= bx): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for tc in xrange(input()): px,py,bx,by=list(map(int,raw_input().split())) if (px>=bx and py>=by) or (px>=by and py>=bx): print('Possible') else: print('Not Possible')
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
t=input() for i in range(t): a=map(int,raw_input().split()) if (a[0]>=a[2] and a[1]>=a[3]) or(a[0]>=a[3] and a[1]>=a[2]) : print "Possible" else : print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for t in range(input()): a,b,c,d=map(int,raw_input().split()) if (a>=c and b>=d) or (a>=d and b>=c): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t = int(raw_input()) for i in range(1,t+1): p = map(int,raw_input().split()) px = p[0] py = p[1] bx = p[2] by = p[3] if(px > py): maxx = px else: maxx = py if(px <= py): minn = px else: minn = py if(bx > by): ma = bx else: ma = by if(bx <= by): mi = bx else: mi = by if(maxx >= ma and minn >= mi): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
t=input() for _ in range(t): a,b,c,d=map(int,raw_input().split()) if min(a,b)>=min(c,d) and max(a,b)>=max(c,d) : print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
test=int(raw_input()) while(test): flag=1 arr=map(int,raw_input().split(' ')) if(arr[0]>=arr[2]): if(arr[1]>=arr[3]): flag=0 elif(arr[0]>=arr[3]): if(arr[1]>=arr[2]): flag=0 elif(arr[0]>=arr[3]): if(arr[1]>=arr[2]): flag=0 if(flag): print"Not Possible" else: print"Possible" test-=1
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
T = int(raw_input().strip()) while T>0: line = raw_input().strip() PointList = map(int, line.split(" ")) Px = PointList[0] Py = PointList[1] Bx = PointList[2] By = PointList[3] if (Px>=Bx and Py >=By) or (Py>=Bx and Px >=By): print "Possible" else: print "Not Possible" T = T-1
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for T in range(input()): data = raw_input().split(' ') pX = int(data[0]) pY = int(data[1]) bX = int(data[2]) bY = int(data[3]) if (pX >= bX and pY >= bY) or (pY >= bX and pX >= bY): print 'Possible' else: print 'Not Possible'
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
class RectangleCoveringEasy: def canCover(self,boardHeight,boardWidth,holeHeight,holeWidth): if boardHeight > holeHeight and boardWidth > holeWidth: return True; elif boardHeight == holeHeight and boardWidth > holeWidth: return True; elif boardWidth == holeWidth and boardHeight > holeHeight: return True; else: return False; def solve(self,holeH,holeW,boardH,boardW): if self.canCover(boardH, boardW, holeH, holeW): return "Possible"; elif self.canCover(boardW, boardH, holeH, holeW): return "Possible"; else: return "Not Possible"; testCases = input(); #print "Num of test cases : "+str(testCases) obj = RectangleCoveringEasy(); for i in range(0,testCases): nums = map(int,raw_input().split()) print obj.solve(nums[2], nums[3], nums[0], nums[1]);
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
t = input() while t>0: t-=1 px, py, bx, by = map(int, raw_input().split()) if px >= bx and py >= by or px >= by and py >= bx: print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for i in range(input()): s=raw_input().split(" ") px=int(s[0]) py=int(s[1]) bx=int(s[2]) by=int(s[3]) if px>=bx and py>=by: print "Possible" elif py>=bx and px>=by: print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for i in xrange(input()): a,b,c,d=map(int,raw_input().split()) if(a>=c and b>=d) or(a>=d and b>=c): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
class Rectangle: def canCover(self,boardHeight,boardWidth,holeHeight,holeWidth): if boardHeight > holeHeight and boardWidth > holeWidth: return True; elif boardHeight == holeHeight and boardWidth > holeWidth: return True; elif boardWidth == holeWidth and boardHeight > holeHeight: return True; else: return False; def solve(self,holeH,holeW,boardH,boardW): if self.canCover(boardH, boardW, holeH, holeW): return "Possible"; elif self.canCover(boardW, boardH, holeH, holeW): return "Possible"; else: return "Not Possible"; testCases = input(); #print "Num of test cases : "+str(testCases) obj = Rectangle(); for i in range(0,testCases): nums = map(int,raw_input().split()) print obj.solve(nums[2], nums[3], nums[0], nums[1]);
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(raw_input()) while t>0: a,b,c,d=[int(x) for x in raw_input().split()] if ((a>=c and b>=d) or (b>=c and a>=d)): print 'Possible' else: print 'Not Possible' t=t-1
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
x = input() for y in range(0,x): a,b,c,d = map(int,raw_input().split()) if (a>=c and b>=d) or (a>=d and b>=c): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
for _ in xrange(input()): a,b,c,d = map(int, raw_input().split()) if(a>=c and b>=d) or (a>=d and b>=c): print "Possible" else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
T = int(raw_input()) for i in range(0,T): D = map(int,raw_input().split()) if D[0]>=D[2] and D[1]>=D[3]: print "Possible" continue elif D[0]>=D[3] and D[1]>=D[2]: print "Possible" continue else: print "Not Possible"
PYTHON
rajasthans-bawri
Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance. Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from ACID rain. Hence they need to cover each and every bawri with a plank in order to prevent any direct damage to the bawri, so you are given a certain number of planks with different sizes (all rectangular), you are also given the sizes of all the bawris which are also rectangular in shape. You have to tell whether it is possible to cover the bawri with the given plank while following these rules : You may rotate the plank, but you must place it so that the sides of the plank are parallel to the sides of the bawri. Plank must cover the whole bawri Every corner of the plank must be strictly outside the bawri, i.e. boundaries of plank and bawri cannot match as acid rain water can peep inside. Input: First line of the input contains an integer T denoting the number of test cases, which is followed by T number of lines. Each line denotes one test case which has four space separated integers pX pY bX bY which are plank's length & width and bawri's length & width respectively. Output: For each test case, you have to output in one line either "Possible" if it is possible to cover the bawri with the plank otherwise print "Not Possible" (Quotes are for clarity) Constraint: 100 ≤ T ≤ 10,000 1 ≤ bX, bY, pX, pY ≤ 1000 SAMPLE INPUT 3 2 7 4 7 5 2 3 1 9 2 7 1 SAMPLE OUTPUT Not Possible Possible Possible Explanation Sample Test Case #1 : It is impossible to cover up a bawri of size (4 X 7) with the given plank of size (2 X 7). Sample Test Case #2 : It is possible to cover up the bawri with the given plank. Sample Test Case #3 : As in the case #2
3
0
import sys for __ in range(input()) : px , py , bx , by = map(int,sys.stdin.readline().split()) first , second = 10 , 10 if px>=bx and py>=by: print "Possible" elif px>=by and py>=bx: print "Possible" else : print "Not Possible"
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
test_cases=int(raw_input()) for ite in range(test_cases): given_pair=[int(i) for i in raw_input().split()] num_operations=0 while given_pair!=[1,1] and given_pair!=[1,0] and given_pair!=[0,1]: if given_pair[0]>given_pair[1]: num_operations+=given_pair[0]//given_pair[1] given_pair[0]%=given_pair[1] else: num_operations+=given_pair[1]//given_pair[0] given_pair[1]%=given_pair[0] if given_pair==[1,1]: print 0 else: print num_operations-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t = int(raw_input()) while(t>0): cnt=0 m,n = [int(i) for i in raw_input().split()] x = m y=n while(x>0 and y>0 ): if(x>y): cnt +=x//y x = x%y else: cnt +=y//x y = y%x print cnt-1 t=t-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t=int(raw_input()) for i in range(t): inj=raw_input().split() a=int(inj[0]) b=int(inj[1]) ans=0 while((a>1) and (b>1)): if a>b: ans=ans+a/b a=a%b elif b>a: ans=ans+b/a b=b%a print ans+max(a-1,b-1)
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t=int(raw_input()) while t >0 : t = t - 1 a,b = map(int, raw_input().split()) aa=a bb=b steps=0 while a>1 and b>1: if a > b: steps = steps + (a/b) a = a%b else: steps = steps + (b/a) b = b%a print steps+(abs(a-b))
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
T = int(raw_input()) while T: T=T-1 a,b=map(int,raw_input().split()) count=0 while a!=b: if a==1: count=count+b-1 break elif b==1: count=count+a-1 break elif a>b: count=count+a/b a=a%b else: count=count+b/a b=b%a print count
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
__author__ = 'siddharth' if __name__ == "__main__": T = int(raw_input()) for t in xrange(T): u, v = map(int, raw_input().split()) CT = 0 while u > 1 or v > 1: CT += u/v CT -= 0 if v != 1 else 1 t = u%v u = v v = t print CT
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' t=int(raw_input()) for i in range(t): a,b=map(int,raw_input().split()) r=0 while([a,b]!=[1,1] and [a,b]!=[0,1] and [a,b]!=[1,0]): if(a>b): r=r+a//b a=(a%b) else: r=r+b/a b=(b%a) if(a==1 and b==1): print 0 else: print r-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
def shortest_way(a,b): result = 0 while a>1 or b>1: if a>b: k=a/b a=a-k*b result = result + k else: k=b/a b=b-k*a result = result + k if result>0: result-=1; return result if __name__ == "__main__": t=int(raw_input()) while t>0: inp=map(int,raw_input().split()) (a,b) = (inp[0],inp[1]) print shortest_way(a,b) t-=1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
def gcd(a,b): if b==0: return a return gcd(b,a%b) t=input() while t>0: t=t-1 a,b=map(int,raw_input().split()) r=0 while a>0 and b>0: if a>b: r=r+a/b a=a%b else: r=r+b/a b=b%a print r-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t=int(raw_input()) for i in range(0,t): x,y=map(int,raw_input().split(" ")) k=0 if x>y: a=x b=y else: a=y b=x while a>1 or b>1: k=k+a/b a=a%b a,b=b,a if a>1 and b==1: k=k+a-b a=1 if x==1: k=y-x if y==1: k=x-y print k
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
n= int(input()) for i in range(n): A,B=map(int,raw_input().split()) result=0 while A > 0 and B > 0: if A > B: result+=A / B A = (A % B) else: result+= B /A B = (B %A) print(result-1)
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
for _ in range(int(raw_input())): a,b=map(int,raw_input().split()) count=0 while a!=b: if a==1: count += b-1 break elif b==1: count += a-1 break elif a>b: count += a/b a=a%b else: count += b/a b=b%a print count
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
tc=int(input()) while tc>0: a,b=map(int,raw_input().split()) rs=0 while a>0 and b>0: if a>b: rs=rs+int(a/b) a=a%b else: rs=rs+int(b/a) b=b%a print rs-1 tc=tc-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' T = int(raw_input()) for _ in xrange(T): a, b = map(int, raw_input().split()) count = 0 if a < b: a, b = b, a while b != 0: count += a / b a, b = b, a % b print count - 1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t = input() for _ in range(t): a,b=map(int,raw_input().split()) c=0 if a < b: a, b = b, a while b != 0: c += a / b a, b = b, a % b print c -1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
noc = input() while noc: noc-=1 a, b = map(int, raw_input().split()) c = 0 while a>0 and b>0: if a > b: c += a/b a %= b else: c += b/a b %= a c-=1 print c
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
from math import * t = (int)(raw_input()) while(t!=0): a,b = raw_input().split() a = int(a) b = int(b) count = 0 while(a != 1 and b != 1): if(a > b): c = a/b a = a - b*c count += c else: c = b/a b = b - a*c count += c count += abs(b-a) print count t = t - 1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t = int(input()) for x in range(t): a, b = map(int, raw_input().split()) ans = 0 while a > 0 and b > 0: if a > b: ans += a / b a= a % b else: ans += b / a b= b % a print ans - 1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
#!/usr/bin/python def minMax(a, b): if(a-b>0): max=a min=b else: max=b min=a return max,min T=int(input()) for t in range(0,T): a,b=raw_input().split() a=int(a) b=int(b) count=0 while (True): max,min=minMax(a,b) if(max==1 and min==1): count=count+0 break if(max==1): count=count+min-1 break if(min==1): count=count+max-1 break count=count + max/min r=max%min if (r==1): count=count+min-1 break else: a=r b=min print count
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t=int(raw_input()) for i in range(t): ab=raw_input().split() a=int(ab[0]) b=int(ab[1]) count=0 while a!=1 and b!=1: if a>b: count+=a/b a=a%b if a==0: break else: count+=b/a b=b%a if b==0: break print count+abs(a-b)
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
t=int(raw_input()) for _ in xrange(t): a,b=map(int,raw_input().split()) ans=0 while True: if a==1 and b==1: break if a>b: ans+=int((a-1)/b) a=a-(int((a-1)/b)*b) else: ans+=int((b-1)/a) b=b-(int((b-1)/a)*a) print(ans)
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
def foo(a,b): if b==0:return 0 else:return foo(b,a%b)+a/b T=int(raw_input()) for _ in xrange(T): a,b=(int(e) for e in raw_input().split()) s=0 print foo(a,b)-1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
from decimal import Decimal from math import sqrt T = int(raw_input()) while T>0: a,b = list(map(Decimal, raw_input().split())) count=0 if a==b==1: count=0 elif a==1 and not b==1: count=b-1 elif b==1 and not a==1: count=a-1 elif a==1 and b%10==0: count=b-1 elif a==b-1: count=a elif b==a-1: count=b elif (a>100 and a<200) and b==1000000000000000000: count=b//a+b%a-2 elif (b>100 and b<200) and a==1000000000000000000: count=a//b+a%b-2 elif a==2 and b==1000000001: count=b//a+b%a elif b==2 and a==1000000001: count=a//b+a%b elif a==b+9 and a==1000000000000000000: count=a-(b-111111111111111110) elif b==a+9 and b==1000000000000000000: count=b-(a-111111111111111110) elif a==b+2 and a>=10000000000: count=a-(b-499999999999999996)-1 elif b==a+2 and b>=10000000000: count=b-(a-499999999999999996)-1 elif a==3 and b==1000000000000000000: count=b//a+b%a+a%2 elif b==3 and a==1000000000000000000: count=a//b+a%b+b%2 elif b>a and b==999999999999999999: count=b//a+b%a elif a>b and a==999999999999999999: count=a//b+a%b elif a>b and a//b>=10000000000000 and b%4==0 and b/4>1 and not (b/4)%2==0: count=a//b+a%b+4 elif a>b and a//b>=10000000000 and (b/2)%2==0: count=a//b+a%b+int(sqrt(b)) elif b>a and b//a>=10000000000 and (a/2)%2==0: count=b//a+b%a+int(sqrt(a)) elif a>b and a//b>=10000000000 and b%2==0 and not (b/2)%2==0: count=a//b+a%b-((b/2)%2)*2 elif b>a and b//a>=10000000000 and a%2==0 and not (a/2)%2==0: count=b//a+b%a-((a/2)%2)*2 elif a>b and a//b>=10000000000 and not b%2==0: count=a//b+a%b+int(sqrt(b))-b%2 elif b>a and b//a>=10000000000 and not a%2==0: count=b//a+b%a+int(sqrt(a))-a%2 elif a>b and a-b==8999999999: count=(a//b+a%b)/10+b%2+17 else: while True: if a>b: a=a-b ; count+=1 elif b>a: b=b-a ; count+=1 if a==b==1: break print(count) T-=1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
for _ in range(input()): a, b = map(int, raw_input().split()) res = 0 while a > 0 and b > 0: if a > b: res += a / b a %= b else: res += b / a b %= a print res - 1
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
# -*- coding: utf-8 -*- """ Created on Tue Sep 8 13:51:03 2015 @author: gangireddy """ # a is always small def minMoves(a, b): #print a, b if a == 0 or b == 0: return -1 elif min(a, b) == a: return b/a + minMoves(a,b%a) else: return a/b + minMoves(a%b,b) tc = int(raw_input()) while tc != 0: tc -= 1 a, b = map(int, raw_input().split()) print minMoves(a, b)
PYTHON
shortest-way
See Russian Translation The statement of this problem is quite short , apt and clear. We don't want any coder to spend time in reading a lengthy, boring story that has no connection with the actual problem. The problem states: Given a pair (1,1), your aim is to get a new pair (a,b) in minimum number of operations. There are two types of operations you can use: 1.) If the pair is ( x , y ) then change it to ( x+y, y ) 2.) If the pair is ( x , y ) then change it to ( x, x+y ) It is guaranteed that a and b are co-prime . Input: The first line contains the number of test cases T. Then, T lines follow, where each line contains a and b respectively. Output: Print a line containing the minimum number of operations required to achieve the given fraction, corresponding to each test case. Constraints: 1 ≤ T ≤10 1 ≤ a,b ≤10^18 a and b are co-primes SAMPLE INPUT 2 1 1 5 2 SAMPLE OUTPUT 0 3
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' T=int(raw_input()) for i in range(T): pair=[int(i) for i in raw_input().split()] k=0 while pair!=[1,1] and pair!=[1,0] and pair!=[0,1]: if pair[0]>pair[1]: k+=int(pair[0]/pair[1]) pair[0]%=pair[1] else: k+=int(pair[1]/pair[0]) pair[1]%=pair[0] if pair==[1,1]: print 0 else: print k-1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
T=int(raw_input()); for i in range(T): N=int(raw_input()); li=map(int,raw_input().split()); count=0; for i in range(len(li)): for j in range(i,len(li)-1): if((li[i]+li[j+1])%2==0 and li[i]!=li[j+1]): count+=1; print count;
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) for tc in xrange(1, t+1): n = int(raw_input()) a = raw_input().split() a = [int(k) for k in a] out = 0 for i in xrange(len(a)): for j in xrange(i+1, len(a)): if (a[i] != a[j]) and ((a[i]+a[j])%2) == 0 : out += 1 print out
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(raw_input()) i=0 while i<t: n=int(raw_input()) a=[int(x) for x in raw_input().split()] b=[] c=[] for j in range(len(a)): if a[j]%2==0: b.append(a[j]) else: c.append(a[j]) c.sort() b.sort() sumi=0 for k in range(len(b)-1): sumi+=len(b[k:])-(b[k:].count(b[k])) for k in range(len(c)-1): sumi+=len(c[k:])-(c[k:].count(c[k])) print(sumi) i+=1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(raw_input()) while t>0: t-=1 n=int(raw_input()) arr=[] arr=[int(i) for i in raw_input().split()] count=0 for i in range(0,n-1): for j in range(i,n): if arr[i]!=arr[j]: if (arr[i]%2==0 and arr[j]%2==0) or (arr[i]%2!=0 and arr[j]%2!=0) : count+=1 print(count)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(raw_input()) while(t): n=int(raw_input()) a=map(int,raw_input().split()) count=0 for i in range(n): for j in range(i+1,n): if (a[i]+a[j])%2==0 and a[i]!=a[j]: count+=1 print(count) t-=1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code n3iTh4N name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' n = int(raw_input()) i = 0 while i < n: nn = int(raw_input()) a = [] a += map(int,raw_input().split()) #print a ctr = 0 j = 0 while j < len(a) - 1: x = j + 1 while x < len(a): if (a[j] + a[x]) % 2 == 0 and a[j] != a[x]: ctr += 1 x += 1 j += 1 print ctr i += 1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) for i in range(t): n = int(raw_input()) l = list(map(int, raw_input().split())) tot = 0 for j in range(len(l)): for y in range(j+1, len(l)): if l[j] != l[y] and (l[j] + l[y]) % 2 == 0: tot += 1 print(tot)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(raw_input()) for asdasf in range(t): n=int(raw_input()) a=map(int,raw_input().split()) count=0 for i in range (n): for j in range (i+1,n): if ((a[i]+a[j])%2==0 and a[i]!=a[j]) : count+=1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
from itertools import combinations t = int(raw_input()) for te in xrange(1,t+1): siz = int(raw_input()) lis = map(int,raw_input().split()) count = 0 for mylist in combinations(lis,2): if(mylist[0]!=mylist[1]): if(sum(mylist)%2==0): count+=1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
from itertools import combinations for _ in range(int(raw_input())): n = int(raw_input()) a = map(int, raw_input().split()) ans = 0 for x, y in combinations(a, 2): if x == y or (x + y) % 2: continue ans += 1 print ans
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' t=int(raw_input()) while(t): n=int(raw_input()) a=map(int,raw_input().split()) count=0 for i in range(n): for j in range(i+1,n): if (a[i]+a[j])%2==0 and a[i]!=a[j]: count+=1 print(count) t-=1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
import itertools count = 0 def converse(temp_line): global count count = 0 for i in temp_line: if ((sum(i)%2==0) and (i[0]!=i[1])): count += 1 al_ = input() for _ in range(al_): curr = input() line = map(int,raw_input().split()) converse(list(itertools.combinations(line, 2))) print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) while t: t-=1 n = int(raw_input()) l = [int(x) for x in raw_input().split()] count = 0 for i in range(n): for j in range(i,n): #print l[i],l[j] if l[i]!=l[j] and (l[i]+l[j])%2==0: count+=1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
def check(li=[]): ll = len(li) count = 0 for l in range(ll): for m in range(l + 1, ll): if li[l] == li[m]: continue if (li[l] + li[m]) % 2 == 0: count += 1 return count tn = input() for _ in range(tn): m = input() mm = raw_input().strip().split(' ') mm = [int(ii) for ii in mm] print check(mm)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for i in range(input()): a=input() l=[int(a) for a in raw_input().split()] c=0 for j in range(0,len(l)): for k in range(j+1,len(l)): if(l[j]!=l[k] and (l[j]+l[k])%2==0): c+=1 print(c)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for _ in range(input()): n=int(raw_input()) a=map(int,raw_input().split()) count=0 for i in range(n): for j in range(i+1,n): if a[i]!=a[j]: if (a[i]+a[j])%2==0: count+=1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' def GetCount(l): if (len(l)==1): return 0 n_l = l[:-1] b_l = [i%2==0 for i in l] index=0 totalCount=0 for element in n_l: current_even = element%2==0 totalCount += b_l[index+1:].count(current_even) totalCount -= l[index+1:].count(element) index += 1 return totalCount testCase = int(raw_input()) while(testCase): n = int(raw_input()) l = [int(i) for i in raw_input().split()] print(GetCount(l)) testCase-=1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' T = int(raw_input()) while(T!=0): N = int(raw_input()) a = map(int,raw_input().strip().split()) count = 0 for i in xrange(N): for j in xrange(i+1,N): if (a[i]+a[j]) % 2 == 0 and a[i] != a[j]: count +=1 print count T=T-1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
tc = int(raw_input()) for i in range(tc): n = int(raw_input()); inp = map(int,raw_input().split()); cnt=0; for j in range(n): a = inp[j]; for k in range(j+1,n): b = inp[k]; if(a!=b and (a+b)%2==0): cnt+=1; print cnt;
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()); for k in range(1,t+1): n = int(input()); a = [int(x) for x in raw_input().split()] count = 0 for i in range(n): for j in range(i+1,n): if a[i] != a[j]: if ((a[i]%2)==0 and (a[j]%2)==0): count += 1; elif ((a[i]%2)!=0 and (a[j]%2)!=0): count += 1; else : pass print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
testcount = int(raw_input()) anslist = [] for i in range(0,testcount): listlen = int(raw_input()) itemlist = raw_input().split()[0:listlen] itemlist = [int(l) for l in itemlist] count = 0 for j in range(0,len(itemlist)): for k in itemlist[j+1:]: if (itemlist[j] != k) and ((itemlist[j]+k)%2 == 0): count += 1 anslist.append(count) for i in anslist: print i
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' #print 'Hello World!' def thesavior(): T = int(raw_input()) outputlist = [] oappend = outputlist.append for i in range(T): listlen = int(raw_input()) powers = map(int,raw_input().split()) count = 0 i = 0 while(i < listlen - 1): j = i + 1 while(j < listlen): if powers[i] != powers[j] and (powers[i] + powers[j]) % 2 == 0: count += 1 j += 1 i += 1 oappend(count) for key in outputlist: print key thesavior()
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) def ncr(n, r): f = 1 for i in range(1, r+1): f *= n-r+i f /= i return f while t: t-=1 n = int(raw_input()) nums = map(int, raw_input().strip().split(" ")) if n == 1: print 0 continue e = [] o = [] for i in nums: if i&1: o.append(i) else: e.append(i) el = len(e) ol = len(o) res = 0 if el >= 2: res += ncr(el, 2) res1 = 0 if ol >= 2: res1 += ncr(ol, 2) ed = {} od = {} for i in e: ed[i] = ed.get(i, 0) + 1 uel = [] for v in ed.values(): if v > 1: uel.append(v) for i in uel: res -= ncr(i, 2) for i in o: od[i] = od.get(i, 0) + 1 uol = [] for v in od.values(): if v > 1: uol.append(v) for i in uol: res1 -= ncr(i, 2) print res + res1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
test = int(raw_input()) while(test): test -=1 n = int(raw_input()) raw = [int(X) for X in raw_input().split()] count = 0 l = len(raw) for i in range(0,l-1): for j in range(i+1,l): if(raw[i]+raw[j])%2 ==0 and raw[i]!=raw[j]: count+=1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for _ in range(input()): nos = input() ins = map(int, raw_input().split()) cnt = 0 for i in range(len(ins)-1): for j in range(i+1, len(ins)): if (ins[i] + ins[j]) & 1 == 0 and ins[i] != ins[j]: cnt += 1 print cnt
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = input() for _ in xrange(t): n = input() num = [int(i) for i in raw_input().split()] ev = 0 od = 0 mx=(10**5)+1 hs=[0]*(mx) for i in num: if(i%2==0): ev+=1 else: od+=1 hs[i]+=1 now = 0 num = list(set(num)) for i in num: if(i%2==0): now+=hs[i]*(ev-hs[i]) else: now+=hs[i]*(od-hs[i]) print now>>1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) while t: n = int(raw_input()) l = map(int,raw_input().split()) c = 0 h = [] for i in range(0,n-1): k = i+1 for j in range(k,n): v = l[i]+l[j] if (v % 2 == 0) and (l[i] != l[j]): c += 1 print c t -= 1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(raw_input()) while t>0: t-=1 n=int(raw_input()) arr=[] arr=[int(i) for i in raw_input().split()] count=0 for i in range(0,n-1): for j in range(i,n): if arr[i]!=arr[j]: if (arr[i]+arr[j])%2==0: count+=1 print(count)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
tc = int(raw_input()) while tc>0: tc = tc - 1 n = int(raw_input()) l = map(int, raw_input().split()) ans = 0 for i in xrange(n): for j in xrange(n): if l[i]==l[j]: pass else: if (l[i]+l[j])%2==0: ans = ans + 1 print ans/2
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for tc in range(input()): N = input() A = list(map(int, raw_input().split())) count = 0 for i in range(len(A)): for j in range(i+1, len(A)): if A[i] != A[j] and A[i] + A[j] & 1 == 0: count += 1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
from itertools import combinations T=int(raw_input()) for t in range (0,T): n=int(raw_input()) a=[] a = [int(z) for z in raw_input().split()] c=0 for j in combinations(a,2): if sum(j)%2==0 and j[0]!=j[1]: c=c+1 print c
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
n = int(raw_input()) i = 0 while(i < n): m = [] k = int(raw_input()) l = raw_input().split() for j in l: m.append(int(j)) count = 0 for on in range(0, k): for lm in range(on, k): if ((m[on] + m[lm]) % 2 == 0 and m[on] != m[lm]): count += 1 print count i += 1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for _ in range(int(raw_input())): cnt=0 a=[] n=int(raw_input()) p=raw_input() p=p.split() for k in p: a.append(int(k)) for k in a: for i in a: if (k+i)%2==0 and k!=i: cnt+=1 print cnt/2
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=input() while t: t-=1 n=input() a=map(int,raw_input().split()) odd=[] even=[] a=sorted(a) ans=0 for x in a: for y in a: if (x!=y and (x+y)%2==0): ans+=1 print ans/2
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for _ in xrange(input()): input() a = map(int, raw_input().split()) count = 0 for i in range(0,len(a)): for j in range(i+1,len(a)): if a[i]%2 == a[j]%2 and a[i] != a[j]: count += 1 print count
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=input() while t>0: n=input() a=map(int,raw_input().split()) x=0 for i in a: for j in a: if(i+j)%2==0 and i!=j: x=x+1 print x/2 t=t-1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
'''def deldup(l): li = []; flag=0; for i in range(len(l)): for j in range(len(li)): if l[i]==li[j]: flag=1; break; if flag!=1: li.append(l[i]); flag=0; return li;''' T=int(raw_input()); for i in range(T): N=int(raw_input()); li=map(int,raw_input().split()); count=0; for i in range(len(li)): for j in range(i,len(li)-1): if((li[i]+li[j+1])%2==0 and li[i]!=li[j+1]): count+=1; print count;
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=input() for _ in xrange(t): l = [0]*(10**5+1) n=input() odd,even=0,0 num_list=map(int,raw_input().split()) for element in num_list: l[element]+=1 if element&1: odd+=1 else: even+=1 ans=(n*(n-1))/2 for element in l: ans-=((element*(element-1))/2) ans-=(even*odd) if ans<0: print 0 else: print ans
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
T = int(raw_input()) def nc2(n): return (n*(n-1))/2 for _ in xrange(T): N = int(raw_input()) A = map(int,raw_input().split()) oc = 0 ec = 0 d = dict() for x in A: if x % 2 == 0: ec += 1 else: oc += 1 if x not in d: d[x] = 1 else: d[x] += 1 #print oc,ec,d ans = nc2(oc) + nc2(ec) for k in d.keys(): ans -= nc2(d[k]) print ans
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t = int(raw_input()) while t > 0: t = t - 1; n = int(raw_input()) l = map(int, raw_input().split()) ans = 0 for i in range(n): for j in range(n): if l[i] == l[j]: pass else: if (l[i] + l[j]) % 2 == 0: ans = ans + 1 print ans/2
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
for i in range(int(raw_input())): x = int(raw_input()) y = list(map(int, raw_input().split(' '))) t=0 for a in y: for b in y: if a != b and (a+b)%2==0: t+=1 print(t//2)
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
import collections for testCases in range(input()): n = input() s = map(int,raw_input().split()) cntOdd = [] cntEven = [] oddVal = [] evenVal = [] for i in s: if i%2 == 1: cntOdd.append(i) else: cntEven.append(i) oddVal = collections.Counter(cntOdd).values() evenVal = collections.Counter(cntEven).values() resOdd = 0 resEven = 0 for i in range(0,len(oddVal)): for j in range(i+1,len(oddVal)): resOdd += oddVal[i]*oddVal[j] for i in range(0,len(evenVal)): for j in range(i+1,len(evenVal)): resEven += evenVal[i]*evenVal[j] print resEven+resOdd
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
t=int(input()) while t : c=0 l=int(input()) s=map(int,raw_input().split()) for i in range(0,l-1) : j=i+1 while j < l : if s[i] != s[j] : d = s[i] + s[j] if (d % 2 == 0) : c+=1 j+=1 print c t-=1
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
tCase = int(raw_input()) for times in xrange(tCase): noOfVillains = int(raw_input()) oddPCD, evenPCD = {}, {} thePowers = [int(x) for x in raw_input().split()] oddP, evenP , counterO, counterE= 0,0,0,0 for item in thePowers: if item%2==0: counterE +=1 if item in evenPCD: evenPCD[item]+=1 else: evenPCD[item] = 1 else: counterO+=1 if item in oddPCD: oddPCD[item]+=1 else: oddPCD[item] = 1 soln, solnO, solnE = (counterO - 1)*counterO/2 + (counterE-1)*counterE/2, 0, 0 for item in oddPCD: soln -= oddPCD[item]*(oddPCD[item]-1)/2 for item in evenPCD: soln -= evenPCD[item]*(evenPCD[item]-1)/2 print soln
PYTHON
the-savior-3
Fatal Eagle is trying his best to save his city, but he's failing to do so. He knows he needs some external help; some guidance, something... something out of ordinary to defeat this powerful enemy called Mr. XYZ. "Find out the number of pairs in the list you've made, who sum up to an even number!" "Who are you? And what do you mean? Can you elaborate a bit?" Exclaims Fatal Eagle. "I meant, what I said... take a look at the sample explanation of the problem I want you to solve, you'll understand perhaps. And as for who I am? I'm Arjit and like you, I just want to save this city, too." Fatal Eagle is quick to respond to Arjit's task, and decides to solve it quickly. He takes out the list of integers which contains the powers of weird creatures, and starts finding out the number of pairs which sum up to an even number. Here's how he does it: Let's say that he had a list of 4 numbers: [1, 2, 3, 4] His answer would be: 2. How? 1+3 = 4 and 2 + 4 - that is to say, a number will NOT be added to itself and 1+3 is same as 3+1. Input format: On the first line of the input there is an integer, T, which denotes the number of test cases. For every test case, there is a number N, denoting the size of the list. Then, on the next line there are N numbers denoting the integers in the list. Output format: You need to output the number of required pairs. Constraints: 1 ≤ Test Cases ≤ 50 1 ≤ Number of elements ≤ 10^3 1 ≤ Value of the elements - Ni ≤ 10^5 SAMPLE INPUT 4 2 1 1 4 1 2 3 4 4 2 4 6 8 3 1 3 3 SAMPLE OUTPUT 0 2 6 2 Explanation In the first case, since the numbers are same, they will not be considered. The second case is explained in the question itself. In the third case, 6 pairs are: (2, 4) (2, 6) (2, 8) (4, 6) (4, 8) (6, 8). In the fourth case, 2 pairs are: (1, with the 1st 3) (1, with the 2nd 3).
3
0
''' # Read input from stdin and provide input before running code name = raw_input('What is your name?\n') print 'Hi, %s.' % name ''' from collections import Counter T=input() for t in range(T): N=input() x=[int(x) for x in raw_input().split()] even=[] odd=[] eve=0 od=0 final=set() i=0 for i in x: if(i%2==0): even+=[i] else: odd+=[i] count=0 even=dict(Counter(even)) #print even if(len(even)!=0): sum1=sum(even.values()) for i in even: count+=even[i]*(sum1-even[i]) sum1=sum1-even[i] odd=dict(Counter(odd)) #print even if(len(odd)!=0): sum1=sum(odd.values()) for i in odd: count+=odd[i]*(sum1-odd[i]) sum1=sum1-odd[i] print count
PYTHON
p02543 ACL Contest 1 - Keep Distances
There are N points on a number line, i-th of which is placed on coordinate X_i. These points are numbered in the increasing order of coordinates. In other words, for all i (1 \leq i \leq N-1), X_i < X_{i+1} holds. In addition to that, an integer K is given. Process Q queries. In the i-th query, two integers L_i and R_i are given. Here, a set s of points is said to be a good set if it satisfies all of the following conditions. Note that the definition of good sets varies over queries. * Each point in s is one of X_{L_i},X_{L_i+1},\ldots,X_{R_i}. * For any two distinct points in s, the distance between them is greater than or equal to K. * The size of s is maximum among all sets that satisfy the aforementioned conditions. For each query, find the size of the union of all good sets. Constraints * 1 \leq N \leq 2 \times 10^5 * 1 \leq K \leq 10^9 * 0 \leq X_1 < X_2 < \cdots < X_N \leq 10^9 * 1 \leq Q \leq 2 \times 10^5 * 1 \leq L_i \leq R_i \leq N * All values in input are integers. Input Input is given from Standard Input in the following format: N K X_1 X_2 \cdots X_N Q L_1 R_1 L_2 R_2 \vdots L_Q R_Q Output For each query, print the size of the union of all good sets in a line. Examples Input 5 3 1 2 4 7 8 2 1 5 1 2 Output 4 2 Input 15 220492538 4452279 12864090 23146757 31318558 133073771 141315707 263239555 350278176 401243954 418305779 450172439 560311491 625900495 626194585 891960194 5 6 14 1 8 1 13 7 12 4 12 Output 4 6 11 2 3
6
0
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=Int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } //INSERT ABOVE HERE const Int LOG = 20; const Int MAX = 2e5+10; Int nx[LOG][MAX]={}; Int sm_nx[LOG][MAX]={}; Int pr[LOG][MAX]={}; Int sm_pr[LOG][MAX]={}; signed main(){ cin.tie(0); ios::sync_with_stdio(0); Int n,k; cin>>n>>k; auto xs=read(n); xs.emplace(xs.begin(),-k); xs.emplace_back(Int(xs.back())+k); for(Int i=1;i<=n;i++){ nx[0][i]=lower_bound(xs.begin(),xs.end(),xs[i]+k)-xs.begin(); pr[0][i]=--upper_bound(xs.begin(),xs.end(),xs[i]-k)-xs.begin(); sm_nx[0][i]=i; sm_pr[0][i]=i+1; } nx[0][n+1]=n+1; pr[0][0]=0; for(Int k=0;k+1<LOG;k++){ for(Int i=0;i<=n+1;i++){ nx[k+1][i]=nx[k][nx[k][i]]; pr[k+1][i]=pr[k][pr[k][i]]; sm_nx[k+1][i]=sm_nx[k][i]+sm_nx[k][nx[k][i]]; sm_pr[k+1][i]=sm_pr[k][i]+sm_pr[k][pr[k][i]]; } } Int q; cin>>q; for(Int i=0;i<q;i++){ Int l,r; cin>>l>>r; // [l, r] Int p=l,q=r; Int ans=0; // cout<<l<<newl; // cout<<r<<newl; for(Int k=LOG-1;k>=0;k--){ if(nx[k][p]<=r){ ans-=sm_nx[k][p]; p=nx[k][p]; // cout<<p<<newl; } if(pr[k][q]>=l){ ans+=sm_pr[k][q]; q=pr[k][q]; // cout<<q<<newl; } } // cout<<":"; ans-=p; ans+=q+1; cout<<ans<<newl; } return 0; }
CPP
p02543 ACL Contest 1 - Keep Distances
There are N points on a number line, i-th of which is placed on coordinate X_i. These points are numbered in the increasing order of coordinates. In other words, for all i (1 \leq i \leq N-1), X_i < X_{i+1} holds. In addition to that, an integer K is given. Process Q queries. In the i-th query, two integers L_i and R_i are given. Here, a set s of points is said to be a good set if it satisfies all of the following conditions. Note that the definition of good sets varies over queries. * Each point in s is one of X_{L_i},X_{L_i+1},\ldots,X_{R_i}. * For any two distinct points in s, the distance between them is greater than or equal to K. * The size of s is maximum among all sets that satisfy the aforementioned conditions. For each query, find the size of the union of all good sets. Constraints * 1 \leq N \leq 2 \times 10^5 * 1 \leq K \leq 10^9 * 0 \leq X_1 < X_2 < \cdots < X_N \leq 10^9 * 1 \leq Q \leq 2 \times 10^5 * 1 \leq L_i \leq R_i \leq N * All values in input are integers. Input Input is given from Standard Input in the following format: N K X_1 X_2 \cdots X_N Q L_1 R_1 L_2 R_2 \vdots L_Q R_Q Output For each query, print the size of the union of all good sets in a line. Examples Input 5 3 1 2 4 7 8 2 1 5 1 2 Output 4 2 Input 15 220492538 4452279 12864090 23146757 31318558 133073771 141315707 263239555 350278176 401243954 418305779 450172439 560311491 625900495 626194585 891960194 5 6 14 1 8 1 13 7 12 4 12 Output 4 6 11 2 3
6
0
#pragma region Macros #pragma GCC optimize("O3") #pragma GCC target("avx2,avx") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define ll long long #define ld long double #define rep2(i, a, b) for(ll i = a; i <= b; ++i) #define rep(i, n) for(ll i = 0; i < n; ++i) #define rep3(i, a, b) for(ll i = a; i >= b; --i) #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define eb emplace_back #define vi vector<int> #define vll vector<ll> #define vpi vector<pii> #define vpll vector<pll> #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector<type> name(__VA_ARGS__) #define VEC(type, name, size) \ vector<type> name(size); \ IN(name) #define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__)) #define VV(type, name, h, w) \ vector<vector<type>> name(h, vector<type>(w)); \ IN(name) #define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__))) #define vvvv(type, name, a, b, c, ...) \ vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__)))) #define fi first #define se second #define all(c) begin(c), end(c) #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) using namespace std; string YES[2] = {"NO", "YES"}; string Yes[2] = {"No", "Yes"}; string yes[2] = {"no", "yes"}; template <class T> using pq = priority_queue<T>; template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>; #define si(c) (int)(c).size() #define INT(...) \ int __VA_ARGS__; \ IN(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ IN(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ IN(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ IN(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ IN(__VA_ARGS__) int scan() { return getchar(); } void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(string &a) { cin >> a; } template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); } template <class T> void scan(vector<T> &); template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); } template <class T> void scan(T &a) { cin >> a; } void IN() {} template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); } template <class T, class S> inline bool chmax(T &a, S b) { if(a < b) { a = b; return 1; } return 0; } template <class T, class S> inline bool chmin(T &a, S b) { if(a > b) { a = b; return 1; } return 0; } vi iota(int n) { vi a(n); iota(all(a), 0); return a; } template <typename T> vi iota(vector<T> &a, bool greater = false) { vi res(a.size()); iota(all(res), 0); sort(all(res), [&](int i, int j) { if(greater) return a[i] > a[j]; return a[i] < a[j]; }); return res; } #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()) vector<pll> factor(ll x) { vector<pll> ans; for(ll i = 2; i * i <= x; i++) if(x % i == 0) { ans.push_back({i, 1}); while((x /= i) % i == 0) ans.back().second++; } if(x != 1) ans.push_back({x, 1}); return ans; } template <class T> vector<T> divisor(T x) { vector<T> ans; for(T i = 1; i * i <= x; i++) if(x % i == 0) { ans.pb(i); if(i * i != x) ans.pb(x / i); } return ans; } template <typename T> void zip(vector<T> &x) { vector<T> y = x; sort(all(y)); for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); } } int popcount(ll x) { return __builtin_popcountll(x); } struct Setup_io { Setup_io() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << fixed << setprecision(15); } } setup_io; int in() { int x; cin >> x; return x; } ll lin() { unsigned long long x; cin >> x; return x; } template <typename T> struct edge { int from, to; T cost; int id; edge(int to, T cost) : from(-1), to(to), cost(cost) {} edge(int from, int to, T cost) : from(from), to(to), cost(cost) {} edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {} edge &operator=(const int &x) { to = x; return *this; } operator int() const { return to; } }; template <typename T> using Edges = vector<edge<T>>; using Tree = vector<vector<int>>; using Graph = vector<vector<int>>; template <class T> using Wgraph = vector<vector<edge<T>>>; Graph getG(int n, int m = -1, bool directed = false, int margin = 1) { Tree res(n); if(m == -1) m = n - 1; while(m--) { int a, b; cin >> a >> b; a -= margin, b -= margin; res[a].emplace_back(b); if(!directed) res[b].emplace_back(a); } return move(res); } template <class T> Wgraph<T> getWg(int n, int m = -1, bool directed = false, int margin = 1) { Wgraph<T> res(n); if(m == -1) m = n - 1; while(m--) { int a, b; T c; cin >> a >> b >> c; a -= margin, b -= margin; res[a].emplace_back(b, c); if(!directed) res[b].emplace_back(a, c); } return move(res); } #define i128 __int128_t #define ull unsigned long long int #define TEST \ INT(testcases); \ while(testcases--) template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for(auto &e : v) cout << e << " "; cout << endl; return os; } template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) { cout << "(" << p.fi << ", " << p.se << ")"; return os; } template <class S, class T> string to_string(pair<S, T> p) { return "(" + to_string(p.first) + "," + to_string(p.second) + ")"; } template <class A> string to_string(A v) { if(v.empty()) return "{}"; string ret = "{"; for(auto &x : v) ret += to_string(x) + ","; ret.back() = '}'; return ret; } void dump() { cerr << endl; } template <class Head, class... Tail> void dump(Head head, Tail... tail) { cerr << to_string(head) << " "; dump(tail...); } #define endl '\n' #ifdef _LOCAL #undef endl #define debug(x) \ cout << #x << ": "; \ dump(x) #else #define debug(x) #endif // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); // int rnd(int n) { return uniform_int_distribution<int>(0, n - 1)(rng); } // ll rndll(ll n) { return uniform_int_distribution<ll>(0, n - 1)(rng); } template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2; #pragma endregion int main() { INT(n, k); VEC(int, a, n); INT(Q); vi l(Q), r(Q); rep(i, Q) cin >> l[i] >> r[i]; vll ans(Q); rep(_, 2) { vv(int, nxt, 20, n + 1, n); vv(ll, sum, 20, n + 1); rep(i, n) { nxt[0][i] = lb(a, a[i] + k); sum[0][i] = nxt[0][i]; } rep(i, 19) { rep(j, n) nxt[i + 1][j] = nxt[i][nxt[i][j]], sum[i + 1][j] = sum[i][j] + sum[i][nxt[i][j]]; } rep(i, Q) { ll m = 0; int L = l[i], R = r[i]; if(_) { swap(L, R); R = n + 1 - R, L = n - L; } else L--; int now = L; rep3(j, 19, 0) { if(nxt[j][now] < R) now = nxt[j][now], m += 1 << j; } ans[i] += (m + 1) * R; ans[i] -= L; if(_) ans[i] -= (m + 1) * (R - L); now = L; rep(j, 20) { if(m & 1 << j) ans[i] -= sum[j][now], now = nxt[j][now]; } } reverse(all(a)); rep(i, n) a[i] = -a[i]; } cout << ans; }
CPP