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
2971d4418a3bd972f90c6e7f61f9f119
UNKNOWN
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
PYTHON3
CODECHEF
3,649
523a5df0d563b26990dcaeae8ee9cc10
UNKNOWN
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
PYTHON3
CODECHEF
7,239
414f132bae5c659daa61df88a07d6748
UNKNOWN
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
PYTHON3
CODECHEF
1,775
635b89afdc9f37bc04dcb92e2b0b1d69
UNKNOWN
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
PYTHON3
CODECHEF
5,674
868c7b8b1b20814556b0a45853ec65c7
UNKNOWN
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
PYTHON3
CODECHEF
10,154
f051ee56c69ff8af19beb497b1b42a26
UNKNOWN
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
PYTHON3
CODECHEF
664
8896e347eabddc0cf3a52bddc204c778
UNKNOWN
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
PYTHON3
CODECHEF
3,767
48c8b22fae183f71a4b386cadb7fc9bf
UNKNOWN
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
PYTHON3
CODECHEF
13,375
0e994f2593e15c12809d93fc83fcbfe6
UNKNOWN
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
PYTHON3
CODECHEF
2,838
34d4a70d3f5579ab3fac320eb63afa20
UNKNOWN
"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
PYTHON3
CODECHEF
607
43c5fda863220fcf055af304776f0a21
UNKNOWN
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
PYTHON3
CODECHEF
7,481
0cf780631c760a4ef30d773d8aa5c63f
UNKNOWN
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
PYTHON3
CODECHEF
3,661
0236b62136fbdfa8f583428630327365
UNKNOWN
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
PYTHON3
CODECHEF
1,599
246de1f03f6c35a4e401a52041178d83
UNKNOWN
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
PYTHON3
CODECHEF
8,070
ce9f1a49313a67279f730a58a52471a6
UNKNOWN
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
PYTHON3
CODECHEF
7,987
f36291f94f850e7c8c3b500dc469a833
UNKNOWN
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
PYTHON3
CODECHEF
2,409
43a899ff98d995b1c7e019ef0a4303d5
UNKNOWN
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
PYTHON3
CODECHEF
8,800
9652fa322ec74875dbbf9dfdc5bd195c
UNKNOWN
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
PYTHON3
CODECHEF
5,034
5b8aeacf620249aa08562d7fb5b1c952
UNKNOWN
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
PYTHON3
CODECHEF
5,935
8043df6d45cefe09916a3ba0edec6b0c
UNKNOWN
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
PYTHON3
CODECHEF
4,610
3e1fb43b3e68a343dcb9ce3dd9b3cd5c
UNKNOWN
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
PYTHON3
CODECHEF
10,277
deff157791fadc66bdc1e84fc6a6cffb
UNKNOWN
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
PYTHON3
CODECHEF
3,494
22b403390431a89627065c0425605d72
UNKNOWN
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
PYTHON3
CODECHEF
1,480
800c1162a36823f4c2023125390bccd0
UNKNOWN
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
PYTHON3
CODECHEF
7,666
e115ad9d358d407ecfad8192173daffc
UNKNOWN
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
PYTHON3
CODECHEF
846
6a9ea01476387ccca38b0d8f1dcf1fce
UNKNOWN
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
PYTHON3
CODECHEF
5,667
d9eb1fb23a9e6fa2965715526ca271fc
UNKNOWN
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
PYTHON3
CODECHEF
895
a930f5957808a43b95963553a4903af7
UNKNOWN
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
PYTHON3
CODECHEF
5,018
0916e2688f99bf2fc3ba2ffef2aef3ef
UNKNOWN
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
PYTHON3
CODECHEF
3,082
988a8eb06b0686bd62d38460c0ca33c5
UNKNOWN
[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
PYTHON3
CODECHEF
5,362
3162927441b57ae7f89c4b70fb6fd132
UNKNOWN
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
PYTHON3
CODECHEF
6,503
8d518eaf555834aed11c8fea9eb33aae
UNKNOWN
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
PYTHON3
CODECHEF
2,743
5d3ab7bce880a857aab89196a3e99d59
UNKNOWN
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
PYTHON3
CODECHEF
8,047
d8761565796462f3ab2aa8b90facc39b
UNKNOWN
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
PYTHON3
CODECHEF
4,078
dc6d2b9744f4d0c1566eb1671bee1ca9
UNKNOWN
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
PYTHON3
CODECHEF
27,829
86c9baf6b654c0299f0540ecda6bf3de
UNKNOWN
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
PYTHON3
CODECHEF
4,562
7dd327373d9502a5af170c429fad76ce
UNKNOWN
-----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
PYTHON3
CODECHEF
752
ce9552494765da58b62581d7d580ad21
UNKNOWN
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
PYTHON3
CODECHEF
6,640
12cb39df8e020bf4431914002c3950c8
UNKNOWN
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
PYTHON3
CODECHEF
18
b5201f88574b251a0f9732ff560f5460
UNKNOWN
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
PYTHON3
CODECHEF
4,350
f06ccf611d9586505cf952ad9e3970b3
UNKNOWN
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
PYTHON3
CODECHEF
3,776
6311bf1acabbe9cc2f4bf309a9928106
UNKNOWN
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
PYTHON3
CODECHEF
3,009
60036a867deab833dd051d0925b5244f
UNKNOWN
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
PYTHON3
CODECHEF
1,932
b97eb73494fbf994f31071cd79e6f117
UNKNOWN
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
PYTHON3
CODECHEF
20,920
3fc1d995a4ff4eebccba62ed00442277
UNKNOWN
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
PYTHON3
CODECHEF
10,017
7fc584f45207e89f72834b567671f136
UNKNOWN
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
PYTHON3
CODECHEF
8,735
ef1c9bc30eacc5005b5e54f4f95372f0
UNKNOWN
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
PYTHON3
CODECHEF
2,440
da070c6623ca093b22e2689cbbe84010
UNKNOWN
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
PYTHON3
CODECHEF
13,185
3d39024a9b54b5b5a6ca736d2baa90f4
UNKNOWN
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
PYTHON3
CODECHEF
5,033
f05993bae9a572b393c772c9b8761c0c
UNKNOWN
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
PYTHON3
CODECHEF
9,060
5ed7c59a09adbcfdf9f1419eb8bcc3d2
UNKNOWN
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
PYTHON3
CODECHEF
217
9eab40ad16df2884faa627299d0fd8da
UNKNOWN
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
PYTHON3
CODECHEF
5,831
7baca2c6c15a96ab8d4d01b3010c16d4
UNKNOWN
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
PYTHON3
CODECHEF
5,638
1072e1072adf1e352ea5e3266e50338c
UNKNOWN
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
PYTHON3
CODECHEF
5,502
9bba2762708f94fd7af2ee33765ddfae
UNKNOWN
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
PYTHON3
CODECHEF
1,121
6a0bb938486b96b86364c77d547ef1a6
UNKNOWN
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
PYTHON3
CODECHEF
1,470
b617708551b633982599bc8d64490ff0
UNKNOWN
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
PYTHON3
CODECHEF
11,407
13f2002fc6e3b5e700a01ff76fac8f37
UNKNOWN
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
PYTHON3
CODECHEF
1,970
1d1fd96ad78daa1698bf2ed8b5b2c605
UNKNOWN
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
PYTHON3
CODECHEF
514
70223e034e9c43e1e359de45e14c9cf0
UNKNOWN
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
PYTHON3
CODECHEF
5,561
a1cb4402c3797a6fa8d82aec26360785
UNKNOWN
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
PYTHON3
CODECHEF
3,149
b4d8ca636ebc9ea74d56d4a987530742
UNKNOWN
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
PYTHON3
CODECHEF
5,268
493f3681184c2c3aa49d6d172b505d1b
UNKNOWN
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
PYTHON3
CODECHEF
11,654
f90d23657f73bd8c0047fd9f515600a8
UNKNOWN
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
PYTHON3
CODECHEF
11,838
3f528ba3bdf07f9122bc669faf69e2ad
UNKNOWN
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
PYTHON3
CODECHEF
5,706
432e411d7273e8599c2593c3e9a1ad74
UNKNOWN
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
PYTHON3
CODECHEF
11,398
03822a16aec8f9787730cb00a04507dc
UNKNOWN
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
PYTHON3
CODECHEF
1,980
99e95ef1dd25d651bd2024e81cf23e91
UNKNOWN
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
PYTHON3
CODECHEF
17,551
478ab5f36989888529fafee4f4b4dcc5
UNKNOWN
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
PYTHON3
CODECHEF
236
7d51cfdf1184aaccc8798205a0111f50
UNKNOWN
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
PYTHON3
CODECHEF
212
4ed82f62fdcae968952b91e70ba75d3e
UNKNOWN
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
PYTHON3
CODECHEF
4,110
c2bf397cbfaa2ce2aa71f7f0eff470f8
UNKNOWN
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
PYTHON3
CODECHEF
3,282
9cb8b6e85b6da1f9c258a2a11bd6e154
UNKNOWN
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
PYTHON3
CODECHEF
4,599
4573b6a5c08f0b7723eb6b7687ba6df6
UNKNOWN
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
PYTHON3
CODECHEF
6,579
74c8087fa5af1ad64b5df658f109358f
UNKNOWN
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
PYTHON3
CODECHEF
11,070
8ad5b49111cc7bd5932cd2c75ffb823d
UNKNOWN
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
PYTHON3
CODECHEF
7,859
331c02b6e6e77d22b59d199a0f78ced2
UNKNOWN
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
PYTHON3
CODECHEF
2,289
89a12bdba24bd02c670b303e133aeb65
UNKNOWN
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
PYTHON3
CODECHEF
4,888
637f0ca2467c71c4e3776c354d153db4
UNKNOWN
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
PYTHON3
CODECHEF
7,898
880edba101234362e13747168c31502e
UNKNOWN
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
PYTHON3
CODECHEF
9,374
30541b7e5e71338b71a3c293f0cb2479
UNKNOWN
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
PYTHON3
CODECHEF
72,191
0bbc443915da4523c3ca5e1594d4ba2d
UNKNOWN
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
PYTHON3
CODECHEF
11,019
fd19875204445564d285f1368204b550
UNKNOWN
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
PYTHON3
CODECHEF
6,489
2bf25ccda98956b5f6ce9cc426af978f
UNKNOWN
Two sisters, A and B, play the piano every day. During the day, they can play in any order. That is, A might play first and then B, or it could be B first and then A. But each one of them plays the piano exactly once per day. They maintain a common log, in which they write their name whenever they play. You are given t...
["def checkValidity(s):\n count = 0\n previous = \"\"\n\n for x in s:\n if count == 0:\n previous = x\n count += 1\n elif count == 1:\n count = 0\n if previous == x:\n return \"no\"\n\n return \"yes\"\n\nt = int(input())\n\nfor _ in range(t):\n s = input()\n print(checkValidity(s))\n", "n=int(input())\nl=[...
{"inputs": [["4", "AB", "ABBA", "ABAABB", "AA"]], "outputs": [["yes", "yes", "no", "no"]]}
INTERVIEW
PYTHON3
CODECHEF
6,473
9895cc2f6a6de78f06c50c0a38b79bdb
UNKNOWN
Kim has broken in to the base, but after walking in circles, perplexed by the unintelligible base design of the JSA, he has found himself in a large, empty, and pure white, room. The room is a grid with H∗W$H*W$ cells, divided into H$H$ rows and W$W$ columns. The cell (i,j)$(i,j)$ is at height A[i][j]$A[i][j]$. Unfort...
["# cook your dish here\ndef solve(l,r,c,row,col,po):\n count=0\n visited=set()\n stack=set()\n stack.add((l[row][col],row,col))\n while stack:\n ele=stack.pop()\n visited.add((ele[1],ele[2]))\n if ele[0]<po:\n count+=1 \n if ele[1]-1>=0 and (ele[1]-1,ele[2]) no...
{"inputs": [["1", "5 5 3", "4 3 9 7 2", "8 6 5 2 8", "1 7 3 4 3", "2 2 4 5 6", "9 9 9 9 9", "3 4 6", "3 2 5", "1 4 9"]], "outputs": [["10", "0", "19"]]}
INTERVIEW
PYTHON3
CODECHEF
8,204
29a3759b4ce52ff41637497dd46a43ce
UNKNOWN
Mark loves eating chocolates and also likes to be fit. Given the calorie count for every chocolate he eats, find what he has to do to burn the calories. The name of the chocolates along with its calorie count are given as follows: Calories per one whole bar: Dairy milk (D) 238 Twix (T) 244 Milky Bar (M) 138 Bounty (B)...
["# cook your dish here\n\nd = { 'D': 238, 'T': 244, 'M': 138, 'B': 279, 'C': 186 }\n\ns = list(input())\ntotalCal = 0\n\nfor i in range(len(s)):\n if s[i] == 'D':\n totalCal += d['D']\n if s[i] == 'T':\n totalCal += d['T']\n if s[i] == 'M':\n totalCal += d['M']\n if s[i] == 'B':\n ...
{"inputs": [["DDTM"]], "outputs": [["17", "1", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
616
9e8db7e451c3e3ce8706a2a6c2f020fb
UNKNOWN
Given a set of N natural numbers 1,2,3........N and Q query.For each query you have to calculate the total number of subset in which Ith. number of set come at Kth postion.Elements of every subset should be in sorted order. The answer could be very large so you have to print answer modulo 1e9+7. -----Input:----- ...
["import math\nf = math.factorial\nfor u in range(eval(input())):\n n, q = list(map(int, input().split()))\n for j in range(q):\n i,k = list(map(int, input().split()))\n if k>i:\n c=0\n print(c)\n else:\n a=2**(n-i)\n b=1\n d=int(i-1)\n e=1\n h=1\n g=1\n #b=f(i-1)/f(k-1)/f(i-k)\n if(k-1>i-k):\n ...
{"inputs": [["1", "3 3", "1 2", "2 1", "3 2"]], "outputs": [["0", "2", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
9,795
fb2971da5a7ff7b4e9261cd86f4aa71d
UNKNOWN
You are given two strings $S$ and $R$. Each of these strings has length $N$. We want to make $S$ equal to $R$ by performing the following operation some number of times (possibly zero): - Choose two integers $a$ and $b$ such that $1 \le a \le b \le N$. - For each $i$ such that $a \le i \le b$, replace the $i$-th charac...
["for t in range(int(input())):\n s = input()\n r = input()\n diff = list()\n index = list()\n cnt = 0\n for i in range(len(s)):\n if s[i] != r[i]:\n cnt += 1\n index.append(i)\n for i in range(1, len(index)):\n diff.append(index[i] - index[i - 1] - 1)\n diff.sort()\n fmin = cnt ** 2\n oper = cnt ; moves = cnt\n ...
{"inputs": [["1", "adefb", "bdefa"]], "outputs": [["4"]]}
INTERVIEW
PYTHON3
CODECHEF
13,803
0d8b04067db9e8c75dc3125dc3bfa4eb
UNKNOWN
Do you know Professor Saeed? He is the algorithms professor at Damascus University. Yesterday, he gave his students hard homework (he is known for being so evil) - for a given binary string $S$, they should compute the sum of $F(S, L, R)$ over all pairs of integers $(L, R)$ ($1 \le L \le R \le |S|$), where the function...
["for _ in range(int(input())):\n s=input()\n n=len(s)\n t=0\n ans=0\n for i in range(n-1):\n if(s[i]==s[i+1]):\n t=t+1\n x=t\n for i in range(n):\n t=x\n if(i!=0):\n if(s[i]==s[i-1]):\n t=t-1\n else:\n t=t+1\n y=t\n for j in range(i,n):\n t=y\n try:\n if(s[j]==s[j+1]):\n t=t-1\n else...
{"inputs": [["1", "001"]], "outputs": [["6"]]}
INTERVIEW
PYTHON3
CODECHEF
6,451
7a7869d37f47790ca7f3d3d99171e164
UNKNOWN
As you might remember, the collector of Siruseri had ordered a complete revision of the Voters List. He knew that constructing the list of voters is a difficult task, prone to errors. Some voters may have been away on vacation, others may have moved during the enrollment and so on. To be as accurate as possible, he en...
["from sys import stdout, stdin\nn,m,o = list(map(int, stdin.readline().split()))\nn= n+m+o\nl=[]\na=[]\nfor i in range(n):\n b= int(stdin.readline())\n if(b in l and b not in a):\n l.append(b)\n a.append(b)\n elif(b not in l):\n l.append(b)\n\n\na.sort()\nstdout.write(str(len(a)) + '\\n')...
{"inputs": [["5 6 5", "23", "30", "42", "57", "90", "21", "23", "35", "57", "90", "92", "21", "23", "30", "57", "90", "Sample output:", "5", "21", "23", "30", "57", "90"]], "outputs": [[]]}
INTERVIEW
PYTHON3
CODECHEF
1,152
0754ef789de6e07365af53a72c299bcc
UNKNOWN
Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build some bi-directional roads connecting different cities such that each city is c...
["t=int(input())\nfor _ in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n a.sort()\n s=sum(a)\n if a[0]*(s-a[0])<=a[n-1]*(s-a[n-1]):\n print(a[0]*(s-a[0]))\n else:\n print(a[n-1]*(s-a[n-1]))", "def solve(A,n):\n \n \n \n A.sort()\n res = 0\n for i in range(1,n):\n \n res = res + A[i]*A[0]\n \n ret...
{"inputs": [["2", "2", "5 10", "4", "15 10 7 13"]], "outputs": [["50", "266"]]}
INTERVIEW
PYTHON3
CODECHEF
4,480
f9ebf755e3a4b28f3c74738a7766d019
UNKNOWN
Chef is solving mathematics problems. He is preparing for Engineering Entrance exam. He's stuck in a problem. $f(n)=1^n*2^{n-1}*3^{n-2} * \ldots * n^{1} $ Help Chef to find the value of $f(n)$.Since this number could be very large, compute it modulo $1000000007$. -----Input:----- - First line will contain $T$, number...
["T=int(input())\nt=[]\nfor _ in range(T):\n N=int(input())\n t.append(N)\nN=max(t)+1\nl=[0 for i in range(N)]\np=1\na=1\nfor i in range(1,N):\n a=(a*i)%1000000007\n p=p*a%1000000007\n l[i]=p\nfor i in t:\n print(l[i])\n", "import sys;\ninput = sys.stdin.readline\ninp,ip = lambda :int(input()),lambda :[int(w) for w in ...
{"inputs": [["1", "3"]], "outputs": [["12"]]}
INTERVIEW
PYTHON3
CODECHEF
7,469
b2940bce85b4137d69c93c6eaf04b568
UNKNOWN
It's winter and taking a bath is a delicate matter. Chef has two buckets of water. The first bucket has $v_1$ volume of cold water at temperature $t_1$. The second has $v_2$ volume of hot water at temperature $t_2$. Chef wants to take a bath with at least $v_3$ volume of water which is at exactly $t_3$ temperature. To ...
["# cook your dish here\ntry:\n for i in range(int(input())):\n v1,t1,v2,t2,v3,t3=map(int,input().split())\n ok = 0\n if t1 <= t3 <= t2:\n x, y = t2 - t3, t3 - t1\n ok = x * v3 <= (x + y) * v1 and y * v3 <= (x + y) * v2\n print('YES' if ok else 'NO')\n \nexcept:\n pass", "# cook your dish here\ntry:\n for i ...
{"inputs": [["3", "5 10 5 20 8 15", "5 10 5 20 1 30", "5 10 5 20 5 20"]], "outputs": [["YES", "NO", "YES"]]}
INTERVIEW
PYTHON3
CODECHEF
7,418
3d3a95e95187ba3dd1da51bb91b833cf
UNKNOWN
-----Problem Statement----- One of the things JEC is known for is its GR (Group Recreation) where juniors and seniors do friendly interaction ;P As for the new session of 2020 seniors decided to have their first GR and give them some treat. Juniors were excited about it they came to college canteen aligned in a line an...
["t=int(input())\nwhile t:\n t=t-1\n n,x=input().split()\n n=int(n)\n x=int(x)\n d,l=input().split()\n\n if d=='L':\n p=x\n elif d=='R':\n p=(n-x)+1\n\n if p%2==1:\n if l=='H':\n lang='H'\n else:\n lang='E'\n elif p%2==0:\n if l=='H':\n lang='E'\n else:\n lang='H'\n print(p,lang)", "for zz in range(int(in...
{"inputs": [["2", "15 5", "L H", "20 14", "R E", "*try to trim extra white spaces like new line during input in case of wrong answer"]], "outputs": [["5 H", "7 E"]]}
INTERVIEW
PYTHON3
CODECHEF
10,408
8b12d26acc7afece457f704fc764649b
UNKNOWN
The chef is having one string of English lower case alphabets only. The chef wants to remove all "abc" special pairs where a,b,c are occurring consecutively. After removing the pair, create a new string and again remove "abc" special pair from a newly formed string. Repeate the process until no such pair remains in a s...
["# cook your dish here\nfor _ in range(int(input())):\n s=input()\n while(s.count(\"abc\")!=0):\n s=s.replace(\"abc\",\"\")\n print(s) \n", "# cook your dish here\nfor i in range(int(input())):\n txt=input()\n \n while(True):\n l=len(txt)\n x = txt.replace(\"abc\",\"\")\n ...
{"inputs": [["2", "aabcc", "bababccc"]], "outputs": [["ac", "bc"]]}
INTERVIEW
PYTHON3
CODECHEF
6,004
7bb819e85af82186696b7f1cef1e7186
UNKNOWN
"Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Let's call a string balanced if all characters that occur in this string occur in it the same number of times. You are given a string $S$; this string may only contain u...
["from sys import stdin\nfrom collections import Counter\n\ndef func(arr,n,l):\n count=0\n k=l//n\n if n<len(arr):\n for ele in arr[0:n]:\n count+=max(0,k-ele)\n else:\n for ele in arr:\n count+=max(0,ele-k)\n return count \n\nfor _ in range(int(stdin.readline())):\n s=stdin.readline().strip()\n d=Counter(s)\n ar...
{"inputs": [["2", "ABCB", "BBC"]], "outputs": [["1", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
10,575
9c1d52655347c74c58c510d4b166661e
UNKNOWN
Chef and his competitor Kefa own two restaurants located at a straight road. The position of Chef's restaurant is $X_1$, the position of Kefa's restaurant is $X_2$. Chef and Kefa found out at the same time that a bottle with a secret recipe is located on the road between their restaurants. The position of the bottle is...
["# cook your dish here\nfor t in range(int(input())):\n x1,x2,x3,v1,v2=[int(x)for x in input().rstrip().split()]\n t1=abs(x3-x1)/v1\n t2=abs(x3-x2)/v2\n if t1<t2:\n print(\"Chef\")\n elif t1>t2:\n print(\"Kefa\")\n elif t1==t2:\n print(\"Draw\")\n else:\n pass\n", "for i in range(int(input())):\n x1,x2,x3,v1,v2=[i...
{"inputs": [["3", "1 3 2 1 2", "1 5 2 1 2", "1 5 3 2 2"]], "outputs": [["Kefa", "Chef", "Draw"]]}
INTERVIEW
PYTHON3
CODECHEF
6,399
df345e0c50d36360244cad81c95e4f7d
UNKNOWN
Everybody is worried about Rakesh as the boy does not have much knowledge about the real world. He can not go from one place to another on his own. It's high time he learned to explore the city. He is going to a relative's house situated on the other side of the city on his own. As this is his first time, he is carryin...
["try:\n t=int(input())\n for i in range(t):\n print(\"Case {}:\".format(i+1), end=\" \")\n m, n = map(int,input().split())\n x, y = map(int,input().split())\n l = int(input())\n a=input()\n destx = a.count(\"R\")-a.count(\"L\")\n desty = a.count(\"U\")-a.count(\"D\")\n #print(destx, desty)\n \n if (destx<0 or...
{"inputs": [["2", "20 20", "4 5", "13", "LLUUUUURRRRRR", "10 10", "3 4", "7", "UDUDDRR"]], "outputs": [["Case 1: REACHED", "Case 2: DANGER"]]}
INTERVIEW
PYTHON3
CODECHEF
12,935
88edbe1d0be52e1c06006f0309588f8e
UNKNOWN
Two friends David and Rojer were preparing for their weekly class-test. The are preparing for the math test, but because of continuously adding big integers and solving equations they got exhausted. They decided to take break and play a game. They play a game which will help them in both(for having fun and will also he...
["def isSolvable( W, R):\r\n LW, LR, F, ML, AW, V, LMap = len(W), len(R), set([w[0] for w in W+[R]]), max(map(len, W+[R])), W+[R], set(), {}\r\n if LR < ML: return False\r\n def dfs(d,i,c):\r\n if d == ML: return c == 0\r\n if i == len(W) + 1:\r\n s = sum(LMap[w...
{"inputs": [["3", "THIS", "IS", "TOO", "FUNNY"]], "outputs": [["true"]]}
INTERVIEW
PYTHON3
CODECHEF
4,470
02de49235347d4b2b0eeb07595e03b8c
UNKNOWN
Today Chef wants to evaluate the dishes of his $N$ students. He asks each one to cook a dish and present it to him. Chef loves his secret ingredient, and only likes dishes with at least $X$ grams of it. Given $N$, $X$ and the amount of secret ingredient used by each student $A_i$, find out whether Chef will like at lea...
["t=int(input())\nfor i in range(t):\n n,k=map(int,input().split())\n m=list(map(int,input().split()))\n a=0\n for i in m:\n if i>=k:\n a=1\n break\n if a==1:\n print('YES')\n else:\n print('NO')", "for i in range(int(input())):\n n,m=map(int,input().split())\n k=list(map(int,input().split()))\n c=0\n for i in k...
{"inputs": [["3", "5 100", "11 22 33 44 55", "5 50", "10 20 30 40 50", "5 45", "12 24 36 48 60"]], "outputs": [["NO", "YES", "YES"]]}
INTERVIEW
PYTHON3
CODECHEF
5,766