problem_id stringlengths 32 32 | name stringclasses 1
value | problem stringlengths 200 14k | solutions stringlengths 12 1.12M | test_cases stringlengths 37 74M | difficulty stringclasses 3
values | language stringclasses 1
value | source stringclasses 7
values | num_solutions int64 12 1.12M | starter_code stringlengths 0 956 |
|---|---|---|---|---|---|---|---|---|---|
67c552ab54ecde231df648a60e17fca4 | UNKNOWN | Chef has created a special dividing machine that supports the below given operations on an array of positive integers.
There are two operations that Chef implemented on the machine.
Type 0 Operation
Update(L,R):
for i = L to R:
a[i] = a[i] / LeastPrimeDivisor(a[i])
Type 1 Operation
Get(L,R):
result = 1
for i = ... | ["import math\nn=1001\na=[True]*n\nl=[]\nfor i in range(2,33):\n if(a[i]):\n for j in range(i*i,n,i):\n a[j]=False\nfor pr in range(2,1001):\n if(a[pr]):\n l.append(pr)\nt=int(input())\nfor j in range(t):\n n,m=list(map(int,input().strip().split()))\n arr=[int(num) for num in input().strip().split()]\n Matrix =[]\n... | {"inputs": [["2", "6 7", "2 5 8 10 3 44", "1 2 6", "0 2 3", "1 2 6", "0 4 6", "1 1 6", "0 1 6", "1 4 6", "2 2", "1 3", "0 2 2", "1 1 2"]], "outputs": [["5 3 5 11", "1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 986 | |
b13e1710a53422728dbd60c88a106c3b | UNKNOWN | Today is rose day, batch mates of Kabir and Tara decided to celebrate this day by exchanging roses with each other.
Note:$Note:$ exchanging means both the boy and the girl will give rose to each other.
In the class there are B$B$ boys and G$G$ girls.
Exchange of rose will take place if and only if at least one of th... | ["for i in range(int(input())):\n print(2*(sum(list(map(int, input().split())))-1))", "# cook your dish here\nt=int(input())\nwhile(t>0):\n b,g=input().split()\n b=int(b)\n g=int(g)\n ans=(abs(b+g)-1)*2\n print(ans)\n \n t=t-1", "nn=int(input())\nfor i in range(nn):\n l=list(map(int,input().s... | {"inputs": [["1", "2 3"]], "outputs": [["8"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,284 | |
107e886eef13f90967edf707b6fa0b42 | UNKNOWN | The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of... | ["import sys\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\ninp = lambda: list(map(int,sys.stdin.readline().rstrip(\"\\r\\n\").split()))\n#_______________________________________________________________________________\u00a0\u00a0\u00a0\u00a0_______________________\n# from math import *\n# from bisect import... | {"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["0", "0", "1 1", "0", "1 1", "2 3 5", "0", "1 1", "2 3 5", "8 13 21 34"]]} | INTERVIEW | PYTHON3 | CODECHEF | 9,031 | |
f4f2d83f9e1dfc8779e74c4a340ae598 | UNKNOWN | -----Problem-----
Suppose there is a circle. There are N Juice shops on that circle. Juice shops are numbered 0 to N-1 (both inclusive). You have two pieces of information corresponding to each of the juice shop:
(1) the amount of Juice that a particular Juice shop can provide and
(2) the distance from that juice sho... | ["import re,sys\ndef isCirlePossible(juices,distances):\n if juices == [] or distances == []:\n return -1;\n total_juice_consumed = 0\n juice_consumed = 0\n start=0\n for i in range(0,len(juices)):\n diff = juices[i] - distances[i]\n if juice_consumed >= 0:\n juice_consumed += diff\n else:\n juice_consumed = di... | {"inputs": [["3", "1 5", "10 3", "3 4"]], "outputs": [["1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,183 | |
4bef8bd14a30d0548232fb4eebf8f1d0 | UNKNOWN | All strings in Chefland are beautiful because they are binary strings (a binary string contains only characters '0' and '1'). The beauty of a binary string $S$ is defined as the number of pairs $(i, j)$ ($1 \le i \le j \le |S|$) such that the substring $S_i, S_{i+1}, \ldots, S_j$ is special.
For a binary string $U$, le... | ["t = int(input())\nfor _ in range(t):\n s = input()\n pref = [0]*len(s)\n if s[0]==\"1\":\n pref[0]+=1\n for i in range(1,len(s)):\n if s[i]==\"1\":\n pref[i]+=1\n pref[i]=pref[i]+pref[i-1]\n k=1\n cnt=0\n while (k+k*k)<=len(s):\n r = k+k*k\n i=r-1\n while i<len(s):\n if (i-r)>=0:\n if pref[i]-pref[i-r]==... | {"inputs": [["2", "010001", "10"]], "outputs": [["4", "1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 10,724 | |
6fd3387fab02c49514970fb7f54e0c09 | UNKNOWN | Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited choices when naming a new dish.
For the given positive integer N, your tas... | ["# cook your dish here\ndef permutation(n,p):\n r=26\n if n==1:\n return 26\n elif n==2:\n return 52\n elif n==3:\n return 728\n else:\n if n%2==0:\n return ((2*(bin_expo(r,((n//2)+1),p)-r)*bin_expo(25,1000000005,p)))%p\n else:\n n=n+1\n ... | {"inputs": [["5", "1", "2", "3", "4", "100", "", ""]], "outputs": [["26", "52", "728", "1404", "508533804"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,611 | |
73b5f5a6d8ecf6ac7fe1434bf3789535 | UNKNOWN | The kingdom of the snakes is an NxN grid. Their most-valued possession is a huge collection of poison, which is stored in the central KxK grid. It is guaranteed that both N and K are odd. What we mean by 'central' is this: suppose in the NxN grid, (i, j) refers to the cell in the i-th row and j-th column and (1,1) refe... | ["'''input\n2\n7 3 5\n5 2 5 2\n2 4 2 6\n6 2 6 4\n5 6 5 7\n7 1 7 4\n7 3 7\n1 1 6 1\n1 2 3 2\n5 2 5 2\n2 6 2 6\n6 2 6 4\n5 6 5 7\n7 1 7 4\n'''\n\nfor _ in range(int(input())):\n n, k, m = list(map(int, input().split()))\n row_s = []\n col_s = []\n for _ in range(m):\n h_x, h_y, t_x, t_y = list(map(int, input().split()))... | {"inputs": [["2", "7 3 7", "1 1 6 1", "1 2 3 2", "5 2 5 2", "2 4 2 6", "6 2 6 4", "5 6 5 7", "7 1 7 4", "7 3 7", "1 1 6 1", "1 2 3 2", "5 2 5 2", "2 6 2 6", "6 2 6 4", "5 6 5 7", "7 1 7 4"]], "outputs": [["3", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,003 | |
e56906e8a0cd560a7b70256feb33b306 | UNKNOWN | In this problem, you will be given a polynomial, you have to print what it becomes after differentiation.
Following are the rules for differentiation:
- For a polynomial f(x), its differentiation is defined as f'(x).
- If a is a constant, then differentiation of af(x) is af'(x).
- If f(x) = h(x) + g(x) , then f'(x) = ... | ["def ans(l):\n s = \"\"\n i = 0\n while (i < len(l)):\n temp = l[i]\n k = temp[1]\n if (k != 0):\n s += str(temp[0]) + \"x^\" + str(k)\n else:\n s += str(temp[0])\n i += 1\n if (i < len(l)):\n s += \" + \"\n if (len(s) > 0):\n return s\n else:\n return \"0\"\n \ntest = int(input())\nwhile (test != 0):\n ... | {"inputs": [["2", "1", "1 2", "3", "1 3", "1 1", "1 0"]], "outputs": [["2x^1", "3x^2 + 1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 12,054 | |
96f7c6a69cb3e5a183fd2ef9c0714340 | UNKNOWN | Petya is preparing a problem for a local contest in his school. The problem is to find a longest increasing subsequence in a given permutation. A permutation of size n$n$ is a sequence of n$n$ numbers a1,…,an$a_1, \ldots, a_n$ such that every number from 1$1$ to n$n$ occurs in the sequence exactly once. An increasing s... | ["# cook your dish here\nfor _ in range(int(input())):\n n,k = [int(c) for c in input().split()]\n a = [int(c) for c in input().split()]\n ls = a\n if n==1:\n print(\"YES\")\n print(1)\n continue\n if k==1:\n print(\"NO\")\n continue\n \n if k==2 and n>2:\n ... | {"inputs": [["2", "3 2", "1 2", "2 1", "1"]], "outputs": [["YES", "2 3 1", "NO"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,048 | |
544f3f43bf48f78de00b8cd30900aa7f | UNKNOWN | The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants.
There were N elephants ordered from the left to the right in a row and numbered from 0 to N-1. Let R[i] to be the result of... | ["def magic():\n def check(art,k,m):\n n=len(art)\n for i in range(n-k+1):\n maxi=0\n maxi=max(art[i:i+k])\n\n total=0\n total=art[i:i+k].count(maxi)\n\n if total>=m:\n return False\n\n return True\n \n\n\n for _ in range(eval(input())):\n n,k,m=list(map(int,input().split()))\n arr=list(map(int,input... | {"inputs": [["4", "5 3 2", "1 3 1 2 1", "5 3 3", "7 7 7 7 7", "5 3 3", "7 7 7 8 8", "4 3 1", "1 3 1 2"]], "outputs": [["0", "1", "1", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 609 | |
7ecdd7ad1bd3aa81d73ff76c5ce10861 | UNKNOWN | Today, Chef decided to cook some delicious meals from the ingredients in his kitchen. There are $N$ ingredients, represented by strings $S_1, S_2, \ldots, S_N$. Chef took all the ingredients, put them into a cauldron and mixed them up.
In the cauldron, the letters of the strings representing the ingredients completely ... | ["# cook your dish here\nt=int(input())\nwhile t>0:\n n=int(input())\n li=[]\n c,o,d,e,h,f=0,0,0,0,0,0\n for i in range(0,n):\n s=input()\n \n for i in range(len(s)):\n if s[i]=='c':\n c=c+1\n elif s[i]=='o':\n o=o+1\n elif s[i]=='d':\n d=d+1\n elif s[i]=='e':\n e=e+1\n elif s[i]=='h':\n h=h... | {"inputs": [["3", "6", "cplusplus", "oscar", "deck", "fee", "hat", "near", "5", "code", "hacker", "chef", "chaby", "dumbofe", "5", "codechef", "chefcode", "fehcedoc", "cceeohfd", "codechef"]], "outputs": [["1", "2", "5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 7,882 | |
83371756082ea3e36a10839b4038b722 | UNKNOWN | To protect people from evil,
a long and tall wall was constructed a few years ago.
But just a wall is not safe, there should also be soldiers on it,
always keeping vigil.
The wall is very long and connects the left and the right towers.
There are exactly N spots (numbered 1 to N) on the wall for soldiers.
The Kth... | ["D=[0]*31\nD[1]=2\nD[2]=5\n\nfor i in range(3,31):\n best=10**10\n for p in range(1,i+1):\n best=min(best,D[p-1]+D[i-p]+i+1)\n D[i]=best\n\nt=int(input())\nfor i in range(t):\n n,m=list(map(int,input().split()))\n maxi=(n+2)*(n+1)/2-1\n mini=D[n]\n if mini<=m<=maxi: print(0)\n elif m<mini: print(-1)\n else: print(m-m... | {"inputs": [["4", "3 8", "3 9", "2 4", "5 25"]], "outputs": [["0", "0", "-1", "5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,916 | |
38e63987f491d5cf5965d54569ebfdc4 | UNKNOWN | Given a square matrix of size N×N, calculate the absolute difference between the sums of its diagonals.
-----Input-----
The first line contains a single integer N. The next N lines denote the matrix's rows, with each line containing N space-separated integers describing the columns.
-----Output-----
Print the absolu... | ["def diagonal_difference(matrix):\n l = sum(matrix[i][i] for i in range(N))\n r = sum(matrix[i][N-i-1] for i in range(N))\n return abs(l - r)\n\nmatrix = []\nN = eval(input())\nfor _ in range(N):\n matrix.append(list(map(int, input().split())))\n\nprint(diagonal_difference(matrix))"] | {"inputs": [["3", "11 2 4", "4 5 6", "10 8 -12"]], "outputs": [["15"]]} | INTERVIEW | PYTHON3 | CODECHEF | 285 | |
da716ee516449416c91135919e6e8b4c | UNKNOWN | You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | ["t=int(input())\nfor _ in range(t):\n n,m=map(int,input().split())\n d={}\n e={}\n l=[]\n for i in range(n):\n d[i]=0\n for i in range(m):\n e[i]=0\n for i in range(n):\n l.append(input())\n for i in range(n):\n for j in range(m):\n if l[i][j]=='1':\n d[i]=1\n e[j]=1\n #ans=[]\n if sum(d.values())+sum(e.va... | {"inputs": [["1", "3 3", "010", "000", "001"]], "outputs": [["1 0 1", "2 1 1", "1 1 0"]]} | INTERVIEW | PYTHON3 | CODECHEF | 7,521 | |
2dc6f5cebeaa3f2f22817e61c293b833 | UNKNOWN | Every Friday Chef and his N - 1 friends go for a party. At these parties, they play board games. This Friday, they are playing a game named "Boats! Boats! Boats!". In this game players have to transport cookies between Venice and Constantinople. Each player has a personal storage. The players are numbered from 1 to N, ... | ["# cook your code here\nfor _ in range(eval(input())):\n n=eval(input())\n ind=0\n m=-1\n \n for i in range(n):\n \n l=[int(x) for x in input().split()]\n sc=l[0]\n for j in range(1,len(l)):\n sc+=int(l[j]>=4)+int(l[j]>=5)+2*int(l[j]>=6)\n if sc==m:\n ind=-2\n if sc>m :\n m=sc\n ind=i+1\n \n \n if (in... | {"inputs": [["3", "2", "6 1 2 3 4 5 6", "9 3 3 3 4 4 4 5 5 5", "2", "5 2 3 4 5 6", "7 1 1 2 2 3 3 4", "3", "4 1 1 2 3", "4 1 2 2 3", "4 1 2 3 3"]], "outputs": [["chef", "2", "tie"]]} | INTERVIEW | PYTHON3 | CODECHEF | 8,650 | |
8be7bc43baf9dbce36b4930b12d9bf36 | UNKNOWN | -----Indian National Olympiad in Informatics 2014-----
Nikhil’s slogan has won the contest conducted by Drongo Airlines and he is entitled to a free ticket between any two destinations served by the airline. All cities served by Drongo Airlines can be reached from each other by some sequence of connecting flights. Nikh... | ["c,f=list(map(int,input().split()))\r\nl=[[1000001 for i in range(c)] for j in range(c)] \r\nwhile f:\r\n x,y,cost=list(map(int,input().split()))\r\n l[x-1][y-1]=cost\r\n l[y-1][x-1]=cost\r\n f-=1 \r\nfor i in range(c):\r\n l[i][i]=0\r\nfor k in range(c): \r\n for x in range(c):\r\n for y in ... | {"inputs": [["4 5", "1 2 10", "1 3 24", "2 3 2", "2 4 15", "3 4 7"]], "outputs": [["19", "Note : Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your final submission. A program with extraneous output will be treated a... | INTERVIEW | PYTHON3 | CODECHEF | 26,346 | |
b103bf3119219e0a31a4a4f4b212223e | UNKNOWN | Alice and Bob are walking on an infinite straight street. Initially, both are at the position $X=0$ and they start walking in the direction of increasing $X$. After $N$ seconds, they stop. Let's denote Alice's speed and Bob's speed during the $i$-th of these seconds by $A_i$ and $B_i$ respectively.
Sometimes, Alice and... | ["# cook your dish here\nfor tc in range(int(input())):\n \n n = int(input())\n \n li1 = list(map(int,input().split(' ')))\n li2 = list(map(int,input().split(' ')))\n walk = 0\n sum1 = 0 \n sum2 = 0\n for i in range(n):\n if li1[i] == li2[i] and sum1 == sum2:\n walk += li1[i]\n sum1 += li1[i]\n sum2 += li2[i]\n pr... | {"inputs": [["3", "4", "1 3 3 4", "1 2 4 4", "2", "2 3", "3 2", "2", "3 3", "3 3"]], "outputs": [["5", "0", "6"]]} | INTERVIEW | PYTHON3 | CODECHEF | 9,160 | |
d60a60f592ce0324e71b9877b8a6d591 | UNKNOWN | Given a string consisting of only lowercase English alphabets, your task is to find the smallest palindromic substring.
In case there are multiple palindromic substrings of the same length present, print the lexicographically smallest substring.
Formally, a substring is a contiguous sequence of characters within a str... | ["# cook your dish here\nT = int(input())\nfor t in range(T):\n N = int(input())\n s = sorted(list(str(input())))\n print(s[0])", "for t in range(int(input())):\n n=int(input())\n s=sorted(list(str(input())))\n print(s[0])", "T = int(input())\nfor t in range(T):\n N = int(input())\n s = sorted(list(str(input())... | {"inputs": [["2", "2", "zy", "1", "cd"]], "outputs": [["y", "c"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,735 | |
a0fbd95137bc88389f852095703e8a07 | UNKNOWN | Chef has $N$ markers. There is a cap on each marker. For each valid $i$, the $i$-th marker has colour $a_i$. Initially, for each valid $i$, the colour of the cap on the $i$-th marker is also $a_i$.
Chef wants to rearrange the caps in such a way that no marker has the same colour as its cap. (Obviously, each marker must... | ["# cook your dish here\nfrom collections import Counter,defaultdict\n\nfor i in range(int(input())):\n n=int(input())\n arr=list(map(int,input().split()))\n coun=Counter(arr)\n check=True\n\n for j in coun:\n if coun[j]>n//2:\n print(\"No\")\n check=False\n break\n\n\n\n\n if check==True:\n print(\"Yes\")\n n... | {"inputs": [["2", "9", "1 1 1 2 2 2 3 3 3", "2", "1 1"]], "outputs": [["Yes", "2 2 2 3 3 3 1 1 1", "No"]]} | INTERVIEW | PYTHON3 | CODECHEF | 14,062 | |
ebf201c2f350cdbed16e83fedb226474 | UNKNOWN | Harish has decided to go to Arya's hotel this morning. We all know he is crazy for masala dosas. And as usual he is always hungry. He decided to order all the masala dosas at once. But then he realised that he did not have enough money to buy all of them. So he decided to share the amount with his friend Ozil. But both... | ["for _ in range(eval(input())):\n n=eval(input())\n if n%2:\n print('NO')\n else:\n print('YES') ", "tc=int(input())\nfor case in range(tc):\n n=int(input())\n if n%4==0:\n print(\"YES\")\n else:\n print(\"NO\")\n", "t = eval(input())\nwhile t:\n t=~(-t)\n n = eval(input())\n print(\"NO\" if (n==2 or n%2!=0) else ... | {"inputs": [["2", "16", "27"]], "outputs": [["YES", "NO"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,312 | |
8a54c9616af961421ddb7d3bb6b00e8c | UNKNOWN | Gargi is thinking of a solution to a problem. Meanwhile, her friend asks her to solve another problem. Since Gargi is busy in her own problem, she seeks your help to solve the new problem.
You are given a string S containing characters a-z (lower case letters) only. You need to change the string to a new string consis... | ["t = int(input())\nfor i in range(t):\n s = input().rstrip()\n sumv = 0\n for j in range(len(s)):\n sumv += ord(s[j])\n minv = 10 ** 8;\n for i in range(ord('a'), ord('z') + 1):\n val = abs(sumv - i * len(s))\n if minv > val:\n minv = val\n print(minv)", "for t in range(int(input())):\n s = input()\n a = [0]*26\n... | {"inputs": [["1", "abba"]], "outputs": [["2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 457 | |
cfdbf34a9c9c92975a734ce52b0ffc44 | UNKNOWN | Rodriguez is a happy and content farmer. He has got a square field of side length $x$. Miguel, his son has himself grown into a man and his father wants to gift him something out of which he can make a living. So he gift's his son a square piece of land cut out from a corner of his field of side length $ y (y < x) $ le... | ["from math import sqrt\ndef isPrime(n):\n for i in range(2, int(sqrt(n))+1):\n if(n%i==0): return True\n return False\nans = []\nfor _ in range(int(input())):\n x, y = map(int, input().split())\n ans.append('NO' if(isPrime(x**2-y**2)) else 'YES')\nprint('\\n'.join(ans))"] | {"inputs": [["2", "7 5", "6 5"]], "outputs": [["YES", "NO"]]} | INTERVIEW | PYTHON3 | CODECHEF | 274 | |
c45f8d3364a530ba7aba47427abdf17f | UNKNOWN | Calculate the power of an army of numbers from 1 to $N$, both included.
-----Input:-----
- First line will contain a single integer $N$.
-----Output:-----
For each testcase, output in a single line containing the answer.
-----Constraints-----
- $1 \leq N \leq 5000$
-----Sample Input:-----
24
-----Sample Output:---... | ["# cook your dish here\n# cook your dish here\n#powerful numbers\nn = int(input())\nplist = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, ... | {"inputs": [["24"]], "outputs": [["5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,036 | |
b566d47c8788b0495bb6a8552cc03110 | UNKNOWN | Mr. X stays in a mansion whose door opens in the North. He travels every morning to meet his friend Ms. Y walking a predefined path.
To cut the distance short, one day he decides to construct a skywalk from his place to his friend’s place. Help him to find the shortest distance between the two residences.
-----Input... | ["#!/usr/bin/env python\n\nfrom math import sqrt\n\ndef process(S):\n P = [0,0,'S']\n for i in S:\n if i == 'L':\n if P[-1] == 'N': P[-1] = 'W'\n elif P[-1] == 'S': P[-1] = 'E'\n elif P[-1] == 'E': P[-1] = 'N'\n elif P[-1] == 'W': P[-1] = 'S'\n elif i == 'R':\n if P[-1] == 'N': P[-1] = 'E'\n elif P[-1] ==... | {"inputs": [["1", "2 L 2 R 2 L 1"]], "outputs": [["5.0NW"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,812 | |
f8c75ab83bf4fa75e4d844ba3649a8f5 | UNKNOWN | There is a field with plants — a grid with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$); out of its $NM$ cells, $K$ cells contain plants, while the rest contain weeds. Two cells are adjacent if they have a common side.
You want to build fences in the field in such a way that the follow... | ["t=int(input())\nwhile(t):\n t-=1\n d={}\n n,m,k=[int(x) for x in list(input().split())]\n sum=0\n while(k):\n k-=1\n x,y=[int(x) for x in list(input().split())]\n a=[-1,1,0,0]\n b=[0,0,-1,1]\n for i in range(4):\n if((x+a[i],y+b[i]) in d):\n sum-=1\n else:\n sum+=1\n d[(x,y)]=1\n print(sum)", "# cook ... | {"inputs": [["2", "4 4 9", "1 4", "2 1", "2 2", "2 3", "3 1", "3 3", "4 1", "4 2", "4 3", "4 4 1", "1 1"]], "outputs": [["20", "4"]]} | INTERVIEW | PYTHON3 | CODECHEF | 11,932 | |
bd83eec19565fde704face86aaeb8071 | UNKNOWN | Given a positive integer K > 2, with prime
factorization:
K = p1^a1 * p2^a2 ... * pn^an
Compute the following:
S = a1*p1 + a2*p2 ... + an*pn.
-----Input-----
A list of <100 integers, one on each line,
all less than $2*10^{18}$.
-----Output-----
For each integer compute the super factor
sum and output it on a singl... | ["import random\nimport os\nyash=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401... | {"inputs": [["6", "7"]], "outputs": [["5", "7"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,140 | |
face38b2779a16dfaad19f9f19efa680 | UNKNOWN | Rakesh has built a model rocket and wants to test how stable it is. He usually uses a magic box which runs some tests on the rocket and tells if it is stable or not, but his friend broke it by trying to find out how stable he is (very delicate magic indeed). The box only gives a polynomial equation now which can help R... | ["import random\n\ndef sign(i):\n if i>0:\n return 1\n elif i<=0:\n return 0\nbleh = []\nfor _ in range(int(input())):\n p = list(map(int,input().rstrip().split()))\n max_rows = len(p)\n if all([x==0 for x in p]):\n print(1)\n continue\n if max_rows <= 1:\n bleh.appe... | {"inputs": [["1", "10 12 4 5 3"]], "outputs": [["0"]]} | INTERVIEW | PYTHON3 | CODECHEF | 10,774 | |
1248a47ab904d4bf8a26ff8f5903a0f6 | UNKNOWN | Yesterday, Chef found $K$ empty boxes in the cooler and decided to fill them with apples. He ordered $N$ apples, where $N$ is a multiple of $K$. Now, he just needs to hire someone who will distribute the apples into the boxes with professional passion.
Only two candidates passed all the interviews for the box filling ... | ["# cook your dish here\nt=int(input())\nfor i in range(t,0,-1):\n x,y=map(int,input().split())\n k=x//y\n \n if k%y==0:\n print(\"NO\")\n else:\n print(\"YES\")", "# cook your dish here\nt = int(input())\nfor _ in range(t):\n n,k = map(int,input().split())\n if(n%(k*k)==0):\n print(\"NO\")\n else:\n print(\"YES\")... | {"inputs": [["3", "5 1", "4 2", "10 10"]], "outputs": [["NO", "NO", "YES"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,298 | |
718548a7c0cc8c323dcd8eb87bf44802 | UNKNOWN | The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K (odd) to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single li... | ["t=int(input())\nfor _ in range(t):\n n=int(input())\n l1=[]\n if n==1:\n print('*')\n elif n==3:\n print('*')\n print('**')\n print('*')\n else:\n s1=\"\"\n n1=n//2\n n1+=1 \n for i in range(1,n1+1):\n s1=\"\"\n if i==1:\n ... | {"inputs": [["4", "1", "3", "5", "7"]], "outputs": [["*", "*", "**", "*", "*", "**", "* *", "**", "*", "*", "**", "* *", "* *", "* *", "**", "*"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,893 | |
5d5883e3a3df6ca8924ff5d73c9665dc | UNKNOWN | You want to build a temple for snakes. The temple will be built on a mountain range, which can be thought of as n blocks, where height of i-th block is given by hi. The temple will be made on a consecutive section of the blocks and its height should start from 1 and increase by exactly 1 each time till some height and ... | ["# cook your dish here\n\nt = int(input())\nwhile t:\n t -= 1\n n = int(input())\n arr = list(map(int, input().split()))\n sumi = sum(arr)\n prev = 1\n for i in range(n):\n arr[i] = min(arr[i], prev)\n prev = arr[i] + 1\n prev = 1\n for i in range(n - 1, -1, -1):\n arr[i] = min(arr[i], prev)\n prev = arr[i] + 1\n ... | {"inputs": [["3", "3", "1 2 1", "4", "1 1 2 1", "5", "1 2 6 2 1"]], "outputs": [["0", "1", "3"]]} | INTERVIEW | PYTHON3 | CODECHEF | 11,362 | |
1dc66b22527270709ee0f1ab8aaf93db | UNKNOWN | Given a complete binary tree with the height of H, we index the nodes respectively top-down and left-right from 1. The i-th node stores a positive integer Vi. Define Pi as follows: Pi=Vi if the i-th node is a leaf, otherwise Pi=max(Vi*PL, Vi*PR), where L and R are the indices of the left and right children of i, respec... | ["def treeProduct(num, h, root, ch):\n if ch >= h:\n return num[root]\n\n left = (root * 2) + 1\n right = (root * 2) + 2\n\n ret1 = treeProduct(num, h, left, ch + 1)\n ret2 = treeProduct(num, h, right, ch + 1)\n\n return num[root] * max(ret1, ret2)\n\ndef main():\n n = int(input())\n while n!=0:\n line = str(input())... | {"inputs": [["2", "1 2 3", "3", "3 1 5 2 6 4 7", "0"]], "outputs": [["3", "105"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,013 | |
d5d1238b44c2fa679f5073fa13ca07a8 | UNKNOWN | Chef received a new sequence $A_1, A_2, \ldots, A_N$. He does not like arbitrarily ordered sequences, so he wants to permute the elements of $A$ in such a way that it would satisfy the following condition: there is an integer $p$ ($1 \le p \le N$) such that the first $p$ elements of the new (permuted) sequence are stri... | ["for _ in range(int(input())):\n n = int(input())\n\n arr= list(map(int,input().split()))\n arr.sort()\n d={}\n for i in arr:\n if i not in d:\n d[i]=1\n else:\n d[i]+=1\n \n flag = True\n for i in d:\n if d[i]>2:\n flag=False\n break\n \n \n\n if arr.count(max(arr))!=1:\n flag=False\n \n \n if flag==Tru... | {"inputs": [["5", "4", "1 3 2 4", "4", "1 3 2 4", "6", "1 10 10 10 20 15", "5", "1 1 2 2 3", "4", "1 2 3 3"]], "outputs": [["YES", "1 2 3 4", "YES", "4 3 2 1", "NO", "YES", "1 2 3 2 1", "NO"]]} | INTERVIEW | PYTHON3 | CODECHEF | 13,142 | |
40f0bb51eeb0be718e436d6e99161846 | UNKNOWN | Chef has a cubic die with 6 faces kept on an infinite plane. Each face has a distinct integer in the range [1,6] written on it, but the exact arrangement of the numbers on the faces of the die is unknown to Chef. Curiosity gets the better of Chef and he wants to find out o(1), o(2), ..., o(6), where o(i) is the number... | ["from itertools import permutations\n\ndef solve(n,a):\n ans=[]\n \n for des in desire:\n check=1\n for i in range(n-1):\n \n if (a[i]==a[i+1]):\n return [-1]\n if a[i+1]==des[a[i]-1]:\n check=0\n break\n if check:\n ans=des\n break\n if ans:\n return ans\n return [-1]\n \n\nper=permutations([... | {"inputs": [["4", "9", "1 3 4 6 1 3 4 6 1", "10", "1 2 1 3 1 4 1 5 1 6", "6", "1 2 3 4 5 6", "4", "1 3 3 1"]], "outputs": [["2 1 6 5 4 3", "-1", "4 5 6 1 2 3", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 701 | |
5346615931a8975faa163d9fea63c8b7 | UNKNOWN | The Government of Siruseri is no different from any other when it comes to being "capital-centric" in its policies. Recently the government decided to set up a nationwide fiber-optic network to take Siruseri into the digital age. And as usual, this decision was implemented in a capital centric manner --- from each city... | ["n=int(input())\r\nl=[]\r\nfor i in range(n):\r\n\tl.append([int(x) for x in input().split()])\r\nd=[10**9]*(n)\r\nq=set([int(x) for x in range(1,n)])\r\nd[1]=0\r\n#print(q)\r\ndef extract():\r\n\tmini=10**9\r\n\to=0\r\n\tfor i in range(1,len(d)):\r\n\t\tif d[i]<mini and i in q:\r\n\t\t\tmini=d[i]\r\n\t\t\to=i\r\n\tq.... | {"inputs": [["4", "0 7 8 10", "7 0 4 5", "8 4 0 6", "10 5 6 0"]], "outputs": [["9"]]} | INTERVIEW | PYTHON3 | CODECHEF | 486 | |
1456016076d98eebd60a0a454019558d | UNKNOWN | Some programming contest problems are really tricky: not only do they
require a different output format from what you might have expected, but
also the sample output does not show the difference. For an example,
let us look at permutations.
A permutation of the integers 1 to n is an
ordering of
these integers. So the ... | ["def invper(ar):\n ar1=[0]*(len(ar))\n for i in range(len(ar)):\n ar1[ar[i]-1]=i+1\n return ar1\nt=int(input())\n\nwhile(t!=0):\n ar=list(map(int,input().split()))\n ar1=invper(ar)\n if(ar==ar1):\n print(\"ambiguous\")\n else:\n print(\"not ambiguous\")\n t = int(input())\n", "while int(input()) != 0:\n l = list(ma... | {"inputs": [["4", "1 4 3 2", "5", "2 3 4 5 1", "1", "1", "0"]], "outputs": [["ambiguous", "not ambiguous", "ambiguous"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,924 | |
a90629277dbc6c53b427555ae37b3217 | UNKNOWN | There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Chef decided that electricity should be provided to all the villages. So, he d... | ["for _ in range(int(input())):\n n=int(input())\n s=list(input())\n coord=list(map(int,input().split()))\n p=0\n i=0\n h=[]\n for i in range(0,n):\n if s[i]=='1':\n h.append(i)\n if h[0]!=0:\n p=p+coord[h[0]]-coord[0]\n if h[len(h)-1]!=n-1:\n p=p+coord[n-1]-coord[h[len(h)-1]]\n for j in range(0,len(h)-1):\n if h... | {"inputs": [["2", "2", "01", "1 2", "3", "100", "1 5 6"]], "outputs": [["1", "5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,744 | |
3fd686a27e54b164b234a31a341e6a95 | UNKNOWN | Many internet protocols these days include the option of associating a
media type with the content being sent.
The type is usually inferred from the file extension.
You are to write a program that facilitates the lookup of media types for
a number of files.
You will be given a table of media type associations that asso... | ["# cook your dish here\nn,m=list(map(int,input().split()))\na={}\nfor i in range(n):\n x,y=input().split()\n a[x]=y\nfor i in range(m):\n c=input().strip()\n if '.' not in c:\n print(\"unknown\")\n else:\n h=c.split('.')[-1]\n if h in a:\n print(a[h])\n else:\n print('unknown')\n \n \n", "# cook your dish her... | {"inputs": [["5 6", "html text/html", "htm text/html", "png image/png", "svg image/svg+xml", "txt text/plain", "index.html", "this.file.has.lots.of.dots.txt", "nodotsatall", "virus.exe", "dont.let.the.png.fool.you", "case.matters.TXT"]], "outputs": [["text/html", "text/plain", "unknown", "unknown", "unknown", "unknown"... | INTERVIEW | PYTHON3 | CODECHEF | 7,331 | |
198c6d155fc3cf8304a6a435ffdcde31 | UNKNOWN | It's autumn now, the time of the leaf fall.
Sergey likes to collect fallen leaves in autumn. In his city, he can find fallen leaves of maple, oak and poplar. These leaves can be of three different colors: green, yellow or red.
Sergey has collected some leaves of each type and color. Now he wants to create the biggest n... | ["for t in range(int(input())):\r\n\tl1=list(map(int,input().split()))\r\n\tl2=list(map(int,input().split()))\r\n\tl3=list(map(int,input().split()))\r\n\tmax=0\r\n\tg=l1[0]+l2[0]+l3[0]\r\n\ty=l1[1]+l2[1]+l3[1]\r\n\tr=l1[2]+l2[2]+l3[2]\r\n\tif g%2==0:\r\n\t\tg-=1\r\n\tif y%2==0:\r\n\t\ty-=1\r\n\tif r%2==0:\r\n\t\tr-=1\r... | {"inputs": [["1", "1 2 3", "3 2 1", "1 3 4"]], "outputs": [["7"]]} | INTERVIEW | PYTHON3 | CODECHEF | 671 | |
441dac497d9bff3a9c131ada44e80b93 | UNKNOWN | Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 2. If any of the permutations is divisible by 2 then print 1 else print 0.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single... | ["# cook your dish here\nfor i in range(int(input())):\n n = int(input())\n flag = 0\n while(n>0):\n if((n%10)%2 == 0):\n flag = 1\n break\n n = n//10\n if(flag == 0):\n print(0)\n else:\n print(1)", "testcases=int(input())\r\nfor i in range(testcases):\r... | {"inputs": [["2", "19", "385"]], "outputs": [["0", "1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 9,823 | |
2975b5b0115872520881482a141a0d0d | UNKNOWN | Akshay is interested in mathematics, one day he came across a problem of modulus operator.He has a list of M integers say arr[M] and has to find all integers K such that :
- K > 1
- arr[1]%K = arr[2]%K = arr[3]%K = … = arr[M]%K where '%' is a modulus operator.
Help Akshay to find all such K's.
-----Input:-----
- Firs... | ["l = []\nfor _ in range(int(input())):\n l.append(int(input()))\nfor i in range(2,max(l)):\n r = [x%i for x in l]\n if len(set([x%i for x in l])) == 1:\n print(i, end = ' ')\n", "def find_gcd(x, y): \r\n\t\r\n\twhile(y): \r\n\t\tx, y = y, x % y \r\n\t\r\n\treturn x \r\n\t\t\r\ndef print_factors(x):\r\n... | {"inputs": [["3", "38", "6", "34"]], "outputs": [["2 4"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,793 | |
7a19494ac163fdbc1b0f9195f4ce0912 | UNKNOWN | Saket loves to play with strings. One day , while he was having fun with Cyclic Permutations of available strings to him, he observed that despite being scarce in numbers Vowels were really clingy.Being clingy means for almost every given string, there was a Cyclic Permutation in which atleast two vowels were together.... | ["for t in range(int(input())):\r\n\tn=int(input())\r\n\ts=input().strip()\r\n\tc=0\r\n\tflag=0\r\n\tfor i in range(n):\r\n\t\tif (s[i]==\"A\" or s[i]==\"E\" or s[i]==\"I\" or s[i]==\"O\" or s[i]==\"U\") and (s[i-1]==\"A\" or s[i-1]==\"E\" or s[i-1]==\"I\" or s[i-1]==\"O\" or s[i-1]==\"U\") :\r\n\t\t\tflag=1\r\n\tif fl... | {"inputs": [["2", "5", "AUXFC", "6", "XBCDEF"]], "outputs": [["Yes", "No"]]} | INTERVIEW | PYTHON3 | CODECHEF | 8,474 | |
d4946c93421866d8db577c84b27dc323 | UNKNOWN | Everyone loves short problem statements.
Given a function $ f(x) $ find its minimum value over the range $ 0 < x < π/2$
$
f(x) = ( x^2 + b*x + c ) / sin( x )
$
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two re... | ["import sys\nimport math\ninput=sys.stdin.readline\ndef binary(l,r,co,b,c):\n x=(l+r)/2\n #print(x)\n val1=(2*x+b)*math.sin(x)\n val2=(x**2+b*x+c)*math.cos(x)\n x=(l+r)/2\n val=val1-val2\n if(abs(val)<.0000001 or co==150):\n return (l+r)/2\n if(val<0):\n return binary((l+r)/2,r,co+1,b,c)\n else:\n return binary(l,(... | {"inputs": [["1", "2 2"]], "outputs": [["5.8831725615"]]} | INTERVIEW | PYTHON3 | CODECHEF | 1,062 | |
257bab1e5470ac9e75dd0c373526085b | UNKNOWN | Tara was completing an Algorithms assignment and got stuck on a question. She thought of who can help her, and got reminded of Kabir who has good problem solving skills. The question is:
Given N$N$ the number of elements in the sequence A1$A_1$,A2$A_2$ … An$A_n$. Find out the prime factor which occurred maximum number ... | ["# cook your dish here\nstore=[0]*(10**5+1)\ndef sieve():\n\tfor i in range(2,10**5+1):\n\t\tif(store[i]==0):\n\t\t\tstore[i]=1\n\t\t\tfor j in range(i,10**5+1,i):\n\t\t\t\tstore[j]=i\nsieve()\n# print(store)\nfor _ in range(int(input())):\n\t\n\tn=int(input())\n\tli=[int(x) for x in input().split()]\n\n\tdp=[0]*(10**... | {"inputs": [["1", "7", "3 2 15 6 8 5 10"]], "outputs": [["5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,959 | |
849de040c669cba615ea2e51e7afc92a | UNKNOWN | Sereja has a string A consisting of n lower case English letters.
Sereja calls two strings X and Y each of length n similar if they can be made equal by applying the following operation at most once in each of them.
- Chose any two position i, j in the string (i can be equal to j too). Swap the characters at positio... | ["import math\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modin(a, m):\n g, x, y = egcd(a, m)\n return x % m\n# def gcdexten(a,b,x,y):\n# \tif a == 0:\n# \t\tx = 0\n# \t\ty = 1\n# \t\treturn b\n# \tx1 = y1 ... | {"inputs": [["2", "z", "abcd", "", ""]], "outputs": [["0", "144"]]} | INTERVIEW | PYTHON3 | CODECHEF | 46,873 | |
2ab32706ee814f9afd9a91c07cb7c0d4 | UNKNOWN | Chef spent N days working really hard! He planned loads of tasks: as many as Ai tasks to do on the ith day! Chef's work was brutal, so he only managed to finish Bi tasks on the ith day.
The good news is that Chef has a Time Machine!
The Time Machine has K white buttons and M black buttons. Each button has a positive i... | ["t=int(input())\n\ndef diffe(a,b):\n return int(a-b)\n\nwhile t :\n t=t-1\n \n lia=[]\n lib=[]\n lik=[]\n lim=[]\n liab=[]\n likm=[]\n n,k,m=list(map(int,input().split()))\n \n \n lia=list(map(int,input().split()))\n lib=list(map(int,input().split()))\n lik=list(map(int,input().split()))\n lim=list(map(int,input().spl... | {"inputs": [["1", "4 2 2", "5 7 6 1", "3 3 1 1", "6 3", "1 4"]], "outputs": [["3"]]} | INTERVIEW | PYTHON3 | CODECHEF | 15,897 | |
37694cce1016223375dffec212f6bf49 | UNKNOWN | The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of... | ["t=int(input())\nwhile(t):\n n=int(input())\n cnt=1;\n for i in range(n):\n s=\"\"\n for j in range(n):\n s=s+str(bin(cnt))[2:][: : -1]+\" \"\n cnt=cnt+1\n print(s)\n \n t=t-1", "# cook your dish here\nfor _ in range(int(input())):\n n = int(input())... | {"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["1", "1 01", "11 001", "1 01 11", "001 101 011", "111 0001 1001", "1 01 11 001", "101 011 111 0001", "1001 0101 1101 0011", "1011 0111 1111 00001"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,370 | |
42b605877ec74173e7286f73f411d8df | UNKNOWN | You are given two binary strings $S$ and $P$, each with length $N$. A binary string contains only characters '0' and '1'. For each valid $i$, let's denote the $i$-th character of $S$ by $S_i$.
You have to convert the string $S$ into $P$ using zero or more operations. In one operation, you should choose two indices $i$ ... | ["\ndef solve(s, p):\n diffs = 0\n for x, y in zip(s, p):\n if x == y:\n continue\n if x == '0':\n if diffs < 1:\n return \"No\"\n diffs -= 1\n else:\n diffs += 1\n return \"Yes\" if diffs == 0 else \"No\"\n\nfor _ in range(int(input())):\n l = int(input())\n s = input().strip()\n p = input().strip()\n pr... | {"inputs": [["3", "2", "00", "00", "3", "101", "010", "4", "0110", "0011"]], "outputs": [["Yes", "No", "Yes"]]} | INTERVIEW | PYTHON3 | CODECHEF | 11,884 | |
5a2c14246d479370205bd9f5a601664b | UNKNOWN | Chef has just found a recipe book, where every dish consists of exactly four ingredients.
He is going to choose some two dishes and prepare them for dinner.
Of course, he likes diversity and wants to know whether the two dishes are similar.
Two dishes are called similar if at least half of their ingredients are the sam... | ["# cook your dish here\nt=int(input())\ni=0\nwhile i<t:\n a=[]\n a=input().split()\n b=[]\n b=input().split()\n j=0\n c=0\n while j<4:\n if a[j] in b:\n c+=1\n j+=1\n if c>=2:\n print(\"similar\")\n else:\n print(\"dissimilar\")\n i+=1", "# cook your dish here\nn=int(input())\nl=[]\nfor i in range(0,n):\n s1=lis... | {"inputs": [["5", "eggs sugar flour salt", "sugar eggs milk flour", "aa ab ac ad", "ac ad ae af", "cookies sugar grass lemon", "lemon meat chili wood", "one two three four", "one two three four", "gibberish jibberish lalalalala popopopopo", "jibberisz gibberisz popopopopu lalalalalu"]], "outputs": [["similar", "similar... | INTERVIEW | PYTHON3 | CODECHEF | 6,106 | |
41ce86b67f796b7e3a30c9a2742a859a | UNKNOWN | Chef likes to travel a lot. Every day Chef tries to visit as much cities as possible. Recently he had a quite a few trips of great Chefland for learning various recipes. Chefland had N cities numbered from 1 to N. People in Chefland are very friendly, friendliness of i-th city is given by Fi.
Before starting of each t... | ["n=int(input())\na=list(map(int,input().split()))\nq=int(input())\nwhile q>0:\n i=1\n tot=a[0]\n b=list(map(int,input().split()))\n if b[0]==1:\n #p,f=map(int,raw_input().split())\n a[b[1]-1]=b[2]\n else:\n #r=int(raw_input())\n tot=a[0]\n while 1+i*b[1]<=n:\n tot=tot*a[i*b[1]]\n i=i+1\n m=(str)(tot)\n tot=... | {"inputs": [["5", "1 2 3 4 5", "3", "2 1", "1 3 10", "2 2"]], "outputs": [["1 120", "5 50"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,971 | |
0f5a9f9b745af76988269225cf975219 | UNKNOWN | Chef has an array of N natural numbers. Cheffina challenges the chef to choose the two numbers from the array and following the condition as the area of the rectangle formed from the two numbers is maximum. Cheffina also asks the chef to choose two numbers different from the previous two to form the rectangle with a mi... | ["import sys\r\nimport math\r\nimport bisect\r\nfrom sys import stdin,stdout\r\nfrom math import gcd,floor,sqrt,log\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left as bl,bisect_right as br\r\n\r\nsys.setrecursionlimit(100000000)\r\n\r\nii =lambda: int(input())\r\nsi =lambda: input... | {"inputs": [["1", "5", "4 2 1 5 3"]], "outputs": [["20 2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,103 | |
5989eecf57b445b063e3550339260fe6 | UNKNOWN | Indian National Olympiad in Informatics 2012
The Republic of Tutaria is celebrating its 37th year of independence. To mark the occasion, the nation is organising a contest where all its N citizens take part. The event has three tracks, a COBOL programming competition, pole vault, and a doughnut-eating competition. Each... | ["# cook your dish here\nwhile True:\n try:\n n=int(input())\n lis=[]\n for i in range(n):\n k=list(map(int,input().split()))\n k.append(k[1]+k[2])\n lis.append(k)\n \n #print(lis)\n p=sorted(lis,key=lambda x:x[3],reverse=True)\n #prin... | {"inputs": [["and output corresponding to the example above.", "Sample input", "3", "18 7 6", "23 10 27", "20 9 14", "Sample output", "74", "Note: Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your final submission.... | INTERVIEW | PYTHON3 | CODECHEF | 574 | |
3efc068e925bfcd73514c861762df409 | UNKNOWN | The MEX of a set of integers is defined as the smallest non-negative integer that does not belong to this set. For example, $\mathrm{MEX}(\{0,2,3\}) = 1$ and $\mathrm{MEX}(\{1,3\}) = 0$.
Chef has a tree with $N$ nodes (numbered $1$ through $N$). The tree is rooted at node $1$. Chef wants to assign a non-negative intege... | ["# cook your dish here\n# cook your dish here\nfrom math import log2;\nimport sys;\n\nsys.setrecursionlimit(10 ** 7)\nfrom collections import defaultdict\n\ninf = float(\"inf\")\ndef find_height(node):\n nodes[node]=1\n for i in graph[node]:\n nodes[node]+=find_height(i)\n return nodes[node]\ndef find_... | {"inputs": [["2", "3", "1 1", "5", "1 1 2 2", ""]], "outputs": [["4", "9"]]} | INTERVIEW | PYTHON3 | CODECHEF | 16,424 | |
0fb95b6e7fe1211214023c71130d1110 | UNKNOWN | Pushkar is very good in Number Theory. He takes two numbers $A\ and\ B$ and declares them a Pushkar Pair. Pushkar Pair has a property that $A$ has a $Modular\ Inverse$ modulo $B$.
He asks you to tell him the largest number $L$ that divides both of them.
-----Input:-----
- First line will contain $T$, number of tes... | ["import math\nfor i in range(int(input())):\n a,b = map(int,input().split())\n print(math.gcd(a,b))", "# cook your dish here\nt=int(input())\ndef gcd(a,b):\n big=max(a,b)\n small=min(a,b)\n while small:\n big,small=small,big%small\n return(big)\nfor __ in range(t):\n a,b=list(map(int, input(). split(\" \")))\n print(... | {"inputs": [["1", "3 4"]], "outputs": [["1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,945 | |
51e754b9561b7dafbe97bca7f2909cd7 | UNKNOWN | You are given an array $a$ of length $n$. A subsequence of this array is valid, if it satisfies these two conditions:
- There shouldn't be any two even numbers within a distance of $K$, both which have been chosen in the subsequence. i.e. there shouldn't be two indices $i, j$ such that $a_i$ and $a_j$ are even, $|i - j... | ["import sys\nimport math\n\ndef main(arr,k):\n \n \n x=[]\n y=[]\n \n \n \n for e in arr:\n if e%2==0:\n x.append(e)\n y.append(0)\n else:\n x.append(0)\n y.append(e)\n \n a=[0]*n\n b=[0]*n\n a[0]=x[0]\n b[0]=y[0]\n for i in range(1,n):\n \n if i<k:\n a[i]=max(x[i],a[i-1])\n b[i]=max(y[i],b[i-1])\n ... | {"inputs": [["3", "1 1", "3", "2 1", "2 2", "5 2", "1 2 3 4 6"]], "outputs": [["3", "2", "11"]]} | INTERVIEW | PYTHON3 | CODECHEF | 9,380 | |
e2728eb3b24b64741f93f2d2892b80a5 | UNKNOWN | Sultan, the freestyle wrestler, you all know him. He broke multiple records in the history of all wrestling leagues. Now 20 years have passed, Sultan has grown old. He has two sons, he wants them to be like him. Sultan being orthodox goes to his astrologer, where he is told that his sons shall be invincible like him.
... | ["from operator import itemgetter\nt=int(input())\nfor i in range(t):\n n=int(input())\n m,f=list(map(int,input().split()))\n x=list(map(int,input().split()))\n my,fy=0,0\n check=[0]*n\n #print check\n for j in range(n):\n if x[j]>0 and x[j]%m==0 and check[j]==0:\n check[j]=1\n my+=1\n #print check\n for j in rang... | {"inputs": [["2", "7", "2 3", "4 5 7 8 9 10 14", "6", "5 7", "1 2 8 9 10 11"]], "outputs": [["Yes", "Multan", "No"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,002 | |
2c917524e6be3e91efe69d7c243247ac | UNKNOWN | You are given a binary string S of N bits. The bits in the string are indexed starting from 1. S[i] denotes the ith bit of S.
Let's say that a sequence i1, i2, …, iK(1 ≤ K; 1 ≤ i1 < i2 < … < iK ≤ N) produces a palindrome when applied to S, if the string S[i1] S[i2] … S[ik] is a palindrome (that is, reads the same back... | ["\n\n\ndef powerset(s):\n n = len(s)\n masks = [1 << j for j in range(n)]\n for i in range(2**n):\n yield [j + 1 for j in range(n) if (masks[j] & i)]\n\n\ndef is_power2(num):\n return num != 0 and ((num & (num - 1)) == 0)\n\n\ndef special(l):\n n = len(l)\n for i in range(n):\n lis = [i... | {"inputs": [["2", "11010", "101001011", "", ""]], "outputs": [["9", "18"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,864 | |
bca66e3664f7813cf4b4f852bdc22fe4 | UNKNOWN | A permutation of length n is an array of size n consisting of n distinct integers in the range [1, n]. For example, (3, 2, 4, 1) is a permutation of length 4, but (3, 3, 1, 4) and (2, 3, 4, 5) are not, as (3, 3, 1, 4) contains duplicate elements, and (2, 3, 4, 5) contains elements not in range [1,4].
A permutation p of... | ["tests = int(input())\r\nfor t in range(tests):\r\n n = int(input())\r\n permut='2'\r\n permut_list=[]\r\n if n%2==0:\r\n for i in range(2, n+1):\r\n if i%2==1:\r\n permut=permut+' '+str(i+1)\r\n else:\r\n permut=permut+' '+str(i-1)\r\n print(permut)\r\n pass\r\n elif n==1:\r\n ... | {"inputs": [["4", "2", "3", "5", "6", "", ""]], "outputs": [["2 1", "2 3 1", "2 1 4 5 3", "2 1 4 3 6 5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 11,199 | |
7ff65c573133eca9be1c275ac8dcc237 | UNKNOWN | Nobody knows, but $N$ frogs live in Chef's garden.
Now they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.
Chef knows all $P$ pairs of frogs, which want to send messages. Help him to define can they or not!
Note ... | ["# cook your dish here\nn, k, p = [int(i) for i in input().split()]\nn_sep = list(map(int, input().split()))\ncount = 0\nsep_sort = sorted(n_sep)\nhashing = {sep_sort[0]: 0}\n\nfor j in range(1, n):\n if (abs(sep_sort[j] - sep_sort[j - 1]) > k):\n count += 1\n hashing[sep_sort[j]] = count\n#print(hashing)\nfor i in r... | {"inputs": [["5 3 3", "0 3 8 5 12", "1 2", "1 3", "2 5"]], "outputs": [["Yes", "Yes", "No"]]} | INTERVIEW | PYTHON3 | CODECHEF | 11,274 | |
6ed214ef2dfdbf43d197626c2178b9a6 | UNKNOWN | After six days, professor GukiZ decided to give more candies to his students. Like last time, he has $N$ students, numbered $1$ through $N$. Let's denote the number of candies GukiZ gave to the $i$-th student by $p_i$. As GukiZ has a lot of students, he does not remember all the exact numbers of candies he gave to the ... | ["try:\n# https://www.codechef.com/LTIME63B/problems/GHMC\n# Finally.... I properly understood what needs to be done.\n\n def ctlt(arr, val):\n # find number of values in sorted arr < val\n if arr[0] >= val: return 0\n lo = 0\n hi = len(arr)\n while hi-lo > 1:\n md = (hi... | {"inputs": [["2", "4 3 5 3", "2 1 5", "3 2 8 2", "3 8"]], "outputs": [["12", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 7,836 | |
7d9b4c2ebfa154ba55e72a4a8a833158 | UNKNOWN | You are given an integer $D$. Find an integer sequence $A_1, A_2, \ldots, A_N$ such that the following conditions are satisfied:
- $1 \le N \le 10^5$
- $1 \le A_i \le 10^5$ for each valid $i$
- $\sum_{i=1}^N \sum_{j=i}^N \left( \mathrm{min}(A_i, A_{i+1}, \ldots, A_j) - \mathrm{GCD}(A_i, A_{i+1}, \ldots, A_j) \right) = ... | ["# cook your dish here\nt=int(input())\nfor i in range(t):\n D=int(input())\n P=10**5-2\n ans=[]\n if(D==0):\n ans.append(1)\n while(D>0):\n P=min(P,D)\n ans.append(P+2);\n ans.append(P+1);\n ans.append(1);\n D=D-P;\n print(len(ans))\n print(*ans,sep=\" \",end=\"\\n\")\n \n \n \n ", "for _ in range(int(input... | {"inputs": [["4", "2", "5", "200", "13"]], "outputs": [["3", "3 3 2", "5", "2 8 5 1 10", "7", "12 10 15 11 19 13 15", "4", "5 4 4 10"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,705 | |
dbabec269bcabc978bb5cc16ad5c51b5 | UNKNOWN | Pankaj likes to eat Ice cream when he is working late into the night. Today has been yet another long day for Pankaj. So, he wants to eat ice cream now. He opens the fridge and sees that he has 2 types of containers holding the ice cream.
The first container is a cone with radius r1 and height h1. There is also a hemis... | ["import math\nt=eval(input())\nwhile t:\n t=t-1\n r1,h1,r2,h2=list(map(float,input().split()))\n vol1=(math.pi*r1*r1*h1)/3 + (2*math.pi*r1*r1*r1)/3\n vol2=math.pi*r2*r2*h2\n print(\"%.8f %.8f\" % (vol1,vol2))\n\n", "import math\ninputs = eval(input())\nfor i in range(inputs):\n\tinpu = input().split()\n... | {"inputs": [["2", "1.00 1.00 1.00 1.00", "3.02 7.23 5.20 6.00", "", ""]], "outputs": [["3.141592654 3.141592654", "126.739919445 509.691992118"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,334 | |
06ae1181ec21242d3662116f9eae7cd9 | UNKNOWN | Given an Integer N, write a program to reverse it.
-----Input-----
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
-----Output-----
For each test case, display the reverse of the given number N, in a new line.
-----Constraints-----
- 1 ≤ T ≤ 10... | ["# cook your dish here\nx=int(input())\nfor i in range(x):\n s=input()\n print(int(s[::-1]))\n", "# cook your dish here\nn=int(input())\na=[]\nfor i in range (0,n):\n no=int(input())\n a.append(no)\nfor i in range (0,n):\n c=0\n s=0\n while (a[i]!=0):\n c=a[i]%10\n s=s*10+c\n ... | {"inputs": [["4", "12345", "31203", "2123", "2300"]], "outputs": [["54321", "30213", "3212", "32"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,004 | |
9e4fa6494396d1feb51cbef6242c9453 | UNKNOWN | Tanish is the president of the chemistry club at his school. He considers everyone who doesn't like chemistry as his enemy. After years of research, he has invented a lethal poison, which he named success. Now Tanish plans to kill all his enemies with his success. Success is extremely deadly and is untraceable in small... | ["t=int(input())\nfor i in range(t):\n n=int(input())\n N=list(map(int,input().split()))\n N.sort()\n \n k=n-1\n ave=N[k]\n for j in range(n-1):\n ave=(ave+N[k-1])/2\n k=k-1\n \n print(ave)", "test=int(input())\nfor i in range(test):\n N=int(input())\n n=input()\n a=list(n.split(' '))\n for k in range(N):\n a[k]=in... | {"inputs": [["2", "2", "9 3", "3", "3 2 9"]], "outputs": [["6.00000000", "4.00000000"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,089 | |
cf8b8e74e9436c72d84bf365584eac12 | UNKNOWN | "Ring Ring!!"
Sherlock's phone suddenly started ringing. And it was none other than Jim Moriarty..
"Long time no see ! You miss me right ? Anyway we'll talk about it later . Let me first tell you something. Dr.Watson is with me . And you've got only one chance to save him . Here's your challenge:.
Given a number N an... | ["import sys\nuser_input = sys.stdin.readline().split()\n\nT = int(user_input[0])\n\nfor j in range(T) :\n\n var = sys.stdin.readline().split()\n N = int(var[0])\n M = int(var[1])\n\n if (N%M)%2 :\n print(\"ODD\")\n else :\n print(\"EVEN\")", "t = int(input())\nfor i in range(0,t):\n n,m = list(map(int,input().split(... | {"inputs": [["2", "4 4", "6 5"]], "outputs": [["EVEN", "ODD"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,341 | |
45ca6b0bdcb998507ca39054db297938 | UNKNOWN | Xorgon is an extremely delicious treat formed by the sequence $S$ of binary integers $s_1, s_2,..,s_N$. A really interesting property found in a Xorgon is that the xor of all elements in any contiguous subsequence of length $K$ in $S$ will result in $1$.
Chef has been asked to prepare a Xorgon. However, he has at hi... | ["# cook your dish here\nfrom sys import stdin,stdout\n\na0=0\na1=1\nn,k=stdin.readline().strip().split(' ')\nn,k=int(n),int(k)\n\narr=list(map(int,stdin.readline().strip().split(' ')))\n\n\n\ndef solve(n,k,arr):\n sol=[]\n\n l=0;u=k;\n\n\n while l!=u:\n sol.append(arr[l:min(len(arr),u)])\n l=min(l+k,len(arr))\n ... | {"inputs": [["7 5", "1 0 0 1 1 1 1"]], "outputs": [["1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 987 | |
3443de202b14f0ac944089ff1ff68452 | UNKNOWN | Naman owns a very famous Ice Cream parlour in Pune. He has a wide range of flavours with different pricing.
Every flavour costs ₹ X per gram and quantity of each flavour in the parlour is indefinite. Now, Naman has
received an order for a party wherein he is asked to prepare each Ice Cream with N number of flavours... | ["test = int(input())\nfor i in range(test):\n flavor = int(input())\n rate = input()\n gaf = input()\n gaf = gaf.split()\n gaf = [int(x) for x in gaf]\n rate = rate.split()\n rate = [int(x) for x in rate]\n rate.sort()\n c = gaf[0] - gaf[1]\n sum = rate[0]*c\n t = True\n if gaf[0] < gaf[1]:\n t = False\n j = 0\n whil... | {"inputs": [["2", "5", "4 6 8 1 10", "10 3", "2", "1 2", "1 2"]], "outputs": [["18", "Not Possible"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,360 | |
673d462d0cef300a62eb64210f3d8c32 | UNKNOWN | You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q... | ["# cook your dish here\nepi=10**-2\ndef vision(t):\n a1=x0+(dx*t)-x1\n a2=y0+(dy*t)-y1\n a3=z0+(dz*t)-z1\n b=4*((a1*d1)+(a2*d2)+(a3*d3))*((a1*d1)+(a2*d2)+(a3*d3))\n a=4*((a1*a1)+(a2*a2)+(a3*a3))\n value=(b-(a*c))\n return value\nxrange=range\nfor _ in range(int(input())):\n x1,y1,z1,x0,y0,z0,dx,dy,dz,cx,cy,cz,r=list(m... | {"inputs": [["1", "3 0 0 -10 -10 0 0 10 0 0 -3 0 3"]], "outputs": [["1.0000000000"]]} | INTERVIEW | PYTHON3 | CODECHEF | 619 | |
c7936147a6cdb9c91c709c7ab8fcdc35 | UNKNOWN | Spring is interesting season of year. Chef is thinking about different things, but last time he thinks about interesting game - "Strange Matrix".
Chef has a matrix that consists of n rows, each contains m elements. Initially, the element aij of matrix equals j. (1 ≤ i ≤ n, 1 ≤ j ≤ m).
Then p times some element aij is... | ["import sys\nimport os\nimport random\nimport math\n#nonlocal defs\nn, m, p = list(map(int, input().split()))\narr = [dict() for _ in range(n)]\nfor _ in range(p):\n i,j = list(map(int,input().split()))\n i -= 1\n j -= 1\n if j not in arr[i]:\n arr[i][j] = j+1\n else:\n arr[i][j] += 1\n\ndef chefbm(arr,i):\n for (e,... | {"inputs": [["4 4 6", "2 2", "3 2", "3 2", "4 3", "4 4", "4 3"]], "outputs": [["3", "3", "-1", "4"]]} | INTERVIEW | PYTHON3 | CODECHEF | 16,475 | |
45d17af5c0d4eee6789caaa9a8bc6682 | UNKNOWN | One of Chef's friends offered him a deal: during $D$ days, they are going to exchange money. For each $i$ ($1 \le i \le D$), on the $i$-th day, Chef's friend would give Chef $A$ rupees, while Chef would give his friend $2^{i-1}$ rupees ($1$ rupee on day $1$, $2$ rupees on day $2$, $4$ rupees on day $3$, and so on). Che... | ["# cook your dish here\na = int(input())\nfor i in range(a):\n b = int(input())\n li = []\n if b == 2:\n print(2,1)\n elif b == 3:\n print(3,2)\n elif b == 4:\n print(4,2)\n else:\n for t in range(b+1):\n if ((b*t)+1-(2**t))<0:\n li.append(t-1)\n break\n for o in range(b+1):\n if b<=2**(o):\n li.appe... | {"inputs": [["4", "5", "8", "9", "1000000000"]], "outputs": [["4 3", "5 3", "5 4", "35 30"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,685 | |
d678478648dc0b6a3d3c82528899d8e9 | UNKNOWN | The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get an interaction with Integer numbers, when N(Integer number) is provided to t... | ["from sys import stdin, stdout\r\n#from math import gcd as g\r\n#a,b = map(int, stdin.readline().split())\r\n#l1 = list(map(int, stdin.readline().split()))\r\nl = [1,6,7]\r\nc = 1\r\nfor x in range(3,100001):\r\n if x%2==1:\r\n a = l[c]*6\r\n l.append(a)\r\n else:\r\n l.append(a+1)\r\n ... | {"inputs": [["2", "3", "5"]], "outputs": [["7", "37"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,054 | |
37e9e0b8e86dea20aae62e4ffa1ad70a | UNKNOWN | Limak is a little polar bear.
He is playing a video game and he needs your help.
There is a row with N cells, each either empty or occupied by a soldier, denoted by '0' and '1' respectively.
The goal of the game is to move all soldiers to the right (they should occupy some number of rightmost cells).
The only possible ... | ["for _ in range(int(input())):\n l=list(map(int,input().strip()))\n for j in range(len(l)-1,-1,-1):\n if l[j]==1:\n l.pop()\n else:\n break\n if l.count(1):\n time,prev,z,c=0,0,0,0\n for j in range(len(l)-1,-1,-1):\n if l[j]==0:\n z+=1\n continue\n if prev!=z:\n prev=z\n c+=1\n time+=c+z\n\n ... | {"inputs": [["4", "10100", "1100001", "000000000111", "001110100011010"]], "outputs": [["8", "10", "0", "48"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,477 | |
e9861794be2630e3bece764f2b911d18 | UNKNOWN | If Give an integer N . Write a program to obtain the sum of the first and last digits of this number.
-----Input-----
The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains an integer N.
-----Output-----
For each test case, display the sum of first and last dig... | ["n = int(input())\nfor i in range(n):\n s = input()\n l = len(s)\n n1 = int(s[0])\n n2 = int(s[l-1])\n print(n1+n2)\n", "try:\n # cook your dish here\n for _ in range(int(input())):\n s=str(input())\n print(int(s[0])+int(s[-1]))\nexcept:\n pass", "# cook your dish here\nfor _ in r... | {"inputs": [["3", "1234", "124894", "242323"]], "outputs": [["5", "5", "5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,992 | |
7e11da21d1f52b23ed8b287960e11070 | UNKNOWN | Rani is teaching Raju maths via a game called N-Cube, which involves three sections involving N.
Rani gives Raju a number N, and Raju makes a list of Nth powers of integers in increasing order (1^N, 2^N, 3^N.. so on). This teaches him exponentiation.
Then Raju performs the following subtraction game N times : Take al... | ["tc=int(input())\nfor case in range(tc):\n m,r=list(map(int,input().split()))\n n=m**(r-1)\n a=[i**n for i in range(1,2*n+1)]\n tmp=2*n-1\n for i in range(n):\n for j in range(tmp-i):\n a[j]=a[j+1]-a[j]\n print((a[n-1]/m)%1000000007)\n"] | {"inputs": [["1", "2 2"]], "outputs": [["1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 241 | |
0d10872d4ec20a8aaea9701b1b80cc6e | UNKNOWN | Bob has n heap(s) of gravel (initially there are exactly c piece(s) in each). He wants to do m operation(s) with that heaps, each maybe:
- adding pieces of gravel onto the heaps from u to v, exactly k pieces for each,
- or querying "how many pieces of gravel are there in the heap p now?".
-----Request-----
Help Bob d... | ["N,M,C = list(map(int, input().split()))\ntree = [0] * (N+1)\n\ndef add(u,k):\n while u < len(tree):\n tree[u] += k \n u += u&-u\n\ndef query(k):\n ans = 0\n while k:\n ans += tree[k]\n k -= k&-k\n\n return ans\n\ndef solve():\n for _ in range(M):\n op = input().split()\n if op[0] == 'Q':\n print(query(int(op[... | {"inputs": [["7 5 0", "Q 7", "S 1 7 1", "Q 3", "S 1 3 1", "Q 3"]], "outputs": [["0", "1", "2", "Limitations", "0<n\u226410 6", "0<m\u2264250 000", "0<u\u2264v\u2264n", "0\u2264c,k\u226410 9", "0<p\u2264n"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,553 | |
91dfe58ef4bdcea521172eba400e8a2b | UNKNOWN | Chef's dog Snuffles has so many things to play with! This time around, Snuffles has an array A containing N integers: A1, A2, ..., AN.
Bad news: Snuffles only loves to play with an array in which all the elements are equal.
Good news: We have a mover of size D. !
A mover of size D is a tool which helps to change array... | ["tc=int(input())\nfor case in range(tc):\n n,d=list(map(int,input().split()))\n a=list(map(int,input().split()))\n sm=sum(a)\n f=True\n if sm%n==0:\n avg=sm/n\n for i in range(d):\n tmp_sm=0\n tmp_n=0\n for j in range(i,n,d):\n tmp_sm=tmp_sm+a[j]\n tmp_n+=1\n if tmp_sm%tmp_n==0:\n if avg!=tmp_sm/tmp... | {"inputs": [["3", "5 2", "1 4 5 2 3", "3 1", "1 4 1", "4 2", "3 4 3 5"]], "outputs": [["3", "2", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 16,382 | |
f96bd1411078e3759947f838e7e1dcf6 | UNKNOWN | Dustin, is the head of an Intelligence agency. He wants to send a secret message S$S$ to his colleague.The message is a single word consisting of only lowercase english letters but he decides to encrypt the message for security reasons. He makes a string M$M$ of length N$N$, such that after deleting a substring of non-... | ["# cook your dish here\nt = int(input())\n\nfor _ in range(t):\n\n n,s = input().split()\n\n N = int(n) \n r = N - len(s)\n\n count = 0\n\n if N>len(s):\n\n count = pow(26, r-1,(10**9+7))\n count*= (26+25*len(s))\n\n count = count%(10**9 + 7)\n print(count)\n\n", "# cook your dish here\nt... | {"inputs": [["2", "3 a", "3 ab"]], "outputs": [["1326", "76"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,776 | |
478b23e504432b2996270e3e5270f1e4 | UNKNOWN | As lockdown is going on so no is allowed to go outside , so Chef has come with an innovative idea for food home delivery using drone. But there is an issue with it , the drone can move forward or backward a fix number of steps $x$ .
All the houses and chef restaurant are all in a straight line . Homes which need deli... | ["# cook your dish here\nimport math\ntry:\n n,d=map( int,input().split() )\n a=list(map(int,input().split()))\n a.sort()\n z=abs(a[0]-d)\n for j in range(n):\n x=abs(a[j]-d)\n z=math.gcd(x,z)\n print(z) \n \n \nexcept:\n pass", "# cook your dish here\nn,r=map(int,input()... | {"inputs": [["3 1", "3 5 11"]], "outputs": [["2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 8,670 | |
2c9755e97fa539259447a8c6f452d3d7 | UNKNOWN | One day, Tanya was studying graph theory. She is very inquisitive, so the following problem soon came to her mind.
Find the number of undirected unweighted connected simple graphs with $N$ vertices (numbered $1$ through $N$) and $M$ edges, such that for each $i$ ($2 \le i \le N$), the shortest path from vertex $1$ to v... | ["def multiple_input(): return map(int, input().split())\n\n\ndef list_input(): return list(map(int, input().split()))\n\n\nmod = int(1e9) + 7\nfor _ in range(int(input())):\n n, m = multiple_input()\n a = list_input()\n a.sort()\n max_level = a[-1] + 1\n levels = [0] * max_level\n levels[0] = 1\n for i in a:\n levels... | {"inputs": [["3", "4 3", "1 2 1", "4 6", "1 2 1", "3 2", "2 2"]], "outputs": [["2", "0", "0"]]} | INTERVIEW | PYTHON3 | CODECHEF | 8,440 | |
7faee6d09a787ac0ff92fecf17f4ccc6 | UNKNOWN | In a cricket game, an over is a set of six valid deliveries of balls performed by one player ― the bowler for this over.
Consider a cricket game with a series of $N$ overs (numbered $1$ through $N$) played by $K$ players (numbered $1$ through $K$). Each player may be the bowler for at most $L$ overs in total, but the s... | ["t=int(input())\nfor i in range(t):\n n,k,l=map(int,input().split())\n if k*l<n:\n print(-1)\n elif (k==1 and n>1):\n print(-1)\n else:\n for j in range(n):\n print((j%k)+1,end=' ')\n print()", "t=int(input())\nfor i in range(t):\n n,k,l=map(int,input().split())\n if k*l<n:\n print(-1)\n elif (k==1 and n>1):\n ... | {"inputs": [["2", "4 3 2", "5 4 1"]], "outputs": [["1 2 3 2", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,651 | |
149e87ef99fbbc1394323758c6c08a0a | UNKNOWN | There's an array A consisting of N non-zero integers A1..N. A subarray of A is called alternating if any two adjacent elements in it have different signs (i.e. one of them should be negative and the other should be positive).
For each x from 1 to N, compute the length of the longest alternating subarray that starts at... | ["test=int(input())\nfor i in range(test):\n n=int(input())\n a=list(map(int,input().split()))\n b=[0]*(n+2)\n b[n-1]=1\n for i in range(n-2,-1,-1):\n if(a[i]*a[i+1]<0):\n b[i]=b[i+1]+1\n else:\n b[i]=1\n for i in range(n):\n print(b[i], end=' ')\n print() ", "def f(x,y):\n if x<0 and y>0:\n return 1\n elif x>0... | {"inputs": [["3", "4", "1 2 3 4", "4", "1 -5 1 -5", "6", "-5 -1 -1 2 -2 -3"]], "outputs": [["1 1 1 1", "4 3 2 1", "1 1 3 2 1 1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,456 | |
993265692a4f754122ae20e06cc788ca | UNKNOWN | Chef is a very experienced and well-known cook. He has participated in many cooking competitions in the past — so many that he does not even remember them all.
One of these competitions lasted for a certain number of days. The first day of the competition was day $S$ of the week (i.e. Monday, Tuesday etc.) and the last... | ["# cook your dish here\nd=[\"saturday\",\"sunday\",\"monday\",\"tuesday\",\"wednesday\",\"thursday\",\"friday\"]\nt=int(input())\nfor i in range(t):\n s,e,l,r=map(str,input().split())\n l,r=int(l),int(r)\n v=(d.index(e)-d.index(s)+8)%7\n c=r+1\n for i in range(l,r+1):\n if i%7==v:\n c=i\n break\n if c>r:\n print... | {"inputs": [["3", "saturday sunday 2 4", "monday wednesday 1 20", "saturday sunday 3 5"]], "outputs": [["2", "many", "impossible"]]} | INTERVIEW | PYTHON3 | CODECHEF | 388 | |
98fb990ceb63d3efb6c03e7bebe5a2d3 | UNKNOWN | Zonal Computing Olympiad 2013, 10 Nov 2012
Little Red Riding Hood is carrying a basket with berries through the forest to her grandmother's house. The forest is arranged in the form of a square N × N grid of cells. The top left corner cell, where Little Red Riding Hood starts her journey, is numbered (1,1) and the b... | ["# cook your dish here\nimport sys \ndef dist(a,b):\n return abs(a[0]-b[0])+abs(a[1]-b[1])\nn, m = map(int, input().split())\nmatrix=[]\nid_matrix=[[0 for i in range(n)] for i in range(n)]\nfor _ in range(n):\n matrix.append(list(map(int, input().split())))\ncharms=[]\nfor _ in range(m):\n x,y,lungh = map(int... | {"inputs": [["5 3", "3 3 2 4 3 ", "2 1 -1 -2 2 ", "-1 2 4 3 -3 ", "-2 2 3 2 1 ", "3 -1 2 -1 2 ", "1 2 2", "4 5 2", "4 2 1", ""]], "outputs": [["YES", "19"]]} | INTERVIEW | PYTHON3 | CODECHEF | 34,971 | |
c1affd664e92626783a8e3eb08fbb596 | UNKNOWN | One upon a time there were three best friends Abhinav, Harsh, and Akash decided to form a
team and take part in ICPC from KIIT. Participants are usually offered several problems during
the programming contest. Long before the start, the friends decided that they will implement a
problem if at least two of them are s... | ["# cook your dish here\nn = int(input())\ncount = 0\nfor _ in range(n):\n L = list(map(int, input().split()))\n if (L.count(1)>=2):\n count+=1\n \nprint(count)\n", "count = 0\nfor _ in range(int(input())):\n view = list(map(int , input().split()))\n if(sum(view) > 1): count += 1\nprint(count)", "# cook your dish here... | {"inputs": [["3", "1 1 0", "1 1 1", "1 0 0"]], "outputs": [["2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 3,426 | |
1496dd6c66d9da8c09873bca931ff609 | UNKNOWN | Chef has provided with a sequence of integers of length $N$ arranged in an unsorted fashion.
The elements of the sequence are ordered as ${A1,A2,A3.....A'N}$
The task of the chef is to identify the highest and lowest value among the given sequence. It is assured that the sequence given contains the highest and the lowe... | ["n=int(input())\na=list(map(int,input().split()))\na.sort()\nprint(a[-1],a[0])\n", "n = int(input())\narr = list(map(int,input().split()))\nprint(max(arr),min(arr))", "# cook your dish here\ntry:\n n=int(input())\n num = list(map(int, input().split()[:n]))\n m1=max(num)\n m2=min(num)\n print(m1,m2)\n\ne... | {"inputs": [["5", "3 2 7 9 4"]], "outputs": [["9 2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,731 | |
b7f7eb5745069059a70f635443ca81a9 | UNKNOWN | Chefina has two sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_N$. She views two sequences with length $N$ as identical if, after they are sorted in non-decreasing order, the $i$-th element of one sequence is equal to the $i$-th element of the other sequence for each $i$ ($1 \le i \le N$).
To impress Chefin... | ["from collections import Counter\ntc=int(input())\nfor k in range(tc):\n n=int(input())\n a=list(map(int, input().rstrip().split()))\n b= list(map(int, input().rstrip().split()))\n cc=sorted(a+b)\n #print('cc = ',cc)\n p=[]\n q=[]\n #print('len(cc) = ',len(cc))\n #print('len = ',(2*n))\n #rx=0\n for i in range(0,(2*n)... | {"inputs": [["3", "1", "1", "2", "2", "1 2", "2 1", "2", "1 1", "2 2"]], "outputs": [["-1", "0", "1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 20,100 | |
89508c8b60aa46f2acf50770a278547d | UNKNOWN | Chef likes to solve difficult tasks. This time, he tried to solve the Big Famous Unsolvable $A+B=C$. One of his friends played a prank on Chef and randomly shuffled the bits in $A$ and $B$ (independently in each number). However, the funny thing is that the sum of the resulting numbers remained $C$ even after shuffling... | ["import math\ndef csb(n): \n count = 0\n while (n): \n n &= (n-1) \n count+= 1\n \n return count\ndef f(ca,cb,i,cf,C,n,dp):\n if ca<0 or cb<0:\n return 0\n if i==n:\n if ca==0 and cb==0 and cf==0:\n return 1\n return 0\n st=str(ca)+\" \"+str(cb)+\" \"+str(cf)+\" \"+str(i)\n if dp.get(st)!=None:\n return dp[st... | {"inputs": [["2", "1 2 3", "369 428 797"]], "outputs": [["2", "56"]]} | INTERVIEW | PYTHON3 | CODECHEF | 8,762 | |
b9c4e381824060ae7ac5f54369acf230 | UNKNOWN | In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest):
- royal flush - ace, king, queen, jack and ten, all in the same suit
- straight flush - five cards of the same suit in sequence, such
as 10,9,8,7,6 of clubs; ace can be counted both as the highest card or as the
lowest card - A,... | ["cards = ['A','2','3','4','5','6','7','8','9','T','J','Q','K']\n\ndef royal_flush(arr):\n nonlocal ans, confirm\n rf_set = 'TJQKA'\n rf = 1\n for char in arr:\n if char[0] not in rf_set:\n rf = 0\n break\n if rf :\n if len(set(suit)) == 1:\n ans = 'royal flush'\n confirm = 1\ndef straight_flush(arr): # and ... | {"inputs": [["3", "AH KH QH TH JH", "KH 5S 3C 5C 7D", "QH QD 2S QC 2C"]], "outputs": [["royal flush", "pair", "full house"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,149 | |
e6f6a3e544cd1232229c588e7148c1e8 | UNKNOWN | Bitland declared war on Chefland and sent an army to fight them, but Chefland defended efficiently and Bitland's army has been reduced to N$N$ soldiers. They have no chance of winning the war and do not want to surrender, so they are planning to commit group suicide. Josh, the leader of Bitland's remaining soldiers, ha... | ["import numpy as np\nfor _ in range(int(input())):\n n = int(input())-1;soldiers = [int(j) for j in input().split()]\n force = int(input());attacks = np.zeros(2*n,dtype=int);attacks[:n] = np.array(soldiers);attacks[n:2*n] = attacks[:n];shield = [0 for _ in range(n)];pow_of_2 = 1\n while n // pow_of_2 > 0: p... | {"inputs": [["2", "5", "12 34 45 5", "10", "5", "10 15 43 20", "5"]], "outputs": [["possible", "4 100", "impossible"]]} | INTERVIEW | PYTHON3 | CODECHEF | 35,895 | |
17b28a87200b61ea78f1014ddda4a895 | UNKNOWN | in Chefland, there is a very famous street where $N$ types of street food (numbered $1$ through $N$) are offered. For each valid $i$, there are $S_i$ stores that offer food of the $i$-th type, the price of one piece of food of this type is $V_i$ (the same in each of these stores) and each day, $P_i$ people come to buy ... | ["t=int(input())\nwhile(t):\n n=int(input())\n l=[]\n for i in range(n):\n l.append(list(map(int,input().split())));\n m=[]\n for i in l:\n m.append((i[1]//(i[0]+1))*i[2])\n res=max(m)\n print(res)\n t=t-1", "# cook your dish here\nt=int(input())\nwhile(t):\n n=int(input())\n l=[]\n for i in range(n):\n l.append(lis... | {"inputs": [["2", "3", "4 6 8", "2 6 6", "1 4 3", "1", "7 7 4"]], "outputs": [["12", "0"]]} | INTERVIEW | PYTHON3 | CODECHEF | 6,312 | |
f6454491dcb11120daa83f87fc2c2f9d | UNKNOWN | John was learning mathematics and was very bored. Jane his best friend gave him a problem to solve.
The description of the problem was as follows:-
You are given a decimal number $N$(1<=$N$<=$10^9$) and three integers $A$, $B$, $C$.
Steps to perform:
1) You have to create a $LIST$.
2) You have to initialize the $LI... | ["# Why do we fall ? So we can learn to pick ourselves up.\r\n\r\n\r\n\r\n\r\nt = int(input())\r\nfor _ in range(0,t):\r\n n = int(input())\r\n abc = [int(i) for i in input().split()]\r\n\r\n i = 0\r\n\r\n lst = [n]\r\n\r\n for _ in range(0,100):\r\n k = str(lst[-1]/abc[i%3]).split('.')\r\n ... | {"inputs": [["1", "56", "3 5 7", "4", "0", "1", "2", "3"]], "outputs": [["56", "6", "2", "2"]]} | INTERVIEW | PYTHON3 | CODECHEF | 9,513 | |
14793a1b87bddfd03ee66486215b7815 | UNKNOWN | You are given an array A of size N. Let us list down all the subarrays of the given array. There will be a total of N * (N + 1) / 2 subarrays of the given array. Let us sort each of the subarrays in descending order of the numbers in it.
Now you want to sort these subarrays in descending order. You can compare two su... | ["# cook your dish here\nfor _ in range(int(input())):\n n,q=map(int,input().split())\n l=[int(i) for i in input().split()]\n qry=[int(input()) for i in range(q)]\n def cmp(sub1,sub2):\n for i in range(len(sub1)):\n if sub1[i]>sub2[i]:\n return 1 \n if sub1[i]<sub2[i]:\n return 2 \n return 1 \n maxl=[]\n fo... | {"inputs": [["1", "4 2", "3 1 2 4", "1", "5"]], "outputs": [["4", "3"]]} | INTERVIEW | PYTHON3 | CODECHEF | 2,138 | |
dd9e909f802f05b7a150f07d09f14488 | UNKNOWN | One day Chef was playing with numbers. He loves Lowest Common Multiple (LCM) too much and he is a very curious guy. He always try to do new things. Now he want to make a large number with it. But he doesn't want to take too many numbers.
He is willing to take only three numbers less than or equal to N (not necessarily... | ["from fractions import gcd\nfor testCases in range(eval(input())):\n n = eval(input())\n if n == 1:\n print('1')\n elif n == 2:\n print('2')\n elif n == 3:\n print('6')\n else:\n c = n*(n-1)\n k = n - 2\n while True:\n if gcd(k,n-1) == 1 and gcd(k,n) == 1:\n break\n k -= 1\n d = (n-1)*(n - 2)\n k1 = n -... | {"inputs": [["2", "9", "7"]], "outputs": [["504", "210"]]} | INTERVIEW | PYTHON3 | CODECHEF | 432 | |
ebeeaa7893a27c5be7e8d947e7cc071d | UNKNOWN | Zaikia has $N$ sticks of distinct positive lengths $A_1,A_2,\dots,A_N$. For no good reason at all, he wants to know if there is a triplet of sticks which when connected end-to-end will form a non-trivial triangle. Here non-trivial refers to a triangle with positive area.
Help Zaikia know if such a triplet exists or not... | ["#from itertools import combinations as c\r\nn=int(input());l=list(map(int,input().split()))\r\nl1=[]\r\nif(n<3):\r\n print(\"NO\")\r\nelse:\r\n l.sort()\r\n for i in range(n-2):\r\n if(l[i]+l[i+1]>l[i+2]):\r\n l1.append([l[i+2],l[i+1],l[i]])\r\nif(len(l1)!=0):\r\n print(\"YES\")\r\n p... | {"inputs": [["5", "4 2 10 3 5"]], "outputs": [["YES", "5 4 3"]]} | INTERVIEW | PYTHON3 | CODECHEF | 12,079 | |
b09726871094744c674b7bf5e438a82f | UNKNOWN | Chef is frustrated in this lockown. So to overcome this he plans to travel various mountains.
He is very strange so he sets some conditions for $each$ Type 2 query(mentioned below) (i.e. $1$ $i$) :
- Let Chef has travelled till $ith$ mountain from left to right.
- He does not like to travel the mountain with the heigh... | ["# cook your dish here\nfrom bisect import bisect_left \n \ndef BinarySearch(a, x): \n i = bisect_left(a, x) \n if i != len(a) and a[i] == x: \n return i \n else: \n return -1\n\nfor _t in range(int(input())):\n _n, q = list(map(int, input().split()))\n mounts = list(map(int, input().split()))\n for _q in range(q):\... | {"inputs": [["1", "10 5", "1 3 5 4 5 6 7 8 4 5", "1 7", "1 3", "1 1", "0 2 7", "1 3"]], "outputs": [["-1", "6", "5", "5"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,335 | |
93548d6047e078c0e5633b2d6131dd7d | UNKNOWN | Indian National Olympiad in Informatics 2013
Calvin wakes up early one morning and finds that all his friends in the hostel are asleep. To amuse himself, he decides to play the following game : he draws a sequence of N squares on the ground, numbered 1 to N, and writes an integer in each square. He starts at square k (... | ["try:\n n, k=map(int, input().split())\n arr=list(map(int, input().split()))\n forward = [0]*(n+1)\n backward= [0]*(n+1)\n backward[0]=arr[0]\n backward[1]=arr[0]+arr[1]\n for i in range(k, n):\n forward[i]=arr[i] +max(forward[i-1],forward[i-2])\n\n for i in range(2, n):\n backward[i]=a... | {"inputs": [["and output corresponding to the example above.", "Sample input", "5 2", "5 3 -2 1 1", "Sample output", "11", "Note : Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your final submission. A program with e... | INTERVIEW | PYTHON3 | CODECHEF | 3,298 | |
95cd05a1a30881fabbcdb36a9681387f | UNKNOWN | DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.
You are given the information of DevuLand
by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village.
Otherwise, it mean... | ["# cook your dish here\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n curr = 0\n ans = 0\n for x in a:\n curr += x\n ans += abs(curr)\n print(ans)"] | {"inputs": [["3", "2", "5 -5", "2", "-5 5", "3", "1 2 -3"]], "outputs": [["5", "5", "4"]]} | INTERVIEW | PYTHON3 | CODECHEF | 194 | |
f1270ee87c8f8625f2cb2adb291f763d | UNKNOWN | Harsh, like usual, started studying 6 months before for his end semester examinations. He was going to complete his 8th revision of the whole syllabus, when suddenly Pranav showed up in his room with the last year's question paper for their algorithms course. This paper contains a problem which both of them couldn't so... | ["#dt = {} for i in x: dt[i] = dt.get(i,0)+1\r\nimport sys;input = sys.stdin.readline\r\ninp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]\r\n\r\nn,k = ip()\r\nx = ip()\r\nx.sort()\r\nif k == 1:\r\n a = x[n//2]\r\n b = x[n//2-1]\r\nelse:\r\n s = sum(x)\r\n a = s//n\r\n b = a + 1\r\n... | {"inputs": [["3 1", "6 1 7"]], "outputs": [["6"]]} | INTERVIEW | PYTHON3 | CODECHEF | 4,109 | |
f0bc3a6d2feac2e8fb6559f59fff28c5 | UNKNOWN | Tzuyu gave Nayeon a strip of $N$ cells (numbered $1$ through $N$) for her birthday. This strip is described by a sequence $A_1, A_2, \ldots, A_N$, where for each valid $i$, the $i$-th cell is blocked if $A_i = 1$ or free if $A_i = 0$. Tzuyu and Nayeon are going to use it to play a game with the following rules:
- The p... | ["for _ in range(int(input())):\n n=int(input())\n\n\n def maxConsequtiveOnes(lst):\n _max = 0\n _ones = [0]\n for i in lst:\n if i == 0:\n _max += 1\n if i == 1:\n _max = 0\n _ones.append(_max)\n return max(_ones)\n\n\n a = list(map(int, input().split()))\n b = maxConsequtiveOnes(a)\n if (b % 2 == 0):\... | {"inputs": [["4", "7", "1 1 0 0 0 1 1", "8", "1 0 1 1 1 0 0 1", "4", "1 1 0 1", "4", "1 1 1 1"]], "outputs": [["Yes", "No", "Yes", "No"]]} | INTERVIEW | PYTHON3 | CODECHEF | 10,942 | |
89243b1fde3e2bca84300f6af78c28e8 | UNKNOWN | Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently.
The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the puzzle is to swap the tiles until the following final state is reached:
1 2 3... | ["# cook your dish here\r\nfrom collections import deque\r\nprimes = {2,3,5,7,11,13,17}\r\nedges = [(0,3),(0,1),(1,2),(1,4),(2,5),(3,4),(3,6),(4,5),(4,7),(5,8),(6,7),(7,8)]\r\nx = [1,2,3,4,5,6,7,8,9]\r\navail = {tuple(x):0}\r\nq = deque([x])\r\nwhile q:\r\n curr = q.popleft();\r\n for e in edges:\r\n if cu... | {"inputs": [["2", "", "7 3 2 ", "4 1 5 ", "6 8 9 ", "", "9 8 5 ", "2 4 1 ", "3 7 6 ", "", ""]], "outputs": [["6", "-1"]]} | INTERVIEW | PYTHON3 | CODECHEF | 23,952 | |
0057172dfd79e6991e7f4858ce65d547 | UNKNOWN | This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by their number. Each book has a distinct number.
He has lost many books, since many of his friends borrow his books and never bother to return them. He does not want to lose any more bo... | ["def bookList():\r\n numBooks=int(input())\r\n bookNum=[int(x) for x in input().split()]\r\n takenBooks=int(input())\r\n for i in range(takenBooks):\r\n takenBookPos=(int(input()))\r\n a=bookNum[takenBookPos-1]\r\n print(a)\r\n bookNum.remove(a)\r\n\r\nbookList()\r\n", "########... | {"inputs": [["5", "26 1 42 15 3", "2", "3", "4"]], "outputs": [["42", "3"]]} | INTERVIEW | PYTHON3 | CODECHEF | 5,718 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.