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
1186
Solve the following coding problem using the programming language python: Bhallaladeva was an evil king who ruled the kingdom of Maahishmati. He wanted to erect a 100ft golden statue of himself and he looted gold from several places for this. He even looted his own people, by using the following unfair strategy: There...
```python import math n = int(input()) a = sorted(map(int,input().split())) l = [0]*n for i in range(n): l[i] = a[i] + l[i-1] for q in range(int(input())): print(l[int(math.ceil(float(n)/(int(input())+1)))-1]) ```
vfc_3586
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AMR15ROL/problems/AMR15D", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n3 2 1 4\n2\n0\n2\n", "output": "10\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1187
Solve the following coding problem using the programming language python: Chef wants to select a subset $S$ of the set $\{1, 2, \ldots, N\}$ such that there are no two integers $x, y \in S$ which satisfy $\frac{x}{y} = M$. Help Chef find the maximum size of a subset $S$ he can choose and the number of ways in which he...
```python for _ in range(int(input())): N,M = list(map(int,input().split())) count,e,perm = 0,0,1 while(True): lim,start = N//(M**e),N//(M**(e + 1)) + 1 num = lim - start + 1 divs = num//M if((start + divs*M) <= lim): r = (start+divs*M)%M if(r == 0 or (r + (lim - (start + divs*M)) >= M)): divs += 1...
vfc_3590
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BANQUNT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 2\n10 2\n100 3\n", "output": "4 1\n6 12\n76 49152\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1188
Solve the following coding problem using the programming language python: Chef is a private detective. He was asked to investigate a case of murder in the city of Frangton. Chef arrived in Frangton to find out that the mafia was involved in the case. Chef spent some time watching for people that belong to the clan and...
```python n = eval(input()) r = list(map(int, input().split())) tree = dict() i = 1 for j in r: c = tree.get(j) if c: tree[j].append(i) else: tree[j] = [i] if not tree.get(i): tree[i] = [] i += 1 s = [] for elem in tree: if not tree[elem]: s.append(str(elem)) print(' '.join(s)) ```
vfc_3594
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/FEB16/problems/CHEFDETE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n0 1 1 2 2 3\n", "output": "4 5 6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1189
Solve the following coding problem using the programming language python: You are given a sequence $A_1, A_2, \ldots, A_N$. For each $k$ ($1 \le k \le N$), let's define a function $f(k)$ in the following way: - Consider a sequence $B_1, B_2, \ldots, B_N$, which is created by setting $A_k = 0$. Formally, $B_k = 0$ and ...
```python from sys import stdin def gt(num): if num: return num return 0 for __ in range(int(stdin.readline().split()[0])): n = int(stdin.readline().split()[0]) a = list(map(int, stdin.readline().split())) cnta = dict() cnta.setdefault(0) cntb = dict() cntb.setdefault(0) for i in a: cnta[i] = gt(cnta.get(i...
vfc_3598
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CFINASUM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6\n1 2 1 1 3 1\n3\n4 1 4\n", "output": "6\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1190
Solve the following coding problem using the programming language python: Tomya is a girl. She loves Chef Ciel very much. Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p. The current menus of Ciel's restaurant are shown the following table. Name ...
```python t= int(input()) while(t>0): n = int(input()) m=0 m=n//(2**11) n%=(2**11) while(n>0): num=n%2 m+=num n//=2 print(m) t-=1 ```
vfc_3602
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CIELRCPT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n10\n256\n255\n4096\n", "output": "2\n1\n8\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1191
Solve the following coding problem using the programming language python: Sandy is a professor at a very reputed institute. The institute mandates that all the lectures be communicated in English. As Sandy is not very good at English(or anything actually) the presentations he displays in class have a lot of spelling m...
```python # cook your dish here from difflib import get_close_matches import sys, os def closeMatches(patterns, word): return get_close_matches(word, patterns, 1, 0.9)[0] def get_string(): return sys.stdin.readline().strip() def get_ints(): return map(int, sys.stdin.readline().strip().split()) ans = [] test...
vfc_3606
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PROC2020/problems/ENGRIS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 2\nszhbdvrngk\nqzhxibnuec\njfsalpwfkospl\nlevjehdkjy\nwdfhzgatuh\nszhbdvcngk\nqzhxbnuec\n", "output": "szhbdvrngk\nqzhxibnuec\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1192
Solve the following coding problem using the programming language python: You are given a sequence of integers $A_1, A_2, \ldots, A_N$. This sequence is circular ― for each valid $i$, the element $A_{i+1}$ follows after $A_i$, and the element $A_1$ follows after $A_N$. You may insert any positive integers at any posit...
```python from math import gcd from itertools import groupby def gcd_split(seq): gcds= [int(gcd(a,b)==1) for a,b in zip(seq[1:],seq[:-1])] gcds.append(int(gcd(seq[0],seq[-1])==1)) # print(gcds) if max(gcds)==0: return -1 else: splits=[len(list(x))+1 for num,x in groupby(gcds) if num==0] # print(splits) if...
vfc_3610
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MININS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n3 6 4 5 9\n", "output": "3 1 1 0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1193
Solve the following coding problem using the programming language python: There are $N$ robots who work for $Y$ days and on each day they produce some toys .on some days a few robots are given rest. So depending on the availability of robots owner has made a time table which decides which robots will work on the par...
```python MAX = 100005 tree = [0] * MAX; lazy = [0] * MAX; def updateRangeUtil(si, ss, se, us, ue, diff) : if (lazy[si] != 0) : tree[si] += lazy[si]; if (ss != se) : lazy[si * 2 + 1] += lazy[si]; lazy[si * 2 + 2] += lazy[si]; lazy[si] = 0; if (ss > se or ss >...
vfc_3614
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC6", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n4\n0 3\n1 2\n4 4\n0 4\n", "output": "4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1194
Solve the following coding problem using the programming language python: Toby has found a game to entertain himself.The game is like this: You are in a coordinate system initially at (0,0) and you are given a sequence of steps which lead to your destination.The steps are given in the form of directions: ’U’ ,’D’ , ’...
```python from collections import Counter try: for _ in range(int(input())): n=int(input()) s=input() d1=dict(Counter(s)) u,d,r,l=0,0,0,0 if 'U' in d1: u=d1['U'] else: u=0 if 'D' in d1: d=d1['D'] else: d=0 if 'R' in d1: r=d1['R'] else: r=0 if 'L' in d1: l=d1['L'] else: ...
vfc_3618
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CSEP2020/problems/TOBY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n7\nULUDLLU\n4\nRUUR\n4\nLRLR\n", "output": "2\n0\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1195
Solve the following coding problem using the programming language python: Chefland has all the cities on a straight line. There are $N$ cities in Chefland numbered $1$ to $N$. City $i$ is located at coordinate $x_i$ on the x-axis. Guru wants to travel from city $A$ to city $B$. He starts at time t=0. He has following ...
```python t=int(input()) for _ in range(t): n,a,b,c,d,p,q,y=list(map(int,input().split())) l=list(map(int,input().split())) ans = abs((l[b-1]-l[a-1]))*p x=abs(l[c-1]-l[a-1])*p if x<=y: x=y+abs(l[d-1]-l[c-1])*q+abs(l[b-1]-l[d-1])*p ans=min(ans,x) print(ans) ```
vfc_3622
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WALKFAST", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 1 3 2 4 3 2 4\n1 2 3 4\n", "output": "6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1196
Solve the following coding problem using the programming language python: Every college has a stud−max$stud-max$ buoy. JGEC$JGEC$ has its own Atul$Atul$ who loves to impress everyone with his smile. A presentation is going on at the auditorium where there are N$N$ rows of M$M$ chairs with people sitting on it. Everyon...
```python t = int(input()) for i in range(t): q = input().split() n = int(q[0]) m = int(q[1]) k = int(q[2]) sumax = 0 b = [] for j in range(n): a = [int(k) for k in input().split()] b = b + [a] for j in range(n): su = 0 for x in range(k): ...
vfc_3626
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AARA2018/problems/ARMBH2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n4 4 3\n1 4 5 7\n2 3 8 6\n1 4 8 9\n5 1 5 6\n", "output": "22\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1197
Solve the following coding problem using the programming language python: Chef loves saving money and he trusts none other bank than State Bank of Chefland. Unsurprisingly, the employees like giving a hard time to their customers. But instead of asking them to stand them in long queues, they have weird way of acceptin...
```python lst=[1, 2, 4, 8, 13, 21, 31, 45, 66, 81, 97, 123, 148, 182, 204, 252, 290, 361, 401, 475, 565, 593, 662, 775, 822, 916, 970, 1016, 1159, 1312, 1395, 1523, 1572, 1821, 1896, 2029, 2254, 2379, 2510, 2780, 2925, 3155, 3354, 3591, 3797, 3998, 4297, 4433, 4779, 4851, 5123, 5243, 5298, 5751, 5998, 6374, 6801, 6925,...
vfc_3630
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PROC2020/problems/CHFBANK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n2\n3\n4\n", "output": "1\n1\n1 2\n3\n1 2 4\n7\n1 2 4 8\n15\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1198
Solve the following coding problem using the programming language python: Chef recently took a course in linear algebra and learned about linear combinations of vectors. Therefore, in order to test his intelligence, Raj gave him a "fuzzy" problem to solve. A sequence of integers $B_1, B_2, \ldots, B_M$ generates an in...
```python import math import bisect from functools import reduce from collections import defaultdict # import sys # input = sys.stdin.readline def inn(): return int(input()) def inl(): return list(map(int, input().split())) MOD = 10**9+7 INF = inf = 10**18+5 n = inn() a = inl() k = [] for q in range(inn()): k.ap...
vfc_3634
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/FUZZYLIN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 4\n3\n1\n2\n8\n", "output": "0\n2\n3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1199
Solve the following coding problem using the programming language python: In a country called Chef Land, there was a lot of monetary fraud, so Chefu, the head of the country, decided to choose new denominations of the local currency ― all even-valued coins up to an integer $N$ should exist. After a few days, a citizen...
```python for i in range(int(input())): n,k=list(map(int,input().split())) t=0 if n%2!=0: n-=1 t+=1 t+=(n//k) if n%k!=0: t+=1 print(t) ```
vfc_3638
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHFMOT18", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 2\n1 14\n30 10\n31 4\n", "output": "1\n1\n3\n9\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1200
Solve the following coding problem using the programming language python: Two sisters, A and B, play the piano every day. During the day, they can play in any order. That is, A might play first and then B, or it could be B first and then A. But each one of them plays the piano exactly once per day. They maintain a com...
```python def checkValidity(s): count = 0 previous = "" for x in s: if count == 0: previous = x count += 1 elif count == 1: count = 0 if previous == x: return "no" return "yes" t = int(input()) for _ in range(t): s = input() print(checkValidity(s)) ```
vfc_3642
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PLAYPIAN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nAB\nABBA\nABAABB\nAA\n", "output": "yes\nyes\nno\nno\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1201
Solve the following coding problem using the programming language python: Kim has broken in to the base, but after walking in circles, perplexed by the unintelligible base design of the JSA, he has found himself in a large, empty, and pure white, room. The room is a grid with H∗W$H*W$ cells, divided into H$H$ rows an...
```python # cook your dish here def solve(l,r,c,row,col,po): count=0 visited=set() stack=set() stack.add((l[row][col],row,col)) while stack: ele=stack.pop() visited.add((ele[1],ele[2])) if ele[0]<po: count+=1 if ele[1]-1>=0 and (ele[1]-1,ele[2]) not i...
vfc_3646
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/UWCOI20C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5 5 3\n4 3 9 7 2\n8 6 5 2 8\n1 7 3 4 3\n2 2 4 5 6\n9 9 9 9 9\n3 4 6\n3 2 5\n1 4 9\n", "output": "10\n0\n19\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1202
Solve the following coding problem using the programming language python: Mark loves eating chocolates and also likes to be fit. Given the calorie count for every chocolate he eats, find what he has to do to burn the calories. The name of the chocolates along with its calorie count are given as follows: Calories per ...
```python # cook your dish here d = { 'D': 238, 'T': 244, 'M': 138, 'B': 279, 'C': 186 } s = list(input()) totalCal = 0 for i in range(len(s)): if s[i] == 'D': totalCal += d['D'] if s[i] == 'T': totalCal += d['T'] if s[i] == 'M': totalCal += d['M'] if s[i] == 'B': tota...
vfc_3650
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/RTCG2020/problems/RTCG002", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "DDTM\n", "output": "17\n1\n6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1203
Solve the following coding problem using the programming language python: Given a set of N natural numbers 1,2,3........N and Q query.For each query you have to calculate the total number of subset in which Ith. number of set come at Kth postion.Elements of every subset should be in sorted order. The answer could ...
```python import math f = math.factorial for u in range(eval(input())): n, q = list(map(int, input().split())) for j in range(q): i,k = list(map(int, input().split())) if k>i: c=0 print(c) else: a=2**(n-i) b=1 d=int(i-1) e=1 h=1 g=1 #b=f(i-1)/f(k-1)/f(i-k) if(k-1>i-k): for z in...
vfc_3654
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDVA16/problems/CDVA1607", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 3\n1 2\n2 1\n3 2\n", "output": "0\n2\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1204
Solve the following coding problem using the programming language python: You are given two strings $S$ and $R$. Each of these strings has length $N$. We want to make $S$ equal to $R$ by performing the following operation some number of times (possibly zero): - Choose two integers $a$ and $b$ such that $1 \le a \le b ...
```python for t in range(int(input())): s = input() r = input() diff = list() index = list() cnt = 0 for i in range(len(s)): if s[i] != r[i]: cnt += 1 index.append(i) for i in range(1, len(index)): diff.append(index[i] - index[i - 1] - 1) diff.sort() fmin = cnt ** 2 oper = cnt ; moves = cnt for i i...
vfc_3658
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MINOPS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\nadefb\nbdefa\n", "output": "4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1205
Solve the following coding problem using the programming language python: Do you know Professor Saeed? He is the algorithms professor at Damascus University. Yesterday, he gave his students hard homework (he is known for being so evil) - for a given binary string $S$, they should compute the sum of $F(S, L, R)$ over a...
```python for _ in range(int(input())): s=input() n=len(s) t=0 ans=0 for i in range(n-1): if(s[i]==s[i+1]): t=t+1 x=t for i in range(n): t=x if(i!=0): if(s[i]==s[i-1]): t=t-1 else: t=t+1 y=t for j in range(i,n): t=y try: if(s[j]==s[j+1]): t=t-1 else: t=t+1 ...
vfc_3662
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/EVIPRO", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n001\n", "output": "6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1206
Solve the following coding problem using the programming language python: As you might remember, the collector of Siruseri had ordered a complete revision of the Voters List. He knew that constructing the list of voters is a difficult task, prone to errors. Some voters may have been away on vacation, others may have m...
```python from sys import stdout, stdin n,m,o = list(map(int, stdin.readline().split())) n= n+m+o l=[] a=[] for i in range(n): b= int(stdin.readline()) if(b in l and b not in a): l.append(b) a.append(b) elif(b not in l): l.append(b) a.sort() stdout.write(str(len(a)) + '\n') stdout....
vfc_3666
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IARCSJUD/problems/VOTERSDI", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5 6 5\n23\n30\n42\n57\n90\n21\n23\n35\n57\n90\n92\n21\n23\n30\n57\n90\nSample output:\n5\n21\n23\n30\n57\n90\n", "output": "", "type": "stdin_stdout" } ] }
apps
verifiable_code
1207
Solve the following coding problem using the programming language python: Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build som...
```python t=int(input()) for _ in range(t): n=int(input()) a=list(map(int,input().split())) a.sort() s=sum(a) if a[0]*(s-a[0])<=a[n-1]*(s-a[n-1]): print(a[0]*(s-a[0])) else: print(a[n-1]*(s-a[n-1])) ```
vfc_3670
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/KINGSHIP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n5 10\n4\n15 10 7 13\n", "output": "50\n266\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1208
Solve the following coding problem using the programming language python: Chef is solving mathematics problems. He is preparing for Engineering Entrance exam. He's stuck in a problem. $f(n)=1^n*2^{n-1}*3^{n-2} * \ldots * n^{1} $ Help Chef to find the value of $f(n)$.Since this number could be very large, compute it m...
```python T=int(input()) t=[] for _ in range(T): N=int(input()) t.append(N) N=max(t)+1 l=[0 for i in range(N)] p=1 a=1 for i in range(1,N): a=(a*i)%1000000007 p=p*a%1000000007 l[i]=p for i in t: print(l[i]) ```
vfc_3674
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MATHL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n", "output": "12\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1209
Solve the following coding problem using the programming language python: It's winter and taking a bath is a delicate matter. Chef has two buckets of water. The first bucket has $v_1$ volume of cold water at temperature $t_1$. The second has $v_2$ volume of hot water at temperature $t_2$. Chef wants to take a bath wit...
```python # cook your dish here try: for i in range(int(input())): v1,t1,v2,t2,v3,t3=map(int,input().split()) ok = 0 if t1 <= t3 <= t2: x, y = t2 - t3, t3 - t1 ok = x * v3 <= (x + y) * v1 and y * v3 <= (x + y) * v2 print('YES' if ok else 'NO') except: pass ```
vfc_3678
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CLBATH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 10 5 20 8 15\n5 10 5 20 1 30\n5 10 5 20 5 20\n", "output": "YES\nNO\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1210
Solve the following coding problem using the programming language python: -----Problem Statement----- One of the things JEC is known for is its GR (Group Recreation) where juniors and seniors do friendly interaction ;P As for the new session of 2020 seniors decided to have their first GR and give them some treat. Juni...
```python t=int(input()) while t: t=t-1 n,x=input().split() n=int(n) x=int(x) d,l=input().split() if d=='L': p=x elif d=='R': p=(n-x)+1 if p%2==1: if l=='H': lang='H' else: lang='E' elif p%2==0: if l=='H': lang='E' else: lang='H' print(p,lang) ```
vfc_3682
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COPT2020/problems/GRDAY1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n15 5\nL H\n20 14\nR E\n*try to trim extra white spaces like new line during input in case of wrong answer\n", "output": "5 H\n7 E\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1211
Solve the following coding problem using the programming language python: The chef is having one string of English lower case alphabets only. The chef wants to remove all "abc" special pairs where a,b,c are occurring consecutively. After removing the pair, create a new string and again remove "abc" special pair from a...
```python # cook your dish here for _ in range(int(input())): s=input() while(s.count("abc")!=0): s=s.replace("abc","") print(s) ```
vfc_3686
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK12020/problems/ITGUY15", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\naabcc\nbababccc\n", "output": "ac\nbc\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1212
Solve the following coding problem using the programming language python: "Everything in the universe is balanced. Every disappointment you face in life will be balanced by something good for you! Keep going, never give up." Let's call a string balanced if all characters that occur in this string occur in it the same ...
```python from sys import stdin from collections import Counter def func(arr,n,l): count=0 k=l//n if n<len(arr): for ele in arr[0:n]: count+=max(0,k-ele) else: for ele in arr: count+=max(0,ele-k) return count for _ in range(int(stdin.readline())): s=stdin.readline().strip() d=Counter(s) arr=sorted(...
vfc_3690
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ARTBALAN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nABCB\nBBC\n", "output": "1\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1213
Solve the following coding problem using the programming language python: Chef and his competitor Kefa own two restaurants located at a straight road. The position of Chef's restaurant is $X_1$, the position of Kefa's restaurant is $X_2$. Chef and Kefa found out at the same time that a bottle with a secret recipe is l...
```python # cook your dish here for t in range(int(input())): x1,x2,x3,v1,v2=[int(x)for x in input().rstrip().split()] t1=abs(x3-x1)/v1 t2=abs(x3-x2)/v2 if t1<t2: print("Chef") elif t1>t2: print("Kefa") elif t1==t2: print("Draw") else: pass ```
vfc_3694
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFRUN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n1 3 2 1 2\n1 5 2 1 2\n1 5 3 2 2\n", "output": "Kefa\nChef\nDraw\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1214
Solve the following coding problem using the programming language python: Everybody is worried about Rakesh as the boy does not have much knowledge about the real world. He can not go from one place to another on his own. It's high time he learned to explore the city. He is going to a relative's house situated on the ...
```python try: t=int(input()) for i in range(t): print("Case {}:".format(i+1), end=" ") m, n = map(int,input().split()) x, y = map(int,input().split()) l = int(input()) a=input() destx = a.count("R")-a.count("L") desty = a.count("U")-a.count("D") #print(destx, desty) if (destx<0 or destx>m) or (de...
vfc_3698
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ZUBREACH", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n20 20\n4 5\n13\nLLUUUUURRRRRR\n10 10\n3 4\n7\nUDUDDRR\n", "output": "Case 1: REACHED\nCase 2: DANGER\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1215
Solve the following coding problem using the programming language python: Two friends David and Rojer were preparing for their weekly class-test. The are preparing for the math test, but because of continuously adding big integers and solving equations they got exhausted. They decided to take break and play a game. Th...
```python def isSolvable( W, R): LW, LR, F, ML, AW, V, LMap = len(W), len(R), set([w[0] for w in W+[R]]), max(map(len, W+[R])), W+[R], set(), {} if LR < ML: return False def dfs(d,i,c): if d == ML: return c == 0 if i == len(W) + 1: s = sum(LMap[w[-d-...
vfc_3702
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHLG2020/problems/MATH88", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nTHIS\nIS\nTOO\nFUNNY\n", "output": "true\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1216
Solve the following coding problem using the programming language python: Today Chef wants to evaluate the dishes of his $N$ students. He asks each one to cook a dish and present it to him. Chef loves his secret ingredient, and only likes dishes with at least $X$ grams of it. Given $N$, $X$ and the amount of secret in...
```python t=int(input()) for i in range(t): n,k=map(int,input().split()) m=list(map(int,input().split())) a=0 for i in m: if i>=k: a=1 break if a==1: print('YES') else: print('NO') ```
vfc_3706
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PCJ18A", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5 100\n11 22 33 44 55\n5 50\n10 20 30 40 50\n5 45\n12 24 36 48 60\n", "output": "NO\nYES\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1217
Solve the following coding problem using the programming language python: Chef has an array A = (A1, A2, ..., AN), which has N integers in it initially. Chef found that for i ≥ 1, if Ai > 0, Ai+1 > 0, and Ai+2 exists, then he can decrease both Ai, and Ai+1 by one and increase Ai+2 by one. If Ai+2 doesn't exist, but Ai...
```python def fun(a,cur,n,cnt): if cur>=n-1: return for i in range(cur,n-1): if i<n-2: if a[i]>0 and a[i+1]>0: a[i]-=1 a[i+1]-=1 a[i+2]+=1 cnt[0]=(cnt[0]+1)%1000000007 fun(a,i,n,cnt) a[i]+...
vfc_3710
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AUG17/problems/CHEFFA", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n2 3 1\n2\n2 2\n3\n1 2 3\n\n\n", "output": "9\n4\n9\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1218
Solve the following coding problem using the programming language python: Richik$Richik$ has just completed his engineering and has got a job in one of the firms at Sabrina$Sabrina$ which is ranked among the top seven islands in the world in terms of the pay scale. Since Richik$Richik$ has to travel a lot to reach th...
```python t=int(input()) for i in range(t): x,n=[int(g) for g in input().split()] sal=0 day=x while day<n: sal=sal+day day+=x print(sal) ```
vfc_3714
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AARA2018/problems/ARMBH1", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 10\n", "output": "18\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1219
Solve the following coding problem using the programming language python: You have found $M$ different types of jewels in a mine and each type of jewel is present in an infinite number. There are $N$ different boxes located at position $(1 ,2 ,3 ,...N)$. Each box can collect jewels up to a certain number ( box at posi...
```python t = int(input()) while t != 0: M = 1000000007 n, m = list(map(int, input().split())) ans = 1 tt = n//2 tt = tt * (tt + 1) ans = pow(m, tt, M) print(ans) t -= 1 ```
vfc_3718
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/INRO2021/problems/JEWELMIN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 10\n5 2\n", "output": "1\n64\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1220
Solve the following coding problem using the programming language python: Lets wish Horsbug98 on his birthday and jump right into the question. In Chefland, $6$ new mobile brands have appeared each providing a range of smartphones. For simplicity let the brands be represented by numbers $1$ to $6$. All phones are sold...
```python import sys from collections import defaultdict from copy import copy R = lambda t = int: t(eval(input())) RL = lambda t = int: [t(x) for x in input().split()] RLL = lambda n, t = int: [RL(t) for _ in range(n)] def solve(): N, Q = RL() P = RL() B = RL() phones = sorted(zip(P, B)) ...
vfc_3722
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ENJU2020/problems/ECJN209", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n4 5 6 7\n1 2 3 4\n3 3\n1 2 3\n3 4\n4 5 6\n", "output": "4\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1221
Solve the following coding problem using the programming language python: Chef played an interesting game yesterday. This game is played with two variables $X$ and $Y$; initially, $X = Y = 0$. Chef may make an arbitrary number of moves (including zero). In each move, he must perform the following process: - Choose any...
```python from math import sqrt T = int(input()) ans = [] for _ in range(T): X = int(input()) count = 0 x = 0 y = 0 while(x<=X): p = int(sqrt(y)) count += 1 if(p*p>y): x = p y += p**2 else: x = p+1 y += (p+1)**2 if(x<=X): ans.append(count) else: ans.append(count-1) for i in ans: prin...
vfc_3726
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TWOVRIBL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n8\n9\n", "output": "3\n5\n6\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1222
Solve the following coding problem using the programming language python: The EEE classes are so boring that the students play games rather than paying attention during the lectures. Harsha and Dubey are playing one such game. The game involves counting the number of anagramic pairs of a given string (you can read ab...
```python def sort_str(s): o = [] for c in s: o.append(c) o.sort() return "".join(o) def find_ana(s): if len(s) <= 1: return 0 h = {} c = 0 for i in range(len(s)): for j in range(i+1, len(s)+1): t = sort_str(s[i:j]) if t in h: c += h...
vfc_3730
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COCU2016/problems/CURR2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\nrama\nabba\nabcd\n", "output": "2\n4\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1223
Solve the following coding problem using the programming language python: It's the annual military parade, and all the soldier snakes have arrived at the parade arena, But they aren't standing properly. The entire parade must be visible from the main podium, and all the snakes must be in a line. But the soldiers are l...
```python t=int(input()) def vsense(val,a,l): sense=0 ctr=a for c in range(n): if val[c]<=ctr: sense+=-1 else: sense+=1 ctr+=l return sense while t: n,l,a,b=list(map(int,input().split())) val=list(map(int,input().split())) val.sort() sense=0 if b==a+n*l or vsense(val,a,l)<=0: loc=a else: s...
vfc_3734
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CONSESNK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 4 11 23\n10 11 30\n3 4 11 40\n10 11 30\n", "output": "16\n16\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1224
Solve the following coding problem using the programming language python: Eugene loves sequences, especially arithmetic progressions. One day he was asked to solve a difficult problem. If a sequence of numbers A1, A2, ... , AN form an arithmetic progression A, he was asked to calculate sum of F(Ai), for L ≤ i ≤ R. F(...
```python import fractions import sys f = sys.stdin if len(sys.argv) > 1: f = open(sys.argv[1], "rt") sum_cache = {} def sum_func(x): if x < 10: return x r = sum_cache.get(x) if r is not None: return r xx = 0 while x > 0: xx += x % 10 x /= 10 r = sum...
vfc_3738
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/NOV15/problems/KFUNC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 1 1 3\n14 7 2 4\n\n\n", "output": "6\n12\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1225
Solve the following coding problem using the programming language python: Tomya is a girl. She loves Chef Ciel very much. Today, too, Tomya is going to Ciel's restaurant. Of course, Tomya would like to go to Ciel's restaurant as soon as possible. Therefore Tomya uses one of the shortest paths from Tomya's house to Ci...
```python t=eval(input()) def func(k,n,x,dist,graph): if k==n: x+=[dist[n]] return for i in range(1,n+1): if graph[k][i]!=0 and dist[i]==-1: dist[i]=dist[k]+graph[k][i] func(i,n,x,dist,graph) dist[i]=-1 while t: graph=[[0 for i in range(11)]for j in range(11)] v,e=list(map(int,input().split())) ...
vfc_3742
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CIELTOMY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 3\n1 2 3\n2 3 6\n1 3 7\n3 3\n1 2 3\n2 3 6\n1 3 9\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1226
Solve the following coding problem using the programming language python: It is well-known that the elephants are afraid of mouses. The Little Elephant from the Zoo of Lviv is not an exception. The Little Elephant is on a board A of n rows and m columns (0-based numeration). At the beginning he is in cell with coordi...
```python from collections import defaultdict from itertools import product def solve(mouse,n,m): # shadow matrix will contains the count of mice which affect (i,j) position # if there is a mice at position (i,j) then in shadow matrix it will affect         all four adjacent blocks shadow=[[0 for i in range(m)]f...
vfc_3746
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/LEMOUSE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3 9\n001000001\n111111010\n100100100\n7 9\n010101110\n110110111\n010011111\n100100000\n000010100\n011011000\n000100101\n", "output": "9\n10\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1227
Solve the following coding problem using the programming language python: One day, Chef found a cube which has each of its sides painted in some color out of black, blue, red, green, yellow and orange. Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same co...
```python for _ in range(int(input())): l=list(map(str,input().split())) a=[(1,3,5),(1,3,6),(1,4,5),(1,4,6),(2,3,5),(2,3,6),(2,4,5),(2,4,6)] c=0 for i in a: if len(set([l[i[0]-1],l[i[1]-1],l[i[2]-1]]))==1: c=1 break if c==1: print("YES") else: print("NO") ```
vfc_3750
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHCUBE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\nblue yellow green orange black green\ngreen yellow green orange black green\n", "output": "NO\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1228
Solve the following coding problem using the programming language python: Chef has $N$ axis-parallel rectangles in a 2D Cartesian coordinate system. These rectangles may intersect, but it is guaranteed that all their $4N$ vertices are pairwise distinct. Unfortunately, Chef lost one vertex, and up until now, none of hi...
```python for _ in range(int(input())): n=int(input()) a=[] b=[] for i in range(4*n-1): c,d=list(map(int,input().split())) a.append(c) b.append(d) c1=0 c2=0 for i in a: c1^=i for i in b: c2^=i print(c1,c2) ```
vfc_3754
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PTMSSNG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n2\n1 1\n1 2\n4 6\n2 1\n9 6\n9 3\n4 3\n", "output": "2 2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1229
Solve the following coding problem using the programming language python: Motu and Tomu are very good friends who are always looking for new games to play against each other and ways to win these games. One day, they decided to play a new type of game with the following rules: - The game is played on a sequence $A_0, ...
```python for _ in range(int(input())): n, k = map(int, input().split()) arr= list(map(int, input().split())) motu, tomu = [], [] for i in range(n): if i%2 == 0: motu.append(arr[i]) else: tomu.append((arr[i])) motu.sort(reverse=True) tomu.sort() for i in range(len(motu)): if len(tomu)-1<i: break ...
vfc_3758
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MTYFRI", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n6 0\n1 1 1 1 1 1\n5 1\n2 4 6 3 4\n", "output": "NO\nYES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1230
Solve the following coding problem using the programming language python: The Gray code (see wikipedia for more details) is a well-known concept. One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation. In this problem, we will give you n non-...
```python dic = {} #num = "1" #def tonum(num): # res=0 # for i in range(len(num)): # res = 2*res + int(num[i]) # return res #for i in range(64): # number = tonum(num) # dic[num] = [] # num = num+"0" n = int(input()) flag=0 if n >= 68: inp = input() print("Yes") else: inp = [int(x) for x in input(...
vfc_3762
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/JULY12/problems/GRAYSC", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\n1 0 2 3 7\n", "output": "Yes\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1231
Solve the following coding problem using the programming language python: The chef won a duet singing award at Techsurge & Mridang 2012. From that time he is obsessed with the number 2. He just started calculating the powers of two. And adding the digits of the results. But he got puzzled after a few calculations. S...
```python from operator import add from functools import reduce choices=[] for x in range(1800): num_str = list(map (int, str (2**x))) suma = reduce (add, num_str) choices.append(suma) N=int(input()) for x in range(N): t=int(input()) print(choices[t]) ```
vfc_3766
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AGTK2012/problems/ALG2N", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n10\n4\n", "output": "5\n7\n7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1232
Solve the following coding problem using the programming language python: AND gates and OR gates are basic components used in building digital circuits. Both gates have two input lines and one output line. The output of an AND gate is 1 if both inputs are 1, otherwise the output is 0. The output of an OR gate is 1 if ...
```python # cook your dish here class node: def __init__(self,a,b=0,c=0): self.val=a self.a=b self.b=c arr=[] def finder(node,val): if(arr[node].val==0): return val else: a=finder(arr[node].a,val) b=finder(arr[node].b,val) if(arr[node].val==1): return a+b-a*b else: return a*b t=int(input()) ...
vfc_3770
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CIRCUITS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n\n1\n0\n\n3\n0\n0\n1 1 2\n\n3\n0\n0\n2 1 2\n\n5\n0\n0\n0\n2 1 2\n1 3 4\n\n\n", "output": "0.50000\n0.29289\n0.70711\n0.40303\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1233
Solve the following coding problem using the programming language python: There are players standing in a row each player has a digit written on their T-Shirt (multiple players can have the same number written on their T-Shirt). You have to select a group of players, note that players in this group should be standi...
```python import sys def GRIG(L): LENT = len(L) MINT = 1 GOT = 0 DY = [ [{x: 0 for x in range(0, 10)}, 0, 0] ] for i in L: DY.append([{x: 0 for x in range(0, 10)}, 0, 0]) GOT += 1 for j in range(0, GOT): if DY[j][0][i] == 1: DY[j][0][i] = 0 ...
vfc_3774
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COVO2020/problems/GRIG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n123343\n", "output": "3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1234
Solve the following coding problem using the programming language python: There is a new prodigy in town and he has challenged people to a game. They have to give him an integer N and he will immediately respond with a number which has more than N factors. What the prodigy really does is to do some complex calculation...
```python divisors = [1 , 2 , 3 , 4 , 6 , 8 , 9 , 10 , 12 , 16 , 18 , 20 , 24 , 30 , 32 , 36 , 40 , 48 , 60 , 64 , 72 , 80 , 84 , 90 , 96 , 100 , 108 , 120 , 128 , 144 , 160 , 168 , 180 , 192 , 200 , 216 , 224 , 240 , 256 , 288 , 320 , 336 , 360 , 384 , 400 , 432 , 448 , 480 , 504 , 512 , 576 , 600 , 640 , 672 , 720 , ...
vfc_3778
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/IOPC2012/problems/IOPC1211", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n3\n5\n12345678\n", "output": "win 6\nwin 12\nlose\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1235
Solve the following coding problem using the programming language python: Given a number n. Find the last two digits of 5 ^ n ( 5 to the power of n ). Remember that overflow can occur. -----Input:----- - N — the power in which you need to raise number 5. -----Output:----- Last two digits of 5^n. -----Constraints--...
```python print(25) ```
vfc_3782
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CMR12121/problems/DGLST", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n", "output": "25\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1236
Solve the following coding problem using the programming language python: You are given a set of n pens, each of them can be red, blue, green, orange, and violet in color. Count a minimum number of pens that should be taken out from the set so that any two neighboring pens have different colors. Pens are considered to...
```python t = int(input()) for _ in range(t): n = int(input()) a = input().strip() prev = a[0] ans = -1 for i in a: if prev == i: ans += 1 prev = i print(ans) ```
vfc_3786
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDGO2021/problems/DIFFPENS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5\nRBBRG\n5\nRBGOV\n", "output": "1\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1237
Solve the following coding problem using the programming language python: You are standing near a very strange machine. If you put C cents in the machine, the remaining money in your purse will transform in an unusual way. If you have A dollars and B cents remaining in your purse after depositing the C cents, then aft...
```python # cook your dish here for _ in range(int(input())): a,b,c=list(map(int, input().split())) p=a*100+b mx=p ans, cnt = 0, 0 while True: cnt+=1 if p<c or cnt==10000: break else: p-=c a=p//100 b=p%...
vfc_3790
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MONTRANS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9 77 69\n98 99 69\n\n\n", "output": "4\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1238
Solve the following coding problem using the programming language python: Chef likes to play with big numbers. Today, he has a big positive integer N. He can select any two digits from this number (the digits can be same but their positions should be different) and orders them in any one of the two possible ways. For ...
```python test=int(input()) for i in range(test): N=input() X=[] list2=[] for x in N: X.append(x) list1=[] list1=list(set(X)) output='' for x in list1: for y in X: if int(x)>=6: n=int(x)*10+int(y) list2.append(n) for j in list1: if int(j)>=6: m=int(j)*10+int(j) list2.remove(m) list2.sor...
vfc_3794
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFPDIG", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n65\n566\n11\n1623455078\n", "output": "A\nAB\nACDFGHIJKLNPQRSTUVW\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1239
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 # cook your dish here t=int(input()) for _ in range(t): n = int(input()) for i in range(n+1): b = n for space in range(n-i): print(" ",end="") for j in range(i+1): print(b,end="") b-=1 print() for l in range(n): a = n ...
vfc_3798
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY28", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n4\n", "output": "2\n21\n210\n21\n2\n4\n43\n432\n4321\n43210\n4321\n432\n43\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1240
Solve the following coding problem using the programming language python: The chef is having one array of natural numbers. Cheffina challenges chef that find the sum of weights all the natural numbers present in the array, but the main problem is that all numbers have not original weights. After every 6 natural number...
```python # cook your dish here t = int(input()) while t: x = int(input()) arr = [int(i) for i in input().split()] total = 0 for i in arr: if i % 6 == 0: total += 6 else: total += (i % 6) print(total) t -= 1 ```
vfc_3802
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PEND2020/problems/ITGUY00", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n6\n6 7 9 11 4 16\n", "output": "23\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1241
Solve the following coding problem using the programming language python: "Don't Drink and Drive, but when you do, Better Call Saul." Once Jesse and Walter were fighting over extra cash, and Saul decided to settle it with a game of stone piles whose winner gets the extra money. The game is described as follows : There...
```python n=int(input()) for i in range(n): k,x=map(int,input().split()) l=list(map(int,input().split())) f,e,o=0,0,0 for i in l: if(i%2==0): e+=1 else: o+=1 if(o<=x//2): f=1 elif(e<=x//2): if((k-x)%2!=0): f=0 else: f=1 else: if(x%2==0): ...
vfc_3806
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GMSTN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 3\n4 4 4 3 4\n7 4\n3 3 1 1 1 2 4\n", "output": "Jesse\nWalter\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1242
Solve the following coding problem using the programming language python: Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A. - Select a pair of adjacent integers and remove the larger one of these two. This...
```python from math import * for t in range(int(input())): n = int(input()) numberlist = list(map(int,input().split())) numberlist.sort() print(numberlist[0]* ( len(numberlist) -1)) ```
vfc_3810
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/MNMX", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n3 4\n3\n4 2 5\n", "output": "3\n4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1243
Solve the following coding problem using the programming language python: Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 5. If any of the permutations is divisible by 5 then print 1 else print 0. -----Input:----- - First-line will contain $T$, the number of ...
```python a = int(input()) for i in range(a): b = input() if '5' in b or '0' in b: print(1) continue print(0) ```
vfc_3814
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY06", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n19\n385\n", "output": "0\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1244
Solve the following coding problem using the programming language python: A Train started its journey at x=-infinity is travelling on the x-Coordinate Axis. Given n passengers and the coordinates $b_i$ and $d_i$ for each of the $ith$ passenger at which they board and leave from the train respectively. Due to current C...
```python c=0 for i in range (int(input ())): a, b=map(int, input().split()) c+=abs(a-b)+1 print(c%((10**9) +7)) ```
vfc_3818
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COW42020/problems/COW3C", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n0 2\n1 3\n-1 4\n", "output": "12\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1245
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 n = int(input()) l = [0] * n for x in range(n): l[x] = int(input()) for i in range(n): z = 1 for j in range(1,l[i]+1): for k in range(1,l[i]+1): print(z,end='') z += 2 print() ```
vfc_3822
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PTRN2021/problems/ITGUY51", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1\n2\n3\n4\n", "output": "1\n13\n57\n135\n7911\n131517\n1357\n9111315\n17192123\n25272931\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1246
Solve the following coding problem using the programming language python: Walter White and Jesse Pinkman (a drug addict) both love to play with chemicals. One day they were playing with some chemicals to make an energy drink. Unknowingly they made a highly powerful drink. To test the drink on others also they called s...
```python # cook your dish here l1=int(input()) for i in range(l1): x=int(input()) y=list(map(int,input().split())) z=list(map(int,input().split())) if max(z)!=max(y): print('YES') else: print('NO') ```
vfc_3826
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHPTRS01/problems/FUNRUN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n5\n1 2 3 4 5\n2 7 8 9 9\n\n", "output": "YES\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1247
Solve the following coding problem using the programming language python: Chef received a permutation $P_1, P_2, \ldots, P_N$ and also an integer $D$ from his good friend Grux, because Grux was afraid he would forget them somewhere. However, since Grux was just playing with the permutation, it was all shuffled, and Ch...
```python import sys sys.setrecursionlimit(10000000) def mergeSortInversions(arr): if len(arr) == 1: return arr, 0 larr=len(arr) a = arr[:larr//2] b = arr[larr//2:] a, ai = mergeSortInversions(a) b, bi = mergeSortInversions(b) c = [] i = 0 j = 0 inversions = 0 + ai + bi la=len(a) while i < l...
vfc_3830
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DPERM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n5 2\n3 4 5 2 1\n5 2\n4 3 2 1 5\n", "output": "3\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1248
Solve the following coding problem using the programming language python: Chef has recently learned about number bases and is becoming fascinated. Chef learned that for bases greater than ten, new digit symbols need to be introduced, and that the convention is to use the first few letters of the English alphabet. For ...
```python # cook your dish here def finder(n): cnt=0 for i in range(2,n+1): a=n while a!=0: r=a%i a=a//i if r==1: cnt+=1 return cnt t=int(input()) for _ in range(t): n=int(input()) if n==0: print(0) elif n==1: print('IN...
vfc_3834
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BASE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n6\n9\n11\n24\n", "output": "4\n7\n8\n14\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1249
Solve the following coding problem using the programming language python: For a permutation P = (p1, p2, ..., pN) of numbers [1, 2, ..., N], we define the function f(P) = max(p1, p2) + max(p2, p3) + ... + max(pN-1, pN). You are given N and an integer K. Find and report a permutation P of [1, 2, ..., N] such that f(P) ...
```python # cook your dish here for i in range(int(input())): n,k=[int(i) for i in input().split()] if(n%2==0): if(k<(n*(n+1))//2 - 1 or k>3*((n//2)**2) - 1):print(-1) elif(k==(n*(n+1))//2 - 1): for i in range(1,n+1):print(i,'',end='') print() else: k,count,p,l,x = k-(n*(n+1))...
vfc_3838
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/GENPERM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n4 12\n2 2\n5 14\n", "output": "-1\n1 2\n5 4 3 2 1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1250
Solve the following coding problem using the programming language python: Our chef has been assigned a task to make a necklace of length N, from gold, diamond and platinum.There is single kind of gold, two types of diamond and three types of platinum available. A necklace can be represented as strings of the form (G)∗...
```python t=int(input()) for _ in range(t): n=int(input()) p=10**9+7 a=(pow(3,n+1,p)-1) b=(pow(2,n+1,p)-1) print((((3*a)//2)%p-(2*(b))%p+p)%p) ```
vfc_3842
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/ALQU2018/problems/GDP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n2\n", "output": "6\n25\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1251
Solve the following coding problem using the programming language python: Chef likes to travel very much. He plans some travel routes and wants to know their lengths. He hired you to make these calculations. But be careful, some of the routes are incorrect. There may be some misspelling in city names or there will be ...
```python import sys def _r(*conv) : r = [conv[i](x) for i, x in enumerate(input().strip().split(' '))] return r[0] if len(r) == 1 else r def _ra(conv) : return list(map(conv, input().strip().split(' '))) def _rl() : return list(input().strip()) def _rs() : return input().strip() def _a(k, *v) : return all(x...
vfc_3846
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TRAVELER", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "5\nDonetsk Kiev New-York Miami Hollywood\n9\nDonetsk Kiev 560\nKiev New-York 7507\nNew-York Miami 1764\nMiami Hollywood 28\nHollywood Miami 30\nMiami New-York 1764\nKiev Donetsk 550\nHollywood New-York 1736\nNew-York Hollywood 1738...
apps
verifiable_code
1252
Solve the following coding problem using the programming language python: Given a number $n$, give the last digit of sum of all the prime numbers from 1 to $n$ inclusive. -----Input:----- - First line contains number of testcase $t$. - Each testcase contains of a single line of input, number $n$. -----Output:----- ...
```python # cook your dish here import math N = 10**6 sum_arr = [0] * (N + 1) def lprime(): arr = [0] * (N + 1) arr[0] = 1 arr[1] = 1 for i in range(2, math.ceil(math.sqrt(N) + 1)): if arr[i] == 0: for j in range(i * i, N + 1, i): arr[j] = 1 curr_prime...
vfc_3850
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CSEP2020/problems/IRVS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n10\n", "output": "7\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1253
Solve the following coding problem using the programming language python: People in Karunanagar are infected with Coronavirus. To understand the spread of disease and help contain it as early as possible, Chef wants to analyze the situation in the town. Therefore, he does the following: - Chef represents the populatio...
```python # cook your dish here T = int(input()) for i in range(T): N,data,D,People = int(input()),list(map(int,list(input()))),int(input()),list(map(int,input().split())) data.insert(0,"|"),data.append("|") infected = [] for i in range(1,N+1): if(data[i]==1): infected.append(i...
vfc_3854
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CHPTRS01/problems/WASHHAND", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n9\n000010000\n3\n2 5 8\n5\n00001\n1\n5\n", "output": "6\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1254
Solve the following coding problem using the programming language python: Chef wants to organize a contest. Predicting difficulty levels of the problems can be a daunting task. Chef wants his contests to be balanced in terms of difficulty levels of the problems. Assume a contest had total P participants. A problem tha...
```python t = int(input()) for z in range(t) : n,p = [int(x) for x in input().split()] a = [int(x) for x in input().split()] c = [x for x in a if x >= p//2] h = [x for x in a if x <= p//10] if len(c)==1 and len(h)==2 : print("yes") else: print("no") ```
vfc_3858
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PERFCONT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n3 100\n10 1 100\n3 100\n11 1 100\n3 100\n10 1 10\n3 100\n10 1 50\n4 100\n50 50 50 50\n4 100\n1 1 1 1\n", "output": "yes\nno\nno\nyes\nno\nno\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1255
Solve the following coding problem using the programming language python: You are teaching students to generate strings consisting of unique lowercase latin characters (a-z). You give an example reference string $s$ to the students. You notice that your students just copy paste the reference string instead of creating...
```python for _ in range(int(input())): s,k=map(str,input().split()) k=int(k) n="NOPE" al=[0]*26 for ele in s: al[ord(ele)-ord('a')]=1 l=len(s) ans=[] # print(al) for i in range(26): if len(ans)==l: break elif al[i]==1 and k>0: k-=1 ans.append(chr(i+ord('a'))) elif al[i]==0: ans.append(chr(...
vfc_3862
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SDIFFSTR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nhelowrd 0\nbackground 0\nabcdefghijklmnopqrstuvwxyz 0\nb 1\n", "output": "abcfgij\nefhijlmpqs\nNOPE\na\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1256
Solve the following coding problem using the programming language python: Little chef has just been introduced to the world of numbers! While experimenting with addition and multiplication operations, the little chef came up with the following problem: Given an array A of non-negative integers, how many pairs of indi...
```python # cook your dish here t = int(input()) res = [] for i in range(t): n = int(input()) arr = [int(i) for i in input().split()] num_2 = 0 num = 0 for j in range(len(arr)): if arr[j] == 2: num_2 += 1 if arr[j] > 2: num += 1 res.append(num_2 * num + (num * (num - 1)) // 2) for z in re...
vfc_3866
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PROSUM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n3 4 5\n4\n1 1 1 1\n", "output": "3\n0\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1257
Solve the following coding problem using the programming language python: The chef was chatting with his friend who was a mathematician. Chef said "Hi !". His friend replied that '!' is the symbol of factorial. Chef had never heard about it and he asked more about it. Then his friend taught him how to calculate the ...
```python factorials=[1] for x in range(1,201): factorials.append(factorials[x-1]*x) x=int(input()) for x in range(x): n=int(input()) print(factorials[n]) ```
vfc_3870
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/AGTK2012/problems/ALGFACT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n5\n4\n6\n", "output": "120\n24\n720\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1258
Solve the following coding problem using the programming language python: Chef Zidane likes the number 9. He has a number N, and he wants to turn it into a multiple of 9. He cannot add or remove digits, and he can only change one digit at a time. The only allowed operation is to increment or decrement a digit by one, ...
```python s=int(input()) while(s>0): s-=1 a=input() c=0 for x in a: c+=int(x) if(c<9 and len(a)!=1): print(9-c%9) else: print(min(9-c%9,c%9)) ```
vfc_3874
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/DIVNINE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n1989\n86236\n90210\n99999999999999999999999999999999999999988\n", "output": "0\n2\n3\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1259
Solve the following coding problem using the programming language python: Vasya likes the number $239$. Therefore, he considers a number pretty if its last digit is $2$, $3$ or $9$. Vasya wants to watch the numbers between $L$ and $R$ (both inclusive), so he asked you to determine how many pretty numbers are in this ...
```python # cook your dish here t=int(input()) for _ in range(t): n,m = map(int,input().split()) count=0 for i in range(n,m+1): p=str(i) if p[-1]=='2' or p[-1]=='3' or p[-1]=='9': count+=1 print(count) ```
vfc_3878
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/NUM239", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 10\n11 33\n", "output": "3\n8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1260
Solve the following coding problem using the programming language python: Lavanya and Nikhil have K months of holidays ahead of them, and they want to go on exactly K road trips, one a month. They have a map of the various cities in the world with the roads that connect them. There are N cities, numbered from 1 to N. ...
```python def merge(intervals,start,mid,end): al = mid-start+1 bl = end-mid A = intervals[start:mid+1] B = intervals[mid+1:end+1] p=0;q=0;k=start; while(p<al and q<bl): if(A[p]<B[q]): intervals[k] = A[p] k+=1;p+=1; else: intervals[k] = B[q] k+=1;q+=1; while(p<al): intervals[k] = A[p] k+...
vfc_3882
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/INOIPRAC/problems/ROADTRIP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n10 10 3\n1 3\n3 5\n5 1\n1 6\n6 2\n5 6\n2 5\n7 10\n4 7\n10 9\n20 0 15 20 25 30 30 150 35 20\n10 10 2\n1 3\n3 5\n5 1\n1 6\n6 2\n5 6\n2 5\n7 10\n4 7\n10 9\n20 0 15 20 25 30 30 150 35 20\n10 10 5\n1 3\n3 5\n5 1\n1 6\n6 2\n5 6\n2 5\n...
apps
verifiable_code
1261
Solve the following coding problem using the programming language python: You have been appointed as the designer for your school's computer network. In total, there are N computers in the class, and M computer-to-computer connections need to be made. Also, there are three mandatory conditions the design should fulfil...
```python import fractions import sys f = sys.stdin if len(sys.argv) > 1: f = open(sys.argv[1], "rt") def calc(N, M): if M != N: return [(-1, -1)] r = [(i+1, ((i+1) % N)+1) for i in range(N)] return r T = int(f.readline().strip()) for case_id in range(1, T+1): N, M = list(map(int, f.readline().strip().sp...
vfc_3886
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LTIME31/problems/EXNETWRK", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n10 1\n5 5\n", "output": "-1 -1\n1 2\n2 3\n3 4\n4 5\n5 1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1262
Solve the following coding problem using the programming language python: An area named Renus, is divided into $(N \times M)$ cells. According to archaeological survey the area contains huge amount of treasure. Some cells out of $(N \times M)$ cells contain treasure. But problem is, you can't go to every cell as some ...
```python t=int(input()) for _ in range(t): n,m=[int(x) for x in input().split()] mat=[] ans=[] for i in range(n+2): l=[] p=[] for j in range(m+2): l.append(0) p.append(1000000000) mat.append(l) ans.append(p) y=int(input()) for i in range(y): a,b=[int(x) for x in input().split()] mat[a][b]=1 ...
vfc_3890
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CACD2020/problems/AJP", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3 3\n2\n1 1\n1 3\n2\n2 1\n2 2\n", "output": "0 1 0\nX X 1\n4 3 2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1263
Solve the following coding problem using the programming language python: The chef was playing with numbers and he found that natural number N can be obtained by sum various unique natural numbers, For challenging himself chef wrote one problem statement, which he decided to solve in future. Problem statement: N can b...
```python for _ in range(int(input())): x,n = map(int,input().split()) reach = [0]*(x+1) reach[0] = 1 i=1 while i**n<=x: j = 1 while j+i**n<=x: j+=1 j-=1 while j>=0: if reach[j]>0: reach[j+i**n]+=reach[j] j-=1 ...
vfc_3894
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY24", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 1\n38 2\n", "output": "2\n1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1264
Solve the following coding problem using the programming language python: Mohit's girlfriend is playing a game with Nicky. The description of the game is as follows: - Initially on a table Player 1 will put N gem-stones. - Players will play alternatively, turn by turn. - At each move a player can take at most M gem-st...
```python r=[0,1,1,2,1,4,2,6,1,8,4] n,m=[int(x) for x in input().split()] if m==1: while n%2!=1: n=n/2 if n==1: print(1) else: print(n-1) elif (n+1)/2<m: print(m) else: print(n-m) ```
vfc_3898
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/CDVA16/problems/CDVA1610", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4 2\n", "output": "2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1265
Solve the following coding problem using the programming language python: The Head Chef is receiving a lot of orders for cooking the best of the problems lately. For this, he organized an hiring event to hire some talented Chefs. He gave the following problem to test the skills of the participating Chefs. Can you solv...
```python def base5(n): if n == 0: return for x in base5(n // 5): yield x yield n % 5 def seq(n): return int(''.join(str(2 * x) for x in base5(n)) or '0') for i in range(eval(input())): k=eval(input()) while(i<k): i=i+1 print(seq(i-1)) ```
vfc_3902
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/JUNE16/problems/CHEARMY", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n5\n\n\n", "output": "2\n8\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1266
Solve the following coding problem using the programming language python: Chef's younger brother is in town. He's a big football fan and has a very important match to watch tonight. But the Chef wants to watch the season finale of MasterChef which will be aired at the same time. Now they don't want to fight over it li...
```python res="" for _ in range(int(input())): ans=0 c=int(input()) for i in range(c): n,m=list(map(int,input().split( ))) ans^=(n+m-2)%3 if ans: res+="MasterChef\n" else: res+="Football\n" print(res) ```
vfc_3906
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFBRO", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n1\n2 2\n", "output": "MasterChef\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1267
Solve the following coding problem using the programming language python: Chef likes problems related to learning new languages. He only knows first N letters of English alphabet. Also he explores all M-letter words formed by the characters he knows. Define cost for a given M-letter word S, cost(S) = P1, S1+P2, S2+......
```python def dfs(ind,m,n,k): if(ind == m): return [""] else: temp = dfs(ind+1,m,n,k) ans = [] if(len(temp)<k): for i in temp: for j in range(97,97+n): ans += [chr(j)+i] else: for i in temp: ans += ["z"+i] return ans n,m,k = list(map(int,input().split())) p = [] mr= [] for _ in range(m):...
vfc_3910
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/LTIME40/problems/LTM40EF", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2 5 17\n7 9\n13 18\n10 12\n4 18\n3 9\n", "output": "aaaba\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1268
Solve the following coding problem using the programming language python: There is a universal library, where there is a big waiting room with seating capacity for maximum $m$ people, each of whom completes reading $n$ books sequentially. Reading each book requires one unit of time. Unfortunately, reading service is ...
```python while(True): n, m, x = map(int, input().split()) if(n==0 and m==0 and x==0): break money=0 for i in range(n): money=money + (x+m*i)//n print(money) ```
vfc_3914
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/READCOST", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1 100 9\n11 2 10\n12 2 11\n0 0 0\n", "output": "9\n15\n16\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1269
Solve the following coding problem using the programming language python: Once again, we have a lot of requests from coders for a challenging problem on geometry. Geometry expert Nitin is thinking about a problem with parabolas, icosahedrons, crescents and trapezoids, but for now, to encourage beginners, he chooses to...
```python for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) a.sort() b.sort() s=0 for i in range(n): s+=min(a[i],b[i]) print(s) ```
vfc_3918
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/SNUG_FIT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4\n8 8 10 12\n15 20 3 5\n3\n20 20 20\n10 10 10\n", "output": "30\n30\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1270
Solve the following coding problem using the programming language python: Get excited, folks, because it is time for the final match of Codechef Premier League (CPL)! Mike and Tracy also want to watch the grand finale, but unfortunately, they could not get tickets to the match. However, Mike is not someone who gives u...
```python import sys sys.setrecursionlimit(100000) memo = {} def recurse(arr, T1, T2, k, i): if T1 >= k and T2 >= k: return i if i >= len(arr): return float('inf') if (T1, T2) in memo: return memo[(T1, T2)] t1 = recurse(arr, T1 + arr[i], T2, k, i+1) t2 = recurse(arr, T1, T2 + arr[i], k, i+1) memo[(T1,...
vfc_3922
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/WIPL", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n8 38\n7 8 19 7 8 7 10 20\n4 5\n2 10 4 9\n", "output": "7\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1271
Solve the following coding problem using the programming language python: You are given a set $S$ and $Q$ queries. Initially, $S$ is empty. In each query: - You are given a positive integer $X$. - You should insert $X$ into $S$. - For each $y \in S$ before this query such that $y \neq X$, you should also insert $y \op...
```python # fast io import sys def fop(s): sys.stdout.write(str(s)+'\n') def fip(): return sys.stdin.readline() fintinp = lambda : int(fip()) def flistinp(func= int): return list(map(func,fip().split())) def fnsepline(n,func=str): return [func(fip()) for _ in range(n)] #-------------------code------------------------...
vfc_3926
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/PRTAGN", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n4\n2\n7\n", "output": "0 1\n1 2\n3 4\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1272
Solve the following coding problem using the programming language python: Given an integer $x$, find two non-negative integers $a$ and $b$ such that $(a \wedge b) + (a \vee b) = x$, where $\wedge$ is the bitwise AND operation and $\vee$ is the bitwise OR operation. -----Input----- - The first line of the input contai...
```python # cook your dish here n=int(input()) for _ in range(n): a=int(input()) if(a%2==0): f=(a//2)-1 s=a-f else: f=(a//2) s=a-f print(f,s) ```
vfc_3930
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ANDOR", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1\n8\n", "output": "0 1\n5 3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1273
Solve the following coding problem using the programming language python: There is a haunted town called HauntedLand. The structure of HauntedLand can be thought of as a grid of size n * m. There is a house in each cell of the grid. Some people have fled from their houses because they were haunted. '.' represents a ha...
```python import math t = int(input().strip()) for _ in range(t): n, m = list(map(int, input().strip().split())) a = [] v = [-1] * 4 for i in range(n): a.append(input().strip()) for i, ai in enumerate(a): if ai.find('*') > -1: v[2] = i break if v[2] == -1: print(0) else: for i, ai in reverse...
vfc_3934
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/JAN16/problems/DEVPERF", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2 2\n*.\n..\n3 4\n.*..\n***.\n.*..\n", "output": "1\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1274
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 for _ in range(int(input().strip())): n = int(input().strip()) lst = [] for i in range(n): lst.append(i+1) lst.append(1) #print(lst) for i in range(n): print(''.join(str(e) for e in lst)) for x in range(n): lst[x * 2 + 1] += 1 ```
vfc_3938
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY35", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n2\n3\n4\n", "output": "1121\n1222\n112131\n122232\n132333\n11213141\n12223242\n13233343\n14243444\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1275
Solve the following coding problem using the programming language python: N Soldiers are lined up for a memory test. They are numbered from 0 to N-1 from left to right. In the test, there are M rounds. In each round, Captain selects one position. Soldier at that position will be numbered 0. All the soldiers to the r...
```python test = int(input()) for _ in range(test): n, m = map(int, input().split()) indexArray = list(map(int, input().split())) mini = min(indexArray) maxi = max(indexArray) result = n*[0] for i in range(n): result[i] = max(maxi - i, i - mini) print(result[i], end=" ") print() ```
vfc_3942
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/ANUARM", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n4 1\n1\n6 2\n2 3\n", "output": "1 0 1 2\n3 2 1 1 2 3\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1276
Solve the following coding problem using the programming language python: Chef Tobby is trying to run a code given to him by Bhuvan for an experiment they want to include in the manuscript to be submitted to a conference. The deadline to submit the manuscript is within a couple of hours and Chef Tobby needs to finish ...
```python from bisect import * for x in range(eval(input())): n,k = list(map(int,input().split())) arr = list(map(int,input().split())) arr.sort() t = 1 result = 0 y = 0 while y < n: if arr[y]<t: y += 1 elif arr[y]==t: t = t*2 y += 1 else: result += 1 t = t*2 while t < 2**(k): result +=...
vfc_3946
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COOK86/problems/LIKECS03", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "- 1\n1\n2 2\n3 1\n", "output": "1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1277
Solve the following coding problem using the programming language python: Chef recently opened a big e-commerce website where her recipes can be bought online. It's Chef's birthday month and so she has decided to organize a big sale in which grand discounts will be provided. In this sale, suppose a recipe should have ...
```python for i in range(int(input())): n=int(input()) s=0 for i in range(n): a,b,c=map(int,input().split()) d=(c/100)*a e=a+d f=e-((c/100)*e) g=a-f h=b*g s=s+h print(s) ```
vfc_3950
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/BIGSALE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n2\n100 5 10\n100 1 50\n3\n10 10 0\n79 79 79\n100 1 100\n", "output": "30.000000000\n3995.0081000\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1278
Solve the following coding problem using the programming language python: A plot of land can be described by $M x N$ dots such that horizontal and vertical distance between any two dots is 10m. Mr. Wolf would like to build a house in the land such that all four sides of the house are equal. Help Mr. Wolf to find the t...
```python # cook your dish here from sys import stdin,stdout,setrecursionlimit from math import ceil mod = 1000000007 t = int(stdin.readline()) for _ in range(t): m,n = list(map(int,input().split())) if m < n: m,n = n,m y = n-1 s1 = ((y*(y+1)) //2)%mod s2 = ((y*(y+1)*(2*y+1)) //6)%mod ...
vfc_3954
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/COX22020/problems/DCODEX2", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\n2 4\n3 4\n4 4\n1000 500\n", "output": "3\n10\n20\n624937395\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1279
Solve the following coding problem using the programming language python: Chef hates unoptimized codes and people who write such codes. One fine day he decided to look through the kitchen's codebase and found a function whose pseudo-code is given here: input: integer N, list X[1, 2, ..., N], list Y[1, 2, ..., N] out...
```python # cook your dish here for _ in range(int(input())): d=dict() ls=[] for i in range(int(input())): ls=list(map(int,input().split())) if ls[0] in d: d[ls[0]]=max(ls[1],d[ls[0]]) else: d[ls[0]]=ls[1] # print(d) if len(d)<3: print(0) else: kd=list(d.values()) kd.sort() # print(kd) print...
vfc_3958
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/OPTCODE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n3\n1 3\n3 1\n1 2\n5\n1 3\n2 4\n1 2\n3 2\n3 4\n", "output": "0\n11\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1280
Solve the following coding problem using the programming language python: Emily and Mia are friends. Emily got Mia’s essay paper, but since she is a prankster, she decided to meddle with the words present in the paper. She changes all the words in the paper into palindromes. To do this, she follows two rules: - In on...
```python t=int(input()) for _ in range(t): xyz = input().strip() string = 0 for i in range(len(xyz)//2): string = string + (abs(ord(xyz[i])-ord(xyz[len(xyz)-i-1]))) print(string) ```
vfc_3962
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/RTCG2020/problems/RTCG004", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "4\nabc\nabcba\nabcd\ncba\n", "output": "2\n0\n4\n2\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1281
Solve the following coding problem using the programming language python: Chef likes all arrays equally. But he likes some arrays more equally than others. In particular, he loves Rainbow Arrays. An array is Rainbow if it has the following structure: - First a1 elements equal 1. - Next a2 elements equal 2. - Next a...
```python t=int(input()) x=[1,2,3,4,5,6,7] for i in range(t): N=int(input()) a=list(map(int,input().split())) rev=a[::-1] dup=set(a) if rev== a and list(dup) ==x: print("yes") else: print("no") ```
vfc_3966
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RAINBOWA", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n19\n1 2 3 4 4 5 6 6 6 7 6 6 6 5 4 4 3 2 1\n14\n1 2 3 4 5 6 7 6 5 4 3 2 1 1\n13\n1 2 3 4 5 6 8 6 5 4 3 2 1\n", "output": "yes\nno\nno\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1282
Solve the following coding problem using the programming language python: You are given positive integers $L$ and $R$. You have to find the sum S=∑i=LR(L∧(L+1)∧…∧i),S=∑i=LR(L∧(L+1)∧…∧i),S = \sum_{i=L}^R \left(L \wedge (L+1) \wedge \ldots \wedge i\right) \,, where $\wedge$ denotes the bitwise AND operation. Since the s...
```python l= [] for i in range(62): l.append(2**i) T = int(input()) flag = 0 for t in range(T): L,R = [int(i) for i in input().split()] bL = bin(L) lL = len(bL)-2 index = 1 ans = 0 temp = 0 while(index<=lL): temp = L%l[index] if temp>=l[index-1]: if(l[index]-temp<=R-L+1): ans= (ans +(l[index-1])*(...
vfc_3970
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/RGAND", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "2\n1 4\n4 10\n", "output": "1\n16\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1283
Solve the following coding problem using the programming language python: Chef likes prime numbers. However, there is one thing he loves even more. Of course, it's semi-primes! A semi-prime number is an integer which can be expressed as a product of two distinct primes. For example, $15 = 3 \cdot 5$ is a semi-prime nu...
```python # cook your dish here import sys n = 201 v = [0 for i in range(n + 1)] def gen(): for i in range(1, n + 1): v[i] = i countDivision = [0 for i in range(n + 1)] for i in range(n + 1): countDivision[i] = 2 for i in range(2, n + 1, 1): ...
vfc_3974
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/CHEFPRMS", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "3\n30\n45\n62\n\n", "output": "YES\nYES\nNO\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1284
Solve the following coding problem using the programming language python: Coach Khaled is a swag teacher in HIT (Hag Institute of Technology). However, he has some obsession problems. Recently, coach Khaled was teaching a course in building 8G networks using TV antennas and programming them with assembly. There are $N...
```python # cook your dish here for _ in range(int(input())): n = int(input()) k = n//4 # a,b,c = map(int,input().split()) a = sorted(map(int,input().split())) a60 = (a[k-1],a[k]) a75 = (a[2*k-1],a[2*k]) a90 = (a[3*k-1],a[3*k]) if a60[0]==a60[1] or a75[0]==a75[1] or a90[0]==a90[1] : print(-1) else : print(...
vfc_3978
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/HIT", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "6\n4\n90 25 60 75\n8\n27 29 92 92 67 67 85 92\n4\n0 1 2 3\n4\n100 100 100 100\n4\n30 30 40 50\n4\n30 40 40 50\n", "output": "60 75 90\n-1\n1 2 3\n-1\n-1\n-1\n", "type": "stdin_stdout" } ] }
apps
verifiable_code
1285
Solve the following coding problem using the programming language python: Chef is learning linear algebra. Recently, he learnt that for a square matrix $M$, $\mathop{\rm trace}(M)$ is defined as the sum of all elements on the main diagonal of $M$ (an element lies on the main diagonal if its row index and column index ...
```python # cook your dish here T=int(input()) for k in range(0,T): N=int(input()) matrix=[] for i in range(0,N): a=list(map(int, input().split())) matrix.append(a) max_trace = [] for i in range(0,N): trace1=0 trace2=0 for j in range(0,i+1): trace1+=matrix[j][N+j-i-1] trace2+=matrix[N+j-i-1][j] ...
vfc_3982
{ "difficulty": "interview", "memory_limit": null, "memory_limit_bytes": null, "problem_url": "https://www.codechef.com/problems/TRACE", "time_limit": "None" }
{ "language": "python", "test_cases": [ { "fn_name": null, "input": "1\n3\n1 2 5\n6 3 4\n2 7 1\n", "output": "13\n", "type": "stdin_stdout" } ] }