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
786
Solve the following coding problem using the programming language python: The chef was not happy with the binary number system, so he designed a new machine which is having 6 different states, i.e. in binary there is a total of 2 states as 0 and 1. Now, the chef is confused about how to correlate this machine to get a...
```python from sys import stdin, stdout #from math import gcd as g #a,b = map(int, stdin.readline().split()) #l1 = list(map(int, stdin.readline().split())) l = [1,6,7] c = 1 for x in range(3,100001): if x%2==1: a = l[c]*6 l.append(a) else: l.append(a+1) c+=1 n = int(...
vfc_1986
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY23", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n5\n", "output": "7\n37\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
787
Solve the following coding problem using the programming language python: Limak is a little polar bear. He is playing a video game and he needs your help. There is a row with N cells, each either empty or occupied by a soldier, denoted by '0' and '1' respectively. The goal of the game is to move all soldiers to the ri...
```python for _ in range(int(input())): l=list(map(int,input().strip())) for j in range(len(l)-1,-1,-1): if l[j]==1: l.pop() else: break if l.count(1): time,prev,z,c=0,0,0,0 for j in range(len(l)-1,-1,-1): if l[j]==0: z+=1 continue if prev!=z: prev=z c+=1 time+=c+z print(tim...
vfc_1990
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ROWSOLD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10100\n1100001\n000000000111\n001110100011010\n", "output": "8\n10\n0\n48\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
788
Solve the following coding problem using the programming language python: If Give an integer N . Write a program to obtain the sum of the first and last digits of this number. -----Input----- The first line contains an integer T, the total number of test cases. Then follow T lines, each line contains an integer N. ...
```python n = int(input()) for i in range(n): s = input() l = len(s) n1 = int(s[0]) n2 = int(s[l-1]) print(n1+n2) ```
vfc_1994
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FLOW004", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1234\n124894\n242323\n", "output": "5\n5\n5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
789
Solve the following coding problem using the programming language python: Rani is teaching Raju maths via a game called N-Cube, which involves three sections involving N. Rani gives Raju a number N, and Raju makes a list of Nth powers of integers in increasing order (1^N, 2^N, 3^N.. so on). This teaches him exponenti...
```python tc=int(input()) for case in range(tc): m,r=list(map(int,input().split())) n=m**(r-1) a=[i**n for i in range(1,2*n+1)] tmp=2*n-1 for i in range(n): for j in range(tmp-i): a[j]=a[j+1]-a[j] print((a[n-1]/m)%1000000007) ```
vfc_1998
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDST2016/problems/CDS2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 2\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
790
Solve the following coding problem using the programming language python: Bob has n heap(s) of gravel (initially there are exactly c piece(s) in each). He wants to do m operation(s) with that heaps, each maybe: - adding pieces of gravel onto the heaps from u to v, exactly k pieces for each, - or querying "how many pi...
```python N,M,C = list(map(int, input().split())) tree = [0] * (N+1) def add(u,k): while u < len(tree): tree[u] += k u += u&-u def query(k): ans = 0 while k: ans += tree[k] k -= k&-k return ans def solve(): for _ in range(M): op = input().split() if op[0] == 'Q': print(query(int(op[1])) + C) ...
vfc_2002
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SPREAD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7 5 0\nQ 7\nS 1 7 1\nQ 3\nS 1 3 1\nQ 3\n", "output": "0\n1\n2\nLimitations\n0<n≤10 6\n0<m≤250 000\n0<u≤v≤n\n0≤c,k≤10 9\n0<p≤n\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
791
Solve the following coding problem using the programming language python: Chef's dog Snuffles has so many things to play with! This time around, Snuffles has an array A containing N integers: A1, A2, ..., AN. Bad news: Snuffles only loves to play with an array in which all the elements are equal. Good news: We have a ...
```python tc=int(input()) for case in range(tc): n,d=list(map(int,input().split())) a=list(map(int,input().split())) sm=sum(a) f=True if sm%n==0: avg=sm/n for i in range(d): tmp_sm=0 tmp_n=0 for j in range(i,n,d): tmp_sm=tmp_sm+a[j] tmp_n+=1 if tmp_sm%tmp_n==0: if avg!=tmp_sm/tmp_n: ...
vfc_2006
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AUG17/problems/CHEFMOVR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 2\n1 4 5 2 3\n3 1\n1 4 1\n4 2\n3 4 3 5\n", "output": "3\n2\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
792
Solve the following coding problem using the programming language python: Dustin, is the head of an Intelligence agency. He wants to send a secret message S$S$ to his colleague.The message is a single word consisting of only lowercase english letters but he decides to encrypt the message for security reasons. He makes...
```python # cook your dish here t = int(input()) for _ in range(t): n,s = input().split() N = int(n) r = N - len(s) count = 0 if N>len(s): count = pow(26, r-1,(10**9+7)) count*= (26+25*len(s)) count = count%(10**9 + 7) print(count) ```
vfc_2010
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ICL1904", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 a\n3 ab\n", "output": "1326\n76\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
793
Solve the following coding problem using the programming language python: As lockdown is going on so no is allowed to go outside , so Chef has come with an innovative idea for food home delivery using drone. But there is an issue with it , the drone can move forward or backward a fix number of steps $x$ . All the ho...
```python # cook your dish here import math try: n,d=map( int,input().split() ) a=list(map(int,input().split())) a.sort() z=abs(a[0]-d) for j in range(n): x=abs(a[j]-d) z=math.gcd(x,z) print(z) except: pass ```
vfc_2014
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LDT42020/problems/DRONEDEL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n3 5 11\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
794
Solve the following coding problem using the programming language python: One day, Tanya was studying graph theory. She is very inquisitive, so the following problem soon came to her mind. Find the number of undirected unweighted connected simple graphs with $N$ vertices (numbered $1$ through $N$) and $M$ edges, such ...
```python def multiple_input(): return map(int, input().split()) def list_input(): return list(map(int, input().split())) mod = int(1e9) + 7 for _ in range(int(input())): n, m = multiple_input() a = list_input() a.sort() max_level = a[-1] + 1 levels = [0] * max_level levels[0] = 1 for i in a: levels[i] += ...
vfc_2018
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CNTGRP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 3\n1 2 1\n4 6\n1 2 1\n3 2\n2 2\n", "output": "2\n0\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
795
Solve the following coding problem using the programming language python: In a cricket game, an over is a set of six valid deliveries of balls performed by one player ― the bowler for this over. Consider a cricket game with a series of $N$ overs (numbered $1$ through $N$) played by $K$ players (numbered $1$ through $K...
```python t=int(input()) for i in range(t): n,k,l=map(int,input().split()) if k*l<n: print(-1) elif (k==1 and n>1): print(-1) else: for j in range(n): print((j%k)+1,end=' ') print() ```
vfc_2022
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BOWLERS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 3 2\n5 4 1\n", "output": "1 2 3 2\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
796
Solve the following coding problem using the programming language python: There's an array A consisting of N non-zero integers A1..N. A subarray of A is called alternating if any two adjacent elements in it have different signs (i.e. one of them should be negative and the other should be positive). For each x from 1 ...
```python test=int(input()) for i in range(test): n=int(input()) a=list(map(int,input().split())) b=[0]*(n+2) b[n-1]=1 for i in range(n-2,-1,-1): if(a[i]*a[i+1]<0): b[i]=b[i+1]+1 else: b[i]=1 for i in range(n): print(b[i], end=' ') print() ```
vfc_2026
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK68/problems/ALTARAY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4\n1 2 3 4\n4\n1 -5 1 -5\n6\n-5 -1 -1 2 -2 -3\n", "output": "1 1 1 1\n4 3 2 1\n1 1 3 2 1 1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
797
Solve the following coding problem using the programming language python: Chef is a very experienced and well-known cook. He has participated in many cooking competitions in the past — so many that he does not even remember them all. One of these competitions lasted for a certain number of days. The first day of the c...
```python # cook your dish here d=["saturday","sunday","monday","tuesday","wednesday","thursday","friday"] t=int(input()) for i in range(t): s,e,l,r=map(str,input().split()) l,r=int(l),int(r) v=(d.index(e)-d.index(s)+8)%7 c=r+1 for i in range(l,r+1): if i%7==v: c=i break if c>r: print('impossible') eli...
vfc_2030
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EVENT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nsaturday sunday 2 4\nmonday wednesday 1 20\nsaturday sunday 3 5\n", "output": "2\nmany\nimpossible\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
798
Solve the following coding problem using the programming language python: Zonal Computing Olympiad 2013, 10 Nov 2012 Little Red Riding Hood is carrying a basket with berries through the forest to her grandmother's house. The forest is arranged in the form of a square N × N grid of cells. The top left corner cell, w...
```python # cook your dish here import sys def dist(a,b): return abs(a[0]-b[0])+abs(a[1]-b[1]) n, m = map(int, input().split()) matrix=[] id_matrix=[[0 for i in range(n)] for i in range(n)] for _ in range(n): matrix.append(list(map(int, input().split()))) charms=[] for _ in range(m): x,y,lungh = map(int, i...
vfc_2034
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO13002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 3\n3 3 2 4 3 \n2 1 -1 -2 2 \n-1 2 4 3 -3 \n-2 2 3 2 1 \n3 -1 2 -1 2 \n1 2 2\n4 5 2\n4 2 1\n\n", "output": "YES\n19\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
799
Solve the following coding problem using the programming language python: One upon a time there were three best friends Abhinav, Harsh, and Akash decided to form a team and take part in ICPC from KIIT. Participants are usually offered several problems during the programming contest. Long before the start, the friend...
```python # cook your dish here n = int(input()) count = 0 for _ in range(n): L = list(map(int, input().split())) if (L.count(1)>=2): count+=1 print(count) ```
vfc_2038
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COX22020/problems/ACODEX2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1 0\n1 1 1\n1 0 0\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
800
Solve the following coding problem using the programming language python: Chef has provided with a sequence of integers of length $N$ arranged in an unsorted fashion. The elements of the sequence are ordered as ${A1,A2,A3.....A'N}$ The task of the chef is to identify the highest and lowest value among the given sequen...
```python n=int(input()) a=list(map(int,input().split())) a.sort() print(a[-1],a[0]) ```
vfc_2042
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SPTC2020/problems/CPCEJC2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n3 2 7 9 4\n", "output": "9 2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
801
Solve the following coding problem using the programming language python: Chefina has two sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_N$. She views two sequences with length $N$ as identical if, after they are sorted in non-decreasing order, the $i$-th element of one sequence is equal to the $i$-th elem...
```python from collections import Counter tc=int(input()) for k in range(tc): n=int(input()) a=list(map(int, input().rstrip().split())) b= list(map(int, input().rstrip().split())) cc=sorted(a+b) #print('cc = ',cc) p=[] q=[] #print('len(cc) = ',len(cc)) #print('len = ',(2*n)) #rx=0 for i in range(0,(2*n),2): ...
vfc_2046
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHFNSWPS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n1\n2\n2\n1 2\n2 1\n2\n1 1\n2 2\n", "output": "-1\n0\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
802
Solve the following coding problem using the programming language python: Chef likes to solve difficult tasks. This time, he tried to solve the Big Famous Unsolvable $A+B=C$. One of his friends played a prank on Chef and randomly shuffled the bits in $A$ and $B$ (independently in each number). However, the funny thing...
```python import math def csb(n): count = 0 while (n): n &= (n-1) count+= 1 return count def f(ca,cb,i,cf,C,n,dp): if ca<0 or cb<0: return 0 if i==n: if ca==0 and cb==0 and cf==0: return 1 return 0 st=str(ca)+" "+str(cb)+" "+str(cf)+" "+str(i) if dp.get(st)!=None: return dp[st] x=0 if (C&...
vfc_2050
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFADD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2 3\n369 428 797\n", "output": "2\n56\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
803
Solve the following coding problem using the programming language python: In poker, you have 5 cards. There are 10 kinds of poker hands (from highest to lowest): - royal flush - ace, king, queen, jack and ten, all in the same suit - straight flush - five cards of the same suit in sequence, such as 10,9,8,7,6 of cl...
```python cards = ['A','2','3','4','5','6','7','8','9','T','J','Q','K'] def royal_flush(arr): nonlocal ans, confirm rf_set = 'TJQKA' rf = 1 for char in arr: if char[0] not in rf_set: rf = 0 break if rf : if len(set(suit)) == 1: ans = 'royal flush' confirm = 1 def straight_flush(arr): # and 'strai...
vfc_2054
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/POKER", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nAH KH QH TH JH\nKH 5S 3C 5C 7D\nQH QD 2S QC 2C\n", "output": "royal flush\npair\nfull house\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
804
Solve the following coding problem using the programming language python: Bitland declared war on Chefland and sent an army to fight them, but Chefland defended efficiently and Bitland's army has been reduced to N$N$ soldiers. They have no chance of winning the war and do not want to surrender, so they are planning to...
```python import numpy as np for _ in range(int(input())): n = int(input())-1;soldiers = [int(j) for j in input().split()] force = int(input());attacks = np.zeros(2*n,dtype=int);attacks[:n] = np.array(soldiers);attacks[n:2*n] = attacks[:n];shield = [0 for _ in range(n)];pow_of_2 = 1 while n // pow_of_2 > 0: ...
vfc_2058
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHFWAR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n12 34 45 5\n10\n5\n10 15 43 20\n5\n", "output": "possible\n4 100\nimpossible\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
805
Solve the following coding problem using the programming language python: in Chefland, there is a very famous street where $N$ types of street food (numbered $1$ through $N$) are offered. For each valid $i$, there are $S_i$ stores that offer food of the $i$-th type, the price of one piece of food of this type is $V_i$...
```python t=int(input()) while(t): n=int(input()) l=[] for i in range(n): l.append(list(map(int,input().split()))); m=[] for i in l: m.append((i[1]//(i[0]+1))*i[2]) res=max(m) print(res) t=t-1 ```
vfc_2062
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/STFOOD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n4 6 8\n2 6 6\n1 4 3\n1\n7 7 4\n", "output": "12\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
806
Solve the following coding problem using the programming language python: John was learning mathematics and was very bored. Jane his best friend gave him a problem to solve. The description of the problem was as follows:- You are given a decimal number $N$(1<=$N$<=$10^9$) and three integers $A$, $B$, $C$. Steps to ...
```python # Why do we fall ? So we can learn to pick ourselves up. t = int(input()) for _ in range(0,t): n = int(input()) abc = [int(i) for i in input().split()] i = 0 lst = [n] for _ in range(0,100): k = str(lst[-1]/abc[i%3]).split('.') if int(k[1][0]) > 0: ...
vfc_2066
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PROC2020/problems/WLIST", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n56\n3 5 7\n4\n0\n1\n2\n3\n", "output": "56\n6\n2\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
807
Solve the following coding problem using the programming language python: You are given an array A of size N. Let us list down all the subarrays of the given array. There will be a total of N * (N + 1) / 2 subarrays of the given array. Let us sort each of the subarrays in descending order of the numbers in it. Now y...
```python # cook your dish here for _ in range(int(input())): n,q=map(int,input().split()) l=[int(i) for i in input().split()] qry=[int(input()) for i in range(q)] def cmp(sub1,sub2): for i in range(len(sub1)): if sub1[i]>sub2[i]: return 1 if sub1[i]<sub2[i]: return 2 return 1 maxl=[] for i i...
vfc_2070
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/KTHMAX", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n3 1 2 4\n1\n5\n", "output": "4\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
808
Solve the following coding problem using the programming language python: One day Chef was playing with numbers. He loves Lowest Common Multiple (LCM) too much and he is a very curious guy. He always try to do new things. Now he want to make a large number with it. But he doesn't want to take too many numbers. He is ...
```python from fractions import gcd for testCases in range(eval(input())): n = eval(input()) if n == 1: print('1') elif n == 2: print('2') elif n == 3: print('6') else: c = n*(n-1) k = n - 2 while True: if gcd(k,n-1) == 1 and gcd(k,n) == 1: break k -= 1 d = (n-1)*(n - 2) k1 = n - 3 whil...
vfc_2074
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDX2015/problems/CDXLRG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9\n7\n", "output": "504\n210\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
809
Solve the following coding problem using the programming language python: Zaikia has $N$ sticks of distinct positive lengths $A_1,A_2,\dots,A_N$. For no good reason at all, he wants to know if there is a triplet of sticks which when connected end-to-end will form a non-trivial triangle. Here non-trivial refers to a tr...
```python #from itertools import combinations as c n=int(input());l=list(map(int,input().split())) l1=[] if(n<3): print("NO") else: l.sort() for i in range(n-2): if(l[i]+l[i+1]>l[i+2]): l1.append([l[i+2],l[i+1],l[i]]) if(len(l1)!=0): print("YES") print(*max(l1)) else...
vfc_2078
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COJK2020/problems/CKOJ20A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n4 2 10 3 5\n", "output": "YES\n5 4 3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
810
Solve the following coding problem using the programming language python: Chef is frustrated in this lockown. So to overcome this he plans to travel various mountains. He is very strange so he sets some conditions for $each$ Type 2 query(mentioned below) (i.e. $1$ $i$) : - Let Chef has travelled till $ith$ mountain f...
```python # cook your dish here from bisect import bisect_left def BinarySearch(a, x): i = bisect_left(a, x) if i != len(a) and a[i] == x: return i else: return -1 for _t in range(int(input())): _n, q = list(map(int, input().split())) mounts = list(map(int, input().split())) for _q in range(q): que...
vfc_2082
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/STR2020/problems/CHFMNT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10 5\n1 3 5 4 5 6 7 8 4 5\n1 7\n1 3\n1 1\n0 2 7\n1 3\n", "output": "-1\n6\n5\n5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
811
Solve the following coding problem using the programming language python: Indian National Olympiad in Informatics 2013 Calvin wakes up early one morning and finds that all his friends in the hostel are asleep. To amuse himself, he decides to play the following game : he draws a sequence of N squares on the ground, num...
```python try: n, k=map(int, input().split()) arr=list(map(int, input().split())) forward = [0]*(n+1) backward= [0]*(n+1) backward[0]=arr[0] backward[1]=arr[0]+arr[1] for i in range(k, n): forward[i]=arr[i] +max(forward[i-1],forward[i-2]) for i in range(2, n): backward[i]=arr[...
vfc_2086
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/INOIPRAC/problems/INOI1301", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "and output corresponding to the example above.\nSample input\n5 2\n5 3 -2 1 1\nSample output\n11\nNote : Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print s...
apps
verifiable_code
812
Solve the following coding problem using the programming language python: DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers. You are given the information of DevuLand by an array D of size n. If D[i] is non-negative, i...
```python # cook your dish here for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) curr = 0 ans = 0 for x in a: curr += x ans += abs(curr) print(ans) ```
vfc_2090
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRLADDU", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n5 -5\n2\n-5 5\n3\n1 2 -3\n", "output": "5\n5\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
813
Solve the following coding problem using the programming language python: Harsh, like usual, started studying 6 months before for his end semester examinations. He was going to complete his 8th revision of the whole syllabus, when suddenly Pranav showed up in his room with the last year's question paper for their algo...
```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()] n,k = ip() x = ip() x.sort() if k == 1: a = x[n//2] b = x[n//2-1] else: s = sum(x) a = s//n b = a + 1 sa = sum([abs((a-i)*...
vfc_2094
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COJK2020/problems/CKOJ20B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 1\n6 1 7\n", "output": "6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
814
Solve the following coding problem using the programming language python: Tzuyu gave Nayeon a strip of $N$ cells (numbered $1$ through $N$) for her birthday. This strip is described by a sequence $A_1, A_2, \ldots, A_N$, where for each valid $i$, the $i$-th cell is blocked if $A_i = 1$ or free if $A_i = 0$. Tzuyu and ...
```python for _ in range(int(input())): n=int(input()) def maxConsequtiveOnes(lst): _max = 0 _ones = [0] for i in lst: if i == 0: _max += 1 if i == 1: _max = 0 _ones.append(_max) return max(_ones) a = list(map(int, input().split())) b = maxConsequtiveOnes(a) if (b % 2 == 0): print("N...
vfc_2098
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ARRGAME", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n7\n1 1 0 0 0 1 1\n8\n1 0 1 1 1 0 0 1\n4\n1 1 0 1\n4\n1 1 1 1\n", "output": "Yes\nNo\nYes\nNo\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
815
Solve the following coding problem using the programming language python: Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently. The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the pu...
```python # cook your dish here from collections import deque primes = {2,3,5,7,11,13,17} edges = [(0,3),(0,1),(1,2),(1,4),(2,5),(3,4),(3,6),(4,5),(4,7),(5,8),(6,7),(7,8)] x = [1,2,3,4,5,6,7,8,9] avail = {tuple(x):0} q = deque([x]) while q: curr = q.popleft(); for e in edges: if curr[e[0]]+cur...
vfc_2102
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/H1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n\n7 3 2 \n4 1 5 \n6 8 9 \n\n9 8 5 \n2 4 1 \n3 7 6 \n\n\n", "output": "6\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
816
Solve the following coding problem using the programming language python: This is another problem about Indraneel's library. His library has one long shelf. His books are numbered and he identifies the books by their number. Each book has a distinct number. He has lost many books, since many of his friends borrow his ...
```python def bookList(): numBooks=int(input()) bookNum=[int(x) for x in input().split()] takenBooks=int(input()) for i in range(takenBooks): takenBookPos=(int(input())) a=bookNum[takenBookPos-1] print(a) bookNum.remove(a) bookList() ```
vfc_2106
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IARCSJUD/problems/BOOKLIST", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n26 1 42 15 3\n2\n3\n4\n", "output": "42\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
817
Solve the following coding problem using the programming language python: Amit is going on a date and he wants to gift his date an array of positive numbers. But he is running short on money. He already has an array of numbers in design. Cost of an array of numbers is the sum of elements in it. But he wants to minimiz...
```python for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) su=l[0] for i in range(1,n): su^=l[i] print(su) ```
vfc_2110
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/INDC2021/problems/DATEGIFT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n8 4 1 5 0\n5\n1 2 4 0 8\n2\n10 10\n", "output": "8\n15\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
818
Solve the following coding problem using the programming language python: We all know Gru loves Agnes very much. One day Agnes asked Gru to answer some of her queries. She lined up $N$ minions in a straight line from $1$ to $N$. You are given an array $A$ which contains the height of minions. Agnes will ask him sever...
```python # cook your dish here for _ in range(int(input())): n=int(input()) a=[int(x) for x in input().split()] sum=0 for i in range(n): if a[i]%2==0: sum+=1 a[i]=sum q=int(input()) while q: l,r=map(int,input().split()) if l!=1: c=a[r-1]-a[l-2] else: c=a[r-1] if c==0: print("ODD") els...
vfc_2114
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MINIAND", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n1 3 2 4 5\n3\n1 2\n1 5\n3 4\n", "output": "ODD\nEVEN\nEVEN\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
819
Solve the following coding problem using the programming language python: Motu wants to learn Cricket from a coach, but firstly coach wants to test his IQ level, so he gave Motu $1$ $Red$ $ball$ and $1$ $Black$ $ball$ , and asked him to buy other $x – 1$ red balls and other $y – 1$ black balls from the market. But he ...
```python T=int(input()) while T: x,y=map(int,input().split()) while(y): x, y = y, x % y if x==1: print("YES") else: print("NO") T-=1 ```
vfc_2118
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CCOD2020/problems/NITGOC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 2\n2 3\n", "output": "YES\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
820
Solve the following coding problem using the programming language python: The Little Elephant from the Zoo of Lviv is going to the Birthday Party of the Big Hippo tomorrow. Now he wants to prepare a gift for the Big Hippo. He has N balloons, numbered from 1 to N. The i-th balloon has the color Ci and it costs Pi dol...
```python # cook your dish here for _ in range(int(input())): n,m = list(map(int,input().split())) colors = [0]*41; cost = [0]*41 color = 0 for i in range(n): cc,pp = list(map(int,input().split())) colors[cc] += 1 cost[cc] += pp for i in colors: if i>0: color += 1 ...
vfc_2122
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LEBALONS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n1 4\n2 7\n2 1\n1 4\n2 7\n", "output": "11.000000000\n7.333333333\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
821
Solve the following coding problem using the programming language python: You are given $n$ intervals on the $X$ axis. Each interval $i$ is specified by its ends $[L_i, R_i]$. You want to color each interval either blue or yellow. After coloring all the intervals, the $X$ axis will will have $4$ colors: - White, the p...
```python for _ in range(int(input())): n = int(input()) ls = [] rs = [] lrs = [] for i in range(n): l, r = map(int, input().split()) ls.append(l) rs.append(r) lrs.append((l, r, i)) lrs.sort() c = 0 maxi = -1 res = [-1] * n for l, r, i in lrs: if ls[i] > maxi: maxi = rs[i] res[i] = c el...
vfc_2126
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/COLINT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n3 7\n2 5\n6 9\n", "output": "100\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
822
Solve the following coding problem using the programming language python: Doubleville, a small town in Texas, was attacked by the aliens. They have abducted some of the residents and taken them to the a spaceship orbiting around earth. After some (quite unpleasant) human experiments, the aliens cloned the victims, and...
```python def main(): while True: [n, m] = [int(i) for i in input().split()] if n == m and n == 0: break cache = {} for i in range(n): dna = input().rstrip('\n') if dna in cach...
vfc_2130
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PRFT2012/problems/PD11", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "9 6\nAAAAAA\nACACAC\nGTTTTG\nACACAC\nGTTTTG\nACACAC\nACACAC\nTCCCCC\nTCCCCC\n0 0\n\n\n", "output": "1\n2\n0\n1\n0\n0\n0\n0\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
823
Solve the following coding problem using the programming language python: Chef likes problems which using some math. Now he asks you to solve next one. You have 4 integers, Chef wondering is there non-empty subset which has sum equals 0. -----Input----- The first line of input contains T - number of test cases. Each...
```python # cook your dish here # cook your dish here t = int(input()) while t: t-=1 c=0 ar=[int(i) for i in input().strip().split()] for i in range(1,16): b=bin(i)[2:].zfill(4) s=0 for i in range(4): if b[i]=='1': s+=ar[i] if(s==0): c=1 break print("Yes" if c==1 else "No") ```
vfc_2134
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFSETC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 2 0 3\n1 2 4 -1\n1 2 3 4\n", "output": "Yes\nYes\nNo\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
824
Solve the following coding problem using the programming language python: Corruption is on the rise in the country of Freedonia, Gru's home. Gru wants to end this for good and for that he needs the help of his beloved minions. This corruption network can be represented in the form of a tree having N$N$ nodes and N−1$N...
```python from sys import stdin,stdout input=stdin.readline n=int(input()) a=[[] for i in range(n)] for i in range(n-1): u,v=map(int,input().split()) a[u-1].append(v-1) a[v-1].append(u-1) b=[0]*n vis=[0]*n st=[(0,0)] vis[0]=1 pa=[0]*n while st: x,y=st.pop() b[x]=y for i in a[x]: ...
vfc_2138
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MINIKILL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "7\n1 2\n1 3\n2 4\n2 5\n3 6\n3 7\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
825
Solve the following coding problem using the programming language python: Our Chef is doing what he is best at, COOKING A BARBECUE for his guests. He has invited all of us, and taking the help of his apprentice to smoke the barbecues. The chef has got BBQ sticks, each can take N fillings, and he presents N distinctly ...
```python testcase = int(input()) for case in range(testcase): n = int(input()) print(2**(n-2)+1) print('\n') ```
vfc_2142
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AGTK2012/problems/ALGBBQ", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n", "output": "5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
826
Solve the following coding problem using the programming language python: Let's consider a rectangular table R consisting of N rows and M columns. Rows are enumerated from 1 to N from top to bottom. Columns are enumerated from 1 to M from left to right. Each element of R is a non-negative integer. R is called steady ...
```python # This is not my code, it's Snehasish Karmakar's. Refer to http://www.codechef    .com/viewsolution/7153774 # for original version. # Submitting it to try and work out if it can be sped up. def compute_nCr(n,r) : C[0][0]=1 for i in range(1,n+1) : # print "i",i C[i][0]=1 for j in range(1,min(i,r)...
vfc_2146
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/STDYTAB", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 1\n2 2\n2 3\n", "output": "2\n25\n273\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
827
Solve the following coding problem using the programming language python: Limak has a string S, that consists of N lowercase English letters. Limak then created a new string by repeating S exactly K times. For example, for S = "abcb" and K = 2, he would get "abcbabcb". Your task is to count the number of subsequences ...
```python try: t=int(input()) for i in range(t): n,k=map(int,input().split()) s=input() l=[-1]*len(s) numb=s.count('b') x=numb for j in range(len(s)): if(s[j]=='a'): l[j]=numb if(s[j]=='b'): numb=...
vfc_2150
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ABREPEAT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 2\nabcb\n7 1\naayzbaa\n12 80123123\nabzbabzbazab\n\n\n", "output": "6\n2\n64197148392731290\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
828
Solve the following coding problem using the programming language python: Chef lives in a big apartment in Chefland. The apartment charges maintenance fees that he is supposed to pay monthly on time. But Chef is a lazy person and sometimes misses the deadlines. The apartment charges 1000 Rs per month as maintenance fe...
```python for i in range(int(input())): a=int(input()) b=input().split() if '0' in b: print(100*(a-b.index('0'))+b.count('0')*1000) else: print(0) ```
vfc_2154
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFAPAR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n1 1\n2\n0 0\n3\n0 1 0\n2\n0 1\n\n\n", "output": "0\n2200\n2300\n1200\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
829
Solve the following coding problem using the programming language python: Zonal Computing Olympiad 2013, 10 Nov 2012 N teams participate in a league cricket tournament on Mars, where each pair of distinct teams plays each other exactly once. Thus, there are a total of (N × (N-1))/2 matches. An expert has assigned a st...
```python # cook your dish here # cook your dish here from itertools import combinations n = int(input()) t = list(combinations(list(map(int, input().split())), 2)) ar = 0 for i in t: ar += abs(i[0] - i[1]) print(ar) ```
vfc_2158
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO13001", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 10 3 5\nSample output\n23\nTest data\nIn all subtasks, the strength of each team is an integer between 1 and 1,000 inclusive.\nSubtask 1 (30 marks) : 2 ≤ N ≤ 1,000.\nSubtask 2 (70 marks) : 2 ≤ N ≤ 200,000.\nLive evaluati...
apps
verifiable_code
830
Solve the following coding problem using the programming language python: Vivek was quite bored with the lockdown, so he came up with an interesting task. He successfully completed this task and now, he would like you to solve it. You are given two strings $A$ and $B$, each with length $N$. Let's index the characters ...
```python for _ in range(int(input())): n=int(input()) a=input() b=input() l=[] flag=0 for i in range(n): if b[i]!=a[i]: if b[i] in a and b[i]<a[i]: l.append(b[i]) else: flag=1 break if flag==1: print(-1) else: if l==[]: print(0) else: l = sorted(list(set(l)), reverse = True) ...
vfc_2162
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CONVSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\nabcab\naabab\n3\naaa\naab\n2\nde\ncd\n", "output": "2\n3 1 2 4\n3 0 1 3\n-1\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
831
Solve the following coding problem using the programming language python: Bear Limak has a sequence of N non-negative integers A1, A2, ..., AN. He defines the score of a segment (consecutive subsequence) as its sum of elements modulo P (not necessarily prime). Find the maximum score of a non-empty segment, and also fi...
```python for _ in range(int(input())): n,m=input().split() n,m=int(n),int(m) x=y=c=0 l=list(map(int,input().split())) for i in range(n): for j in range(i,n): x=x+l[j] if (x%m)>y: y=x%m c=1 elif y==(x%m): c+=1 x = 0 print(y,c) ```
vfc_2166
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BEARSEG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 3\n1 2\n3 5\n2 4 3\n3 100\n1 3 5\n4 3\n1 2 3 4\n", "output": "2 1\n4 2\n9 1\n2 2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
832
Solve the following coding problem using the programming language python: Chef has a sequence $A_1, A_2, \ldots, A_N$. This sequence has exactly $2^N$ subsequences. Chef considers a subsequence of $A$ interesting if its size is exactly $K$ and the sum of all its elements is minimum possible, i.e. there is no subsequen...
```python def fact(n): if n<2: return 1 return n * fact(n-1) def ncr(n, r): return fact(n)// (fact(r)*fact(n-r)) t=int(input()) for _ in range(t): n, k = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() count_z = a.count(a[k-1]) count_z_seq = a[:k].count(a[k-1]) print(ncr(c...
vfc_2170
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFINSQ", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 2\n1 2 3 4\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
833
Solve the following coding problem using the programming language python: Galileo's latest project involves determining the density of stars in certain regions of the sky. For this purpose he started looking for datasets online, and discovered a dataset on Newton's blog. Newton had decomposed the night sky into a Voro...
```python import sys def main(): s=sys.stdin.readline n, m = list(map(int, s().split())) nums={} for i in range(1, n+1): nums[i]=list(map(int, s().split())) cases=int(s()) for case in range(cases): px, py, qx, qy = list(map(int, s().split())) ans=[] for i in range(px, qx+1): for j in range(py-1, qy): ...
vfc_2174
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/DMNT2012/problems/COUNTSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 3\n10 10 10\n10 10 10\n10 10 10\n4\n1 1 1 1\n1 1 3 3\n2 1 3 3\n3 1 3 3\n", "output": "10\n90\n60\n30\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
834
Solve the following coding problem using the programming language python: Striver$Striver$ wants to strive hard in order to reach his goals, hence asks his mentor to give him a question for which he has to strive hard. The mentor gives Striver$Striver$ a N$N$ X N$N$ matrix consisting of lowercase characters (′a′$'a'$...
```python a=int(input()) for _ in range(a): c,d=list(map(int,input().split())) crr=[[[0,0] for i in range(c+1)] for j in range(c+1)] trr=[] for i in range(c): kk=list(input().split()) trr.append(kk) for i in range(1,c+1): for j in range(1,c+1): if(trr[i-...
vfc_2178
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AARA2018/problems/ARMBH5", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 2\na b a\na c d\nb a b\n1 3\n3 3\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
835
Solve the following coding problem using the programming language python: Chef is stuck in a two dimensional maze having N rows and M columns. He needs to get out of the maze as soon as possible and arrive at the kitchen in order to serve his hungry customers. But, he can get out of the maze only if he is able to succ...
```python t = eval(input()) for _ in range(t): n, m = list(map(int, input().split())) if n*m == 2: print('Yes') elif (n*m)%2 == 0 and m != 1 and n != 1: print('Yes') else: print('No') ```
vfc_2182
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/APRIL16/problems/CHEFPATH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2 2\n", "output": "Yes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
836
Solve the following coding problem using the programming language python: Little Egor is a huge movie fan. He likes watching different kinds of movies: from drama movies to comedy movies, from teen movies to horror movies. He is planning to visit cinema this weekend, but he's not sure which movie he should watch. Ther...
```python def bestMovie(): tests=int(input()) for t in range(tests): n = int(input()) L = list(map(int, input().split())) R = list(map(int, input().split())) maxIndex = -1 maxValue = 0 for i in range(n): prod = L[i]*R[i] if maxValue < prod: maxValue = prod maxIndex = i elif maxValue == pr...
vfc_2186
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK69/problems/MOVIEWKN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n1 2\n2 1\n4\n2 1 4 1\n2 4 1 4\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
837
Solve the following coding problem using the programming language python: Find sum of all the numbers that are multiples of 10 and are less than or equal to a given number "N". (quotes for clarity and be careful of integer overflow) -----Input----- Input will start with an integer T the count of test cases, each case...
```python for t in range(eval(input())): n=eval(input()) n-=n%10 n/=10 print(n*(n+1)/2*10) ```
vfc_2190
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/KQPM2015/problems/SUMMATH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10\n", "output": "10\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
838
Solve the following coding problem using the programming language python: Chef and his girlfriend are going to have a promenade. They are walking along the straight road which consists of segments placed one by one. Before walking Chef and his girlfriend stay at the beginning of the first segment, they want to achieve...
```python T = int(input()) for i in range(T): x = int(input()) l= [int(x) for x in input().split()] t=[] for i in range(len(l)): t.append(l[i]+i) print(max(t)) ```
vfc_2194
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WALK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n6 5 4 3 2\n5\n3 4 3 1 1\n", "output": "6\n5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
839
Solve the following coding problem using the programming language python: Dhiraj loves Chocolates.He loves chocolates so much that he can eat up to $1000$ chocolates a day. But his mom is fed up by this habit of him and decides to take things in her hand. Its diwali Season and Dhiraj has got a lot of boxes of chocolat...
```python def isSubsetSum(arr, n, sum): subset = [ [False for j in range(sum + 1)] for i in range(3) ] for i in range(n + 1): for j in range(sum + 1): if (j == 0):subset[i % 2][j] = True elif (i == 0):subset[i % 2][j] = False elif (arr[i - 1] <= j):subset[i % 2...
vfc_2198
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COFY2020/problems/GKSMNLC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n20\n5\n8 7 2 10 5\n11\n4\n6 8 2 10\n", "output": "1\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
840
Solve the following coding problem using the programming language python: The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K(odd) to form a new pattern. Help the chef to code this pattern problem. -----Input:----- - First-line will contain $T$, the number of test...
```python def func(num): for i in range(num): if i < num//2 + 1: print(' '*i, end='') print('*') else: print(' '*(num-i-1), end='') print('*') for _ in range(int(input())): num = int(input()) func(num) ```
vfc_2202
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY45", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n3\n5\n7\n", "output": "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
841
Solve the following coding problem using the programming language python: The Petrozavodsk camp takes place in about one month. Jafar wants to participate in the camp, but guess what? His coach is Yalalovichik. Yalalovichik is a legendary coach, famous in the history of competitive programming. However, he is only wil...
```python M = 10 ** 9 + 7 for _ in range(int(input())): s,p,m,r = list(map(int, input())),0,1,0 for d in reversed(s): p += d * m m = m * 10 % M for d in s: r = (r * m + p) % M p = (p * 10 - (m - 1) * d) % M print(r) ```
vfc_2206
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/YVNUM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n123\n\n", "output": "123231312\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
842
Solve the following coding problem using the programming language python: The chef is trying to solve 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 case...
```python t=int(input()) for _ in range(t): n=int(input()) b=1 if n%2: c=n-2 for j in range(n//2): print(" "*j+str(b) +" "*c+ str(b)) b+=1 c-=2 print(" "*(n//2)+str(b)+" "*(n//2)) b+=1 c=1 for j in range(n//2): ...
vfc_2210
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY41", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n3\n4\n", "output": "1 1\n2 2\n3\n4 4\n5 5\n1 1\n2\n3 3\n1 1\n22\n33\n4 4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
843
Solve the following coding problem using the programming language python: You are given N integer sequences A1, A2, ..., AN. Each of these sequences contains N elements. You should pick N elements, one from each sequence; let's denote the element picked from sequence Ai by Ei. For each i (2 ≤ i ≤ N), Ei should be stri...
```python t=int(input()) for _ in range(t): n=int(input()) grid=[] for _ in range(n): temp=[] temp=list(map(int,input().strip().split())) temp.sort() grid.append(temp) curr=max(grid[n-1]) total=curr for i in range(n-2,0-1,-1): flag=0 for j in range(n-1,0-1,-1): if grid[i][j]<curr: flag=1...
vfc_2214
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MAXSC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1 2 3\n4 5 6\n7 8 9\n", "output": "18\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
844
Solve the following coding problem using the programming language python: Little kids, Jack and Evan like playing their favorite game Glass-and-Stone. Today they want to play something new and came across Twitter on their father's laptop. They saw it for the first time but were already getting bored to see a bunch of...
```python def getInput(): N_k = input().split() N =int(N_k[0]) k =int(N_k[1]) list = [] output = [] count = 0 for i in range(0,k): val = input() if(val!="CLOSEALL"): val=val.split() val = int (val[1]) if val not in list: count= count +1 list.append(val) else: list.remove(val) coun...
vfc_2218
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK23/problems/TWTCLOSE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3 6\nCLICK 1\nCLICK 2\nCLICK 3\nCLICK 2\nCLOSEALL\nCLICK 1\n", "output": "1\n2\n3\n2\n0\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
845
Solve the following coding problem using the programming language python: Give me Biscuit Sunny wants to make slices of biscuit of size c * d into identical pieces. but each piece is a square having maximum possible side length with no left over piece of biscuit. Input Format The first line contains an integer N. ...
```python def __gcd(a, b): # Everything divides 0 if (a == 0 or b == 0): return 0; # base case if (a == b): return a; # a is greater if (a > b): return __gcd(a - b, b); return __gcd(a, b - a); # Function to find # number of squares def NumberOfSquares(x, y): # Here in built PHP...
vfc_2222
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COM12020/problems/CODE_00", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n6 9\n", "output": "1\n6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
846
Solve the following coding problem using the programming language python: -----Problem Statement----- Harry Potter has one biscuit and zero rupee in his pocket. He will perform the following operations exactly $K$ times in total, in the order he likes: - Hit his pocket, which magically increases the number of biscuits...
```python K,A,B = map(int,input().split()) if A + 2 > B: print(K + 1) return start = A - 1 K -= start ans = K//2 * (B-A) + K%2 + start + 1 print(ans) ```
vfc_2226
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SCAT2020/problems/SC_04", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2 6\n", "output": "7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
847
Solve the following coding problem using the programming language python: Did you know that the people of America eat around 100 acres of pizza per day ? Having read this fact on internet, two chefs from the Elephant city, Arjuna and Bhima are set to make pizza popular in India. They organized a social awareness camp,...
```python a= [0, 0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 0, 5, 2, 2, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 2, 7, 4, 0, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 2, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 3, 7, 4, 8, 1, 1, 2, 0, 3, 1, 1, 0, 3, 3, 2, 2, 4, 4, 5, 5, 9, 3, 3, 0, 1, 1, 3, 0, 2, 1, 1, 0, 4, 5, 3, 7, ...
vfc_2230
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BIGPIZA", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2\n4\n5\n6\n", "output": "Arjuna\nArjuna\nBhima\nArjuna\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
848
Solve the following coding problem using the programming language python: Coach Moony wants the best team to represent their college in ICPC. He has $N$ students standing in a circle with certain rating $X_i$ on a competitive coding platform. It is an established fact that any coder with more rating on the platform is...
```python # cook your dish here #Moony and ICPC team T = int(input()) for i in range(T): N,data = int(input()),list(map(int,input().split())) if(N==3): print(sum(data)) else: best = data[0]+data[1]+data[2] overall = best k=len(data) for i in range(1,k-2):...
vfc_2234
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COG2020/problems/COG2002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n7\n10 40 30 30 20 0 0\n", "output": "100\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
849
Solve the following coding problem using the programming language python: We all know how great ABD aka AB-DE-VILLIERS is. However his team mates were jealous of him and posed a problem for him to solve.The problem description is as follows : Given an array of integers,find the length of the largest subarray(contiguo...
```python n=eval(input()) a=list(map(int,input().split())) c=m=0 maxi=max(a) for i in range(n): if a[i]==maxi: c+=1 m=max(c,m) else: c=0 print(m) ```
vfc_2238
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/BYTE2016/problems/BYTES11", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 4 8 3\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
850
Solve the following coding problem using the programming language python: Chef has a sequence of positive integers $A_1, A_2, \ldots, A_N$. He wants to split this sequence into two non-empty (not necessarily contiguous) subsequences $B$ and $C$ such that $\mathrm{GCD}\,(B) + \mathrm{GCD}\,(C)$ is maximum possible. Hel...
```python from math import gcd __author__ = 'Prateek' def test(): n = int(input()) a = list(map(int, input().split())) a = list(set(a)) n = len(a) if len(a) == 1: print(2 * a[0]) return g1 = [0 for i in range(n)] g2 = [0 for i in range(n)] g1[0] = a[0] ...
vfc_2242
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUMAGCD", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 \n4 \n4 4 7 6 \n\n", "output": "9\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
851
Solve the following coding problem using the programming language python: Mr. X has come up with a new string compression algorithm. Consider a string of length N which contains up to K distinct characters. The compression algorithm works as follows: Replace each maximal contiguous substring containing only one distin...
```python for _ in range(int(input())): n,k=map(int,input().split()) print(((2*n*(k-1))+2)/k) ```
vfc_2246
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/COMPEXP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 1\n3 2\n\n", "output": "2.0\n4.0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
852
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 t=int(input()) for t in range(t): n=int(input()) for i in range(0,n): for j in range(0,n): if i%2==0: if j%2==0: print(0,end="") else: print(1,end="") else: if j%2==0: ...
vfc_2250
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PTRN2021/problems/ITGUY56", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n2\n3\n4\n", "output": "0\n01\n10\n010\n101\n010\n0101\n1010\n0101\n1010\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
853
Solve the following coding problem using the programming language python: The new Formula 1 season is about to begin and Chef has got the chance to work with the Formula 1 technical team. Recently, the pre-season testing ended and the technical team found out that their timing system for qualifying was a little bit ...
```python # cook your dish here t=int(input()) for i in range(t): n=int(input()) if n<101: l1=[] l2=[] d=dict() for i in range(1,2*n+1): if i%2==0: l1.append(int(input())) else: l2.append(str(input())) r1=[] for i in l1: r1.append(i) l1.sort() ind=[] for i in l1: a=r1.index(i) ...
vfc_2254
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/TCFL2020/problems/TCFL20B", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\nHamilton\n75000\nVettel\n76000\nBottas\n75500\n2\nLeclerc\n666666\nVerstappen\n666777\n", "output": "Hamilton\nBottas\nVettel\nLeclerc\nVerstappen\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
854
Solve the following coding problem using the programming language python: A beautiful sequence is defined as a sequence that do not have any repeating elements in it. You will be given any random sequence of integers, and you have to tell whether it is a beautiful sequence or not. -----Input:----- - The first line o...
```python # cook your dish here for _ in range(int(input())): n = int(input()) arr = list(map(int,input().split())) l = [] for i in range(0, len(arr)): for j in range(i+1, len(arr)): if(arr[i] == arr[j]): l.append(arr[j]) if (len(l) ==0): print("...
vfc_2258
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ARYS2020/problems/FREQARRY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 2 3 4\n6\n1 2 3 5 1 4\n", "output": "prekrasnyy\nne krasivo\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
855
Solve the following coding problem using the programming language python: Accepts a string from the user and print the reverse string as the output without using any built-in function. -----Input:----- Each testcase contains of a single line of input, a string. -----Output:----- For each testcase, output in a single...
```python oo = int(input()) for i in range(oo): val = input() print(val[::-1]) ```
vfc_2262
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SPNT2020/problems/AODLS002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nTracy\n", "output": "ycarT\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
856
Solve the following coding problem using the programming language python: You are given a dataset consisting of $N$ items. Each item is a pair of a word and a boolean denoting whether the given word is a spam word or not. We want to use this dataset for training our latest machine learning model. Thus we want to choos...
```python t = int(input()) for _ in range(t): n = int(input()) a = {} for i in range(n): l = input() if l not in a: a[l] = 1 else: a[l] += 1 done = [] ans = 0 for i in a: if a[i] != 0: temp = [x for...
vfc_2266
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TRAINSET", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\nabc 0\nabc 1\nefg 1\n7\nfck 1\nfck 0\nfck 1\nbody 0\nbody 0\nbody 0\nram 0\n5\nvv 1\nvv 0\nvv 0\nvv 1\nvv 1\n\n", "output": "2\n6\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
857
Solve the following coding problem using the programming language python: Problem description. Dominic Toretto has taken his crew to compete in this years' Race Wars, a crew-on-crew tournament in which each member of one crew competes with a member of the other crew in a quarter mile drag race. Each win counts as one ...
```python testcases = int(input()) for i in range(testcases): n = int(input()) my = list(map(int,input().split())) opp = list(map(int,input().split())) my.sort(reverse = True) opp.sort(reverse = True) j = 0 k = 0 while(k < n): if(my[j] > opp[k]): j += 1 k += 1 print(j) ```
vfc_2270
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/EXCT2015/problems/RACEWARS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n5 4 1\n5 4 1\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
858
Solve the following coding problem using the programming language python: For Diwali, Chef arranges all $K$ laddus in a row in his sweet shop. Whenever a customer comes to buy laddus, chef follows a rule that each customer must buy all laddus on odd position. After the selection of the laddu, a new row is formed, and ...
```python # cook your dish here t=int(input()) while t>0: n=int(input()) if n==1: print(1) else: c,num=1,2 while num<n: num*=2 if num==n: print(num) else: print(num//2) t-=1 ```
vfc_2274
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK02020/problems/ITGUY11", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1\n5\n8\n", "output": "1\n4\n8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
859
Solve the following coding problem using the programming language python: Voritex a big data scientist collected huge amount of big data having structure of two rows and n columns. Voritex is storing all the valid data for manipulations and pressing invalid command when data not satisfying the constraints. Voritex lik...
```python import math import os import random import re import sys r = 100000 prev = 1 s = set() for i in range(1, r+1): now = i ^ prev s.add(now) prev = now s = list(s) t = int(input()) while t > 0: t -= 1 n, k = list(map(int, input().split())) if n > 3: if n % 2...
vfc_2278
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CMYC2020/problems/BTENG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 2\n5 5\n", "output": "2\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
860
Solve the following coding problem using the programming language python: Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and...
```python # cook your dish here import math T = int(input()) for _ in range(T): N, H = map(int, input().split()) A = list(map(int, input().split())) low, high = 1, max(A) while low != high: time = 0 mid = (low + high) // 2 for i in range(N): time += math.ceil(A[i] / mid) if time <= H : high = mid ...
vfc_2282
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MINEAT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 3\n1 2 3\n3 4\n1 2 3\n4 5\n4 3 2 7\n", "output": "3\n2\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
861
Solve the following coding problem using the programming language python: Recall the definition of the Fibonacci numbers: f1 := 1 f2 := 2 fn := fn-1 + fn-2 (n>=3) Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a,b]. -----Input----- The input contains several test cases. Each ...
```python #!/usr/bin/env python F = [1,1] def fibo(): for i in range(500): F.append(F[-2] + F[-1]) def main(): fibo() #print len(str(F[-1])) #print len(str(10**100)) while True: try: A, B = list(map(int, input().strip().split()[:2])) if A == 0 and B == 0: break print(len([x for x in F if x >= A and ...
vfc_2286
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PRFT2012/problems/PD32", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10 100\n1234567890 9876543210\n0 0\n", "output": "5\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
862
Solve the following coding problem using the programming language python: As we all know, Dhoni loves drinking milk. Once he and Sir Jadeja were invited in the inauguration of a Dairy company in Ranchi. The company had arranged n jars of milk from various breeds of cows , jar number i containing a[i] litres of...
```python cases = int(input()) for case in range(cases): N, M, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] jad = 0 P = M*K for milk in A: if(milk>P): jad += milk-P else: jad += milk%K print(jad%1000000007) ```
vfc_2290
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/BITC2016/problems/DMILK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 3 3\n15 8 10\n", "output": "9\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
863
Solve the following coding problem using the programming language python: The government has invited bids from contractors to run canteens at all railway stations. Contractors will be allowed to bid for the catering contract at more than one station. However, to avoid monopolistic price-fixing, the government has decl...
```python n=int(input()) l=[] dp=[] d={} for i in range(n): l.append(int(input())) d[i]=[] dp.append([0,0]) for i in range(n-1): a,b=list(map(int,input().split())) d[a-1].append(b-1) d[b-1].append(a-1) #print(l) #print(d) def dfs(ch,pa,visited): dp[ch][1]=l[ch] #print(dp[ch],ch+1) for i in...
vfc_2294
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IARCSJUD/problems/CATERCON", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n10\n20\n25\n40\n30\n30\n4 5\n1 3\n3 4\n2 3\n6 4\n", "output": "90\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
864
Solve the following coding problem using the programming language python: These days, chef is very much interested in Mathematics. He has started attending Recitations too! His hunger for problems is increasing day by day! Today, chef was a given a crumpled maths problem, which he is stuck with . He needs your help to...
```python testCases = int(input()) for c in range(testCases): n, k = list(map(int, input().split())) sum = 0 i = 0 power = 1 while i <= n: if k**power == i: power += 1 else: sum += i i +=1 answer = "Case #" + str(c + 1) + ": " + str(sum) print(answer) ```
vfc_2298
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/GSTS1601/problems/BUG2K16E", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 3\n20 2\n", "output": "Case #1: 43\nCase #2: 180\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
865
Solve the following coding problem using the programming language python: Given N, count how many permutations of [1, 2, 3, ..., N] satisfy the following property. Let P1, P2, ..., PN denote the permutation. The property we want to satisfy is that there exists an i between 2 and n-1 (inclusive) such that - Pj > Pj +...
```python try: for _ in range(int(input())): n = int(input()) print(0) if(n==1) else print(pow(2,n-1,10**9+7)-2) except EOFError: pass ```
vfc_2302
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CPERM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n3\n", "output": "0\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
866
Solve the following coding problem using the programming language python: There are n chef's in Chefland. There is a festival in Chefland in which each chef is asked to vote a person as his best friend. Obviously, a person can't vote himself as his best friend. Note that the best friend relationship is not necessaril...
```python t=int(input()) for _ in range(t): n=int(input()) l=list(map(int,input().split())) if sum(l)!=n or max(l)==n: print('-1') else: d=dict() ans=[-1]*n for i in range(0,n): d[i]=1 for i in range(n): if l[i]!=0: count=l[i] for k,v in list(d.items()): if count>0 and v==1 and i!=k: ...
vfc_2306
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFVOTE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n1 1 1\n3\n3 0 0\n3\n2 2 0\n", "output": "2 3 1\n-1\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
867
Solve the following coding problem using the programming language python: For her next karate demonstration, Ada will break some bricks. Ada stacked three bricks on top of each other. Initially, their widths (from top to bottom) are W1,W2,W3. Ada's strength is S. Whenever she hits a stack of bricks, consider the large...
```python T = int(input()) for _ in range(T): W = list(map(int, input().strip().split())) S = W[0] W = W[1:] W = W[::-1] i = 0 c = 0 flag = 0 while (len(W) != 0 or flag != 1) and i<len(W): k = i su = 0 while su <= S and k<len(W)-1: su += W[k] k += 1 if su-W[k-1]<=S: c += 1 else: flag = 1 ...
vfc_2310
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/JLUG2020/problems/BRKTBRK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3 1 2 2\n2 1 1 1\n3 2 2 1\n", "output": "2\n2\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
868
Solve the following coding problem using the programming language python: "It does not matter how slowly you go as long as you do not stop." - Confucius You are given an array $A_1, A_2, \ldots, A_N$ and an integer $K$. For each subarray $S = [A_l, A_{l+1}, \ldots, A_r]$ ($1 \le l \le r \le N$): - Let's define an arra...
```python from bisect import insort from math import ceil for _ in range(int(input())): n,k=list(map(int,input().split( ))) array=list(map(int,input().split( ))) ans=0 index=[] for i in range(1,n+1): index.append(ceil(k/(ceil(k/i)))) for i in range(n): count=[0]*(2001) temp=[] for j in range(i,n): coun...
vfc_2314
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUBPRNJL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 3\n1 2 3\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
869
Solve the following coding problem using the programming language python: The entire network is under the inspection and direct control of the Decepticons. They have learned our language through the World Wide Web and can easily understand the messages which are being sent. Sam is trying to send the information to Aut...
```python x = input() y = input() z = x.find(y) if z == -1 : print('N') else : print('Y') ```
vfc_2318
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/TCTR2012/problems/NOPC1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "techtrishna online event\nonlin\n", "output": "Y\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
870
Solve the following coding problem using the programming language python: We say that a binary string (a string containing only characters '0' and '1') is pure if it does not contain either of the strings "0101" or "1010" as a subsequence. Recall that string T is a subsequence of string S if we can delete some of the ...
```python # cook your dish here import math; from math import gcd,sqrt,floor,factorial,ceil from bisect import bisect_left,bisect_right import bisect; import sys; from sys import stdin,stdout import os sys.setrecursionlimit(pow(10,7)) import collections from collections import defaultdict,Counter from statistics import...
vfc_2322
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRFYIT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n010111101\n1011100001011101\n0110\n111111\n", "output": "2\n3\n0\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
871
Solve the following coding problem using the programming language python: You are given a grid with $R$ rows (numbered $1$ through $R$) and $C$ columns (numbered $1$ through $C$). Initially, each cell of this grid is either empty, contains an ant or an anteater. Each ant is moving in a fixed direction: up, down, left ...
```python import sys t = int(input()) # print(t) for _ in range(t): n,m = map(int,input().split()); s = []; for i in range(n): s.append(input()) ans = [] for i in range(n): ans.append([]) for j in range(m): ans[i].append([]) for i in range(n): for j in range(m): c = 0 if s[i][j]...
vfc_2326
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ANTEATER", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "10\n3 3\nR--\n---\n--U\n1 4\nR--R\n2 2\n--\n--\n1 4\nR--L\n1 4\n-R-L\n1 4\n-R#L\n3 3\nR-D\n-#-\nR-U\n3 3\nR-D\n---\nR#U\n3 3\n-D-\nR-L\n-U-\n1 7\nRLLLLLL\n\n", "output": "1\n0\n0\n0\n1\n0\n3\n2\n6\n3\n", "type": "stdin_...
apps
verifiable_code
872
Solve the following coding problem using the programming language python: Appy and Chef are participating in a contest. There are $N$ problems in this contest; each problem has a unique problem code between $1$ and $N$ inclusive. Appy and Chef decided to split the problems to solve between them ― Appy should solve the...
```python for t in range(int(input())): n, a , b , k = map(int,input().split()) solvedbychef = 0 solvedbyappy = 0 for i in range(n+1): if i % a == 0 and i % b == 0 : continue elif i%a == 0 : solvedbyappy+=1 elif i%b == 0: solvedbychef+=1 totalsolved = solvedbychef + solvedbyappy if totalsolved>=k: ...
vfc_2330
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/HMAPPY2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6 2 3 3\n", "output": "Win\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
873
Solve the following coding problem using the programming language python: The following graph G is called a Petersen graph and its vertices have been numbered from 0 to 9. Some letters have also been assigned to vertices of G, as can be seen from the following picture: Let's consider a walk W in graph G, which cons...
```python let_to_num = {'A':[0,5], 'B':[1,6], 'C':[2,7], 'D':[3,8], 'E':[4,9]} num_to_let = {0:'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'A', 6:'B', 7:'C', 8:'D', 9:'E'} connections = {0:(1,4,5), 1:(0,2,6), 2:(1,3,7), 3:(2,4,8), 4:(0,3,9), 5:(0,7,8), 6:(1,8,9), 7:(2,5,9), 8:(3,5,6), 9:(4,6,7)} ...
vfc_2334
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK52/problems/PETERSEN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nAAB\nAABE\n\n\n", "output": "501\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
874
Solve the following coding problem using the programming language python: ZCO is approaching, and you want to be well prepared! There are $N$ topics to cover and the $i^{th}$ topic takes $H_i$ hours to prepare (where $1 \le i \le N$). You have only $M$ days left to prepare, and you want to utilise this time wisely. ...
```python import math T=int(input()) for i in range(T): N,M,S=input().split() N=int(N) M=int(M) S=int(S) ls=list(map(int,input().split())) maxx=max(ls) if S<17 and maxx<=50: ls.sort() total_sum = M * S count = 0 sum = 0 for i in ls: if i / S > 2: continue else: sum = sum + math.ceil(i / S...
vfc_2338
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ZCOPREP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 4 10\n10 24 30 19 40\n5 4 16\n7 16 35 10 15\n", "output": "2\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
875
Solve the following coding problem using the programming language python: Vanja and Miksi really like games. After playing one game for a long time, they decided to invent another game! In this game, they have a sequence $A_1, A_2, \dots, A_N$ and two numbers $Z_1$ and $Z_2$. The rules of the game are as follows: - Th...
```python import sys from collections import defaultdict as dd from collections import deque from fractions import Fraction as f from copy import * from bisect import * from heapq import * from math import * from itertools import permutations def eprint(*args): print(*args, file=sys.stderr) zz=1 #sys.setrecursio...
vfc_2342
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/JAGAM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2 6 4\n-4 10\n1 1 -1\n2\n2 0 7\n3 4\n", "output": "1\n0\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
876
Solve the following coding problem using the programming language python: Rachel has some candies and she decided to distribute them among $N$ kids. The ith kid receives $A_i$ candies. The kids are happy iff the difference between the highest and lowest number of candies received is less than $X$. Find out if the chil...
```python t=int(input()) for t1 in range(t): n,x=map(int,input().split()) a=list(map(int,input().split())) mx=max(a) mn=min(a) if (mx-mn<x): print("YES") else: print("NO") ```
vfc_2346
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC01", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 6\n3 5 6 8 1\n3 10\n5 2 9\n", "output": "NO\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
877
Solve the following coding problem using the programming language python: A policeman wants to catch a thief. Both the policeman and the thief can only move on a line on integer coordinates between $0$ and $N$ (inclusive). Initially, the policeman is at a coordinate $x$ and the thief is at a coordinate $y$. During eac...
```python t = int(input()) for _ in range(t): x, y, k, n = [int(x) for x in input().split()] k = k*2 temp = abs(x-y) if(temp%k == 0): print("Yes") else: print("No") ```
vfc_2350
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CATHIEF", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n0 1 1 1\n1 4 1 5\n4 2 1 7\n3 7 2 10\n8 2 3 15\n", "output": "No\nNo\nYes\nYes\nYes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
878
Solve the following coding problem using the programming language python: There is a big staircase with $N$ steps (numbered $1$ through $N$) in ChefLand. Let's denote the height of the top of step $i$ by $h_i$. Chef Ada is currently under the staircase at height $0$ and she wants to reach the top of the staircase (the...
```python # cook your dish here import numpy as np def minstairs(n,k): stairsHeight=[] stairs=0 current = 0 stairsHeight=list(map(int, input().split())) stairsHeight=np.array(stairsHeight) curr=0 for i in range(n): if stairsHeight[i]-curr<=k: curr=stairsHeight[i] else: if (stairsHeight[i]-curr)%k==...
vfc_2354
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ADASTAIR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 3\n2 4 8 16\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
879
Solve the following coding problem using the programming language python: There are $X$ people participating in a quiz competition and their IDs have been numbered from $1$ to $X$ (both inclusive). Beth needs to form a team among these $X$ participants. She has been given an integer $Y$. She can choose participants wh...
```python for _ in range(int(input())): x, y = map(int, input().split()) ans = 0 for i in range(y, x+1, y): if i%y == 0: ans += i%10 print(ans) ```
vfc_2358
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC04", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 3\n15 5\n", "output": "18\n10\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
880
Solve the following coding problem using the programming language python: Tracy loves Donuts. She purchased a lots of Donuts for her birthday party. She learnt to calculate the area of the circle a few days back and she is fascinated to know the area of the donuts as well !! Help her finding the area of the Donuts….. ...
```python oo = int(input()) for i in range(oo): val = int(input()) print((val**2)*3.14) ```
vfc_2362
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SPNT2020/problems/AODLS001", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\n12\n", "output": "78.5\n452.16\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
881
Solve the following coding problem using the programming language python: Given an array $A_1, A_2, ..., A_N$, count the number of subarrays of array $A$ which are non-decreasing. A subarray $A[i, j]$, where $1 ≤ i ≤ j ≤ N$ is a sequence of integers $A_i, A_i+1, ..., A_j$. A subarray $A[i, j]$ is non-decreasing if $A...
```python # cook your dish here t=int(input()) for i in range(t): n=int(input()) ar=list(map(int,input().split())) tot=0 st=0 for j in range(1,n): if(ar[j-1]>ar[j]): si=j-st c=(si*(si+1))//2 tot+=c st=j si=n-st c=(si*(si+1))//2 tot+=c print(tot) ```
vfc_2366
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SUBINC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n1 4 2 3\n1\n5\n", "output": "6\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
882
Solve the following coding problem using the programming language python: As we all know, Chef is cooking string for long days, his new discovery on string is the longest common pattern length. The longest common pattern length between two strings is the maximum number of characters that both strings have in common. C...
```python from collections import Counter def solve(A,B): a = Counter(A) b = Counter(B) ans = 0 for i in a: if i in b: ans += min(a[i],b[i]) return ans t = int(input()) for _ in range(t): A = input() B = input() print(solve(A,B)...
vfc_2370
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LCPESY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nabcd\nxyz\nabcd\nbcda\naabc\nacaa\nCodechef\nelfedcc\n\n\n", "output": "0\n4\n3\n5\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
883
Solve the following coding problem using the programming language python: It's year 2018 and it's Christmas time! Before going for vacations, students of Hogwarts School of Witchcraft and Wizardry had their end semester exams. $N$ students attended the semester exam. Once the exam was over, their results were displaye...
```python for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) s = set(a) if n == 1 or len(s) > 2: print(-1) continue if len(s) == 1: x = s.pop() if x == 0: print(n) elif x == n-1: print(0) else: print(-1) continue x, y = sorted(s) xc, yc = a.count(x), a....
vfc_2374
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CNTFAIL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4\n3 2 2 2\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
884
Solve the following coding problem using the programming language python: Write a program that reads two numbers $X$ and $K$. The program first finds the factors of $X$ and then gives the sum of $K$th power of every factor. The program also finds the factor of $k$ and outputs the sum of $X$ times of every factor. --...
```python try: for _ in range(int(input())): s,s1=0,0 x,k=[int(i) for i in input().split()] for i in range(2,x+1): if(x%i==0): s=s+i**k for i in range(2,k+1): if(k%i==0): s1+=i*x print(s,s1) except EOFError as...
vfc_2378
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/SITC2020/problems/FACPOW", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n8 6\n", "output": "266304 88\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
885
Solve the following coding problem using the programming language python: Chef solved so many hard questions, now he wants to solve some easy problems for refreshment. Chef asks Cheffina for the new question. Cheffina challenges the chef to print the total number of 0's in the binary representation of N(natural number...
```python from sys import stdin, stdout input = stdin.readline from collections import defaultdict as dd import math def geti(): return list(map(int, input().strip().split())) def getl(): return list(map(int, input().strip().split())) def gets(): return input() def geta(): return int(input()) def print_s(s): st...
vfc_2382
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY31", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n4\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }