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 | 1486 | Solve the following coding problem using the programming language python:
You are provided with the marks of entire class in Data structures exam out of 100. You need to calculate the number of students having backlog (passing marks is >=31) and the average of the class. But this average is not a normal average, for t... | ```python
for j in range(int(input())):
input()
a = list(map(int,input().split()))
marks = 0
backlok = 0
top_marks = max(a)
topper = []
for i in range(len(a)):
if(a[i] >= 31):
marks+=a[i]
if(a[i]<31):
backlok+=1
if(a[i] == top_marks):
topper.append(i)
print(backlok, "{:0.2f}".format(marks/len(a),... | vfc_4786 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/UCOD2020/problems/DSEXAM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n9\n56 42 94 25 74 99 27 52 83\n",
"output": "2 55.56\n5\n43\n57\n5\n74\n25\n0\n72\n47\n16\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1487 | Solve the following coding problem using the programming language python:
Chef has $N$ boxes arranged in a line.Each box has some candies in it,say $C[i]$. Chef wants to distribute all the candies between of his friends: $A$ and $B$, in the following way:
$A$ starts eating candies kept in the leftmost box(box at $1$s... | ```python
import sys
# stdin = open("testdata.txt", "r")
ip = sys.stdin
def solve(C, n, x):
if n==1:
return (1, 0)
b1, b2 = 1, 1
a , b = C[0], C[-1]
while b1 + b2 < n:
if a < b*x:
a += C[b1]
b1 += 1
elif a > b*x:
b2 += 1
b += C[n-b2]
else:
if b1 >= b2:
a += C[b1]
b1 += 1
else:... | vfc_4790 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BIT2B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n2 8 8 2 9\n2\n",
"output": "4 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1488 | Solve the following coding problem using the programming language python:
You have a sequence $a$ with length $N$ created by removing some elements (possibly zero) from a permutation of numbers $(1, 2, \dots, N)$. When an element is removed, the length of the sequence doesn't change, but there is an empty spot left wh... | ```python
from itertools import permutations
for _ in range(int(input())):
N,K=list(map(int,input().split()))
arr=list(map(int,input().split()))
arr1=[]
arr2=[]
for i in range(1,len(arr)+1):
arr1.append(i)
indexzero=[]
for i in range(0,len(arr)):
if(arr[i]==0):
indexzero.append(i)
else:
arr2.append(... | vfc_4794 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GOODPERM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 1\n2 0 0\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1489 | Solve the following coding problem using the programming language python:
$Harshad$ $Mehta$ is planning a new scam with the stocks he is given a stock of integer price S and a number K . $harshad$ has got the power to change the number $S$ at most $K$ times
In order to raise the price of stock and now cash it for hi... | ```python
a,b=[int(_) for _ in input().split()]
if b==0:
print(a)
else:
l=[]
a=str(a)
for i in range(len(a)):
l.append(a[i])
for i in range(len(l)):
if b==0:
break
if l[i]=='9':
continue
else:
l[i]='9'
... | vfc_4798 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SPRT2020/problems/STCKSCAM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4483 2\n",
"output": "9983\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1490 | Solve the following coding problem using the programming language python:
Rahul is a serial killer. Rahul has been betrayed by his lover in the past and now he want to eliminate entire Universe.He has already Eliminated majority of the population and now only a handful number of people are left. Like other Serial kill... | ```python
from math import ceil
t=int(input())
for i in range(t):
p=int(input())
l=list(map(int,input().split()))
maxx=1
for i in range(len(l)):
maxx=max(maxx,l.count(l[i]))
if(maxx*2>p):
print(maxx)
else:
q=p-maxx*2
maxx+... | vfc_4802 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFY2020/problems/GKSMNRSK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10\n178 184 178 177 171 173 171 183 171 175\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1491 | Solve the following coding problem using the programming language python:
Chef recently learned about ratios and proportions. He wrote some positive integers a, b, c, d on a paper. Chef wants to know whether he can shuffle these numbers so as to make some proportion? Formally, four numbers x, y, z, w are said to make ... | ```python
def permutate(arr):
if len(arr) == 1:
yield arr
for x in range(len(arr)):
for perm in permutate(arr[:x] + arr[x+1:]):
yield [arr[x]] + perm
vals = [int(x) for x in input().split()]
founded = False
for val in permutate(vals):
if (val[0] / float(val[1]) == val[2] / float(val[3])):
print("Possible"... | vfc_4806 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK72/problems/CHEFCBA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 4 2\n",
"output": "Possible\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1492 | Solve the following coding problem using the programming language python:
Devu is a disastrous oracle: his predictions about various events of your life are horrifying. Instead of providing good luck, he "blesses" you with bad luck. The secret behind his wickedness is a hidden omen which is a string of length m. On yo... | ```python
t = int(input())
for j in range(0, t):
n = int(input())
m = 100
for i in range(0, n):
str = input()
p = min(str.count("a",0,len(str)),str.count("b",0,len(str)))
if (m > p):
m = p
print(m)
t = t-1
``` | vfc_4810 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC15/problems/ORACLCS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\nab\nba\n2\naa\nbb\n3\naabb\nabab\nbaab\n",
"output": "1\n0\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1493 | Solve the following coding problem using the programming language python:
Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only le... | ```python
def outOfIndex(boys,girls,COST):
if COST == 0:
return len(boys)
else:
total_cost = [ abs(x-y) for x,y in zip(boys,girls)]
total_cost = sum(total_cost)
return total_cost
for _ in range(int(input())):
COST = int(input())
queue = input()
B = queue.count('B')
G = queue.count('G')
boys=[]
girls = ... | vfc_4814 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DEVCLASS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n0\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB\n",
"output": "-1\n0\n1\n1\n1\n3\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1494 | Solve the following coding problem using the programming language python:
Rohit has n empty boxes lying on the ground in a line. The size of the boxes is given in the form of an array $a$. The size of the ith box is denoted by $a[i]$. Since Rohit has a tiny room, there is a shortage of space. Therefore, he has to redu... | ```python
n=int(input())
l=[0]*n
for i in range(n):
l[i]=int(input())
l.sort()
s=0
i=n-1
while i>=0:
x=2*l[i]
if l[-1]>=x:
j=i
while j<len(l):
if l[j]>=x:
l.pop(j)
l.pop(i)
s+=1
break
j+=... | vfc_4818 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/POPU2021/problems/BXRED",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n16\n1\n4\n8\n2\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1495 | Solve the following coding problem using the programming language python:
After completing some serious investigation, Watson and Holmes are now chilling themselves in the Shimla hills. Very soon Holmes became bored. Holmes lived entirely for his profession. We know he is a workaholic. So Holmes wants to stop his vaca... | ```python
t=int(input())
for i in range(0,t):
n=int(input())
lis=list(map(int,input().split()))
lis2=[]
for j in range(0,10):
lis2.append(0)
for j in range(0,len(lis)):
lis2[lis[j]]+=1;
s=sum(lis)
while s%3!=0:
if s%3==2:
if lis2[2]>=1:
lis2[2]-=1
s=s-2
elif lis2[5]>=1:
lis2[5]-=1
s=s... | vfc_4822 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCJUL16/problems/NUMHOLMS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n12\n3 1 2 3 2 0 2 2 2 0 2 3\n11\n3 9 9 6 4 3 6 4 9 6 0\n",
"output": "33322222200\n999666330\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1496 | Solve the following coding problem using the programming language python:
Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way:
- Let's call the nodes' level a number of nodes th... | ```python
# cook your dish here
MOD=10**9+7
for _ in range(int(input())):
s=input()
ind=1
level=1
for i in range(len(s)):
if s[i]=='l':
if level%2==1:
ind=ind*2
else:
ind=ind*2-1
if s[i]=='r':
if level%2==1:
... | vfc_4826 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFLR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nlrl\nrll\nr\nlllr\n\n",
"output": "10\n14\n4\n13\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1497 | Solve the following coding problem using the programming language python:
Divya's watch of worth Rs10 cr is abducted by N thieves(1,2....i...N). The fight over the watch leads to a final decision that it should belong to the thief who wins a simple game. The rules of the game state that every thief registers a time i... | ```python
for t in range(int(input())):
n = int(input())
mx = -1
for i in range(n):
h, m, s = list(map(int,input().split(":")))
h %= 12
m %= 60
s %= 60
ha = h*30 + m*0.5 + s*0.5/60
ma = m*6 + s*0.1
sa = s*6
hm1 = abs(ha - ma)
hm2 = 360 - hm1
hm3 = abs(hm1 - hm2)
hm = min(hm1, hm2, hm3)
... | vfc_4830 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ITRA2016/problems/ITRA06",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n12:28:26\n07:26:04\n11:23:17\n2\n07:43:25\n06:23:34\n",
"output": "3\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1498 | Solve the following coding problem using the programming language python:
Ash is on his way to becoming the Pokemon Master. His pokemon can perform the following moves:
- Tackle - Deal damage worth $X$ points
- Grow - Increase damage by $Y$ points i.e. $X$ = $X$ + $Y$
But, it can only perform Grow first (0 or mor... | ```python
def Testcase():
h,x,y = [int(x) for x in input().strip().split()]
h = h-1
yt = h//y +1
# print(yt)
flag=0
ans = 100000000009
for i in range(0,yt):
temp = x+i*y
if h%temp==0:
flag = 1
cl =i+int(h/temp)
# print(temp,cl)
... | vfc_4834 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/TCFL2020/problems/TCFL20D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n101 10 10\n11 3 3\n",
"output": "6\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1499 | Solve the following coding problem using the programming language python:
Given $N *M$ matrix containing elements either $1$ or $0$ and string S of length $N+M-1$ containing characters $0$ or $1$. Your task is to make all the paths from top left corner to the bottom right corner of the matrix same as the given stri... | ```python
from sys import stdin,stdout
import math,bisect
from collections import Counter,deque,defaultdict
L=lambda:list(map(int, stdin.readline().strip().split()))
M=lambda:list(map(int, stdin.readline().strip().split()))
I=lambda:int(stdin.readline().strip())
S=lambda:stdin.readline().strip()
C=lambda:stdin.readline... | vfc_4838 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOGI2020/problems/MATMIN1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n1 0 1\n0 1 1\n1 1 0\n10111\n10 5\n3 3\n0 0 1\n0 1 1\n0 1 1\n00011\n2 9\n",
"output": "5\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1500 | Solve the following coding problem using the programming language python:
A valid parentheses sequence is a non-empty string where each character is either '(' or ')', which satisfies the following constraint:
You can find a way to repeat erasing adjacent pairs of parentheses '()' until it becomes empty.
For examp... | ```python
try:
for i in range(int(input())):
s=input()
balance=0
max_balance=0
for i in s:
if i=='(':balance+=1
else:
balance-=1
max_balance=max(max_balance,balance)
print('('*max_balance,')'*max_balance,sep="")
except Excep... | vfc_4842 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BRACKETS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n()((()()))\n\n\n",
"output": "((()))\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1501 | Solve the following coding problem using the programming language python:
Given a Complete Binary Tree of ‘n’ depth, you can perform 4 types of mirror operation on the tree:-
Mirror on the right. The tree is mirrored to the right and rightmost node on every level is connected with the mirrored corresponding node.
Mi... | ```python
import os,sys
from io import BytesIO, IOBase
def ii(): return int(input())
def si(): return input()
def mi(): return list(map(int,input().split()))
def li(): return list(mi())
import math
import collections
def CountFrequency(arr):
return collections.Counter(arr)
for i in range(1):
n,q=mi()
p=pow(2... | vfc_4846 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MIRTREE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3\n1 1\n1 4\n2\n",
"output": "38\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1502 | Solve the following coding problem using the programming language python:
Your are given a string $S$ containing only lowercase letter and a array of character $arr$. Find whether the given string only contains characters from the given character array.
Print $1$ if the string contains characters from the given array... | ```python
t=int(input())
for _ in range(t):
S=set(input().strip())
n=int(input().strip())
a=set(input().strip().split(" "))
g=True
for i in S:
if(i not in a):
g=False
if(g):
print(1)
else:
print(0)
``` | vfc_4850 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDGO2021/problems/STRNCHAR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nabcd\n4\na b c d\naabbbcccdddd\n4\na b c d\nacd\n3\na b d\n",
"output": "1\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1503 | Solve the following coding problem using the programming language python:
Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is... | ```python
# cook your dish here
import math
N=int(input())
for i in range(N):
a,b=list(map(int,input().split()))
c=a//math.gcd(a,b)*b//math.gcd(a,b)
print(c)
``` | vfc_4854 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RECTSQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10 15\n4 6\n",
"output": "6\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1504 | Solve the following coding problem using the programming language python:
To make Yalalovichik even more satisfied and happy, Jafar decided to invent Yalalovichik strings. A string is called a Yalalovichik string if the set of all of its distinct non-empty substrings is equal to the set of all of its distinct non-empt... | ```python
for _ in range(int(input())):
n,s = int(input()),input().strip()
previ,num,_s,dic = s[0],0,[],{}
for i in s:
if previ == i:
num+=1
continue
_s.append((previ, num))
if previ not in dic or dic[previ]<num:dic[previ] = num
previ,num = i,1
_s.append((previ, num))
... | vfc_4858 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/YVSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\nxxx\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1505 | Solve the following coding problem using the programming language python:
Zonal Computing Olympiad 2012, 26 Nov 2011
A sequence of opening and closing brackets is well-bracketed if we can pair up each opening bracket with a matching closing bracket in the usual sense. For instance, the sequences (), (()) and ()(()) ... | ```python
# cook your dish here
T = int(input())
l = list(map(int, input().strip().split(" ")))
depth = 0
max_depth = 0
max_depth_index = 0
max_l=0
max_l_index=0
last_zero=-1
for i in range(T):
if l[i] == 1:
depth += 1
if depth > max_depth:
max_depth = depth
max_depth_ind... | vfc_4862 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO12001",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "20\n1 2 1 1 2 2 1 2 1 1 2 1 2 2 1 1 2 1 2 2\n",
"output": "2 4 6 9\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1506 | Solve the following coding problem using the programming language python:
Cherry has a binary matrix $A$ consisting of $N$ rows and $M$ columns. The rows are numbered from $1$ to $N$, columns are numbered from $1$ to $M$. Element at row $i$ ($1$ ≤ $i$ ≤ $N$) and column $j$ ($1$ ≤ $j$ ≤ $M$) is denoted as $A_{ij}$. All... | ```python
import sys,os,io,time,copy,math,queue,bisect
from collections import deque
from functools import lru_cache
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(100000000)
def main():
n,m=map(int,input().split())
mat=[]
for _ in ... | vfc_4866 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CENS20A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n00\n00\n3\n1 1 1 1\n2 2 2 2\n1 1 2 2\n",
"output": "01\n10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1507 | Solve the following coding problem using the programming language python:
You are given a grid with dimension $n$ x $m$ and two points with coordinates $X(x1,y1)$ and $Y(x2,y2)$ . Your task is to find the number of ways in which one can go from point $A(0, 0)$ to point $B (n, m)$ using the $shortest$ possible path suc... | ```python
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]
N = 100001
p = 998244353
factorialNumInverse = [0]*(N+1)
naturalNumInverse = [0]*(N+1)
fact = [0]*(N+1)
def InverseofNumber(p):
naturalN... | vfc_4870 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CFUS2020/problems/CFS2005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3 1 1 1 2\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1508 | Solve the following coding problem using the programming language python:
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cas... | ```python
# cook your dish here
for _ in range(int(input())):
n=int(input())
if n==1:
print("0")
else:
s=[]
for i in range(n):
s.append(str(i))
print(''.join(s))
p=1
for i in range(n-1):
s.pop(n-1)
s=[str(p)]+s
p... | vfc_4874 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ITGUY59",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "0\n01\n10\n012\n101\n210\n0123\n1012\n2101\n3210\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1509 | Solve the following coding problem using the programming language python:
The Siruseri amusement park has a new attraction. It consists of a rectangular array of discs. Each disc is divided into four equal sectors and the four sectors are coloured with the colours Red, Blue, Green and Yellow (in some order). The order... | ```python
#for _ in range(int(input()):
#n,m = map(int,input().split())
#x = [int(w) for w in input().split()]
#n = int(input())
#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])}
m,n = map(int,input().split()... | vfc_4878 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/MINTURN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\nG Y B R\nB G R Y\nG Y B R\nG R B Y\nB Y G R\nG B R Y\nB R G Y\nB R G Y\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1510 | Solve the following coding problem using the programming language python:
You are playing a game where you have been sent in a town to collect 10 types of coin and their symbol are defined with $A, B, C, D, E, F, G, H , I, J$. In that town every enemy have a coin. By killing one you will get a coin from that enemy. Ea... | ```python
for _ in range(int(input())):
s = input()
c = 0
for i in s:
if i.isalpha() and i.isupper():
c += 1
print(c)
``` | vfc_4882 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NEWB2020/problems/HNH01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nABCDEFGHIJ\n",
"output": "10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1511 | Solve the following coding problem using the programming language python:
Chef loves to play with iron (Fe) and magnets (Ma). He took a row of $N$ cells (numbered $1$ through $N$) and placed some objects in some of these cells. You are given a string $S$ with length $N$ describing them; for each valid $i$, the $i$-th ... | ```python
# cook your dish here
# cook your dish here
for _ in range(int(input())) :
n,k=map(int,input().split())
#reading the string
s=input()
i,j=0,0
q=0
while(i<n and j<n) :
if(s[i]=='M') :
if(s[j]=='I') :
cnt=0
if(i>j) :
p=s[j:i]
cnt=p.count(':')
else :
p=s[i:j]
cnt=p.cou... | vfc_4886 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FEMA2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 5\nI::M\n9 10\nMIM_XII:M\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1512 | Solve the following coding problem using the programming language python:
Tuzik and Vanya are playing the following game.
They have an N × M board and a chip to indicate the current game position. The chip can be placed on any one cell of the game board, each of which is uniquely identified by an ordered pair of posit... | ```python
cases = int(input())
for _ in range(cases):
rows, cols = map(int, input().split())
if (cols - 1) % 3 == 0 and (rows - 1) % 4 == 0: print('Vanya')
elif (cols - 1) % 3 != 0 and (rows - 1) % 4 == 0: print('Tuzik')
elif (cols - 1) % 3 == 0 and (rows - 1) % 4 != 0: print('Tuzik')
else:
if (cols - 1) % 3 == ... | vfc_4890 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TUZGMBR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 4\n2 2\n",
"output": "Tuzik\nVanya\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1513 | Solve the following coding problem using the programming language python:
Ishank lives in a country in which there are N$N$ cities and N−1$N-1$ roads. All the cities are connected via these roads. Each city has been assigned a unique number from 1 to N$N$. The country can be assumed as a tree, with nodes representing ... | ```python
# cook your dish here
try:
X=list(map(int, input().split()))
except:
X=[0,0]
ch=[]
chnew=[]
par={}
par[1]=0
for i in range(X[0]+1):
ch.append([])
chnew.append([])
for i in range(X[0]-1):
Y=list(map(int, input().split()))
#par[Y[1]]=[Y[0],Y[2]]
ch[Y[0]].append([Y[1],Y[2]])
ch[Y[... | vfc_4894 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CTOUR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "9 5\n1 2 8\n1 3 -9\n2 4 1\n2 5 -6\n3 6 7\n3 7 6\n6 8 3\n6 9 4\n1 2\n2 7\n4 3\n3 2\n8 9\n",
"output": "10\n5\n0\n-1\n21\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1514 | Solve the following coding problem using the programming language python:
Raj is a math pro and number theory expert. One day, he met his age-old friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a 3$3$-tuple of non-ne... | ```python
for _ in range(int(input())):
a,b,c,x,y,z = list(map(int,input().split()))
if a == 0 and b == 0 and c == 0 and x == 0 and y == 0 and z == 0:
print(0)
continue
ans = 0
if a == 0 and b == 0 and c == 0:
st = set((abs(x-a)%2,abs(y-b)%2,abs(z-c)%2))
if st == {0,1}:
ans = 1... | vfc_4898 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FUZZYCON",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 1 1 2 2 2\n1 2 3 2 4 2\n",
"output": "0\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1515 | Solve the following coding problem using the programming language python:
Chefina is always interested to play with string. But due to exam pressure she has no time to solve a string problem. She wants your help. Can you help her to solve that problem?
You are given a string. You have to find out the $Wonder$ $Sum$ ... | ```python
for _ in range(int(input())):
string = input().rstrip()
start=(ord(string[0])-96)*100
sum=0
#print(start)
for i in range(len(string)):
sum+=start+(ord(string[i])-97)
print(sum%1000000007)
``` | vfc_4902 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NOOB2020/problems/NBC005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\ncab\nsdef\n",
"output": "903\n7630\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1516 | Solve the following coding problem using the programming language python:
Chef wants to make a feast. In order to do that, he needs a lot of different ingredients. Each ingredient has a certain tastiness; the tastiness of each ingredient may be any positive integer. Initially, for each tastiness between $K$ and $K+N-1... | ```python
__author__ = 'Prateek'
MOD = int(10**9+7)
def test():
n,k=list(map(int,input().split()))
l = k
d =n-1
ans = l-1
ans = ans%MOD
a = k-n
term = (d+a)//d
ll = (a%MOD - (((term-1)%MOD)*(d%MOD))%MOD)%MOD
if ll < 0:
ll = (ll +MOD)%MOD
m = ((term%MOD)*((a%MOD+ll%MOD)%MOD))%MOD
m = (m*pow(2,MOD-2,MOD))%... | vfc_4906 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHFING",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 1\n3 3\n",
"output": "0\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1517 | Solve the following coding problem using the programming language python:
Consider a number X on which K Mag-Inc operations are to be performed. In a Mag-Inc operation, the number X undergoes an increment of A/B times of X where A and B are two integers.
There is a numerator and a denominator array of size K which co... | ```python
import sys
import math
def solution():
T = int(input().strip())
for _ in range(T):
x, k = list(map(float, input().strip().split(' ')))
original_x = x
if k == 1:
a = [float(input().strip())]
b = [float(input().strip())]
else:
a = list(map(float, input().strip().split(' ')))
b = list(map(... | vfc_4910 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CCWR2016/problems/CCWR02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n100 1\n1\n4\n100 2\n1 1\n2 3\n",
"output": "20\n50\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1518 | Solve the following coding problem using the programming language python:
The chef was busy in solving algebra, he found some interesting results, that there are many numbers which can be formed by sum of some numbers which are prime. Chef wrote those numbers in dairy. Cheffina came and saw what the chef was doing. Ch... | ```python
from math import sqrt
def isprime(n):
if (n % 2 == 0 and n > 2) or n == 1: return 0
else:
s = int(sqrt(n)) + 1
for i in range(3, s, 2):
if n % i == 0:
return 0
return 1
def find(N, K):
if (N < 2 * K):
return 0
if (K == 1):
... | vfc_4914 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY27",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n12 2\n11 2\n",
"output": "1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1519 | Solve the following coding problem using the programming language python:
In order to win over and get noticed by his favorite streamer Daenerys, Jon decides to donate a significant amount of money . Every donation made to Daenerys is of $at$ $least$ $1$ $beastcoin$ and is displayed on Daenerys's stream alongside any ... | ```python
# cook your dish here
for _ in range(int(input(''))):
n=int(input(''))
x=bin(n)
x=len(x)-2
if n==(2**(x-1)):
print(n)
else:
print(2**x)
``` | vfc_4918 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INSO2020/problems/INQU2000",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n7\n",
"output": "4\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1520 | Solve the following coding problem using the programming language python:
Given an array of n$n$ integers : A1,A2,...,An$ A_1, A_2,... , A_n$, find the longest size subsequence which satisfies the following property: The xor of adjacent integers in the subsequence must be non-decreasing.
-----Input:-----
- First line... | ```python
# cook your dish here
n=int(input())
l=[int(i) for i in input().split()]
xors=[]
for i in range(n):
for j in range(i+1,n):
xors.append([l[i]^l[j],(i,j)])
xors.sort()
#print(xors)
upto=[0]*n
for i in range(len(xors)):
#a=xors[i][0]
b,c=xors[i][1][0],xors[i][1][1]
upto[c]=max(upto[c],upto... | vfc_4922 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/XOMMON",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n1 200 3 0 400 4 1 7\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1521 | Solve the following coding problem using the programming language python:
The Siruseri Singing Championship is going to start, and Lavanya wants to figure out the outcome before the tournament even begins! Looking at past tournaments, she realizes that the judges care only about the pitches that the singers can sing i... | ```python
# cook your dish here
from operator import itemgetter
t=int(input())
for _ in range(t):
n=int(input())
start=[]
end=[]
for i in range(n):
first, last = map (int, input().split())
start.append((first, i))
end.append((last, i))
score=[0]*n
start.sort(key=itemgett... | vfc_4926 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/SINGTOUR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n10 20\n13 18\n15 19\n3\n10 22\n13 21\n15 20\n",
"output": "4 1 1\n4 2 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1522 | Solve the following coding problem using the programming language python:
Kira likes to play with strings very much. Moreover he likes the shape of 'W' very much. He takes a string and try to make a 'W' shape out of it such that each angular point is a '#' character and each sides has same characters. He calls them W ... | ```python
def frequency(s,n):
f=[[0 for i in range(26)]for j in range(n+1)]
count=0
for i in range(n):
if s[i]!="#":
f[count][ord(s[i])-97]+=1
else:
count+=1
for j in range(26):
f[count][j]=f[count-1][j]
return (f,count)
def solve(... | vfc_4930 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WSTRING",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\naaaaa#bb#cc#dddd\nacb#aab#bab#accba\nabc#dda#bb#bb#aca\n\n\n",
"output": "16\n10\n11\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1523 | Solve the following coding problem using the programming language python:
Zonal Computing Olympiad 2014, 30 Nov 2013
In IPL 2025, the amount that each player is paid varies from match to match. The match fee depends on the quality of opposition, the venue etc.
The match fees for each match in the new season have be... | ```python
# cook your dish here
n=int(input())
l=list(map(int,input().split()))
temp=[]
for item in l:
temp.append(item)
if(n<=3):
print(sum(temp))
else:
for i in range(3,n):
temp[i]=l[i]+min(temp[i-1],temp[i-2],temp[i-3])
res=sum(l)-min(temp[n-1],temp[n-2],temp[n-3])
print(res)
``` | vfc_4934 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO14004",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10 3 5 7 3\n",
"output": "23\n(\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1524 | Solve the following coding problem using the programming language python:
Zombies zombies everywhere!!
In a parallel world of zombies, there are N zombies. There are infinite number of unused cars, each of same model only differentiated by the their colors. The cars are of K colors.
A zombie parent can give birth to... | ```python
ways=x=0
val=10**9
remi=((10**9)+7)
t=int(input())
for i in range(t):
n,k=list(map(int,input().split()))
if t<=100 and n>=1 and k<=val:
x=(k-1)**(n-1)
ways=k*x
ways=ways%remi
print(ways)
x=ways=0
else:
break
``` | vfc_4938 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APRIL16/problems/BIPIN3",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2\n3 3\n",
"output": "2\n12\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1525 | Solve the following coding problem using the programming language python:
The Chef has a huge square napkin of size 2n X 2n. He folds the napkin n-3 times. Each time he folds its bottom side over its top side, and then its right side over its left side. After each fold, the side length of the napkin is reduced by half... | ```python
import sys
t = int(sys.stdin.readline())
def identify(x, y):
rows[x][y] = '2'
r = 0
if x == 0:
r |= 1
elif rows[x-1][y] == '1':
r |= identify(x-1, y)
if x == 7:
r |= 4
elif rows[x+1][y] == '1':
r |= identify(x+1, y)
if y == 0:
r |= 2
el... | vfc_4942 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AUG09/problems/F3",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n01000010\n11000001\n00000000\n00011000\n00011000\n00010100\n00001000\n00000000\n4\n01000010\n11000001\n00000000\n00011000\n00011000\n00010100\n00001000\n00000000\n1000000000\n11111111\n11111111\n11111111\n11111111\n11111111\n... |
apps | verifiable_code | 1526 | Solve the following coding problem using the programming language python:
Alice and Bob created $N$ and $M$ recipes, respectively ($N, M \ge 1$), and submitted them to Chef for evaluation. Each recipe is represented by a string containing only lowercase English letters. Let's denote Alice's recipes by $A_1, A_2, \ldot... | ```python
# v = ["a","e","i","o","u"]
# for _ in range(int(input())):
# n = int(input())
# a,b = [],[]
# for i in range(n):
# s = input()
# isa = True
# for j in range(1,len(s) - 1):
# if(s[j] in v):
# if(s[j - 1] not in v and s[j + 1] not in v):
# isa =... | vfc_4946 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WEIRDO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\naba\nabc\nbab\naac\n3\naba\nbaab\nabc\n",
"output": "1.1250000\n0.0277778\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1527 | Solve the following coding problem using the programming language python:
Today is Chef's birthday. His mom decided to surprise him with a truly fantastic gift: his favourite binary string B. But, unfortunately, all the stocks of binary string B have been sold out, and only a binary string A (A ≠ B) is available in th... | ```python
for j in range(int(input())):
a=input()
b=input()
c,d=0,0
a0=a.count("0")
a1=a.count("1")
if(a0==len(a) or a1==len(a)):
print("Unlucky Chef")
else:
print("Lucky Chef")
for i in range(len(a)):
if(a[i]!=b[i]):
if(a[i]=="0"):
c+=1
else:
d+=1
print(max(c,d))
``` | vfc_4950 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BINOP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n101\n010\n1111\n1010\n",
"output": "Lucky Chef\n2\nUnlucky Chef\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1528 | Solve the following coding problem using the programming language python:
You are Dastan, the great Prince of Persia!
After searching long for the mysterious 'Sands of Time', you have finally arrived at the gates of the city that hosts the ancient temple of the gods. However, the gate is locked and it can only be open... | ```python
t=int(input())
for i in range(t):
n,k=[int(i) for i in input().split()]
l=input().split()
for i in range(k):
if l.pop()=='H':
for ind,j in enumerate(l):
if j=='H':
l[ind]='T'
else:
l[ind]='H'
print(sum([1 for i in l if i=='H']))
``` | vfc_4954 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/POPGATES",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 3\nH T T H T\n7 4\nH H T T T H H\n6 1\nT H T H T T\n",
"output": "1\n2\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1529 | Solve the following coding problem using the programming language python:
During Quarantine Time Chef is at home and he was quite confused about what to cook so, he went to his son and asked about what would he prefer to have? He replied, cakes.
Now, chef cook $N$ number of cake and number of layers for every cake is ... | ```python
#cook your recipe
from math import factorial
test_cases = int(input())
for _ in range(test_cases):
n = int(input())
sum1 = 0
final_sum = 0
num = list(map(int, input().split()))
rep_time = factorial(n - 1)
rep_count = dict()
for i in num:
if i in rep_count:
rep_count[i] +=1
... | vfc_4958 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/QFUN2020/problems/CHEFCAKE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n2 3 5\n",
"output": "2220\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1530 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
t = int(input())
for _ in range(t):
n = int(input())
for i in range(n):
for j in range(n):
if i>=j:
print(int((i+1)*(i+2)/2)-j,end='')
print()
``` | vfc_4962 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY44",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n2\n3\n4\n5\n",
"output": "1\n1\n32\n1\n32\n654\n1\n32\n654\n10987\n1\n32\n654\n10987\n1514131211\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1531 | Solve the following coding problem using the programming language python:
Bobby has decided to hunt some Parrots. There are n horizontal branch of trees aligned parallel to each other. Branches are numbered 1 to n from top to bottom. On each branch there are some parrots sitting next to each other. Supposed there are ... | ```python
n = int(input())
x = [int(i) for i in input().split()]
m = int(input())
for i in range(m):
a,b = map(int,input().split())
a -= 1
t = b-1
t1 = x[a]-b
if a-1>=0:
x[a-1] += t
if a+1<n:
x[a+1] += t1
x[a] = 0
for i in x:
print(i)
``` | vfc_4966 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CFUN2020/problems/CODSTAN2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n10 10 10 10 10\n5\n2 5\n3 13\n2 12\n1 13\n4 6\n3\n2 4 1\n1\n2 2\n",
"output": "0\n12\n5\n0\n16\n3\n0\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1532 | Solve the following coding problem using the programming language python:
As you know America’s Presidential Elections are about to take place and the most popular leader of the Republican party Donald Trump is famous for throwing allegations against anyone he meets.
He goes to a rally and meets n people which he wan... | ```python
for t in range(int(input())):
n = int(input())
a = sorted(map(int,input().split()))
ans = 1
for i in range(n):
ans *= (a[i]-i)
ans %= (10**9+7)
if (ans == 0):
break
print(ans)
``` | vfc_4970 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDGF2016/problems/CDGLF01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n4\n2\n10 5\n4\n2 3 1 3\n",
"output": "4\n45\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1533 | Solve the following coding problem using the programming language python:
You are given a weighted graph with $N$ nodes and $M$ edges. Some of the nodes are marked as special nodes. Your task is to find the shortest pairwise distance between any two different special nodes.
-----Input-----
- The first line of the inp... | ```python
n,m,lk = list(map(int,input().split()))
sp = [int(i)-1 for i in input().split()]
dp = []
for i in range(n):
dp += [[0]*n]
for i in range(n):
for j in range(n):
if(i!=j):
dp[i][j]=10**18
for _ in range(m):
x,y,z = list(map(int,input().split()))
dp[x-1][y-1]=z
dp[y-1][x-1]=z
for k in range(n):
for i ... | vfc_4974 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LTIME34/problems/PAIRCLST",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 3\n1 3 5\n1 2 3\n2 3 4\n3 4 1\n4 5 8\n1 5 19\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1534 | Solve the following coding problem using the programming language python:
Sereja has two integers — A and B — in 7-ary system. He wants to calculate the number C, such that B * C = A. It is guaranteed that B is a divisor of A.
Please, help Sereja calculate the number C modulo 7L.
-----Input-----
First line of input... | ```python
t=int(input())
while t>0 :
a=int(input())
b=int(input())
l=int(input())
x=0
y=0
z=0
a1=0
b1=0
c1=0
while(a//10!=0 or a%10!=0):
a1+=(a%10+((a//10)%10)*7+((a//100)%10)*49+((a//1000)%10)*343+((a//10000)%10)*2401+((a//100000)%10)*16807+((a//1000000)%10)*117649+((a//10000000)%10)*823543+((a//100000000)... | vfc_4978 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC15/problems/SEADIV",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n21\n5\n10\n202\n13\n1\n202\n13\n2\n",
"output": "3\n3\n13\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1535 | Solve the following coding problem using the programming language python:
There are $N$ villages numbered $1$ to $N$. The villages are connected through bi-directional paths in between them. The whole network is in the form of a tree.
Each village has only $1$ fighter but they help each other in times of crisis by se... | ```python
# cook your dish here
def solve(edges,ans):
n = len(edges)
visited = set()
parents = [-1]*(n+1)
dp = [0]*(n+1)
stack = [1]
w = float('inf')
x = -1
while stack:
node = stack[-1]
if node not in visited:
count = 0
for kid in edges[node]:
if parents[kid] == -1:
if kid != 1:
parent... | vfc_4982 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENAU2020/problems/ECAUG207",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n1 2\n1 3\n2 4\n3 5\n3\n1 2\n2 3\n",
"output": "1 2\n2 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1536 | Solve the following coding problem using the programming language python:
Istiak is learning about arithmetic progressions. Today, he wrote an arithmetic sequence on a piece of paper. Istiak was very happy that he managed to write an arithmetic sequence and went out for lunch.
Istiak's friend Rafsan likes to irritate ... | ```python
# cook your dish here
test_cases = int(input())
for i in range(test_cases):
no_of_elements = int(input())
sequence = list(map(int, input().split()))
d1 = sequence[1] - sequence[0]
d2 = sequence[2] - sequence[1]
d3 = (sequence[3] - sequence[0])/3
d4 = (sequence[3] - sequence[1])/2
d5 = (sequence[2] - se... | vfc_4986 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RECVSEQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n1 3 10 7\n5\n-10 -5 0 5 10\n4\n2 2 2 10\n",
"output": "1 3 5 7\n-10 -5 0 5 10\n2 2 2 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1537 | Solve the following coding problem using the programming language python:
Prime numbers are arranged in a ordered list U$U$, in increasing order. Let S$S$ be a sublist of U$U$ with a unique property that for every element A$A$ belonging to list S$S$, if i$i$ denotes the index of A$A$ in list U$U$, than i$i$ also belon... | ```python
import math
def prime(aa):
f=0
for y in ar:
if aa%y==0:
return 0
return 1
ar=[]
ar.append(2)
pc=3
te=int(input())
for _ in range(te):
a=int(input())
f=0
c=0
add=0
for x in ar:
try:
add=add+ar[x-1]
except:
while True:
if prime(pc)==1:
ar.append(pc)
i... | vfc_4990 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALQU2018/problems/SUPPRM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "3\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1538 | Solve the following coding problem using the programming language python:
Two integers A and B are the inputs. Write a program to find GCD and LCM of A and B.
-----Input-----
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer A and B.
-----Output----... | ```python
# cook your dish here
def GCD(x, y):
while y:
x, y = y, x % y
return x
def LCM(x, y):
lcm = (x*y)//GCD(x,y)
return lcm
t = int(input())
while t>0:
x,y = list(map(int,input().split()))
print(GCD(x,y),LCM(x,y))
t -=1
``` | vfc_4994 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW016",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n120 140\n10213 312\n10 30\n",
"output": "20 840\n1 3186456\n10 30\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1539 | Solve the following coding problem using the programming language python:
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones a... | ```python
n = int(input())
for i in range(n):
count = 0
k = input()
x = list(k)
kk = input()
y = list(kk)
for j in y:
for jj in x:
if(j==jj):
count = count+1
break
print(count)
``` | vfc_4998 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MAY12/problems/STONES",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\nabc\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone\n",
"output": "3\n2\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1540 | Solve the following coding problem using the programming language python:
There are total N friends went to Chef's Pizza shop. There they bought a pizza. Chef divided the pizza into K equal slices. Now you have to check whether these K pizza slices can be distributed equally among the friends. Also given that every pe... | ```python
for _ in range(int(input())):
n = int(input())
k = int(input())
if k%n==0:
print("YES")
else:
print("NO")
``` | vfc_5002 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SPTC2020/problems/CPCEJC1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10\n20\n12\n5\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1541 | Solve the following coding problem using the programming language python:
Tennis is a popular game. Consider a simplified view of a tennis game from directly above. The game will appear to be played on a 2 dimensional rectangle, where each player has his own court, a half of the rectangle. Consider the players and the... | ```python
eps=1e-8
t=int(input())
for ii in range(t):
n=int(input())
l=[int(i) for i in input().split() ]
b=[int(i) for i in input().split() ]
v=[int(i) for i in input().split() ]
c=[int(i) for i in input().split() ]
greatest_time=l[0]/v[0]
for i in range(1,n):
if v[i]>0:
... | vfc_5006 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CLTNIS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n3 4\n0 2\n2 -2\n2 2\n3\n10 10 10\n0 0 0\n1 1 1\n5 5 5\n",
"output": "2.0000\n0.0000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1542 | Solve the following coding problem using the programming language python:
Every character in the string “IITMANDI” is given a certain number of points. You are given a scrabble board with only one row. The input contains the positions of score modifiers such as: Double Letter, Triple Letter, Double Word and Triple Wor... | ```python
# cook your dish here
try:
T = int(input())
for i in range(T):
n = int(input())
s = input()
arr = [int(i) for i in input().strip().split(" ")]
res = 1
result = 0
for j in range(n-7):
res = 1
res1= 0
s1 = s[j:j+8]
for i in range(8):
if s1[i] == 'D':
res = res*2
res1 ... | vfc_5010 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MAXSCRAB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10\n..d.t.D..d\n10 11 12 9 8 10 11 15\n22\ndtDtTD..ddT.TtTdDT..TD\n12297 5077 28888 17998 12125 27400 31219 21536\n",
"output": "270\n35629632\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1543 | Solve the following coding problem using the programming language python:
Let X be the set of all integers between 0 and n-1. Suppose we have a collection S1, S2, ..., Sm of subsets of X. Say an atom A is a subset of X such that for each Si we have either A is a subset of Si or A and Si do not have any common elements... | ```python
# cook your dish here
# cook your dish here
for _ in range(int(input())):
n,m=list(map(int,input().split()))
atomlist = ['']*n
for k in range(m):
s=[]
s.extend(input().split()[1:])
#print(s)
for w in range(n):
if str(w) in s:
atomlist[w]+="1"
else:
atomlist[w]+="0"
#print(atomlist)
... | vfc_5014 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ATOMS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 2\n3 0 1 2\n3 2 3 4\n4 3\n2 0 1\n2 1 2\n2 2 3\n",
"output": "3\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1544 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
# cook your dish here
def solve():
n=int(input())
i=0
while i<n-1:
if i==0:
print("*",end="")
else:
print("*",end="")
for k in range(i-1):
print(" ",end="")
print("*",end="")
print()
i+=1
fo... | vfc_5018 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY43",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n2\n3\n4\n5\n",
"output": "*\n*\n**\n*\n**\n***\n*\n**\n* *\n****\n*\n**\n* *\n* *\n*****\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1545 | Solve the following coding problem using the programming language python:
The Quark Codejam's number QC(n, m) represents the number of ways to partition a set of n things into m nonempty subsets. For example, there are seven ways to split a four-element set into two parts:
{1, 2, 3} ∪ {4}, {1, 2, 4} ∪ {3}, {1, 3, 4} ... | ```python
for i in range(eval(input())):
n,k=input().strip().split()
n=int(n)
k=int(k)
print(int( ((n-k)&(int((k-1)/2)))==0))
``` | vfc_5022 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COJA2016/problems/CODEJAM1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1546 | Solve the following coding problem using the programming language python:
Chef loves triangles. But the chef is poor at maths. Given three random lengths Chef wants to find if the three sides form a right-angled triangle or not. Can you help Chef in this endeavour?
-----Input:-----
- First-line will contain $T$, the ... | ```python
# cook your dish here
def check(a,b,c):
if (a==0) or (b==0) or (c==0):
return "NO"
else:
i=3
while(i>0):
if (a*a)==(b*b)+(c*c):
return "YES"
else:
t=a
a=b
b=c
c=t
... | vfc_5026 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENFE2020/problems/ECFEB201",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 4 5\n1 3 4\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1547 | Solve the following coding problem using the programming language python:
Increasing COVID cases have created panic amongst the people of Chefland, so the government is starting to push for production of a vaccine. It has to report to the media about the exact date when vaccines will be available.
There are two compan... | ```python
# cook your dish here
try:
d1,v1,d2,v2,p=map(int, input().split())
total=0
while p>0:
total+=1
if total>=d1:
p=p-v1
if total>=d2:
p=p-v2
print(total)
except:
pass
``` | vfc_5030 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/VACCINE1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 2 1 3 14\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1548 | Solve the following coding problem using the programming language python:
“Jesse, you asked me if I was in the meth business, or the money business… Neither. I’m in the empire business.”
Walter’s sold his stack in Gray Matter Technologies, a company which he deserved half a credit, for peanuts. Now this company is wor... | ```python
# cook your dish here
T=int(input())
for _ in range(T):
n=int(input())
arr=list(map(int,input().split()))
left=[-1 for i in range(n)]
right=[-1 for i in range(n)]
min1=float("inf")
for i in range(n):
min1=min(arr[i],min1+1)
left[i]=min1
min1=float("inf")
for i in range(n-1,-1,-1):
min1=min(arr[i... | vfc_5034 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SOLDVAL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n6 5 5 5 2\n5\n1 2 3 4 5\n",
"output": "6 5 4 3 2\n1 2 3 4 5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1549 | 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 new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First line will contain $T$, number of testcases. Then... | ```python
# cook your dish here
import copy
for _ in range(int(input())):
k=int(input())
c=[]
d=[]
start=0
while True:
c=[]
for i in range(start):
c.append(" ")
for i in range(start,k+1):
c.append(str(i))
start+=1
d.append(c)
... | vfc_5038 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK02020/problems/ITGUY12",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "2\n12\n012\n12\n2\n4\n34\n234\n1234\n01234\n1234\n234\n34\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1550 | Solve the following coding problem using the programming language python:
The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2). You have developed two sequences of numbers. The first sequence that uses the bitwise XOR operation instead of the addition method is called the Xoronacci number. It is described as fo... | ```python
# Python3 program to find XNOR
# of two numbers
import math
def swap(a, b):
temp = a
a = b
b = temp
# log(n) solution
def xnor(a, b):
# Make sure a is larger
if (a < b):
swap(a, b)
if (a == 0 and b == 0):
return 1;
# for last bit of a
a_rem = 0
# for last bit of b
b_rem = 0
# counter fo... | vfc_5042 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CEFT2020/problems/SERIESTO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 4 2\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1551 | Solve the following coding problem using the programming language python:
"I don't have any fancy quotes." - vijju123
Chef was reading some quotes by great people. Now, he is interested in classifying all the fancy quotes he knows. He thinks that all fancy quotes which contain the word "not" are Real Fancy; quotes tha... | ```python
# cook your dish here
import re
t=int(input())
while(t>0):
s=list(input().split(' '))
if("not" in s):
print("Real Fancy")
else:
print("regularly fancy")
t=t-1
``` | vfc_5046 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FANCY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\ni do not have any fancy quotes\nwhen nothing goes right go left\n",
"output": "Real Fancy\nregularly fancy\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1552 | Solve the following coding problem using the programming language python:
Chef has two piles of stones with him, one has n1 stones and the other has n2 stones. Fired up by boredom, he invented a game with the two piles.
Before the start of the game Chef chooses an integer m.
In the j-th move:
- He chooses a numbe... | ```python
import sys
n = int(sys.stdin.readline())
for _ in range(n):
p1, p2, m = list(map(int, sys.stdin.readline().split()))
l = min(p1, p2)
#while(m > 0 and l > 0):
# k = min(l, m)
# l -= k
# m -= 1
q = min(p1, p2)
d = min((m * (m + 1)) / 2, q)
print(p1 - d + p2 - d)
``` | vfc_5050 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC15/problems/CHEFST",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 1\n1 2 1\n4 5 2\n",
"output": "0\n1\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1553 | Solve the following coding problem using the programming language python:
The GoC Timber Mafia is notorious for its deforestation
activities in the forests near Siruseri. These activities have
increased multifold after the death of the bandit who used to
lord over these jungles. Having lost the battle to prevent the
... | ```python
# cook your dish here
from sys import stdin
n, m = map(int,stdin.readline().split())
forest=[]
matrix=[]
for _ in range(n):
forest.append(list(map(int,stdin.readline().split())))
matrix.append([0]*m)
matrix[0][0]=forest[0][0]
for j in range(1,m):
matrix[0][j]=matrix[0][j-1]+forest[0][j]
for i in range(1,n)... | vfc_5054 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/TIMBER",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4\n3 4 15 23\n14 20 12 9\n3 8 12 15\n12 20 7 5\n2\n2 2 3 4\n4 2 4 2\n",
"output": "76\n20\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1554 | Solve the following coding problem using the programming language python:
Meliodas and Ban are fighting over chocolates. Meliodas has $X$ chocolates, while Ban has $Y$. Whoever has lesser number of chocolates eats as many chocolates as he has from the other's collection. This eatfest war continues till either they hav... | ```python
from math import *
t=int(input())
for i in range(t):
m,b=input().split()
m=int(m)
b=int(b)
print(2*gcd(m,b))
``` | vfc_5058 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SINS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 3\n10 10\n4 8\n",
"output": "2\n20\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1555 | Solve the following coding problem using the programming language python:
Chef is interested to solve series problems. Chef wants to solve a series problem but he can't
solve it till now.Can you help Chef to solve the series problem?
- In series problem, the series goes as follows 1,9,31,73,141 . . . . . . . .
Your ... | ```python
# cook your dish here
try:
for t in range(int(input())):
n=int(input())
ans=n*n*n+((n-1)**2)
if ans<=10**9+7:
print(ans)
else:
print(ans)%(10**9+7)
except:
pass
``` | vfc_5062 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NOOB2020/problems/NBC004",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n8\n10\n",
"output": "561\n1081\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1556 | Solve the following coding problem using the programming language python:
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cas... | ```python
for _ in range(int(input())):
n = int(input())
num = ""
val = 1
for i in range(n):
num += str(val)
if val == 1:
val = 0
else:
val = 1
for i in range(n):
print(num)
``` | vfc_5066 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2021/problems/ITGUY55",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "1\n10\n10\n101\n101\n101\n1010\n1010\n1010\n1010\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1557 | Solve the following coding problem using the programming language python:
Chef usually likes to play cricket, but now, he is bored of playing it too much, so he is trying new games with strings. Chef's friend Dustin gave him binary strings $S$ and $R$, each with length $N$, and told him to make them identical. However... | ```python
for _ in range(int(input())):
length = int(input())
S = input()
R = input()
if S.count("1") == R.count("1"):
print("YES")
else:
print("NO")
``` | vfc_5070 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PLAYSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n11000\n01001\n3\n110\n001\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1558 | Solve the following coding problem using the programming language python:
Anas is playing an amazing game on a grid with $N$ rows and $M$ columns. The rows are numbered $1$ through $N$ from top to bottom and the columns are numbered $1$ through $M$ from left to right.
Anas wants to destroy this grid. To do that, he wa... | ```python
"""
Code chef problem DESTCELL, Destroy Cells
"""
def find_destroyed_cells(cell_advance, n, m, k):
row = 1
col = 1
destroyed_cells = {(1, 1)}
while True:
row, col = cell_advance(row, col, n, m, k)
if row <= n and col <= m:
destroyed_cells.add((row, col))
else:
break
return destroyed_cells
... | vfc_5074 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DESTCELL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3\n",
"output": "6 4 3 3 2 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1559 | Solve the following coding problem using the programming language python:
Scheme? - Too loudly said. Just a new idea. Now Chef is expanding his business. He wants to make some new restaurants in the big city of Lviv. To make his business competitive he should interest customers. Now he knows how. But don't tell anyone... | ```python
r = 1000000007
t = int(input())
for i in range(t):
n = int(input())
print(pow(3,n,r) + pow(-1,n)*3)
``` | vfc_5078 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/OCT12/problems/NEWSCH",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n5\n",
"output": "12\n24\n240\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1560 | Solve the following coding problem using the programming language python:
Chef has an array A consisting of N integers. He also has an intger K.
Chef wants you to find out number of different arrays he can obtain from array A by applying the following operation exactly K times.
- Pick some element in the array and mu... | ```python
fact = []
fact.append(1)
for i in range(1,100001):
fact.append((i*fact[i-1])%1000000007)
def power(a,b,p):
x=1
y=a
while(b>0):
if(b%2 == 1):
x=(x*y)
if(x>p):
x=x%p
y=(y*y)
if(y>p):
y=y%p
b=b/2
return x
def inverse(N,p):
return power(N,p-2,p)
def combination(N,R,p):
return (... | vfc_5082 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/JUNE16/problems/CHEFARK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3\n100\n3 1\n1 2 1\n3 2\n1 2 1\n",
"output": "1\n3\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1561 | Solve the following coding problem using the programming language python:
Chef Tobby asked Bhuvan to brush up his knowledge of statistics for a test. While studying some distributions, Bhuvan learns the fact that for symmetric distributions, the mean and the median are always the same.
Chef Tobby asks Bhuvan out for a... | ```python
x=int(input())
for a in range(x):
n=int(input())
L=[str(n)]
c=1
while(len(L)!=n):
L.append(str(n+c))
if len(L)==n:
break
L.append(str(n-c))
c+=1
a=" ".join(L)
print(a)
``` | vfc_5086 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK86/problems/LIKECS02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n2\n3\n",
"output": "1\n1 2\n1 2 3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1562 | Solve the following coding problem using the programming language python:
"I'm a fan of anything that tries to replace actual human contact." - Sheldon.
After years of hard work, Sheldon was finally able to develop a formula which would diminish the real human contact.
He found k$k$ integers n1,n2...nk$n_1,n_2...n_k... | ```python
t = int(input())
def conv(n):
k = bin(n)
k = k[2:]
z = len(k)
c = '1'*z
if c == k:
return False
def find(n):
x = bin(n)[2:]
str = ''
for i in x[::-1]:
if i == '0':
str+='1'
break
else:
str+='0'
return int(str[::-1],2)
for i in range(t):... | vfc_5090 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUMNCR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1\n5\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1563 | Solve the following coding problem using the programming language python:
A reversed arabic no is one whose digits have been written in the reversed order. However in this any trailing zeroes are omitted. The task at hand here is a simple one. You need to add two numbers which have been written in reversed arabic and ... | ```python
n = int(input())
for index in range(0, n):
a, b = list(map(str, input().split()))
a = int(a[::-1])
b = int(b[::-1])
a = str(a + b)
a = int(a[::-1])
print(a)
``` | vfc_5094 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ADR2012/problems/A112",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n24 1\n",
"output": "34\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1564 | Solve the following coding problem using the programming language python:
Sergey recently learned about country codes - two letter strings, denoting countries. For example, BY stands for Belarus and IN stands for India. Mesmerized by this new discovery, Sergey now looks for country codes everywhere!
Sergey has recentl... | ```python
#import set
t = eval(input())
while(t):
s = input()
set1 = set()
j = 0
for i in s[:-1]:
a = s[j:j+2]
set1.add(a)
j = j + 1
print(str(len(set1)) + '\n')
t= t-1
``` | vfc_5098 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LTIME31/problems/DISTCODE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nINBY\nBYBY\n",
"output": "3\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1565 | Solve the following coding problem using the programming language python:
Suppose there is a X x Y x Z 3D matrix A of numbers having coordinates (i, j, k) where 0 ≤ i < X, 0 ≤ j < Y, 0 ≤ k < Z. Now another X x Y x Z matrix B is defined from A such that the (i, j, k) element of B is the sum of all the the numbers in A ... | ```python
# Problem: http://www.codechef.com/JULY09/submit/CUBESUM/
# Author: Susam Pal
def computeA():
X, Y, Z = [int(x) for x in input().split()]
B = []
for x in range(X):
B.append([])
for y in range(Y):
B[-1].append([int(t) for t in input().split()])
for z in range(Z):
result = B[x][y][z]
if x... | vfc_5102 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/JULY09/problems/CUBESUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 1 1\n1\n8\n22\n1 2 3\n0 9 13\n18 45 51\n",
"output": "1\n7\n14\n0 9 4\n18 18 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1566 | Solve the following coding problem using the programming language python:
A matrix B (consisting of integers) of dimension N × N is said to be good if there exists an array A (consisting of integers) such that B[i][j] = |A[i] - A[j]|, where |x| denotes absolute value of integer x.
You are given a partially filled mat... | ```python
import sys
sys.setrecursionlimit(1000000)
mod = 10**9 + 7
ts = int(input())
while ts > 0:
n,q = list(map(int,input().split()))
ncc = n-1
par = [i for i in range(n)]
rank = [1]*n
xor = [0]*n
flag = 1
def find(a):
if par[a] == a:
return a
else:
temp = find(par[a])
xor[a]^=xor[par[a]]
pa... | vfc_5106 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FILLMTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 2\n1 1 0\n1 2 1\n2 3\n1 1 0\n1 2 1\n2 1 0\n3 2\n2 2 0\n2 3 1\n3 3\n1 2 1\n2 3 1\n1 3 1\n",
"output": "yes\nno\nyes\nno\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1567 | Solve the following coding problem using the programming language python:
Ashley likes playing with strings.
She gives Mojo a fun problem to solve. In her imaginary string world, a string of even length is called as "Doublindrome" if both halves of the string are palindromes (both halves have length equal to half of ... | ```python
for _ in range(int(input())):
n=int(input())
s=input()
d={}
for j in s:
if j not in d:
d[j]=1
else:
d[j]+=1
f=0
for j in d:
if(d[j]%2==1):
f=f+1
if((n//2)%2==0 and f==0):
print("YES")
continue
if((n//2)%2==1 and f<=2 and f%2==0):
print("YES")
continue
print("NO")
``` | vfc_5110 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NCC2020/problems/NCC002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n8\nabbacddc\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1568 | Solve the following coding problem using the programming language python:
Dhote and Shweta went on a tour by plane for the first time.Dhote was surprised by the conveyor belt at the airport.As Shweta was getting bored Dhote had an idea of playing a game with her.He asked Shweta to count the number of bags whose indiv... | ```python
t=int(input())
for _ in range(t):
size=int(input())
li=list(map(int,input().split()))
c = 0
for i in li:
if(i >=len(li)/2):
c += 1
print(c)
``` | vfc_5114 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INEK2019/problems/IF10",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n1 2 3 4\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1569 | Solve the following coding problem using the programming language python:
Dio Brando has set a goal for himself of becoming the richest and the most powerful being on earth.To achieve his goals he will do anything using either manipulation,seduction or plain violence.
Only one guy stands between his goal of conquerin... | ```python
# cook your dish here
import sys
import math
from collections import Counter
from collections import OrderedDict
def inputt():
return sys.stdin.readline().strip()
def printt(n):
sys.stdout.write(str(n)+'\n')
def listt():
return [int(i) for i in inputt().split()]
def gcd(a,b):
return math.gcd(... | vfc_5118 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CSEP2020/problems/JOJOA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\nabcdfgh\nurdrdrav\njojojojoj\nbbbbaaa\ncddfsccs\ntttttttttttt\n",
"output": "1234678\n2118418418122\n1015\n21\n46193\n20\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1570 | Solve the following coding problem using the programming language python:
The chef is placing the laddus on the large square plat. The plat has the side of length N. Each laddu takes unit sq.unit area. Cheffina comes and asks the chef one puzzle to the chef as, how many squares can be formed in this pattern with all s... | ```python
# cook your dish here
t = int(input())
while t:
m = int(input())
print(int(m * (m + 1) * (2 * m + 1) / 6))
t -= 1
``` | vfc_5122 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK12020/problems/ITGUY18",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "1\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1571 | Solve the following coding problem using the programming language python:
Chef is making polygon cakes in his kitchen today!
Since the judge panel is very strict, Chef's cakes must be beautiful and have sharp and precise $internal$ angles in arithmetic progression.
Given the number of sides, $N$, of the cake Chef is... | ```python
# cook your dish here
import math
T = int(input())
for _ in range(T):
N, A, K = map(int, input().split(" "))
total = (N-2) * 180
diffT = total - N*A
diffN = sum(range(1,N))
r = (A*diffN+(K-1)*diffT)
d = math.gcd(r, diffN)
while d > 1:
r//=d
diffN//=d
d = math.gcd(r, diffN)
print(r, diffN)
``` | vfc_5126 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PCJ18C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 30 2\n",
"output": "60 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1572 | Solve the following coding problem using the programming language python:
Indian National Olympiad in Informatics 2016
Boing Inc, has N employees, numbered 1 ... N. Every employee other than Mr. Hojo (the head of the company) has a manager (P[i] denotes the manager of employee i). Thus an employee may manage any numb... | ```python
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
arr=[int(x) for x in input().split()]
if arr[0]==1:
print(0)
return
p=[None]
for i in range(1,arr[0]+1):
p.append(arr[i])
a=[None]
for i in range(arr[0]+1,2*arr[0]+1):
... | vfc_5130 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INOIPRAC/problems/INOI1601",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5 10 6 12 2 -1 4 2\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1573 | Solve the following coding problem using the programming language python:
A tennis tournament is about to take place with $N$ players participating in it.
Every player plays with every other player exactly once and there are no ties. That is, every match has a winner and a loser.
With Naman's birthday approaching, he... | ```python
# cook your dish here
a = int(input())
for i in range(a):
n = int(input())
if n%2==0:
print('NO')
else:
print('YES')
for i1 in range(n):
li = [0]*n
b = str()
for i2 in range((n-1)//2):
li[(i1+i2+1)%n]+=1
for i3 in range(len(li)):
b+=str(li[i3])
print(b)
``` | vfc_5134 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EXUNB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2\n",
"output": "YES\n010\n001\n100\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1574 | Solve the following coding problem using the programming language python:
You like tracking airplane flights a lot. Specifically, you maintain history of an airplane’s flight at several instants and record them in your notebook. Today, you have recorded N such records h1, h2, ..., hN, denoting the heights of some airp... | ```python
def f(n):
s = list(map(int, input().split()))
low = []
high = []
for i in range(n - 1):
low.append(min(s[i], s[i+1]))
high.append(max(s[i], s[i+1]))
low.sort()
high.sort()
curr = mx = 0
i = j = 0
n -= 1
while i < n and j < n:
if low[i] < high[j]:
i += 1
curr += 1
else:
j += 1
c... | vfc_5138 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLYMODE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 2 3\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1575 | Solve the following coding problem using the programming language python:
You must have tried to solve the Rubik’s cube. You might even have succeeded at it. Rubik’s cube is a 3x3x3 cube which has 6 different color for each face.The Rubik’s cube is made from 26 smaller pieces which are called cubies. There are 6 cubie... | ```python
for _ in range(int(input())):
m=int(input())
n=int(input())
o=int(input())
ans=4*(m+n+o)-24
if(ans <= 0):
print('0')
else:
print(ans)
``` | vfc_5142 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INLO2016/problems/INLO22",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n3\n3\n",
"output": "12\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1576 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
# cook your dish here
for a0 in range(int(input())):
n = int(input())
l = []
for i in range(1,n+1):
l.append(i)
for j in range(n):
s = ""
for k in l:
s+=str(k)
print(s)
x = l[0]
l.pop(0)
l.append(x)
``` | vfc_5146 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY39",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n4\n",
"output": "12\n21\n123\n231\n312\n1234\n2341\n3412\n4123\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1577 | Solve the following coding problem using the programming language python:
You are given $N$ gears numbered $1$ through $N$. For each valid $i$, gear $i$ has $A_i$ teeth. In the beginning, no gear is connected to any other. Your task is to process $M$ queries and simulate the gears' mechanism. There are three types of ... | ```python
class Dsu:
def __init__(self, v, s):
self.par = s
self.v = v
self.dr = [1] * v
self.zero = [False] * v
self.speed = []
for i in range(v):
self.speed.append([])
self.speed[i].append(i)
def find(self, i):
# if parent[i] == ... | vfc_5150 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GEARS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 10\n6 8 10 13\n3 1 2 2\n2 1 2\n3 1 2 3\n2 2 3\n1 1 7\n3 1 3 10\n2 3 1\n3 1 3 2\n2 1 4\n3 1 4 6\n\n",
"output": "0\n-9/4\n7/1\n0\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1578 | Solve the following coding problem using the programming language python:
Given an alphanumeric string made up of digits and lower case Latin characters only, find the sum of all the digit characters in the string.
-----Input-----
- The first line of the input contains an integer T denoting the number of test cases. ... | ```python
for _ in range(eval(input())):
s = input()
ans = 0
for i in s:
if i.isdigit():
ans += int(i)
print(ans)
``` | vfc_5154 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/TSTIND16/problems/KOL15A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nab1231da\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1579 | Solve the following coding problem using the programming language python:
You are given an integer sequence $A_1, A_2, \ldots, A_N$. For any pair of integers $(l, r)$ such that $1 \le l \le r \le N$, let's define $\mathrm{OR}(l, r)$ as $A_l \lor A_{l+1} \lor \ldots \lor A_r$. Here, $\lor$ is the bitwise OR operator.
I... | ```python
for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
if n<=62:
st = set()
for i in range(n):
curr = 0
for j in range(i,n):
curr = curr|arr[j]
st.add(curr)
if len(st)==n*(n+1)//2:
print("YES")
else:
print("NO")
else:
print("NO")
``` | vfc_5158 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ORTHODOX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3\n1 2 7\n2\n1 2\n3\n6 5 8\n5\n12 32 45 23 47\n",
"output": "NO\nYES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1580 | Solve the following coding problem using the programming language python:
In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (bl... | ```python
import sys
t=int(input())
x=sys.stdin.readlines()
l=[]
for s in x:
s=s.replace(".","")
s=s.replace("'","")
s=s.replace(",","")
s=s.replace(":","")
s=s.replace(";","")
lst=[str(i) for i in s.split()]
for j in lst:
l.append(j)
m=[]
for y in l:
z=y.lower()
m.append(z)
... | vfc_5162 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/WORDLIST",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nThis is a sample piece of text to illustrate this\nproblem.\n",
"output": "10\na\nillustrate\nis\nof\npiece\nproblem\nsample\ntext\nthis\nto\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1581 | Solve the following coding problem using the programming language python:
Kajaria has an empty bag and 2 types of tiles -
tiles of type $1$ have the number $X$ written and those of type $2$ have the number $Y$ written on them. He has an infinite supply of both type of tiles.
In one move, Kajaria adds exactly $1$ tile... | ```python
# cook your dish here
t=int(input())
MOD=1000000007
def mod(n, m=MOD):
n%=m
while n<0: n+=m
return n
def power(n, p):
res=1
while p:
if p%2: res=mod(res*n)
p//=2
n=mod(n*n)
return res
while t:
ma=input().split()
x=int(ma[0])
y=int(ma[1])
s=int(ma[2])
ma=input().split()
u=int(ma[0])
v=int(... | vfc_5166 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TILEBAG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3 96\n1 3\n",
"output": "48\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1582 | Solve the following coding problem using the programming language python:
There are n cards of different colours placed in a line, each of them can be either red, green or blue cards. Count the minimum number of cards to withdraw from the line so that no two adjacent cards have the same colour.
-----Input-----
- The ... | ```python
# cook your dish here
n = int(input())
s = [i for i in input()]
count = 0
for i in range(1,n):
if s[i] == s[i-1]:
count += 1
else:
continue
print(count)
``` | vfc_5170 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COTH2020/problems/MINCARDS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\nRGGBG\nSample Input 2:\n5\nRRRRR\nSample Input 3:\n2\nBB\n",
"output": "1\nSample Output 2:\n4\nSample Output 3:\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1583 | Solve the following coding problem using the programming language python:
Devu loves to play with his dear mouse Jerry. One day they play a game on 2 dimensional grid of dimensions n * n (n ≥ 2). Jerry is currently at coordinates (sx, sy) and wants to move to location (ex, ey) where cheese is placed by Devu. Also Dev... | ```python
import sys
def _r(*conv) :
r = [conv[i](x) for i, x in enumerate(input().strip().split(' '))]
return r[0] if len(r) == 1 else r
def _ra(conv) :
return list(map(conv, input().strip().split(' ')))
def _rl() :
return list(input().strip())
def _rs() :
return input().strip()
def _a(k, *v) :
return all(x... | vfc_5174 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DEVJERRY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 1 1 2 2 1 2\n3 1 1 1 3 1 2\n",
"output": "2\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1584 | Solve the following coding problem using the programming language python:
-----Problem Statement-----
You all must have played the game candy crush. So here is a bomb which works much the fruit bomb in candy crush. A designer, Anton, designed a very powerful bomb. The bomb, when placed on a location $(x, y)$ in a $R \... | ```python
r,c,n = map(int , input().split());coordinates = [];coordinates_1,coordinates_2 = {},{}
for _ in range(n):
x,y = map(int , input().split())
coordinates.append([x,y])
for i in coordinates:
if(i[0] in coordinates_1): coordinates_1[i[0]] += 1
else: coordinates_1[i[0]] = 1
if(i[1] in coordina... | vfc_5178 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SCAT2020/problems/SC_03",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 3 3\n1 1\n0 0\n0 2\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1585 | Solve the following coding problem using the programming language python:
Chef is now a corporate person. He has to attend office regularly. But chef does not want to go to office, rather he wants to stay home and discover different recipes and cook them.
In the office where chef works, has two guards who count how m... | ```python
# cook your dish here
for _ in range(int(input())):
x, y= map(int, input().split())
print(max(x,y), x+y)
``` | vfc_5182 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/REMISS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n19 17\n",
"output": "19 36\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.