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
f38f41e747575a7df97fe48ee116e5cb
UNKNOWN
Chef just come up with a very good idea for his business. He needs to hire two group of software engineers. Each group of engineers will work on completely different things and people from different groups don't want to disturb (and even hear) each other. Chef has just rented a whole floor for his purposes in business ...
["import sys\n \ndef findRoom(x,y,i):\n R = [(x,y)]\n GRID[x][y] = i\n for n in R:\n GRID[n[0]][n[1]] = i\n if n[0]>0 and GRID[n[0]-1][n[1]]==0 and H[n[0]-1][n[1]]:\n GRID[n[0]-1][n[1]] = i\n R.append((n[0]-1,n[1]))\n if n[0]<N-1 and GRID[n[0]+1][n[1]]==0 and H[n[0]][n[1]]:\n GRID[n[0]+1][n[1]] = i\n R.appen...
{"inputs": [["2 4 5 5 3", "1 2 1 3", "1 2 2 2", "1 3 2 3", "1 4 2 4", "2 1 2 2", "1 1 30 12", "1 3 10 15", "2 3 11 22"]], "outputs": [["48"]]}
INTERVIEW
PYTHON3
CODECHEF
2,733
0a808b6d2fd8061740e309afadd86ca4
UNKNOWN
You are given an equilateral triangle ΔABC with the side BC being the base. Each side of the triangle is of length L. There are L-1 additional points on each of the sides dividing the sides into equal parts of unit lengths. Points on the sides of the triangle are called major points. Joining these points with lines par...
["try:\n\n for j in range(1,int(input())+1):\n n,k = map(int,input().split())\n\n if k>n:\n c=0\n else:\n c = n-k+1\n\n s = c*(c+1)//2\n print('Case', str(j)+':',s)\nexcept:\n pass", "\n\ntry:\n\n for j in range(1,int(input())+1):\n n,k = list(map(int,input().split()))\n\n if k>n:\n c=0\n else:\n c = n-...
{"inputs": [["2", "4 3", "4 4"]], "outputs": [["Case 1: 3", "Case 2: 1"]]}
INTERVIEW
PYTHON3
CODECHEF
4,812
6dea30e848e1a23430e4327f825efe98
UNKNOWN
A despotic king decided that his kingdom needed to be rid of corruption and disparity. He called his prime minister and ordered that all corrupt citizens be put to death. Moreover, he wanted this done quickly. The wily prime minister realised that investigating every citizen to decide who was corrupt and who was not wa...
["n,m=map(int,input().split())\r\nl=[]\r\nleng=0\r\nfor i in range(n+m):\r\n w=int(input())\r\n if w==-1:\r\n cm=0\r\n mi=0\r\n for j in range(leng):\r\n if l[j]>cm:\r\n cm=l[j]\r\n mi=j\r\n \r\n print(cm)\r\n l[mi]=-1\r\n else:...
{"inputs": [["10 3", "1", "3", "7", "6", "-1", "5", "-1", "18", "9", "11", "2", "-1", "4"]], "outputs": [["7", "6", "18"]]}
INTERVIEW
PYTHON3
CODECHEF
9,603
8016934e7bc1d740b5bee208257ed358
UNKNOWN
Chef has many friends, but his best friend is Hemant. They both love to watch anime. In fact, their weekends are meant for that only. Also, Hemant is highly into games, of which Chef is unaware. Hemant once gave a game to Chef and asked him to determine the winner of the game. Since the Chef is busy, and you are also h...
["\nfor _ in range(int(input())):\n n=int(input())\n if(n<3):\n print(\"B\")\n else:\n if(n==3):\n print(\"A\")\n elif(n%2):\n print(\"B\")\n else:\n print(\"B\")\n\n\n\n\n\n\n\n\n", "for _ in range(int(input())):\n n=int(input())\n if n%2==0:\...
{"inputs": [["3", "1", "3", "7"]], "outputs": [["B", "A", "B"]]}
INTERVIEW
PYTHON3
CODECHEF
5,297
747809bf7926185712187e7a4591be74
UNKNOWN
The chef is trying to solve some series problems, Chef wants your help to code it. Chef has one number N. Help the chef to find N'th number in the series. 0, 1, 5, 14, 30, 55 ….. -----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 i in range(T):\n n=int(input())\n if n==1:\n print(\"0\")\n else:\n n=n-2\n l=(n+1)*(2*n+3)*(n+2)/6\n print(int(l))\n", "\n\nfor _ in range(int(input())):\n k=int(input())\n print(int(((k-1)*(k)*(2*k-1))/6))\n", "testcases=int(input())\r\nfor i in range(t...
{"inputs": [["3", "1", "7", "8"]], "outputs": [["0", "91", "140"]]}
INTERVIEW
PYTHON3
CODECHEF
4,039
117c78b97ba9e6156b9a5be29439969f
UNKNOWN
Snackdown 2019 is coming! There are two rounds (round A and round B) after the qualification round. From both of them, teams can qualify to the pre-elimination round. According to the rules, in each of these two rounds, teams are sorted in descending order by their score and each team with a score greater or equal to t...
["# cook your dish here\n#t = int(input())\nfor i in range(int(input())):\n n,k = map(int,input().split())\n l = list(map(int,input().split()))\n l.sort(reverse = True)\n c = 0\n for i in l:\n if i >= l[k-1]:\n c += 1\n print(c)", "# cook your dish here\nt = int(input())\nfor i in range(t):\n n,k = map(int,input().s...
{"inputs": [["2", "5 1", "3 5 2 4 5", "6 4", "6 5 4 3 2 1"]], "outputs": [["2", "4"]]}
INTERVIEW
PYTHON3
CODECHEF
6,057
fc99bc361fd0c2bbec887910513bce8e
UNKNOWN
The government of Siruseri has just commissioned one of the longest and most modern railway routes in the world. This route runs the entire length of Siruseri and passes through many of the big cities and a large number of small towns and villages in Siruseri. The railway stations along this route have all been constru...
["#for _ in range(int(input())):\n#n,m = map(int,input().split())\n#n = int(input())\n#x = [int(w) for w in input().split()]\n#x = [int(input()) for _ in range(n)]\n#for i in range(n):\n#dt = {} for i in x:dt[i] = dt.get(i,0)+1\n#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}\n\nfrom bisect import bisect_l...
{"inputs": [["8", "-20", "90", "-30", "-20", "80", "-70", "-60", "125"]], "outputs": [["-5", "6 8"]]}
INTERVIEW
PYTHON3
CODECHEF
1,216
9154bb964900942202c8cbcf3876b8bb
UNKNOWN
Gru wants to distribute $N$ bananas to $K$ minions on his birthday. Gru does not like to just give everyone the same number of bananas, so instead, he wants to distribute bananas in such a way that each minion gets a $distinct$ amount of bananas. That is, no two minions should get the same number of bananas. Gru also l...
["from math import sqrt\n\nfor _ in range(int(input())):\n \n n, k = map(int, input().split())\n fact,i = [],1\n \n while i<=sqrt(n):\n\n if n%i==0:\n if (n // i != i):\n fact.append(n//i)\n \n fact.append(i)\n \n i+=1\n \n tot = (k*(k+1))//2\n mx = -1\n \n for i in fact:\n if i>=tot:\n mx = max(mx,n//...
{"inputs": [["1", "6 3"]], "outputs": [["1"]]}
INTERVIEW
PYTHON3
CODECHEF
5,263
f4545c3932d525beba2723f89e7f2d93
UNKNOWN
Teacher brought a fruit basket for three students. The basket contains only Apples, Mangoes and Oranges. Student A knows a value $a$, the total number of Apples and Mangoes in the Basket, B knows a value $b$, the total number of Mangoes and Oranges in the basket and Student C knows a value $c$, the total number of Oran...
["# cook your dish here\nfor j in range(int(input())):\n \n p,q,r,s =map(int,input().split())\n x=(s-p)\n y=(s-q)\n z=(s-r)\n print(y,z,x)", "def __starting_point():\n try:\n for i in range(int(input())):\n a,b,c,d=list(map(int,input().split()))\n print(d-b, d-c,d-a)\n except:\n pass\n\n\n\n\n\n__starting_point()...
{"inputs": [["2", "7 9 8 12", "3 8 7 9"]], "outputs": [["3 4 5", "1 2 6"]]}
INTERVIEW
PYTHON3
CODECHEF
3,723
45ef607d7181f5afc1f31ff3ff012f9e
UNKNOWN
There are $N$ cars (numbered $1$ through $N$) on a circular track with length $N$. For each $i$ ($2 \le i \le N$), the $i$-th of them is at a distance $i-1$ clockwise from car $1$, i.e. car $1$ needs to travel a distance $i-1$ clockwise to reach car $i$. Also, for each valid $i$, the $i$-th car has $f_i$ litres of gaso...
["for _ in range(int(input())):\n n=int(input())\n f=list(map(int,input().split()))\n sum1=f[0]\n d=0\n i=1 \n while sum1!=0 and i<n:\n sum1=sum1-1+f[i]\n d+=1 \n i+=1 \n print(d+sum1)\n", "t = int(input())\n\nfor _ in range(t):\n n = int(input())\n flag = 0\n \n f = [int(x) for x in input().split()]\n \n for i in r...
{"inputs": [["3", "5", "3 0 0 0 0", "5", "1 1 1 1 1", "5", "5 4 3 2 1"]], "outputs": [["3", "5", "15"]]}
INTERVIEW
PYTHON3
CODECHEF
6,344
739ee8a620d570c1c7fbbb98f6267969
UNKNOWN
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to city $y$, he needs to pay $f(x, y) = |v_y-v_x|+y-x$ coins (this number can b...
["# cook your dish here\nimport bisect\nfor _ in range(int(input())):\n N,Q=list(map(int,input().strip().split(' ')))\n V=list(map(int,input().strip().split(' ')))\n VV=sorted(V)\n for ___ in range(Q):\n x,y=list(map(int,input().strip().split(' ')))\n x-=1\n y-=1\n ans1=abs(V[x]-V[y])+(y-x)\n post1=bisect.bisect_l...
{"inputs": [["2", "4 2", "4 2 5 7", "2 3", "3 4", "2 1", "1 1", "2 1"]], "outputs": [["4 3", "3 2", "-1 2"]]}
INTERVIEW
PYTHON3
CODECHEF
3,543
7e282636178ed8770e11c532f4c94b94
UNKNOWN
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Chef has a positive integer N. He can apply any of the following operations as many times as he want ...
["# cook your dish here\nfor _ in range(0,int(input())):\n n=input().strip()\n x=n.count('4')\n y=n.count('7')\n print(len(n)-x-y)\n ", "# cook your dish here\nfor _ in range(int(input())):\n N=list(input().strip())\n a=N.count('4')\n b=N.count('7')\n print(len(N)-a-b)", "t = int(input())...
{"inputs": [["3", "25", "46", "99", "", ""]], "outputs": [["2", "1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
4,087
27a593292072afce19ae59c84f3a3749
UNKNOWN
Sometimes Sergey visits fast food restaurants. Today he is going to visit the one called PizzaKing. Sergey wants to buy N meals, which he had enumerated by integers from 1 to N. He knows that the meal i costs Ci rubles. He also knows that there are M meal sets in the restaurant. The meal set is basically a set of meals...
["T = int(input())\nfor t in range(T):\n n, m = list(map(int, input().split()))\n c = list(map(int, input().split()))\n dp1 = [1e9]*((1 << n)+1)\n for i in range(n):\n dp1[1 << i] = c[i] \n \n dp1[1 << (n-1)] = min(dp1[1 << (n-1)], sum(c))\n \n for i in range(m):\n l = list(map(int, input().split()))\n cost = l[0]\n...
{"inputs": [["1", "3 3", "3 5 6", "11 3 1 2 3", "5 2 1 2", "5 2 1 3"]], "outputs": [["10"]]}
INTERVIEW
PYTHON3
CODECHEF
3,971
aeb6dfbdadf1c27eb75f71f0bbff685b
UNKNOWN
The country of Siruseri has A∗B$A*B$ districts. You want to create A$A$ states from these districts, such that each state has exactly B$B$ districts, and each district is part of exactly one state. You don't care about the geographical location of the districts. You can pick any B$B$ districts and make it into a state....
["# cook your dish here\nfor _ in range(int(input())):\n A,B=list(map(int,input().split()))\n l1=list(map(int,input().split()))\n l2=list(map(int,input().split()))\n for i in range(A*B):\n if l1[i]<l2[i]:\n l1[i]=0\n else:\n l2[i]=0\n l1.sort(reverse=True)\n l2.sort(reverse=True)\n \...
{"inputs": [["3", "1 3", "4 2 9", "5 6 7", "1 3", "4 2 9", "5 10 7", "3 3", "7 14 11 4 15 5 20 1 17", "2 13 16 9 19 6 12 8 10"]], "outputs": [["1", "0", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
2,542
f3bc7382e285c89175b5385b1fecc0af
UNKNOWN
Chef loves to play games. Now he plays very interesting game called "Segment". At the beginning Chef has segment [0, X] and no points on it. On each step Chef chooses the subsegment of maximal length possible such as it contains no points on it. If there are more than one such subsegment Chef chooses the one with the m...
["t = int(input())\nfrom math import log, ceil, floor\nwhile t:\n t-=1 \n n,k = map(int ,input().split())\n v = floor(log(k, 2))\n block = 1 << v + 1 \n print(n / block * (1 + (k - 2 ** v) * 2 ))", "T = int(input())\nfor _ in range(T):\n X, K = [int(x) for x in input().split()]\n \n x, y = 2, 1\n while x <= K:\n x, y ...
{"inputs": [["4", "10 1", "10 2", "10 3", "1000000000 1234567"]], "outputs": [["5.0000", "2.5000", "7.5000", "177375316.6198730500000000"]]}
INTERVIEW
PYTHON3
CODECHEF
1,115
e73e0ed24da41a7b8d5fdbf7d861528b
UNKNOWN
Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2*v and its right child will be labelled 2*v+1. The root is labelled as 1. You are given N queries of the form i j. For each query, you have to print the len...
["t=eval(input())\nfor _ in range(t):\n i,j=list(map(int,input().split()))\n bi=bin(i)[2:]\n bj=bin(j)[2:]\n k=0\n while k<(min(len(bi),len(bj))):\n if bi[k]!=bj[k]:\n break\n else:\n k+=1\n print(len(bi)-k+len(bj)-k)\n \n", "n = int(input())\nfor _ in range(n):\n x, y = list(map(int, input().split()))\n bx = bin...
{"inputs": [["3", "1 2", "2 3", "4 3"]], "outputs": [["1", "2", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
9,506
ad648d1e09cd649f099d18f254fe7a0d
UNKNOWN
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence ― what could possibly be a better birthday gift than a sequence! After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ...
["mod=10**9+7\ndef pow2(x):\n p,n=1,2\n while(x):\n if(x & 1): p=((p%mod) * (n%mod))%mod\n\n n=((n%mod) * (n%mod))%mod\n x//=2\n\n return p\n\ndef count_bit(val):\n bit=0\n while(val):\n bit+=1\n val &=(val-1)\n return bit\n \ndef answer():\n\n val=b[0]\n po2=0\n for i in range(1,len(b)):\n if(val > b[i]):retur...
{"inputs": [["2", "2", "2 3", "4", "2 6 7 7"]], "outputs": [["2", "64"]]}
INTERVIEW
PYTHON3
CODECHEF
8,893
d53fd0f0fc03ac5003a7b4eeafc79fd5
UNKNOWN
Zonal Computing Olympiad 2014, 30 Nov 2013 In ICO School, all students have to participate regularly in SUPW. There is a different SUPW activity each day, and each activity has its own duration. The SUPW schedule for the next term has been announced, including information about the number of minutes taken by each ac...
["import math\nn = int(input())\na=list(map(int,input().split()))\ndp = [0 for x in range(n)]\ndp[0] = a[0]\ndp[1] = a[1]\ndp[2] = a[2]\nfor x in range(3,n):\n dp[x] = a[x] + min(dp[x-1],dp[x-2],dp[x-3])\n\nprint(min(dp[-3:]))\n", "# cook your dish here\nINT_MAX=1000000000000000000\nn=int(input())\nar=list(map(int,i...
{"inputs": [["10", "3 2 1 1 2 3 1 3 2 1"]], "outputs": [["4", "("]]}
INTERVIEW
PYTHON3
CODECHEF
10,837
1142559d5d8368d933d7a87b667b5269
UNKNOWN
Dinesh is very fond of sweets recently his aunt Riya gifted him an array $a$ of sweets of size $N$. The ith sweet is of the type $a[i]$. His mother told him that he can choose one type of sweet in a day and eat at most 2 sweets of that type. Since he has to eat all the sweets as quickly as possible because his cousins ...
["# cook your dish here\nn=int(input())\nlst=list(map(int,input().split()))\ndict1={}.fromkeys(lst,0)\nfor key in lst:\n dict1[key]+=1\nsum1=0\nfor key in dict1:\n sum1+=dict1[key]//2\n if(dict1[key]%2==1):\n sum1+=1\nprint(sum1) ", "# cook your dish here\nn = int(input())\na = list(map(int,input().split()))\nv = dict...
{"inputs": [["3", "1 2 2"]], "outputs": [["2"]]}
INTERVIEW
PYTHON3
CODECHEF
5,739
d51bbc0d0f4dd476513795cf182bb874
UNKNOWN
A printer – who still uses moveable type – is preparing to print a set of pages for a book. These pages are to be numbered, as usual. The printer needs to know how many instances of each decimal digit will be required to set up the page numbers in the section of the book to be printed. For example, if pages 10, 11, 12...
["line = input()\ntest = 0\n\nwhile line != \"0\":\n test += 1\n d = {'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}\n a = list(map(int,line.split()))\n for i in range(min(a),max(a)+1):\n for c in str(i):\n d[c] += 1\n pairs = list(d.items())\n pairs.sort() \n ...
{"inputs": [["10 15", "912 912", "900 999", "0", "", ""]], "outputs": [["Case 1: 0:1 1:7 2:1 3:1 4:1 5:1 6:0 7:0 8:0 9:0", "Case 2: 0:0 1:1 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:1", "Case 3: 0:20 1:20 2:20 3:20 4:20 5:20 6:20 7:20 8:20 9:120"]]}
INTERVIEW
PYTHON3
CODECHEF
2,695
2574a44d023a023d27d6dbbf83eef525
UNKNOWN
The $String$ Family gave birth to a new $Tripartite$ $trio$ $sisters$ and named them $Hema$, $Rekha$ and $Sushma$. Hema and Rekha are very fond of parties whereas Sushma hates them. One day Hema and Rekha asked their parents to buy them candies to distribute to people in their birthday party. (Remember Hema, Rekha and ...
["from math import gcd\r\ndef compute_lcm(x, y):\r\n lcm = (x*y)//gcd(x,y)\r\n return lcm\r\n\r\ndef LCMofArray(a):\r\n lcm = a[0]\r\n for i in range(1,len(a)):\r\n lcm = lcm*a[i]//gcd(lcm, a[i])\r\n return lcm\r\n\r\nfor _ in range(int(input())):\r\n lens = int(input())\r\n arrs = [int(x) f...
{"inputs": [["1", "2", "2 3", "1"]], "outputs": [["7"]]}
INTERVIEW
PYTHON3
CODECHEF
11,506
e1a827401bddc7c166a903627db32663
UNKNOWN
-----General Statement:----- Read a number in scientific notation and output its equivalent decimal value. -----Input:----- All data is on a single line. The first integer indicates how many pairs of numbers follow. The first of each pair is A, the base number, and the second is E, the power of 10. -----Output:----- ...
["#In the Name of God\r\nimport math\r\n\r\nx = input().split()\r\nn = int(x[0])\r\narr = []\r\ni = 1\r\nwhile(i<len(x)):\r\n\tarr.append(float(x[i]))\r\n\ti += 1\r\n\tarr.append(int(x[i]))\r\n\ti += 1\r\ni = 0\r\n\r\nans = []\r\nwhile(i<len(arr)):\r\n\tx = arr[i]\r\n\ti += 1\r\n\ty = arr[i]\r\n\ty = 10**y\r\n\ti += 1\...
{"inputs": [["4 4.296 3 3.8 -2 1.8 2 2.8678 1"]], "outputs": [["4296.00", "0.04", "180.00", "28.68"]]}
INTERVIEW
PYTHON3
CODECHEF
3,868
99f6da9585adcfde6bc090762f4f2c60
UNKNOWN
Vasya learned about integer subtraction in school. He is still not very good at it, so he is only able to subtract any single digit number from any other number (which is not necessarily single digit). For practice, Vasya chose a positive integer n$n$ and wrote it on the first line in his notepad. After that, on the se...
["# cook your dish here\ndef getAns(num):\n if num<10:return 2 \n last=int(str(num)[0]);rem=int(str(num)[1:]);steps=2;p=len(str(num))-1\n while True:\n steps+=rem//last+1;rem=rem%last \n if last>0:rem=rem+10**p-last\n last=last-1\n if last==0:\n p=p-1;last=9\n if(len(str(rem))==1):rem...
{"inputs": [["3", "2", "3", "100"]], "outputs": [["9", "10", "170"]]}
INTERVIEW
PYTHON3
CODECHEF
1,496
c52a603dceb74760ca4ade3804d1560f
UNKNOWN
You are given a sequence $A_1, A_2, \ldots, A_N$. You should select a (not necessarily contiguous) subsequence of $A$ and reverse it. In other words, if you select a subsequence $A_{i_1}, A_{i_2}, \ldots, A_{i_K}$ ($1 \le i_1 < \ldots < i_K \le N$), then for each valid $j$, the $i_j$-th element of the resulting sequenc...
["for _ in range(int(input())):\n n = int(input())\n a = list(map(int,input().split()))\n ans = 0\n count = 0\n for i in a:\n if i>0:\n ans+=i\n count+=1\n res = []\n for i in range(count):\n if a[i]<=0:\n res.append(i+1)\n for i in range(count,n):\n if a[i]>0:\n res.append(i+1)\n print(ans)\n print(len(res)...
{"inputs": [["2", "5", "-4 2 -4 3 -5", "3", "-3 -2 -1"]], "outputs": [["5", "2 2 3", "0", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
10,546
e23398d788eea33caedbef91c9658dd8
UNKNOWN
You are given a sequence $A_1, A_2, \ldots, A_N$. Calculate the number of ways to remove a non-empty contiguous subsequence from it such that the resulting sequence is non-empty and strictly increasing. -----Input----- - The first line of the input contains a single integer $T$ denoting the number of test cases. The d...
["import bisect\n\ndef pre(a):\n for p in range(n-1):\n if(a[p]>=a[p+1]):\n return p\n return n-1 \n \ndef suf(a):\n for s in range(1,n):\n if(a[n-s]<=a[n-s-1]):\n return n-s\n return 0\n \n \n\nt=int(input())\nfor _ in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n \n p=pre(a)\n s=suf(a)\n \n b=...
{"inputs": [["2", "3", "1 1 2", "4", "2 4 3 5"]], "outputs": [["4", "7"]]}
INTERVIEW
PYTHON3
CODECHEF
14,917
82364ae28b3c2e3ba85af0d773102a02
UNKNOWN
Chef is multi-talented. He has developed a cure for coronavirus called COVAC-19. Now that everyone in the world is infected, it is time to distribute it throughout the world efficiently to wipe out coronavirus from the Earth. Chef just cooks the cure, you are his distribution manager. In the world, there are $N$ countr...
["import math\nfor i in range(int(input())):\n n,x=list(map(int,input().split()))\n l=list(map(int,input().split()))\n l.sort()\n flag=0\n d=0\n \n for j in range(n):\n \n if l[j]>x:\n for k in range(j,n):\n \n if x<l[k]:\n \n \n d+=(math.ceil(math.log(l[k]/x)/math.log(2))+1)\n \n else:\n ...
{"inputs": [["3", "5 5", "1 2 3 4 5", "5 1", "40 30 20 10 50", "3 10", "20 1 110"]], "outputs": [["5", "9", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
9,555
a7e49efa77c6af4bab0d5c1b21976d59
UNKNOWN
One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not. A dish Si is called special if it's name (i.e. the string Si) can be represented in the form of a double string by removing at most one (possibly zero)...
["# cook your dish here\ndef check_equal(a,b):\n index=0\n for i in a:\n while index<len(b) and i != b[index]:\n index+=1\n if(index>=len(b)):\n return False\n index+=1 \n return True\ndef Dob_String(n):\n size=len(n)\n midpoint=size//2\n if(check_equal(n[0:midpoint],n[midpoint:size])):\n return(\"YES\")\n elif...
{"inputs": [["3", "aba", "abac", "abcd"]], "outputs": [["YES", "NO", "NO"]]}
INTERVIEW
PYTHON3
CODECHEF
7,612
8c2662a44ecff67124af907cb8bab78c
UNKNOWN
You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N. -----Input----- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The first line of each description consists of a single integer N. T...
["# cook your dish here\ndef __starting_point():\n try:\n for _ in range (int(input())):\n element = int(input())\n l = list(map(int,input().split()))\n a=min(l)\n l.remove(a)\n b=min(l)\n print(a+b)\n except EOFError :\n print('EOFError')\n\n__starting_point()", "for _ in range(int(input())):\n n=int(inp...
{"inputs": [["1", "4", "5 1 3 4"]], "outputs": [["4"]]}
INTERVIEW
PYTHON3
CODECHEF
4,768
6a545369ec6e93aa0752f106ad205607
UNKNOWN
At the legendary times of Nonsenso wars in ISM Dhanbad, there was a neck to neck competition between Barney Stinson and Sheldon Cooper. They both were on level 19. After trying too hard both of them could not decipher the nonsense, so they decided to play alongside. Sheldon Cooper had to pass a message to Barney Stinso...
["for _ in range(int(input())):\n code=input().strip()+'0'\n message=''\n asc=int(code[0])\n \n for i in range(len(code)-1):\n \n if int(str(asc)+code[i+1])>256:\n message+=chr(asc)\n asc=int(code[i+1])\n else: \n asc=int(str(asc)+code[i+1])\n \n print(message)\n"]
{"inputs": [["2", "721011081081113287111114108100", "871011089911110910132116111327311010010597"]], "outputs": [["Hello World", "Welcome to India"]]}
INTERVIEW
PYTHON3
CODECHEF
279
c37bb9d81ff7b1646bfdb6e70ee0f6e1
UNKNOWN
VK gave a problem to Chef, but Chef is too lazy, so he asked you to solve the problem for him. The statement of the problem follows. Consider an integer with $N$ digits (in decimal notation, without leading zeroes) $D_1, D_2, D_3, \dots, D_N$. Here, $D_1$ is the most significant digit and $D_N$ the least significant. T...
["for _ in range(int(input())):\n n,w = map(int , input().split())\n sigma = 1\n #len(str(num)) == n and D[i] - D[i - 1] ... = w\n if(w > 9 or w < -9):\n print(0)\n continue\n sigma = pow(10,n - 2,1000000007)\n if(w >= 0):\n sigma *= (9 - w)\n else:\n sigma *= (w + 10)\n print(sigma % 1000000007)", "# cook your dis...
{"inputs": [["1", "2 3"]], "outputs": [["6"]]}
INTERVIEW
PYTHON3
CODECHEF
8,506
a5b2d462887446da52494cefe4f092ec
UNKNOWN
Chef Watson uses a social network called ChefBook, which has a new feed consisting of posts by his friends. Each post can be characterized by f - the identifier of the friend who created the post, p - the popularity of the post(which is pre-calculated by ChefBook platform using some machine learning algorithm) and s - ...
["import sys\nans=0\nn,m=list(map(int,input().split()))\naaaaa=100\nli=list(map(int,input().split()))\nnon_special,special=[],[]\nfor i in range(m):\n ans+=1\n f,p,s=list(map(str,input().split()))\n f=int(f)\n poww=pow(1,2)\n p=int(p)\n if f not in li:\n ans+=1\n non_special.append((p,s))\n ans-=1\n else:\n ans+=1\...
{"inputs": [["2 4", "1 2", "1 1 WhoDoesntLoveChefBook", "2 2 WinterIsComing", "3 10 TheseViolentDelightsHaveViolentEnds", "4 3 ComeAtTheKingBestNotMiss"]], "outputs": [["WinterIsComing", "WhoDoesntLoveChefBook", "TheseViolentDelightsHaveViolentEnds", "ComeAtTheKingBestNotMiss"]]}
INTERVIEW
PYTHON3
CODECHEF
8,019
2122ffc41701dd65cae6ce47d9710041
UNKNOWN
There are a lot of problems related to the shortest paths. Nevertheless, there are not much problems, related to the shortest paths in average. Consider a directed graph G, consisting of N nodes and M edges. Consider a walk from the node A to the node B in this graph. The average length of this walk will be total sum o...
["from collections import defaultdict\nimport copy\n#def dfs(l,r,dct):\ndef dfs(l,r,dct):\n visit=[0 for i in range(n+1)]\n arr=[l]\n while(arr):\n node=arr.pop()\n if node==r:return True\n visit[node]=1\n for lnk in dct[node]:\n if not visit[lnk]:\n arr.append(lnk)\n return False\n \ndef ok(mid,cst):\n for i,...
{"inputs": [["2", "3 3", "1 2 1", "2 3 2", "3 2 3", "1 3", "3 3", "1 2 10", "2 3 1", "3 2 1", "1 3"]], "outputs": [["1.5", "1.0"]]}
INTERVIEW
PYTHON3
CODECHEF
1,126
da0e920fb79356925d34fff2abab472f
UNKNOWN
Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 3. If any of the permutations is divisible by 3 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...
["from sys import *\ninput=stdin.readline\nfor u in range(int(input())):\n s=int(input())\n if(s%3==0):\n print(1)\n else:\n print(0)\n", "from sys import stdin, stdout\r\ninput = stdin.readline\r\nfrom collections import defaultdict as dd\r\nimport math\r\ndef geti(): return list(map(int, input(...
{"inputs": [["2", "18", "308"]], "outputs": [["1", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
757
c3747fab0a2ce7075fbce5baa8122e94
UNKNOWN
Chef's love for Fibonacci numbers helps him to design following interesting problem. He defines a function F for an array S as follows: where - Si denotes a non-empty subset of multiset S. - sum(Si) denotes the sum of all element of multiset Si. - Fibonacci(x) denotes the xth Fibonacci number. Given an array A consist...
["m= 1000000007\ndef mul(a,b):\n return [(a[0]*b[0]+a[1]*b[2])%m,\n (a[0]*b[1]+a[1]*b[3])%m,\n (a[2]*b[0]+a[3]*b[2])%m,\n (a[2]*b[1]+a[3]*b[3])%m] \ndef f(n):\n if n==0:\n return 0\n v1, v2, v3 = 1, 1, 0 \n for rec in bin(n)[3:]:\n v2=v2%m\n v1=v1%m\n v3=v3%m\n calc = (v2*v2)\n v1, v2, v3 = (v1*v1+calc), ((...
{"inputs": [["3 5", "1 2 3", "Q 1 2", "Q 2 3", "C 1 2", "Q 1 2", "Q 1 3"]], "outputs": [["4", "8", "5", "30"]]}
INTERVIEW
PYTHON3
CODECHEF
710
3d697d4dff92d247867adbda2dcfc601
UNKNOWN
The chef is having one array of N natural numbers(numbers may be repeated). i.e. All natural numbers must be less than N. Chef wants to rearrange the array and try to place a natural number on its index of the array, i.e array[i]=i. If multiple natural numbers are found for given index place one natural number to its i...
["for _ in range(int(input())):\n n=int(input())\n arr=list(map(int,input().split()))\n d=set()\n for i in arr:\n d.add(i)\n for i in range(n):\n if i in d:\n print(i,end=\" \")\n else:\n print(0,end=\" \")\n print()", "for t in range(int(input())) :\n n =...
{"inputs": [["2", "2", "1 1", "4", "1 1 2 1"]], "outputs": [["0 1", "0 1 2 0"]]}
INTERVIEW
PYTHON3
CODECHEF
6,994
fbe731a0780b5334a2320261b303c65b
UNKNOWN
Chef is very organised in whatever he does and likes to maintain statistics of his work. Chef has expertise in web development and hence is a regular contributor on a forum. Chef sometimes makes multiple contributions in a single day.. Each day chef makes at least 1 contribution he is assigned a shade of green. The gre...
["from collections import Counter\nt=int(input())\nfor i in range(t):\n k=int(input())\n l=list(map(int,input().split()))\n a=Counter(l)\n b=list(a.keys())\n b.sort()\n for x in b:\n s=str(x)+': '+str(a[x])\n print(s)", "n = int(input())\nfrom collections import Counter\nfor c in range(n):\n t = int(input())\n s = li...
{"inputs": [["1", "7", "20 6 5 3 3 1 1"]], "outputs": [["1: 2", "3: 2", "5: 1", "6: 1", "20: 1"]]}
INTERVIEW
PYTHON3
CODECHEF
1,978
b7d0da5cff3018135ead8ccbd8447a9c
UNKNOWN
You are in the future. It's the time of autonomous cars. Switching lanes is a pretty difficult task for autonomous cars, and you have the logs from an experiment you had run with two cars. You want to verify whether the logs are corrupted, or could be valid. In that experiment, you had a highway consisting of two lanes...
["# cook your dish here\ndef check(px,x):\n if px[1]==x[1]:\n return (x[2]-px[2])<=(x[0]-px[0]) and (x[2]>=px[2])\n else:\n return (x[2]-px[2]+1)<=(x[0]-px[0]) and (x[2]>=px[2])\n \ndef checkdouble(px,x):\n if px[3]==x[3]:\n return (x[4]-px[4])<=(x[0]-px[0]) and (x[4]>=px[4])\n else:\n return (x[4]-px[4]+1)<=(x[0]...
{"inputs": [["2", "3", "1 1 1 2 2", "2 2 1 2 2", "4 2 2 2 3", "1", "1 1 3 2 2"]], "outputs": [["yes", "no"]]}
INTERVIEW
PYTHON3
CODECHEF
2,294
d83f881597162ea3bd186ad857d7239c
UNKNOWN
You have a tree consisting of n vertices. You want to color each vertex of the tree in one of the k colors such that for any pair of vertices having same color, all the vertices belonging to the path joining them should also have same color. In other words, for any two vertices u, v with same color, all the vertices in...
["A = [0] * 100001\nM = 1000000007\n\ndef nCk(n, k):\n if k ==0 or k ==n:\n return 1\n r = (A[n-k]*A[k])%M\n x = (A[n]*pow(r, M-2, M))%M\n return x\n\nfor _ in range(int(input())):\n n, k = list(map(int, input().split()))\n for i in range(n-1):\n u,v = input().split()\n summ = 0\n A[0] = 1\n for i in range(1, len(A))...
{"inputs": [["3", "3 2", "1 2", "2 3", "3 1", "1 2", "2 3", "4 3", "1 2", "2 3", "2 4"]], "outputs": [["6", "1", "39"]]}
INTERVIEW
PYTHON3
CODECHEF
1,558
af8887dce2b04920aeb076bb13b81411
UNKNOWN
Chef likes to play with array elements. His teacher has given him an array problem. But now he is busy as Christmas is coming. So, he needs your help. Can you help him to solve this problem. You are given an array $(A1,A2,A3……AN)$ of length $N$. You have to create an another array using the given array in the following...
["# cook your dish here\ndef index(n,val):\n while(val >= n):\n val = val//2\n return n - val\nt = int(input())\nfor _ in range(t):\n n = int(input())\n arr = list(map(int,input().split())) \n new = [0 for i in range(n)]\n for i in range(n):\n if arr[i]<=n :\n new[i] = arr[i] ...
{"inputs": [["2", "5", "2 4 5 7 9", "4", "5 4 2 3"]], "outputs": [["6 11 14 4 2", "4 7 6 5"]]}
INTERVIEW
PYTHON3
CODECHEF
1,217
534ceb9cdfe7dad393318dbaf380b1f2
UNKNOWN
Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once. He serves them in the form of a stack. A pancake can be treated as a circular disk with some radius. Chef needs to take care that when he places a pancake on the top of the stack the radius of the pancake should not exceed the radi...
["t=[[1]]\ndef bell_numbers(start, stop):\n ## Swap start and stop if start > stop\n if stop < start: start, stop = stop, start\n if start < 1: start = 1\n if stop < 1: stop = 1\n c = 1 ## Bell numbers count\n while c <= stop:\n if c >= start:\n yield t[-1][0] ## Yield the Bell number of the previous \u00a0\u00a0\u0...
{"inputs": [["2", "1", "2"]], "outputs": [["1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
12,012
dc47fc784a7558dca17e8ef0c2e9df49
UNKNOWN
Chef owns an icecream shop in Chefland named scoORZ. There are only three types of coins in Chefland: Rs. 5, Rs. 10 and Rs. 15. An icecream costs Rs. 5. There are $N$ people (numbered $1$ through $N$) standing in a queue to buy icecream from scoORZ. Each person wants to buy exactly one icecream. For each valid $i$, the...
["# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n lst=list(map(int,input().split()))\n f=0\n t=0\n p=1\n for i in lst:\n if(i==5):\n f+=1\n elif(i==10):\n if(f>0):\n f-=1\n t+=1\n else:\n ...
{"inputs": [["3", "2", "5 10", "2", "10 5", "2", "5 15", ""]], "outputs": [["YES", "NO", "NO"]]}
INTERVIEW
PYTHON3
CODECHEF
17,637
980d2c4200e7ce427966120ee6837401
UNKNOWN
Chef Al Gorithm was reading a book about climate and oceans when he encountered the word “glaciological”. He thought it was quite curious, because it has the following interesting property: For every two letters in the word, if the first appears x times and the second appears y times, then |x - y| ≤ 1. Chef Al was happ...
["# cook your dish here\nimport bisect\n\nfor _ in range(int(input())):\n w,k=map(str, input().split())\n k=int(k)\n n=len(w)\n w=list(w)\n w.sort()\n w.append('0')\n c=1\n l=0\n l1=[]\n l2=[]\n for i in range(1, n+1):\n if w[i]==w[i-1]:\n c+=1\n else:\n a=bisect.bisect_left(l1, c)\n if a==l:\n l1.append(c)\...
{"inputs": [["4", "glaciological 1", "teammate 0", "possessions 3", "defenselessness 3"]], "outputs": [["0", "0", "1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
2,587
9d0d6d052557e2c4e7511891f1174055
UNKNOWN
There is a task in Among Us in which $N$ temperature scale with unique readings are given and you have to make all of them equal. In one second you can choose an odd number and add or subtract that number in any one temperature value. Find minimum time (in seconds) required to complete the task. $Note$: Equal value may...
["# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n ar=list(map(int,input().split()))\n odd=0\n even=0\n if n==1:\n print(0)\n continue\n for i in range(n):\n if ar[i]%2==1:\n odd+=1\n else:\n even+=1\n if odd>0:\n vo=(odd-1)*2+even\n else:\n vo=even\n if even>0:\n ve=(even-1)*2+odd\n e...
{"inputs": [["3", "5", "1 2 3 4 5", "4", "5 2 3 8", "2", "50 53"]], "outputs": [["5", "4", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
6,806
4b0a6ce8e755162f5e67e567226caddd
UNKNOWN
Watson gives to Sherlock two strings S1 and S2 consisting of uppercase English alphabets. Next he wants Sherlock to build a flower in the following way: He puts both strings perpendicular to each other in such a way that they overlap at the same character. For example, if he has two strings "ABCDEF" and "XXBCZQ", one ...
["for _ in range(eval(input())):\n S1=input()\n m1=len(S1)/2\n\n S2=input()\n m2=len(S2)/2\n d1={}\n d2={}\n for i in range(len(S1)):\n c=S1[i]\n v=abs(m1-i)\n if c in d1:\n if v<d1[c][0]:\n d1[c]=[v,i]\n else:\n d1[c]=[v,i]\n for ...
{"inputs": [["2", "ABCDE", "XXBCZQ", "BBB", "BBBBBB", "", ""]], "outputs": [["2", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
815
132c65f67849a7ef5f28054e4e96dd39
UNKNOWN
Vision has finally made it to Wakanda to get his MindStone extracted. The MindStone was linked to his brain in a highly sophisticated manner and Shuri had to solve a complex problem to extract the stone. The MindStone had $n$ integers inscribed in it and Shuri needs to apply the prefix sum operation on the array $k$ ti...
["# cook your dish here\nfrom itertools import accumulate\nn, k = map(int, input().split())\nlst = list(map(int, input().split()))\ntemp = (10**9)+7\nfor i in range(k):\n lst = list(accumulate(lst))\nfor i in lst:\n print(i%(temp), end = ' ')", "try:\n from itertools import accumulate\n n,k=map(int,input()....
{"inputs": [["4 2", "3 4 1 5"]], "outputs": [["3 10 18 31"]]}
INTERVIEW
PYTHON3
CODECHEF
6,868
b27cdf0e861dbf61a7ab1e068d25bf26
UNKNOWN
You are given a sequence of integers $A_1, A_2, \dots, A_N$. You should choose an arbitrary (possibly empty) subsequence of $A$ and multiply each element of this subsequence by $-1$. The resulting sequence should satisfy the following condition: the sum of elements of any contiguous subsequence with length greater than...
["\"\"\"\n4\n4\n4 3 1 2\n6\n1 2 2 1 3 1\n5\n10 1 2 10 5\n4\n1 2 1 2\n\"\"\"\ntests = int(input())\n\nfor _ in range(tests):\n\n n = int(input())\n ls = list(map(int, input().split()))\n\n if ls[0] < ls[1]:\n ls[0] = -ls[0]\n\n if ls[-1] < ls[-2]:\n ls[-1] = -ls[-1]\n\n for i in range(1, n - 1):\n if ls[i] < ls[i - 1...
{"inputs": [["4", "4", "4 3 1 2", "6", "1 2 2 1 3 1", "5", "10 1 2 10 5", "4", "1 2 1 2"]], "outputs": [["4 3 -1 2", "-1 2 2 -1 3 -1", "10 -1 2 10 -5", "1 2 -1 2"]]}
INTERVIEW
PYTHON3
CODECHEF
4,505
ba68fce5b3e34e2e954137f46bb1082c
UNKNOWN
A squarer is a simple and convenient device. You give it some positive integer X and it calculates its square. Leha is implementing a module of this device which is responsible for squaring the numbers consisting of multiple repetitions of one digit. But it turned out that it's not as simple as he thought. Please help ...
["val = 10**9 + 7\ndef MOD(a,b):\n aans = a\n ans = 1\n while b>0:\n ans = (ans*aans)%val\n aans = (aans*aans)%val\n b/=2\n return ans%val\n \n\n\nfor i in range(eval(input())): \n n,d= list(map(int,input().split()))\n a=int(str(d)*n)\n sqr = str(a*a)\n ans =0\n count=0\n for ii in sqr :\n ans= ans+int(ii)*23**c...
{"inputs": [["3", "1 4", "3 6", "3 5"]], "outputs": [["139", "40079781", "32745632"]]}
INTERVIEW
PYTHON3
CODECHEF
9,561
a8c3db7b04b2cdb6a6375fdd57d203c2
UNKNOWN
Chef has $N$ points (numbered $1$ through $N$) in a 2D Cartesian coordinate system. For each valid $i$, the $i$-th point is $(x_i, y_i)$. He also has a fixed integer $c$ and he may perform operations of the following type: choose a point $(x_i, y_i)$ and move it to $(x_i + c, y_i + c)$ or $(x_i - c, y_i - c)$. Now, Che...
["t = int(input())\n\nfor i in range(t):\n n, c = list(map(int,input().split()))\n\n pts = {}\n moves = 0\n\n for i in range(n):\n x, y = list(map(int,input().split()))\n if (y-x,x%c) in pts:\n pts[(y-x,x%c)].append(x)\n else:\n pts[(y-x,x%c)] = [x]\n \n for i in pts:\n arc = sorted(pts[i])\n \n for j in arc:...
{"inputs": [["1", "3 1", "1 1", "1 0", "3 2"]], "outputs": [["2 2"]]}
INTERVIEW
PYTHON3
CODECHEF
13,332
1c4faf002b3c62b1a97a1de76467d3e4
UNKNOWN
There exist certain strings, known as $Unique$ $Strings$. They possess a unique property: - The character 'c' gets converted to "ff" and the character 'k' gets converted to "gg". Any letter besides 'c' and 'k' does not get converted to any other character. Your job is to count the number of strings that could possibly...
["tb=str(input())\ntb=list(tb)\nif(\"c\" in tb or \"k\" in tb):\n print(0)\nelse:\n ans=1\n i=0\n while(i<len(tb)):\n if(tb[i]==\"g\" or tb[i]==\"f\"):\n my=tb[i]\n i+=1\n ct=1\n while(i<len(tb) and tb[i]==my):\n ct+=1\n i+=1\n if(ct>3):\n ct+=1\n ans*=ct\n else:\n i+=1\n print(ans)", "from ite...
{"inputs": [["thing", "Sample Input 2:", "ggdffn", "Sample Input 3:", "fff", "Sample Input 4:", "cat"]], "outputs": [["1", "Sample Output 2:", "4", "Sample Output 3:", "3", "Sample Output 4:", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
8,269
b54f6904a2d58967b3f716244c7501ec
UNKNOWN
Master Shifu is training Po to become The Dragon Warrior and as a final assignment he must obtain maximum deliciousness from dumplings. There are $N$ plates of dumplings in front of him with deliciousness $A_1, A_2, \ldots, A_N$, Po can choose any number of continuous plates of dumplings. The total deliciousness is t...
["# cook your dish here\nN=int(input())\nfor _ in range(N):\n n=int(input())\n arr=list(map(int,input().split()))[:n]\n count=0\n last=0\n for i in range(n):\n if(arr[i]!=0):\n break\n last=i\n count+=1\n for i in arr[-1:last:-1]:\n if(i!=0):\n break\n...
{"inputs": [["2", "4", "1 2 3 4", "5", "3 2 0 3 0"]], "outputs": [["4", "4"]]}
INTERVIEW
PYTHON3
CODECHEF
11,749
afa0e4f25d04d8c42b3cad7aa3dd2d0c
UNKNOWN
Sebi lives in Chefland where the government is extremely corrupt that usually makes fool out of public by announcing eye catching but non-sustainable schemes. Recently there was a move to increase tourism in the country that was highly lauded. Sebi wants to examine whether the move has some potential or is a hogwash as...
["from sys import stdin,stdout\n\n\n\n\ntotal_cost=0\ndef find(a):\n if par[a]==a:\n return a\n else:\n par[a]=find(par[a])\n return par[a]\ndef union(a,b,c):\n a,b=find(a),find(b)\n nonlocal total_cost\n total_cost+=(rank[a]*rank[b]*c)\n if a!=b:\n if rank[a]>rank[b]:\n par[b]=a\n rank[a]+=rank[b]\n elif rank...
{"inputs": [["3", "1 2 3", "1 3 2"]], "outputs": [["2.333333"]]}
INTERVIEW
PYTHON3
CODECHEF
3,565
1b8eaed7dbd5a8cd99eb1e1a991f83d3
UNKNOWN
The students of Codechef Middle School are visiting an amusement park. The children want to go on a ride, however, there is a minimum height requirement of $X$ cm. Determine if the children are eligible to go on the ride. Print "Yes" if they are eligible, "No" otherwise. -----Input:----- - First line will contain $T$...
["# cook your dish here\nfor _ in range(int(input())):\n h,x=map(int,input().split())\n if(h>=x):\n print(\"Yes\")\n else:\n print(\"No\")", "# cook your dish here\nimport sys\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\ndef get_list(): return list(map(int, sys.stdin.re...
{"inputs": [["2", "120 100", "90 100"]], "outputs": [["Yes", "No"]]}
INTERVIEW
PYTHON3
CODECHEF
4,349
3cf93ca5bfeff27ef8762fd42e8a5d95
UNKNOWN
Chef Vivek is good in mathematics and likes solving problems on prime numbers. One day his friend Jatin told him about Victory numbers. Victory number can be defined as a number formed after summing up all the prime numbers till given number n. Now, chef Vivek who is very fond of solving questions on prime numbers got ...
["from math import sqrt \n\ntest = int(input())\nfor i in range(test):\n sum = 0\n max = int(input())\n if max==1:\n sum = 0\n elif max==2:\n sum += 2\n else: \n sum = sum + 2\n for x in range(3,max+1):\n half = int(sqrt(x)) + 1\n if all(x%y!=0 for y in range(2,half)):\n sum = sum + x\n print(sum) ", "# c...
{"inputs": [["3", "22", "13", "10"]], "outputs": [["77", "41", "17"]]}
INTERVIEW
PYTHON3
CODECHEF
6,135
9d3285c480dd54070312be17d826e2fc
UNKNOWN
You were strolling outside the restaurant at the end of the universe. On a metaspiral path you stumble upon a weird device which takes a three-digit number as input and processes it. The Hitchhiker's guide to the galaxy explains that it processes the input in the following manner: - Multiplies it with 13, followed by ...
["for _ in range(int(input())):\n k, n = input().split()\n\n while int(n) >= 5:\n print(len(set(k)) ** 3)\n break", "for _ in range(int(input())):\n K,N = map(int, input().split())\n K=str(K)\n l=[int(d) for d in K]\n while N>=5:\n print(len(set(K))**3)\n break", "# cook your dish here\ntry:\n from sys import stdin...
{"inputs": [["1", "123 5"]], "outputs": [["27"]]}
INTERVIEW
PYTHON3
CODECHEF
4,047
21369d2993efaf683e0d7fe254a3cdec
UNKNOWN
Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which mutates minions. Each minion has an intrinsic characteristic value (similar...
["for i in range(int(input())):\n yy=input()\n y=[int(e) for e in yy.split()]\n zz=input()\n z=[int(e) for e in zz.split()]\n count=0\n for i in z:\n a=i+y[1]\n if a%7==0:\n count+=1\n print(count)", "# cook your dish here\nn=int(input())\nfor i in range(n):\n m,k=map(int,input().split())\n l=list(map(int,input().s...
{"inputs": [["1", "5 10", "2 4 1 35 1"]], "outputs": [["1"]]}
INTERVIEW
PYTHON3
CODECHEF
4,799
40c54a71d2b4bd17f9a222fb3d94cab2
UNKNOWN
The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at the location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to the office. -----Input:----- The first line of the data set for this prob...
["# cook your dish here\ntry:\n t = int(input())\n for i in range(t):\n ar=list(map(int,input().split()))\n if (ar[0]**2 + ar[1]**2 > ar[2]**2 + ar[3]**2):\n print(\"B IS CLOSER\")\n else:\n print(\"A IS CLOSER\")\n \n \n \nexcept:\n pass\n \n \n", "# cook your dish here\nfor _ in range(int(input())):\n a,b,c...
{"inputs": [["4", "3 -2 -5 -3", "0 6 1 2", "-7 8 4 -1", "3 3 -2 2"]], "outputs": [["A IS CLOSER", "B IS CLOSER", "B IS CLOSER", "B IS CLOSER"]]}
INTERVIEW
PYTHON3
CODECHEF
5,808
721b05fd0f99c4eb9d601cce7738e827
UNKNOWN
Chef made $N$ pieces of cakes, numbered them $1$ through $N$ and arranged them in a row in this order. There are $K$ possible types of flavours (numbered $1$ through $K$); for each valid $i$, the $i$-th piece of cake has a flavour $A_i$. Chef wants to select a contiguous subsegment of the pieces of cake such that there...
["def main():\n t= int(input())\n while(t!=0):\n n,k = list(map(int , input().split()))\n arr = list(map(int, input().split()))\n freq = [0]*100001\n k=k-1\n st=0\n end=0\n currentCount=0\n previousElement = 0\n for i in range(n):\n freq[arr[i]]+=1\n if(freq[arr[i]]==1):\n currentCount+=1\n\n while(cu...
{"inputs": [["2", "6 2", "1 1 1 2 2 1", "5 3", "1 1 2 2 1"]], "outputs": [["3", "5"]]}
INTERVIEW
PYTHON3
CODECHEF
12,839
7e79ec50a0fdfcad688f583c82959f6f
UNKNOWN
Chef Hari has got a new obsession now: he has started playing chess (read about it here) and he is liking this game very much. Since Hari has spent several months playing chess with his friends, he has now decided to take part in some chess tournament in Cheftown. There are currently two tournaments going on in Chefto...
["t=eval(input())\nwhile t>0:\n t=t-1\n f1,f2,r1,r2,r3,r4=list(map(int,input().split()))\n p1,p2,p3,p4=list(map(float,input().split()))\n s1=(1-p1)*(-f1)+(r2-f1)*(1-p2)*p1+p1*p2*(r1-f1)\n s2=(1-p3)*(-f2)+(r3-f2)*(p3)*(1-p4)+p3*p4*(r3+r4-f2)\n if s1>s2:\n print('FIRST')\n elif s1<s2:\n print('SECOND')\n el...
{"inputs": [["2", "30 50 70 10 40 30", "0.25 0.10 0.30 0.05", "50 36 80 38 65 32", "0.55 0.12 0.33 0.54"]], "outputs": [["FIRST", "SECOND"]]}
INTERVIEW
PYTHON3
CODECHEF
1,589
c8d6a35d2b6de87d66c48264295190b6
UNKNOWN
-----Problem description.----- This problem deals with the I/O methods used in codechef. You are supposed to print the integer in its reverse form , or in simple words, print the reverse of the given integer . For instance , reverse of 120 is 21 (not 021) . -----Input----- - The first line of each test case contai...
["t = int(input())\nwhile t > 0:\n\n s = int(input())\n\n while s % 10 == 0 : \n s /= 10\n\n print(''.join(reversed(str(s))))\n\n t = t - 1", "for t in range(int(input())):\n y=list(input())\n y.reverse()\n print(int(''.join(y)))", "for _ in range(int(input())):\n n=int(input())\n p=str(n)\n p=p[::-1]\n print(int(p))"...
{"inputs": [["3", "1234", "4567", "1"]], "outputs": [["4321", "7654", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
2,157
12c406fd8ef24c851b5955bde11a5a66
UNKNOWN
Salmon loves to be a tidy person. One day, when he looked at the mess that he made after playing with his rubber ducks, he felt awful. Now he wants to clean up his mess, by placing his ducks into boxes. Each rubber duck has a color. There are a total of $N+1$ colors, numbered from $0$ to $N$. Salmon wants to place his ...
["# cook your dish here\nfor _ in range(int(input())):\n n,k=map(int,input().split())\n c=[int(i) for i in input().split()]\n i=0\n m=0\n if(n==2 and k==5):\n c1=c\n c.sort()\n d=dict()\n for i in range(len(c)):\n for j in range(len(c1)):\n if(c[i]==c1[j]):\n d[i]=j\n c1[j]=-1\n break\n \n while...
{"inputs": [["1", "2 4", "3 4 1"]], "outputs": [["2 1 1 3", "1 1 0 3"]]}
INTERVIEW
PYTHON3
CODECHEF
11,819
9e7587c0fb886987fcf89ca5e0658e3b
UNKNOWN
-----General Statement:----- Given the actual high and low temperatures for the day and the normal high and low temperatures for that day, calculate the average difference from normal. -----Input:----- The first line of the data set for this problem is an integer that represents the number of data sets that follow. Ea...
["# cook your dish here\nfor _ in range (int(input())):\n x1,y1,x2,y2=map(int,input().split())\n av1=(x1+y1)/2\n av2=(x2+y2)/2\n if(av1>av2):\n print(av1-av2,\" DEGREE(S) ABOVE NORMAL\")\n else:\n print(av2-av1,\" DEGREE(S) BELOW NORMAL\")", "for i in range(int(input())):\r\n a,b,c,d=map...
{"inputs": [["3", "75 45 78 40", "50 32 45 30", "56 48 62 45"]], "outputs": [["1.0 DEGREE(S) ABOVE NORMAL", "3.5 DEGREE(S) ABOVE NORMAL", "1.5 DEGREE(S) BELOW NORMAL"]]}
INTERVIEW
PYTHON3
CODECHEF
1,677
aeac4fd340957d4facb57798a76ef5e0
UNKNOWN
There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 particle to move to the immediate next chamber(if current chamber is 0, then ...
["a,n,k = map(int,input().split())\nfor i in range(k):\n print(a%(n+1),end=' ')\n a=a//(n+1)", "# cook your dish here\na,n,k=map(int,input().split())\nfor i in range(k):\n print(a%(n+1),end=' ')\n a=a//(n+1)\n ", "a,n,k=list(map(int,input().split()))\ns=[]\n\nwhile k:\n s.append(a%(n+1))\n a=a//(n+1)\n k-=1\n\nprint(*s...
{"inputs": [["3 1 3"]], "outputs": [["1 1 0"]]}
INTERVIEW
PYTHON3
CODECHEF
3,972
cd08b9292b35890acaa960b0df5fb2fb
UNKNOWN
A simple string contains a large repetition of letters within it. This problem is related to string handling and manipulation. An original message is sent from planet Earth to planet Cybertron in form of a string. However, the letter position and string size is not important. The number of time each letter has occurre...
["import sys,math\n\ndef main(filename):\n inputfile = open(filename,'rU')\n data = inputfile.readlines()\n T=data.pop(0)\n ans=[]\n ansstring=str()\n explored=[]\n for i in T:\n if i in explored:\n #print explored\n for j in range(len(ans)):\n if ans[j][0]==i:\n ans[j][1] += 1\n else:\n ans.append([i,1]...
{"inputs": [["information"]], "outputs": [["i2n2f1o2r1m1a1t1"]]}
INTERVIEW
PYTHON3
CODECHEF
1,743
a5cbd28dec02929ecc34a4eea2ce47cc
UNKNOWN
The chef was searching for his pen in the garage but he found his old machine with a display and some numbers on it. If some numbers entered then some different output occurs on the display. Chef wants to crack the algorithm that the machine is following. Example to identify the pattern : Input ...
["# cook your dish here\nT = int(input())\n\nfor t in range(T):\n N = int(input())\n \n print(int(((N-1)*(N))/2))", "# cook your dish here\nT = int(input())\n\nfor t in range(T):\n N = int(input())\n \n print(int(((N-1)*(N))/2))", "T = int(input())\r\n\r\nfor t in range(T):\r\n N = int(input())\r\n...
{"inputs": [["1", "7"]], "outputs": [["21"]]}
INTERVIEW
PYTHON3
CODECHEF
801
3958db6172c2b10ed0baf2d4bf15195f
UNKNOWN
Chef works as a cook in a restaurant. Each morning, he has to drive down a straight road with length K$K$ to reach the restaurant from his home. Let's describe this road using a coordinate X$X$; the position of Chef's home is X=0$X = 0$ and the position of the restaurant is X=K$X = K$. The road has exactly two lanes (n...
["# cook your dish here\nt = int(input())\nfor _ in range(t):\n n, k, d = list(map(int, input().split()))\n x = list(map(int, input().split()))\n l = list(map(int, input().split()))\n lane = 3 - l[0]\n switched = -float('inf')\n ans = k\n for i in range(n):\n if l[i] == lane:\n if switched...
{"inputs": [["4", "2 10 20", "4 7", "1 2", "4 15 20", "4 6 9 13", "1 2 2 1", "5 10 1", "1 3 5 7 9", "1 2 1 2 1", "2 10 2", "4 5", "1 2"]], "outputs": [["10", "13", "10", "5"]]}
INTERVIEW
PYTHON3
CODECHEF
3,273
2d8de9ecb8aae7fb23b9720e6fe086ff
UNKNOWN
Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0. Chef can use two types of operations. The first type is to increase all the integers of the given array by 1, but it costs X coins. The operation of the second type...
["n=int(input())\na=list(map(int,input().split()))\nx=int(input())\nl=[]\nfor i in a:\n if i<0:\n l.append(-i)\nl.sort()\nm=len(l)\nans=0\nif l:\n if x>n:\n ans=sum(l)\n else:\n ans=sum(l[m-x:])\nprint(ans)\n\n \n", "# cook your dish here\nn=int(input())\nk=n+1\ntotal=0\na=list(map(int,input().split()))\nx=int(input...
{"inputs": [["3", "-1 -2 -3", "2"]], "outputs": [["5"]]}
INTERVIEW
PYTHON3
CODECHEF
7,255
be304090a8fb3940911612106d3d247e
UNKNOWN
Due to COVID19 all employees of chemical factory are quarantined in home. So, company is organized by automated robots. There are $N$ Containers in company, which are labelled with $1$ to $N$ numbers. There are Total $N$ robots in Company, which are labelled $1$ to $N$. Each Robot adds $1$ litter Chemical in container...
["T = int(input())\r\nfor _ in range(T):\r\n N, K1, K2 = list(map(int, input().split()))\r\n P1, P2, P3, P4 = list(map(int, input().split()))\r\n ans = 0\r\n arr = [0] * (1005)\r\n\r\n length = len(arr)\r\n for i in range(1,N+1):\r\n\r\n j = 0\r\n while j < length:\r\n arr[j] ...
{"inputs": [["1", "4 1 4", "2 2 2 2"]], "outputs": [["8"]]}
INTERVIEW
PYTHON3
CODECHEF
27,025
9c05ffbb5a5b190dfc8b284efd0f0329
UNKNOWN
On each of the following $N$ days (numbered $1$ through $N$), Chef is planning to cook either pizza or broccoli. He wrote down a string $A$ with length $N$, where for each valid $i$, if the character $A_i$ is '1', then he will cook pizza on the $i$-th day, while if $A_i$ is '0', he will cook broccoli on this day. Chefu...
["for _ in range(int(input())):\n\n n, k = map(int, input().split())\n l = [*map(int, input())]\n\n count = [0] * (n + 1)\n\n for i in range(n - 1, -1, -1):\n if l[i] == 1:\n count[i] = count[i + 1] + 1\n\n x,y = 0,0\n for i in range(n):\n if l[i] == 1:\n x += 1\n else:\n try:\n y = max(y, x + k + count[i +...
{"inputs": [["2", "13 2", "0101110000101", "6 3", "100001"]], "outputs": [["5", "4"]]}
INTERVIEW
PYTHON3
CODECHEF
12,288
1c2bbec607327075378d3b0973ab923d
UNKNOWN
Gru has a string $S$ of length $N$, consisting of only characters $a$ and $b$ for banana and $P$ points to spend. Now Gru wants to replace and/or re-arrange characters of this given string to get the lexicographically smallest string possible. For this, he can perform the following two operations any number of times. 1...
["def __starting_point():\n t=int(input())\n for _ in range(t):\n n,p=input().split()\n n,p=int(n),int(p)\n s=input()\n a,b=0,0\n arr=[0]*n\n for i in range(n):\n arr[i]=s[i]\n for c in s:\n if c=='a':\n a+=1\n else:\n b+=1\n swap=0\n for i in range(a):\n if s[i]=='b':\n swap+=1\n tmpp=p\n i...
{"inputs": [["1", "3 3", "bba"]], "outputs": [["aab"]]}
INTERVIEW
PYTHON3
CODECHEF
4,939
616eca841dc6e2a3586c20390714e793
UNKNOWN
-----Problem description----- As a holiday gift, Tojo received a probability problem. The problem read as follows Consider an N by M grid. Rows are numbered 1 to N, from top to bottom. Columns are numbered 1 to M, from left to right. You are initially at cell (1, 1) and want to go to cell (N, M). From any cell you can ...
["from math import factorial\n\nfor _ in range(int(input())):\n N,M=[int(a) for a in input().split()]\n print(float(N+M-1))", "for _ in range(int(input())):\n n ,m = map(int,input().split())\n if n==1 or m==1:\n print(max(n,m))\n else:\n print(n+m-1)", "for i in range(int(input())):\n a,b = list(map(int, input().spli...
{"inputs": [["2", "2 2", "1 6"]], "outputs": [["3.000000", "6.000000"]]}
INTERVIEW
PYTHON3
CODECHEF
3,488
e014959a0b2f90de8462fbef4b043291
UNKNOWN
-----Problem Statement----- Chef studies combinatorics. He tries to group objects by their rang (a positive integer associated with each object). He also gives the formula for calculating the number of different objects with rang N as following: the number of different objects with rang N = F(N) = A0 + A1 * N + A2 * N...
["# cook your dish here\nimport sys\n\nmod_val = 1000000007\nrang = [0]*101\npow_cache = [0]*102\nmultisets = {}\n\n\ndef mod_pow(base, pow):\n result = 1\n while pow:\n if pow&1:\n result = (result*base) % mod_val\n base = (base*base) % mod_val\n pow = pow>>1\n return result\n\n\ndef precalculate():\n\n for i in ...
{"inputs": [["4", "1 0 0 0", "1", "1 0 0 0", "3", "0 1 0 0", "2", "2 3 1 4", "10"]], "outputs": [["1", "3", "3", "213986343"]]}
INTERVIEW
PYTHON3
CODECHEF
1,433
00079559d27c24122100ba9551ec9b52
UNKNOWN
In India, every individual is charged with income tax on the total income each year. This tax is applied to specific ranges of income, which are called income tax slabs. The slabs of income tax keep changing from year to year. This fiscal year (2020-21), the tax slabs and their respective tax rates are as follows:Total...
["arr = [0]*6\n\narr[1] = 250000*(0.05)\narr[2] = 250000*(0.10)\narr[3] = 250000*(0.15)\narr[4] = 250000*(0.20)\narr[5] = 250000*(0.25)\n\nfor _ in range(int(input())):\n n = int(input())\n\n tax = 0\n\n if n<=250000:\n tax = 0\n\n elif 250000<n<=500000:\n tax = sum(arr[:1])\n\n rem = n - 250000\n\n tax+= (rem)*(0....
{"inputs": [["2", "600000", "250000"]], "outputs": [["577500", "250000"]]}
INTERVIEW
PYTHON3
CODECHEF
9,436
1ffbce7a719d9597b7f1ff1f3c643f03
UNKNOWN
In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newline). Your task is print the words in the text in reverse order wi...
["N = int(input())\nl = []\nfor i in range(N):\n l.append(input())\nfor j in range(N-1,-1,-1):\n s = '` '+ l[j]\n n = len(s)-1\n y = s[n]\n f = ''\n while y != '`':\n w = ''\n while y != ' ':\n if ord(y) in range(97,123) or ord(y) in range(65,91):\n w += y\n ...
{"inputs": [["2", "This is a sample piece of text to illustrate this ", "problem. If you are smart you will solve this right.", ""]], "outputs": [["right this solve will you smart are you If problem", "this illustrate to text of piece sample a is This"]]}
INTERVIEW
PYTHON3
CODECHEF
6,444
43aa95532dc29ecf5f65960378fc81a5
UNKNOWN
Our Chef who was a renouned mathematician has recently got into diamonds' business. She has accidentally misplaced $Q$ diamonds into a jar which already had $N$ chocolates. She then started wondering about an interesting question as following. If we pick items one by one at random without replacement, what would be t...
["# cook your dish here\nfor h in range(int(input())):\n n,q=map(int,input().split())\n print(q*(n+q+1)/(q+1))", "# cook your dish here\nfor h in range(int(input())):\n n,q=map(int,input().split())\n print(q*(n+q+1)/(q+1))", "import math\n\nt=int(input())\nwhile(t>0):\n t-=1\n #n=int(input())\n #l=list(map(int,input()....
{"inputs": [["1", "2 2"]], "outputs": [["3.3333333333"]]}
INTERVIEW
PYTHON3
CODECHEF
2,786
ec038bafdb727bad6f6f4947688dbd68
UNKNOWN
Our chef has recently opened a new restaurant with a unique style. The restaurant is divided into K compartments (numbered from 1 to K) and each compartment can be occupied by at most one customer. Each customer that visits the restaurant has a strongly preferred compartment p (1 ≤ p ≤ K), and if that compartment is a...
["try:\n for _ in range(int(input())):\n N, K = map(int, input().split())\n cell = []\n count = 0\n l = []\n for __ in range(N):\n inserted = list(map(int, input().split()))\n cell.append(inserted)\n\n\n\n \n\n\n\n\n cell.sort(key=lambda x: x[1])\n time = {}\n\n for number in cell:\n if number[2] not in ...
{"inputs": [["2", "3 3", "1 3 1", "4 6 2", "7 10 3", "4 2", "10 100 1", "100 200 2", "150 500 2", "200 300 2"]], "outputs": [["3", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
11,115
7e9d2f4042bfa10824aeb8b1687c1f69
UNKNOWN
Chef and Chefina are best friends. Chefina wants to test the Problem Solving skills of chef so she provides Chef 2 integer number $X$ and $Y$ The task of chef is to take the two numbers $X$ and $Y$ and return their SUM. Identify whether Chef can solve the problem or not? -----Input:----- - First line will contain t...
["a,b=map(int,input().split())\r\nprint(a+b)", "x,y=map(int,input().split())\nprint(x+y)", "print(sum(map(int,input().split())))", "# cook your dish here\nX ,Y = map(int, input().split())\noutput = X + Y\nprint(output)", "# cook your dish here\na,b = [int(i) for i in input().split()]\nprint(a+b)", "# cook your dish her...
{"inputs": [["6 70"]], "outputs": [["76"]]}
INTERVIEW
PYTHON3
CODECHEF
1,613
a92c03f9a5cdbadd65a431e4d54f60d6
UNKNOWN
Most problems on CodeChef highlight chef's love for food and cooking but little is known about his love for racing sports. He is an avid Formula 1 fan. He went to watch this year's Indian Grand Prix at New Delhi. He noticed that one segment of the circuit was a long straight road. It was impossible for a car to overtak...
["for _ in range(int(input())):\n n = int(input())\n l = list(map(int,input().split()))\n ans = 1\n l1 = l[0]\n for i in range(1,n):\n if l[i] <= l1:\n l1 = l[i]\n ans = ans + 1\n print(ans)", "for _ in range(int(input())):\n n = int(input())\n l = list(map(int,input().split()))\n ans = 1\n l1 = l[0]\n for i in ra...
{"inputs": [["3", "1", "10", "3", "8 3 6", "5", "4 5 1 2 3"]], "outputs": [["1", "2", "2", "Constraints", "1 \u2264 T \u2264 100", "1 \u2264 N \u2264 10,000", "All speeds are distinct positive integers that fit in a 32 bit signed integer.", "Each input file will not be larger than 4 MB (4,000,000,000 bytes) in size.", ...
INTERVIEW
PYTHON3
CODECHEF
6,339
cb018559e30d3dd5a3ff7b082393a26e
UNKNOWN
Chef's pizza is the tastiest pizza to exist, and the reason for that is his special, juicy homegrown tomatoes. Tomatoes can be grown in rectangular patches of any side lengths. However, Chef only has a limited amount of land. Consider the entire town of Chefville to be consisting of cells in a rectangular grid of pos...
["from math import *\ndef list_input():\n return list(map(int,input().split()))\ndef map_input():\n return list(map(int,input().split()))\ndef map_string():\n return input().split()\ndef g(n):\n return (n*(n+1)*(2*n+1))//6\ndef f(n):\n ans = 0\n for i in range(1,floor(sqrt(n))+1):\n ans+=i*(i+floo...
{"inputs": [["2", "4", "10000000000"]], "outputs": [["23", "227374950"]]}
INTERVIEW
PYTHON3
CODECHEF
1,951
8bc2f2a8c18a4cb056910a71a32ca14b
UNKNOWN
Ram and Shyam are sitting next to each other, hoping to cheat on an exam. However, the examination board has prepared $p$ different sets of questions (numbered $0$ through $p-1$), which will be distributed to the students in the following way: - The students are assigned roll numbers — pairwise distinct positive intege...
["# cook your dish here\nfor test in range(0,int(input())):\n A,B = map(int,input().split())\n diff = abs(A-B)\n count=0\n if not(A^B):\n print(-1)\n else:\n for i in range(1,int(diff**(1/2))+1):\n if diff%i==0:\n if diff/i==i:\n count+=1 \n else:\n count+=2\n print(count)", "# cook your dish here\n#...
{"inputs": [["1", "2 6"]], "outputs": [["3"]]}
INTERVIEW
PYTHON3
CODECHEF
1,453
740c6302ce891d49f03a61ce4cf5b289
UNKNOWN
Mysterious Chefland… Recently, Chef realised that Discuss, the educational system of Chefland, is out of date. Therefore, he is trying to find ways to update the infrastructure in the country. One possible way is to move all materials from Discuss to Discourse. Chef will have access to Discourse if his knowledge and po...
["t = input()\nt = int(t)\n\nfor _ in range(t):\n n, m, x, y = input().split()\n n = int(n)\n m = int(m)\n x = int(x)\n y = int(y)\n n -= 1\n m -= 1\n flag = 0\n if n % x == 0 and m % y == 0:\n flag = 1\n n -= 1\n m -= 1\n if n >= 0 and m >= 0:\n if n % x == 0 and m % y == 0:\n flag = 1\n \n if flag == 1:\n print(...
{"inputs": [["5", "2 2 1 2", "11 10 5 9", "11 11 5 9", "12 11 5 9", "1 2 1 100"]], "outputs": [["Chefirnemo", "Chefirnemo", "Pofik", "Chefirnemo", "Pofik"]]}
INTERVIEW
PYTHON3
CODECHEF
6,573
d3b673a59214a2ed3494063400c42fe2
UNKNOWN
Chef has a sequence $A_1, A_2, \ldots, A_N$. For a positive integer $M$, sequence $B$ is defined as $B = A*M$ that is, appending $A$ exactly $M$ times. For example, If $A = [1, 2]$ and $M = 3$, then $B = A*M = [1, 2, 1, 2, 1, 2]$ You have to help him to find out the minimum value of $M$ such that the length of the long...
["def mForMaxSeq(arr, n):\r\n eim = dict()\r\n for i in range(n):\r\n if arr[i] in eim:\r\n eim[arr[i]].append(i)\r\n else:\r\n eim[arr[i]] = [i]\r\n \r\n keys = sorted(eim.keys())\r\n \r\n # print(eim, keys)\r\n\r\n connected = False\r\n count = 0\r\n pI =...
{"inputs": [["3", "2", "2 1", "2", "1 2", "5", "1 3 2 1 2"]], "outputs": [["2", "1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
17,423
e264f7734c21e11db60f72e6beb4cf0a
UNKNOWN
You have initially a string of N characters, denoted by A1,A2...AN. You have to print the size of the largest subsequence of string A such that all the characters in that subsequence are distinct ie. no two characters in that subsequence should be same. A subsequence of string A is a sequence that can be derived from ...
["def solve(S):\n a = set(S)\n return len(a)\n \n \nt = int(input())\n\nfor _ in range(t):\n s = input()\n print(solve(s))", "# cook your dish her\nfor _ in range(int(input())):\n s = input()\n print(len(set(s)))", "# cook your dish here\nfor test in range(int(input())):\n longest_distint_set = set(input())\n print(len...
{"inputs": [["2", "abc", "aba"]], "outputs": [["3", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
3,611
d0bdb60271af4904db315638e6ff1455
UNKNOWN
Recently, Chef found a new formula for computing powers of a sequence: - You are given two sequences $A_1, A_2, \ldots, A_N$ and $(l_1, r_1), (l_2, r_2), \ldots, (l_N, r_N)$. - The $1$-st power of the sequence $A$ is $A^1 = A$. - For each $k > 1$, the $k$-th power of the sequence $A$ (denoted by $A^k$) is a sequence wi...
["import numpy as np\r\n\r\ndef solve(n,k,a,l,r):\r\n shape = (n,n)\r\n mat = np.zeros(shape, dtype=np.int64)\r\n for i in range(n):\r\n for j in range(l[i], r[i]):\r\n mat[i][j]=1\r\n \r\n ans = np.eye(n,n, dtype=np.int64)\r\n while(k>0):\r\n if k%2 == 1:\r\n ans =...
{"inputs": [["1", "3 2", "1 2 3", "1 2", "2 3", "1 3"]], "outputs": [["3 1 0"]]}
INTERVIEW
PYTHON3
CODECHEF
2,396
faaa7f192a438c10aaa12464fbecd3ba
UNKNOWN
Chandler has a list of non zero positive integers with him. He made a very interesting observation about the list. He noticed that the number of unique integers in an array of size $N$ is in the range $L$ to $R$ (both inclusive) and every element was either 1 or an even number x, in which case x/2 was also definitely p...
["# cook your dish here\nfor _ in range(int(input())):\n n,l,h=list(map(int,input().split()))\n print(n-l+1+2**(l)-2,1+2**(h)-2+2**(h-1)*(n-h))\n", "# cook your dish here\nfor i in range(int(input())):\n n, l, r = list(map(int, input().split()))\n mins = 0\n maxs = 0\n start = 1\n end = 2 ** (min(r,n) - 1)\n cend = end...
{"inputs": [["2", "4 2 2", "5 1 5"]], "outputs": [["5 7", "5 31"]]}
INTERVIEW
PYTHON3
CODECHEF
7,157
9195b31900d105ec34efaf8f05aaf4f7
UNKNOWN
Give me Chocolate Anushka wants to buy chocolates.there are many chocolates in front of her, tagged with their prices. Anushka has only a certain amount to spend, and she wants to maximize the number of chocolates she buys with this money. Given a list of prices and an amount to spend, what is the maximum number of ...
["n,k = map(int,input().split())\nprices = list(map(int,input().split()))\nprices.sort()\nsum,cnt = 0, 0\nfor price in prices:\n sum += price\n if sum <= k: cnt += 1\n else: break\nprint(cnt)", "\nd=input().split()\nmoney=int(d[1])\nprice_of_chocolates=sorted(list(map(int,input().split())))\nprice=None\nn=0\nfor f in p...
{"inputs": [["7 50", "1 12 5 111 200 1000 10"]], "outputs": [["4"]]}
INTERVIEW
PYTHON3
CODECHEF
4,568
9202505dd7369726553ba093c16e5f47
UNKNOWN
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division). After playing with binary operations...
["def add(A, B):\n cnt = 0\n while B > 0:\n U = A ^ B\n B = (A & B) * 2\n A = U\n cnt += 1\n return cnt\n\nfor _ in range(int(input())):\n print(add(int(input(),2), int(input(), 2)))", "def add(A, B):\n cnt = 0\n while B > 0:\n cnt += 1\n U = A ^ B\n V = A & B\n A = U\n B = V * 2\n return cnt\n\nfor _ in range...
{"inputs": [["3", "100010", "0", "0", "100010", "11100", "1010"]], "outputs": [["0", "1", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
4,791
cadc96ec7502c151da8938e90ae993fb
UNKNOWN
Dhruvil has always been a studious person and will be completing his Engineering soon. He is always kneen about solving problems and is preparing hard for his next interview at Hackerrank. He has practiced lots of problems and now he came across this problem. Given a message containing English letters(A-Z), it is being...
["# cook your dish here\n# cook your dish here\ndef numDec(s):\n if not s:\n return 0\n\n dp = [0 for _ in range(len(s) + 1)]\n\n dp[0] = 1\n dp[1] = 0 if s[0] == '0' else 1\n\n\n for i in range(2, len(dp)):\n\n if s[i-1] != '0':\n dp[i] += dp[i-1]\n\n two_digit = int(s[i-2 : i])\n if two_digit >= 10 an...
{"inputs": [["2", "12", "226"]], "outputs": [["2", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
5,702
01835ca496aa162d9737f3b96e39b99c
UNKNOWN
Today a plane was hijacked by a maniac. All the passengers of the flight are taken as hostage. Chef is also one of them. He invited one of the passengers to play a game with him. If he loses the game, he will release all the passengers, otherwise he will kill all of them. A high risk affair it is. Chef volunteered for...
["import sys\ntest_cases = int(input())\nfor i in range(0,test_cases):\n count = input().split()\n #print count\n count_r = int(count[0])\n count_g = int(count[1])\n count_b = int(count[2])\n k = int(input())\n if k is 1:\n total = 1\n else: \n total = 1\n if count_r < k:\n total = total + count_r\n else:\n t...
{"inputs": [["2", "3 3 3", "1", "3 3 3", "2"]], "outputs": [["1", "4"]]}
INTERVIEW
PYTHON3
CODECHEF
7,538
e93e3960a6458bd5d9dadc745000db82
UNKNOWN
There are $N$ sabotages available in the game Among Us, initially all at level $0$. $N$ imposters are allotted the task to upgrade the level of the sabotages. The $i^{th}$ imposter $(1 \leq i \leq N)$ increases the level of $x^{th}$ sabotage $(1 \leq x \leq N)$ by one level if $gcd(i,x)=i$. You need to find the numb...
["from bisect import bisect\nn = 32000\ndef primeSeive(n):\n prime = [True for i in range(n + 1)]\n primes = []\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = False\n prime[1] = ...
{"inputs": [["1", "6"]], "outputs": [["0"]]}
INTERVIEW
PYTHON3
CODECHEF
3,306
05c283adc41e5ef14a021755e92983ef
UNKNOWN
A sophomore Computer Science student is frustrated with boring college lectures. Professor X agreed to give him some questions; if the student answers all questions correctly, then minimum attendance criteria will not apply to him. Professor X chooses a sequence $A_1, A_2, \ldots, A_N$ and asks $Q$ queries. In each que...
["# cook your dish here\nfrom sys import stdin, stdout\n\nfor _ in range(int(stdin.readline())):\n n, q = list(map(int, stdin.readline().split()))\n arr = list(map(int, stdin.readline().split()))[:n]\n od = ev = 0\n for i in arr:\n if bin(i).count('1')%2==0:\n ev += 1\n else:\n od += 1\n for _ in range(q):\n p =...
{"inputs": [["1", "6 1", "4 2 15 9 8 8", "3"]], "outputs": [["2 4"]]}
INTERVIEW
PYTHON3
CODECHEF
10,095
511ae3cb07220ee7e81c6137d333bce0
UNKNOWN
You are given an empty grid with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). You should fill this grid with integers in a way that satisfies the following rules: - For any three cells $c_1$, $c_2$ and $c_3$ such that $c_1$ shares a side with $c_2$ and another side with $c_3$, the int...
["# cook your dish here\nt = int(input())\nfor _ in range(t):\n m,n = [int(d) for d in input().split()]\n\n if m == 1:\n arr = []\n if n%4 == 0:\n print(2)\n arr = [[1,1,2,2]*(n//4)]\n elif n%4 == 1:\n if n == 1:\n print(1)\n arr = [[1]]\n else:\n print(2)\n arr = [[1,1,2,2]*(n//4) + [1]]\n elif...
{"inputs": [["2", "1 1", "2 3"]], "outputs": [["1", "1", "3", "1 1 2", "2 3 3"]]}
INTERVIEW
PYTHON3
CODECHEF
19,075
78c7890cbe33bcd18fdc04c8343d27dd
UNKNOWN
Chef's loves his dog so much! Once his dog created two strings a and b each of length n consisting of digits 1 and 2, and even a problem about them! Chef's Dog will tell by barking if a string x (also containing only digits 1 and 2 and with length N) is good or not by performing the following actions. - It starts at f...
["mod = 10 ** 9 + 7\nfrom collections import Counter\nchoice = {'1' : ['11', '21', '22'], '2' : ['11', '12', '21']}\ndef solve(a,b):\n n = len(a)\n if n == 1:\n return 2\n dp = Counter([('11', '11')])\n for i in range(n-1):\n new = Counter()\n for x,y in (a[i], b[i]), (b[i], a[i]):\n for p in choice[x]:\n for q...
{"inputs": [["2", "1111", "2211", "222", "111"]], "outputs": [["8", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
1,382
9f68051254b9055caf7035cc4c955d27
UNKNOWN
Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challanges the chef to print the total number of 1's in the binary representation of N(natural number). -----Input:----- - First-line will contain $T$, the number of test case...
["for t in range(int(input())):\r\n n=int(input())\r\n print(bin(n).count(\"1\")) ", "for i in range(int(input())):\n print(bin(int(input())).count(\"1\")) ", "\nfor i in range(int(input())):\n print(bin(int(input())).count(\"1\")) \n", "t=int(input())\r\nfor items in range(t):\r\n num=int(input())\r\n ...
{"inputs": [["2", "2", "5"]], "outputs": [["1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
5,288
7a471b96d1738e02792e68567c516626
UNKNOWN
Alice's school is planning to take some students from her class on a field trip. Alice is really excited about it. There are a total of S students in her class. But due to budget constraints, the school is planning to take only N students for the trip. These students will be picked randomly. And each student has equal ...
["nCr = [[0 for x in range(1001)] for x in range(1001)]\n \nfor i in range (0,1001):\n nCr[i][0]=1\n nCr[i][i]=1\nfor i in range (1,1001):\n for j in range (1,1001):\n if i!=j:\n nCr[i][j] = nCr[i-1][j] + nCr[i-1][j-1]\n \nt=eval(input())\nfor rajarshisarkar in range(0,t):\n s,n,m,k=list(map(int,input().split(' ')))...
{"inputs": [["3", "10 10 5 3", "10 4 6 4", "3 2 2 1"]], "outputs": [["1.000000", "0.000000", "0.500000"]]}
INTERVIEW
PYTHON3
CODECHEF
8,598
749588c5e2f1fa0ff31aaa444917cc35
UNKNOWN
Motu and Patlu are racing against each other on a circular track of radius $R$. Initially they are at the same point on the track and will run in same direction .The coach ordered them to run $X$ rounds of the circular field. Patlu wants to know how many times they will meet after the race starts and before any of the...
["# cook your dish here\nimport math\ndef swap(a,b):\n return b,a\n\nt = int(input())\nwhile(t!=0):\n z = list(map(int,input().strip().split(\" \")))\n x=z[0]\n r=z[1]\n a=z[2]\n b=z[3]\n #p = math.pi\n peri = 2*r\n tp = x*peri\n \n if(a<b):\n a,b=swap(a,b)\n t1 = tp/a\n d2 = t1* b\n dd = abs(tp-d2)\n \n if(dd%peri==0...
{"inputs": [["2", "3 10 2 5", "2 20 5 10"]], "outputs": [["1", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
7,193
4fce4877750be91130f9515c300bf2c8
UNKNOWN
Chef changed the password of his laptop a few days ago, but he can't remember it today. Luckily, he wrote the encrypted password on a piece of paper, along with the rules for decryption. The encrypted password is a string S consists of ASCII printable characters except space (ASCII 33 - 126, in decimal notation, the sa...
["from decimal import Decimal\r\n\r\nT = int(input())\r\nfor _ in range(T):\r\n N = int(input())\r\n data = dict() \r\n for __ in range(N):\r\n ci, pi = input().split() \r\n data[ci] = pi\r\n S = list(input())\r\n for i in range(len(S)):\r\n if S[i] in data.keys():\r\n S[...
{"inputs": [["4", "2", "5 3", "3 1", "5", "0", "01800.00", "0", "0.00100", "3", "x 0", "d 3", "# .", "0xd21#dd098x", "", ""]], "outputs": [["3", "1800", ".001", "321.33098"]]}
INTERVIEW
PYTHON3
CODECHEF
1,912
36fb528a258a8ccd2488e16292e44dc0
UNKNOWN
You are given a 1×1×2$1 \times 1 \times 2$ bar (a cuboid) and a grid A$A$ with N$N$ rows (numbered 1$1$ through N$N$) and M$M$ columns (numbered 1$1$ through M$M$). Let's denote the cell in row r$r$ and column c$c$ by (r,c)$(r, c)$. Some cells of the grid are blocked, the remaining cells are free. Each cell has dimensi...
["\r\ndef issafe(r,c,r1,c1,graph):\r\n if (graph[r][c] and graph[r1][c1]):\r\n return True\r\n return False\r\n \r\n\r\nt=int(input())\r\nfor mmmmmm in range(t):\r\n n,m=map(int,input().split())\r\n x,y=map(int,input().split())\r\n \r\n graph=[[False]*(m+2) for _ in range(n+2)]\r\n\r\n co...
{"inputs": [["2", "2 4", "1 1", "1111", "0111", "2 4", "1 1", "1111", "0011", ""]], "outputs": [["0 -1 -1 2", "-1 -1 -1 3", "0 -1 -1 2", "-1 -1 -1 -1"]]}
INTERVIEW
PYTHON3
CODECHEF
28,239
eeaa01b7b5fbfd113d3be67eec6e0be1
UNKNOWN
The auditorium of Stanford University is made up of L*R matrix (assume each coordinate has a chair). On the occasion of an event Chef was called as a chief guest. The auditorium was filled with males (M) and females (F), occupying one chair each. Our Chef is very curious guy, so he asks the gatekeeper some queries. The...
["def matrix(L,row,col,c):\n d={}\n dp=[]\n for i in range(row+1):\n temp=[]\n for i in range(col+1):\n temp.append([])\n dp.append(temp)\n\n for i in range(row+1):\n dp[i][0]=0\n for i in range(col+1):\n dp[0][i]=0\n for i in range(1,row+1):\n for j in range(1,col+1):\n if L[i-1][j-1]==c:\n dp[i][j]=min(d...
{"inputs": [["4 3 3", "MMF", "MMM", "FFM", "FFM", "2 F", "3 M", "1 M"]], "outputs": [["yes", "no", "yes"]]}
INTERVIEW
PYTHON3
CODECHEF
3,550
6566410f4cda87a63a5ce82fc18666c0
UNKNOWN
Given a string s. Can you make it a palindrome by deleting exactly one character? Note that size of the string after deletion would be one less than it was before. -----Input----- First line of the input contains a single integer T denoting number of test cases. For each test case, you are given a single line contain...
["for _ in range(int(input())):\n s=str(input())\n n=len(s)\n k=s[::-1]\n a,b=\"\",\"\"\n for i in range(n):\n if s[i]!=k[i]:\n a+=s[i+1:]\n b+=k[i+1:]\n break\n else:\n a+=s[i]\n b+=k[i]\n #print(a,b)\n if a==a[::-1] or b==b[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")\n", "for _ in range(int(input())...
{"inputs": [["4", "aaa", "abc", "abdbca", "abba"]], "outputs": [["YES", "NO", "YES", "YES"]]}
INTERVIEW
PYTHON3
CODECHEF
9,374
95f277150df4b3c20337bf867b969a01
UNKNOWN
Han Solo and Chewbacca start a space journey to planet Naboo on the Millennium Falcon. During the journey they land at a mysterious planet with high gravity where they find n diamond stones scattered all around. All the stones are of same weight. Each stone has a value according to its purity which can be detected by a...
["s,n,s1,lis,new1=[],[],[],[],[]\nimport itertools\nq = int(input())\ns.append(input().split(' '))\ns1 = list([list(map(int,x)) for x in s])\nsum1 = sum(s1[0])\nif len(s1[0])%2!=0 :\n z = (len(s1[0])+1)//2\n n = list(itertools.combinations(s1[0],z))\n for j in range(len(n)) :\n x = sum(n[j])\n if x==sum1//2 :\n ...
{"inputs": [["7", "1 2 3 4 5 6 7"]], "outputs": [["1 2 4 7", "3 5 6"]]}
INTERVIEW
PYTHON3
CODECHEF
4,210