problem_id int64 0 5k | question stringlengths 50 14k | solutions stringlengths 12 1.21M | input_output stringlengths 0 23.6M | difficulty stringclasses 3
values | url stringlengths 36 108 | starter_code stringlengths 0 1.4k |
|---|---|---|---|---|---|---|
1,100 | This question is similar to the $"Operation$ $on$ $a$ $Tuple"$ problem in this month's Long Challenge but with a slight variation.
Consider the following operations on a triple of integers. In one operation, you should:
- Choose a positive integer $d>0$ and an arithmetic operation - in this case, it will only be addi... | ["# cook your dish here\n\"\"\"\nInput:\nThe first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.\nThe first line of each test case contains three space-separated integers p, q and r.\nThe second line contains three space-separated integers a, b... | {"inputs": [["1", "2 2 1", "3 3 2"]], "outputs": [["3"]]} | interview | https://www.codechef.com/ENJU2020/problems/ECJN201 | |
1,101 | After failing to clear his school mathematics examination, infinitepro decided to prepare very hard for his upcoming re-exam, starting with the topic he is weakest at ― computational geometry.
Being an artist, infinitepro has C$C$ pencils (numbered 1$1$ through C$C$); each of them draws with one of C$C$ distinct colour... | ["from collections import Counter\r\nfrom math import factorial\r\ndef nc3(n):\r\n a=factorial(n)\r\n b=factorial(n-3)\r\n return ((a)/(b*6))\r\ndef rem(s,k):\r\n t=-1\r\n x=-1\r\n for i in range(len(s)):\r\n if s[i][0]>2 and s[i][1]<=k:\r\n if s[i][0]>3:\r\n ch=(nc3(s... | {"inputs": [["2", "7 2 13", "1 10 1", "1 14 2", "6 4 1", "2 2 1", "0 12 2", "2 11 2", "0 6 1", "8 10", "6 1 20", "1 5 1", "2 11 1", "4 0 1", "6 8 1", "0 11 1", "3 3 1", "9"]], "outputs": [["2", "4"]]} | interview | https://www.codechef.com/problems/ACCBIP | |
1,102 | On Miu's smart phone, there is a search feature which lets her search for a contact name by typing digits on the keypad where each digit may correspond to any of the characters given below it. For example, to search for TOM, she can type 866 and for MAX she can type 629.
+------+-----+------+
| 1 | 2 | 3 |
| ... | ["for _ in range(int(input())):\n n=int(input())\n n1=0\n ans=1\n while(n>0):\n d=int(n % 10)\n if(d!=0):\n if(d!=9 and d!=7 and d!=1):\n n1=3\n elif(d==1):\n n1=1\n else:\n n1=4\n ans=(int(ans)*int(n1))% (1000000007)\n n/=10\n else:\n n/=10\n if(ans==1):\n print(\"0\")\n else:\n print(ans %(1... | {"inputs": [["2", "5", "72"]], "outputs": [["3", "12"]]} | interview | https://www.codechef.com/TCFL2020/problems/TCFL20C | |
1,103 | Leha is a bright mathematician. Today he is investigating whether an integer is divisible by some square number or not.
He has a positive integer X represented as a product of N integers a1, a2, .... aN. He has somehow figured out that there exists some integer P such that the number X is divisible by P2, but he is not... | ["import sys\nimport math\nr=int(input())\nfor v in range (0,r):\n n = int(input())\n x=1\n arr=list(map(int,input().strip().split(\" \")))\n for i in range (0,n):\n x=x*arr[i]\n \n for i in range (2,100000000):\n if(x%(pow(i,2))==0):\n ans1=i\n break\n \n \n print(ans1) \n", "import math\ndef forloop(list,list1... | {"inputs": [["1", "3", "21 11 6"]], "outputs": [["3"]]} | interview | https://www.codechef.com/LTIME37/problems/SQNUMBF | |
1,104 | Kabir Singh is playing a game on the non-negative side of x-axis. It takes him $1 second$ to reach from Pth position to (P−1)th position or (P+1)th position.
Kabir never goes to the negative side and also doesn't stop at any moment of time.
The movement can be defined as :
- At the beginning he is at $x=0$ , at tim... | ["# cook your dish here\nT=int(input())\nMOD=int(1e9+7)\nfor t in range(T):\n N,K=[int(a) for a in input().split()]\n M=K//2\n # ans= ((K%2)?( (N+M)*(N+M) + M ):( (N+M)*(N+M) - M) )\n ans=(N+M)*(N+M) -M\n if(K%2):\n ans+=2*M\n if(N==0):\n ans=K*(K-1)\n print(ans%MOD) ", "# cook your d... | {"inputs": [["4", "0 1", "1 1", "1 3", "4 6"]], "outputs": [["0", "1", "5", "46"]]} | interview | https://www.codechef.com/LDT42020/problems/WALKREC | |
1,105 | Chef Ada is preparing $N$ dishes (numbered $1$ through $N$). For each valid $i$, it takes $C_i$ minutes to prepare the $i$-th dish. The dishes can be prepared in any order.
Ada has a kitchen with two identical burners. For each valid $i$, to prepare the $i$-th dish, she puts it on one of the burners and after $C_i$ min... | ["for i in range(int(input())):\n n=int(input())\n c=[int(z) for z in input().split()]\n c.sort()\n c.reverse()\n b1,b2=0,0\n for i in range(n):\n if b1<b2:\n b1+=c[i]\n elif b2<b1:\n b2+=c[i]\n else:\n b1+=c[i]\n print(max(b1,b2))\n \n", "n=int(input())\nfor i in range(n):\n N=int(input())\n lst=list(map(in... | {"inputs": [["3", "3", "2 2 2", "3", "1 2 3", "4", "2 3 4 5"]], "outputs": [["4", "3", "7"]]} | interview | https://www.codechef.com/problems/ADADISH | |
1,106 | A long way back I have taken $5000 from Golu when I used to live in Jodhpur. Now, time has passed and I am out of Jodhpur. While Golu still in Jodhpur, one day called me and asked about his money.
I thought of giving Golu a chance. I told him that he can still take his money back if he reaches my home anyhow just in 2 ... | ["'''Well I found the bug, but I don't understand why it was doing that. I mean, as\nfar as I can tell, it shouldn't be a bug!\nNote to self: deleting from (supposedly) local lists through recursion is dangerous!'''\n\nclass Group(object):\n def __init__(self,size,start,end,value):\n self.size = size\n ... | {"inputs": [["2", "5 5 4", "2 1 5 50", "1 2 4 20", "2 3 4 40", "2 4 5 50", "3 4 5 80", "10 10 5", "2 5 10 17300", "2 1 8 31300", "5 4 10 27600", "4 8 10 7000", "5 9 10 95900", "2 7 10 14000", "3 6 10 63800", "1 7 10 19300", "3 8 10 21400", "2 2 10 7000"]], "outputs": [["140", "127200", "By:", "Chintan, Asad, Ashayam, A... | interview | https://www.codechef.com/IGNS2012/problems/IG02 | |
1,107 | Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422.
Help him to count the sum of goodness of all integers from L to R, inclusive. Since the answer can be too lar... | ["# cook your dish here\nfrom sys import stdin\nfrom math import sqrt,ceil,log10\ndef get_sum(a,b,digits):\n sum=((b+a)*(b-a+1))//2\n return sum*digits\n\ndef solve():\n mod=10**9+7\n thehighlimiter={i: 10 ** i - 1 for i in range(12)}\n thelowlimiter={i: 10**i for i in range(12)}\n for _ in range(int(... | {"inputs": [["1", "9 12", "", ""]], "outputs": [["75"]]} | interview | https://www.codechef.com/problems/PPNUM | |
1,108 | There were $N$ students (numbered $1$ through $N$) participating in the Indian Programming Camp (IPC) and they watched a total of $K$ lectures (numbered $1$ through $K$). For each student $i$ and each lecture $j$, the $i$-th student watched the $j$-th lecture for $T_{i, j}$ minutes.
Additionally, for each student $i$, ... | ["N,M,K=map(int,input().split())\nc=0\nfor i in range(N):\n T=list(map(int,input().split()))\n Q=T[-1]\n T.pop(-1)\n if Q<=10 and sum(T)>=M:\n c+=1\nprint(c)", "n,m,k=map(int,input().split())\na=0\nfor i in range(n):\n t=list(map(int,input().split()))\n q=t[-1]\n t.pop(-1)\n if q<=10 and sum(t)>=m:\n a+=1\nprint(a)",... | {"inputs": [["4 8 4", "1 2 1 2 5", "3 5 1 3 4", "1 2 4 5 11", "1 1 1 3 12"]], "outputs": [["1"]]} | interview | https://www.codechef.com/problems/IPCCERT | |
1,109 | Sumit and Dhiraj are roommates in a hostel of NIT Jamshedpur,One day after completing there boring assignments of Artificial Intelligence, they decided to play a game as it was dhiraj,s idea to play a game so he started explaining the rules of the game to sumit.
So the game was as follows-They randomly took a number N ... | ["import math\nfor t in range(int(input())):\n n = int(input())\n temp = math.sqrt(n)\n if (temp == int(temp)):\n print(\"YES\")\n else:\n print(\"NO\")", "t=int(input());\nfor i in range (0,t):\n c=0;\n n=int(input());\n for j in range (1,n+1):\n if(n%j==0):\n c=c+1;\n if(c%2==0):\n print(\"NO\\n\");\n else:\n ... | {"inputs": [["2", "4", "5"]], "outputs": [["YES", "NO"]]} | interview | https://www.codechef.com/COYA2016/problems/CDYPA01 | |
1,110 | You are given an array of integers [A1,A2,…,AN]$[A_1, A_2, \ldots, A_N]$. Let's call adding an element to this array at any position (including the beginning and the end) or removing an arbitrary element from it a modification. It is not allowed to remove an element from the array if it is empty.
Find the minimum numbe... | ["# cook your dish here\nfor _ in range(int(input())):\n n=int(input());li=list(map(int,input().split()));dli=dict();modi=0\n for i in li:\n if i not in dli:dli[i]=1\n else:dli[i]+=1\n op=sorted(list(dli))\n if(len(dli)!=0):\n while 1:\n tmp=[]\n for i in op:\n if dli[i]==0:conti... | {"inputs": [["2", "5", "1 4 1 2 2", "4", "2 3 2 3"]], "outputs": [["1", "2"]]} | interview | https://www.codechef.com/problems/PERMPART | |
1,111 | Using his tip-top physique, Kim has now climbed up the mountain where the base is located. Kim has found the door to the (supposedly) super secret base. Well, it is super secret, but obviously no match for Kim's talents.
The door is guarded by a row of $N$ buttons. Every button has a single number $A_i$ written on it.... | ["# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n even=[]\n odd=[]\n for i in a:\n if(i & 1):\n even.append(i)\n else:\n odd.append(i)\n print(len(even)*len(odd))", "t=int(input()) \nfor kkk in range(t): \n n=int(input()) \n a=[int(x) for x in input ().sp... | {"inputs": [["3", "4", "3 5 3 4", "2", "5 7", "1", "4"]], "outputs": [["3", "0", "0"]]} | interview | https://www.codechef.com/problems/UWCOI20B | |
1,112 | 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... | ["# cook your dish here\nfor _ in range(int(input())):\n n = int(input())\n m = n\n x= 1\n for i in range(n):\n for j in range(m):\n print(x, end = '')\n x += 1\n print()\n m -= 1", "# cook your dish here\n\nt=int(input())\nfor i in range(t):\n n=int(input())\n ... | {"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["1", "12", "3", "123", "45", "6", "1234", "567", "89", "10"]]} | interview | https://www.codechef.com/PSTR2020/problems/ITGUY58 | |
1,113 | Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first.
-----Input-----
First line of input contains an integer T, denoting the number of test cases. Then follows description of T ca... | ["t = input();\n\na = [0 for i in range(10001)]\n\ni = 0;\n\nwhile i < int(t):\n\n\tn = input();\n\n\tk = input();\n\n\tassert(len(k.split(' ')) == int(n));\n\n\tfor each in k.split(' '):\n\n\t\ta[int(each)] += 1;\n\n\n\tV = 0;\n\n\tC = a[V];\n\n\tfor j in range(10001):\n\n\t\tif C < a[j]:\n\n\t\t\tV = j;\n\n\t\t\tC = ... | {"inputs": [["2", "5", "1 2 3 2 5", "6", "1 2 2 1 1 2", "", ""]], "outputs": [["2 2", "1 3"]]} | interview | https://www.codechef.com/FEB12/problems/MAXCOUNT | |
1,114 | Chefu is Chef's little brother, he is 12 years old and he is new to competitive programming.
Chefu is practicing very hard to become a very skilled competitive programmer and win gold medal in IOI.
Now Chefu is participating in a contest and the problem that he is trying to solve states:
Given an array A of N integers,... | ["T=int(input())\nfor i in range(T):\n N=int(input())\n A=list(map(int,input().split()))[:N]\n l=[]\n for j in range(len(A)):\n for k in range(j+1,len(A)):\n l.append(A[j]+A[k])\n print(l.count(max(l))/((N*(N-1))/2))", "for i in range(int(input())):\n n=int(input())\n t=list(map(int,input().split()))[:n]\n m=[]\n fo... | {"inputs": [["3", "4", "3 3 3 3", "6", "1 1 1 2 2 2", "4", "1 2 2 3"]], "outputs": [["1.00000000", "0.20000000", "0.33333333"]]} | interview | https://www.codechef.com/problems/RNDPAIR | |
1,115 | You are given a tree with $N$ vertices (numbered $1$ through $N$) and a sequence of integers $A_1, A_2, \ldots, A_N$. You may choose an arbitrary permutation $p_1, p_2, \ldots, p_N$ of the integers $1$ through $N$. Then, for each vertex $i$, you should assign the value $A_{p_i}$ to this vertex.
The profit of a path bet... | ["T = int(input())\n\nM = 10 ** 9 + 7\n\nfor _ in range(T):\n N = int(input())\n\n A = list(map(int, input().split()))\n\n if N == 1:\n print(0)\n continue\n\n B = {}\n C = {}\n\n for i in range(N - 1):\n u, v = input().split()\n u = int(u) - 1\n v = int(v) - 1\n\n if u not in B:\n B[u] = []\n\n if v not in B:... | {"inputs": [["2", "4", "1 2 3 4", "1 2", "2 3", "2 4", "5", "1 2 3 4 5", "1 2", "2 3", "3 4", "4 5"]], "outputs": [["24", "15"]]} | interview | https://www.codechef.com/problems/PRT | |
1,116 | -----Problem Statement-----
We have an integer sequence $A$, whose length is $N$.
Find the number of the non-empty contiguous subsequences of $A$ whose sum is $0$. Note that we are counting the ways to take out subsequences. That is, even if the contents of some two subsequences are the same, they are counted individua... | ["from collections import defaultdict \ndef findSubarraySum(arr, n, Sum): \n \n # Dictionary to store number of subarrays \n # starting from index zero having \n # particular value of sum. \n prevSum = defaultdict(lambda : 0) \n \n res = 0 \n \n # Sum of elements so far. \n currsum = 0 \n \n for i in range(0, n):... | {"inputs": [["6", "1 3 -4 2 2 -2"]], "outputs": [["3"]]} | interview | https://www.codechef.com/SCAT2020/problems/SC_01 | |
1,117 | It is the end of 2019 — the 17th of November, the Cooking Challenge day.
There are N$N$ players participating in this competition, numbered 1$1$ through N$N$. Initially, the skill level of each player is zero. There are also M$M$ challenges (numbered 1$1$ through M$M$). For each valid i$i$, the i$i$-th challenge has th... | ["import numpy as np\n\ndef sort_it(array):\n new_list = []\n for i in range(len(array)):\n start = 0\n value = array[i][0]\n last = len(new_list)\n while start != last:\n mid = (start + last) // 2\n if new_list[mid][0] > value:\n last = mid\n ... | {"inputs": [["1", "5 3 4", "1 1 3", "1 2 -4", "4 5 2", "1 2", "1 3", "1 1", "2 3"]], "outputs": [["3 0 0 4 4"]]} | interview | https://www.codechef.com/problems/CHADAY | |
1,118 | Chef is playing a game which contains a binary string.
He can perform one operation only:
- Toggle the i_th bit of the string (0 to 1 or 1 to 0)
By performing operations on the string (can be zero times), you have to convert the string with no adjacent bit being the same.
Can you help chef ?
-----Input:-----
- First ... | ["'''\nName : Jaymeet Mehta\ncodechef id :mj_13\nProblem : Avenir Strings\n'''\nfrom sys import stdin,stdout\ntest=int(stdin.readline())\nfor _ in range(test):\n N=int(stdin.readline())\n seq=list(input())\n fp,fp1,fl,fl1=0,0,0,1\n for i in range(N):\n if fl!=int(seq[i])-0:\n fp+=1\n fl=1-fl\n for i in range(N):\n ... | {"inputs": [["1", "4", "1011"]], "outputs": [["1"]]} | interview | https://www.codechef.com/ENFE2020/problems/ECFEB205 | |
1,119 | It's Diwali time and you are on a tour of Codepur, a city consisting of buildings of equal length and breadth because they were designed by a computer architect with a bit of OCD.
The ruling party of Codepur wants to have a blockbuster Diwali celebration but lack enough funds and decided to open a donation channel call... | ["#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\ndef kadane(arr, start, finish, n):\r\n Sum = 0\r\n maxSum = float('-inf')\r\n i = None\r\n finish[0] = -1\r\n local_start = 0\r\n for ... | {"inputs": [["6 5", "0 -2 -7 0 -1", "9 2 -6 2 0", "-4 1 -4 1 0", "-1 8 0 -2 1", "-10 1 1 -5 6", "-15 -1 1 5 -4"]], "outputs": [["9 2", "-4 1", "-1 8"]]} | interview | https://www.codechef.com/CHLG2020/problems/CCFUND | |
1,120 | Due to the COVID pandemic, maintaining social distancing is of utmost importance. In this problem, you'd calculate how many days would it take to reach an apocalypse from an initial case if nobody maintains social distancing.
The Earth is flat (for this question) and it's dimensions are $R$ x $C$
The whole Earth is alr... | ["#AUTHOR:: AMAN VERMA\ntry:\n for _ in range(int(input())):\n row,column=list(map(int,input().split(\" \")))\n x_x,y_y=list(map(int,input().split(\" \")))\n ab=max((x_x-0),(row-x_x-1))\n ba=max((y_y-0),(column-y_y-1))\n print(ab+ba)\nexcept:\n pass\n", "# cook your dish here\nfrom sys import stdin,stdout\n\ndef m... | {"inputs": [["2", "4 5", "2 1", "3 4", "1 1"]], "outputs": [["5", "3"]]} | interview | https://www.codechef.com/QTST2020/problems/APCLYPSE | |
1,121 | Chef is stuck on the minute hand of a giant clock. To escape from this clock he needs to get onto the hour hand which has an exit door.
Since the minute hand and and hour hand are not connected at any point, chef will surely need to make a jump. Since he wants minimum risks, he chooses to jump on the hour hand so that... | ["# cook your dish here\nt=int(input())\nwhile t>0:\n a=input().split(\":\")\n a1=int(a[0])\n a2=int(a[1])\n b1=a1%12 \n if a2%5!=0:\n b2=(a2//5)*5+5\n else:\n b2=a2\n \n c1=b1*30 \n \n extra=0.5*b2 \n c1+=extra\n c1%=360\n\n d1=(b2//5)*30 \n d1%=360 \n \n if c1>d1:\n ans1=c1-d1 \n ans2=360-ans1\n else:\n ans1=d1-... | {"inputs": [["3", "14:20", "02:10", "09:30"]], "outputs": [["50 degree", "5 degree", "105 degree"]]} | interview | https://www.codechef.com/PAHC2020/problems/CHEFJUMP | |
1,122 | Ravi is very good student in mathematics and he also like Even numbers very much .
On the other hand his friend Jhon like Odd numbers . Both of them are preparing for IIT JEE Advance .One day they are solving a question together the question was Find the sum of first $n$ terms of the given series $1^2+2.2^2+3^2+2.4^... | ["# cook your dish here\nwhile True:\n\ttry:\n\t\tm=int(input())\n\t\t\n\t\tn=int(m/2)\n\t\t\n\t\ta=m-n\n\t\n\t\tsum_even= int(2*(2*n*(n+1)*(2*n+1))/3)\n\t\t\n\t\tsum_odd= int(((4*a*a*a)-a)/3)\n\t\t\n\t\tresult=sum_odd+sum_even\n\t\t\n\t\tif result%2==0:\n\t\t\tprint('Ravi')\n\t\telse:\n\t\t\tprint('Jhon')\n\texcept:\n... | {"inputs": [["2", "3"]], "outputs": [["Jhon", "Ravi"]]} | interview | https://www.codechef.com/CFUN2020/problems/CODSTAN7 | |
1,123 | Chef has decided to start home delivery from his restaurant. He hopes that he will get a lot of orders for delivery, however there is a concern. He doesn't have enough work forces for all the deliveries. For this he has came up with an idea - he will group together all those orders which have to be delivered in nearby... | ["# cook your dish here\nfrom sys import stdin, stdout\nfrom math import ceil\n\n\ndef solve():\n for _ in range(int(input())):\n n, m = map(int, stdin.readline().split())\n par = [i for i in range(n)]\n for i in range(m):\n ta, tb = map(int, stdin.readline().strip().split())\n ... | {"inputs": [["1", "4 2", "0 1", "1 2", "3", "0 2", "0 3", "2 1", "", ""]], "outputs": [["YO", "NO", "YO"]]} | interview | https://www.codechef.com/problems/HDELIVER | |
1,124 | Lumpy is a bus driver. Today, the conductor is absent so Lumpy has to do the conductor's job as well. There are N creatures in the bus. Sometimes the creatures don't carry change and can't pay the exact amount of the fare. Each creature in the bus today has paid an amount
greater than his/her fare. You are given inform... | ["# cook your dish here\n# cook your dish here\nt=int(input())\nfor _ in range(t):\n n,p,q=list(map(int,input().split(\" \")))\n l=list(map(int,input().split(\" \")))\n l.sort()\n s=sum(l)\n a=p+2*q\n b=0\n for i in l:\n if(p==0):\n if(i%2==0 and a>=i):\n a=a-i\n b=b+1\n elif(q==0):\n if(a>=i):\n a=a-i\n... | {"inputs": [["3", "3 3 0", "1 2 2", "3 2 1", "1 2 1", "4 5 4", "2 3 4 5"]], "outputs": [["2", "3", "3"]]} | interview | https://www.codechef.com/problems/LUMPYBUS | |
1,125 | You are the principal of the Cake school in chefland and today is your birthday. You want to treat each of the children with a small cupcake which is made by you. But there is a problem, You don't know how many students are present today.
The students have gathered of the morning assembly in $R$ rows and $C$ columns. N... | ["# cook your dish here\nfor _ in range(int(input())):\n n=list(map(int,input().split()))\n print(n[0]*n[1])\n", "t=int(input())\r\n\r\nfor t1 in range(t):\r\n\tr,c=map(int,input().split())\r\n\tprint(r*c)", "# cook your dish here\nt=int(input())\nfor _ in range(t):\n R, C = map(int,input().split())\n ans =... | {"inputs": [["1", "5 10"]], "outputs": [["50"]]} | interview | https://www.codechef.com/ENDE2020/problems/ENCDEC2 | |
1,126 | "How did you get the deal,how did he agree?"
"Its's simple Tom I just made him an offer he couldn't refuse"
Ayush is the owner of a big construction company and a close aide of Don Vito The Godfather, recently with the help of the Godfather his company has been assigned a big contract according to the contract he has ... | ["for _ in range(int(input())):\n n=int(input())\n print((2*(pow(n,2)))-n+1)\n\n", "for _ in range(int(input())):\n n=int(input())\n print((2*(pow(n,2)))-n+1)\n\n", "# cook your dish here\nt = int(input())\nfor i in range(t):\n n = int(input())\n print(2*(n**2)-n+1)", "for _ in range(int(input())):\n ... | {"inputs": [["2", "1", "2"]], "outputs": [["2", "7"]]} | interview | https://www.codechef.com/CFW32020/problems/AYUSCRT | |
1,127 | Nitika was once reading a history book and wanted to analyze it. So she asked her brother to create a list of names of the various famous personalities in the book. Her brother gave Nitika the list. Nitika was furious when she saw the list. The names of the people were not properly formatted. She doesn't like this and ... | ["# cook your dish here\nx= int(input())\nfor i in range(x):\n y = list(map(str, input().split()))\n j= 0\n while j<len(y)-1:\n print((y[j][0]).capitalize()+\".\", end=' ')\n j+= 1\n print(y[len(y)-1].capitalize())", "# cook your dish here\nfor _ in range(int(input())):\n s = input()\n l... | {"inputs": [["3", "gandhi", "mahatma gandhI", "Mohndas KaramChand gandhi", "", ""]], "outputs": [["Gandhi ", "M. Gandhi ", "M. K. Gandhi "]]} | interview | https://www.codechef.com/problems/NITIKA | |
1,128 | The Chef is given an array of numbers and asked to find the first balance point of an array. A balance point is an index in the array N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no such balance point, print -1
-----Input-----
The first line of the... | ["import sys\n\nt = eval(input())\nfor j in range(t):\n n = eval(input())\n a = list(map(int, input().split()))\n ch = 0\n sm = 0 ; x = sum(a)\n s1 = [0] * n ; s2 = [0] * n\n for i in range(n):\n sm += a[i]\n s1[i] = sm\n s2[i] = x\n x -= a[i]\n if(sum(a) - a[0] == 0):\n print(0)\n elif(sum(a) - a[n - 1] == 0):\n ... | {"inputs": [["2", "7", "7 8 9 1 9 8 7", "6", "1 100 50 -51 1 1"]], "outputs": [["3", "1"]]} | interview | https://www.codechef.com/TSCO2017/problems/TSECJ101 | |
1,129 | Chef’s girlfriend is angry with him because he forgot her birthday. Chef decided to please her by gifting her a Love Graph.
Chef has $N$ vertices: $V_1, V_2, \dots, V_N$. Love Graph is an undirected multigraph with no self-loops and can be constructed by performing the following operations:-
- Choose an integer $i$ ($... | ["def fastpow(base, power):\n result = 1\n while power > 0:\n if power % 2 == 0:\n power = power // 2\n\n base = base * base\n else:\n power = power - 1\n result = result * base\n power = power // 2\n base = base * base\n return result\n\nt=int(input())\nfor i in range(t):\n a=list(map(int,input().split()... | {"inputs": [["1", "2 1"]], "outputs": [["2"]]} | interview | https://www.codechef.com/DCC2020/problems/DCC201 | |
1,130 | Finally, a COVID vaccine is out on the market and the Chefland government has asked you to form a plan to distribute it to the public as soon as possible. There are a total of $N$ people with ages $a_1, a_2, \ldots, a_N$.
There is only one hospital where vaccination is done and it is only possible to vaccinate up to $D... | ["for _ in range(int(input())):\n f,d=list(map(int,input().split()))\n arr=list(map(int,input().split()))\n risk=0\n days_risk=0\n days_norm=0\n if d==1:\n print(f)\n else:\n for a in arr:\n if a>=80 or a<=9:\n risk+=1\n norm=f-risk\n if risk%d==0:\n days_risk=risk//d\n else:\n days_risk=(risk//d)+1\n if... | {"inputs": [["2", "10 1", "10 20 30 40 50 60 90 80 100 1", "5 2", "9 80 27 72 79"]], "outputs": [["10", "3"]]} | interview | https://www.codechef.com/problems/VACCINE2 | |
1,131 | Chef has an array of N natural numbers most of them are repeated. Cheffina challenges chef to find all numbers(in ascending order) whose frequency is strictly more than K.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains two lines of input... | ["for _ in range(int(input())):\n n,k=[int(x) for x in input().split()]\n a=list(map(int,input().split()))\n dp=[0]*(max(a)+1)\n for _ in range(n):\n dp[a[_]]+=1\n for _ in range(1,len(dp)):\n if dp[_]>k:\n print(_,end=\" \")\n print()", "from collections import Counter\r\nfor... | {"inputs": [["1", "5 1", "5 2 1 2 5"]], "outputs": [["2 5"]]} | interview | https://www.codechef.com/PEND2020/problems/ANITGUY8 | |
1,132 | Shaun was given $N$ pairs of parenthesis ( ) by his teacher who gave him a difficult task.The task consists of two steps. First,Shaun should colour all $N$ pairs of parenthesis each with different color but opening and closing bracket of a particular pair should be of same colour. Then,Shaun should report to his teach... | ["mod = 1000000007\r\nfac = [1,1]\r\nmaxn = (10**5)+5\r\nfor i in range(2,maxn):\r\n x = (fac[-1]*i)%mod\r\n fac.append(x)\r\n\r\npre = [1]\r\nfor i in range(2,maxn):\r\n x = 2*i-1\r\n x = (pre[-1]*x)%mod\r\n pre.append(x)\r\n\r\nfor _ in range(int(input())):\r\n n = int(input())\r\n x = fac[n]\r\n... | {"inputs": [["3", "1", "2", "3"]], "outputs": [["1", "6", "90"]]} | interview | https://www.codechef.com/COCA2020/problems/COCA2003 | |
1,133 | Shivam is working on electric circuits. He requires some connecting wires. He needs to make a total of N connections and he has mentioned his wire length requirements for each connection in an integer sequence A. For buying wires, he need to decide the length of each wire piece, and he’ll get as many wire pieces of the... | ["from sys import stdin,stdout\nfrom math import gcd\nnmbr=lambda:int(stdin.readline())\nlst=lambda:list(map(int, stdin.readline().split()))\n\nfor _ in range(nmbr()):\n n=nmbr()\n a=lst()\n g=a[0]\n ans=0\n for v in a[1:]:\n g=gcd(v,g)\n for i in a:\n ans+=i//g\n print(g,ans)", "import math\nimport copy\nfrom functo... | {"inputs": [["1", "3", "2 4 8"]], "outputs": [["2 7"]]} | interview | https://www.codechef.com/CSTR2020/problems/ELECTRIC | |
1,134 | Daenerys Targaryen has been suggested by her counselors to leave the Meereen and start conquering other parts of the world. But she knows giving up on the people of Meereen means victory of slavery. Her plan is to start conquering rest of the world while she remains in Meereen. She can only trust her bravest and most b... | ["t=int(input())\nfor i in range(t):\n n,m=list(map(int,input().split()))\n a=list(map(int,input().split()))\n army=0\n if n>m:\n \n for i in range(0,m):\n army+=a[i]\n \n \n for j in range(m,n):\n army=army-(a[j]/2)\n if army<0:\n print('DEFEAT')\n break\n else:\n continue\n else:\n print('V... | {"inputs": [["3", "5 3", "1 2 3 4 5", "6 2", "4 4 4 4 4 4", "7 4", "10 10 10 10 50 60 70"]], "outputs": [["VICTORY", "VICTORY", "DEFEAT"]]} | interview | https://www.codechef.com/KOKT2015/problems/KOKT03 | |
1,135 | Chef Ada is the FootBall coach of the Dinosaurs Institute of Technology.
There are $N$ dinosaurs (enumerated $1$ through $N$) placed in a line. The i-th dinosaur has a height of $i$ meters.
Ada is training The dinosaurs in the following tactic:
- Initially the leftmost dinosaur has the ball.
- The dinosaur that has the... | ["# cook your dish here\nt=int(input())\nwhile t!=0:\n n,k=map(int,input().split())\n lst=[]\n for i in range(1,n+1):\n lst.append(i)\n lst[k],lst[n-1]=lst[n-1],lst[k]\n for item in lst:\n print(item,end=' ')\n t-=1", "# cook your dish here\nt=int(input())\ninputs=[]\nfor i in range(0,t):\n n,k=map(int,input().split(... | {"inputs": [["1", "5 2"]], "outputs": [["2 3 1 5 4"]]} | interview | https://www.codechef.com/problems/MXCH | |
1,136 | Chef has N laddus of K sweetness each. Chef wants to eat all laddus, but Chef is restricted with the given condition that he must not eat two adjacent laddus. Chef starts calculating the maximum sweetness that he will get from the laddus. Find the maximum sweetness that chef gets at the end of all calculations.
-----... | ["\r\nt = int(input())\r\n\r\nfor _ in range(t):\r\n n,m = map(int,input().split())\r\n\r\n if n==1:\r\n print(m)\r\n else:\r\n \r\n if n%2==0:\r\n print((n//2)*m)\r\n \r\n else:\r\n print(((n//2)+1)*m)", "# cook your dish here\nfor _ in range(int(in... | {"inputs": [["2", "1 2", "4 3"]], "outputs": [["2", "6"]]} | interview | https://www.codechef.com/PBK12020/problems/ITGUY17 | |
1,137 | Vishal Wants to buy 2 gifts for his best friend whose name is Annabelle(her age is 20), So they both went for shopping in a store. But Annabelle gave, Vishal a condition that she will accept this gifts only when the total price of the gifts is the same as her age times 100.
The store contains, a list of items whose pri... | ["test = int(input())\nANS = list()\nfor i in range(test):\n n = int(input())\n items = sorted(list(map(int, input().split())))\n c = 1\n for j in range(len(items)):\n if items[j] < 2000:\n t = 2000 - items[j]\n if t in items[j+1:]:\n ANS.append(\"Accepted\")\n c = 2\n break\n else:\n pass\n else:\n... | {"inputs": [["1", "5", "10 2 1000 50 1000"]], "outputs": [["Accepted"]]} | interview | https://www.codechef.com/ARYS2020/problems/BDYGFT | |
1,138 | Sereja is hosting his birthday dinner. He invited his N close friends. Let us number the people from 1 to N according to the order in which they arrive at the event. The dinner is being held in long straight corridor in which people sit in a way such that they won't leave any empty space in between two consecutive pers... | ["a=eval(input())\nwhile(a):\n\n x=eval(input())\n b=list(map(int,input().split()))\n z=[0]*100\n k=1\n j=0\n c=0\n for i in b:\n \n if i==0:\n \n z.insert(i,k)\n \n else:\n \n if z[z.index(i)+1]==0:\n \n z.insert(j,k)\n else:\n m=z.index(i)\n n=m+1\n p=(len(z)-z.count(0))-n\n c=c+min(n... | {"inputs": [["3", "1", "0", "3", "0 0 0", "5", "0 1 2 1 4"]], "outputs": [["0", "0", "3"]]} | interview | https://www.codechef.com/COOK64/problems/SEALINE | |
1,139 | The chef is very expert in coding, so to keep his password safe from the hackers. He always enters a decoded code of his password. You are a hacker and your work is to find the maximum number of possible ways to unlock his password in encoded form.
The encoded message containing only letters from A-Z is being encoded ... | ["t = int(input())\nwhile t>0:\n s = input().strip()\n if not s:\n print('NO')\n\n dp = [0 for x in range(len(s) + 1)]\n dp[0] = 1\n dp[1] = 1 if 0 < int(s[0]) <= 9 else 0\n\n for i in range(2, len(s) + 1):\n if 0 < int(s[i-1:i]) <= 9:\n dp[i] += dp[i - 1]\n if s[i-2:i][0] != '0' and int(s[i-2:i]) <= 26:\n dp[i]... | {"inputs": [["2", "12", "223"]], "outputs": [["YES", "NO"]]} | interview | https://www.codechef.com/CY302020/problems/CODEY302 | |
1,140 | Consider the following algorithm
order(arr, i) {
if length(arr) <= 1 {
return arr
}
l = []
r = []
n = length(arr) - 1
for j in 0, 1, ..., n {
if ( (arr[j] modulo power(2,i+1)) < power(2,i) ) {
append arr[j] to l
}else{
append arr[j] to r
}
}
l = order(l, i + 1)
r = order(r, i + 1)
c = concatenate(l, r)
return c
}
N... | ["for _ in range(int(input())):\n p, idx = map(int, input().split())\n b = bin(idx)[2:]\n b = ('0' * (p - len(b)) + b)[::-1]\n print(int(b, 2))", "# cook your dish here\nt=int(input())\nfor _ in range(t):\n p, idx=list(map(int, input().split()))\n length=2**p \n somma=0\n mult=1\n while length>1:\n length=length>>1 \n... | {"inputs": [["2", "3 3", "3 7"]], "outputs": [["6", "7"]]} | interview | https://www.codechef.com/ZCOPRAC/problems/ZCO20001 | |
1,141 | A tourist is visiting Byteland. The tourist knows English very well. The language of Byteland is rather different from English. To be exact it differs in following points:
- Bytelandian alphabet has the same letters as English one, but possibly different in meaning. Like 'A' in Bytelandian may be 'M' in English. Howev... | ["try:\n t,m=input().split()\n t=int(t)\n m=list(m)\n letters=list(\"abcdefghijklmnopqrstuvwxyz\")\n trans={}\n for i in range(len(letters)):\n trans[letters[i]]=m[i]\n for i in range(t):\n x=list(input())\n y=\"\"\n for j in x:\n if(j.isalpha()==True):\n if(j.isupper()==True):\n y+=trans[j.lower()].upper(... | {"inputs": [["and its"]], "outputs": [[]]} | interview | https://www.codechef.com/problems/TOTR | |
1,142 | This is one more story about our old friend, the Despotic King. Once every year, it was customary for the king to give audience to the rich merchants of his country in a large hall. On that day, the merchants were ushered in to meet the king one by one and after paying their respects to the king they were seated in the... | ["arr=[]\nn=int(input())\nfor i in range(n):\n a=int(input())\n arr.append(a)\n arr.sort()\n p=arr.index(a)\n print((i-p)+1)", "t=int(input())\nlst=[]\nfor m in range(t):\n n=int(input())\n lst.append(n)\nl=[]\nfor i in range(0,len(lst)):\n count=0\n for j in range(0,i):\n if(lst[i]<ls... | {"inputs": [["6", "78", "24", "68", "40", "39", "89"]], "outputs": [["1", "2", "2", "3", "4", "1"]]} | interview | https://www.codechef.com/IARCSJUD/problems/IARANK | |
1,143 | Yash likes playing with numbers. He has a challenge for you. Yash gives
you a number that he made by multiplying two numbers. He claims that the
possible sum of the two numbers he multiplied is as minimum as possible. He
challenges you to find that minimum sum.
Formally, for a given value of N, you are required to fin... | ["# cook your dish here\ndef isPrime(n) : \n \n # Corner cases \n if (n <= 1) : \n return False\n if (n <= 3) : \n return True\n \n # This is checked so that we can skip \n # middle five numbers in below loop \n if (n % 2 == 0 or n % 3 == 0) : \n return False\n \n i = 5\n ... | {"inputs": [["1", "852140"]], "outputs": [["1929"]]} | interview | https://www.codechef.com/CHLG2020/problems/MINI2 | |
1,144 | Devu loves to play with binary strings a lot. One day he borrowed a binary string s of size n from his friend Churu. Before starting to play with it, he wants to make sure that string does not contain more than k consecutive equal characters. For achieving that, only kind of operation he is allowed to perform is to fl... | ["T= int(input());\n\nfor i in range(T):\n n,k = list(map(int,input().split()));\n s=list(map(int,input()));\n\n if k==1:\n s_0 ={};\n s_1={};\n c0=0;\n c1=0;\n for j in range(n):\n if(j%2==0):\n s_1[j]=1;\n s_0[j]=0;\n else:\n s_1[j]=0;\n s_0[j]=1;\n for j in range(n):\n if(s_0[j]-s[j]!=0):\n ... | {"inputs": [["3", "2 1", "11", "2 2", "11", "4 1", "1001"]], "outputs": [["1", "10", "0", "11", "2", "1010"]]} | interview | https://www.codechef.com/problems/DEVSTR | |
1,145 | In a bizarre game of chess ,knight was so drunk, that instead of his usual move he started walking straight. In every move Knight jumps on 2n steps forward (n is number of block that he had travelled so far from starting) but after that he has to take either 1 step forward or backward.
Now the Knight needs to get to po... | ["from math import log,pow\nn=int(input())\na=[]\nfor i in range(n):\n no=int(input())\n if(no%2==0):\n a.append(\"0\")\n elif(no==1):\n a.append(\"1\")\n elif(no==3):\n a.append(\"3\")\n else:\n s=\"2\"\n lv=int(log(no,2))\n clv=1\n cno=3\n while(cno!=no):\n if(no<cno*pow(2,lv-clv)):\n s=s+\"1\"\n clv=... | {"inputs": [["2", "17", "10"]], "outputs": [["2111", "0"]]} | interview | https://www.codechef.com/ALGT2013/problems/TNMALG07 | |
1,146 | [Chopsticks (singular: chopstick) are short, frequently tapered sticks used in pairs of equal length, which are used as the traditional eating utensils of China, Japan, Korea and Vietnam. Originated in ancient China, they can also be found in some areas of Tibet and Nepal that are close to Han Chinese populations, as w... | ["# cook your dish here\n\na,b=list(map(int,input().split()))\nls=[]\nfor i in range(a):\n ls.append(int(input()))\nls.sort()\nc=0;i=0\nwhile i<(a-1):\n if ls[i+1]-ls[i]<=b:\n c=c+1\n i=i+1\n i=i+1\nprint(c)\n", "# cook your dish here\n\na,b=list(map(int,input().split()))\nls=[]\nfor i in range(a):\n ls.append(int(in... | {"inputs": [["5 2", "1", "3", "3", "9", "4"]], "outputs": [["2"]]} | interview | https://www.codechef.com/problems/TACHSTCK | |
1,147 | You are given a string S containing only lowercase characters.
You can rearrange the string and you have to print minimum number of characters needed(can be 0) to make it palindrome.
-----Input:-----
- First line contain an interger T denoting number of testcases.
- First line of each testcase contains integer N, siz... | ["# cooking dish here\n\nfrom sys import stdin\nfrom collections import Counter\nread = stdin.readline\n\nfor testcase in range(int(read())):\n length = int(read())\n string = read().strip()\n \n counts = Counter(string)\n \n odd_counts = 0\n \n for count in list(counts.values()):\n # pri... | {"inputs": [["3", "1", "a", "9", "abbbcbddd", "6", "abcdef"]], "outputs": [["0", "2", "5"]]} | interview | https://www.codechef.com/CDGO2021/problems/PALINDRO | |
1,148 | In ACM-ICPC contests, there are usually three people in a team. For each person in the team, you know their scores in three skills - hard work, intelligence and persistence.
You want to check whether it is possible to order these people (assign them numbers from 1 to 3) in such a way that for each 1 ≤ i ≤ 2, i+1-th per... | ["def g(x,y):\n d = x[0]>=y[0] and x[1]>=y[1] and x[2]>=y[2]\n e= x[0]>y[0] or x[1]>y[1] or x[2]>y[2]\n return d and e\nt=int(input())\nfor _ in range(t):\n a=list(map(int,input().split()))\n b=list(map(int,input().split()))\n c=list(map(int,input().split()))\n\n if g(a,b) and g(b,c):\n print('yes')\n elif g(a,c) and ... | {"inputs": [["3", "1 2 3", "2 3 4", "2 3 5", "1 2 3", "2 3 4", "2 3 4", "5 6 5", "1 2 3", "2 3 4"]], "outputs": [["yes", "no", "yes"]]} | interview | https://www.codechef.com/problems/ORDTEAMS | |
1,149 | Chef had an interesting dream last night. He dreamed of a new revolutionary chicken recipe. When he woke up today he tried very hard to reconstruct the ingredient list. But, he could only remember certain ingredients. To simplify the problem, the ingredient list can be represented by a string of lowercase characters 'a... | ["# cook your dish here\n\n \nt=int(input())\nfor _ in range(t):\n l = input()\n \n n= len(l)\n prod = 1\n for k in range(n//2):\n i = l[k]\n j = l[n-k-1]\n if ((i!=j) and (i!='?' and j!=\"?\") ):\n prod=0\n break\n elif ((i==j) and (i=='?')):\n prod*=26\n prod = prod%10000009\n if n%2!=0:\n if l[n//2]==\"?... | {"inputs": [["5", "?", "??", "ab?", "a?c", "aba"]], "outputs": [["26", "26", "1", "0", "1", "Constraints", "1 \u2264 T \u2264 20", "1 \u2264 sum of length of all input strings \u2264 1,000,000", "Each input string contains only lowercase roman letters ('a' - 'z') or question marks."]]} | interview | https://www.codechef.com/problems/RRECIPE | |
1,150 | In the 2-D world of Flatland, the Circles were having their sports day and wanted to end it with a nice formation. So, they called upon Mr. Sphere from Spaceland for help. Mr Sphere decides to arrange the Circles in square formations. He starts with $N$ Circles and forms the largest possible square using these Circles.... | ["# cook your dish here\nimport math\nfor _ in range(int(input())):\n n=int(input())\n c=0\n while(n>0):\n i=int(math.sqrt(n))\n c+=1\n n=n-i**2\n print(c)\n \n", "l = []\nfor _ in range(int(input())):\n n = int(input())\n count = 0\n while n>0:\n r = int(n ** 0.5)\n n = n - r*r\n count+=1\n l.append(coun... | {"inputs": [["2", "85", "114"]], "outputs": [["2", "4"]]} | interview | https://www.codechef.com/problems/ICL1902 | |
1,151 | There is a city with $N$ numbered $0 - N-1$ shops. A market is a place where we can reach from one shop to another using some road. There are $M$ roads in this city connecting each connecting any two shops.
Find the number of markets in the city.
NOTE: A market having only one shop is also a valid market.
-----Input... | ["from sys import stdin\r\nfrom math import ceil, gcd\r\n\r\n# Input data\r\n#stdin = open(\"input\", \"r\")\r\n\r\n\r\ndef dfs(src, visit):\r\n visit[src] = 1\r\n for nbr in d[src]:\r\n if visit[nbr] == 0:\r\n dfs(nbr, visit)\r\n\r\nfor _ in range(int(stdin.readline())):\r\n n, m = list(map(... | {"inputs": [["1", "5 3", "0 1", "2 3", "3 4"]], "outputs": [["2"]]} | interview | https://www.codechef.com/ENAU2020/problems/ECAUG206 | |
1,152 | Chef Jessie has a lot of recipes with her (N). She often remembered the starting few characters of the recipe and forgot the rest. As all the great chefs do, Jessie also numbered the recipes depending on the priority. So, given the list of recipes along with their priorities answer Jessie’s queries.
Jessie’s queries ar... | ["nr=int(input())\nd={}\nfor r in range(nr):\n s,v=list(map(str,input().split()))\n d[int(v)]=s\nq=int(input())\nlis=[]\nfor i in range(q):\n lis.append(input())\nl=list(d.keys())\nl.sort(reverse=True)\nans='NO'\n\n\nfor j in lis:\n ans='NO'\n for k in l:\n if len(j)<=len(d[k]):\n a=d[k]\n if j==a[0:len(j)]:\n ... | {"inputs": [["4", "flour-with-eggs 100", "chicken-ham -10", "flour-without-eggs 200", "fish-with-pepper 1100", "6", "f", "flour-with", "flour-with-", "c", "fl", "chik"]], "outputs": [["fish-with-pepper", "flour-without-eggs", "flour-with-eggs", "chicken-ham", "flour-without-eggs", "NO"]]} | interview | https://www.codechef.com/problems/TWSTR | |
1,153 | -----Problem Statement-----
Sereja has a sequence of n integers a[1], a[2], ..., a[n]. Sereja can do following transformation of the array:
- create a new sequence of n integers b[1], b[2], ..., b[n]in this way: (1 ≤ i ≤ n)
- Replace the sequence a by b, i.e., a[i] = b[i] for all i in [1, n]
Sereja decided to us... | ["def mod(a,b,c):\n x = 1\n y = a\n while(b>0):\n if(b%2==1):\n x = (x*y)%c\n y = (y*y)%c\n b /=2\n return x%c\nt = int(input())\nnum = 10**9+7\nfor i in range(t):\n n,m,q,k = list(map(int,input().split()))\n if m<=q:\n print(0)\n else:\n a1 = m-q\n a2 = mod(q+1,n,num)\n a3 = mod(q-1,n,num)\n a4 = mod(q,n,num... | {"inputs": [["3", "1 1 1 1", "2 2 1 1", "2 3 1 1"]], "outputs": [["0", "2", "4"]]} | interview | https://www.codechef.com/problems/SEATRSF | |
1,154 | Chef and his friends are playing the game AMONG US. They all have chosen their names as numbers. There are N people in Chef’s group including him, and each swears that he is not the imposter. However, it turns out there were N+1 people in the game. Now all that Chef needs to know is the name of the imposter, which is a... | ["try:\n\tn=int(input())\n\tx=[*list(map(int, input().split()))]\n\ty=[*list(map(int, input().split()))]\n\tfor i in y:\n\t\td=x.count(i)-y.count(i)\n\t\tif d!=0:\n\t\t\tprint(i)\n\t\t\tbreak\nexcept: pass\n", "n=int(input())\nl1=list(map(int,input().split()))\nl2=list(map(int,input().split()))\np=1\nl1=sorted(l1)\nl2=... | {"inputs": [["3", "4 2 5", "4 2 3 5"]], "outputs": [["3"]]} | interview | https://www.codechef.com/CSTR2020/problems/AMONGUS | |
1,155 | Autobots are instructed by Optimus Prime to mobilize in the form of a rectangular shape with each Autobot on each vertex of the rectangle region on a -”deployment area” (which may consist of one or more regions). This is done so as to take care of the inner rectangular area called “region”. However the rule states-“no ... | ["print", "print"] | {"inputs": [["1", "4", "0 4 0 4", "1 3 1 2", "2 3 1 3", "3 4 1 3"]], "outputs": [["2"]]} | interview | https://www.codechef.com/TCTR2012/problems/NOPC2 | |
1,156 | Write a program, which takes an integer N and if the number is less than 10 then display "Thanks for helping Chef!" otherwise print "-1".
-----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, output... | ["# cook your dish here\nfor i in range(int(input())):\n x=int(input())\n if x<10:\n print(\"Thanks for helping Chef!\")\n else:\n print(\"-1\")\n", "for _ in range(int(input())):\n if int(input())<10:\n print(\"Thanks for helping Chef!\")\n else:\n print(-1)", "# cook your di... | {"inputs": [["3", "1", "12", "-5"]], "outputs": [["Thanks for helping Chef!", "-1", "Thanks for helping Chef!"]]} | interview | https://www.codechef.com/problems/FLOW008 | |
1,157 | Today is the planned day tor Thik and Ayvak's wedding. Kark is infatuated with Ayvak. He offers to play a game with Thik. Whosoever wins, will get to marry Ayvak. Ayvak, who values games of chance over all the other things in life, agrees to this.
Kark sets up an N by M grid (N rows, M columns), labelled from left to ... | ["# cook your dish here\n# cook your dish here\nfor i in range(int(input())):\n n,m,k=map(int,input().split())\n l,ans = list(map(int,input().split())),0\n for i in l:\n r=i//m + 1;c=i%m\n if(c==0):c=m;r-=1\n ans+=r*(n+1-r)*c*(m+1-c)\n ans/=((n+1)*(m+1)*n*m)//4\n print(ans)", "# cook... | {"inputs": [["1", "2 2 2", "1 2", "", ""]], "outputs": [["0.8888888888888888"]]} | interview | https://www.codechef.com/problems/RECTLOVE | |
1,158 | Recently, chef Ciel often hears about 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.
Ciel decides to make Ciel numbers.
As you know, Ciel likes the digit 8 ve... | ["#!/usr/bin/env python\n\ndef main():\n N = int(input())\n C = 0\n for n in range(N):\n S = input().strip()\n Pi = S.split()[-1]\n L = [Pi.count(k) for k in map(str, list(range(10)))]\n if L[8] >= L[5] and L[5] >= L[3] and \\\n L[0] == 0 and L[1] == 0 and \\\n L[2] == 0 and L[4] == 0 and \\\n L[6] == 0 and L... | {"inputs": [["6", "milk 58", "Ciel's Drink 80", "The curry 2nd edition 888888", "rice omelet 85855", "unagi 1", "The first and last letters can be a space 358"]], "outputs": [["3", "Output details", "58 and 888888 and 358 are Ciel numbers.", "80 and 85855 and 1 are not Ciel numbers.", "Notes", "Different operatin... | interview | https://www.codechef.com/COOK20/problems/CIELNUM2 | |
1,159 | Abhi and his friends (Shanky,Anku and Pandey) love to play with strings. Abhi invented a simple game. He will give a string S to his friends. Shanky and Anku will play the game while Pandey is just a spectator. Shanky will traverse the string from beginning (left to right) while Anku will traverse from last (right to l... | ["t = int(input())\n\nfor e in range(t):\n\n str = input()\n\n dict = {}\n\n for x in range(len(str)):\n if str[x] in dict:\n dict[str[x]] = -1\n else:\n dict[str[x]] = x\n\n shankyIndex = len(str)\n ankuIndex = -1\n for x in dict:\n if dict[x] != -1:\n if dict[x] < shankyIndex:\n shankyIndex = dict[x]\n ... | {"inputs": [["3", "google", "breakraekb", "aman"]], "outputs": [["SHANKY", "PANDEY", "ANKU"]]} | interview | https://www.codechef.com/RECJ1601/problems/ABHSTR | |
1,160 | Chef is an advocate for Go Green Initiative. Today he had n trees planted in a row outside his his restaurant. Today, the height of i-th tree is hi feet. The trees grow at a rate of mi feet per day.
Chef knows that trees will look beautiful if they form a zig-zag sequence. The trees will be said to be in Zig-zag sequen... | ["def get(l,n):\n l1,l2 = [],[]\n i = 1\n h1,m1 = l[0]\n while (i < len(l)):\n h2,m2 = l[i]\n if (h1>h2):\n if (m1 >= m2):\n l1 += [(0,10**20)]\n l2 += [(-1,-1)]\n else:\n d = (h1-h2)//(m2-m1)\n if (((h1-h2)%(m2-m1)) == 0):\n l1 += [(0,d-1)]\n l2 += [(d+1,10**20)]\n else:\n l1 += [(0,d)... | {"inputs": [["3", "3", "0 1", "2 2", "0 3", "2", "2 1", "1 2", "3", "1 1", "2 2", "3 3"]], "outputs": [["1", "0 1", "2", "0 0", "2 Inf", "0"]]} | interview | https://www.codechef.com/AUG16/problems/CHAHG | |
1,161 | In Snakeland, there are some snakes and mongooses. They are lined up in a row. The information about how exactly they are lined up it is provided to you by a string of length n. If the i-th character of this string is 's', then it means that there is a snake at the i-th position, whereas the character 'm' denotes a mon... | ["for i in range(int(input())):\n a=input()\n c=a.count('m')\n d=a.count('s')\n t=0\n while t<len(a)-1:\n if (a[t]=='m' and a[t+1]=='s') or (a[t]=='s' and a[t+1]=='m'):\n d=d-1\n t=t+2\n else:\n t=t+1\n if c>d:\n print('mongooses')\n elif d>c:\n print('snakes')\n else:\n print('tie')\n", "for t in range(int(... | {"inputs": [["4", "sm", "ssm", "sms", "ssmmmssss"]], "outputs": [["mongooses", "tie", "tie", "snakes"]]} | interview | https://www.codechef.com/problems/SNELECT | |
1,162 | Every great chef knows that lucky numbers are positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Our chef has recently returned from the Lucky country. He observed that every restaurant in the Lucky country had a lu... | ["import sys\nimport os\n\ndef __starting_point():\n start = 0\n for line in sys.stdin:\n if start == 0:\n start = 1\n continue\n else:\n try:\n n = int(line.strip())\n \n # print n \n \n ... | {"inputs": [["5", "7", "4", "11", "1", "15", "", ""]], "outputs": [["7", "0", "7", "-1", "7"]]} | interview | https://www.codechef.com/MAY12/problems/CHEFLUCK | |
1,163 | Who's interested in football?
Rayne Wooney has been one of the top players for his football club for the last few years. But unfortunately, he got injured during a game a few months back and has been out of play ever since.
He's got proper treatment and is eager to go out and play for his team again. Before doing that,... | ["T = int(input())\nfor j in range(0,T):\n line1, line2 = input(), input()\n seq = line2.split()\n current_min = 1000001\n current_max = 0\n max_spread = 0\n for i in range(0,len(seq)):\n current_value = int(seq[i])\n if current_min > current_value:\n current_min = current_value\n current_max = current_value\n e... | {"inputs": [["3", "6", "3 7 1 4 2 4", "5", "5 4 3 2 1", "5", "4 3 2 2 3"]], "outputs": [["4", "UNFIT", "1"]]} | interview | https://www.codechef.com/APRIL12/problems/PLAYFIT | |
1,164 | Mandarin chinese
, Russian and Vietnamese as well.
Chef is organising a contest with $P$ problems (numbered $1$ through $P$). Each problem has $S$ subtasks (numbered $1$ through $S$).
The difficulty of a problem can be calculated as follows:
- Let's denote the score of the $k$-th subtask of this problem by $SC_k$ and t... | ["p,s = [int(i) for i in input().split()]\nscores = {}\n\nfor j in range(1, p + 1):\n sc = [int(i) for i in input().split()]\n ns = [int(i) for i in input().split()]\n nsc = dict(list(zip(sc,ns)))\n ssc = sorted(sc)\n score = 0\n for a,b in zip(ssc[:-1], ssc[1:]):\n if nsc[a] > nsc[b]:\n score += 1\n if score in lis... | {"inputs": [["3 3", "16 24 60", "498 861 589", "14 24 62", "72 557 819", "16 15 69", "435 779 232"]], "outputs": [["2", "1", "3"]]} | interview | https://www.codechef.com/problems/PROBLEMS | |
1,165 | Chef will not be able to attend the birthday of his best friend Rock. He promised Rock that this will not be the case on his half birthday. To keep his promise Chef must know Rock’s next half birthday accurately. Being busy, he is assigning this work to you.
Half birthday is the day that occurs exactly between two subs... | ["# cook your dish here\nd = {'january':31,'february':29,'march':31,\n 'april':30,'may':31,'june':30,'july':31,\n 'august':31,'september':30,'october':31,\n 'november':30,'december':31}\n \n#l=[[15,'january'],[31,'august'],[10,'october']]\nl2 = list(d.keys())\nfor _ in range(int(input())):\n l=input().split()\n l[0]=in... | {"inputs": [["3", "15 january", "31 august", "10 october"]], "outputs": [["16 july", "1 march", "10 april"]]} | interview | https://www.codechef.com/PAHC2020/problems/HALFBDAY | |
1,166 | Little Elephant is playing a game with arrays. He is given an array A0, A1, ..., AN−1 of N integers. And then Q queries are given, each containing an integer K. He has to tell how many subarrays satisfy the condition: the function foo returns K when it is applied to the subarray.
In this problem, a subarray is defined... | ["import sys\nimport math\n\ndef main(arr,k):\n \n ans=0\n for i in range(len(arr)):\n curr_min=float('inf')\n for j in range(i,len(arr)):\n curr_min=min(curr_min,arr[j])\n \n if curr_min==k:\n ans+=1 \n return ans\n \n\nn=int(input())\nar... | {"inputs": [["5", "4 1 2 3 4", "4", "3", "4", "6", "1", "", ""]], "outputs": [["2", "2", "0", "8"]]} | interview | https://www.codechef.com/problems/SUBMIN | |
1,167 | Tom has finally taken over the business empire and now looking for
a new Name of the business to make a new start.
Joe (Tom's dear friend) suggested a string $S$ consisting of
Uppercase and lowercase letters
Tom wants to make some changes as per the following criteria:
1) String should $not$ have any vowels ... | ["s = input().lower()\r\nvow = [\"a\", \"e\", \"i\", \"o\", \"u\", \"y\"]\r\nans = \"\"\r\nfor ch in s:\r\n if ch in vow:\r\n continue\r\n if ch.isalpha():\r\n ans += \".\" + ch\r\nprint(ans)\r\n"] | {"inputs": [["CodeSprInT"]], "outputs": [[".c.d.s.p.r.n.t"]]} | interview | https://www.codechef.com/SPRT2020/problems/EMPRNM | |
1,168 | Abhishek is fond of playing cricket very much. One morning, he is playing cricket with his friends. Abhishek is a right-hand batsman
.He has to face all types of balls either good or bad. There are total 26 balls in the game and each ball is represented
by one of the following two ways:-
1. "g" denotes a good ball... | ["import sys\nfor _ in range(0,eval(input())): \n d,inp,mp,n,q=set(),list(map(ord,list(sys.stdin.readline().strip()))),[x=='b' for x in list(sys.stdin.readline().strip())],eval(input()),ord('a')\n inps = [inp[i:] for i in range(len(inp))]\n inps.sort()\n op,prev= 0,''\n for ip in inps:\n \ti,ct=... | {"inputs": [["2", "ababab", "bgbbbbbbbbbbbbbbbbbbbbbbbb", "1", "acbacbacaa", "bbbbbbbbbbbbbbbbbbbbbbbbbb", "2"]], "outputs": [["5", "8"]]} | interview | https://www.codechef.com/ICOD2016/problems/ICODE16G | |
1,169 | This is a simple game you must have played around with during your school days, calculating FLAMES of you and your crush! Given the names of two people, cancel out the common letters (repeated occurrence of a letter is treated separately, so 2A's in one name and one A in the other would cancel one A in each name), coun... | ["import sys\n\ndef joseph(k, n=6):\n\tif k==0:\n\t\tk = 1\n\tx = 0\n\tfor i in range(2,n+1):\n\t\tx = (x+k)%i\n\treturn x\n\nFLAMES = ['FRIENDS', 'LOVE', 'ADORE', 'MARRIAGE', 'ENEMIES', 'SISTER']\n\nnCase = int(sys.stdin.readline())\nfor _ in range(nCase):\n\ta = ''.join(sys.stdin.readline().split())\n\tb = ''.join(sy... | {"inputs": [["2", "SHILPA", "AAMIR", "MATT", "DENISE", "", "", ""]], "outputs": [["ENEMIES", "LOVE"]]} | interview | https://www.codechef.com/IGNS2012/problems/IG01 | |
1,170 | In order to establish dominance amongst his friends, Chef has decided that he will only walk in large steps of length exactly $K$ feet. However, this has presented many problems in Chef’s life because there are certain distances that he cannot traverse. Eg. If his step length is $5$ feet, he cannot travel a distance of... | ["t=int(input())\nfor i in range(0,t):\n n,k=map(int,input().split())\n a1,*a=map(int,input().split())\n a.insert(0,a1)\n j=0\n while j<n:\n if a[j]%k==0:\n print(1,end=\"\")\n else:\n print(0,end=\"\")\n j+=1\n print(\"\")", "t=int(input())\nfor i in range(0,t):\n n,k=map(int,input().split())\n a1,*a=map(int,in... | {"inputs": [["1", "5 3", "12 13 18 20 27216"]], "outputs": [["10101"]]} | interview | https://www.codechef.com/problems/CHEFSTEP | |
1,171 | Roger recently built a circular race track with length K$K$. After hosting a few races, he realised that people do not come there to see the race itself, they come to see racers crash into each other (what's wrong with our generation…). After this realisation, Roger decided to hold a different kind of "races": he hired... | ["import numpy as np\r\nfrom numba import njit\r\ni8 = np.int64\r\n\r\n\r\n@njit\r\ndef solve(a, b, t, K, N):\r\n t1 = t // K\r\n d = t % K * 2\r\n # b \u304c a \u304b\u3089 a + d \u306e\u4f4d\u7f6e\u306b\u3042\u308c\u3070\u885d\u7a81\u3059\u308b\r\n x = 0\r\n y = 0\r\n ans = 0\r\n for c in a:\r\n ... | {"inputs": [["5 3 11", "1 3", "1 10", "2 4", "2 7", "2 0", "3", "8", "100"]], "outputs": [["4", "10", "110"]]} | interview | https://www.codechef.com/problems/CRSHIT | |
1,172 | Chef has the string s of length n consisted of digits 4 and 7.
The string s is called balanced
if there exits such integer x (1 ≤ x ≤ n) that the number of digits 4 in substring s[1; x) is equal to the number of digits 7 in substring s(x; n],
where s[1; x) is the substring from the 1st digit to (x-1)th digit of s, and ... | ["from math import factorial\ndef Ncr(n,r):\n if r<0:return 0\n return factorial(n)/(factorial(n-r)*factorial(r))\ndef solve(m,n):\n modulo=10**9+7\n if m==n:\n return (Ncr(2*n-1,n-1)+Ncr(2*n-2,n-2))%modulo\n elif m>n:\n return (Ncr(m+n,n)-Ncr(m+n-2,n-1))%modulo\n else:\n return (... | {"inputs": [["2", "47", "4477", "", ""]], "outputs": [["1", "4"]]} | interview | https://www.codechef.com/NOV12/problems/LUCKY9 | |
1,173 | Guddu was participating in a programming contest. He only had one problem left when his mother called him for dinner. Guddu is well aware how angry his mother could get if he was late for dinner and he did not want to sleep on an empty stomach, so he had to leave that last problem to you. Can you solve it on his behalf... | ["import itertools\nfrom collections import defaultdict as dfd\ndef sumPairs(arr, n):\n s = 0\n for i in range(n-1,-1,-1): \n s += i*arr[i]-(n-1-i)*arr[i]\n return s\n\ndef subarrayXor(arr, n, m):\n ans = 0\n xorArr =[0 for _ in range(n)]\n mp = dfd(list)\n xorArr[0] = arr[0]\n for i in range(1, n): \n xorArr[i] = xo... | {"inputs": [["1", "3", "5 2 7"]], "outputs": [["2"]]} | interview | https://www.codechef.com/problems/KS1 | |
1,174 | Chef has a sequence of N$N$ integers A1,A2,...,AN$A_1, A_2, ..., A_N$.
Chef thinks that a triplet of integers (i,j,k)$(i,j,k)$ is good if 1≤i<j<k≤N$1 \leq i < j < k \leq N$ and P$P$ in the following expression contains an odd number of ones in its binary representation:
P=[Ai<<(⌊log2(Aj)⌋+⌊log2(Ak)⌋+2)]+[Aj<<(⌊log2(Ak... | ["from math import *\nt = int(input())\nfor _ in range(t):\n n = int(input())\n a = [int(d) for d in input().split()]\n odd,even = 0,0\n for i in range(n):\n if bin(a[i]).count(\"1\")%2 == 1:\n odd += 1\n else:\n even +=1\n total = 0\n if odd >= 3 and even >= 2:\n total += (odd*(... | {"inputs": [["1", "4", "1 1 2 3"]], "outputs": [["1"]]} | interview | https://www.codechef.com/problems/LOG_EQN | |
1,175 | Oliver and Nova are true lovers. Inspite of knowing that Nova will die Oliver married her at the lake where they met. But they had a conflict about even and odd numbers. Nova likes the odd numbers and Oliver prefers even. One day they went to a fair where Oliver bought some square shaped marshmallows and Nova bought so... | ["import math\n\ndef lcm(a, b):\n return (a*b)//gcd(a, b)\n\ndef gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a%b) \n \nfor _ in range(int(input())):\n n = int(input())\n\n na = math.ceil((2*n)/math.acos(-1))\n nb = ((n+1)//2)**2\n\n nlcm = lcm(na, nb)\n\n oa = math.ceil(n/2)\... | {"inputs": [["1", "111"]], "outputs": [["YESS(sunglass emo)"]]} | interview | https://www.codechef.com/NEWB2020/problems/CNFCT | |
1,176 | There are $5$ cities in the country.
The map of the country is given below.
The tour starts from the red city.
Each road is associated with a character.
Initially, there is an empty string.
Every time a road has been travelled the character associated gets appended to the string.
At the green city either the string ca... | ["for _ in range(int(input())):\n s=input()\n if len(s)<4:\n print(\"NO\")\n else:\n if s[-4:]==\"1000\":\n print(\"YES\")\n else:\n print(\"NO\")", "# cook your dish here\nt = int(input())\nfor i in range(t):\n n = input()\n if len(n)>=4:\n if n . endswith ('1000'):\n print(\"YES\")\n else:\n print(\"NO\"... | {"inputs": [["1", "100"]], "outputs": [["NO"]]} | interview | https://www.codechef.com/problems/ICM2006 | |
1,177 | Chef has N subordinates. In order to complete a very important order he will choose exactly K of them. He can't choose less than K since it will be not enough to complete the order in time. On the other hand if he chooses more than K subordinates he can't control them during the operation. Help him to find the number o... | ["def nCr(n,k):\n if(k>n):return 0\n k=min(k,n-k)\n num,den=1,1\n for i in range(k):\n num*=(n-i)\n den*=(i+1)\n return num/den\n\ndef Main():\n for cases in range(int(input())):\n a,b=[int(x) for x in input().split()]\n print(nCr(a,b))\n\nMain()", "def gets():\n while(1):\n a=input().strip()\n if(a):return a\n\n... | {"inputs": [["3", "2 1", "3 3", "10 5"]], "outputs": [["2", "1", "252"]]} | interview | https://www.codechef.com/COOK06/problems/CHEFTEAM | |
1,178 | Tonight, Chef would like to hold a party for his $N$ friends.
All friends are invited and they arrive at the party one by one in an arbitrary order. However, they have certain conditions — for each valid $i$, when the $i$-th friend arrives at the party and sees that at that point, strictly less than $A_i$ other people ... | ["test=int(input())\nfor _ in range(test):\n n=int(input())\n ls=list(map(int,input().split()))\n ls.sort()\n s=0\n for i in range(n):\n if s>=ls[i]:\n s=s+1\n else:\n break\n print(s)", "# cook your dish here\ntest_case = int(input())\nwhile test_case :\n n = int(input())\n friends_req = list(map(int, input().st... | {"inputs": [["3", "2", "0 0", "6", "3 1 0 0 5 5", "3", "1 2 3"]], "outputs": [["2", "4", "0"]]} | interview | https://www.codechef.com/problems/CHFPARTY | |
1,179 | You are given a positive integer $N$. Consider the sequence $S = (1, 2, \ldots, N)$. You should choose two elements of this sequence and swap them.
A swap is nice if there is an integer $M$ ($1 \le M < N$) such that the sum of the first $M$ elements of the resulting sequence is equal to the sum of its last $N-M$ elemen... | ["# cook your dish here\nfrom math import sqrt\nfor _ in range(int(input())):\n n=int(input())\n sum=(n*(n+1))//2\n #print(sum)\n if(sum%2!=0):\n print(0)\n continue\n m=(int((sqrt(1+4*(sum)))-1)//2)\n if(m*(m+1)//2==sum//2):\n print((((m-1)*m)//2)+n-m+((n-m-1)*(n-m))//2)\n else:\n print(n-m)\n", "# cook your dish ... | {"inputs": [["5", "1", "2", "3", "4", "7"]], "outputs": [["0", "0", "2", "2", "3"]]} | interview | https://www.codechef.com/problems/CHFNSWAP | |
1,180 | You are playing a Billiards-like game on an $N \times N$ table, which has its four corners at the points $\{(0, 0), (0, N), (N, 0),$ and $(N, N)\}$. You start from a coordinate $(x,y)$, $(0 < x < N, 0 < y < N)$ and shoot the ball at an angle $45^{\circ}$ with the horizontal. On hitting the sides, the ball continues t... | ["# cook your dish here\nt=int(input())\nfor i in range(t):\n a=0\n b=0\n N,K,x,y=map(int,input().split())\n if x==y:\n a=N\n b=N\n elif x>y:\n if K%4==1:\n a=N \n b=y-x+N\n elif K%4==2:\n a=y-x+N\n b=N\n elif K%4==3:\n a=0\n b=x-y\n else:\n a=x-y\n b=0\n else:\n if K%4==1:\n a=x-y+N \n b=N\n... | {"inputs": [["2", "5 5 4 4", "5 2 3 1"]], "outputs": [["5 5", "3 5"]]} | interview | https://www.codechef.com/problems/BILLRD | |
1,181 | Chef has a natural number N. Cheffina challenges chef to check whether the given number is divisible by the sum of its digits or not. If the given number is divisible then print "Yes" else "No".
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case cont... | ["import sys,io,os,math\nfrom math import ceil,log,gcd,inf\nfrom itertools import permutations\nmod=1000000007\nmod1=998244353\ndef printlist(n):\n sys.stdout.write(\" \".join(map(str,n)) + \"\\n\")\nprintf=lambda n:sys.stdout.write(str(n)+\"\\n\")\ndef printns(n):\n sys.stdout.write(str(n)) \ndef intinp():\n ... | {"inputs": [["2", "16", "27"]], "outputs": [["No", "Yes"]]} | interview | https://www.codechef.com/PEND2020/problems/ANITGUY9 | |
1,182 | Gorodetskiy is a university student. He is really good at math and really likes solving engaging math problems. In the last exam, his professor gave him really hard math problems to solve, but Gorodetskiy could not solve them and failed the exam, so the professor told him: "These problems are a piece of cake, you shoul... | ["\ndef interesting_nums(m):\n nums = []\n for x in range(m + 1, 2 * m + 1):\n if x * m % (x - m) == 0:\n nums.append(x)\n\n return nums\n\n\ndef main():\n\n T = int(input())\n\n for _ in range(T):\n num_list = interesting_nums(int(input()))\n print(len(num_list))\n\n for num in num_list:\n print(num)\n\n\nmain... | {"inputs": [["2", "3", "6"]], "outputs": [["2", "4", "6", "5", "7", "8", "9", "10", "12"]]} | interview | https://www.codechef.com/problems/DRMP | |
1,183 | Problem description.
This problem is simple and will introduce you to the Dynamic Programming.
You will be given an array and a key value.
You will have to find out the occurrences of the key value depending upon the query using Brute Force and Top Down Dynamic Programming.
-----Brute-Force: -----
You will check th... | ["for __ in range(eval(input())):\n x = eval(input())\n a = list(map(int,input().split()))\n key = eval(input())\n query = eval(input())\n maxvisited = x #maximum visted value\n j = x-1\n ans = []\n val = 0\n while j>=0:\n if a[j]==key:\n ans.append(val+1)\n val =... | {"inputs": [["1", "10", "1 2 3 1 2 3 1 2 3 1", "3", "5", "2", "4", "6", "8", "2", ""]], "outputs": [["3 8 9", "2 6 1", "1 4 1", "1 2 1", "3 8 1"]]} | interview | https://www.codechef.com/AIPC2015/problems/AN01 | |
1,184 | Chef's friend Alex runs a movie theatre. Due to the increasing number of platforms for watching movies online, his business is not running well. As a friend, Alex asked Chef to help him maximise his profits. Since Chef is a busy person, he needs your help to support his friend Alex.
Alex's theatre has four showtimes:... | ["from itertools import permutations\nC = list(permutations(['A','B','C','D']))\nV = list(permutations([3,6,9,12]))\nP = list(permutations([25,50,75,100]))\nR = []\n\ndef test():\n d = {}\n n = int(input())\n for i in C[0]:\n for j in V[0]:\n d[i+str(j)] = 0\n for i in range(n):\n x,y = input().split()\n d[x+y] +=... | {"inputs": [["5", "12", "A 3", "B 12", "C 6", "A 9", "B 12", "C 12", "D 3", "B 9", "D 3", "B 12", "B 9", "C 6", "7", "A 9", "A 9", "B 6", "C 3", "D 12", "A 9", "B 6", "2", "A 9", "B 6", "1", "D 12", "0"]], "outputs": [["575", "525", "-25", "-200", "-400", "475"]]} | interview | https://www.codechef.com/problems/THEATRE | |
1,185 | Taru likes reading. Every month he gets a copy of the magazine "BIT". The magazine contains information about the latest advancements in technology. Taru
reads the book at night and writes the page number to which he has read on a piece of paper so that he can continue from there the next day. But sometimes
the pa... | ["import sys\n\nrl=sys.stdin.readline\nT=int(rl())\nfor t in range(T):\n P=int(rl())\n T=(P+1)//2\n F=list(map(int,rl().split()))[1:]\n numtorn=int(rl())\n t=sum(range(1,P+1))-sum(F)\n K=T-numtorn\n print('%.4f' % (t*K/float(T)))\n \n"] | {"inputs": [["2", "10", "2 1 2", "2", "10", "1 8", "0"]], "outputs": [["31.2000", "47.0000"]]} | interview | https://www.codechef.com/SEPT11/problems/TRMAG | |
1,186 | Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy:
There are N houses in Maahishmati, and the ith house has Ai gold plates. Each go... | ["import math\nn = int(input())\na = sorted(map(int,input().split()))\nl = [0]*n\nfor i in range(n):\n l[i] = a[i] + l[i-1]\nfor q in range(int(input())):\n print(l[int(math.ceil(float(n)/(int(input())+1)))-1])"] | {"inputs": [["4", "3 2 1 4", "2", "0", "2"]], "outputs": [["10", "3"]]} | interview | https://www.codechef.com/AMR15ROL/problems/AMR15D | |
1,187 | Chef wants to select a subset $S$ of the set $\{1, 2, \ldots, N\}$ such that there are no two integers $x, y \in S$ which satisfy $\frac{x}{y} = M$.
Help Chef find the maximum size of a subset $S$ he can choose and the number of ways in which he can choose a subset $S$ with this maximum size. Since the number of ways t... | ["for _ in range(int(input())):\n N,M = list(map(int,input().split()))\n count,e,perm = 0,0,1\n while(True):\n lim,start = N//(M**e),N//(M**(e + 1)) + 1\n num = lim - start + 1\n divs = num//M\n if((start + divs*M) <= lim):\n r = (start+divs*M)%M\n if(r == 0 or (r + (lim - (start + divs*M)) >= M)):\n divs +=... | {"inputs": [["3", "5 2", "10 2", "100 3"]], "outputs": [["4 1", "6 12", "76 49152"]]} | interview | https://www.codechef.com/problems/BANQUNT | |
1,188 | Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton.
Chef arrived in Frangton to find out that the mafia was involved in the case. Chef spent some time watching for people that belong to the clan and was able to build a map of relationships between them. He knows that a maf... | ["n = eval(input())\nr = list(map(int, input().split()))\n\ntree = dict()\ni = 1\nfor j in r:\n c = tree.get(j)\n if c:\n tree[j].append(i)\n else:\n tree[j] = [i]\n if not tree.get(i):\n tree[i] = []\n i += 1\ns = []\nfor elem in tree:\n if not tree[elem]:\n s.append(str(elem))\nprint(' '.join(s))", "T = eval(inpu... | {"inputs": [["6", "0 1 1 2 2 3"]], "outputs": [["4 5 6"]]} | interview | https://www.codechef.com/FEB16/problems/CHEFDETE | |
1,189 | You are given a sequence $A_1, A_2, \ldots, A_N$. For each $k$ ($1 \le k \le N$), let's define a function $f(k)$ in the following way:
- Consider a sequence $B_1, B_2, \ldots, B_N$, which is created by setting $A_k = 0$. Formally, $B_k = 0$ and $B_i = A_i$ for each valid $i \neq k$.
- $f(k)$ is the number of ways to sp... | ["from sys import stdin\ndef gt(num):\n if num:\n return num\n return 0\nfor __ in range(int(stdin.readline().split()[0])):\n n = int(stdin.readline().split()[0])\n a = list(map(int, stdin.readline().split()))\n cnta = dict()\n cnta.setdefault(0)\n cntb = dict()\n cntb.setdefault(0)\n for i in a:\n cnta[i] = gt(cnta.... | {"inputs": [["2", "6", "1 2 1 1 3 1", "3", "4 1 4"]], "outputs": [["6", "2"]]} | interview | https://www.codechef.com/problems/CFINASUM | |
1,190 | Tomya is a girl. She loves Chef Ciel very much.
Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p.
The current menus of Ciel's restaurant are shown the following table.
Name of Menupriceeel flavored water1deep-fried eel bones2clear soup made with ee... | ["t= int(input())\nwhile(t>0):\n n = int(input())\n m=0\n m=n//(2**11)\n n%=(2**11)\n while(n>0):\n num=n%2\n m+=num\n n//=2\n print(m)\n t-=1", "n=int(input())\nfor i in range(n):\n p=int(input())\n menu=0\n if p>2048:\n menu=(p//2048)-1\n p=p-(2048*menu... | {"inputs": [["4", "10", "256", "255", "4096"]], "outputs": [["2", "1", "8", "2"]]} | interview | https://www.codechef.com/problems/CIELRCPT | |
1,191 | Sandy is a professor at a very reputed institute. The institute mandates that all the lectures be communicated in English. As Sandy is not very good at English(or anything actually) the presentations he displays in class have a lot of spelling mistakes in them.
As you have a dictionary on you containing $N$ words in it... | ["# cook your dish here\nfrom difflib import get_close_matches \nimport sys, os\n\ndef closeMatches(patterns, word): \n return get_close_matches(word, patterns, 1, 0.9)[0]\n\ndef get_string(): \n return sys.stdin.readline().strip() \n\ndef get_ints(): \n return map(int, sys.stdin.readline().strip().split()) \nans = []\... | {"inputs": [["1", "5 2", "szhbdvrngk", "qzhxibnuec", "jfsalpwfkospl", "levjehdkjy", "wdfhzgatuh", "szhbdvcngk", "qzhxbnuec"]], "outputs": [["szhbdvrngk", "qzhxibnuec"]]} | interview | https://www.codechef.com/PROC2020/problems/ENGRIS | |
1,192 | You are given a sequence of integers $A_1, A_2, \ldots, A_N$. This sequence is circular ― for each valid $i$, the element $A_{i+1}$ follows after $A_i$, and the element $A_1$ follows after $A_N$.
You may insert any positive integers at any positions you choose in this sequence; let's denote the resulting sequence by $B... | ["from math import gcd\nfrom itertools import groupby\n\ndef gcd_split(seq):\n gcds= [int(gcd(a,b)==1) for a,b in zip(seq[1:],seq[:-1])]\n gcds.append(int(gcd(seq[0],seq[-1])==1))\n # print(gcds)\n if max(gcds)==0:\n return -1\n else:\n splits=[len(list(x))+1 for num,x in groupby(gcds) if num==0]\n # print(splits)\n... | {"inputs": [["1", "5", "3 6 4 5 9"]], "outputs": [["3 1 1 0"]]} | interview | https://www.codechef.com/problems/MININS | |
1,193 | There are $N$ robots who work for $Y$ days and on each day they
produce some toys .on some days a few robots are given rest.
So depending on the availability of robots owner has
made a time table which decides which robots will work on
the particular day.
Only contiguous robots must be selected as they can form
a li... | ["MAX = 100005\ntree = [0] * MAX; \nlazy = [0] * MAX;\n \ndef updateRangeUtil(si, ss, se, us, ue, diff) :\n if (lazy[si] != 0) :\n tree[si] += lazy[si];\n if (ss != se) :\n lazy[si * 2 + 1] += lazy[si];\n lazy[si * 2 + 2] += lazy[si];\n lazy[si] = 0;\n \n if (ss > se or ... | {"inputs": [["1", "5", "4", "0 3", "1 2", "4 4", "0 4"]], "outputs": [["4"]]} | interview | https://www.codechef.com/ENDE2020/problems/ENCDEC6 | |
1,194 | Toby has found a game to entertain himself.The game is like this:
You are in a coordinate system initially at (0,0) and you are given a sequence of steps which lead to your destination.The steps are given in the form of directions: ’U’ ,’D’ , ’L’ and ‘R’ for up, down, left and right respectively.If you are at position... | ["from collections import Counter\ntry:\n for _ in range(int(input())):\n n=int(input())\n s=input()\n d1=dict(Counter(s))\n \n u,d,r,l=0,0,0,0\n if 'U' in d1:\n u=d1['U']\n else:\n u=0\n if 'D' in d1:\n d=d1['D']\n else:\n d=0\n if 'R' in d1:\n r=d1['R']\n else:\n r=0\n if 'L' in d1:\n l=d1['... | {"inputs": [["3", "7", "ULUDLLU", "4", "RUUR", "4", "LRLR"]], "outputs": [["2", "0", "4"]]} | interview | https://www.codechef.com/CSEP2020/problems/TOBY | |
1,195 | Chefland has all the cities on a straight line. There are $N$ cities in Chefland numbered $1$ to $N$. City $i$ is located at coordinate $x_i$ on the x-axis. Guru wants to travel from city $A$ to city $B$. He starts at time t=0. He has following choices to travel.
- He can walk $1$ metre in $P$ secs.
- There is a train ... | ["t=int(input())\nfor _ in range(t):\n n,a,b,c,d,p,q,y=list(map(int,input().split()))\n l=list(map(int,input().split()))\n ans = abs((l[b-1]-l[a-1]))*p\n x=abs(l[c-1]-l[a-1])*p\n if x<=y:\n x=y+abs(l[d-1]-l[c-1])*q+abs(l[b-1]-l[d-1])*p\n ans=min(ans,x)\n print(ans)\n", "t = int(input())\nfor _ in range(t):\n n,a,b,c,... | {"inputs": [["1", "4 1 3 2 4 3 2 4", "1 2 3 4"]], "outputs": [["6"]]} | interview | https://www.codechef.com/problems/WALKFAST | |
1,196 | Every college has a stud−max$stud-max$ buoy. JGEC$JGEC$ has its own Atul$Atul$ who loves to impress everyone with his smile. A presentation is going on at the auditorium where there are N$N$ rows of M$M$ chairs with people sitting on it. Everyone votes for Atul's presentation skills, but Atul is interested in knowing t... | ["t = int(input())\r\nfor i in range(t):\r\n q = input().split()\r\n n = int(q[0])\r\n m = int(q[1])\r\n k = int(q[2])\r\n sumax = 0\r\n b = []\r\n for j in range(n):\r\n a = [int(k) for k in input().split()]\r\n b = b + [a]\r\n for j in range(n):\r\n su = 0\r\n for x... | {"inputs": [["1", "4 4 3", "1 4 5 7", "2 3 8 6", "1 4 8 9", "5 1 5 6"]], "outputs": [["22"]]} | interview | https://www.codechef.com/AARA2018/problems/ARMBH2 | |
1,197 | Chef loves saving money and he trusts none other bank than State Bank of Chefland. Unsurprisingly, the employees like giving a hard time to their customers. But instead of asking them to stand them in long queues, they have weird way of accepting money.
Chef did his homework and found that the bank only accepts the mon... | ["lst=[1, 2, 4, 8, 13, 21, 31, 45, 66, 81, 97, 123, 148, 182, 204, 252, 290, 361, 401, 475, 565, 593, 662, 775, 822, 916, 970, 1016, 1159, 1312, 1395, 1523, 1572, 1821, 1896, 2029, 2254, 2379, 2510, 2780, 2925, 3155, 3354, 3591, 3797, 3998, 4297, 4433, 4779, 4851, 5123, 5243, 5298, 5751, 5998, 6374, 6801, 6925, 7460, 7... | {"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["1", "1", "1 2", "3", "1 2 4", "7", "1 2 4 8", "15"]]} | interview | https://www.codechef.com/PROC2020/problems/CHFBANK | |
1,198 | Chef recently took a course in linear algebra and learned about linear combinations of vectors. Therefore, in order to test his intelligence, Raj gave him a "fuzzy" problem to solve.
A sequence of integers $B_1, B_2, \ldots, B_M$ generates an integer $K$ if it is possible to find a sequence of integers $C_1, C_2, \ldot... | ["import math\nimport bisect\nfrom functools import reduce\nfrom collections import defaultdict\n# import sys\n# input = sys.stdin.readline\n\ndef inn():\n return int(input())\n\ndef inl():\n return list(map(int, input().split()))\n\nMOD = 10**9+7\nINF = inf = 10**18+5\n\nn = inn()\na = inl()\nk = []\nfor q in range(in... | {"inputs": [["2", "2 4", "3", "1", "2", "8"]], "outputs": [["0", "2", "3"]]} | interview | https://www.codechef.com/problems/FUZZYLIN | |
1,199 | In a country called Chef Land, there was a lot of monetary fraud, so Chefu, the head of the country, decided to choose new denominations of the local currency ― all even-valued coins up to an integer $N$ should exist. After a few days, a citizen complained that there was no way to create an odd value, so Chefu decided ... | ["for i in range(int(input())):\n n,k=list(map(int,input().split()))\n t=0\n if n%2!=0:\n n-=1\n t+=1\n t+=(n//k)\n if n%k!=0:\n t+=1\n print(t)\n", "for i in range(int(input())):\n n,k=map(int,input().split())\n t=0\n if n%2!=0:\n n-=1\n t+=1\n t+=(n//k)\n if n%k!=0:\n t+=1\n print(t)", "for i in range(int(input... | {"inputs": [["4", "2 2", "1 14", "30 10", "31 4"]], "outputs": [["1", "1", "3", "9"]]} | interview | https://www.codechef.com/problems/CHFMOT18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.