source
stringclasses
4 values
task_type
stringclasses
1 value
in_source_id
stringlengths
0
138
problem_statement
stringlengths
219
13.2k
gold_standard_solution
stringlengths
0
413k
problem_id
stringlengths
5
10
metadata
dict
verification_info
dict
apps
verifiable_code
1086
Solve the following coding problem using the programming language python: Let's define the niceness of a sequence of positive integers X1,X2,…,XN$X_1, X_2, \dots, X_N$ as the sum of greatest common divisors of all pairs of its elements, i.e. N∑i=1N∑j=i+1gcd(Xi,Xj).∑i=1N∑j=i+1Ngcd(Xi,Xj).\sum_{i=1}^N \sum_{j=i+1}^N \ma...
```python # cook your dish here mod = 10**9 + 7 from math import gcd def fac50(): f = [0]*51 f[0] ,f[1] = 1,1 for i in range(1,51):f[i] = (f[i-1]*i)%mod return f def gcd110(): gc = [[0]*111 for i in range(111)] for i in range(111): for j in range(111):gc[i][j] = gcd(i,j) return gc fa...
vfc_3186
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NICARRAY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3\n1 1 -1\n4 8\n1 -1 -1 3\n3 10\n-1 -1 -1\n\n", "output": "3\n23\n150\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1087
Solve the following coding problem using the programming language python: You are given an unweighted, undirected graph. Write a program to check if it's a tree topology. -----Input----- The first line of the input file contains two integers N and M --- number of nodes and number of edges in the graph (0 < N <= 1000...
```python #!/usr/bin/env python def iscycle(E, v, EXPLORED_NODES, EXPLORED_EDGES): EXPLORED_NODES.add(v) r = False for e in [x for x in E if v in x]: if e in EXPLORED_EDGES: continue if e[0] == v: w = e[1] else: w = e[0] if w in EXPLORED_NODES: return True else: EXPLORED_EDGES.add(e) r = ...
vfc_3190
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PRFT2012/problems/PD31", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 2\n1 2\n2 3\n", "output": "YES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1088
Solve the following coding problem using the programming language python: Two cheeky thieves (Chef being one of them, the more talented one of course) have came across each other in the underground vault of the State Bank of Churuland. They are shocked! Indeed, neither expect to meet a colleague in such a place with t...
```python t=int(input()) while(t): s=input().split() m=int(s[0]) p=float(s[1]) if(m%2==0): r=(1-p**m)/(p+1) else: r=(1+p**m)/(p+1) print(1000000000*r,1000000000*(1-r)) t-=1 ```
vfc_3194
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BANROB", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 0.5\n2 0.5\n", "output": "1000000000.0 0.0\n500000000.0 500000000.0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1089
Solve the following coding problem using the programming language python: The garden has a tree with too many leaves on it and gardner wants to cut the unwanted leaves. This is a rooted tree, where a node $v$ is called parent of another node $u$, if there exists a directed edge from $v$ to $u$. Leaf node is a node wit...
```python def dfs(node): nonlocal adj,leaf val=0 flag=0 for i in adj[node]: x= dfs(i) val+=x if x==0: flag=1 leaf+=val-val%3 if val%3==0 and flag==0: return 1 else: return 0 for _ in range(int(input())): n=int(input()) adj=[[] for i in range(n+2)] arr=[int(i) for i in input().split()] leaf=0 #p...
vfc_3198
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ECPG2020/problems/ECPC10D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n13\n1 1 1 1 1 4 3 4 4 3 4 3\n", "output": "4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1090
Solve the following coding problem using the programming language python: You are given a sequence of n integers a1, a2, ..., an and an integer d. Find the length of the shortest non-empty contiguous subsequence with sum of elements at least d. Formally, you should find the smallest positive integer k with the followi...
```python # cook your dish here import collections def shortestSubarray(A, K): N = len(A) P = [0] for x in A: P.append(P[-1] + x) #Want smallest y-x with Py - Px >= K ans = N+1 # N+1 is impossible monoq = collections.deque() #opt(y) candidates, represented as indices             of P for y, P...
vfc_3202
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MINSUBAR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5\n1 2 3 1 -5\n5 1\n1 2 3 1 -5\n", "output": "2\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1091
Solve the following coding problem using the programming language python: Rupsa really loves triangles. One day she came across an equilateral triangle having length of each side as an integer N. She started wondering if it was possible to transform the triangle keeping two sides fixed and alter the third side such th...
```python # cook your dish here import math def isPos(num): if num%2==0: for i in range(num,2*num,1): if ((num**2)-((i/2)**2))**(1/2)==int(((num**2)-((i/2)**2))**(1/2)): return 'YES' return 'NO' else: for i in range(num+1,2*num,1): if ((num**2)-((i/2)**2))**(1/2)==int(((num**2)-((i/2)**2))**(1/2)): ...
vfc_3206
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADTRI", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n3\n", "output": "YES\nNO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1092
Solve the following coding problem using the programming language python: The faculty of application management and consulting services (FAMCS) of the Berland State University (BSU) has always been popular among Berland's enrollees. This year, N students attended the entrance exams, but no more than K will enter the u...
```python # cook your dish here t=int(input()) for i in range(t): (n,k,e,m)=tuple(map(int,input().split())) scores=[] for j in range(n-1): scores.append(sum(list(map(int,input().split())))) scores.sort(reverse=True); bsc=scores[k-1]; msc=sum(list(map(int,input().split()))) mini=bsc-msc+1 if(mini<0): print(0...
vfc_3210
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ENTEXAM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2 3 10\n7 7 7\n4 6 10\n7 10 9\n9 9\n", "output": "4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1093
Solve the following coding problem using the programming language python: Chef likes toys. His favourite toy is an array of length N. This array contains only integers. He plays with this array every day. His favourite game with this array is Segment Multiplication. In this game, the second player tells the left and r...
```python # # # # n = int(input()) # # # # arr = list(map(int , input().split())) # # # # for _ in range(int(input())): # # # # l,r,mod = map(int , input().split()) # # # # pro = 1 # # # # for i in range(l - 1,r): # # # # pro *= arr[i] # # # # print(pro % mod) #sample testcases passed #TLE # # # import nu...
vfc_3214
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHMOD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 2 3 4 5\n4\n1 2 3\n2 3 4\n1 1 1\n1 5 1000000000\n", "output": "2\n2\n0\n120\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1094
Solve the following coding problem using the programming language python: Two words rhyme if their last 3 letters are a match. Given N words, print the test case number (of the format Case : num) followed by the rhyming words in separate line adjacent to each other. The output can be in anyorder. -----Input----- Fir...
```python t = int(input()) for i in range(t): n = int(input()) suffixes = {} xx = input().split() for x in range(n): try: a = suffixes[xx[x][-3:]] except Exception as e: a = [] a.append(xx[x]) suffixes.update({xx[x][-3:]: a}) print("Case : %d" % (i + 1)) for a in sorted(suffixes): print("".join(...
vfc_3218
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COWA2016/problems/CWAM1502", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\nnope qwerty hope\n5\nbrain drain request grain nest\n4\nthese words dont rhyme\n", "output": "Case : 1\nhope nope\nqwerty\nCase : 2\nbrain drain grain\nnest request\nCase : 3\nthese\ndont\nwords\nrhyme\n", "type":...
apps
verifiable_code
1095
Solve the following coding problem using the programming language python: Indraneel has to sort the books in his library. His library has one long shelf. His books are numbered $1$ through $N$ and he wants to rearrange the books so that they appear in the sequence $1,2, ..., N$. He intends to do this by a sequence of ...
```python n=int(input()) arr=[int(x) for x in input().split()] l=[1]*n if sorted(arr)==arr: print('0') else: for i in range(0,len(arr)): for j in range(i): if arr[i]>=arr[j] and l[i]<l[j]+1: l[i]=l[j]+1 print(n-max(l)) ```
vfc_3222
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IARCSJUD/problems/BOOKSORT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n2 1 4 5 3\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1096
Solve the following coding problem using the programming language python: Zonal Computing Olympiad 2012, 26 Nov 2011 The year is 2102 and today is the day of ZCO. This year there are N contests and the starting and ending times of each contest is known to you. You have to participate in exactly one of these contests....
```python import sys n, x, y = input().split(' ') n = int(n) x = int(x) y = int(y) contests = {} for i in range(n): s, e = input().split(' ') s = int(s) e = int(e) contests[(s, e)] = abs(s-e) v_time = input().split(' ') w_time = input().split(' ') v_time, w_time = list(map(int, v_time)), list(map(int, w_time)) v...
vfc_3226
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO12002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 4 2\n15 21\n5 10\n7 25\n4 14 25 2\n13 21\n", "output": "8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1097
Solve the following coding problem using the programming language python: Sinchan and his friends loves to eat. They have a 2D rectangular cake which they want to share. Sinchan is very kind and offers his friends to eat the cake first, all friends goes one by one to eat the cake. Each friend will cut cake into two pa...
```python testcases=int(input()) results=[] for i in range(0,testcases): friends=int(input()) l,b=list(map(int,input().split())) over=False if b>l: temp=b b=l l=temp for counter in range(0,friends): if l==b: over=True break elif l>b: l=l-b if b>l: temp=b b=l l=temp if over: ...
vfc_3230
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDGO2016/problems/CDGO1601", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n5 3\n4\n4 8\n1\n1 2\n", "output": "Yes 2\nNo\nYes 1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1098
Solve the following coding problem using the programming language python: Chef and Roma are playing a game. Rules of the game are quite simple. Initially there are N piles of stones on the table. In each turn, a player can choose one pile and remove it from the table. Each player want to maximize the total number of s...
```python # cook your dish here for i in range(int(input())): n = int(input()) l = list(map(int,input().split())) s = 0 l.sort(reverse = True) for i in range(0,n,2): s = s+l[i] print(s) ```
vfc_3234
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFA", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 2 3\n3\n1 2 1\n", "output": "4\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1099
Solve the following coding problem using the programming language python: Did you know that there are over 40,000 varieties of Rice in the world ? There are so many dishes that can be prepared with Rice too. A famous chef from Mumbai, Tid Gusto prepared a new dish and named it 'Tid Rice'. He posted the recipe in his n...
```python import sys def f(p): votes = {} for x in range(p): str = sys.stdin.readline() t = str.split() votes[t[0]] = t[1] ans = 0 for per in votes: if votes[per] == "+": ans= ans+1 else: ans = ans-1 return ans x = sys.stdin.readline() for t in range(int(x)): p = sys.stdi...
vfc_3238
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK10/problems/TIDRICE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\ntilak +\ntilak +\ntilak -\ntilak +\n3\nratna +\nshashi -\nratna -\n3\nbhavani -\nbhavani +\nbhavani -\n", "output": "1\n-2\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1100
Solve the following coding problem using the programming language python: This question is similar to the $"Operation$ $on$ $a$ $Tuple"$ problem in this month's Long Challenge but with a slight variation. Consider the following operations on a triple of integers. In one operation, you should: - Choose a positive int...
```python # cook your dish here """ Input: The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first line of each test case contains three space-separated integers p, q and r. The second line contains three space-separated integers a, b...
vfc_3242
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENJU2020/problems/ECJN201", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 2 1\n3 3 2\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1101
Solve the following coding problem using the programming language python: After failing to clear his school mathematics examination, infinitepro decided to prepare very hard for his upcoming re-exam, starting with the topic he is weakest at ― computational geometry. Being an artist, infinitepro has C$C$ pencils (numbe...
```python from collections import Counter from math import factorial def nc3(n): a=factorial(n) b=factorial(n-3) return ((a)/(b*6)) def rem(s,k): t=-1 x=-1 for i in range(len(s)): if s[i][0]>2 and s[i][1]<=k: if s[i][0]>3: ch=(nc3(s[i][0])-nc3(s[i]...
vfc_3246
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ACCBIP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7 2 13\n1 10 1\n1 14 2\n6 4 1\n2 2 1\n0 12 2\n2 11 2\n0 6 1\n8 10\n6 1 20\n1 5 1\n2 11 1\n4 0 1\n6 8 1\n0 11 1\n3 3 1\n9\n", "output": "2\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1102
Solve the following coding problem using the programming language python: On Miu's smart phone, there is a search feature which lets her search for a contact name by typing digits on the keypad where each digit may correspond to any of the characters given below it. For example, to search for TOM, she can type 866 and...
```python for _ in range(int(input())): n=int(input()) n1=0 ans=1 while(n>0): d=int(n % 10) if(d!=0): if(d!=9 and d!=7 and d!=1): n1=3 elif(d==1): n1=1 else: n1=4 ans=(int(ans)*int(n1))% (1000000007) n/=10 else: n/=10 if(ans==1): print("0") else: print(ans %(1000000007)) `...
vfc_3250
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/TCFL2020/problems/TCFL20C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n72\n", "output": "3\n12\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1103
Solve the following coding problem using the programming language python: Leha is a bright mathematician. Today he is investigating whether an integer is divisible by some square number or not. He has a positive integer X represented as a product of N integers a1, a2, .... aN. He has somehow figured out that there exi...
```python import sys import math r=int(input()) for v in range (0,r): n = int(input()) x=1 arr=list(map(int,input().strip().split(" "))) for i in range (0,n): x=x*arr[i] for i in range (2,100000000): if(x%(pow(i,2))==0): ans1=i break print(ans1) ```
vfc_3254
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LTIME37/problems/SQNUMBF", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n21 11 6\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1104
Solve the following coding problem using the programming language python: Kabir Singh is playing a game on the non-negative side of x-axis. It takes him $1 second$ to reach from Pth position to (P−1)th position or (P+1)th position. Kabir never goes to the negative side and also doesn't stop at any moment of time. Th...
```python # cook your dish here T=int(input()) MOD=int(1e9+7) for t in range(T): N,K=[int(a) for a in input().split()] M=K//2 # ans= ((K%2)?( (N+M)*(N+M) + M ):( (N+M)*(N+M) - M) ) ans=(N+M)*(N+M) -M if(K%2): ans+=2*M if(N==0): ans=K*(K-1) print(ans%MOD) ```
vfc_3258
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LDT42020/problems/WALKREC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n0 1\n1 1\n1 3\n4 6\n", "output": "0\n1\n5\n46\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1105
Solve the following coding problem using the programming language python: Chef Ada is preparing $N$ dishes (numbered $1$ through $N$). For each valid $i$, it takes $C_i$ minutes to prepare the $i$-th dish. The dishes can be prepared in any order. Ada has a kitchen with two identical burners. For each valid $i$, to pre...
```python for i in range(int(input())): n=int(input()) c=[int(z) for z in input().split()] c.sort() c.reverse() b1,b2=0,0 for i in range(n): if b1<b2: b1+=c[i] elif b2<b1: b2+=c[i] else: b1+=c[i] print(max(b1,b2)) ```
vfc_3262
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADADISH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n2 2 2\n3\n1 2 3\n4\n2 3 4 5\n", "output": "4\n3\n7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1106
Solve the following coding problem using the programming language python: A long way back I have taken $5000 from Golu when I used to live in Jodhpur. Now, time has passed and I am out of Jodhpur. While Golu still in Jodhpur, one day called me and asked about his money. I thought of giving Golu a chance. I told him th...
```python '''Well I found the bug, but I don't understand why it was doing that. I mean, as far as I can tell, it shouldn't be a bug! Note to self: deleting from (supposedly) local lists through recursion is dangerous!''' class Group(object): def __init__(self,size,start,end,value): self.size = size ...
vfc_3266
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IGNS2012/problems/IG02", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5 4\n2 1 5 50\n1 2 4 20\n2 3 4 40\n2 4 5 50\n3 4 5 80\n10 10 5\n2 5 10 17300\n2 1 8 31300\n5 4 10 27600\n4 8 10 7000\n5 9 10 95900\n2 7 10 14000\n3 6 10 63800\n1 7 10 19300\n3 8 10 21400\n2 2 10 7000\n", "output": "140\n...
apps
verifiable_code
1107
Solve the following coding problem using the programming language python: Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422. Help him to count the sum of goodn...
```python # cook your dish here from sys import stdin from math import sqrt,ceil,log10 def get_sum(a,b,digits): sum=((b+a)*(b-a+1))//2 return sum*digits def solve(): mod=10**9+7 thehighlimiter={i: 10 ** i - 1 for i in range(12)} thelowlimiter={i: 10**i for i in range(12)} for _ in range(int(inp...
vfc_3270
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PPNUM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n9 12\n\n\n", "output": "75\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1108
Solve the following coding problem using the programming language python: There were $N$ students (numbered $1$ through $N$) participating in the Indian Programming Camp (IPC) and they watched a total of $K$ lectures (numbered $1$ through $K$). For each student $i$ and each lecture $j$, the $i$-th student watched the ...
```python N,M,K=map(int,input().split()) c=0 for i in range(N): T=list(map(int,input().split())) Q=T[-1] T.pop(-1) if Q<=10 and sum(T)>=M: c+=1 print(c) ```
vfc_3274
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/IPCCERT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 8 4\n1 2 1 2 5\n3 5 1 3 4\n1 2 4 5 11\n1 1 1 3 12\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1109
Solve the following coding problem using the programming language python: Sumit and Dhiraj are roommates in a hostel of NIT Jamshedpur,One day after completing there boring assignments of Artificial Intelligence, they decided to play a game as it was dhiraj,s idea to play a game so he started explaining the rules of t...
```python import math for t in range(int(input())): n = int(input()) temp = math.sqrt(n) if (temp == int(temp)): print("YES") else: print("NO") ```
vfc_3278
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COYA2016/problems/CDYPA01", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n5\n", "output": "YES\nNO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1110
Solve the following coding problem using the programming language python: You are given an array of integers [A1,A2,…,AN]$[A_1, A_2, \ldots, A_N]$. Let's call adding an element to this array at any position (including the beginning and the end) or removing an arbitrary element from it a modification. It is not allowed...
```python # cook your dish here for _ in range(int(input())): n=int(input());li=list(map(int,input().split()));dli=dict();modi=0 for i in li: if i not in dli:dli[i]=1 else:dli[i]+=1 op=sorted(list(dli)) if(len(dli)!=0): while 1: tmp=[] for i in op: if dli[i]==0:continue...
vfc_3282
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PERMPART", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 4 1 2 2\n4\n2 3 2 3\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1111
Solve the following coding problem using the programming language python: Using his tip-top physique, Kim has now climbed up the mountain where the base is located. Kim has found the door to the (supposedly) super secret base. Well, it is super secret, but obviously no match for Kim's talents. The door is guarded by ...
```python # cook your dish here for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) even=[] odd=[] for i in a: if(i & 1): even.append(i) else: odd.append(i) print(len(even)*len(odd)) ```
vfc_3286
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/UWCOI20B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n3 5 3 4\n2\n5 7\n1\n4\n", "output": "3\n0\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1112
Solve the following coding problem using the programming language python: 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 cas...
```python # cook your dish here for _ in range(int(input())): n = int(input()) m = n x= 1 for i in range(n): for j in range(m): print(x, end = '') x += 1 print() m -= 1 ```
vfc_3290
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY58", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n2\n3\n4\n", "output": "1\n12\n3\n123\n45\n6\n1234\n567\n89\n10\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1113
Solve the following coding problem using the programming language python: Given an array A of length N, your task is to find the element which repeats in A maximum number of times as well as the corresponding count. In case of ties, choose the smaller element first. -----Input----- First line of input contains an int...
```python t = input(); a = [0 for i in range(10001)] i = 0; while i < int(t): n = input(); k = input(); assert(len(k.split(' ')) == int(n)); for each in k.split(' '): a[int(each)] += 1; V = 0; C = a[V]; for j in range(10001): if C < a[j]: V = j; C = a[V]; a[j] = 0; i += 1; print(V...
vfc_3294
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/FEB12/problems/MAXCOUNT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n1 2 3 2 5\n6\n1 2 2 1 1 2\n\n\n", "output": "2 2\n1 3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1114
Solve the following coding problem using the programming language python: Chefu is Chef's little brother, he is 12 years old and he is new to competitive programming. Chefu is practicing very hard to become a very skilled competitive programmer and win gold medal in IOI. Now Chefu is participating in a contest and the...
```python T=int(input()) for i in range(T): N=int(input()) A=list(map(int,input().split()))[:N] l=[] for j in range(len(A)): for k in range(j+1,len(A)): l.append(A[j]+A[k]) print(l.count(max(l))/((N*(N-1))/2)) ```
vfc_3298
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RNDPAIR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n3 3 3 3\n6\n1 1 1 2 2 2\n4\n1 2 2 3\n", "output": "1.00000000\n0.20000000\n0.33333333\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1115
Solve the following coding problem using the programming language python: You are given a tree with $N$ vertices (numbered $1$ through $N$) and a sequence of integers $A_1, A_2, \ldots, A_N$. You may choose an arbitrary permutation $p_1, p_2, \ldots, p_N$ of the integers $1$ through $N$. Then, for each vertex $i$, you...
```python T = int(input()) M = 10 ** 9 + 7 for _ in range(T): N = int(input()) A = list(map(int, input().split())) if N == 1: print(0) continue B = {} C = {} for i in range(N - 1): u, v = input().split() u = int(u) - 1 v = int(v) - 1 if u not in B: B[u] = [] if v not in B: B[v] = [] ...
vfc_3302
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 2 3 4\n1 2\n2 3\n2 4\n5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n", "output": "24\n15\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1116
Solve the following coding problem using the programming language python: -----Problem Statement----- We have an integer sequence $A$, whose length is $N$. Find the number of the non-empty contiguous subsequences of $A$ whose sum is $0$. Note that we are counting the ways to take out subsequences. That is, even if the...
```python from collections import defaultdict def findSubarraySum(arr, n, Sum): # Dictionary to store number of subarrays # starting from index zero having # particular value of sum. prevSum = defaultdict(lambda : 0) res = 0 # Sum of elements so far. currsum = 0 for i in range(0, n): ...
vfc_3306
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SCAT2020/problems/SC_01", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n1 3 -4 2 2 -2\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1117
Solve the following coding problem using the programming language python: 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 (num...
```python import numpy as np def sort_it(array): new_list = [] for i in range(len(array)): start = 0 value = array[i][0] last = len(new_list) while start != last: mid = (start + last) // 2 if new_list[mid][0] > value: last = mid ...
vfc_3310
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHADAY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 3 4\n1 1 3\n1 2 -4\n4 5 2\n1 2\n1 3\n1 1\n2 3\n", "output": "3 0 0 4 4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1118
Solve the following coding problem using the programming language python: 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 ...
```python ''' Name : Jaymeet Mehta codechef id :mj_13 Problem : Avenir Strings ''' from sys import stdin,stdout test=int(stdin.readline()) for _ in range(test): N=int(stdin.readline()) seq=list(input()) fp,fp1,fl,fl1=0,0,0,1 for i in range(N): if fl!=int(seq[i])-0: fp+=1 fl=1-fl for i in range(N): if fl1!...
vfc_3314
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENFE2020/problems/ECFEB205", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n1011\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1119
Solve the following coding problem using the programming language python: 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 ce...
```python #dt = {} for i in x: dt[i] = dt.get(i,0)+1 import sys;input = sys.stdin.readline inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()] def kadane(arr, start, finish, n): Sum = 0 maxSum = float('-inf') i = None finish[0] = -1 local_start = 0 for i in range(n...
vfc_3318
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHLG2020/problems/CCFUND", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6 5\n0 -2 -7 0 -1\n9 2 -6 2 0\n-4 1 -4 1 0\n-1 8 0 -2 1\n-10 1 1 -5 6\n-15 -1 1 5 -4\n", "output": "9 2\n-4 1\n-1 8\n", "type": "stdin_...
apps
verifiable_code
1120
Solve the following coding problem using the programming language python: 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 (...
```python #AUTHOR:: AMAN VERMA try: for _ in range(int(input())): row,column=list(map(int,input().split(" "))) x_x,y_y=list(map(int,input().split(" "))) ab=max((x_x-0),(row-x_x-1)) ba=max((y_y-0),(column-y_y-1)) print(ab+ba) except: pass ```
vfc_3322
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/QTST2020/problems/APCLYPSE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 5\n2 1\n3 4\n1 1\n", "output": "5\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1121
Solve the following coding problem using the programming language python: 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...
```python # cook your dish here t=int(input()) while t>0: a=input().split(":") a1=int(a[0]) a2=int(a[1]) b1=a1%12 if a2%5!=0: b2=(a2//5)*5+5 else: b2=a2 c1=b1*30 extra=0.5*b2 c1+=extra c1%=360 d1=(b2//5)*30 d1%=360 if c1>d1: ans1=c1-d1 ans2=360-ans1 else: ans1=d1-c1 ans2=360-ans1 ...
vfc_3326
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PAHC2020/problems/CHEFJUMP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n14:20\n02:10\n09:30\n", "output": "50 degree\n5 degree\n105 degree\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1122
Solve the following coding problem using the programming language python: 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 w...
```python # cook your dish here while True: try: m=int(input()) n=int(m/2) a=m-n sum_even= int(2*(2*n*(n+1)*(2*n+1))/3) sum_odd= int(((4*a*a*a)-a)/3) result=sum_odd+sum_even if result%2==0: print('Ravi') else: print('Jhon') except: break; ```
vfc_3330
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CFUN2020/problems/CODSTAN7", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n", "output": "Jhon\nRavi\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1123
Solve the following coding problem using the programming language python: 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 - h...
```python # cook your dish here from sys import stdin, stdout from math import ceil def solve(): for _ in range(int(input())): n, m = map(int, stdin.readline().split()) par = [i for i in range(n)] for i in range(m): ta, tb = map(int, stdin.readline().strip().split()) ...
vfc_3334
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/HDELIVER", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n0 1\n1 2\n3\n0 2\n0 3\n2 1\n\n\n", "output": "YO\nNO\nYO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1124
Solve the following coding problem using the programming language python: 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 b...
```python # cook your dish here # cook your dish here t=int(input()) for _ in range(t): n,p,q=list(map(int,input().split(" "))) l=list(map(int,input().split(" "))) l.sort() s=sum(l) a=p+2*q b=0 for i in l: if(p==0): if(i%2==0 and a>=i): a=a-i b=b+1 elif(q==0): if(a>=i): a=a-i b=b+1 el...
vfc_3338
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LUMPYBUS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3 0\n1 2 2\n3 2 1\n1 2 1\n4 5 4\n2 3 4 5\n", "output": "2\n3\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1125
Solve the following coding problem using the programming language python: 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 st...
```python # cook your dish here for _ in range(int(input())): n=list(map(int,input().split())) print(n[0]*n[1]) ```
vfc_3342
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 10\n", "output": "50\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1126
Solve the following coding problem using the programming language python: "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...
```python for _ in range(int(input())): n=int(input()) print((2*(pow(n,2)))-n+1) ```
vfc_3346
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CFW32020/problems/AYUSCRT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2\n", "output": "2\n7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1127
Solve the following coding problem using the programming language python: 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 ...
```python # cook your dish here x= int(input()) for i in range(x): y = list(map(str, input().split())) j= 0 while j<len(y)-1: print((y[j][0]).capitalize()+".", end=' ') j+= 1 print(y[len(y)-1].capitalize()) ```
vfc_3350
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NITIKA", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ngandhi\nmahatma gandhI\nMohndas KaramChand gandhi\n\n\n", "output": "Gandhi \nM. Gandhi \nM. K. Gandhi \n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1128
Solve the following coding problem using the programming language python: 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 ther...
```python import sys t = eval(input()) for j in range(t): n = eval(input()) a = list(map(int, input().split())) ch = 0 sm = 0 ; x = sum(a) s1 = [0] * n ; s2 = [0] * n for i in range(n): sm += a[i] s1[i] = sm s2[i] = x x -= a[i] if(sum(a) - a[0] == 0): print(0) elif(sum(a) - a[n - 1] == 0): print(n ...
vfc_3354
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/TSCO2017/problems/TSECJ101", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n7\n7 8 9 1 9 8 7\n6\n1 100 50 -51 1 1\n", "output": "3\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1129
Solve the following coding problem using the programming language python: 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 cons...
```python def fastpow(base, power): result = 1 while power > 0: if power % 2 == 0: power = power // 2 base = base * base else: power = power - 1 result = result * base power = power // 2 base = base * base return result t=int(input()) for i in range(t): a=list(map(int,input().split())) n,r=...
vfc_3358
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/DCC2020/problems/DCC201", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 1\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1130
Solve the following coding problem using the programming language python: 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 hospi...
```python for _ in range(int(input())): f,d=list(map(int,input().split())) arr=list(map(int,input().split())) risk=0 days_risk=0 days_norm=0 if d==1: print(f) else: for a in arr: if a>=80 or a<=9: risk+=1 norm=f-risk if risk%d==0: days_risk=risk//d else: days_risk=(risk//d)+1 if norm%d==...
vfc_3362
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/VACCINE2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 1\n10 20 30 40 50 60 90 80 100 1\n5 2\n9 80 27 72 79\n", "output": "10\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1131
Solve the following coding problem using the programming language python: 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...
```python for _ in range(int(input())): n,k=[int(x) for x in input().split()] a=list(map(int,input().split())) dp=[0]*(max(a)+1) for _ in range(n): dp[a[_]]+=1 for _ in range(1,len(dp)): if dp[_]>k: print(_,end=" ") print() ```
vfc_3366
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PEND2020/problems/ANITGUY8", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 1\n5 2 1 2 5\n", "output": "2 5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1132
Solve the following coding problem using the programming language python: 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 part...
```python mod = 1000000007 fac = [1,1] maxn = (10**5)+5 for i in range(2,maxn): x = (fac[-1]*i)%mod fac.append(x) pre = [1] for i in range(2,maxn): x = 2*i-1 x = (pre[-1]*x)%mod pre.append(x) for _ in range(int(input())): n = int(input()) x = fac[n] y = pre[n-1] pr...
vfc_3370
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COCA2020/problems/COCA2003", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n2\n3\n", "output": "1\n6\n90\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1133
Solve the following coding problem using the programming language python: 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 dec...
```python from sys import stdin,stdout from math import gcd nmbr=lambda:int(stdin.readline()) lst=lambda:list(map(int, stdin.readline().split())) for _ in range(nmbr()): n=nmbr() a=lst() g=a[0] ans=0 for v in a[1:]: g=gcd(v,g) for i in a: ans+=i//g print(g,ans) ```
vfc_3374
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CSTR2020/problems/ELECTRIC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n2 4 8\n", "output": "2 7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1134
Solve the following coding problem using the programming language python: 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 wo...
```python t=int(input()) for i in range(t): n,m=list(map(int,input().split())) a=list(map(int,input().split())) army=0 if n>m: for i in range(0,m): army+=a[i] for j in range(m,n): army=army-(a[j]/2) if army<0: print('DEFEAT') break else: continue else: print('VICTORY') ...
vfc_3378
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/KOKT2015/problems/KOKT03", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 3\n1 2 3 4 5\n6 2\n4 4 4 4 4 4\n7 4\n10 10 10 10 50 60 70\n", "output": "VICTORY\nVICTORY\nDEFEAT\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1135
Solve the following coding problem using the programming language python: 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: ...
```python # cook your dish here t=int(input()) while t!=0: n,k=map(int,input().split()) lst=[] for i in range(1,n+1): lst.append(i) lst[k],lst[n-1]=lst[n-1],lst[k] for item in lst: print(item,end=' ') t-=1 ```
vfc_3382
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MXCH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 2\n", "output": "2 3 1 5 4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1136
Solve the following coding problem using the programming language python: 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 t...
```python t = int(input()) for _ in range(t): n,m = map(int,input().split()) if n==1: print(m) else: if n%2==0: print((n//2)*m) else: print(((n//2)+1)*m) ```
vfc_3386
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK12020/problems/ITGUY17", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n4 3\n", "output": "2\n6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1137
Solve the following coding problem using the programming language python: 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 t...
```python test = int(input()) ANS = list() for i in range(test): n = int(input()) items = sorted(list(map(int, input().split()))) c = 1 for j in range(len(items)): if items[j] < 2000: t = 2000 - items[j] if t in items[j+1:]: ANS.append("Accepted") c = 2 break else: pass else: break ...
vfc_3390
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ARYS2020/problems/BDYGFT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n10 2 1000 50 1000\n", "output": "Accepted\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1138
Solve the following coding problem using the programming language python: 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...
```python a=eval(input()) while(a): x=eval(input()) b=list(map(int,input().split())) z=[0]*100 k=1 j=0 c=0 for i in b: if i==0: z.insert(i,k) else: if z[z.index(i)+1]==0: z.insert(j,k) else: m=z.index(i) n=m+1 p=(len(z)-z.count(0))-n c=c+min(n,p) z.i...
vfc_3394
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK64/problems/SEALINE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n0\n3\n0 0 0\n5\n0 1 2 1 4\n", "output": "0\n0\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1139
Solve the following coding problem using the programming language python: 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 fo...
```python t = int(input()) while t>0: s = input().strip() if not s: print('NO') dp = [0 for x in range(len(s) + 1)] dp[0] = 1 dp[1] = 1 if 0 < int(s[0]) <= 9 else 0 for i in range(2, len(s) + 1): if 0 < int(s[i-1:i]) <= 9: dp[i] += dp[i - 1] if s[i-2:i][0] != '0' and int(s[i-2:i]) <= 26: dp[i] += dp...
vfc_3398
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CY302020/problems/CODEY302", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n12\n223\n", "output": "YES\nNO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1140
Solve the following coding problem using the programming language python: 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 } } ...
```python for _ in range(int(input())): p, idx = map(int, input().split()) b = bin(idx)[2:] b = ('0' * (p - len(b)) + b)[::-1] print(int(b, 2)) ```
vfc_3402
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO20001", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3\n3 7\n", "output": "6\n7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1141
Solve the following coding problem using the programming language python: 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...
```python try: t,m=input().split() t=int(t) m=list(m) letters=list("abcdefghijklmnopqrstuvwxyz") trans={} for i in range(len(letters)): trans[letters[i]]=m[i] for i in range(t): x=list(input()) y="" for j in x: if(j.isalpha()==True): if(j.isupper()==True): y+=trans[j.lower()].upper() else...
vfc_3406
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TOTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "and its\n", "output": "", "type": "stdin_stdout" } ] }
apps
verifiable_code
1142
Solve the following coding problem using the programming language python: 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...
```python arr=[] n=int(input()) for i in range(n): a=int(input()) arr.append(a) arr.sort() p=arr.index(a) print((i-p)+1) ```
vfc_3410
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IARCSJUD/problems/IARANK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n78\n24\n68\n40\n39\n89\n", "output": "1\n2\n2\n3\n4\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1143
Solve the following coding problem using the programming language python: 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 t...
```python # cook your dish here def isPrime(n) : # Corner cases if (n <= 1) : return False if (n <= 3) : return True # This is checked so that we can skip # middle five numbers in below loop if (n % 2 == 0 or n % 3 == 0) : return False i = 5 while...
vfc_3414
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHLG2020/problems/MINI2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n852140\n", "output": "1929\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1144
Solve the following coding problem using the programming language python: 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. F...
```python T= int(input()); for i in range(T): n,k = list(map(int,input().split())); s=list(map(int,input())); if k==1: s_0 ={}; s_1={}; c0=0; c1=0; for j in range(n): if(j%2==0): s_1[j]=1; s_0[j]=0; else: s_1[j]=0; s_0[j]=1; for j in range(n): if(s_0[j]-s[j]!=0): c0+=1; ...
vfc_3418
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DEVSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 1\n11\n2 2\n11\n4 1\n1001\n", "output": "1\n10\n0\n11\n2\n1010\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1145
Solve the following coding problem using the programming language python: 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 t...
```python from math import log,pow n=int(input()) a=[] for i in range(n): no=int(input()) if(no%2==0): a.append("0") elif(no==1): a.append("1") elif(no==3): a.append("3") else: s="2" lv=int(log(no,2)) clv=1 cno=3 while(cno!=no): if(no<cno*pow(2,lv-clv)): s=s+"1" clv=clv+1 cno=(2*cno)...
vfc_3422
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ALGT2013/problems/TNMALG07", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n17\n10\n", "output": "2111\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1146
Solve the following coding problem using the programming language python: [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 so...
```python # cook your dish here a,b=list(map(int,input().split())) ls=[] for i in range(a): ls.append(int(input())) ls.sort() c=0;i=0 while i<(a-1): if ls[i+1]-ls[i]<=b: c=c+1 i=i+1 i=i+1 print(c) ```
vfc_3426
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TACHSTCK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 2\n1\n3\n3\n9\n4\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1147
Solve the following coding problem using the programming language python: 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...
```python # cooking dish here from sys import stdin from collections import Counter read = stdin.readline for testcase in range(int(read())): length = int(read()) string = read().strip() counts = Counter(string) odd_counts = 0 for count in list(counts.values()): # print(coun...
vfc_3430
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDGO2021/problems/PALINDRO", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\na\n9\nabbbcbddd\n6\nabcdef\n", "output": "0\n2\n5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1148
Solve the following coding problem using the programming language python: 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 ...
```python def g(x,y): d = x[0]>=y[0] and x[1]>=y[1] and x[2]>=y[2] e= x[0]>y[0] or x[1]>y[1] or x[2]>y[2] return d and e t=int(input()) for _ in range(t): a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) if g(a,b) and g(b,c): print('yes') elif g(a,c) and g(c,...
vfc_3434
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ORDTEAMS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 3\n2 3 4\n2 3 5\n1 2 3\n2 3 4\n2 3 4\n5 6 5\n1 2 3\n2 3 4\n", "output": "yes\nno\nyes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1149
Solve the following coding problem using the programming language python: 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, th...
```python # cook your dish here t=int(input()) for _ in range(t): l = input() n= len(l) prod = 1 for k in range(n//2): i = l[k] j = l[n-k-1] if ((i!=j) and (i!='?' and j!="?") ): prod=0 break elif ((i==j) and (i=='?')): prod*=26 prod = prod%10000009 if n%2!=0: if l[n//2]=="?": prod*=26...
vfc_3438
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RRECIPE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n?\n??\nab?\na?c\naba\n", "output": "26\n26\n1\n0\n1\nConstraints\n1 ≤ T ≤ 20\n1 ≤ sum of length of all input strings ≤ 1,000,000\nEach input string contains only lowercase roman letters ('a' - 'z') or question marks.\n", ...
apps
verifiable_code
1150
Solve the following coding problem using the programming language python: 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 ...
```python # cook your dish here import math for _ in range(int(input())): n=int(input()) c=0 while(n>0): i=int(math.sqrt(n)) c+=1 n=n-i**2 print(c) ```
vfc_3442
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ICL1902", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n85\n114\n", "output": "2\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1151
Solve the following coding problem using the programming language python: 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 cit...
```python from sys import stdin from math import ceil, gcd # Input data #stdin = open("input", "r") def dfs(src, visit): visit[src] = 1 for nbr in d[src]: if visit[nbr] == 0: dfs(nbr, visit) for _ in range(int(stdin.readline())): n, m = list(map(int, stdin.readline().sp...
vfc_3446
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENAU2020/problems/ECAUG206", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 3\n0 1\n2 3\n3 4\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1152
Solve the following coding problem using the programming language python: 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 recip...
```python nr=int(input()) d={} for r in range(nr): s,v=list(map(str,input().split())) d[int(v)]=s q=int(input()) lis=[] for i in range(q): lis.append(input()) l=list(d.keys()) l.sort(reverse=True) ans='NO' for j in lis: ans='NO' for k in l: if len(j)<=len(d[k]): a=d[k] if j==a[0:len(j)]: ans=a br...
vfc_3450
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TWSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nc\nfl\nchik\n", "output": "fish-with-pepper\nflour-without-eggs\nflour-with-eggs\nchicken-ham\nflour-witho...
apps
verifiable_code
1153
Solve the following coding problem using the programming language python: -----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 se...
```python def mod(a,b,c): x = 1 y = a while(b>0): if(b%2==1): x = (x*y)%c y = (y*y)%c b /=2 return x%c t = int(input()) num = 10**9+7 for i in range(t): n,m,q,k = list(map(int,input().split())) if m<=q: print(0) else: a1 = m-q a2 = mod(q+1,n,num) a3 = mod(q-1,n,num) a4 = mod(q,n,num) a5 = a2...
vfc_3454
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SEATRSF", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 1 1\n2 2 1 1\n2 3 1 1\n", "output": "0\n2\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1154
Solve the following coding problem using the programming language python: 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 ga...
```python try: n=int(input()) x=[*list(map(int, input().split()))] y=[*list(map(int, input().split()))] for i in y: d=x.count(i)-y.count(i) if d!=0: print(i) break except: pass ```
vfc_3458
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CSTR2020/problems/AMONGUS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 2 5\n4 2 3 5\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1155
Solve the following coding problem using the programming language python: 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 ...
```python print ```
vfc_3462
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/TCTR2012/problems/NOPC2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n0 4 0 4\n1 3 1 2\n2 3 1 3\n3 4 1 3\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1156
Solve the following coding problem using the programming language python: 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, eac...
```python # cook your dish here for i in range(int(input())): x=int(input()) if x<10: print("Thanks for helping Chef!") else: print("-1") ```
vfc_3466
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FLOW008", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n12\n-5\n", "output": "Thanks for helping Chef!\n-1\nThanks for helping Chef!\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1157
Solve the following coding problem using the programming language python: 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 thi...
```python # cook your dish here # cook your dish here for i in range(int(input())): n,m,k=map(int,input().split()) l,ans = list(map(int,input().split())),0 for i in l: r=i//m + 1;c=i%m if(c==0):c=m;r-=1 ans+=r*(n+1-r)*c*(m+1-c) ans/=((n+1)*(m+1)*n*m)//4 print(ans) ```
vfc_3470
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RECTLOVE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 2 2\n1 2\n\n\n", "output": "0.8888888888888888\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1158
Solve the following coding problem using the programming language python: 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....
```python #!/usr/bin/env python def main(): N = int(input()) C = 0 for n in range(N): S = input().strip() Pi = S.split()[-1] L = [Pi.count(k) for k in map(str, list(range(10)))] if L[8] >= L[5] and L[5] >= L[3] and \ L[0] == 0 and L[1] == 0 and \ L[2] == 0 and L[4] == 0 and \ L[6] == 0 and L[7] == ...
vfc_3474
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK20/problems/CIELNUM2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\nmilk 58\nCiel's Drink 80\nThe curry 2nd edition 888888\nrice omelet 85855\nunagi 1\nThe first and last letters can be a space 358\n", "output": "3\nOutput details\n58 and 888888 and 358 are Ciel numbers.\n80 and 8585...
apps
verifiable_code
1159
Solve the following coding problem using the programming language python: 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 fr...
```python t = int(input()) for e in range(t): str = input() dict = {} for x in range(len(str)): if str[x] in dict: dict[str[x]] = -1 else: dict[str[x]] = x shankyIndex = len(str) ankuIndex = -1 for x in dict: if dict[x] != -1: if dict[x] < shankyIndex: shankyIndex = dict[x] if dict[x] >...
vfc_3478
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/RECJ1601/problems/ABHSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\ngoogle\nbreakraekb\naman\n", "output": "SHANKY\nPANDEY\nANKU\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1160
Solve the following coding problem using the programming language python: 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 t...
```python def get(l,n): l1,l2 = [],[] i = 1 h1,m1 = l[0] while (i < len(l)): h2,m2 = l[i] if (h1>h2): if (m1 >= m2): l1 += [(0,10**20)] l2 += [(-1,-1)] else: d = (h1-h2)//(m2-m1) if (((h1-h2)%(m2-m1)) == 0): l1 += [(0,d-1)] l2 += [(d+1,10**20)] else: l1 += [(0,d)] l...
vfc_3482
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AUG16/problems/CHAHG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n0 1\n2 2\n0 3\n2\n2 1\n1 2\n3\n1 1\n2 2\n3 3\n", "output": "1\n0 1\n2\n0 0\n2 Inf\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1161
Solve the following coding problem using the programming language python: 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 the...
```python for i in range(int(input())): a=input() c=a.count('m') d=a.count('s') t=0 while t<len(a)-1: if (a[t]=='m' and a[t+1]=='s') or (a[t]=='s' and a[t+1]=='m'): d=d-1 t=t+2 else: t=t+1 if c>d: print('mongooses') elif d>c: print('snakes') else: print('tie') ```
vfc_3486
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SNELECT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nsm\nssm\nsms\nssmmmssss\n", "output": "mongooses\ntie\ntie\nsnakes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1162
Solve the following coding problem using the programming language python: 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 Luc...
```python import sys import os def __starting_point(): start = 0 for line in sys.stdin: if start == 0: start = 1 continue else: try: n = int(line.strip()) # print n q = ...
vfc_3490
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/MAY12/problems/CHEFLUCK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n7\n4\n11\n1\n15\n\n\n", "output": "7\n0\n7\n-1\n7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1163
Solve the following coding problem using the programming language python: 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 treat...
```python T = int(input()) for j in range(0,T): line1, line2 = input(), input() seq = line2.split() current_min = 1000001 current_max = 0 max_spread = 0 for i in range(0,len(seq)): current_value = int(seq[i]) if current_min > current_value: current_min = current_value current_max = current_value elif ...
vfc_3494
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/APRIL12/problems/PLAYFIT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n6\n3 7 1 4 2 4\n5\n5 4 3 2 1\n5\n4 3 2 2 3\n", "output": "4\nUNFIT\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1164
Solve the following coding problem using the programming language python: 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: - L...
```python p,s = [int(i) for i in input().split()] scores = {} for j in range(1, p + 1): sc = [int(i) for i in input().split()] ns = [int(i) for i in input().split()] nsc = dict(list(zip(sc,ns))) ssc = sorted(sc) score = 0 for a,b in zip(ssc[:-1], ssc[1:]): if nsc[a] > nsc[b]: score += 1 if score in list(sc...
vfc_3498
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PROBLEMS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n16 24 60\n498 861 589\n14 24 62\n72 557 819\n16 15 69\n435 779 232\n", "output": "2\n1\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1165
Solve the following coding problem using the programming language python: 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...
```python # cook your dish here d = {'january':31,'february':29,'march':31, 'april':30,'may':31,'june':30,'july':31, 'august':31,'september':30,'october':31, 'november':30,'december':31} #l=[[15,'january'],[31,'august'],[10,'october']] l2 = list(d.keys()) for _ in range(int(input())): l=input().split() l[0]=int(...
vfc_3502
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PAHC2020/problems/HALFBDAY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n15 january\n31 august\n10 october\n", "output": "16 july\n1 march\n10 april\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1166
Solve the following coding problem using the programming language python: 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 ...
```python import sys import math def main(arr,k): ans=0 for i in range(len(arr)): curr_min=float('inf') for j in range(i,len(arr)): curr_min=min(curr_min,arr[j]) if curr_min==k: ans+=1 return ans n=int(input()) arr=list(ma...
vfc_3506
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUBMIN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 1 2 3 4\n4\n3\n4\n6\n1\n\n\n", "output": "2\n2\n0\n8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1167
Solve the following coding problem using the programming language python: 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 chan...
```python s = input().lower() vow = ["a", "e", "i", "o", "u", "y"] ans = "" for ch in s: if ch in vow: continue if ch.isalpha(): ans += "." + ch print(ans) ```
vfc_3510
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SPRT2020/problems/EMPRNM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "CodeSprInT\n", "output": ".c.d.s.p.r.n.t\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1168
Solve the following coding problem using the programming language python: 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...
```python import sys for _ in range(0,eval(input())): 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') inps = [inp[i:] for i in range(len(inp))] inps.sort() op,prev= 0,'' for ip in inps: i,ct=...
vfc_3514
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ICOD2016/problems/ICODE16G", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nababab\nbgbbbbbbbbbbbbbbbbbbbbbbbb\n1\nacbacbacaa\nbbbbbbbbbbbbbbbbbbbbbbbbbb\n2\n", "output": "5\n8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1169
Solve the following coding problem using the programming language python: 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'...
```python import sys def joseph(k, n=6): if k==0: k = 1 x = 0 for i in range(2,n+1): x = (x+k)%i return x FLAMES = ['FRIENDS', 'LOVE', 'ADORE', 'MARRIAGE', 'ENEMIES', 'SISTER'] nCase = int(sys.stdin.readline()) for _ in range(nCase): a = ''.join(sys.stdin.readline().split()) b = ''.join(sys.stdin.readline(...
vfc_3518
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IGNS2012/problems/IG01", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nSHILPA\nAAMIR\nMATT\nDENISE\n\n\n\n", "output": "ENEMIES\nLOVE\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1170
Solve the following coding problem using the programming language python: 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 t...
```python t=int(input()) for i in range(0,t): n,k=map(int,input().split()) a1,*a=map(int,input().split()) a.insert(0,a1) j=0 while j<n: if a[j]%k==0: print(1,end="") else: print(0,end="") j+=1 print("") ```
vfc_3522
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFSTEP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 3\n12 13 18 20 27216\n", "output": "10101\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1171
Solve the following coding problem using the programming language python: 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 th...
```python import numpy as np from numba import njit i8 = np.int64 @njit def solve(a, b, t, K, N): t1 = t // K d = t % K * 2 # b が a から a + d の位置にあれば衝突する x = 0 y = 0 ans = 0 for c in a: while b[x] < c: x += 1 while b[y] <= c + d: y +=...
vfc_3526
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CRSHIT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3 11\n1 3\n1 10\n2 4\n2 7\n2 0\n3\n8\n100\n", "output": "4\n10\n110\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1172
Solve the following coding problem using the programming language python: 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], wh...
```python from math import factorial def Ncr(n,r): if r<0:return 0 return factorial(n)/(factorial(n-r)*factorial(r)) def solve(m,n): modulo=10**9+7 if m==n: return (Ncr(2*n-1,n-1)+Ncr(2*n-2,n-2))%modulo elif m>n: return (Ncr(m+n,n)-Ncr(m+n-2,n-1))%modulo else: return (Ncr...
vfc_3530
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/NOV12/problems/LUCKY9", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n47\n4477\n\n\n", "output": "1\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1173
Solve the following coding problem using the programming language python: 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, ...
```python import itertools from collections import defaultdict as dfd def sumPairs(arr, n): s = 0 for i in range(n-1,-1,-1): s += i*arr[i]-(n-1-i)*arr[i] return s def subarrayXor(arr, n, m): ans = 0 xorArr =[0 for _ in range(n)] mp = dfd(list) xorArr[0] = arr[0] for i in range(1, n): xorArr[i] = xorArr[i...
vfc_3534
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/KS1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n5 2 7\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1174
Solve the following coding problem using the programming language python: 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 ...
```python from math import * t = int(input()) for _ in range(t): n = int(input()) a = [int(d) for d in input().split()] odd,even = 0,0 for i in range(n): if bin(a[i]).count("1")%2 == 1: odd += 1 else: even +=1 total = 0 if odd >= 3 and even >= 2: total += (odd*(odd-1)*...
vfc_3538
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LOG_EQN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n1 1 2 3\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1175
Solve the following coding problem using the programming language python: 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 ...
```python import math def lcm(a, b): return (a*b)//gcd(a, b) def gcd(a, b): if b == 0: return a return gcd(b, a%b) for _ in range(int(input())): n = int(input()) na = math.ceil((2*n)/math.acos(-1)) nb = ((n+1)//2)**2 nlcm = lcm(na, nb) oa = math.ceil(n/2) ob = (...
vfc_3542
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/NEWB2020/problems/CNFCT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n111\n", "output": "YESS(sunglass emo)\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1176
Solve the following coding problem using the programming language python: 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 ass...
```python for _ in range(int(input())): s=input() if len(s)<4: print("NO") else: if s[-4:]=="1000": print("YES") else: print("NO") ```
vfc_3546
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ICM2006", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n100\n", "output": "NO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1177
Solve the following coding problem using the programming language python: 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 subordinate...
```python def nCr(n,k): if(k>n):return 0 k=min(k,n-k) num,den=1,1 for i in range(k): num*=(n-i) den*=(i+1) return num/den def Main(): for cases in range(int(input())): a,b=[int(x) for x in input().split()] print(nCr(a,b)) Main() ```
vfc_3550
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK06/problems/CHEFTEAM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 1\n3 3\n10 5\n", "output": "2\n1\n252\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1178
Solve the following coding problem using the programming language python: 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 th...
```python test=int(input()) for _ in range(test): n=int(input()) ls=list(map(int,input().split())) ls.sort() s=0 for i in range(n): if s>=ls[i]: s=s+1 else: break print(s) ```
vfc_3554
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHFPARTY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n0 0\n6\n3 1 0 0 5 5\n3\n1 2 3\n", "output": "2\n4\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1179
Solve the following coding problem using the programming language python: 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$ elem...
```python # cook your dish here from math import sqrt for _ in range(int(input())): n=int(input()) sum=(n*(n+1))//2 #print(sum) if(sum%2!=0): print(0) continue m=(int((sqrt(1+4*(sum)))-1)//2) if(m*(m+1)//2==sum//2): print((((m-1)*m)//2)+n-m+((n-m-1)*(n-m))//2) else: print(n-m) ```
vfc_3558
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHFNSWAP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1\n2\n3\n4\n7\n", "output": "0\n0\n2\n2\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1180
Solve the following coding problem using the programming language python: 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 $...
```python # cook your dish here t=int(input()) for i in range(t): a=0 b=0 N,K,x,y=map(int,input().split()) if x==y: a=N b=N elif x>y: if K%4==1: a=N b=y-x+N elif K%4==2: a=y-x+N b=N elif K%4==3: a=0 b=x-y else: a=x-y b=0 else: if K%4==1: a=x-y+N b=N elif K%4==2: ...
vfc_3562
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BILLRD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 5 4 4\n5 2 3 1\n", "output": "5 5\n3 5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1181
Solve the following coding problem using the programming language python: 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$, t...
```python import sys,io,os,math from math import ceil,log,gcd,inf from itertools import permutations mod=1000000007 mod1=998244353 def printlist(n): sys.stdout.write(" ".join(map(str,n)) + "\n") printf=lambda n:sys.stdout.write(str(n)+"\n") def printns(n): sys.stdout.write(str(n)) def intinp(): return in...
vfc_3566
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PEND2020/problems/ANITGUY9", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n16\n27\n", "output": "No\nYes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1182
Solve the following coding problem using the programming language python: 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...
```python def interesting_nums(m): nums = [] for x in range(m + 1, 2 * m + 1): if x * m % (x - m) == 0: nums.append(x) return nums def main(): T = int(input()) for _ in range(T): num_list = interesting_nums(int(input())) print(len(num_list)) for num in num_list: print(num) main() ```
vfc_3570
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DRMP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n6\n", "output": "2\n4\n6\n5\n7\n8\n9\n10\n12\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1183
Solve the following coding problem using the programming language python: 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 a...
```python for __ in range(eval(input())): x = eval(input()) a = list(map(int,input().split())) key = eval(input()) query = eval(input()) maxvisited = x #maximum visted value j = x-1 ans = [] val = 0 while j>=0: if a[j]==key: ans.append(val+1) val = val...
vfc_3574
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AIPC2015/problems/AN01", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10\n1 2 3 1 2 3 1 2 3 1\n3\n5\n2\n4\n6\n8\n2\n\n", "output": "3 8 9\n2 6 1\n1 4 1\n1 2 1\n3 8 1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1184
Solve the following coding problem using the programming language python: 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...
```python from itertools import permutations C = list(permutations(['A','B','C','D'])) V = list(permutations([3,6,9,12])) P = list(permutations([25,50,75,100])) R = [] def test(): d = {} n = int(input()) for i in C[0]: for j in V[0]: d[i+str(j)] = 0 for i in range(n): x,y = input().split() d[x+y] += 1 an...
vfc_3578
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/THEATRE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n12\nA 3\nB 12\nC 6\nA 9\nB 12\nC 12\nD 3\nB 9\nD 3\nB 12\nB 9\nC 6\n7\nA 9\nA 9\nB 6\nC 3\nD 12\nA 9\nB 6\n2\nA 9\nB 6\n1\nD 12\n0\n", "output": "575\n525\n-25\n-200\n-400\n475\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1185
Solve the following coding problem using the programming language python: 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 pa...
```python import sys rl=sys.stdin.readline T=int(rl()) for t in range(T): P=int(rl()) T=(P+1)//2 F=list(map(int,rl().split()))[1:] numtorn=int(rl()) t=sum(range(1,P+1))-sum(F) K=T-numtorn print('%.4f' % (t*K/float(T))) ```
vfc_3582
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SEPT11/problems/TRMAG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10\n2 1 2\n2\n10\n1 8\n0\n", "output": "31.2000\n47.0000\n", "type": "stdin_stdout" } ] }