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
e838332c05fa3e3275689d1373bb240b
UNKNOWN
Raj loves to listen to songs in his free time. It’s his birthday tomorrow and his friend Neelansh wants his gift to be the most unique. Being great at making music, he decides to produce a song for him. However, Raj likes songs according to their beauty. He determines the beauty of the song as the number of times all t...
["for _ in range(int(input())):\r\n n = int(input())\r\n ar = list(map(int,input().split()))\r\n d = {}\r\n for ele in ar:\r\n if ele in d:\r\n d[ele] += 1\r\n else:\r\n d[ele] = 1\r\n m = 99999\r\n count = 0\r\n for ele in d:\r\n count+=1\r\n if m>...
{"inputs": [["2", "8", "1 2 3 4 5 6 7 8", "16", "1 2 1 2 3 3 4 4 5 5 6 6 7 8 7 8"]], "outputs": [["1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
7,645
d573f7fb6c7f7808a30110c5d361f48e
UNKNOWN
You are given a sequence $A_1, A_2, \ldots, A_N$. You may perform the following operation an arbitrary number of times (including zero): choose two adjacent elements of this sequence, i.e. $A_i$, $A_{i+1}$ for some valid $i$, and swap them. However, for each valid $i$, it is not allowed to choose $A_i$ (the element wit...
["# cook your dish here\n# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n l=list(map(int, input().split()))\n l.insert(0, 0)\n l1=[0]*(n+1)\n l1[1]=l[1]\n for i in range(2, n+1):\n l1[i]=max(l1[i-1]+l[i]*i, l1[i-2]+l[i-1]*i+l[i]*(i-1))\n \n print(l1[-1]) ", "# cook your dish here\nfor _ in rang...
{"inputs": [["2", "4", "2 1 4 3", "4", "7 6 3 2"]], "outputs": [["30", "39"]]}
INTERVIEW
PYTHON3
CODECHEF
4,355
d1eb85c4a8b35acf7d294b6206c9a059
UNKNOWN
Mr. Wilson was planning to record his new Progressive Rock music album called "Digits. Cannot. Separate". Xenny and PowerShell, popular pseudo-number-theoreticists from the Land of Lazarus were called by him to devise a strategy to ensure the success of this new album. Xenny and Powershell took their Piano Lessons and ...
["\n\n\nt = int(input())\n\ndef gcd (a, b):\n if (b == 0): return a\n return gcd (b, a % b)\n\ndp = {}\n\ndef solve (p, k, g, s, m, x, y, n):\n if ((p, k, g) in dp): return dp[(p, k, g)];\n \n ans = 0\n\n if (p == n): \n if k >= x and k <= y:\n ans = g\n else:\n ans = 0 \n else: \n for i in range (p, n):\n \...
{"inputs": [["2", "3", "474", "2 1 1", "34", "6311861109697810998905373107116111", "10 4 25"]], "outputs": [["2", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
689
45ac45554cf2cebbb861018faad35fa2
UNKNOWN
In an array, a $block$ is a maximal sequence of identical elements. Since blocks are maximal, adjacent blocks have distinct elements, so the array breaks up into a series of blocks. For example, given the array $[3, 3, 2, 2, 2, 1, 5, 8, 4, 4]$, there are 6 blocks: $[3, 3], [2, 2, 2], [1], [5], [8], [4, 4]$ . In this ...
["# cook your dish here\n# cook your dish here\nn=0;m=0;\nA=[];B=[];\nanscount=0;k=0;\n\ndef generate(n,m,l):\n nonlocal anscount\n if(len(l)==n+m):\n X=l\n i,j = 0,0\n C=[0 for t in range(n+m)]\n while((i+j)<(n+m)):\n if(X[i+j] == 0):\n C[i+j] = A[i]\n i = i+1\n else:\n C[i+j] = B[j]\n j = j+1\n a...
{"inputs": [["5", "2 2 4", "1 3", "3 4", "2 2 3", "1 3", "3 4", "2 2 2", "1 3", "3 4", "2 2 4", "4 7", "8 5", "2 2 2", "4 7", "8 5"]], "outputs": [["4", "2", "0", "6", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
17,948
8b10d41ea57a99fb4a853d0ca1f7e41e
UNKNOWN
Patlu has recently got a new problem based on Pallindromes. A Pallindrome is a number that is same from front and back, example $121$ is pallindrome but $123$ is not . He wants to calculate sum of all $N$ digit number which are Pallindromic in nature and divisible by $9$ and does not contain any zero in their decimal r...
["def getsum(N):\n\tif N==1:\n\t\treturn 9\n\tif N==2:\n\t\treturn 99\n\ts = \"\"\n\tfor i in range(0,N):\n\t\ts = s+'5'\n\ts = int(s)\n\tif N%2==0:\n\t\ts = s*pow(9,N//2-1)\n\telse:\n\t\ts = s*pow(9,N//2)\n\treturn s%(pow(10,9)+7)\n\ndef main():\n\tt = int(input())\n\tfor _ in range(0,t):\n\t\tN = int(input())\n\t\tre...
{"inputs": [["2", "1", "2"]], "outputs": [["9", "99"]]}
INTERVIEW
PYTHON3
CODECHEF
414
2cee3653b5cdefc2ebc3e51de9d13536
UNKNOWN
The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings with indices i-1 and i+1. The first and the last buildings have j...
["import sys\nT = int(sys.stdin.readline().strip())\nfor t in range(T):\n sys.stdin.readline().strip()\n st = '0'+sys.stdin.readline().strip()+'0'\n res = 0\n for i in range(1,len(st)-1):\n if st[i] == st[i-1] == st[i+1] == '0':\n res+=1\n print(res)\n", "t = int( input() )\n\nwhile t > 0:\n n = int( input() )\n s =...
{"inputs": [["3", "3", "010", "5", "10001", "7", "0000000"]], "outputs": [["0", "1", "7"]]}
INTERVIEW
PYTHON3
CODECHEF
6,012
79d57eaef6c96c6996a4c3255a89a6cd
UNKNOWN
Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants! Vlad built up his own playlist. The playlist consists of N songs, each has a unique positi...
["# cook your dish here\nt=int(input())\nfor i in range(t):\n n=int(input())\n nums=list(map(int,input().split()))\n k=int(input())\n an=nums[k-1]\n cn=0\n for i in range(n):\n if(nums[i]<an):\n cn+=1\n\n print(cn+1)\n", "# cook your dish here\nT = int(input())\nfor i in range(1,T...
{"inputs": [["3", "4", "1 3 4 2", "2", "5", "1 2 3 9 4", "5", "5", "1 2 3 9 4 ", "1", "", ""]], "outputs": [["3", "4", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
3,891
e1617e0c638a757211d712cabda2c935
UNKNOWN
Little Praneet loves experimenting with algorithms and has devised a new algorithm. The algorithm is performed on an integer as follows: - if the rearmost digit is $0$, he will erase it. - else, he will replace the rearmost digit $d$ with $d-1$. If a point comes when the integer becomes $0$, the algorithm stops. You ar...
["# cook your dish here\nn,a=map(int,input().split())\nfor i in range(a):\n if(n%10==0):\n n=n//10\n else:\n n=n-1\n \nprint(n)", "# cook your dish here\na,b=map(int,input().split())\nfor i in range(b):\n r=a%10\n n=a//10\n if(r==0):\n a=n\n else:\n a=a-1\nprint(a)", "#q1\nn,x=list(map(int,input().split()))\nfor i...
{"inputs": [["1001 2", "Sample Input 2", "5 2"]], "outputs": [["100", "Sample Output 2", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
3,998
9e12d24deb5e26ac7c994ad3e9752f5a
UNKNOWN
Chef has just learned a new data structure - Fenwick tree. This data structure holds information about array of N elements and can process two types of operations: - Add some value to ith element of the array - Calculate sum of all elements on any prefix of the array Both operations take O(log N) time. This data stru...
["t=int(input())\ncount=[]\n\nfor i in range(t) :\n s = input()\n a,b,c,n = s.split()\n n=int(n)\n d = int(a+b*n+c,2)\n count.append(0)\n while(d>0) :\n d=(d&(d+1))-1\n count[i]+=1\n\n\nfor i in range(t) :\n print(count[i])\n"]
{"inputs": [["4", "001 100 011 4", "1000 1101 100 3", "1010 001 101 4", "010 101 000 4"]], "outputs": [["6", "12", "8", "10"]]}
INTERVIEW
PYTHON3
CODECHEF
229
439b44535007d1ac0c7d7ee7f39af1e4
UNKNOWN
Chef is operating a slush machine. The machine produces slush drinks with $M$ flavors (numbered $1$ through $M$); for each valid $i$, the maximum number of drinks with flavour $i$ the machine can produce is $C_i$. Chef expects $N$ customers to come buy slush drinks today. The customers are numbered $1$ through $N$ in t...
["t=int(input())\nfor i in range(t):\n n,m=list(map(int,input().split()))\n l=[0]+list(map(int,input().split()))\n s=0\n c=1\n m1=[]\n for i in range(n):\n d,f,b=list(map(int,input().split()))\n if(l[d]>0):\n m1.append(d)\n s+=f\n l[d]-=1\n else:\n m1.append(0)\n s+=b\n for i in range(n):\n if(m1[i]==0):\...
{"inputs": [["1", "5 3", "1 2 3", "2 6 3", "2 10 7", "2 50 3", "1 10 5", "1 7 4"]], "outputs": [["33", "2 2 3 1 3"]]}
INTERVIEW
PYTHON3
CODECHEF
13,185
57b1f2dbc72988fcd0da36554f61632f
UNKNOWN
Today, puppy Tuzik is going to a new dog cinema. He has already left his home and just realised that he forgot his dog-collar! This is a real problem because the city is filled with catchers looking for stray dogs. A city where Tuzik lives in can be considered as an infinite grid, where each cell has exactly four neigh...
["# cook your dish here\nfrom sys import stdin,stdout\na,b=list(map(int,stdin.readline().split()))\nleft=[]\ntop=[]\nfor i in range(a):\n c,d=list(map(int,stdin.readline().split()))\n left.append(c)\n top.append(d)\nleft.sort()\ntop.sort()\nfrom bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nro...
{"inputs": [["2 3", "1 2", "0 1", "RDL"]], "outputs": [["4", "6", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
860
27d0a69336ca3e336549148f45d02850
UNKNOWN
Pied Piper is a startup company trying to build a new Internet called Pipernet. Currently, they have $A$ users and they gain $X$ users everyday. There is also another company called Hooli, which has currently $B$ users and gains $Y$ users everyday. Whichever company reaches $Z$ users first takes over Pipernet. In case ...
["# cook your dish here\nimport heapq as hq\nfrom math import floor\nfor _ in range(int(input())):\n n,a,b,x,y,z=map(int,input().split())\n arr=[-int(i) for i in input().split()]\n days=((z-b-1)//y)\n ans=0\n hq.heapify(arr)\n curr=a+days*x\n while curr<z :\n u=hq.heappop(arr)\n u=-u\n if u==0 :\n break\n else:\n...
{"inputs": [["3", "3 10 15 5 10 100", "12 15 18", "3 10 15 5 10 100", "5 5 10", "4 40 80 30 30 100", "100 100 100 100"]], "outputs": [["4", "RIP", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
12,397
069eb79b8917dd3fc69cc30feda03fe2
UNKNOWN
Monisha likes to paint. She has painted $N$ paintings (numbered $1$ through $N$) and wants to choose some subset of these paintings for an exhibition. For each valid $i$, the $i$-th painting has beauty $b_i$ and the probability that it will be displayed at the exhibition is $p_i$. Each painting is chosen or excluded fr...
["# cook your dish here\nt=int(input())\nwhile(t>0):\n n=int(input())\n b=[int(x) for x in input().split()]\n p=[float(x) for x in input().split()]\n s=[0]*(10)\n yet=2\n mx=0\n for i in range(n):\n st=bin(b[i])\n rng=len(st)-2\n if(rng+2>yet):\n for ml in range(rng+2-yet):\n s.append(0)\n if(rng>mx):\n mx=r...
{"inputs": [["2", "3", "5 6 2", "1.0 0.0 0.5", "4", "2 2 2 2", "0.5 0.5 0.5 0.5"]], "outputs": [["6.000000000000000", "1.000000000000000"]]}
INTERVIEW
PYTHON3
CODECHEF
6,721
88fb55c640a4ad5708428991926bcf04
UNKNOWN
Chef wants you to distribute candies among $N$ kids who are sitting in a circle. However, he wants to make some kids jealous of others. Thus, he wants you to distribute candies in such a way that there is a difference of at least $K$ candies between two adjacent kids. Given the value of $N$ and $K$, you need to find t...
["# cook your dish here\nfor _ in range(int(input())):\n n,k = [int(v) for v in input().split()]\n ans = (n//2)*(k+2)\n if n%2 == 0:\n ans = ans\n else:\n ans += 1 + 2*k\n \n print(ans)", "t=int(input())\r\nl=[]\r\nfor i in range(t):\r\n n,k=map(int,input().split())\r\n can=0\r\n ...
{"inputs": [["1", "2 1"]], "outputs": [["3"]]}
INTERVIEW
PYTHON3
CODECHEF
5,450
46b746160d8a9e2a1ff1c0abc6fd1e67
UNKNOWN
After the hundred years of war started by the Fire Nation, its time for the Water Tribes to bring it to an end. Avatar asked Sokka to go to the Southern WarZone from The Northern WarZone and gave him some money in a bag for his journey. Sokka has the World Map to guide him during his journey . The World Map is describe...
["m=1000000007\r\ndef gcd(a, b): \r\n if (a == 0): \r\n return b \r\n return gcd(b % a, a)\r\ndef modexp(x, n): \r\n if (n == 0) : \r\n return 1\r\n elif (n % 2 == 0) : \r\n return modexp((x * x) % m, n // 2) \r\n else : \r\n return (x * modexp((x * x) % m, \r\n ...
{"inputs": [["2", "5", "2"]], "outputs": [["200000002", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
648
06fba60dbb7e4c250482ebf54078b048
UNKNOWN
Bandwidth of a matrix A is defined as the smallest non-negative integer K such that A(i, j) = 0 for |i - j| > K. For example, a matrix with all zeros will have its bandwith equal to zero. Similarly bandwith of diagonal matrix will also be zero. For example, for the below given matrix, the bandwith of this matrix is 2....
["t = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n A = []\r\n for i in range(0, n):\r\n A.append([int(i) for i in input().split()])\r\n ones = sum([sum(i) for i in A])\r\n compare = n\r\n ans = 0\r\n for i in range(0, n):\r\n if ones <= compare:\r\n ans = i\r...
{"inputs": [["6", "2", "0 0", "0 0", "2", "1 0", "0 1", "2", "1 0", "1 0", "2", "1 0", "1 1", "3", "1 0 0", "0 1 1", "1 1 0", "4", "1 1 1 1", "1 1 1 1", "1 1 1 1", "1 1 1 1", "", ""]], "outputs": [["0", "0", "0", "1", "1", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
15,384
4f029208ac22abad4a46a114eb445eba
UNKNOWN
The Little Elephant loves lucky strings. Everybody knows that the lucky string is a string of digits that contains only the lucky digits 4 and 7. For example, strings "47", "744", "4" are lucky while "5", "17", "467" are not. The Little Elephant has the strings A and B of digits. These strings are of equal lengths, th...
["\nt = int(input())\n\nfor i in range(0,t):\n\ta = input()\n\tb = input()\n\t\n\tagts=bgts=afour=bfour=aseven=bseven=altf=bltf=afts=bfts=0;\n\t\n\tfor j in a:\n\t\tif j >= '7':\n\t\t\tif j > '7':\n\t\t\t\tagts += 1\n\t\t\telse:\n\t\t\t\taseven += 1\n\t\telif j >= '4':\n\t\t\tif j > '4':\n\t\t\t\tafts += 1\n\t\t\telse:...
{"inputs": [["4", "4", "7", "435", "479", "7", "8", "1675475", "9756417", "", ""]], "outputs": [["7", "74", "", "777744"]]}
INTERVIEW
PYTHON3
CODECHEF
31,415
b097da0499448a772a0ab2f9e62b0be8
UNKNOWN
There's a tree and every one of its nodes has a cost associated with it. Some of these nodes are labelled special nodes. You are supposed to answer a few queries on this tree. In each query, a source and destination node (SNODE$SNODE$ and DNODE$DNODE$) is given along with a value W$W$. For a walk between SNODE$SNODE$ a...
["# cook your dish here\n# cook your dish here\nimport numpy as np\nn, s, q = [int(j) for j in input().split()]\nedges = [int(j)-1 for j in input().split()]\ncosts = [int(j) for j in input().split()]\nspecial = [int(j)-1 for j in input().split()]\nqueries = [[0] * 3 for _ in range(q)]\nfor i in range(q):\n queries[i]...
{"inputs": [["7 1 5", "1 1 2 2 3 3", "3 5 4 2 7 9 1", "1", "2 3 100", "1 1 100", "2 1 100", "4 5 100", "4 7 100"]], "outputs": [["6", "6", "6", "20", "16"]]}
INTERVIEW
PYTHON3
CODECHEF
3,243
1d265b01812017e02804e5663d929256
UNKNOWN
Indraneel's student has given him data from two sets of experiments that the student has performed. Indraneel wants to establish a correlation between the two sets of data. Each data set is a sequence of $N$ numbers. The two data sets do not match number for number, but Indraneel believes that this is because data has ...
["import copy\r\nn=int(input())\r\na=[int(x) for x in input().split()]\r\nb=[int(x) for x in input().split()]\r\nc=[]\r\nd=[]\r\nlcs=[]\r\ndef lcsfn(a,c,corda,cordb):\r\n\tfor i in range(n+1):\r\n\t\td.append([0]*(n+1))\r\n\t\tlcs.append([0]*(n+1))\r\n\tfor i in range(1,n+1):\r\n\t\tfor j in range(1,n+1):\r\n\t\t\tif a...
{"inputs": [["7", "3 8 4 23 9 11 28", "2 3 22 26 8 16 12"]], "outputs": [["4", "3 4 23 9", "2 3 22 8"]]}
INTERVIEW
PYTHON3
CODECHEF
3,699
d6eb7146f58bf96ba4fff67bd31c0f39
UNKNOWN
A prime number is number x which has only divisors as 1 and x itself. Harsh is playing a game with his friends, where his friends give him a few numbers claiming that they are divisors of some number x but divisor 1 and the number x itself are not being given as divisors. You need to help harsh find which number's divi...
["import math\ndef findnumber(l,n):\n l.sort()\n x = l[0] * l[-1]\n vec = []\n i = 2\n while (i*i)<=x:\n if x%i==0:\n vec.append(i)\n if x//i !=i:\n vec.append(x//i)\n i = i + 1\n vec.sort() \n if len(vec)!=n:\n return -1\n else:\n ...
{"inputs": [["3", "2", "2 3", "2", "4 2", "3", "12 3 2"]], "outputs": [["6", "8", "-1"]]}
INTERVIEW
PYTHON3
CODECHEF
7,637
a709869f7dbc8a58e55b4508ca0df6f4
UNKNOWN
Mandarin chinese , Russian and Vietnamese as well. Let's denote $S(x)$ by the sum of prime numbers that divides $x$. You are given an array $a_1, a_2, \ldots, a_n$ of $n$ numbers, find the number of pairs $i, j$ such that $i \neq j$, $a_i$ divides $a_j$ and $S(a_i)$ divides $S(a_j)$. -----Input:----- - First line will...
["# cook your dish here\ndef prime_factors(n):\n i = 2\n factors =set()\n while i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.add(i)\n if n > 1:\n factors.add(n)\n return factors\nfor _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n ans=0\n s=[]\n for i in range(n)...
{"inputs": [["1", "5", "2 30 2 4 3"]], "outputs": [["6"]]}
INTERVIEW
PYTHON3
CODECHEF
4,880
39dbfda1043e087f6890bb78c42a70c3
UNKNOWN
Chef has arrived in Dagobah to meet with Yoda to study cooking. Yoda is a very busy cook and he doesn't want to spend time with losers. So he challenges the Chef to a series of games, and agrees to teach the Chef if Chef can win at least P of the games. The total number of games is K. The games will be played on a ches...
["import math\n\ndp = []\ndp.append(0)\nfor i in range(1,1000005):\n\tdp.append(math.log(i) + dp[i-1])\n\nt = int(input())\nfor i in range(t):\n\tn,m,p,k = input().split()\n\tn = int(n)\n\tm = int(m)\n\tp = int(p)\n\tk = int(k)\n\n\tif p==0 or (n%2==0 and m%2==0):\n\t\tans = 1.0\n\t\tprint(ans)\n\telif n%2==1 and m%2==...
{"inputs": [["2", "2 3 2 3", "2 2 5 5"]], "outputs": [["0.500000", "1.000000"]]}
INTERVIEW
PYTHON3
CODECHEF
4,500
0a67ffb6d3fa27a08b7e69f319cf792d
UNKNOWN
You are given an array $A$ of $N$ positive and pairwise distinct integers. You can permute the elements in any way you want. The cost of an ordering $(A_1, A_2, \ldots, A_N)$ is defined as $ (((A_1 \bmod A_2) \bmod A_3)......) \bmod A_N$ where $X \bmod Y$ means the remainder when $X$ is divided by $Y$. You need to f...
["# cook your dish here\nt=int(input())\nfor i in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n print(min(a))", "t=int(input())\nfor i in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n print(min(a))", "# cook your dish here\nfor i in range(int(input())):\n n=int(input())\n x=list(map(...
{"inputs": [["1", "2", "7 12"]], "outputs": [["7"]]}
INTERVIEW
PYTHON3
CODECHEF
3,743
296f764ec48da17f3cf1a3d9df92e37c
UNKNOWN
Chef is again playing a game with his best friend Garry. As usual, the rules of this game are extremely strange and uncommon. First, they are given a stack of $N$ discs. Each disc has a distinct, non-negative integer written on it. The players exchange turns to make a move. Before the start of the game, they both agree...
["for _ in range(int(input())):\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n\n a = [-1] + a[::-1]\n mx = a.index(max(a))\n dp = [0] * (n + 1)\n for i in range(1, n + 1):\n for x in b:\n if i - x < 0: continue\n if i - x < mx <= i:\n dp[i] = 1\n...
{"inputs": [["1", "3 2", "5 7 1", "1 2"]], "outputs": [["Chef"]]}
INTERVIEW
PYTHON3
CODECHEF
3,077
d80acf580e15fc55301d0a506594c146
UNKNOWN
Chef is baking a cake. While baking, in each minute the size of cake doubles as compared to its previous size. In this cake, baking of cake is directly proportional to its size. You are given $a$, the total time taken(in minutes) to bake the whole cake. Let cake be half baked at $k^{th}$ minute. Your task i...
["# cook your dish here\nfor _ in range(int(input())):\n a=int(input())\n print(a/2+2)", "# cook your dish here\nfor _ in range(int(input())):\n a=int(input())\n print(a//2+2)"]
{"inputs": [["1", "2"]], "outputs": [["3"]]}
INTERVIEW
PYTHON3
CODECHEF
189
4d753d0fc0d40fe7d111e98ce00dc795
UNKNOWN
Once N boys and M girls attended a party. You are given a matrix A of N rows and M columns where Aij is 1 if the i-th boy likes the j-th girl, otherwise it will be 0. Note that it is not necessary that if a boy x likes girl y, then girl y should like boy x. You know that if there are two different boys x and y, who bot...
["for i in range(int(input())):\n n,k=map(int,input().split())\n m=[]\n for j in range(n):\n l=list(input())\n m.append(l)\n a=0\n for k in range(k):\n b=0\n for p in range(n):\n if m[p][k]=='1':\n b+=1\n if b>1:\n a+=((b*(b-1))//2)\n print(a)", "a=int(input())\nfor i in range(a):\n n,m=map(int,input().spli...
{"inputs": [["2", "4 3", "111", "100", "110", "000", "2 2", "10", "01"]], "outputs": [["4", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
8,013
30e947780207cc28f32878374aaf55d7
UNKNOWN
Chef is a big fan of soccer! He loves soccer so much that he even invented soccer for dogs! Here are the rules of soccer for dogs: - N$N$ dogs (numbered 1$1$ through N$N$) stand in a line in such a way that for each valid i$i$, dogs i$i$ and i+1$i + 1$ are adjacent. - Each dog has a skill level, which is either 1$1$ or...
["for _ in range(int(input())):\r\n\tnum=int(input())\r\n\tarr=list(map(int,input().split()))\r\n\tdp=[0]*num\r\n\tdp[0]=1\r\n\tans=1\r\n\tj=0\r\n\tfor i in range(1,num):\r\n\t\tj=i+1\r\n\t\tcount=1\r\n\t\tdp[i]=dp[i-1]%1000000007\r\n\t\tif i-2>=0 and arr[i-2]==2:\r\n\t\t\tdp[i]+=dp[i-2]%1000000007\r\n\t\t\tif i-3>=0 a...
{"inputs": [["3", "4", "1 1 1 1", "3", "2 2 2", "4", "1 2 1 1"]], "outputs": [["4", "5", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
20,256
575aadb3a23f45487a7445fe10e31084
UNKNOWN
There are N islands in the sea, enumerated from 1 to N. Each of them is so small that we can consider them as points on a plane. You are given the Cartesian coordinates of all islands. X-axis is directed towards East and Y-axis is directed towards North. You need to illuminate all the islands. To do this, you can place...
["t= int(input())\nfor _ in range(t):\n n = int(input())\n ar = []\n y = []\n for i in range(n):\n ar.append( list(map(int,input().split())) )\n y.append(ar[-1][1])\n ar[-1].append(i)\n \n y.sort()\n mny = y[0]\n mxy = y[-1]\n ar.sort()\n ssx,ssy,ssi = ar[0]\n bbx,bby,bbi = ar[-1]\n \n sbx,sby,sbi = ar[0]\n bsx,bsy,...
{"inputs": [["2", "5", "0 0", "1 0", "2 0", "0 -1", "0 -2", "4", "5 0", "-5 0", "0 5", "0 -5"]], "outputs": [["1", "3 SW", "2", "4 NE", "2 NE"]]}
INTERVIEW
PYTHON3
CODECHEF
7,957
d2ebcb3a11a9e051e7bb720bbdaa6d71
UNKNOWN
Given an integer N, Chef wants to find the smallest positive integer M such that the bitwise XOR of M and M+1 is N. If no such M exists output -1. -----Input----- The first line of input contain an integer T denoting the number of test cases. Each of the following T lines contains an integer N for that test case. ---...
["# from math import log2\n# N = 10000\n# for i in range(1,N):\n# # print(i)\n# for m in range(i):\n# if( (m^(m+1))==i ):\n# print(i)\n# print(m,m+1,bin(m)[2:])\n# print()\n# break\n# # else:\n# # print(-1)\n# # print()\nT = int(input()...
{"inputs": [["1", "3"]], "outputs": [["1"]]}
INTERVIEW
PYTHON3
CODECHEF
5,299
8d08598ea6226edd8f5cd4529cd7b9bd
UNKNOWN
In Chefland, types of ingredients are represented by integers and recipes are represented by sequences of ingredients that are used when cooking. One day, Chef found a recipe represented by a sequence $A_1, A_2, \ldots, A_N$ at his front door and he is wondering if this recipe was prepared by him. Chef is a very picky ...
["# cook your dish here\n \nfor __ in range(int(input())):\n n=int(input())\n arr=list(map(int,input().split()))\n d={}\n s=set()\n flag=0\n for i in range(n):\n if arr[i] in list(d.keys()):\n d[arr[i]]+=1\n else:\n d[arr[i]]=1\n curr_ele=arr[i]\n if (curr_ele in s) and arr[i-1]!=arr[i]:\n flag=1\n break\n ...
{"inputs": [["3", "6", "1 1 4 2 2 2", "8", "1 1 4 3 4 7 7 7", "8", "1 7 7 3 3 4 4 4"]], "outputs": [["YES", "NO", "NO"]]}
INTERVIEW
PYTHON3
CODECHEF
11,297
49067de904719163493e439153a495d5
UNKNOWN
Kshitij has recently started solving problems on codechef. As he is real problem solving enthusiast, he wants continuous growth in number of problems solved per day. He started with $a$ problems on first day. He solves $d$ problems more than previous day. But after every $k$ days , he increases $d$ by $inc$ . Can you...
["# cook your dish here\n\nt = int(input())\n\nfor _ in range(t):\n\ta,d,k,n,inc = map(int, input().strip().split())\n\n\tres = a\n\tfor i in range(1, n):\n\t\tif i%k == 0:\n\t\t\td += inc\n\t\tres += d\n\n\tprint(res)", "# cook your dish here\ntry:\n for i in range(int(input())):\n inp=list(map(int,input().s...
{"inputs": [["1", "1 4 3 8 2"]], "outputs": [["43"]]}
INTERVIEW
PYTHON3
CODECHEF
9,985
495766d613ab61e9480a44032b99f4d0
UNKNOWN
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
["x=eval(input())\nfor x in range(0,x):\n\tans=0\n\td=input()\n\ta=0\n\tcont=0\n\tfor i in range(0,len(d)):\n\t\ta+=len(d)-i\n\t\tif d[i]=='7':\n\t\t\tans+=1+cont\n\t\t\tcont+=1\n\t\telse:\n\t\t\tcont=0\n\tans=a-ans\n\tprint(ans)\n", "for _ in range(int(input())):\n\ts = input()\n\ta = s.split('4')\n\tsum1 = 0\n\tfor k...
{"inputs": [["4", "47", "74", "477", "4747477", "", ""]], "outputs": [["2", "2", "3", "23"]]}
INTERVIEW
PYTHON3
CODECHEF
2,209
5abf06b57dfee6ef29df4ea632a6240b
UNKNOWN
Cheffina challanges chef to rearrange the given array as arr[i] > arr[i+1] < arr[i+2] > arr[i+3].. and so on…, i.e. also arr[i] < arr[i+2] and arr[i+1] < arr[i+3] and arr[i] < arr[i+3] so on.. Chef accepts the challenge, chef starts coding but his code is not compiling help him to write new code. -----Input:----- - Fi...
["# cook your dish here\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int,input().split()))\n a.sort()\n i=1\n while(i<n):\n a[i-1],a[i] = a[i],a[i-1]\n i+=2\n print(*a)\n", "# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n arr=[int(i) for ...
{"inputs": [["2", "4", "4 1 6 3", "5", "4 5 1 6 3"]], "outputs": [["3 1 6 4", "3 1 5 4 6"]]}
INTERVIEW
PYTHON3
CODECHEF
2,158
183c220057d6f72c51e84c665c740687
UNKNOWN
There is only little time left until the New Year! For that reason, Chef decided to make a present for his best friend. He made a connected and undirected simple graph with N$N$ vertices and M$M$ edges. Since Chef does not like odd numbers and his friend does not like undirected graphs, Chef decided to direct each edge...
["# cook your dish here\nfor _ in range(int(input())):\n N, M = [int(x) for x in input().split()]\n edges = [0]*M\n dir = {}\n nodes = [[] for j in range(N+1)]\n ind = [0]*(N+1)\n graph = {}\n final_edges = []\n for i in range(M):\n u, v = [int(x) for x in input().split()]\n nodes[...
{"inputs": [["2", "4 4", "1 2", "1 3", "2 4", "3 4", "3 3", "1 2", "2 3", "1 3"]], "outputs": [["0 0 1 1", "-1"]]}
INTERVIEW
PYTHON3
CODECHEF
17,524
0470f9a947e8a235bba0e83006585ed5
UNKNOWN
Chef has bought N robots to transport cakes for a large community wedding. He has assigned unique indices, from 1 to N, to each of them. How it will happen? Chef arranges the N robots in a row, in the (increasing) order of their indices. Then, he chooses the first M robots and moves them to the end of the queue. Now, C...
["#read input\ncases = int(input())\ncaselist = []\nfor i in range(0, cases):\n caselist.append(input())\n\n#iterate each case\nfor j in range(0, cases):\n\n #current case's parameters:\n current_input = caselist[j].split(' ')\n bots = int(current_input[0])\n switch = int(current_input[1])\n\n #generate botlist and cak...
{"inputs": [["3", "2 0", "2 1", "4 2"]], "outputs": [["No 1", "Yes", "No 2"]]}
INTERVIEW
PYTHON3
CODECHEF
5,915
46c341e41e7e9dccc61e871e00d2d2f6
UNKNOWN
Chef has a sequence $A_1, A_2, \ldots, A_N$; each element of this sequence is either $0$ or $1$. Appy gave him a string $S$ with length $Q$ describing a sequence of queries. There are two types of queries: - '!': right-shift the sequence $A$, i.e. replace $A$ by another sequence $B_1, B_2, \ldots, B_N$ satisfying $B_{i...
["n, q, k = map(int, input().split())\narr = list(map(int, input().split()))\nquery = list(input())\nq_ = len(query)\nc1 = query.count('?')\nc = arr.count(0)\nif c == n:\n for i in range(c1):\n print(0)\nelse:\n for i in range(q_):\n if (i!=0) and (query[i] == '?' and query[i-1] == '?'):\n print(max_c)\n elif quer...
{"inputs": [["5 5 3", "1 1 0 1 1", "?!?!?"]], "outputs": [["2", "3", "3"]]}
INTERVIEW
PYTHON3
CODECHEF
1,977
5d8962662c446038d581398413da64ee
UNKNOWN
It's Christmas time and Santa is in town. There are N children each having a bag with a mission to fill in as many toffees as possible. They are accompanied by a teacher whose ulterior motive is to test their counting skills. The toffees are of different brands (denoted by lowercase letters a-z). Santa picks up a child...
["import numpy as np\n\nN=10**6+1\nt=eval(input())\ninp = ()\n\nt1=ord('z')\n#bag=[[0 for _ in xrange(t1)] for _ in xrange(N+1)]\nbag=np.zeros((N+1,t1),dtype=np.int)\n#print bag\nwhile t:\n t-=1\n inp=input().split()\n t2=ord(inp[3]) - ord('a')\n t3=int(inp[1])\n t4=int(inp[2]) + 1\n if inp[0]==\"1\":\n #print \"ente...
{"inputs": [["5", "1 3 4 a", "1 5 8 a", "1 1 7 x", "2 1 6 a", "2 3 6 y"]], "outputs": [["12", "0", "In first case, there are two children between 3 and 5 between 0 - 6 having sum (4 + 8)", "There's no toffee for y in given range"]]}
INTERVIEW
PYTHON3
CODECHEF
1,105
7633f07d89509a1d71a8c0f76d22546c
UNKNOWN
Leha is a usual student at 'The Usual University for Usual Students'. Sometimes he studies hard; at other times he plays truant and gets busy with other things besides academics. He has already studied at the university for N months. For the ith month (1 ≤ i ≤ N), he has received some non-negative integer grade A[i]. N...
["n=eval(input())\ngrades=list(map(int,input().split()))\nm=eval(input())\nfor df in range(m):\n x,y=list(map(int,input().split()))\n arr=[]\n arr=grades[x-1:y]\n arr.sort()\n sum=0\n #arr.append(1000000)\n for nh in range(0,len(arr)-1,1):\n sum=sum+(arr[nh+1]-arr[nh])**2\n #print sum,len(arr),nh+1,nh\n print(sum)", ...
{"inputs": [["5", "1 3 2 4 5", "5", "1 5", "1 4", "2 4", "3 3", "3 5"]], "outputs": [["4", "3", "2", "0", "5"]]}
INTERVIEW
PYTHON3
CODECHEF
4,852
79bcbbe605a6eeef42ab66219caaf099
UNKNOWN
The XOR pair representation (XPR) of a positive integer $N$ is defined as a pair of integers $(A, B)$ such that: - $1 \le A \le B \le N$ - $A \oplus B = N$ - if there is no way to choose $A$ and $B$ satisfying the above conditions, $A = B = -1$ - otherwise, the value of $A$ should be the smallest possible These conditi...
["import math\ndef GLR(x):\n summation_N = (x*(x+1))//2\n initial = x\n power = 0\n sum_A = 0\n while x>=1:\n count = (x+1)//2\n sum_A += count * 2**power\n x = x - count\n power += 1\n sum_B = summation_N - sum_A\n ans = sum_B - (int(math.log(initial,2))+1)\n return ans\n \nfor _ in range(int(input())):\n l,r = li...
{"inputs": [["5", "1 10", "3 6", "4 10", "10 17", "100 159"]], "outputs": [["28", "9", "28", "79", "7485"]]}
INTERVIEW
PYTHON3
CODECHEF
11,201
301f07583e33e5e9b73a46782986cba2
UNKNOWN
The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Output warning. You are expected to be able to process at least 2.5MB of input data per second at runtime. -----Input----- The input begins with two posit...
["#Note that it's python3 Code. Here, we are using input() instead of raw_input().\n#You can check on your local machine the version of python by typing \"python --version\" in the terminal.\n\n(n, k) = list(map(int, input().split(' ')))\n\nans = 0\n\nfor i in range(n):\n\tx = int(input())\n\tif x % k == 0:\n\t\tans +=...
{"inputs": [["7 3", "1", "51", "966369", "7", "9", "999996", "11"]], "outputs": [["4"]]}
INTERVIEW
PYTHON3
CODECHEF
6,344
78a53389812fe6124f208a0a65bb37a4
UNKNOWN
Chef has recently been playing a lot of chess in preparation for the ICCT (International Chef Chess Tournament). Since putting in long hours is not an easy task, Chef's mind wanders elsewhere. He starts counting the number of squares with odd side length on his chessboard.. However, Chef is not satisfied. He wants to k...
["# cook your dish here\nt=int(input())\nfor i in range(t):\n a=0\n n=int(input())\n while(n>0):\n a += n*n\n n=n-2\n print(a)\n", "t=int(input())\nfor i in range (t):\n a=0\n n=int(input())\n while(n>0):\n a += n*n\n n=n-2\n print(a)\n", "t=int(input())\nfor i in range (t):\n a=0\n n=int(input())\n while(n>0):\n ...
{"inputs": [["2", "3", "8"]], "outputs": [["10", "120"]]}
INTERVIEW
PYTHON3
CODECHEF
3,963
27a49498c1994cefe06eafd169696101
UNKNOWN
Today, Chef has a fencing job at hand and has to fence up a surface covering N$N$ points. To minimize his work, he started looking for an algorithm that had him fence the least amount of length. He came up with the Convex Hull algorithm, but soon realized it gave him some random shape to fence. However, Chef likes re...
["import math\n\n\nn,m = map(int, input().split())\nhyp = math.sqrt(1+m*m)\ncosx = 1/hyp\nsinx = m/hyp\n\npts = [[], []]\nfor i in range(n):\n p = input().split()\n px = int(p[0])\n py = int(p[1])\n pts[0].append(cosx*px+sinx*py)\n pts[1].append(cosx*py-sinx*px)\n\nw = max(pts[0])-min(pts[0])\nl = max(pt...
{"inputs": [["4 1", " 0 1", " 0 -1", " 1 0", " -1 0", ""]], "outputs": [["5.656854249492380"]]}
INTERVIEW
PYTHON3
CODECHEF
10,199
2fd9b4d645c4ea370cf50cfdde86e1be
UNKNOWN
Mia is working as a waitress at a breakfast diner. She can take up only one shift from 6 shifts a day i.e. from 10 am to 4 pm. She needs to save 300$ after completion of the month. She works only for $D$ days in the month. She estimates that she gets her highest tip in the first shift and the tip starts decreasing by 2...
["# cook your dish here\n\nl=[int(k) for k in input().split()]\ns=[int(k) for k in input().split()]\nx=l[1]*l[0]\nfor i in range(l[0]):\n if(s[i]==1):\n x+=l[2]\n elif(s[i]==2):\n x+=(l[2]*98/100)\n elif(s[i]==3):\n x+=(l[2]*96/100)\n elif(s[i]==4):\n x+=(l[2]*94/100)\n elif(s...
{"inputs": [["9 17 5", "1 3 2 4 5 6 1 2 2"]], "outputs": [["NO"]]}
INTERVIEW
PYTHON3
CODECHEF
8,422
3b176ac7472640ba1a276747fef3b45d
UNKNOWN
Consider the fraction, $a/b$, where $a$ and $b$ are positive integers. If $a < b$ and $GCD(a,b) = 1$, it is called a reduced proper fraction. If we list the set of a reduced proper fraction for $d \leq 8$, (where $d$ is the denominator) in ascending order of size, we get: $1/8$, $1/7$, $1/6$, $1/5$, $1/4$, $2/7$, $1/3$...
["from sys import stdin\nfrom fractions import Fraction\n\ninput = stdin.readline\n\nfor _ in range(int(input())):\n a, b, n = list(map(int, input().split()))\n ab = Fraction(a, b)\n\n p = set()\n\n for i in range(1, n+1):\n for j in range(n, 0, -1):\n x = Fraction(i, j)\n\n if ...
{"inputs": [["5", "3 7 8", "3 5 8", "4 5 8", "6 7 8", "1 5 8"]], "outputs": [["2 5", "4 7", "3 4", "5 6", "1 6"]]}
INTERVIEW
PYTHON3
CODECHEF
3,278
3b220d696de019f9e05aa76e35f2fcf5
UNKNOWN
The name of our college is "Government College of Engineering and Textile Technology Berhampore". There is another college named "Government College of Engineering and Textile Technology Serampore". As the names are quite similar, those who are unaware of existence of both the colleges, often get confused. And mistake ...
["# cook your dish here\ntry:\n t=int(input()) \n for i in range(t):\n n=input() \n n=n.lower()\n a=\"berhampore\"\n b=\"serampore\"\n if a in n:\n if b in n:\n print(\"Both\")\n else:\n print(\"GCETTB\")\n elif b in n:\...
{"inputs": [["3", "Government clg Berhampore", "SeRaMporE textile college", "Girls college Kolkata"]], "outputs": [["GCETTB", "GCETTS", "Others"]]}
INTERVIEW
PYTHON3
CODECHEF
9,996
e9237fd84585226f65e3c1ce062c55b8
UNKNOWN
Chef has a recipe book. He wishes to read it completely as soon as possible so that he could try to cook the dishes mentioned in the book. The pages of the book are numbered $1$ through $N$. Over a series of days, Chef wants to read each page. On each day, Chef can choose to read any set of pages such that there is no ...
["def ugcd(n):\r\n ans = [[1]]\r\n if(n==1):\r\n return ans\r\n elif(n%2==1):\r\n ans = [[1, 2, n]]\r\n else:\r\n ans = [[1, 2]]\r\n for k in range(1, int(n//2)):\r\n ans.append([k*2+1, k*2+2])\r\n return ans\r\nt = int(input())\r\nfor i in range(t):\r\n n = int(input())\r\n s = (ugcd(n))\r\n print...
{"inputs": [["1", "5", ""]], "outputs": [["2", "3 1 2 5", "2 3 4"]]}
INTERVIEW
PYTHON3
CODECHEF
15,849
01bc9ef313f7acc0ab693b923d5adff4
UNKNOWN
You visit a doctor on a date given in the format $yyyy:mm:dd$. Your doctor suggests you to take pills every alternate day starting from that day. You being a forgetful person are pretty sure won’t be able to remember the last day you took the medicine and would end up in taking the medicines on wrong days. So you com...
["t=int(input())\nli1=[31,29,31,30,31,30,31,31,30,31,30,31]\nli2=[31,28,31,30,31,30,31,31,30,31,30,31]\nfor z in range(t):\n y,m,d=list(map(int,input().split(':')))\n if y%4 == 0:\n if y%100 == 0:\n if y%400 == 0:\n li=li1\n else:\n li=li2\n else:\n li=li1\n else:\n li=li2\n c=0\n if d%2 == 0:\n while d...
{"inputs": [["1", "2019:03:31"]], "outputs": [["1"]]}
INTERVIEW
PYTHON3
CODECHEF
9,814
9f8013696dc77a447cfef1f3f7fb9ad1
UNKNOWN
You are given a tree consisting of n nodes numbered from 1 to n. The weights of edges of the tree can be any binary integer satisfying following Q conditions. - Each condition is of form u, v, x where u, v are nodes of the tree and x is a binary number. For satisfying this condition, sum of the weight of all t...
["import sys\n\ndef powc(x,n,m):\n res = 1\n xx=x\n while n:\n if n&1:\n res = (res*xx)%m\n xx=xx*xx%m\n n >>= 1\n return res\n\ndef circles(u):\n r = 0\n S = [(u,-1,0)]\n Visited[u] = 0\n for s in S:\n for e in V[s[0]]:\n if e[0] != s[1]:\n if Visited[e[0]]==-1: \n Visited...
{"inputs": [["3", "3 2", "1 2", "1 3", "1 2 0", "1 3 0", "3 0", "1 2", "2 3", "3 1", "1 2", "2 3", "1 2 1"]], "outputs": [["1", "4", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
12,473
e4ef5106b7ebb22273336de489334006
UNKNOWN
Vietnamese and Bengali as well. An $N$-bonacci sequence is an infinite sequence $F_1, F_2, \ldots$ such that for each integer $i > N$, $F_i$ is calculated as $f(F_{i-1}, F_{i-2}, \ldots, F_{i-N})$, where $f$ is some function. A XOR $N$-bonacci sequence is an $N$-bonacci sequence for which $f(F_{i-1}, F_{i-2}, \ldots, F...
["# cook your dish here\nn,q=map(int,input().split())\nls=[int(i) for i in input().split()]\ncur=0\ns=[0]\nfor i in ls:\n cur=cur^i\n s.append(cur)\nfor i in range(q):\n k=int(input())\n print(s[k%(n+1)])", "# cook your dish here\nn,k=list(map(int,input().split()))\nd=[0]+list(map(int,input().split()))\nl=[0]\nfor i in...
{"inputs": [["3 4", "0 1 2", "7", "2", "5", "1000000000"]], "outputs": [["3", "1", "0", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
6,334
daec23f77254d7c82f72417eed79ade0
UNKNOWN
Alice and Johnny are playing a simple guessing game. Johnny picks an arbitrary positive integer n (1<=n<=109) and gives Alice exactly k hints about the value of n. It is Alice's task to guess n, based on the received hints. Alice often has a serious problem guessing the value of n, and she's beginning to suspect that...
["# cook your dish here\ndef guessingGame (l):\n a = []\n m = 1000000001\n for i in range (len(l)):\n k=int(l[i][1])\n if (l[i][0]=='<' and l[i][2]=='Yes'):\n a.append((1,1))\n a.append((k,-1))\n \n if (l[i][0]=='<' and l[i][2]=='No'):\n a.append((k,1))\n a.append((m,-1))\n \n if (l[i][0]=='=' and l[i][...
{"inputs": [["3", "2", "< 100 No", "> 100 No", "3", "< 2 Yes", "> 4 Yes", "= 3 No", "6", "< 2 Yes", "> 1 Yes", "= 1 Yes", "= 1 Yes", "> 1 Yes", "= 1 Yes"]], "outputs": [["0", "1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
1,059
69d35f28914862f7fbdab2b44e4e735f
UNKNOWN
Ms. E.T. came from planet Hex. She has 8 fingers in each hand which makes her count in hexadecimal way. When she meets you, she tells you that she came from 7E light years from the planet Earth. You see she means that it is 126 light years far away and she is telling you the numbers in hexadecimal. Now, you are in trou...
["# cook your dish here\ntry:\n t=int(input())\n for i in range(t):\n s=input()\n i=int(s,16)\n print(i)\nexcept EOFError as e:\n print(e)", "# cook your dish here\ntry:\n n=int(input())\n for i in range(n):\n a=input()\n \n print(int(a, 16))\nexcept EOFError as ...
{"inputs": [["3", "A", "1A23", "2C2A"]], "outputs": [["10", "6691", "11306"]]}
INTERVIEW
PYTHON3
CODECHEF
4,886
12f53c68dc80badf68c57f28271c42d3
UNKNOWN
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test cases. Then the test cases follow. - Each test case contains a single line of...
["try:\r\n tc=int(input())\r\n for _ in range(tc):\r\n n=int(input())\r\n st=\"\"\r\n b=1\r\n for i in range(1,n+1):\r\n b+=1\r\n a=b\r\n for j in range(1,n+1):\r\n print(a,end='')\r\n a+=1\r\n print() \r\...
{"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["2", "23", "34", "234", "345", "456", "2345", "3456", "4567", "5678"]]}
INTERVIEW
PYTHON3
CODECHEF
7,209
9f31984b13d95e539b5fafce3ef13eac
UNKNOWN
Ahmed Gafer failed to pass the test, but he got the job because of his friendship with Said and Shahhoud. After working in the kitchen for a while, he blew it. The customers didn't like the food anymore and one day he even burned the kitchen. Now the master Chef is very upset. Ahmed isn't useful anymore at being a co-C...
["# cook your dish here\nfor _ in range(int(input())):\n s=input()\n count=0\n i=0\n while i<len(s)-1:\n ch=s[i]\n j=i+1 \n while j<len(s) and s[j]==ch:\n j+=1 \n l=j-i\n if i!=0 and j!=len(s) and s[i-1]==s[j] :\n count+=1\n count+=l*(l-1)//2\n #print(s[i:j],count)\n i=j\n print(count) \n", "# cook your dis...
{"inputs": [["2", "a", "abba"]], "outputs": [["0", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
1,295
89ca3b8091f8098c73d6953b06639441
UNKNOWN
In Chefland, there is a monthly robots competition. In the competition, a grid table of N rows and M columns will be used to place robots. A cell at row i and column j in the table is called cell (i, j). To join this competition, each player will bring two robots to compete and each robot will be placed at a cell in th...
["import sys\n\ndef spaces(a,n,m,k,visit1,visit2,dist,position):\n queue = [position]\n lastedit = []\n dist[position[0]][position[1]] = 0 \n while queue!=[]:\n point = queue[0]\n i = point[0]\n j = point[1]\n #print 'point',i,j\n if visit1[i][j]==False:\n visit1[i][j] = True\n startx = max(i-k,0)\n endx = m...
{"inputs": [["2", "4 4 1 1", "0 1 1 0", "0 1 1 0", "0 1 1 0", "0 0 0 0", "4 4 1 1", "0 1 1 0", "0 1 1 0", "0 1 1 0", "1 0 0 1"]], "outputs": [["5", "-1"]]}
INTERVIEW
PYTHON3
CODECHEF
7,738
54078897a043438922c09e82b3177d83
UNKNOWN
$Neha$ is given a number $N$. She always looks for special thing , this time she is looking for $Special$ $Number$ and $Partial$ $Special$ $Number$. A $Special$ $Number$ is a number whose product of its digits is equal to number itself i.e. $N $, and in this number there is no digit $1$. $Partial$ $Special$ is a numbe...
["n=int(input())\r\na=[]\r\nb=[]\r\nfor i in range(1,1000001):\r\n s = str(i)\r\n p=1\r\n flag=0\r\n for e in s:\r\n if e=='1':\r\n flag=1\r\n p=p*int(e)\r\n if p==n:\r\n if flag!=1:\r\n a.append(i)\r\n else:\r\n b.append(i)\r\nprint(len(a),len...
{"inputs": [["3"]], "outputs": [["1 20"]]}
INTERVIEW
PYTHON3
CODECHEF
6,723
efe407ed8fea096e718256dd457703d0
UNKNOWN
Many things in this first paragraph are references to some pretty famous YouTube stars, so be careful about rephrasing. Thanks! Michael, Kevin and Jake are sharing a cake, in celebration of their Webby award. They named it VCake. Unlike other cakes they considered, this one has finite volume and surface area. It's sha...
["#!/usr/bin/python\nimport sys\n\ndef __starting_point():\n t = int(input())\n for iteration in range(t):\n r,c,m_inp,k_inp,j_inp = input().strip().split(\" \")\n r=int(r)\n c=int(c)\n m_inp=int(m_inp)\n k_inp=int(k_inp)\n j_inp=int(j_inp)\n\n ans = \"\"\n if (r*c) != (m_inp+k_inp+j_inp):\n print(\"No\")\n ...
{"inputs": [["4", "4 5 10 4 6", "4 5 6 10 4", "4 5 4 6 10", "2 2 2 2 2"]], "outputs": [["Yes", "Yes", "Yes", "No"]]}
INTERVIEW
PYTHON3
CODECHEF
17,631
8cdef539b502c583079ffe00091a80fb
UNKNOWN
Stuart is obsessed to numbers. He like all type of numbers in fact he is having a great collection of numbers in his room. His collection includes N different large numbers. But today he is searching for a number which is having maximum frequency of digit X. Numbers are large so he can’t do the task on his own. Help hi...
["T = int(input())\n\ndef call_me(N,A,X):\n max = 0\n ans = ''\n for i in A:\n if i.count(X) > max:\n max = i.count(X)\n ans = i\n return ans\n\n\n\nfor i in range(T):\n N = int(input())\n A = list(map(str,input().split()))\n X = input()\n print(call_me(N,A,X))\n", "for _ in range(int(input())):\n n=int(input())\n...
{"inputs": [["2", "5", "345 1323 165 98 456", "3", "5", "335 876 98 1323 349", "3"]], "outputs": [["1323", "335"]]}
INTERVIEW
PYTHON3
CODECHEF
2,160
8b11782a82f70f7ddaa30c8fe7c4b07c
UNKNOWN
Abhiram needs to search for an antidote. He comes to know that clue for finding the antidote is carefully hidden by KrishnaMurthy in the form of a puzzle. The puzzle consists of a string S and a keywordK. Abhiram needs to find the string of position of anagrams R of the keyword in the string which is the clue. The an...
["x = input().split(\" \")\ny = input()\nans = ''\nl = 1\nfor i in x:\n if i!=y and sorted(i) == sorted(y):\n ans = ans + (str)(l)\n l=l+1\nans+='.'\nprint(\"The antidote is found in\",ans)", "s = input().split(\" \")\nk = input()\nl = \"abcdefghijklmnopqrstuvwxyz\"\na = 26*[0]\nn = len(k)\nc = \"\"\nfor i in range(n)...
{"inputs": [["cat is the act of tac", "cat"]], "outputs": [["The antidote is found in 46."]]}
INTERVIEW
PYTHON3
CODECHEF
1,576
870f6807b532f440bde921e558290ad8
UNKNOWN
Chef has decided to retire and settle near a peaceful beach. He had always been interested in literature & linguistics. Now when he has leisure time, he plans to read a lot of novels and understand structure of languages. Today he has decided to learn a difficult language called Smeagolese. Smeagolese is an exotic lan...
["# cook your dish here\nfrom collections import Counter\nfrom math import factorial\nfor _ in range(int(input())):\n s=input()\n c=Counter(s)\n k=factorial(len(s))\n for value in c.values():\n if value>1:\n k=k//factorial(value)\n print(k%(10**9+7))", "# cook your dish here\nfrom collections import Counter\nfrom ma...
{"inputs": [["4", "ab", "aa", "aA", "AAbaz"]], "outputs": [["2", "1", "2", "60", "Description:", "In first case \"ab\" & \"ba\" are two different words. In third case, note that A & a are different alphabets and hence \"Aa\" & \"aA\" are different words."]]}
INTERVIEW
PYTHON3
CODECHEF
5,905
0bf755731d0b4965b581a5e0fbd5700f
UNKNOWN
You have a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind: Choose any position in the string, remove the character at that position and insert it back to any other place in the string. Find the lexicographically smallest string you can achieve. ...
["for _1 in range(int(input())):\n n=int(input())\n s=input().strip()\n answer=s\n for i in range(len(s)):\n c=s[i]\n string=s[:i]+s[i+1:]\n for j in range(len(string)+1):\n answer=min(answer, string[:j]+c+string[j:])\n print(answer)", "def modify(s,i,j):\n k = s[i]\n del(s[i])\n s.insert(j,k)\n return(str(s))\n \...
{"inputs": [["2", "4", "DCBA", "7", "XYZZYZZ"]], "outputs": [["ADCB", "XYYZZZZ"]]}
INTERVIEW
PYTHON3
CODECHEF
3,486
784e19ec33177a7926dbdf578bb9533e
UNKNOWN
Let's define a periodic infinite sequence S$S$ (0$0$-indexed) with period K$K$ using the formula Si=(i%K)+1$S_i = (i \% K) + 1$. Chef has found a sequence of positive integers A$A$ with length N$N$ buried underground. He suspects that it is a contiguous subsequence of some periodic sequence. Unfortunately, some element...
["# cook your dish here\nfrom math import gcd\nfor _ in range(int(input())):\n n,a,k,min_k,e = int(input()),[int(i) for i in input().split()],0,0,-1 \n for j in range(n):\n if(a[j] != -1):break \n for i in range(j,n):\n if min_k==0:min_k,e = a[i],a[i]+1 \n else:\n if min_k < a[i]:...
{"inputs": [["3", "3", "-1 -1 -1", "5", "1 -1 -1 4 1", "4", "4 6 7 -1"]], "outputs": [["inf", "4", "impossible"]]}
INTERVIEW
PYTHON3
CODECHEF
2,311
db80229d59f88c801deea9b6f6cfbd46
UNKNOWN
You are participating in a contest which has $11$ problems (numbered $1$ through $11$). The first eight problems (i.e. problems $1, 2, \ldots, 8$) are scorable, while the last three problems ($9$, $10$ and $11$) are non-scorable ― this means that any submissions you make on any of these problems do not affect your tota...
["# cook your dish here\np=int(input())\nfor z in range(p):\n n=int(input())\n a=[]\n for i in range(8):\n a.append(0)\n for i in range(n):\n x,y=list(map(int,input().split()))\n if x<=8 and y>a[x-1]:\n a[x-1]=y\n print(sum(a))\n", "# cook your dish here\nn=int(input())\nfor i in range(n):\n m=int(input())\n l=[0]...
{"inputs": [["2", "5", "2 45", "9 100", "8 0", "2 15", "8 90", "1", "11 1"]], "outputs": [["135", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
5,435
249c86c4e684a627ea77d4b771173c92
UNKNOWN
There are n cabs in a city numbered from 1 to n. The city has a rule that only one cab can run in the city at a time. Cab picks up the customer and drops him to his destination. Then the cab gets ready to pick next customer. There are m customers in search of cab. First customer will get the taxi first. You have to fin...
["import math\ndef dist(w,x,y,z):\n return math.hypot(y - w, z - x)\n\nt = int(input())\nwhile (t>0):\n t = t -1\n n, m = list(map(int,input().split()))\n a = []\n for i in range(0,n):\n x,y = list(map(int,input().split()))\n a.append([x,y])\n for j in range(0,m):\n p,q,r,s = list(map(int,input().split()))\n neares...
{"inputs": [["1", "3 2", "1 3", "3 2", "3 5", "2 3 3 4", "5 3 4 1"]], "outputs": [["1", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
542
cac4fe86af59e78be3b886d571a7b33b
UNKNOWN
A binary string is called a self-destructing string if it can reduced to an empty string by performing the following operation some number of times (possibly zero): Choose a valid integer $i$ such that the $i$-th character of the current string is different from the $i+1$-th character, and remove these two characters f...
["t=int(input())\nfor i in range(t):\n s=input()\n zeroes=s.count('0')\n ones=s.count('1')\n if (len(s)%2==1 or zeroes==0 or ones==0):\n ans= -1\n else:\n ans=abs(zeroes-ones)//2\n print(ans) ", "a = int(input())\nfor i in range(a):\n b = list(map(int,str(input())))\n if len(b)%2!=0:\n print(-1)\n else:\n if sum(b)...
{"inputs": [["3", "001101", "1101", "110"]], "outputs": [["0", "1", "-1"]]}
INTERVIEW
PYTHON3
CODECHEF
6,010
73af08261b86a1a1146247dca487aac5
UNKNOWN
Chef's company wants to make ATM PINs for its users, so that they could use the PINs for withdrawing their hard-earned money. One of these users is Reziba, who lives in an area where a lot of robberies take place when people try to withdraw their money. Chef plans to include a safety feature in the PINs: if someone in...
["for i in range(int(input())):\n n = int(input())\n q = \"1\"+\"0\"*(n//2)\n print(1,q)", "# cook your dish here\nfor i in range(int(input())):\n n = int(input())\n q = \"1\"+\"0\"*(n//2)\n print(1,q)", "# cook your dish here\nfor _ in range(int(input())):\n n = int(input())\n q = \"1\"+\"0\"*(n//2)\n print(1,q)\n \n...
{"inputs": [["1", "1"]], "outputs": [["1 1"]]}
INTERVIEW
PYTHON3
CODECHEF
4,572
f483f091a2a5e1ebf49e08636cbd499b
UNKNOWN
As we all know caterpillars love to eat leaves. Usually, a caterpillar sits on leaf, eats as much of it as it can (or wants), then stretches out to its full length to reach a new leaf with its front end, and finally "hops" to it by contracting its back end to that leaf. We have with us a very long, straight branch of a...
["from math import gcd\r\nn, k = list(map(int, input().split()))\r\na = []\r\nfor i in range(k):\r\n try:\r\n a += list(map(int, input().split()))\r\n except:\r\n pass\r\nans = n\r\nfor i in range(1, 2**k):\r\n b = bin(i)[2:].rjust(k, \"0\")\r\n c = []\r\n for j in range(k):\r\n if(b...
{"inputs": [["20 3", "3", "2", "5"]], "outputs": [["6", "Hint:", "You may use 64 -bit integers ( long long in C/C++) to avoid errors while multiplying large integers. The maximum value you can store in a 32 -bit integer is 2 31 \u2212 1 , which is approximately 2 \u22c5 10 9 . 64 -bit integers can store values gr...
INTERVIEW
PYTHON3
CODECHEF
583
3ce51b46bd15e9bcb8662fbf7ecbef49
UNKNOWN
Young Sheldon is given the task to teach Chemistry to his brother Georgie. After teaching him how to find total atomic weight, Sheldon gives him some formulas which consist of $x$, $y$ and $z$ atoms as an assignment. You already know that Georgie doesn't like Chemistry, so he want you to help him solve this assignment...
["for _ in range(int(input())):\n s = list(input().strip())\n\n i = 0\n\n while i < len(s) - 1:\n if s[i].isalpha() or s[i] == ')':\n if s[i + 1].isdigit():\n if i + 2 >= len(s) or s[i + 2] == ')':\n s = s[:i+1] + ['*', s[i+1]] + s[i+2:]\n else:\n s = s[:i+1] + ['*', s[i+1], '+'] + s[i+2:]\n i += 1\...
{"inputs": [["2", "(xy)2", "x(x2y)3(z)2"]], "outputs": [["12", "46"]]}
INTERVIEW
PYTHON3
CODECHEF
504
a72aa6ce50902748aa8e2022fd7dcdfd
UNKNOWN
Chef has a pepperoni pizza in the shape of a $N \times N$ grid; both its rows and columns are numbered $1$ through $N$. Some cells of this grid have pepperoni on them, while some do not. Chef wants to cut the pizza vertically in half and give the two halves to two of his friends. Formally, one friend should get everyth...
["# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n l1=[]\n l2=[]\n \n for i in range(n):\n s=input()\n a=s[ :n//2].count('1')\n b=s[n//2: ].count('1')\n if a>b:\n l1.append(a-b)\n \n elif a<b:\n l2.append(b-a)\n \n p=sum(l1)\n q=sum(l2)\n \n if p==q:\n print(0)\n \n elif p>q:\n di...
{"inputs": [["2", "6", "100000", "100000", "100000", "100000", "010010", "001100", "4", "0011", "1100", "1110", "0001"]], "outputs": [["2", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
9,280
0323456a1d9bafb3a011dc7f12a07093
UNKNOWN
You are provided with the marks of entire class in Data structures exam out of 100. You need to calculate the number of students having backlog (passing marks is >=31) and the average of the class. But this average is not a normal average, for this average marks of students having backlog are not considered but they wi...
["for j in range(int(input())):\n input()\n a = list(map(int,input().split()))\n marks = 0\n backlok = 0\n top_marks = max(a)\n topper = []\n for i in range(len(a)):\n if(a[i] >= 31):\n marks+=a[i]\n if(a[i]<31):\n backlok+=1\n if(a[i] == top_marks):\n topper.append(i)\n print(backlok, \"{:0.2f}\".format(marks...
{"inputs": [["1", "9", "56 42 94 25 74 99 27 52 83"]], "outputs": [["2 55.56", "5", "43", "57", "5", "74", "25", "0", "72", "47", "16"]]}
INTERVIEW
PYTHON3
CODECHEF
916
86a4084ff8565d4e07db5c12623a243a
UNKNOWN
Chef has $N$ boxes arranged in a line.Each box has some candies in it,say $C[i]$. Chef wants to distribute all the candies between of his friends: $A$ and $B$, in the following way: $A$ starts eating candies kept in the leftmost box(box at $1$st place) and $B$ starts eating candies kept in the rightmost box(box at $N$...
["import sys\n\n# stdin = open(\"testdata.txt\", \"r\")\nip = sys.stdin \n\ndef solve(C, n, x):\n if n==1:\n return (1, 0)\n\n b1, b2 = 1, 1\n a , b = C[0], C[-1]\n while b1 + b2 < n:\n if a < b*x:\n a += C[b1]\n b1 += 1\n elif a > b*x:\n b2 += 1\n b += C[n-b2] \n else:\n if b1 >= b2:\n a += C[b1]\n ...
{"inputs": [["1", "5", "2 8 8 2 9", "2"]], "outputs": [["4 1"]]}
INTERVIEW
PYTHON3
CODECHEF
12,618
c4f5eeb7ef015181c3d1b49823a35a44
UNKNOWN
You have a sequence $a$ with length $N$ created by removing some elements (possibly zero) from a permutation of numbers $(1, 2, \dots, N)$. When an element is removed, the length of the sequence doesn't change, but there is an empty spot left where the removed element was. You also have an integer $K$. Let's call a per...
["from itertools import permutations\n\nfor _ in range(int(input())):\n N,K=list(map(int,input().split()))\n arr=list(map(int,input().split()))\n arr1=[]\n arr2=[]\n for i in range(1,len(arr)+1):\n arr1.append(i)\n indexzero=[]\n for i in range(0,len(arr)):\n if(arr[i]==0):\n indexzero.append(i)\n else:\n arr2.a...
{"inputs": [["1", "3 1", "2 0 0"]], "outputs": [["2"]]}
INTERVIEW
PYTHON3
CODECHEF
4,751
24095a7bd03b4e960b2f09faa4c92183
UNKNOWN
$Harshad$ $Mehta$ is planning a new scam with the stocks he is given a stock of integer price S and a number K . $harshad$ has got the power to change the number $S$ at most $K$ times In order to raise the price of stock and now cash it for his benefits Find the largest price at which $harshad$ can sell the stock in ...
["a,b=[int(_) for _ in input().split()]\r\nif b==0:\r\n print(a)\r\nelse: \r\n l=[]\r\n a=str(a)\r\n for i in range(len(a)):\r\n l.append(a[i])\r\n for i in range(len(l)):\r\n if b==0:\r\n break\r\n if l[i]=='9':\r\n continue\r\n else:\r\n l...
{"inputs": [["4483 2"]], "outputs": [["9983"]]}
INTERVIEW
PYTHON3
CODECHEF
7,460
7533fe99aea3e440d4129b7621519831
UNKNOWN
Rahul is a serial killer. Rahul has been betrayed by his lover in the past and now he want to eliminate entire Universe.He has already Eliminated majority of the population and now only a handful number of people are left. Like other Serial killers, he has an interesting pattern of killing people. He either kill one i...
["from math import ceil\r\nt=int(input())\r\nfor i in range(t):\r\n p=int(input())\r\n l=list(map(int,input().split()))\r\n maxx=1\r\n for i in range(len(l)):\r\n maxx=max(maxx,l.count(l[i]))\r\n if(maxx*2>p):\r\n print(maxx)\r\n else:\r\n q=p-maxx*2\r\n...
{"inputs": [["1", "10", "178 184 178 177 171 173 171 183 171 175"]], "outputs": [["5"]]}
INTERVIEW
PYTHON3
CODECHEF
772
75438b511245353451ce12b2918b4f5f
UNKNOWN
Chef recently learned about ratios and proportions. He wrote some positive integers a, b, c, d on a paper. Chef wants to know whether he can shuffle these numbers so as to make some proportion? Formally, four numbers x, y, z, w are said to make a proportion if ratio of x : y is same as that of z : w. -----Input----- O...
["def permutate(arr):\n if len(arr) == 1:\n yield arr\n for x in range(len(arr)):\n for perm in permutate(arr[:x] + arr[x+1:]):\n yield [arr[x]] + perm\n\nvals = [int(x) for x in input().split()]\n\nfounded = False\nfor val in permutate(vals):\n if (val[0] / float(val[1]) == val[2] / float(val[3])):\n print(\"Poss...
{"inputs": [["1 2 4 2"]], "outputs": [["Possible"]]}
INTERVIEW
PYTHON3
CODECHEF
6,195
e2cc78f3f007e25a62bae2f1d548150a
UNKNOWN
Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The secret behind his wickedness is a hidden omen which is a string of length m. On your visit to him, you can ask a lot of questions about your future, each of ...
["t = int(input())\nfor j in range(0, t):\n n = int(input())\n m = 100\n for i in range(0, n):\n str = input()\n p = min(str.count(\"a\",0,len(str)),str.count(\"b\",0,len(str)))\n if (m > p):\n m = p\n print(m)\n t = t-1", "for i in range(int(input())):\n n=int(input())\n li_a=li_b=[]\n for i in range(n):\n ...
{"inputs": [["3", "2", "ab", "ba", "2", "aa", "bb", "3", "aabb", "abab", "baab"]], "outputs": [["1", "0", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
6,907
c63ed3a364fedea94464c128dad4b03e
UNKNOWN
Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G' represents a girl. De...
["def outOfIndex(boys,girls,COST):\n if COST == 0:\n return len(boys)\n else:\n total_cost = [ abs(x-y) for x,y in zip(boys,girls)]\n total_cost = sum(total_cost)\n return total_cost\n\nfor _ in range(int(input())):\n COST = int(input())\n queue = input()\n B = queue.count('B')\n G = queue.count('G')\n boys=[]\n gi...
{"inputs": [["8", "0", "BB", "0", "BG", "0", "BBGG", "1", "BGG", "1", "BGGB", "1", "BBBGG", "2", "BBGG", "2", "BGB"]], "outputs": [["-1", "0", "1", "1", "1", "3", "1", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
14,237
4480764bafe2b8f69908e23b995b35d3
UNKNOWN
Rohit has n empty boxes lying on the ground in a line. The size of the boxes is given in the form of an array $a$. The size of the ith box is denoted by $a[i]$. Since Rohit has a tiny room, there is a shortage of space. Therefore, he has to reduce the number of boxes on the ground by putting a box into another box that...
["n=int(input())\r\nl=[0]*n\r\nfor i in range(n):\r\n l[i]=int(input())\r\nl.sort()\r\ns=0\r\ni=n-1\r\nwhile i>=0:\r\n x=2*l[i]\r\n if l[-1]>=x:\r\n j=i\r\n while j<len(l):\r\n if l[j]>=x:\r\n l.pop(j)\r\n l.pop(i)\r\n s+=1\r\n ...
{"inputs": [["5", "16", "1", "4", "8", "2"]], "outputs": [["3"]]}
INTERVIEW
PYTHON3
CODECHEF
5,262
2d7d124114aa689a11a05ff822bb97ce
UNKNOWN
After completing some serious investigation, Watson and Holmes are now chilling themselves in the Shimla hills. Very soon Holmes became bored. Holmes lived entirely for his profession. We know he is a workaholic. So Holmes wants to stop his vacation and get back to work. But after a tiresome season, Watson is in no moo...
["t=int(input())\nfor i in range(0,t):\n n=int(input())\n lis=list(map(int,input().split()))\n lis2=[]\n for j in range(0,10):\n lis2.append(0)\n for j in range(0,len(lis)):\n lis2[lis[j]]+=1;\n s=sum(lis)\n while s%3!=0:\n if s%3==2:\n if lis2[2]>=1:\n lis2[2]-=1\n s=s-2\n elif lis2[5]>=1:\n lis2[5]-=1...
{"inputs": [["2", "12", "3 1 2 3 2 0 2 2 2 0 2 3", "11", "3 9 9 6 4 3 6 4 9 6 0"]], "outputs": [["33322222200", "999666330"]]}
INTERVIEW
PYTHON3
CODECHEF
23,354
1d9aa9c585e8f140147654c582156641
UNKNOWN
Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: - Let's call the nodes' level a number of nodes that occur on the way to this node from the root, including this node. This w...
["# cook your dish here\nMOD=10**9+7\nfor _ in range(int(input())):\n s=input()\n ind=1\n level=1\n for i in range(len(s)):\n if s[i]=='l':\n if level%2==1:\n ind=ind*2\n else:\n ind=ind*2-1\n if s[i]=='r':\n if level%2==1:\n ...
{"inputs": [["4", "lrl", "rll", "r", "lllr", ""]], "outputs": [["10", "14", "4", "13"]]}
INTERVIEW
PYTHON3
CODECHEF
3,643
6a6ba32420fe2445951534860fc213f0
UNKNOWN
Divya's watch of worth Rs10 cr is abducted by N thieves(1,2....i...N). The fight over the watch leads to a final decision that it should belong to the thief who wins a simple game. The rules of the game state that every thief registers a time in the format HH:MM:SS . Accordingly the average A of three clockwise angles...
["for t in range(int(input())):\n n = int(input())\n mx = -1\n for i in range(n):\n h, m, s = list(map(int,input().split(\":\")))\n h %= 12\n m %= 60\n s %= 60\n ha = h*30 + m*0.5 + s*0.5/60\n ma = m*6 + s*0.1\n sa = s*6\n \n hm1 = abs(ha - ma)\n hm2 = 360 - hm1\n hm3 = abs(hm1 - hm2)\n hm = min(hm1, hm2, h...
{"inputs": [["2", "3", "12:28:26", "07:26:04", "11:23:17", "2", "07:43:25", "06:23:34"]], "outputs": [["3", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
1,142
619349a52ded51453fe9ced7fbd5a74d
UNKNOWN
Ash is on his way to becoming the Pokemon Master. His pokemon can perform the following moves: - Tackle - Deal damage worth $X$ points - Grow - Increase damage by $Y$ points i.e. $X$ = $X$ + $Y$ But, it can only perform Grow first (0 or more times) and then tackle (0 or more) times after which it cannot perform Gr...
["def Testcase():\n h,x,y = [int(x) for x in input().strip().split()]\n \n h = h-1\n yt = h//y +1\n # print(yt)\n flag=0\n ans = 100000000009\n \n for i in range(0,yt):\n temp = x+i*y\n if h%temp==0:\n flag = 1\n cl =i+int(h/temp)\n # print(temp,cl)...
{"inputs": [["2", "101 10 10", "11 3 3"]], "outputs": [["6", "-1"]]}
INTERVIEW
PYTHON3
CODECHEF
9,967
f59c1801f26eb3e916fc3a687cc21d72
UNKNOWN
Given $N *M$ matrix containing elements either $1$ or $0$ and string S of length $N+M-1$ containing characters $0$ or $1$. Your task is to make all the paths from top left corner to the bottom right corner of the matrix same as the given string .You can perform two types of operations any time .Path means you can on...
["from sys import stdin,stdout\nimport math,bisect\nfrom collections import Counter,deque,defaultdict\nL=lambda:list(map(int, stdin.readline().strip().split()))\nM=lambda:list(map(int, stdin.readline().strip().split()))\nI=lambda:int(stdin.readline().strip())\nS=lambda:stdin.readline().strip()\nC=lambda:stdin.readline(...
{"inputs": [["2", "3 3", "1 0 1", "0 1 1", "1 1 0", "10111", "10 5", "3 3", "0 0 1", "0 1 1", "0 1 1", "00011", "2 9"]], "outputs": [["5", "4"]]}
INTERVIEW
PYTHON3
CODECHEF
7,358
2afd18cce01f36b8721129070ca63377
UNKNOWN
A valid parentheses sequence is a non-empty string where each character is either '(' or ')', which satisfies the following constraint: You can find a way to repeat erasing adjacent pairs of parentheses '()' until it becomes empty. For example, '(())' and '()((()()))' are valid parentheses sequences, but ')()(' and...
["try:\n for i in range(int(input())):\n s=input()\n balance=0\n max_balance=0\n for i in s:\n if i=='(':balance+=1\n else:\n balance-=1\n max_balance=max(max_balance,balance)\n print('('*max_balance,')'*max_balance,sep=\"\")\nexcept ...
{"inputs": [["1", "()((()()))", "", ""]], "outputs": [["((()))"]]}
INTERVIEW
PYTHON3
CODECHEF
6,696
cb26dcda763bfea022cdeda68e8f4274
UNKNOWN
Given a Complete Binary Tree of ‘n’ depth, you can perform 4 types of mirror operation on the tree:- Mirror on the right. The tree is mirrored to the right and rightmost node on every level is connected with the mirrored corresponding node. Mirror on the left. The tree is mirrored to the left and leftmost node on eve...
["import os,sys\nfrom io import BytesIO, IOBase\n\ndef ii(): return int(input())\ndef si(): return input()\ndef mi(): return list(map(int,input().split()))\ndef li(): return list(mi())\nimport math \n\nimport collections \n\ndef CountFrequency(arr): \n return collections.Counter(arr) \n\nfor i in range(1):\n n,q=mi()\n...
{"inputs": [["2 3", "1 1", "1 4", "2"]], "outputs": [["38"]]}
INTERVIEW
PYTHON3
CODECHEF
9,196
2bd5d3acbad9c9fbcbb4c676dba9e588
UNKNOWN
Your are given a string $S$ containing only lowercase letter and a array of character $arr$. Find whether the given string only contains characters from the given character array. Print $1$ if the string contains characters from the given array only else print $0$. Note: string contains characters in lower case only. ...
["t=int(input())\r\nfor _ in range(t):\r\n S=set(input().strip())\r\n n=int(input().strip())\r\n a=set(input().strip().split(\" \"))\r\n g=True\r\n for i in S:\r\n if(i not in a):\r\n g=False\r\n if(g):\r\n print(1)\r\n else:\r\n print(0)", "t=int(input())\r\nfor _ i...
{"inputs": [["3", "abcd", "4", "a b c d", "aabbbcccdddd", "4", "a b c d", "acd", "3", "a b d"]], "outputs": [["1", "1", "0"]]}
INTERVIEW
PYTHON3
CODECHEF
5,784
f149fd5397256fc23d63c1825d631c2b
UNKNOWN
Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it is rectangular in nature. Santosh comes to know that he will get m...
["# cook your dish here\nimport math\nN=int(input())\nfor i in range(N):\n a,b=list(map(int,input().split()))\n c=a//math.gcd(a,b)*b//math.gcd(a,b)\n print(c)\n \n", "# cook your dish here\n\nimport math\nt=int(input())\n\nfor i in range(t):\n n,m=list(map(int,input().split()))\n \n print(n//math.gcd(n,m)*m//math.gcd(n...
{"inputs": [["2", "10 15", "4 6"]], "outputs": [["6", "6"]]}
INTERVIEW
PYTHON3
CODECHEF
3,513
16a188b4d2cc295f0620f2e0591e802b
UNKNOWN
To make Yalalovichik even more satisfied and happy, Jafar decided to invent Yalalovichik strings. A string is called a Yalalovichik string if the set of all of its distinct non-empty substrings is equal to the set of all of its distinct non-empty subsequences. You are given a string S$S$. You need to find the number o...
["for _ in range(int(input())):\n n,s = int(input()),input().strip()\n previ,num,_s,dic = s[0],0,[],{}\n for i in s:\n if previ == i:\n num+=1\n continue\n _s.append((previ, num))\n if previ not in dic or dic[previ]<num:dic[previ] = num\n previ,num = i,1\n _s.append((previ, num))\n...
{"inputs": [["1", "3", "xxx"]], "outputs": [["3"]]}
INTERVIEW
PYTHON3
CODECHEF
1,950
5d44f2266bbdace3f6ab0fa88f221a9c
UNKNOWN
Zonal Computing Olympiad 2012, 26 Nov 2011 A sequence of opening and closing brackets is well-bracketed if we can pair up each opening bracket with a matching closing bracket in the usual sense. For instance, the sequences (), (()) and ()(()) are well-bracketed, while (, ()), (()(), and )( are not well-bracketed. T...
["# cook your dish here\n\nT = int(input())\nl = list(map(int, input().strip().split(\" \")))\n\ndepth = 0\nmax_depth = 0\nmax_depth_index = 0\n\nmax_l=0\nmax_l_index=0\nlast_zero=-1\n\nfor i in range(T):\n if l[i] == 1:\n depth += 1\n if depth > max_depth:\n max_depth = depth\n m...
{"inputs": [["20", "1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2"]], "outputs": [["2 4 6 9"]]}
INTERVIEW
PYTHON3
CODECHEF
14,200
cbc6095828db1e523f0cb3920b1de5a6
UNKNOWN
Cherry has a binary matrix $A$ consisting of $N$ rows and $M$ columns. The rows are numbered from $1$ to $N$, columns are numbered from $1$ to $M$. Element at row $i$ ($1$ ≤ $i$ ≤ $N$) and column $j$ ($1$ ≤ $j$ ≤ $M$) is denoted as $A_{ij}$. All elements of $A$ are either $0$ or $1$. He performs $Q$ queries on matrix. ...
["import sys,os,io,time,copy,math,queue,bisect\nfrom collections import deque\nfrom functools import lru_cache\n\nif os.path.exists('input.txt'):\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w') \n\nsys.setrecursionlimit(100000000)\n\ndef main():\n n,m=map(int,input().split())\n mat=[]\n for ...
{"inputs": [["2 2", "00", "00", "3", "1 1 1 1", "2 2 2 2", "1 1 2 2"]], "outputs": [["01", "10"]]}
INTERVIEW
PYTHON3
CODECHEF
17,725
877404165b306960c8017d6f2a266247
UNKNOWN
You are given a grid with dimension $n$ x $m$ and two points with coordinates $X(x1,y1)$ and $Y(x2,y2)$ . Your task is to find the number of ways in which one can go from point $A(0, 0)$ to point $B (n, m)$ using the $shortest$ possible path such that the shortest path neither passes through $X$ nor through $Y$. Cons...
["#dt = {} for i in x: dt[i] = dt.get(i,0)+1\r\nimport sys;input = sys.stdin.readline\r\ninp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]\r\n\r\nN = 100001\r\np = 998244353\r\nfactorialNumInverse = [0]*(N+1) \r\nnaturalNumInverse = [0]*(N+1)\r\nfact = [0]*(N+1)\r\n \r\ndef InverseofNumber(p): \r...
{"inputs": [["1", "3 3 1 1 1 2"]], "outputs": [["5"]]}
INTERVIEW
PYTHON3
CODECHEF
1,471
ea44ccd542458169f71b809c532785dd
UNKNOWN
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test cases. Then the test cases follow. - Each test case contains a single line of...
["# cook your dish here\nfor _ in range(int(input())):\n n=int(input())\n if n==1:\n print(\"0\")\n else:\n s=[]\n for i in range(n):\n s.append(str(i))\n print(''.join(s))\n p=1\n for i in range(n-1):\n s.pop(n-1)\n s=[str(p)]+s\n ...
{"inputs": [["4", "1", "2", "3", "4"]], "outputs": [["0", "01", "10", "012", "101", "210", "0123", "1012", "2101", "3210"]]}
INTERVIEW
PYTHON3
CODECHEF
5,219
6753bea5ef1ad6c77d70c73a8bb13373
UNKNOWN
The Siruseri amusement park has a new attraction. It consists of a rectangular array of discs. Each disc is divided into four equal sectors and the four sectors are coloured with the colours Red, Blue, Green and Yellow (in some order). The ordering may be different in different discs. Here is a possible arrangment of t...
["#for _ in range(int(input()):\n#n,m = map(int,input().split())\n#x = [int(w) for w in input().split()]\n#n = int(input())\n#x = [int(input()) for _ in range(n)]\n#for i in range(n):\n#dt = {} for i in x:dt[i] = dt.get(i,0)+1\n#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}\n\nm,n = map(int,input().split(...
{"inputs": [["2 4", "G Y B R", "B G R Y", "G Y B R", "G R B Y", "B Y G R", "G B R Y", "B R G Y", "B R G Y"]], "outputs": [["2"]]}
INTERVIEW
PYTHON3
CODECHEF
3,707
49fd12f8a557de187d97f78570e39cd8
UNKNOWN
You are playing a game where you have been sent in a town to collect 10 types of coin and their symbol are defined with $A, B, C, D, E, F, G, H , I, J$. In that town every enemy have a coin. By killing one you will get a coin from that enemy. Each enemy have only a unique coin. The challange of the game is You have to ...
["for _ in range(int(input())):\n s = input()\n c = 0\n for i in s:\n if i.isalpha() and i.isupper():\n c += 1\n print(c)\n", "for _ in range(int(input())):\n str=input()\n c=0\n for i in range(len(str)):\n if((str[i]>='A' and str[i] <= 'J')):\n c+=1 \n print(c) \n\n \n", "# cook your dish here\ntry:\n for _ in ...
{"inputs": [["1", "ABCDEFGHIJ"]], "outputs": [["10"]]}
INTERVIEW
PYTHON3
CODECHEF
4,078
d83b00b8d1b08b7213c8b507907298be
UNKNOWN
Chef loves to play with iron (Fe) and magnets (Ma). He took a row of $N$ cells (numbered $1$ through $N$) and placed some objects in some of these cells. You are given a string $S$ with length $N$ describing them; for each valid $i$, the $i$-th character of $S$ is one of the following: - 'I' if the $i$-th cell contains...
["# cook your dish here\n# cook your dish here\nfor _ in range(int(input())) :\n n,k=map(int,input().split())\n #reading the string \n s=input()\n i,j=0,0\n q=0\n while(i<n and j<n) :\n if(s[i]=='M') :\n if(s[j]=='I') :\n cnt=0\n if(i>j) :\n p=s[j:i]\n cnt=p.count(':')\n else :\n p=s[i:j]\n ...
{"inputs": [["2", "4 5", "I::M", "9 10", "MIM_XII:M"]], "outputs": [["1", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
15,796
e1784e02dd451f88772b8d26d54bc6de
UNKNOWN
Tuzik and Vanya are playing the following game. They have an N × M board and a chip to indicate the current game position. The chip can be placed on any one cell of the game board, each of which is uniquely identified by an ordered pair of positive integers (r, c), where 1 ≤ r ≤ N is the row number and 1 ≤ c ≤ M is the...
["cases = int(input())\nfor _ in range(cases):\n rows, cols = map(int, input().split())\n if (cols - 1) % 3 == 0 and (rows - 1) % 4 == 0: print('Vanya')\n elif (cols - 1) % 3 != 0 and (rows - 1) % 4 == 0: print('Tuzik')\n elif (cols - 1) % 3 == 0 and (rows - 1) % 4 != 0: print('Tuzik')\n else:\n if (cols - 1) % 3 == 1...
{"inputs": [["2", "4 4", "2 2"]], "outputs": [["Tuzik", "Vanya"]]}
INTERVIEW
PYTHON3
CODECHEF
454
ab87299bbaf606fba9394e4f51e252cc
UNKNOWN
Ishank lives in a country in which there are N$N$ cities and N−1$N-1$ roads. All the cities are connected via these roads. Each city has been assigned a unique number from 1 to N$N$. The country can be assumed as a tree, with nodes representing the cities and edges representing the roads. The tree is rooted at 1.Every ...
["# cook your dish here\ntry:\n X=list(map(int, input().split()))\nexcept:\n X=[0,0]\nch=[]\nchnew=[]\npar={}\npar[1]=0\nfor i in range(X[0]+1):\n ch.append([])\n chnew.append([])\nfor i in range(X[0]-1):\n Y=list(map(int, input().split()))\n #par[Y[1]]=[Y[0],Y[2]]\n ch[Y[0]].append([Y[1],Y[2]])\n ...
{"inputs": [["9 5", "1 2 8", "1 3 -9", "2 4 1", "2 5 -6", "3 6 7", "3 7 6", "6 8 3", "6 9 4", "1 2", "2 7", "4 3", "3 2", "8 9"]], "outputs": [["10", "5", "0", "-1", "21"]]}
INTERVIEW
PYTHON3
CODECHEF
10,143
957536defd956ef5f9d408e019e1b2f8
UNKNOWN
Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-negative integers (a0,b0,c0)$(a_0, b_0, c_0)$ and told Chef to convert it to ...
["for _ in range(int(input())):\n a,b,c,x,y,z = list(map(int,input().split()))\n if a == 0 and b == 0 and c == 0 and x == 0 and y == 0 and z == 0:\n print(0)\n continue\n ans = 0\n if a == 0 and b == 0 and c == 0:\n st = set((abs(x-a)%2,abs(y-b)%2,abs(z-c)%2))\n if st == {0,1}:\n ans = ...
{"inputs": [["2", "1 1 1 2 2 2", "1 2 3 2 4 2"]], "outputs": [["0", "1"]]}
INTERVIEW
PYTHON3
CODECHEF
2,313
561be8206d334177d42e3a20dcd5d7c8
UNKNOWN
Chefina is always interested to play with string. But due to exam pressure she has no time to solve a string problem. She wants your help. Can you help her to solve that problem? You are given a string. You have to find out the $Wonder$ $Sum$ of the string. $Wonder$ $Sum$ of a string is defined as the sum of the valu...
["for _ in range(int(input())):\n string = input().rstrip()\n start=(ord(string[0])-96)*100\n sum=0\n #print(start)\n for i in range(len(string)):\n sum+=start+(ord(string[i])-97)\n print(sum%1000000007)", "for _ in range(int(input())):\r\n\ts = input()\r\n\tres = 0\r\n\tcnt = 0\r\n\tfor c in s...
{"inputs": [["2", "cab", "sdef"]], "outputs": [["903", "7630"]]}
INTERVIEW
PYTHON3
CODECHEF
2,836
9b74a837ca8352d9d39c0397b729b574
UNKNOWN
Chef wants to make a feast. In order to do that, he needs a lot of different ingredients. Each ingredient has a certain tastiness; the tastiness of each ingredient may be any positive integer. Initially, for each tastiness between $K$ and $K+N-1$ (inclusive), Chef has an infinite supply of ingredients with this tastine...
["__author__ = 'Prateek'\n\nMOD = int(10**9+7)\n\ndef test():\n n,k=list(map(int,input().split()))\n l = k\n d =n-1\n ans = l-1\n ans = ans%MOD\n a = k-n\n term = (d+a)//d\n ll = (a%MOD - (((term-1)%MOD)*(d%MOD))%MOD)%MOD\n if ll < 0:\n ll = (ll +MOD)%MOD\n m = ((term%MOD)*((a%MOD+ll%MOD)%MOD))%MOD\n m = (m*pow(2,MOD-...
{"inputs": [["2", "2 1", "3 3"]], "outputs": [["0", "2"]]}
INTERVIEW
PYTHON3
CODECHEF
8,642
6410eeba574bcd87e52c5dfd68bbea11
UNKNOWN
Consider a number X on which K Mag-Inc operations are to be performed. In a Mag-Inc operation, the number X undergoes an increment of A/B times of X where A and B are two integers. There is a numerator and a denominator array of size K which contain the ith values of A and B. After K Mag-Inc operations, the number X t...
["import sys\nimport math\n\ndef solution():\n T = int(input().strip())\n for _ in range(T):\n x, k = list(map(float, input().strip().split(' ')))\n original_x = x\n if k == 1:\n a = [float(input().strip())]\n b = [float(input().strip())]\n else:\n a = list(map(float, input().strip().split(' ')))\n b = list...
{"inputs": [["2", "100 1", "1", "4", "100 2", "1 1", "2 3"]], "outputs": [["20", "50"]]}
INTERVIEW
PYTHON3
CODECHEF
2,250