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 | 1286 | Solve the following coding problem using the programming language python:
Wet Shark once had 2 sequences:
{a_n}= {a_1, a_2, a_3, ... , a_(109)}
{b_n} = {b_1, b_2, b_3, ... , b_(109)}
However, he only kept one element from each sequence. Luckily, both the elements that Wet Shark kept have the same index in Wet Sha... | ```python
import math
def main():
#print("enter i, k, s")
IN = '11 6 5'
z = IN.split()
z = input().split()
i = int(z[0])
k = int(z[1])
s = int(z[2])
#print("enter a_i and b_i")
IN = '4 5'
z = IN.split()
z = input().split()
a_i = int(z[0])
b_i = int(z[1])
#print( "i = %d ... | vfc_3986 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CODECRCK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 5\n4 5\n",
"output": "0.28125\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1287 | Solve the following coding problem using the programming language python:
You are given a string $s$. And you have a function $f(x)$ defined as:
f(x) = 1, if $x$ is a vowel
f(x) = 0, if $x$ is a constant
Your task is to apply the above function on all the characters in the string s and convert
the obtained binary st... | ```python
t=int(input())
MOD=(10**9)+7
l=['a','e','i','o','u']
for i in range(t):
s=input()
k=[]
for j in s:
if j in l:
k.append(1)
else:
k.append(0)
r=bin(int(''.join(map(str, k)), 2) << 1)
print((int(r,2)//2)%MOD)
``` | vfc_3990 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CBEN2020/problems/STRNM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nhello\n",
"output": "9\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1288 | Solve the following coding problem using the programming language python:
Chef Shifu wanted to celebrate the success of his new restaurant with all his employees. He was willing to host a party and he had decided the location of the party as well. However, Chef Shifu was a shy person and wanted to communicate with the... | ```python
t=int(input())
for _ in range(t):
n,m=map(int,input().split())
mat=[0 for i in range(n)]
#mat=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
u,v=map(int,input().split())
u,v=(u-1),(v-1)
mat[u]|=(1<<v)
mat[v]|=(1<<u)
for i in range(n):
mat[i]|=(1<<i) ... | vfc_3994 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHSHIFU",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n1 2\n2 3\n1 3\n4 3\n1 2\n2 3\n3 4\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1289 | Solve the following coding problem using the programming language python:
So the Chef has become health conscious and is now lifting weights at the gym. But its his first time so the trainer gives him a simple job to do.
He has been given a weight lifting rod and N heavy weights, each weighing 20, 21, .... , 2n-1. H... | ```python
t = int(input())
while(t>0):
n=int(input())
if(n<=0):
print(0)
fact=1
start=1
for i in range(1,n+1):
fact*=start
start+=2
print(fact)
t=t-1
``` | vfc_3998 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AGTK2012/problems/ALGPAN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n5\n18\n",
"output": "3\n945\n221643095476699771875\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1290 | Solve the following coding problem using the programming language python:
Write a program to obtain a number $(N)$ from the user and display whether the number is a one digit number, 2 digit number, 3 digit number or more than 3 digit number
-----Input:-----
- First line will contain the number $N$,
-----Output:----... | ```python
# cook your dish here
x=input ()
y=len (x)
if y==1:
print('1')
elif y==2:
print('2')
elif y==3:
print('3')
elif y>3:
print('More than 3 digits')
``` | vfc_4002 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HOWMANY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1291 | Solve the following coding problem using the programming language python:
Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what... | ```python
#-*- coding:utf-8 -*-
import sys
# class Point:
# def __init__(self, x, y):
# self.x = x
# self.y = y
# def mul(self, k):
# return Point(k * self.x, k * self.y)
# def __add__(self, other):
# return Point(self.x + other.x, self.y + other.y)
# def __sub__(se... | vfc_4006 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/COLLIDE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0 0 R\n2\n1 -2 U\n2 2 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n3 0 L\n",
"output": "2.0\nSAFE\n1.5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1292 | Solve the following coding problem using the programming language python:
You are given a grid of size N x M consisting of '.' (empty), 'W' (white) or 'B' (black) cells. We follow the convention that the top left corner is the position (1,1) and bottom right corner is (N,M).
From every '.' cell (i, j), a ray is shot ... | ```python
# cook your dish here
from operator import itemgetter
inp=list(map(int, input().split()))
n, m, w, b = inp[:4]
stops=[]
for i in range(w):
stops.append((inp[4+2*i]-1,inp[5+2*i]-1,'w'))
for i in range(b):
stops.append((inp[4+2*w+2*i]-1,inp[5+2*w+2*i]-1,'b'))
stops.sort(key=itemgetter(1))
stops.sort(key=itemg... | vfc_4010 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO17002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 5 2 1 3 2 1 3 2 3 3 4 3 1 4 2 3\n",
"output": "22\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1293 | Solve the following coding problem using the programming language python:
Chef and his friend Miron were getting bored and decided to play a game.
Miron thinks of a sequence of N integers (A1, A2, …., AN) and gives Chef a matrix B, where Bi,j = |Ai - Aj|. He further tells Chef that A1 = 0. The game is for Chef to g... | ```python
def update_B(B, query):
p, R = query
for i in range(len(R)):
B[p][i] = R[i]
B[i][p] = R[i]
def get_A(B):
N = len(B)
A = [0] * N
i = 0
for j in range(N):
if B[0][j] != 0:
i = j
A[i] = -B[0][i]
break
for j in range(i + 1, N):
if abs(A[i] - B[0][j]) == B[i][j]:
A[j] = B[0][j]
else:... | vfc_4014 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MTRXMOD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n0 1 2\n1 0 1\n2 1 0\n1\n0 4 3\n2\n4 0 7\n",
"output": "0 -1 -2\n0 -4 -3\n0 -4 3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1294 | Solve the following coding problem using the programming language python:
"Say my Name".
Todd Alquist is being taught the process of cooking methamphetamine, but to see whether he's really capable of learning it, Walt gives him a problem to solve. Since he can't solve it, he asks you for help.
You are given a tree wit... | ```python
# cook your dish here
import sys,collections
input=sys.stdin.readline
def main():
T=int(input())
for _ in range(T):
N,K=map(int,input().split())
Tree={}
for j in range(N):
Tree[j]=[]
for i in range(N-1):
u,v=map(int,input().split())
Tree[u-1].append(v-1)
Tree[v-1].append(u-1)
A... | vfc_4018 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/KTREE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n6 85\n1 2\n2 3\n2 4\n4 5\n3 6\n3 5 4 7 1 9\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1295 | Solve the following coding problem using the programming language python:
In the year 4242, the language Haskell has evolved so much that it has become an AI. It can solve very challenging problems, in very little time. Humanity is worried that Haskell will take over the world. All hopes remain tied to the Competitive... | ```python
mod=10**9+7
def fibonacci(n):
if n < 0:
raise ValueError("Negative arguments not implemented")
return (_fib(n)[0]%mod + mod)%mod;
def _fib(n):
if n == 0:
return (0, 1)
else:
a, b = _fib(n // 2)
c = (a * (b * 2 - a))%mod
d = (a * a + b * b)%mod
if n % 2 == 0:
return (c, d)
else:
return ... | vfc_4022 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IPC15P3B/problems/FIBEQN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1 1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1296 | Solve the following coding problem using the programming language python:
In Byteland there are N cities, numbered 1 through N. Some pairs of cities are connected by bi-directional roads in such a way that starting from any one city you can visit all other cities either directly or indirectly.
Chef is currently at ci... | ```python
import sys
sys.setrecursionlimit(10**8)
MOD = 10**9+7
fac = [0]*(10**5+1)
def pre() :
fac[0] = 1
for i in range(1,10**5+1) :
fac[i] = fac[i-1]*i
fac[i] = fac[i]%MOD
def dfs(gp , vertex , visited , deg , ans) :
visited[vertex] = 1
stack = []
stack.append(vertex)
while len(stack)>0 :
vertex = sta... | vfc_4026 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCAPR16/problems/BLTOUR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 2\n1 3\n1\n5\n1 2\n1 3\n2 4\n2 5\n1\n",
"output": "2\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1297 | Solve the following coding problem using the programming language python:
Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.
Relational Operators are operators which check relatioship between two values. Given two numerical values A and B you need to he... | ```python
# cook your dish here
for _ in range(int(input())):
x, y= map(int, input().split())
if x<y:
print('<')
elif x>y:
print('>')
else:
print('=')
``` | vfc_4030 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHOPRT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n10 20\n20 10\n10 10\n",
"output": "<\n>\n=\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1298 | Solve the following coding problem using the programming language python:
Batman is about to face Superman so he decides to prepare for the battle by upgrading his Batmobile. He manufactures multiple duplicates of his standard Batmobile each tweaked in a different way such that the maximum speed of each is never less ... | ```python
t = int(input())
while(t):
n = int(input())
ar = list(map(int,input().strip().split(" ")))
print(len([x for x in ar[1:len(ar)] if ar[0]<x]))
t-=1
``` | vfc_4034 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COLE2016/problems/CLBMUP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 2 3 4 5\n5\n1 10 100 1000 10000 100000\n",
"output": "4\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1299 | Solve the following coding problem using the programming language python:
Chef has $N$ dishes of different types arranged in a row: $A_1, A_2, \ldots, A_N$, where $A_i$ denotes the type of the $i^{th}$ dish. He wants to choose as many dishes as possible from the given list but while satisfying two conditions:
- He ca... | ```python
t=int(input())
f=0
y=0
for _ in range(t):
n=int(input())
seq=[int(x) for x in input().split()]
prev=seq[0]
for i in range(1,len(seq)):
if prev==seq[i]:
seq[i]=0
prev=seq[i]
ans=0
anss=0
for el in seq:
if el!=0:
c=seq.count(el)
if ans<c:
ans=c
anss=el
elif ans==c:
if ... | vfc_4038 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/RC122020/problems/RECNDNOS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5\n1 2 2 1 2\n6\n1 1 1 1 1 1\n8\n1 2 2 2 3 4 2 1\n",
"output": "1\n1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1300 | Solve the following coding problem using the programming language python:
Sunita has lots of tasks pending and she has no time to complete. She needs your help and wants you complete the task.
You are given a list of integers and two values $N$ and $K$ $-$ the size of array of integers and the numbers of partitions t... | ```python
from sys import stdin,stdout
from math import gcd
for _ in range(int(stdin.readline())):
# n=int(stdin.readline()) k-pieces
n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))
gr=[[0 for _ in range(n)]for _ in range(n)];ans=0;k-=1
for sz in range(n)... | vfc_4042 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENNO2020/problems/ECJAND",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2\n5 6 3 2\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1301 | Solve the following coding problem using the programming language python:
The chef has a number N, Cheffina challenges chef to form the largest number X from the digits of N.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line ... | ```python
# cook your dish here
n=int(input())
l=[]
for i in range(n):
a=int(input())
l.append(a)
for i in l:
b = list(map(int, str(i)))
b.sort(reverse=True)
s = [str(i) for i in b]
r = int("".join(s))
print(r)
``` | vfc_4046 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY32",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n212\n",
"output": "2\n221\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1302 | Solve the following coding problem using the programming language python:
The Chef has bought $N$ boxes of Tiles. The number of tiles present in $i^{th}$ box is $i$ ($i $ varies from $1$ to $N$) . The Chef has two houses with $N$ rooms each, whose floors is a square with area $(i*i)$ ,i varies from $(1..... | ```python
from sys import stdin
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
n //= 2
k = 2 * int(n**0.5)
print(k)
``` | vfc_4050 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENAU2020/problems/ECAUG203",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n16\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1303 | Solve the following coding problem using the programming language python:
After the death of their mother, Alphonse and Edward now live with Pinako and Winry.
Pinako is worried about their obsession with Alchemy, and that they don't give attention to their studies.
So to improve their mathematical solving ability, ev... | ```python
# cook your dish here
mod = 10**9 + 7
for i in range(int(input())):
n,k,m = tuple(map(int, input().split()))
a = list(map(int, input().split()))
ans = [0 for i in range(k+1)]
ans[0] = 1
curr_ending = 1
for i in range(n):
mod_a = a[i]%m
start = curr_ending - (curr_ending%m - m... | vfc_4054 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GRUMPMA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n12 4 3\n4 5 6 7 1 4 6 9 0 0 10 2\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1304 | Solve the following coding problem using the programming language python:
It is an interesting exercise to write a program to print out all permutations of $1, 2, …, n$. However, since there are $6227020800$ permutations of $1, 2, …, 13$, it is unlikely that we would ever run this program on an input of size more than... | ```python
import sys
# import math as mt
# from collections import Counter
# from itertools import permutations
# from functools import reduce
# from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
def get_inpt(): return sys.stdin.readline().strip()
def get_int(): return int(sys.stdin.readlin... | vfc_4058 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/NEXTPERM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n3 1 2\n2 3 1\n\n",
"output": "3 2 1\n3 1 2 \n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1305 | Solve the following coding problem using the programming language python:
Due to the COVID pandemic, there has been an increase in the number of cases if a hospital. The management has decided to clear a large square area for the patients and arrange for beds. But the beds can't be too near to each other.
The area is ... | ```python
res = []
for _ in range(int(input())):
lst = []
flag = 0
n = int(input())
for i in range(n):
lst.append(list(map(int, input().split())))
for i in lst:
for j in range(n-1):
if i[j] == i[j+1] == 1:
res.append("UNSAFE")
flag = 1
break
if flag != 0:
break
for i in range(n-1):
for j... | vfc_4062 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QTST2020/problems/HOSPBEDS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 0 1 0\n0 0 0 1\n0 1 0 0\n1 0 0 1\n4\n1 0 1 0\n0 0 0 0\n1 0 1 1\n0 1 0 0\n",
"output": "SAFE\nUNSAFE\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1306 | Solve the following coding problem using the programming language python:
You are given a string S constisting of uppercase Latin letters. Is it possible to reorder the characters in this string to get a string with prefix "LTIME" and suffix "EMITL"?
We remind you that a prefix of a string is any substring which conta... | ```python
# cook your dish here
from collections import Counter
for i in range(int(input())):
s=input().upper()
res=Counter(s)
if res["L"]>=2 and res["T"]>=2 and res["I"]>=2 and res["M"]>=2 :
if len(s)==9:
if res["E"] >=1 :
print("YES")
else:
print("NO")
elif len(s)>9:
if res["E"]>=2:
print(... | vfc_4066 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EMITL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nLTIMEAZAZAITLME\nLLLTTTIIIMMMEEEAHA\nLTIMEM\n",
"output": "YES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1307 | Solve the following coding problem using the programming language python:
As we all know, F.C. Barcelona is the best soccer team of our era! Their entangling and mesmerizing game style usually translates into very high ball possession, consecutive counter-attack plays and goals. Lots of goals, thanks to the natural ta... | ```python
T = int(input())
for _ in range(T):
p,n=map(int,input().split())
mod = 1000000007
if p == 2:
print(n)
else:
f=n
t=n
for i in range(p-2):
f=(f%mod*n)%mod
a=(f-t+mod)%mod
t=a
print(a)
``` | vfc_4070 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FCBARCA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 4\n4 2\n",
"output": "4\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1308 | Solve the following coding problem using the programming language python:
Raj is suffering from shot term memory loss so he is unable to remember his laptop password but he has a list of some string and the only thing that he remember about his password is alphanumeric and also that all the characters are unique.
Gi... | ```python
import collections
while True:
d = input().strip()
myCounter = collections.Counter(d)
flag = 1
for x in list(myCounter.keys()):
if myCounter[x] > 1:
flag = 0
break
isAlp = sum([myCounter[x] for x in list(myCounter.keys()) if x.isalnum()])
if flag and isAlp:
print("Valid")
break
else:
... | vfc_4074 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CYPH2016/problems/LOSTPW",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "absdbads\nasdjenfef\ntyerbet\nabc564\n",
"output": "Invalid\nInvalid\nInvalid\nValid\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1309 | 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())):
n = int(input())
s = [str(i) for i in range(n,0,-1)]
for i in range(n):
print('*'*i+''.join(s))
del(s[0])
``` | vfc_4078 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY37",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "1\n21\n*1\n321\n*21\n**1\n4321\n*321\n**21\n***1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1310 | Solve the following coding problem using the programming language python:
Bohan loves milk tea so much and he drinks one cup of milk tea every day. The local shop sells milk tea in two sizes: a Medium cup for $3 and a Large cup for $4. For every cup of milk tea purchased Bohan receives a promotional stamp. Bohan may r... | ```python
t = int(input())
for tc in range(t):
seq = input()
dollar = 0
stamp = 0
for ct in seq:
if stamp >= 6:
stamp -= 6
continue
elif ct == 'M':
dollar += 3
elif ct == 'L':
dollar += 4
stamp += 1
print(dollar)
``` | vfc_4082 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NUPNMR15/problems/NYUMTEA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nMLM\nMMLLMMLL\nMMMMMMML\n",
"output": "10\n24\n22\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1311 | Solve the following coding problem using the programming language python:
You are given two positive integers $N$ and $K$, where $K \le N$. Find a sequence $A_1, A_2, \ldots, A_N$ such that:
- for each valid $i$, $A_i$ is either $i$ or $-i$
- there are exactly $K$ values of $i$ such that $1 \le i \le N$ and $A_1 + A_2... | ```python
test=int(input())
for i in range(test):
n,k=map(int,input().split())
x=n-k
for j in range(1,n+1):
if(j%2==0 and x>0):
print(-j,end=' ')
x-=1
elif(k<=0):
print(-j,end=' ')
else:
print(j,end=' ')
k-=1
print()
``` | vfc_4086 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/POSPREFS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\n",
"output": "1 2 3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1312 | Solve the following coding problem using the programming language python:
Chef recently saw the movie Matrix. He loved the movie overall but he didn't agree with some things in it. Particularly he didn't agree with the bald boy when he declared - There is no spoon. Being a chef, he understands the importance of the sp... | ```python
import sys
spoon = [ "SPOON", "spoon" ]
def main():
try:
tc=int(input())
while tc>0:
tc=tc-1
[r,c] = input().split()
r=int(r)
c=int(c)
k=0
flag=0
matrix=[0]*r
i=0
while i<r:
matrix[i]=input()
i=i+1
#Check row wise
for m in matrix:
for s in m:
if s==... | vfc_4090 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MARCH12/problems/SPOON",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 6\nabDefb\nbSpoon\nNIKHil\n6 6\naaaaaa\nssssss\nxuisdP\noooooo\nioowoo\nbdylan\n6 5\nbdfhj\ncacac\nopqrs\nddddd\nindia\nyucky\n",
"output": "There is a spoon!\nThere is a spoon!\nThere is indeed no spoon!\n",
"type... |
apps | verifiable_code | 1313 | Solve the following coding problem using the programming language python:
The Little Elephant from the Zoo of Lviv has an array A that consists of N positive integers. Let A[i] be the i-th number in this array (i = 1, 2, ..., N).
Find the minimal number x > 1 such that x is a divisor of all integers from array A. Mor... | ```python
from math import sqrt,gcd
for _ in range(int(input())):
n=int(input())
ar=[int(x) for x in input().split()]
g=ar[0]
for i in range(1,n):
g=gcd(g,ar[i])
f=g
for i in range(2,int(sqrt(g))+1):
if g%i==0:
f=i
break
if g!=1:
print(f)... | vfc_4094 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LEDIV",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2 4 8\n3\n4 7 5\n\n\n",
"output": "2\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1314 | Solve the following coding problem using the programming language python:
Devu and Churu love to play games a lot. Today, they have an array A consisting of N positive integers. First they listed all N × (N+1) / 2 non-empty continuous subarrays of the array A on a piece of paper and then replaced all the subarrays on ... | ```python
def left_span(arr,n):
ans=[0]
span=[0]
for i in range(1,n):
while span and arr[i]>arr[span[-1]]:
span.pop()
if not span:
ans.append(0)
else:
ans.append(span[-1]+1)
span.append(i)
return ans
def right_span(arr,n):
ans=[n+1]
span=[n-1]
for i in range(n-2,-1,-1):
while spa... | vfc_4098 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DCGAME",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n1 2 3\n> 1 D\n< 2 C\n= 3 D\n> 4 C\n< 5 D\n",
"output": "DCDDC\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1315 | Solve the following coding problem using the programming language python:
-----
RANJANA QUIZ
-----
Prof. Ranjana decided to conduct a quiz in her class. She divided all the students of her
class into groups of three. Consider that no student was left out after the division. She gave
different sets of questions to eve... | ```python
n=int(input())
l=[]
count=0
while n:
n-=1
a,b,c=sorted(map(int,input().split()))
if (a,b,c) in l:
count-=1
else:
l.append((a,b,c))
count+=1
print(count)
``` | vfc_4102 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APO12020/problems/APOC2_01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n6 5 4\n2 3 7\n4 6 5\n7 2 3\n5 3 1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1316 | Solve the following coding problem using the programming language python:
You are given a weighted undirected graph consisting of n$n$ nodes and m$m$ edges. The nodes are numbered from 1$1$ to n$n$. The graph does not contain any multiple edges or self loops.
A walk W$W$ on the graph is a sequence of vertices (with re... | ```python
# cook your dish here
from collections import defaultdict
class sol():
def __init__(self,n,edges):
self.n = n
self.edges = edges
self.graph = self.create_graph()
self.precompute()
def create_graph(self):
graph = defaultdict(list)
for e in self.... | vfc_4106 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WALK4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3\n1 2 1\n2 3 2\n3 1 3\n3\n1\n2\n3\n",
"output": "2\n10\n36\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1317 | Solve the following coding problem using the programming language python:
Chef just come up with a very good idea for his business. He needs to hire two group of software engineers. Each group of engineers will work on completely different things and people from different groups don't want to disturb (and even hear) e... | ```python
import sys
def findRoom(x,y,i):
R = [(x,y)]
GRID[x][y] = i
for n in R:
GRID[n[0]][n[1]] = i
if n[0]>0 and GRID[n[0]-1][n[1]]==0 and H[n[0]-1][n[1]]:
GRID[n[0]-1][n[1]] = i
R.append((n[0]-1,n[1]))
if n[0]<N-1 and GRID[n[0]+1][n[1]]==0 and H[n[0]][n[1]]:
GRID[n[0]+1][n[1]] = i
R.append((n... | vfc_4110 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MARCH16/problems/FLOORDIS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4 5 5 3\n1 2 1 3\n1 2 2 2\n1 3 2 3\n1 4 2 4\n2 1 2 2\n1 1 30 12\n1 3 10 15\n2 3 11 22\n",
"output": "48\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1318 | Solve the following coding problem using the programming language python:
You are given an equilateral triangle ΔABC with the side BC being the base. Each side of the triangle is of length L. There are L-1 additional points on each of the sides dividing the sides into equal parts of unit lengths. Points on the sides o... | ```python
try:
for j in range(1,int(input())+1):
n,k = map(int,input().split())
if k>n:
c=0
else:
c = n-k+1
s = c*(c+1)//2
print('Case', str(j)+':',s)
except:
pass
``` | vfc_4114 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ZUBTRCNT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 3\n4 4\n",
"output": "Case 1: 3\nCase 2: 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1319 | Solve the following coding problem using the programming language python:
A despotic king decided that his kingdom needed to be rid of corruption and disparity. He called his prime minister and ordered that all corrupt citizens be put to death. Moreover, he wanted this done quickly.
The wily prime minister realised th... | ```python
n,m=map(int,input().split())
l=[]
leng=0
for i in range(n+m):
w=int(input())
if w==-1:
cm=0
mi=0
for j in range(leng):
if l[j]>cm:
cm=l[j]
mi=j
print(cm)
l[mi]=-1
else:
l.append(w)
... | vfc_4118 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/ENDCORR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 3\n1\n3\n7\n6\n-1\n5\n-1\n18\n9\n11\n2\n-1\n4\n",
"output": "7\n6\n18\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1320 | Solve the following coding problem using the programming language python:
Chef has many friends, but his best friend is Hemant. They both love to watch anime.
In fact, their weekends are meant for that only. Also, Hemant is highly into games, of which Chef is unaware. Hemant once gave a game to Chef and asked him to d... | ```python
for _ in range(int(input())):
n=int(input())
if(n<3):
print("B")
else:
if(n==3):
print("A")
elif(n%2):
print("B")
else:
print("B")
``` | vfc_4122 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENCO2020/problems/ENC2020A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n3\n7\n",
"output": "B\nA\nB\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1321 | Solve the following coding problem using the programming language python:
The chef is trying to solve some series problems, Chef wants your help to code it. Chef has one number N. Help the chef to find N'th number in the series.
0, 1, 5, 14, 30, 55 …..
-----Input:-----
- First-line will contain $T$, the number of tes... | ```python
T=int(input())
for i in range(T):
n=int(input())
if n==1:
print("0")
else:
n=n-2
l=(n+1)*(2*n+3)*(n+2)/6
print(int(l))
``` | vfc_4126 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ITGUY04",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n7\n8\n",
"output": "0\n91\n140\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1322 | Solve the following coding problem using the programming language python:
Snackdown 2019 is coming! There are two rounds (round A and round B) after the qualification round. From both of them, teams can qualify to the pre-elimination round. According to the rules, in each of these two rounds, teams are sorted in desce... | ```python
# cook your dish here
#t = int(input())
for i in range(int(input())):
n,k = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse = True)
c = 0
for i in l:
if i >= l[k-1]:
c += 1
print(c)
``` | vfc_4130 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/QUALPREL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 1\n3 5 2 4 5\n6 4\n6 5 4 3 2 1\n",
"output": "2\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1323 | Solve the following coding problem using the programming language python:
The government of Siruseri has just commissioned one of the longest and most modern railway routes in the world. This route runs the entire length of Siruseri and passes through many of the big cities and a large number of small towns and villag... | ```python
#for _ in range(int(input())):
#n,m = map(int,input().split())
#n = int(input())
#x = [int(w) for w in input().split()]
#x = [int(input()) for _ in range(n)]
#for i in range(n):
#dt = {} for i in x:dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
from bisect import bisect_le... | vfc_4134 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/DEVIOUS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n-20\n90\n-30\n-20\n80\n-70\n-60\n125\n",
"output": "-5\n6 8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1324 | Solve the following coding problem using the programming language python:
Gru wants to distribute $N$ bananas to $K$ minions on his birthday.
Gru does not like to just give everyone the same number of bananas, so instead, he wants to distribute bananas in such a way that each minion gets a $distinct$ amount of bananas... | ```python
from math import sqrt
for _ in range(int(input())):
n, k = map(int, input().split())
fact,i = [],1
while i<=sqrt(n):
if n%i==0:
if (n // i != i):
fact.append(n//i)
fact.append(i)
i+=1
tot = (k*(k+1))//2
mx = -1
for i in fact:
if i>=tot:
mx = max(mx,n//i)
print(... | vfc_4138 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GRUBAN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n6 3\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1325 | Solve the following coding problem using the programming language python:
Teacher brought a fruit basket for three students. The basket contains only Apples, Mangoes and Oranges. Student A knows a value $a$, the total number of Apples and Mangoes in the Basket, B knows a value $b$, the total number of Mangoes and Oran... | ```python
# cook your dish here
for j in range(int(input())):
p,q,r,s =map(int,input().split())
x=(s-p)
y=(s-q)
z=(s-r)
print(y,z,x)
``` | vfc_4142 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COW42020/problems/COW3A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7 9 8 12\n3 8 7 9\n",
"output": "3 4 5\n1 2 6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1326 | Solve the following coding problem using the programming language python:
There are $N$ cars (numbered $1$ through $N$) on a circular track with length $N$. For each $i$ ($2 \le i \le N$), the $i$-th of them is at a distance $i-1$ clockwise from car $1$, i.e. car $1$ needs to travel a distance $i-1$ clockwise to reach... | ```python
for _ in range(int(input())):
n=int(input())
f=list(map(int,input().split()))
sum1=f[0]
d=0
i=1
while sum1!=0 and i<n:
sum1=sum1-1+f[i]
d+=1
i+=1
print(d+sum1)
``` | vfc_4146 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BEGGASOL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5\n3 0 0 0 0\n5\n1 1 1 1 1\n5\n5 4 3 2 1\n",
"output": "3\n5\n15\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1327 | Solve the following coding problem using the programming language python:
Firdavs is living on planet F. There are $N$ cities (numbered $1$ through $N$) on this planet; let's denote the value of city $i$ by $v_i$. Firdavs can travel directly from each city to any other city. When he travels directly from city $x$ to c... | ```python
# cook your dish here
import bisect
for _ in range(int(input())):
N,Q=list(map(int,input().strip().split(' ')))
V=list(map(int,input().strip().split(' ')))
VV=sorted(V)
for ___ in range(Q):
x,y=list(map(int,input().strip().split(' ')))
x-=1
y-=1
ans1=abs(V[x]-V[y])+(y-x)
post1=bisect.bisect_left... | vfc_4150 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FAPF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 2\n4 2 5 7\n2 3\n3 4\n2 1\n1 1\n2 1\n",
"output": "4 3\n3 2\n-1 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1328 | Solve the following coding problem using the programming language python:
Chef loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Chef has a positive intege... | ```python
# cook your dish here
for _ in range(0,int(input())):
n=input().strip()
x=n.count('4')
y=n.count('7')
print(len(n)-x-y)
``` | vfc_4154 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LUCKY5",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n25\n46\n99\n\n\n",
"output": "2\n1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1329 | Solve the following coding problem using the programming language python:
Sometimes Sergey visits fast food restaurants. Today he is going to visit the one called PizzaKing.
Sergey wants to buy N meals, which he had enumerated by integers from 1 to N. He knows that the meal i costs Ci rubles. He also knows that there ... | ```python
T = int(input())
for t in range(T):
n, m = list(map(int, input().split()))
c = list(map(int, input().split()))
dp1 = [1e9]*((1 << n)+1)
for i in range(n):
dp1[1 << i] = c[i]
dp1[1 << (n-1)] = min(dp1[1 << (n-1)], sum(c))
for i in range(m):
l = list(map(int, input().split()))
cost = l[0]
s =... | vfc_4158 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FFCOMB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\n3 5 6\n11 3 1 2 3\n5 2 1 2\n5 2 1 3\n",
"output": "10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1330 | Solve the following coding problem using the programming language python:
The country of Siruseri has A∗B$A*B$ districts. You want to create A$A$ states from these districts, such that each state has exactly B$B$ districts, and each district is part of exactly one state. You don't care about the geographical location ... | ```python
# cook your dish here
for _ in range(int(input())):
A,B=list(map(int,input().split()))
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
for i in range(A*B):
if l1[i]<l2[i]:
l1[i]=0
else:
l2[i]=0
l1.sort(reverse=True)
l2.sort(reverse=True)
... | vfc_4162 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SIRUSERI",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3\n4 2 9\n5 6 7\n1 3\n4 2 9\n5 10 7\n3 3\n7 14 11 4 15 5 20 1 17\n2 13 16 9 19 6 12 8 10\n",
"output": "1\n0\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1331 | Solve the following coding problem using the programming language python:
Chef loves to play games. Now he plays very interesting game called "Segment". At the beginning Chef has segment [0, X] and no points on it. On each step Chef chooses the subsegment of maximal length possible such as it contains no points on it.... | ```python
t = int(input())
from math import log, ceil, floor
while t:
t-=1
n,k = map(int ,input().split())
v = floor(log(k, 2))
block = 1 << v + 1
print(n / block * (1 + (k - 2 ** v) * 2 ))
``` | vfc_4166 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFSEG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n10 1\n10 2\n10 3\n1000000000 1234567\n",
"output": "5.0000\n2.5000\n7.5000\n177375316.6198730500000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1332 | Solve the following coding problem using the programming language python:
Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2*v and its right child will be labelled 2*v+1. The root is labelled as 1.
You are... | ```python
t=eval(input())
for _ in range(t):
i,j=list(map(int,input().split()))
bi=bin(i)[2:]
bj=bin(j)[2:]
k=0
while k<(min(len(bi),len(bj))):
if bi[k]!=bj[k]:
break
else:
k+=1
print(len(bi)-k+len(bj)-k)
``` | vfc_4170 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APRIL14/problems/BINTREE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2\n2 3\n4 3\n",
"output": "1\n2\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1333 | Solve the following coding problem using the programming language python:
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence ― what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose ... | ```python
mod=10**9+7
def pow2(x):
p,n=1,2
while(x):
if(x & 1): p=((p%mod) * (n%mod))%mod
n=((n%mod) * (n%mod))%mod
x//=2
return p
def count_bit(val):
bit=0
while(val):
bit+=1
val &=(val-1)
return bit
def answer():
val=b[0]
po2=0
for i in range(1,len(b)):
if(val > b[i]):return 0
po2+=coun... | vfc_4174 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MYSARA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n2 3\n4\n2 6 7 7\n",
"output": "2\n64\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1334 | Solve the following coding problem using the programming language python:
Zonal Computing Olympiad 2014, 30 Nov 2013
In ICO School, all students have to participate regularly in SUPW. There is a different SUPW activity each day, and each activity has its own duration. The SUPW schedule for the next term has been an... | ```python
import math
n = int(input())
a=list(map(int,input().split()))
dp = [0 for x in range(n)]
dp[0] = a[0]
dp[1] = a[1]
dp[2] = a[2]
for x in range(3,n):
dp[x] = a[x] + min(dp[x-1],dp[x-2],dp[x-3])
print(min(dp[-3:]))
``` | vfc_4178 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO14002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n3 2 1 1 2 3 1 3 2 1\n",
"output": "4\n(\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1335 | Solve the following coding problem using the programming language python:
Dinesh is very fond of sweets recently his aunt Riya gifted him an array $a$ of sweets of size $N$. The ith sweet is of the type $a[i]$. His mother told him that he can choose one type of sweet in a day and eat at most 2 sweets of that type. Sin... | ```python
# cook your dish here
n=int(input())
lst=list(map(int,input().split()))
dict1={}.fromkeys(lst,0)
for key in lst:
dict1[key]+=1
sum1=0
for key in dict1:
sum1+=dict1[key]//2
if(dict1[key]%2==1):
sum1+=1
print(sum1)
``` | vfc_4182 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/POPU2021/problems/POPPUSH1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 2\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1336 | Solve the following coding problem using the programming language python:
A printer – who still uses moveable type – is preparing to print a set of pages for a book. These pages are to be numbered, as usual. The printer needs to know how many instances of each decimal digit will be required to set up the page numbers ... | ```python
line = input()
test = 0
while line != "0":
test += 1
d = {'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,'7':0,'8':0,'9':0}
a = list(map(int,line.split()))
for i in range(min(a),max(a)+1):
for c in str(i):
d[c] += 1
pairs = list(d.items())
pairs.sort()
print... | vfc_4186 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PRFT2012/problems/PD21",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10 15\n912 912\n900 999\n0\n\n\n",
"output": "Case 1: 0:1 1:7 2:1 3:1 4:1 5:1 6:0 7:0 8:0 9:0\nCase 2: 0:0 1:1 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:1\nCase 3: 0:20 1:20 2:20 3:20 4:20 5:20 6:20 7:20 8:20 9:120\n",
"type": "std... |
apps | verifiable_code | 1337 | Solve the following coding problem using the programming language python:
The $String$ Family gave birth to a new $Tripartite$ $trio$ $sisters$ and named them $Hema$, $Rekha$ and $Sushma$. Hema and Rekha are very fond of parties whereas Sushma hates them. One day Hema and Rekha asked their parents to buy them candies ... | ```python
from math import gcd
def compute_lcm(x, y):
lcm = (x*y)//gcd(x,y)
return lcm
def LCMofArray(a):
lcm = a[0]
for i in range(1,len(a)):
lcm = lcm*a[i]//gcd(lcm, a[i])
return lcm
for _ in range(int(input())):
lens = int(input())
arrs = [int(x) for x in input().sp... | vfc_4190 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMX2020/problems/CMX1P02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2\n2 3\n1\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1338 | Solve the following coding problem using the programming language python:
-----General Statement:-----
Read a number in scientific notation and output its equivalent decimal value.
-----Input:-----
All data is on a single line. The first integer indicates how many pairs of numbers follow. The first of each pair is A,... | ```python
#In the Name of God
import math
x = input().split()
n = int(x[0])
arr = []
i = 1
while(i<len(x)):
arr.append(float(x[i]))
i += 1
arr.append(int(x[i]))
i += 1
i = 0
ans = []
while(i<len(arr)):
x = arr[i]
i += 1
y = arr[i]
y = 10**y
i += 1
ans.append(x*y)
for i in range(len(ans... | vfc_4194 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QTCC2020/problems/VIEW2004",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4.296 3 3.8 -2 1.8 2 2.8678 1\n",
"output": "4296.00\n0.04\n180.00\n28.68\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1339 | Solve the following coding problem using the programming language python:
Vasya learned about integer subtraction in school. He is still not very good at it, so he is only able to subtract any single digit number from any other number (which is not necessarily single digit).
For practice, Vasya chose a positive intege... | ```python
# cook your dish here
def getAns(num):
if num<10:return 2
last=int(str(num)[0]);rem=int(str(num)[1:]);steps=2;p=len(str(num))-1
while True:
steps+=rem//last+1;rem=rem%last
if last>0:rem=rem+10**p-last
last=last-1
if last==0:
p=p-1;last=9
if(len(str(rem))==1):rem=0... | vfc_4198 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUBLD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n100\n",
"output": "9\n10\n170\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1340 | Solve the following coding problem using the programming language python:
You are given a sequence $A_1, A_2, \ldots, A_N$. You should select a (not necessarily contiguous) subsequence of $A$ and reverse it. In other words, if you select a subsequence $A_{i_1}, A_{i_2}, \ldots, A_{i_K}$ ($1 \le i_1 < \ldots < i_K \le ... | ```python
for _ in range(int(input())):
n = int(input())
a = list(map(int,input().split()))
ans = 0
count = 0
for i in a:
if i>0:
ans+=i
count+=1
res = []
for i in range(count):
if a[i]<=0:
res.append(i+1)
for i in range(count,n):
if a[i]>0:
res.append(i+1)
print(ans)
print(len(res),*res)
``... | vfc_4202 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MVAL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n-4 2 -4 3 -5\n3\n-3 -2 -1\n",
"output": "5\n2 2 3\n0\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1341 | Solve the following coding problem using the programming language python:
You are given a sequence $A_1, A_2, \ldots, A_N$. Calculate the number of ways to remove a non-empty contiguous subsequence from it such that the resulting sequence is non-empty and strictly increasing.
-----Input-----
- The first line of the i... | ```python
import bisect
def pre(a):
for p in range(n-1):
if(a[p]>=a[p+1]):
return p
return n-1
def suf(a):
for s in range(1,n):
if(a[n-s]<=a[n-s-1]):
return n-s
return 0
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
p=pre(a)
s=suf(a)
b=a[s:n]
count=0
... | vfc_4206 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DELARRAY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 1 2\n4\n2 4 3 5\n",
"output": "4\n7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1342 | Solve the following coding problem using the programming language python:
Chef is multi-talented. He has developed a cure for coronavirus called COVAC-19. Now that everyone in the world is infected, it is time to distribute it throughout the world efficiently to wipe out coronavirus from the Earth. Chef just cooks the... | ```python
import math
for i in range(int(input())):
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
l.sort()
flag=0
d=0
for j in range(n):
if l[j]>x:
for k in range(j,n):
if x<l[k]:
d+=(math.ceil(math.log(l[k]/x)/math.log(2))+1)
else:
d+=1
... | vfc_4210 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DRCHEF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 5\n1 2 3 4 5\n5 1\n40 30 20 10 50\n3 10\n20 1 110\n",
"output": "5\n9\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1343 | Solve the following coding problem using the programming language python:
One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.
A dish Si is called special if it's name (i.e. the string Si) can be represe... | ```python
# cook your dish here
def check_equal(a,b):
index=0
for i in a:
while index<len(b) and i != b[index]:
index+=1
if(index>=len(b)):
return False
index+=1
return True
def Dob_String(n):
size=len(n)
midpoint=size//2
if(check_equal(n[0:midpoint],n[midpoint:size])):
return("YES")
elif(size%2!=... | vfc_4214 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFSPL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\naba\nabac\nabcd\n",
"output": "YES\nNO\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1344 | Solve the following coding problem using the programming language python:
You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N.
-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases fol... | ```python
# cook your dish here
def __starting_point():
try:
for _ in range (int(input())):
element = int(input())
l = list(map(int,input().split()))
a=min(l)
l.remove(a)
b=min(l)
print(a+b)
except EOFError :
print('EOFError')
__starting_point()
``` | vfc_4218 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SMPAIR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n5 1 3 4\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1345 | Solve the following coding problem using the programming language python:
At the legendary times of Nonsenso wars in ISM Dhanbad, there was a neck to neck competition between Barney Stinson and Sheldon Cooper. They both were on level 19. After trying too hard both of them could not decipher the nonsense, so they decid... | ```python
for _ in range(int(input())):
code=input().strip()+'0'
message=''
asc=int(code[0])
for i in range(len(code)-1):
if int(str(asc)+code[i+1])>256:
message+=chr(asc)
asc=int(code[i+1])
else:
asc=int(str(asc)+code[i+1])
print(message)
``` | vfc_4222 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDSC2012/problems/CDS003",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n721011081081113287111114108100\n871011089911110910132116111327311010010597\n",
"output": "Hello World\nWelcome to India\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1346 | Solve the following coding problem using the programming language python:
VK gave a problem to Chef, but Chef is too lazy, so he asked you to solve the problem for him. The statement of the problem follows.
Consider an integer with $N$ digits (in decimal notation, without leading zeroes) $D_1, D_2, D_3, \dots, D_N$. H... | ```python
for _ in range(int(input())):
n,w = map(int , input().split())
sigma = 1
#len(str(num)) == n and D[i] - D[i - 1] ... = w
if(w > 9 or w < -9):
print(0)
continue
sigma = pow(10,n - 2,1000000007)
if(w >= 0):
sigma *= (9 - w)
else:
sigma *= (w + 10)
print(sigma % 1000000007)
``` | vfc_4226 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WGHTNUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1347 | Solve the following coding problem using the programming language python:
Chef Watson uses a social network called ChefBook, which has a new feed consisting of posts by his friends. Each post can be characterized by f - the identifier of the friend who created the post, p - the popularity of the post(which is pre-calc... | ```python
import sys
ans=0
n,m=list(map(int,input().split()))
aaaaa=100
li=list(map(int,input().split()))
non_special,special=[],[]
for i in range(m):
ans+=1
f,p,s=list(map(str,input().split()))
f=int(f)
poww=pow(1,2)
p=int(p)
if f not in li:
ans+=1
non_special.append((p,s))
ans-=1
else:
ans+=1
special... | vfc_4230 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK75/problems/BOOKCHEF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\n1 2\n1 1 WhoDoesntLoveChefBook\n2 2 WinterIsComing\n3 10 TheseViolentDelightsHaveViolentEnds\n4 3 ComeAtTheKingBestNotMiss\n",
"output": "WinterIsComing\nWhoDoesntLoveChefBook\nTheseViolentDelightsHaveViolentEnds\nComeAt... |
apps | verifiable_code | 1348 | Solve the following coding problem using the programming language python:
There are a lot of problems related to the shortest paths. Nevertheless, there are not much problems, related to the shortest paths in average.
Consider a directed graph G, consisting of N nodes and M edges. Consider a walk from the node A to th... | ```python
from collections import defaultdict
import copy
#def dfs(l,r,dct):
def dfs(l,r,dct):
visit=[0 for i in range(n+1)]
arr=[l]
while(arr):
node=arr.pop()
if node==r:return True
visit[node]=1
for lnk in dct[node]:
if not visit[lnk]:
arr.append(lnk)
return False
def ok(mid,cst):
for i,j in edg... | vfc_4234 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AVGSHORT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n1 2 1\n2 3 2\n3 2 3\n1 3\n3 3\n1 2 10\n2 3 1\n3 2 1\n1 3\n",
"output": "1.5\n1.0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1349 | 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 3. If any of the permutations is divisible by 3 then print 1 else print 0.
-----Input:-----
- First-line will contain $T$, the number of ... | ```python
from sys import *
input=stdin.readline
for u in range(int(input())):
s=int(input())
if(s%3==0):
print(1)
else:
print(0)
``` | vfc_4238 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY34",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n18\n308\n",
"output": "1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1350 | Solve the following coding problem using the programming language python:
Chef's love for Fibonacci numbers helps him to design following interesting problem.
He defines a function F for an array S as follows:
where
- Si denotes a non-empty subset of multiset S.
- sum(Si) denotes the sum of all element of multiset Si... | ```python
m= 1000000007
def mul(a,b):
return [(a[0]*b[0]+a[1]*b[2])%m,
(a[0]*b[1]+a[1]*b[3])%m,
(a[2]*b[0]+a[3]*b[2])%m,
(a[2]*b[1]+a[3]*b[3])%m]
def f(n):
if n==0:
return 0
v1, v2, v3 = 1, 1, 0
for rec in bin(n)[3:]:
v2=v2%m
v1=v1%m
v3=v3%m
calc = (v2*v2)
v1, v2, v3 = (v1*v1+calc), ((v1+v3)*... | vfc_4242 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APRIL16/problems/FIBQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 5\n1 2 3\nQ 1 2\nQ 2 3\nC 1 2\nQ 1 2\nQ 1 3\n",
"output": "4\n8\n5\n30\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1351 | Solve the following coding problem using the programming language python:
The chef is having one array of N natural numbers(numbers may be repeated). i.e. All natural numbers must be less than N. Chef wants to rearrange the array and try to place a natural number on its index of the array, i.e array[i]=i. If multiple ... | ```python
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
d=set()
for i in arr:
d.add(i)
for i in range(n):
if i in d:
print(i,end=" ")
else:
print(0,end=" ")
print()
``` | vfc_4246 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK12020/problems/ITGUY14",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n1 1\n4\n1 1 2 1\n",
"output": "0 1\n0 1 2 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1352 | Solve the following coding problem using the programming language python:
Chef is very organised in whatever he does and likes to maintain statistics of his work. Chef has expertise in web development and hence is a regular contributor on a forum. Chef sometimes makes multiple contributions in a single day.. Each day ... | ```python
from collections import Counter
t=int(input())
for i in range(t):
k=int(input())
l=list(map(int,input().split()))
a=Counter(l)
b=list(a.keys())
b.sort()
for x in b:
s=str(x)+': '+str(a[x])
print(s)
``` | vfc_4250 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/GSTS1601/problems/BUG2K16B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n20 6 5 3 3 1 1\n",
"output": "1: 2\n3: 2\n5: 1\n6: 1\n20: 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1353 | Solve the following coding problem using the programming language python:
You are in the future. It's the time of autonomous cars. Switching lanes is a pretty difficult task for autonomous cars, and you have the logs from an experiment you had run with two cars. You want to verify whether the logs are corrupted, or co... | ```python
# cook your dish here
def check(px,x):
if px[1]==x[1]:
return (x[2]-px[2])<=(x[0]-px[0]) and (x[2]>=px[2])
else:
return (x[2]-px[2]+1)<=(x[0]-px[0]) and (x[2]>=px[2])
def checkdouble(px,x):
if px[3]==x[3]:
return (x[4]-px[4])<=(x[0]-px[0]) and (x[4]>=px[4])
else:
return (x[4]-px[4]+1)<=(x[0]-px... | vfc_4254 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AUTOCARS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 1 1 2 2\n2 2 1 2 2\n4 2 2 2 3\n1\n1 1 3 2 2\n",
"output": "yes\nno\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1354 | Solve the following coding problem using the programming language python:
You have a tree consisting of n vertices. You want to color each vertex of the tree in one of the k colors such that for any pair of vertices having same color, all the vertices belonging to the path joining them should also have same color. In ... | ```python
A = [0] * 100001
M = 1000000007
def nCk(n, k):
if k ==0 or k ==n:
return 1
r = (A[n-k]*A[k])%M
x = (A[n]*pow(r, M-2, M))%M
return x
for _ in range(int(input())):
n, k = list(map(int, input().split()))
for i in range(n-1):
u,v = input().split()
summ = 0
A[0] = 1
for i in range(1, len(A)):
A[i]... | vfc_4258 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SNCKEL16/problems/COLTREE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 2\n1 2\n2 3\n3 1\n1 2\n2 3\n4 3\n1 2\n2 3\n2 4\n",
"output": "6\n1\n39\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1355 | Solve the following coding problem using the programming language python:
Chef likes to play with array elements. His teacher has given him an array problem. But now he is busy as Christmas is coming. So, he needs your help. Can you help him to solve this problem.
You are given an array $(A1,A2,A3……AN)$ of length $N$.... | ```python
# cook your dish here
def index(n,val):
while(val >= n):
val = val//2
return n - val
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
new = [0 for i in range(n)]
for i in range(n):
if arr[i]<=n :
new[i] = arr[i] + ar... | vfc_4262 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NOOB2020/problems/NBC006",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n2 4 5 7 9\n4\n5 4 2 3\n",
"output": "6 11 14 4 2\n4 7 6 5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1356 | Solve the following coding problem using the programming language python:
Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once.
He serves them in the form of a stack.
A pancake can be treated as a circular disk with some radius.
Chef needs to take care that when he places a pancake o... | ```python
t=[[1]]
def bell_numbers(start, stop):
## Swap start and stop if start > stop
if stop < start: start, stop = stop, start
if start < 1: start = 1
if stop < 1: stop = 1
c = 1 ## Bell numbers count
while c <= stop:
if c >= start:
yield t[-1][0] ## Yield the Bell number of the previous ... | vfc_4266 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APRIL12/problems/PANSTACK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1357 | Solve the following coding problem using the programming language python:
Chef owns an icecream shop in Chefland named scoORZ. There are only three types of coins in Chefland: Rs. 5, Rs. 10 and Rs. 15. An icecream costs Rs. 5.
There are $N$ people (numbered $1$ through $N$) standing in a queue to buy icecream from sco... | ```python
# cook your dish here
for _ in range(int(input())):
n=int(input())
lst=list(map(int,input().split()))
f=0
t=0
p=1
for i in lst:
if(i==5):
f+=1
elif(i==10):
if(f>0):
f-=1
t+=1
else:
p=0
... | vfc_4270 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHFICRM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n5 10\n2\n10 5\n2\n5 15\n\n",
"output": "YES\nNO\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1358 | Solve the following coding problem using the programming language python:
Chef Al Gorithm was reading a book about climate and oceans when he encountered the word “glaciological”. He thought it was quite curious, because it has the following interesting property: For every two letters in the word, if the first appears... | ```python
# cook your dish here
import bisect
for _ in range(int(input())):
w,k=map(str, input().split())
k=int(k)
n=len(w)
w=list(w)
w.sort()
w.append('0')
c=1
l=0
l1=[]
l2=[]
for i in range(1, n+1):
if w[i]==w[i-1]:
c+=1
else:
a=bisect.bisect_left(l1, c)
if a==l:
l1.append(c)
l2.appen... | vfc_4274 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/KGOOD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nglaciological 1\nteammate 0\npossessions 3\ndefenselessness 3\n",
"output": "0\n0\n1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1359 | Solve the following coding problem using the programming language python:
There is a task in Among Us in which $N$ temperature scale with unique readings are given and you have to make all of them equal. In one second you can choose an odd number and add or subtract that number in any one temperature value. Find minim... | ```python
# cook your dish here
for _ in range(int(input())):
n=int(input())
ar=list(map(int,input().split()))
odd=0
even=0
if n==1:
print(0)
continue
for i in range(n):
if ar[i]%2==1:
odd+=1
else:
even+=1
if odd>0:
vo=(odd-1)*2+even
else:
vo=even
if even>0:
ve=(even-1)*2+odd
else:
ve=od... | vfc_4278 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/RC152020/problems/REC15A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5\n1 2 3 4 5\n4\n5 2 3 8\n2\n50 53\n",
"output": "5\n4\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1360 | Solve the following coding problem using the programming language python:
Watson gives to Sherlock two strings S1 and S2 consisting of uppercase English alphabets. Next he wants Sherlock to build a flower in the following way:
He puts both strings perpendicular to each other in such a way that they overlap at the sam... | ```python
for _ in range(eval(input())):
S1=input()
m1=len(S1)/2
S2=input()
m2=len(S2)/2
d1={}
d2={}
for i in range(len(S1)):
c=S1[i]
v=abs(m1-i)
if c in d1:
if v<d1[c][0]:
d1[c]=[v,i]
else:
d1[c]=[v,i]
for i in ran... | vfc_4282 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK75/problems/UGLYF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nABCDE\nXXBCZQ\nBBB\nBBBBBB\n\n\n",
"output": "2\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1361 | Solve the following coding problem using the programming language python:
Vision has finally made it to Wakanda to get his MindStone extracted. The MindStone was linked to his brain in a highly sophisticated manner and Shuri had to solve a complex problem to extract the stone. The MindStone had $n$ integers inscribed ... | ```python
# cook your dish here
from itertools import accumulate
n, k = map(int, input().split())
lst = list(map(int, input().split()))
temp = (10**9)+7
for i in range(k):
lst = list(accumulate(lst))
for i in lst:
print(i%(temp), end = ' ')
``` | vfc_4286 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COSQ2020/problems/VISIONMS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\n3 4 1 5\n",
"output": "3 10 18 31\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1362 | Solve the following coding problem using the programming language python:
You are given a sequence of integers $A_1, A_2, \dots, A_N$.
You should choose an arbitrary (possibly empty) subsequence of $A$ and multiply each element of this subsequence by $-1$. The resulting sequence should satisfy the following condition:... | ```python
"""
4
4
4 3 1 2
6
1 2 2 1 3 1
5
10 1 2 10 5
4
1 2 1 2
"""
tests = int(input())
for _ in range(tests):
n = int(input())
ls = list(map(int, input().split()))
if ls[0] < ls[1]:
ls[0] = -ls[0]
if ls[-1] < ls[-2]:
ls[-1] = -ls[-1]
for i in range(1, n - 1):
if ls[i] < ls[i - 1] and ls[i] < ls[i + 1]... | vfc_4290 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHSIGN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n4 3 1 2\n6\n1 2 2 1 3 1\n5\n10 1 2 10 5\n4\n1 2 1 2\n",
"output": "4 3 -1 2\n-1 2 2 -1 3 -1\n10 -1 2 10 -5\n1 2 -1 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1363 | Solve the following coding problem using the programming language python:
A squarer is a simple and convenient device. You give it some positive integer X and it calculates its square.
Leha is implementing a module of this device which is responsible for squaring the numbers consisting of multiple repetitions of one d... | ```python
val = 10**9 + 7
def MOD(a,b):
aans = a
ans = 1
while b>0:
ans = (ans*aans)%val
aans = (aans*aans)%val
b/=2
return ans%val
for i in range(eval(input())):
n,d= list(map(int,input().split()))
a=int(str(d)*n)
sqr = str(a*a)
ans =0
count=0
for ii in sqr :
ans= ans+int(ii)*23**count
coun... | vfc_4294 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LTIME29/problems/FSTSQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 4\n3 6\n3 5\n",
"output": "139\n40079781\n32745632\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1364 | Solve the following coding problem using the programming language python:
Chef has $N$ points (numbered $1$ through $N$) in a 2D Cartesian coordinate system. For each valid $i$, the $i$-th point is $(x_i, y_i)$. He also has a fixed integer $c$ and he may perform operations of the following type: choose a point $(x_i, ... | ```python
t = int(input())
for i in range(t):
n, c = list(map(int,input().split()))
pts = {}
moves = 0
for i in range(n):
x, y = list(map(int,input().split()))
if (y-x,x%c) in pts:
pts[(y-x,x%c)].append(x)
else:
pts[(y-x,x%c)] = [x]
for i in pts:
arc = sorted(pts[i])
for j in arc:
moves ... | vfc_4298 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHKPTS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 1\n1 1\n1 0\n3 2\n",
"output": "2 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1365 | Solve the following coding problem using the programming language python:
There exist certain strings, known as $Unique$ $Strings$. They possess a unique property:
- The character 'c' gets converted to "ff" and the character 'k' gets converted to "gg". Any letter besides 'c' and 'k' does not get converted to any othe... | ```python
tb=str(input())
tb=list(tb)
if("c" in tb or "k" in tb):
print(0)
else:
ans=1
i=0
while(i<len(tb)):
if(tb[i]=="g" or tb[i]=="f"):
my=tb[i]
i+=1
ct=1
while(i<len(tb) and tb[i]==my):
ct+=1
i+=1
if(ct>3):
ct+=1
ans*=ct
else:
i+=1
print(ans)
``` | vfc_4302 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COTH2020/problems/UNIQSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "thing\nSample Input 2:\nggdffn\nSample Input 3:\nfff\nSample Input 4:\ncat\n",
"output": "1\nSample Output 2:\n4\nSample Output 3:\n3\nSample Output 4:\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1366 | Solve the following coding problem using the programming language python:
Master Shifu is training Po to become The Dragon Warrior and as a final assignment he must obtain maximum deliciousness from dumplings. There are $N$ plates of dumplings in front of him with deliciousness $A_1, A_2, \ldots, A_N$, Po can choose ... | ```python
# cook your dish here
N=int(input())
for _ in range(N):
n=int(input())
arr=list(map(int,input().split()))[:n]
count=0
last=0
for i in range(n):
if(arr[i]!=0):
break
last=i
count+=1
for i in arr[-1:last:-1]:
if(i!=0):
break
... | vfc_4306 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALRA2020/problems/ALR20A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 2 3 4\n5\n3 2 0 3 0\n",
"output": "4\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1367 | Solve the following coding problem using the programming language python:
Sebi lives in Chefland where the government is extremely corrupt that usually makes fool out of public by announcing eye catching but non-sustainable schemes. Recently there was a move to increase tourism in the country that was highly lauded. S... | ```python
from sys import stdin,stdout
total_cost=0
def find(a):
if par[a]==a:
return a
else:
par[a]=find(par[a])
return par[a]
def union(a,b,c):
a,b=find(a),find(b)
nonlocal total_cost
total_cost+=(rank[a]*rank[b]*c)
if a!=b:
if rank[a]>rank[b]:
par[b]=a
rank[a]+=rank[b]
elif rank[b]>rank[a]:... | vfc_4310 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SETELE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 3\n1 3 2\n",
"output": "2.333333\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1368 | Solve the following coding problem using the programming language python:
The students of Codechef Middle School are visiting an amusement park. The children want to go on a ride, however, there is a minimum height requirement of $X$ cm. Determine if the children are eligible to go on the ride.
Print "Yes" if they ar... | ```python
# cook your dish here
for _ in range(int(input())):
h,x=map(int,input().split())
if(h>=x):
print("Yes")
else:
print("No")
``` | vfc_4314 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENNO2020/problems/ECNOV09",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n120 100\n90 100\n",
"output": "Yes\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1369 | Solve the following coding problem using the programming language python:
Chef Vivek is good in mathematics and likes solving problems on prime numbers. One day his friend Jatin told him about Victory numbers. Victory number can be defined as a number formed after summing up all the prime numbers till given number n. ... | ```python
from math import sqrt
test = int(input())
for i in range(test):
sum = 0
max = int(input())
if max==1:
sum = 0
elif max==2:
sum += 2
else:
sum = sum + 2
for x in range(3,max+1):
half = int(sqrt(x)) + 1
if all(x%y!=0 for y in range(2,half)):
sum = sum + x
print(sum)
``` | vfc_4318 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BGS12020/problems/BSP1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n22\n13\n10\n",
"output": "77\n41\n17\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1370 | Solve the following coding problem using the programming language python:
You were strolling outside the restaurant at the end of the universe. On a metaspiral path you stumble upon a weird device which takes a three-digit number as input and processes it. The Hitchhiker's guide to the galaxy explains that it processe... | ```python
for _ in range(int(input())):
k, n = input().split()
while int(n) >= 5:
print(len(set(k)) ** 3)
break
``` | vfc_4322 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ICL1901",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n123 5\n",
"output": "27\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1371 | Solve the following coding problem using the programming language python:
Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him away from the limelight, he has built a transmogrifier — a machine which m... | ```python
for i in range(int(input())):
yy=input()
y=[int(e) for e in yy.split()]
zz=input()
z=[int(e) for e in zz.split()]
count=0
for i in z:
a=i+y[1]
if a%7==0:
count+=1
print(count)
``` | vfc_4326 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHN15A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 10\n2 4 1 35 1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1372 | Solve the following coding problem using the programming language python:
The Jones Trucking Company tracks the location of each of its trucks on a grid similar to an (x, y) plane. The home office is at the location (0, 0). Read the coordinates of truck A and the coordinates of truck B and determine which is closer to... | ```python
# cook your dish here
try:
t = int(input())
for i in range(t):
ar=list(map(int,input().split()))
if (ar[0]**2 + ar[1]**2 > ar[2]**2 + ar[3]**2):
print("B IS CLOSER")
else:
print("A IS CLOSER")
except:
pass
``` | vfc_4330 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QTCC2020/problems/VIEW2002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 -2 -5 -3\n0 6 1 2\n-7 8 4 -1\n3 3 -2 2\n",
"output": "A IS CLOSER\nB IS CLOSER\nB IS CLOSER\nB IS CLOSER\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1373 | Solve the following coding problem using the programming language python:
Chef made $N$ pieces of cakes, numbered them $1$ through $N$ and arranged them in a row in this order. There are $K$ possible types of flavours (numbered $1$ through $K$); for each valid $i$, the $i$-th piece of cake has a flavour $A_i$.
Chef wa... | ```python
def main():
t= int(input())
while(t!=0):
n,k = list(map(int , input().split()))
arr = list(map(int, input().split()))
freq = [0]*100001
k=k-1
st=0
end=0
currentCount=0
previousElement = 0
for i in range(n):
freq[arr[i]]+=1
if(freq[arr[i]]==1):
currentCount+=1
while(currentCou... | vfc_4334 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/NOTALLFL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 2\n1 1 1 2 2 1\n5 3\n1 1 2 2 1\n",
"output": "3\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1374 | Solve the following coding problem using the programming language python:
Chef Hari has got a new obsession now: he has started playing chess (read about it here) and he is liking this game very much. Since Hari has spent several months playing chess with his friends, he has now decided to take part in some chess tour... | ```python
t=eval(input())
while t>0:
t=t-1
f1,f2,r1,r2,r3,r4=list(map(int,input().split()))
p1,p2,p3,p4=list(map(float,input().split()))
s1=(1-p1)*(-f1)+(r2-f1)*(1-p2)*p1+p1*p2*(r1-f1)
s2=(1-p3)*(-f2)+(r3-f2)*(p3)*(1-p4)+p3*p4*(r3+r4-f2)
if s1>s2:
print('FIRST')
elif s1<s2:
print('SECOND')
else:... | vfc_4338 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCAUG16/problems/CHEFCHSS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n30 50 70 10 40 30\n0.25 0.10 0.30 0.05\n50 36 80 38 65 32\n0.55 0.12 0.33 0.54\n",
"output": "FIRST\nSECOND\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1375 | Solve the following coding problem using the programming language python:
-----Problem description.-----
This problem deals with the I/O methods used in codechef.
You are supposed to print the integer in its reverse form , or in simple words, print the reverse of the given integer . For instance , reverse of 120 is ... | ```python
t = int(input())
while t > 0:
s = int(input())
while s % 10 == 0 :
s /= 10
print(''.join(reversed(str(s))))
t = t - 1
``` | vfc_4342 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SRMC2016/problems/INTROSRM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1234\n4567\n1\n",
"output": "4321\n7654\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1376 | Solve the following coding problem using the programming language python:
Salmon loves to be a tidy person. One day, when he looked at the mess that he made after playing with his rubber ducks, he felt awful. Now he wants to clean up his mess, by placing his ducks into boxes.
Each rubber duck has a color. There are a ... | ```python
# cook your dish here
for _ in range(int(input())):
n,k=map(int,input().split())
c=[int(i) for i in input().split()]
i=0
m=0
if(n==2 and k==5):
c1=c
c.sort()
d=dict()
for i in range(len(c)):
for j in range(len(c1)):
if(c[i]==c1[j]):
d[i]=j
c1[j]=-1
break
while(m<n):
... | vfc_4346 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/UWCOI21/problems/UWCOI21C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 4\n3 4 1\n",
"output": "2 1 1 3\n1 1 0 3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1377 | Solve the following coding problem using the programming language python:
-----General Statement:-----
Given the actual high and low temperatures for the day and the normal high and low temperatures for that day, calculate the average difference from normal.
-----Input:-----
The first line of the data set for this pr... | ```python
# cook your dish here
for _ in range (int(input())):
x1,y1,x2,y2=map(int,input().split())
av1=(x1+y1)/2
av2=(x2+y2)/2
if(av1>av2):
print(av1-av2," DEGREE(S) ABOVE NORMAL")
else:
print(av2-av1," DEGREE(S) BELOW NORMAL")
``` | vfc_4350 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QTCC2020/problems/VIEW2005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n75 45 78 40\n50 32 45 30\n56 48 62 45\n",
"output": "1.0 DEGREE(S) ABOVE NORMAL\n3.5 DEGREE(S) ABOVE NORMAL\n1.5 DEGREE(S) BELOW NORMAL\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1378 | Solve the following coding problem using the programming language python:
There are K nuclear reactor chambers labelled from 0 to K-1. Particles are bombarded onto chamber 0. The particles keep collecting in the chamber 0. However if at any time, there are more than N particles in a chamber, a reaction will cause 1 pa... | ```python
a,n,k = map(int,input().split())
for i in range(k):
print(a%(n+1),end=' ')
a=a//(n+1)
``` | vfc_4354 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/NUKES",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 1 3\n",
"output": "1 1 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1379 | Solve the following coding problem using the programming language python:
A simple string contains a large repetition of letters within it. This problem is related to string handling and manipulation. An original message is sent from planet Earth to planet Cybertron in form of a string. However, the letter position a... | ```python
import sys,math
def main(filename):
inputfile = open(filename,'rU')
data = inputfile.readlines()
T=data.pop(0)
ans=[]
ansstring=str()
explored=[]
for i in T:
if i in explored:
#print explored
for j in range(len(ans)):
if ans[j][0]==i:
ans[j][1] += 1
else:
ans.append([i,1])
exp... | vfc_4358 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/TCTR2012/problems/NOPC9",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "information\n",
"output": "i2n2f1o2r1m1a1t1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1380 | Solve the following coding problem using the programming language python:
The chef was searching for his pen in the garage but he found his old machine with a display and some numbers on it. If some numbers entered then some different output occurs on the display. Chef wants to crack the algorithm that the machine is ... | ```python
# cook your dish here
T = int(input())
for t in range(T):
N = int(input())
print(int(((N-1)*(N))/2))
``` | vfc_4362 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK32020/problems/ITGUY29",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n",
"output": "21\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1381 | Solve the following coding problem using the programming language python:
Chef works as a cook in a restaurant. Each morning, he has to drive down a straight road with length K$K$ to reach the restaurant from his home. Let's describe this road using a coordinate X$X$; the position of Chef's home is X=0$X = 0$ and the ... | ```python
# cook your dish here
t = int(input())
for _ in range(t):
n, k, d = list(map(int, input().split()))
x = list(map(int, input().split()))
l = list(map(int, input().split()))
lane = 3 - l[0]
switched = -float('inf')
ans = k
for i in range(n):
if l[i] == lane:
if switched + ... | vfc_4366 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TWOLANE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 10 20\n4 7\n1 2\n4 15 20\n4 6 9 13\n1 2 2 1\n5 10 1\n1 3 5 7 9\n1 2 1 2 1\n2 10 2\n4 5\n1 2\n",
"output": "10\n13\n10\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1382 | Solve the following coding problem using the programming language python:
Chef has an array of N integers. He wants to play a special game. In this game he needs to make all the integers in the array greater than or equal to 0.
Chef can use two types of operations. The first type is to increase all the integers of t... | ```python
n=int(input())
a=list(map(int,input().split()))
x=int(input())
l=[]
for i in a:
if i<0:
l.append(-i)
l.sort()
m=len(l)
ans=0
if l:
if x>n:
ans=sum(l)
else:
ans=sum(l[m-x:])
print(ans)
``` | vfc_4370 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/INTEG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n-1 -2 -3\n2\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1383 | Solve the following coding problem using the programming language python:
Due to COVID19 all employees of chemical factory are quarantined in home. So, company is organized by automated robots. There are $N$ Containers in company, which are labelled with $1$ to $N$ numbers. There are Total $N$ robots in Company, which... | ```python
T = int(input())
for _ in range(T):
N, K1, K2 = list(map(int, input().split()))
P1, P2, P3, P4 = list(map(int, input().split()))
ans = 0
arr = [0] * (1005)
length = len(arr)
for i in range(1,N+1):
j = 0
while j < length:
arr[j] += 1
... | vfc_4374 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QFUN2020/problems/CHEMFACT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 1 4\n2 2 2 2\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1384 | Solve the following coding problem using the programming language python:
On each of the following $N$ days (numbered $1$ through $N$), Chef is planning to cook either pizza or broccoli. He wrote down a string $A$ with length $N$, where for each valid $i$, if the character $A_i$ is '1', then he will cook pizza on the ... | ```python
for _ in range(int(input())):
n, k = map(int, input().split())
l = [*map(int, input())]
count = [0] * (n + 1)
for i in range(n - 1, -1, -1):
if l[i] == 1:
count[i] = count[i + 1] + 1
x,y = 0,0
for i in range(n):
if l[i] == 1:
x += 1
else:
try:
y = max(y, x + k + count[i + k])
... | vfc_4378 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PIBRO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n13 2\n0101110000101\n6 3\n100001\n",
"output": "5\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1385 | Solve the following coding problem using the programming language python:
Gru has a string $S$ of length $N$, consisting of only characters $a$ and $b$ for banana and $P$ points to spend.
Now Gru wants to replace and/or re-arrange characters of this given string to get the lexicographically smallest string possible. F... | ```python
def __starting_point():
t=int(input())
for _ in range(t):
n,p=input().split()
n,p=int(n),int(p)
s=input()
a,b=0,0
arr=[0]*n
for i in range(n):
arr[i]=s[i]
for c in s:
if c=='a':
a+=1
else:
b+=1
swap=0
for i in range(a):
if s[i]=='b':
swap+=1
tmpp=p
if p<=swap:
... | vfc_4382 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BANSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\nbba\n",
"output": "aab\n",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
Random Hard Python Problems
Retrieves a random sample of 10 hard difficulty questions along with their answers and problem IDs, providing basic filtering but limited analytical value.