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 | 586 | Solve the following coding problem using the programming language python:
Teacher Sungjae wanted to hold a programming competition for his students where every participant need to be included into team. The participants submitted their team names before the deadline. After the competition ran for half an hour, (It is... | ```python
# cook your dish here
for t in range(int(input())):
n,k=map(int,input().split())
a=[]
sr=[]
for i in range(k):
x,y=input().split()
y=int(y)
a.append([10**10-y,x])
sr.append(sorted(x))
for i in range(n-k):
x,y=input().split()
y=int(y)
... | vfc_1186 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BLAS2020/problems/TM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10 5\namigoes 1\nbannermen 1\nmonarchy 4\noutliers 5\niniciador 10\naegimos 2\niiiacdnor 1\neilorstu 1\ngimosae 3\nmnachroy 7\n",
"output": "iniciador 11\nmonarchy 11\namigoes 6\noutliers 6\nbannermen 1\n",
"type": ... |
apps | verifiable_code | 587 | Solve the following coding problem using the programming language python:
On a planet called RUIZ LAND, which is ruled by the queen, Erika Ruiz. Each person on that planet has a strength value (strength value >0).
That planet has a special rule made by the queen that a boy and a girl will form a couple if their Hate v... | ```python
n=int(input())
a=list(map(int,input().split()))
c=[]
for i in range(len(a)):
if a[i]==2:
c.append(1)
else:
c.append(a[i]^2)
print(*c)
``` | vfc_1190 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INRO2021/problems/COUPLING",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10 16\n",
"output": "8 18\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 588 | Solve the following coding problem using the programming language python:
Vasya has ordered a pizza delivery. The pizza can be considered a perfect circle. There were $n$ premade cuts in the pizza when it was delivered. Each cut is a straight segment connecting the center of the pizza with its boundary.
Let $O$ be the... | ```python
def gcd(a, b):
if a == 0:
return b
return(gcd(b % a, a))
t = int(input())
for T in range(t):
n = int(input())
l = [int(x) for x in input().split()]
ang = []
for i in range(1, n):
ang.append(l[i] - l[i - 1])
ang.append(360 - (l[-1] - l[0]))
ang.sort()
if ang == ang[::-1]:
print(0)
continue
... | vfc_1194 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CUTPIZ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n0 90 180 270\n2\n90 210\n2\n0 1\n",
"output": "0\n1\n358\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 589 | Solve the following coding problem using the programming language python:
Digory Kirke and Polly Plummer are two kids living next door to each other. The attics of the two houses are connected to each other through a passage. Digory's Uncle Andrew has been secretly doing strange things in the attic of his house, and h... | ```python
# cook your dish here
for i in range(int(input())):
s = input()
m = 0
p = 0
d = 0
l = []
for i in range(len(s)):
if(s[i] == "."):
m = m+1
elif(s[i] == "#"):
l.append(m)
m=0
for i in range(len(l)):
if(l[i]>p):
p = l[i]
d = d+1
print(d)
``` | vfc_1198 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ATTIC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n####\n##.#..#\n##..#.#\n##.#....#\n",
"output": "0\n2\n1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 590 | Solve the following coding problem using the programming language python:
Chef has an array A consisting of N integers (1-based indexing). He asks you to perform the following operation M times:
for i = 2 to N:
Ai = Ai + Ai-1
Your task is to find the xth element of the array (i.e., Ax) after performing the above ... | ```python
for _ in range(int(input())):
n,x,m = map(int,input().split())
a = list(map(int,input().split()))
for _ in range(m):
for i in range(1,n):
a[i] = a[i] + a[i-1]
print(a[x-1]%(10**9+7))
``` | vfc_1202 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/STROPR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 2 3\n1 2 3\n3 3 3\n1 2 3\n",
"output": "5\n15\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 591 | Solve the following coding problem using the programming language python:
Ganesh lives in Gopalmath. He is looking for Jojo. So he decides to collect Aadhar Card Information of all the citizens of India from UIDAI.
Someone told Ganesh that the sum of all the digits of Jojo’s Aadhar number is divisible by 10 and it is ... | ```python
for _ in range(int(input())):
N = input()
num = list(N)
s=0
for n in num:
if n.isnumeric():
s+=int(n)
#print(s)
x=(10-s%10)%10
print(int(N)*10+int(x))
``` | vfc_1206 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CORS2020/problems/JOJO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n",
"output": "37\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 592 | Solve the following coding problem using the programming language python:
Teddy and Tracy like to play a game based on strings. The game is as follows. Initially, Tracy writes a long random string on a whiteboard. Then, each player starting with Teddy makes turn alternately. Each turn, the player must erase a contiguo... | ```python
import sys
def mex(S,W,C,start,end):
"""Returns Nim-number of S[start:end]"""
key=(start,end)
try:
return C[key]
except KeyError:
pass
A=set()
for s in range(start,end):
for e in range(start+1,end+1):
if S[s:e] not in W: continue
A.add(m... | vfc_1210 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC10/problems/ASTRGAME",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\ncodechef\n2\ncode\nchef\nfoo\n1\nbar\nmississippi\n4\nssissi\nmippi\nmi\nppi\n\n\n",
"output": "Tracy\nTracy\nTeddy\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 593 | Solve the following coding problem using the programming language python:
Mathison recently inherited an ancient papyrus that contained some text. Unfortunately, the text was not a
pangram. Now, Mathison has a particular liking for holoalphabetic strings and the text bothers him. The good news is that Mathison can buy... | ```python
# cook your dish here
# cook your dish here
for i in range(int(input())):
a=list(map(int,input().split()))
x=input()
t=0
for i in range(ord('a'),ord('z')+1):
if chr(i) not in x:
t+=a[i-97]
print(t)
``` | vfc_1214 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MATPAN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26\nabcdefghijklmopqrstuvwz\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26\nthequickbrownfoxjumpsoverthelazydog\n",
"output": "63\n0\... |
apps | verifiable_code | 594 | Solve the following coding problem using the programming language python:
You are given a sequence of integers $A_1,A_2,…,A_N$ and a magical non-zero integer $x$
You have to select a subsegment of sequence A (possibly empty), and replace the elements in that subsegment after dividing them by x.
Formally, replace any o... | ```python
def solve(a,n):
max1=curr=a[0]
for i in range(1,n):
curr=max(a[i],curr+a[i])
max1=max(max1,curr)
return max1
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
print(sum(a)-solve(a,n)+solve(a,n)/k)
``` | vfc_1218 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SMALLARR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\n1 -2 3\n",
"output": "0.5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 595 | Solve the following coding problem using the programming language python:
You are given a string $S$. Find the number of ways to choose an unordered pair of non-overlapping non-empty substrings of this string (let's denote them by $s_1$ and $s_2$ in such a way that $s_2$ starts after $s_1$ ends) such that their concat... | ```python
def binarySearch(arr, l, r, x):
mid=0
while l <= r:
mid = l + (r - l)//2;
if arr[mid] == x:
return mid+1
elif arr[mid] < x:
l = mid + 1
else:
r = mid - 1
if mid!=len(arr):
if arr[mid]<x:
return mid+1
return mid
s=input()
strt=[]
end=[]
plc=[]
landr=[]
l2r=[]
lr=[]
ans=0
n=len(s... | vfc_1222 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/KLPM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "abba\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 596 | Solve the following coding problem using the programming language python:
Chef is playing a game on the non-negative x-axis. It takes him $1$ second to reach from $i^{th}$ position to $(i-1)^{th}$ position or $(i+1)^{th}$ position. The chef never goes to the negative x-axis. Also, Chef doesn't stop at any moment of ti... | ```python
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def MI(): return map(int,... | vfc_1226 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/RC122020/problems/RECNDNUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n0 1\n1 1\n2 1\n1 3\n4 6\n",
"output": "0\n1\n4\n5\n46\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 597 | Solve the following coding problem using the programming language python:
Chef Ada is building a new restaurant in the following way:
- First, $N$ points $X_1, X_2, \ldots, X_N$ are chosen on the $x$-axis.
- Then, $N$ columns (numbered $1$ through $N$) are made. For simplicity, the columns are represented as vertical ... | ```python
# cook your dish here
t = int(input())
for _ in range(t):
n = int(input())
a = []
b = []
for i in range(n):
x,y = list(map(int, input().split()))
a.append(x)
b.append(y)
b.sort()
xcor = []
xcor.append(a[1]-a[0])
xcor.append(a[n-1]-a[n-2])
for i in range(1,n-1):
xcor.append(a[i+1]-a[i-1])
xco... | vfc_1230 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BIGRES",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n1 1\n2 2\n3 3\n4 4\n5 5\n",
"output": "27\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 598 | Solve the following coding problem using the programming language python:
Roman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over all Ai is chosen, let's call it MAX. Then Ai =
MAX ... | ```python
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
maximum = max(A)
minimum = min(A)
if k == 0:
for i in A:
print(i, end=' ')
elif k&1:
for i in A:
print(maximum - i, end=' ')
else:
for i in A:
print(i - minimum, end=' ')
``` | vfc_1234 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MAY14/problems/RRSTONE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 1\n5 -1 7 0\n",
"output": "2 8 0 7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 599 | Solve the following coding problem using the programming language python:
Chef just got a box of chocolates as his birthday gift. The box contains $N$ chocolates in a row (numbered $1$ through $N$), where $N$ is even. For each valid $i$, the $i$-th chocolate has a sweetness value $W_i$.
Chef wants to eat all the choco... | ```python
from collections import deque
t=int(input())
for i in range(t):
n=int(input())
N=[i for i in range(1, n+1)]
w=list(map(int, input().split()))
max_sweetness=max(w)
sizes=[]
cnt=0
for i in range(n):
if w[i]!=max_sweetness:
cnt+= 1
else:
sizes.append(cnt)
cnt=0
if cnt!=0:
sizes[0]=(cnt... | vfc_1238 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHCBOX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6\n1 1 2 1 1 1\n6\n1 1 2 1 1 2\n",
"output": "3\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 600 | Solve the following coding problem using the programming language python:
The Fibonacci sequence $F_0, F_1, \ldots$ is a special infinite sequence of non-negative integers, where $F_0 = 0$, $F_1 = 1$ and for each integer $n \ge 2$, $F_n = F_{n-1} + F_{n-2}$.
Consider the sequence $D$ of the last decimal digits of the ... | ```python
import math
t = int(input())
a = [-1, 0, 1]
for i in range(58):
temp = a[-1] + a[-2]
temp = temp%10
a.append(temp)
for _ in range(t):
n = int(input())
temp = len(bin(n)) - 3
temp = 2**temp
temp = temp%60
print(a[temp])
``` | vfc_1242 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FIBEASY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n9\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 601 | Solve the following coding problem using the programming language python:
The bustling town of Siruseri has just one sports stadium. There are a number of schools, colleges, sports associations, etc. that use this stadium as the venue for their sports events.
Anyone interested in using the stadium has to apply to the ... | ```python
# cook your dish here
n=(int(input()))
x=[]
for _ in range(n):
a,b=map(int,input().split())
a=[a,a+b]
x.append(a)
x = sorted(x, key= lambda i:i[1])
y=-1
c=0
for i in range(len(x)):
if x[i][0]>y:
c+=1
y=x[i][1]
print(c)
``` | vfc_1246 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/STADIUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 5\n9 7\n15 6\n9 3\nSample output:\n3\n",
"output": "",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 602 | Solve the following coding problem using the programming language python:
Chef Loves to listen to remix songs, but currently he had already finished the entire playlist of remix songs.
As Chef is smart, so he thought let's make my own remix songs of the original songs.
Chef is not having much knowledge of making remix... | ```python
m= 9999999
word=''
p= ''
try:
s=input().split()
for i in s:
if(len(i) <= m):
m = len(i)
word = i
p = word
for i in s:
p+= (' '+i+' '+ word)
print(p)
except EOFError:
pass
`... | vfc_1250 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/STRG2020/problems/REMIX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "Mai Hu Jiyaan\n",
"output": "Hu Mai Hu Hu Hu Jiyaan Hu\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 603 | Solve the following coding problem using the programming language python:
----- Statement -----
You need to find a string which has exactly K positions in it such that the character at that position comes alphabetically later than the character immediately after it. If there are many such strings, print the one which... | ```python
for i in range(int(input())):
N = int(input())
s = 'zyxwvutsrqponmlkjihgfedcba'
r = ''
while True:
r = s[-N-1:] + r
if N < 26:
break
N -= 25
print(r)
``` | vfc_1254 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DECSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "ba\ncba\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 604 | Solve the following coding problem using the programming language python:
You are given a grid with $R$ rows (numbered $1$ through $R$) and $C$ columns (numbered $1$ through $C$). A cell in row $r$ and column $c$ is denoted by $(r, c)$. Two cells in the grid are adjacent if they have a common side. For each valid $i$ ... | ```python
for _ in range(int(input())):
r,c = map(int,input().split())
l = []
for k in range(r):
a = list(map(int,input().split()))
l.append(a)
ans = "Stable"
for i in range(r):
for j in range(c):
p = l[i][j]
count=0
if i-1>=0 and j>=0:
count+=1
if i>=0 and j-1>=0:
count+=1
if i+1<=... | vfc_1258 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/REACTION",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n1 2 1\n2 3 2\n1 2 1\n3 4\n0 0 0 0\n0 0 0 0\n0 0 4 0\n",
"output": "Stable\nUnstable\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 605 | Solve the following coding problem using the programming language python:
There is a rectangular grid of cells consisting of n rows and m columns.
You will place a robot on one of the grid cells and provide it with a command string s, consisting of characters ‘L’, ‘R’, ‘U’, ‘D’.
After being placed, the robot will foll... | ```python
# cook your dish here
test=int(input())
for _ in range(test):
b=list(map(int,str(input()).split(' ')))
c=str(input())
li1=[0]
li2=[0]
for i1 in range(len(c)):
if c[i1]=='R':
li1.append(li1[len(li1)-1]+1)
elif c[i1]=='L':
li1.append(li1[len(li1)-1]-1)
elif c[i1]=='U':
li2.append(li2[len(li2... | vfc_1262 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ROBOTG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 1\nR\n2 3\nLLRU\n3 2\nLLRU\n4 3\nULURUDRDLD\n3 6\nRURUR\n",
"output": "unsafe\nsafe\nunsafe\nsafe\nsafe\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 606 | Solve the following coding problem using the programming language python:
Consider the infinite x$x$ axis. There are N$N$ impacts on this X-axis at integral points (X1$X_1$,X2$X_2$,....XN$X_N$) (all distinct) . An impact at a point X$X$i propagates such that at a point X$X$0, the effect of the impact is K|Xi−X0|$K^{|... | ```python
# cook your dish here
T = int(input())
for i in range(T):
l = list(map(int, input().split()))
n, k, m, x = l[0], l[1], l[2], l[3]
if k == 1:
if n == m:
print("yes")
else:
print("no")
elif m % k > 1:
print("no")
elif k == 2:
stack = []... | vfc_1266 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/IMPACT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 3 10 10\n2 3 10 10\n",
"output": "no\nyes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 607 | Solve the following coding problem using the programming language python:
You are given a sequence $A_1, A_2, \ldots, A_N$. You have to split the array into maximum number of non-empty subarrays such that the gcd of elements of each subarray is equal to 1.
-----Input:-----
- The first line of the input contains a sin... | ```python
'''input
2
3
2 2 3
4
2 3 3 2
'''
import math
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 0
while i < len(a):
if a[i] == 1:
count += 1
i += 1
continue
curr_gcd = a[i]
while i < len(a) and curr_gcd != 1:
curr_gcd = math.gcd(curr_gcd, a... | vfc_1270 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DECO2020/problems/DECOGCD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n2 2 3\n4\n2 3 3 2\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 608 | Solve the following coding problem using the programming language python:
Abhi Ram analyses london stock exchange and invests in a software company C-.gate . He wants to sell his shares after 5 weeks.
Given the investment m, increase or decrease of share prices of 5 weeks(+/- pi) , help him to calculate his net prof... | ```python
for i in range(int(input())):
n = int(input())
P = list(map(float, input().split()))
pr = 1
for p in P:
a = 100+p
pr = (pr*a)/100
pr = (pr-1)*100
x = 6-len(str(int(abs(pr))))
if (x==1):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.1f" % round(pr,x)))
els... | vfc_1274 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ITRA2016/problems/ITRA03",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10000\n+5 -3 -2 +10 +15\n6256250\n-24 +22 +4 -16 +20\n",
"output": "+26.2634\n-2.79977\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 609 | Solve the following coding problem using the programming language python:
Chef published a blog post, and is now receiving many queries about it. On day $i$, he receives $Q_i$ queries. But Chef can answer at most $k$ queries in a single day.
Chef always answers the maximum number of questions that he can on any given... | ```python
# cook your dish here
t=int(input())
while(t):
t=t-1
n,k=list(map(int,input().split()))
q=list(map(int,input().split()))
days,rem=0,0
for i in range(n):
rem+=q[i]
if(rem>=k):
rem-=k
else:
days=i+1
break
days+=1
if(rem>=k):
days+=(rem//k)+1
print(days)
``` | vfc_1278 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFEZQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 5\n10 5 5 3 2 1\n1 1\n100\n",
"output": "6\n101\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 610 | Solve the following coding problem using the programming language python:
Due to the COVID pandemic, people have been advised to stay at least $6$ feet away from any other person. Now, people are lining up in a queue at the local shop and it is your duty to check whether they are all following this advice.
There are a... | ```python
# cook your dish here
t=int(input())
while t>0:
n=int(input())
l=list(map(int,input().split()))
l1=[]
c=1
for i in range(len(l)):
if l[i]==1:
l1.append(i)
for j in range(len(l1)-1):
if l1[j+1]-l1[j]<6:
c=0
break
if c:
prin... | vfc_1282 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/COVIDLQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1 0 1\n7\n1 0 0 0 0 0 1\n11\n0 1 0 0 0 0 0 1 0 0 1\n\n",
"output": "NO\nYES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 611 | Solve the following coding problem using the programming language python:
"What do you know about happiness?" — Yoda
Chef is happy only if three conditions hold:
- Chef finished cooking a delicious meal
- Chef got AC for a programming problem with an almost correct code
- Chef got a new problem with a sequence of int... | ```python
# cook your dish here
t=int(input())
for i in range(t):
n=int(input())
a=list(map(int,input().split()))
d={}
for i in range(n):
if a[i]-1 not in d:
d[a[i]-1]=[i]
else:
d[a[i]-1].append(i)
ans=False
d1={}
for i in d:
if ans==True:
break
for j in d:
if i!=j:
if a[i]==a[j] and ... | vfc_1286 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHHAPPY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n1 1 2 3\n4\n2 1 3 3\n5\n5 4 4 3 1\n5\n3 2 1 1 4\n",
"output": "Truly Happy\nPoor Chef\nPoor Chef\nTruly Happy\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 612 | Solve the following coding problem using the programming language python:
Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'.
Now since chef is not... | ```python
# cook your dish here
t=int(input())
for i in range(t):
s=input()
fl=-1
n=len(s)
for i in range(n-2):
if(s[i:i+3]=="010" or s[i:i+3]=="101"):
fl=0
print("Good")
break
if(fl==-1):
print("Bad")
``` | vfc_1290 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ERROR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n11111110\n10101010101010\n",
"output": "Bad\nGood\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 613 | Solve the following coding problem using the programming language python:
-----Problem-----
Nikki's latest work is writing a story of letters. However, she finds writing story so boring that, after working for three hours, she realized that all she has written are M long words consisting entirely of letters A and ... | ```python
def check(s):
arr=[s[0]]
l=len(s)
f1=0
for i in range(1,l):
if arr==[]: arr.append(s[i])
elif arr[-1]!=s[i]:arr.append(s[i])
else: del arr[-1]
if arr==[]: return True
else: return False
count = 0
for t in range(eval(input())):
s=input().strip()
if check(s): count+=1
print(count)
``` | vfc_1294 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMN2016/problems/NIKKLIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nABAB\nAABB\nABBA\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 614 | Solve the following coding problem using the programming language python:
Chef would like go shopping to buy ingredients for his special dish. The local grocery store has some special discount offers. If you want to buy some set of ingredients you will pay for all ingredients except the cheapest one. Chef would like t... | ```python
from itertools import permutations as p
def disc(a,b):
for ai in a:
for bi in b:
if ai==bi:
return False
return True
for i in range(eval(input())):
n = eval(input())
arr = list(map(int,input().split()))
perms = list(p(arr))
m = eval(input())
offer = {}
for i in range(m):
dup = list(map(int... | vfc_1298 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NOV15/problems/CHEFSHOP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n1 2 3 4\n3\n2 1 2\n2 3 4\n3 1 2 3\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 615 | Solve the following coding problem using the programming language python:
Nexus 4.O is going to be organized by ASME, GLA University. Shubhanshu, Head of Finance Team is working for it. He has $N$ number of bills of different values as $a$$1$,$ a$$2$, $a$$3$…$a$$n$.
He is interested in a game in which one has to do th... | ```python
t=int(input())
for i in range(t):
l=list(map(int,input().split(' ')))
a=l[0]
b=l[1]
l1=list(map(int,input().split(' ')))
for i in range(b):
l2=list(map(int,input().split(' ')))
a1=l2[0]
b1=l2[1]
su=0
for j in range(a1-1,b1):
su=(su+l1[j])%1000000000
print(su)
``` | vfc_1302 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/REER2020/problems/NXS4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n8 3\n1 2 3 4 5 6 7 8\n2 3\n1 6\n5 8\n",
"output": "5\n21\n26\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 616 | Solve the following coding problem using the programming language python:
There are $M$ levels for a building numbered from $1$ to $M$ from top to bottom, each level having $N$ parking spots numbered from $1$ to $N$ from left to right. Some spots might have a car while other may be empty, the information of which is g... | ```python
from sys import stdin
for _ in range(int(stdin.readline())):
m, n = list(map(int, stdin.readline().split()))
final = []
arr = []
val = 0
extra = 0
for j in range(m):
ans = list(map(str, stdin.readline().split()))
if ans.count('N') == n:
val += 1
else:
if val%2 == 0:
arr.append(ans)
... | vfc_1306 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CHPTRS01/problems/CARLOT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 5\nN P N N P\nN N P N N\nN P N N N\nP N N N N\n3 3\nN P P\nP P P\nP P N\n",
"output": "10\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 617 | Solve the following coding problem using the programming language python:
We all know that Share market is place where drastic change occurs within moments. So we have one Stockholder, Isabella, who wants to maximize her profit by selling her shares. She has $N$ shares of a Doofenshmirtz Corporation which is represent... | ```python
def CeilIndex(A, l, r, key):
while (r - l > 1):
m = l + (r - l)//2
if (A[m] >= key):
r = m
else:
l = m
return r
def LongestIncreasingSubsequenceLength(A, size):
# Add boundary case,
# when array size is one
tail... | vfc_1310 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CACD2020/problems/STOCKMAX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n1 2\n4 3\n3 5\n2 4\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 618 | Solve the following coding problem using the programming language python:
Dexter, being irritated by DD, gave her a lucrative game to play to keep her busy.
There are $N$ bags numbered $1$ to $N$. The $i_{th}$ bag contains $A_i$ coins. The bags are placed in a circular order such that the $N_{th}$ bag is adjacent to t... | ```python
t=int(input())
for i in range(t):
n,k=list(map(int,input().split(" ")))
arr=list(map(int,input().strip().split(" ")))[:n]
def maxCircularSum(arr, n, k):
if (n < k):
print("Invalid");
return;
sum = 0;
start = 0;
end = k - 1;
for i in... | vfc_1314 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENCD2020/problems/ECAPR206",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3\n8 6 9 4 10\n",
"output": "24\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 619 | Solve the following coding problem using the programming language python:
In a regular table tennis match, the player who serves changes every time after 2 points are scored, regardless of which players scored them.
Chef and Cook are playing a different match — they decided that the player who serves would change ever... | ```python
n=int(input())
for i in range(n):
l=list(map(int,input().split()))
k=l[0]+l[1]
k=k%(2*l[2])
if k>=0 and k<l[2]:
print("CHEF")
else:
print("COOK")
``` | vfc_1318 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHSERVE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 2\n0 3 2\n34 55 2\n",
"output": "CHEF\nCOOK\nCHEF\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 620 | Solve the following coding problem using the programming language python:
Find the length of the longest contiguous segment in an array, in which if a given element $K$ is inserted, $K$ becomes the second largest element of that subarray.
-----Input:-----
- The first line will contain $T$, number of test cases. Then ... | ```python
for _ in range(int(input())):
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
def check(mid):
d,left={},0
for i in range(mid):
if a[i]>k:
if a[i] not in d:
d[a[i]]=1
else:
d[a[i]]+=1
if len(d)==1:
return True
for i in range(mid,n):
if a[left]>k:
... | vfc_1322 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SLAEL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 3\n2 4 2 4 2\n8 5\n9 3 5 7 8 11 17 2\n",
"output": "5\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 621 | Solve the following coding problem using the programming language python:
Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in al... | ```python
t = eval(input())
for _ in range(t):
n = eval(input())
a = input().strip().split()
cb, cs = 0, ""
for i in range(len(a[0])):
for j in range(i+1,len(a[0])+1):
al = True
s = a[0][i:j]
for k in a[1:]:
if s not in k:
al = False
break
if al:
if j-i>=cb:
cb = max(cb, j-i)
... | vfc_1326 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK63/problems/STEM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\ngrace graceful disgraceful gracefully\n",
"output": "grace\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 622 | Solve the following coding problem using the programming language python:
Chef has a rectangular piece of paper. He puts it on a big board in such a way that two sides of the paper are horizontal and two are vertical, and then he performs a sequence of $N$ operations. You are given a string $S$ with length $N$; for ea... | ```python
# cook your dish here folding paper
from collections import Counter
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def dist(a,b):return ((a[0]-b[0])**2+(a[1]-b[1])**2)**0.5
for _ in range(val()):
n,m,w,h=li()
s=C... | vfc_1330 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PAPER",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 2 10 10\nULRDDL\n4 4\n5 5\n4 2 10 10\nRUDL\n1 1\n9 9\n",
"output": "1.41421356237\n2.00000000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 623 | Solve the following coding problem using the programming language python:
Given the list of numbers, you are to sort them in non decreasing order.
-----Input-----
t – the number of numbers in list, then t lines follow [t <= 10^6].
Each line contains one integer: N [0 <= N <= 10^6]
-----Output-----
Output given num... | ```python
t = int(input())
list_to_tri = []
for i in range(t):
list_to_tri.append(int(input()))
list_to_tri.sort()
for i in list_to_tri:
print(i)
``` | vfc_1334 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TSORT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n5\n3\n6\n7\n1\n",
"output": "1\n3\n5\n6\n7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 624 | Solve the following coding problem using the programming language python:
Once, a genius guy Cristo visited NASA where he met many scientists. A young intern Mark at NASA asked Cristo to observe the strange behaviour of two
independent particles (say Alpha and Beta) moving in the free space.Cristo was astonished to s... | ```python
for _ in range(eval(input())):
n=eval(input())
mod=1000000007
f1,f2=[0]*101000,[0]*101000
f1[1]=0
f1[2]=2
f1[3]=3
f2[1]=1
f2[2]=1
f2[3]=2;
for i in range(4,100001):
f1[i]=f1[i-1]%mod+f1[i-2]%mod+f1[i-3]%mod
f2[i]=f2[i-1]%mod+f2[i-2]%mod+f2[i-3]%mod
print(f1[n]%mod,f2[n]%mod)
``` | vfc_1338 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ICOD2016/problems/ICODE16C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "0 1\n2 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 625 | Solve the following coding problem using the programming language python:
Shaun is very much interested in Subarrays. Shaun wants to count the number of subarrays in his chosen array with sum being a multiple of $10^9$. Since, Shaun is interested in huge numbers.He chose his array such that it contains only $10^8$ and... | ```python
def subCount(arr, n, k):
mod = []
for i in range(k + 1):
mod.append(0)
cumSum = 0
for i in range(n):
cumSum = cumSum + arr[i]
# as the sum can be negative,
# taking modulo twice
mod[((cumSum % k) + k) % k] = mod[((cumSum % k) + k) % k] +... | vfc_1342 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COCA2020/problems/COCA2001",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n100000000 900000000 100000000\n1\n900000000\n",
"output": "2\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 626 | Solve the following coding problem using the programming language python:
The Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will display the message. The Chef... | ```python
t=int(input())
def reversebinary(bits,n):
bStr=''
for i in range(bits):
if n>0:
bStr=bStr+str(n%2)
else:
bStr=bStr+'0'
n=n>>1
return int(bStr,2)
for i in range(t):
k,msg=input().split()
k=int(k)
newmsg=[]
for j in msg:
... | vfc_1346 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK02/problems/ARRANGE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 chef\n4 enjoyourapplepie\n\n\n",
"output": "cehf\neayejpuinpopolre\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 627 | Solve the following coding problem using the programming language python:
Bharat was given a problem to solve, by his brother, Lord Ram. The problem was like, given integers, $N$ and $K$, Bharat has to find the number (possibilities) of non-increasing arrays of length $K$, where each element of the array is between $1... | ```python
import math
p=7+10**9
n,k=list(map(int,input().split()))
c=math.factorial(n+k-1)//((math.factorial(k))*(math.factorial(n-1)))
print(c%p)
``` | vfc_1350 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PCR12020/problems/BHARAT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 5\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 628 | Solve the following coding problem using the programming language python:
Chef and his best friend Aleksa are into mathematical games these days. Today, they have some ( ≥ 0 ) black cells represented as B, and a white cell represented as W, lying randomly in a straight line.
They have decided to play with these cells.... | ```python
t =int(input()) #no. of test cases
while t>0:
t=t-1
str=input()
size=len(str)
pos=str.find('W')
left=pos
right=size-pos-1
arr = [[0 for i in range(right+1)] for j in range(left+1)]
#arr[i,j] = 1 if with i black cells on left and j on right 1st player can win, 0 otherwise.
#Recursion: arr[i][j... | vfc_1354 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BWCELL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nW\nBW\nBWBB\n",
"output": "Chef\nAleksa\nAleksa\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 629 | Solve the following coding problem using the programming language python:
Naturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid,
B potions of blue liquid, and G potions of green liquid.
-
The red liquid potions have liquid amoun... | ```python
import sys
import math
import heapq
def half(n):
return n//2
def main(arr,m):
a,b,c=arr
while m!=0:
s=max(a,b,c)
if s==a:
a=half(a)
elif s==b:
b=half(b)
else:
c=half(c)
m-=1
return max(a,b,c)
for i in range(int(input())):
r,g,b,m=list(map(int,input().split())... | vfc_1358 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PRPOTION",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1 1 1\n1\n2\n3\n1 1 1 1\n2\n4\n6\n3 2 2 2\n1 2 3\n2 4\n6 8\n",
"output": "2\n4\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 630 | Solve the following coding problem using the programming language python:
Cersei wants to be the queen of seven kingdoms.
For this to happen, she needs to address the soldiers in her army. There are n$n$ soldiers in her army (numbered 1$1$ through n$n$). Cersei passes on the message to the first soldier (soldier 1). ... | ```python
dt, a = None, None
def dfs(z):
r = [{}, {}];ln = len(dt[z])
if ln == 0:r[0][0] = 0;r[1][1 << a[z]] = 1
elif ln == 1:
l = dfs(dt[z][0]);r[0] = l[1]
for m in l[0]: r[1][(1 << a[z]) | m] = min(r[1][(1 << a[z]) | m], l[0][m] + 1) if (1 << a[z]) | m in r[1] else l[0][m] + 1
... | vfc_1362 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CERSOL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 4 3\n1 1 2 2 3\n1 2\n1 3\n2 4\n2 5\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 631 | Solve the following coding problem using the programming language python:
In Ciel's restaurant, a waiter is training.
Since the waiter isn't good at arithmetic, sometimes he gives guests wrong change.
Ciel gives him a simple problem.
What is A-B (A minus B) ?
Surprisingly, his answer is wrong.
To be more precise, his... | ```python
a, b = [int(x) for x in input().split()]
r = list(str(a-b))
if r[0] == "1":
r[0] = "2"
else:
r[0]="1"
print("".join(r))
``` | vfc_1366 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK17/problems/CIELAB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5858 1234\n",
"output": "1624\nOutput details\nThe correct answer of 5858-1234 is 4624.\nSo, for instance, 2624, 4324, 4623, 4604 and 4629 will be accepted, but 0624, 624, 5858, 4624 and 04624 will be rejected.\nNotes\nThe pr... |
apps | verifiable_code | 632 | Solve the following coding problem using the programming language python:
Sheldon is a little geek living in Texas. While his friends like to play outside, little Sheldon likes to play around with ICs and lasers in his house. He decides to build N clap activated toggle machines each with one power inlet and one outlet... | ```python
n=int(input())
while n>0:
i=1
a,b=(int(i) for i in input().split())
if (b+1)%(i<<a)==0:
print("ON")
else:
print("OFF")
n=n-1
``` | vfc_1370 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BTCD2012/problems/T05",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4 0\n4 47\n1 0\n1 1\n",
"output": "OFF\nON\nOFF\nON\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 633 | Solve the following coding problem using the programming language python:
Well known investigative reporter Kim "Sherlock'' Bumjun needs your help! Today, his mission is to sabotage the operations of the evil JSA. If the JSA is allowed to succeed, they will use the combined power of the WQS binary search and the UFDS ... | ```python
n=int(input())
def do():
t=int(input())
x=[]
for i in range(t):
x.append(int(input()))
print(max(x))
return
for i in range(n):
do()
``` | vfc_1374 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/UWCOI20A",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n4\n7\n6\n3\n1\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 634 | Solve the following coding problem using the programming language python:
Lyra Belacqua is a very gifted girl. She is one of a very small set of people capable of reading an alethiometer, more commonly known as The Golden Compass. It has one specific use: to tell the truth. The name in fact, is derived from "Aletheia"... | ```python
string=input()
max_no=0
for i in range(len(string)):
var_occur=0
check_no=str()
j=i
while(j<len(string) and var_occur<2 ):
if(string[j].isalpha()):
if(var_occur==0):
check_no+='9'
var_occur+=1
else:
var_occur+=1
else:
check_no+=string[j]
j+=1
#print(check_no)
max_no=max(max_no... | vfc_1378 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ALETHIO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "06454\nInput2:\nC0D3C43F\n",
"output": "6454\nOutput2:\n3943\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 635 | Solve the following coding problem using the programming language python:
Chef is given a sequence of prime numbers $A_1, A_2, \ldots, A_N$. This sequence has exactly $2^N$ subsequences. A subsequence of $A$ is good if it does not contain any two identical numbers; in particular, the empty sequence is good.
Chef has t... | ```python
# cook your dish here
from collections import Counter
def solve(arr, n, k):
ans = 0
dict1 = {}
mod = 1000000007
for i in range(n):
if arr[i] in dict1:
dict1[arr[i]] += 1
else:
dict1[arr[i]] = 1
l1 = [0]+list(dict1.keys())
v = min(k, len(l1))
dp = [[0 for _ in range(v+1)]for _ in range(len(... | vfc_1382 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GDSUB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n2 2 3 3 5\n",
"output": "18\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 636 | Solve the following coding problem using the programming language python:
In this problem you are given a sequence of $N$ positive integers $S[1],S[2],\dots,S[N]$. In addition you are given an integer $T$, and your aim is to find the number of quadruples $(i,j,k,l)$, such that $1 \le i < j < k < l \le N$, and $S[i] +... | ```python
# cook your dish here
from itertools import combinations
a = list(map(int, input().split()))
n = a[0]
t = a[1]
q = list(combinations(a[2:], 4))
total = 0
for i in q:
if sum(i) == t:
total += 1
print(total)
``` | vfc_1386 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/ZCO17001",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 20 3 1 1 2 5 10\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 637 | Solve the following coding problem using the programming language python:
A balanced parenthesis string is defined as follows:
- The empty string is balanced
- If P is balanced, (P) is also
- If P and Q are balanced, PQ is also balanced
You are given two even integers n$n$ and k$k$. Find any balanced paranthesis stri... | ```python
import sys
def input():
return sys.stdin.readline().strip()
for i in range(int(input())):
n, k = map(int, input().split())
arr = []
if k == 2 or k == 4 or n % 2 != 0 or n == k:
arr.append('-1')
elif k % 2 != 0:
for i in range(int(n / 2)):
arr.append('(')
... | vfc_1390 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/UNBAL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 2\n8 6\n",
"output": "-1\n(())(())\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 638 | Solve the following coding problem using the programming language python:
You will be given m strings. For each of those strings, you need to count the total number of appearances of that string as substrings in all possible strings of length n containing only lower case English letters.
A string may appear in a str... | ```python
for _ in range(int(input())):
n,m=map(int,input().split())
print("Case "+str(_+1)+":")
for i in range(m):
s=input()
ls=len(s)
if ls>n:
print("0")
else:
k=(n-ls+1)
print((k*pow(26,n-ls,1000000007))%1000000007)
``` | vfc_1394 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ZUBAPCNT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 1\naa\n2 1\nd\n12 3\ncdmn\nqweewef\nqs\n\n\n",
"output": "Case 1:\n1\nCase 2:\n52\nCase 3:\n443568031\n71288256\n41317270\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 639 | Solve the following coding problem using the programming language python:
For a string $S$ let the unique set of characters that occur in it one or more times be $C$. Consider a permutation of the elements of $C$ as $(c_1, c_2, c_3 ... )$. Let $f(c)$ be the number of times $c$ occurs in $S$.
If any such permutation of... | ```python
# cook your dish here
t=int(input())
for _ in range(t):
st=input()
s=set(st)
a=[]
f1=f2=0
for i in s:
a.append(st.count(i))
a.sort()
if len(a)>=3:
for i in range(2,len(a)):
if a[i]!=a[i-1]+a[i-2]:
f1=1
break
x=a[0]
a[0]=a[1]
a[1]=x
for i in range(2,len(a)):
if a[i]!=a[i-1]+a[i... | vfc_1398 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CLFIBD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\naaaabccc\naabbcc\nppppmmnnoooopp\n",
"output": "Dynamic\nNot\nDynamic\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 640 | Solve the following coding problem using the programming language python:
Chef made two laddus with sweetness X and Y respectively. Cheffina comes and sees the chef created two laddus with different sweetness (might be same). Cheffina has the magical power to make the sweetness of laddus equal. Cheffina requires 1 uni... | ```python
def gcd(a,b):
if b==0:return a
else:return gcd(b,a%b)
def lcm(a,b):
m=a*b
g=gcd(a,b)
return int(m/g)
for _ in range(int(input())):
x,y=[int(x) for x in input().split()]
l=lcm(x,y)
s=int(l/x)
t=int(l/y)
print(s+t-2)
``` | vfc_1402 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY22",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2\n4 6\n",
"output": "0\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 641 | Solve the following coding problem using the programming language python:
A key feature of the Siruseri railway network is that it has exactly one route between any pair of stations.
The government has chosen three contractors to run the canteens at the stations on the railway network. To ensure that there are no disp... | ```python
n=int(input())
cost=[]
d={}
val_desc=[0]*n
visited=set()
visited.add(0)
dfstack=[]
desc = [[False for i in range(n)] for i in range(n)]
for i in range(n):
cost.append(int(input()))
d[i]=[]
for i in range(n-1):
j,k=list(map(int,input().split()))
d[j-1].append(k-1)
d[k-1].append(j-1)
def... | vfc_1406 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/SPLIT3",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n10\n20\n25\n40\n30\n30\n4 5\n1 3\n3 4\n2 3\n6 4\n",
"output": "70\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 642 | Solve the following coding problem using the programming language python:
Chef is the leader of Chef's Earth Defense Organization, and his mission is to counter aliens which are threatening the earth. According to information gathered by the organization, there are $N$ alien spaceships (numbered $1$ through $N$) plann... | ```python
# cook your dish here
def isValid(mid):
time = 0.0
for i in range(n):
if time < c[i]:
time = c[i]
time += mid # cannon cooling
elif time >= c[i] and time <= c[i] + d:
time += mid # cannon cooling
else:
return False
return True
t = int(input())
while t != 0:
n, d = list(map(int, input().... | vfc_1410 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ALIENIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 2\n3 2 3\n2 1\n5 6\n",
"output": "1.5000000000\n2.0000000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 643 | Solve the following coding problem using the programming language python:
Ted$Ted$ loves prime numbers. One day he is playing a game called legendary$legendary$ with his girlfriend Robin$Robin$. Ted$Ted$ writes a number N$N$ on a table and the number is in the form of :
N = P1A1 * P2A2 * ……….. * PnAn
Ted$Ted$ asks Ro... | ```python
d = 10**9 + 7
t = int(input())
while t:
t-=1
n =int(input())
p =list(map(int, input().strip().split()))
a =list(map(int, input().strip().split()))
b =list(map(int, input().strip().split()))
ans = 1
for i in range(n):
c = a[i] - b[i] + 1
tmp = (( pow... | vfc_1414 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AARA2018/problems/ARMBH4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n2 3 5\n2 1 2\n1 1 1\n",
"output": "540\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 644 | Solve the following coding problem using the programming language python:
There are $N$ friends in a group. Each of them have $A_{i}$ candies.
Can they share all of these candies among themselves such that each one of them have equal no. of candies.
-----Input:-----
- First line will contain $T$, number of testcases.... | ```python
# cook your dish here
for _ in range(int(input())):
friends = int(input())
candies = list(map(int,input().split()))
if (sum(candies) % friends == 0):
print("Yes")
else:
print("No")
``` | vfc_1418 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENJU2020/problems/ECJN202",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n1 2 3\n",
"output": "Yes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 645 | Solve the following coding problem using the programming language python:
Chef has $K$ chocolates and he wants to distribute them to $N$ people (numbered $1$ through $N$). These people are standing in a line in such a way that for each $i$ ($1 \le i \le N-1$), person $i$ and person $i+1$ are adjacent.
First, consider ... | ```python
t = int(input())
for _ in range(t):
n = int(input())
k = int(input())
num = int(k/n)
x = max(n*(1+num) - k, 0)
diff = abs(x - (n-x))
if diff == 0:
number = 2*x - 1
else:
number = min(x, n-x)*2
print(number)
``` | vfc_1422 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MMAX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n2\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 646 | Solve the following coding problem using the programming language python:
Given a string $s$.
You can perform the following operation on given string any number of time.
Delete two successive elements of the string if they are same.
After performing the above operation you have to return the least possible length of t... | ```python
from sys import stdin,stdout
import math,bisect
from datetime import date
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... | vfc_1426 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDGO2021/problems/MINLEN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\nabccd\nabbac\naaaa\n",
"output": "3\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 647 | Solve the following coding problem using the programming language python:
Ashley wrote a random number generator code.
Due to some reasons, the code only generates random positive integers which are not evenly divisible by 10. She gives $N$ and $S$ as input to the random number generator. The code generates a random n... | ```python
"""
Author : thekushalghosh
Team : CodeDiggers
"""
import sys,math
input = sys.stdin.readline
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input()
return(s[:len(s) -... | vfc_1430 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NCC2020/problems/NCC005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 5\n2 2\n",
"output": "5\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 648 | Solve the following coding problem using the programming language python:
Chef is going to organize a hill jumping competition and he is going to be one of the judges in it. In this competition there are N hills in a row, and the initial height of i-th hill is Ai. Participants are required to demonstrate their jumping... | ```python
n,q=list(map(int,input().split()))
final=[]
height=list(map(int,input().split()))
for k in range(0,q):
b=input().split()
if int(b[0])==1:
step=int(b[1])-1
for k in range(0,int(b[2])):
temp = 0
j=1
while j in range(1,101) and temp==0 and step+j<n:
if height[step+j]>height[step]:
step=st... | vfc_1434 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AUG17/problems/HILLJUMP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 2 3 4 5\n1 1 2\n2 3 4 -1\n1 1 2\n",
"output": "3\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 649 | Solve the following coding problem using the programming language python:
Mandarin chinese
, Russian and Vietnamese as well.
You are given a grid with $n$ rows and $m$ columns. Each cell of this grid can either be empty or it contains one particle. It can never contain more than one particle. Let's denote the cell in ... | ```python
def main():
for _ in range(int(input())):
rows,column = map(int,input().split())
arr = []
for i in range(rows):
arr.append(list(input()))
string = input()
last = string[-1]
operation = Find(string,last)
for i in string[0]+operation:
if i == "L":
arr = Left(arr)
if i == "R":
arr... | vfc_1438 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FRCPRT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 4\n1010\n0010\n1001\n0100\nLRDU\n4 3\n000\n010\n001\n101\nLRL\n3 2\n01\n10\n00\nD\n",
"output": "0011\n0011\n0001\n0001\n000\n100\n100\n110\n00\n00\n11\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 650 | Solve the following coding problem using the programming language python:
Chef is the event manager of his college. He has been assigned the task to manage the upcoming tech fest. There are $K$ rooms where the event can take place, and at a particular time only one event can be organized in a room for a particular tim... | ```python
import sys
# import math
from math import gcd
# import re
# from heapq import *
# from collections import defaultdict as dd
# from collections import OrderedDict as odict
# from collections import Counter as cc
# from collections import deque
# sys.setrecursionlimit(10**5)#thsis is must
# mod = 10**... | vfc_1442 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENNO2020/problems/ENCNOV4",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2\n1 10 1\n10 20 2\n15 50 2\n20 30 2\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 651 | Solve the following coding problem using the programming language python:
In these quarantine days, Chef and Chefina are getting bored. So, Chef came up with a game for her. He gets a pack of cards with numbers written on them. Chef then asks her to remove cards from the pack in the following manner: Chefina can choos... | ```python
# cook your dish here
try:
for i in range(int(input())):
n=int(input())
l=[int(j) for j in input().split()][:n]
d={}
for j in l:
d[j]=d.get(j,0)+1
a=len(d)
c=0
for j in list(d.keys()):
while(d[j]>=3):
d[j]=(d[j]//3)+(d[j]%3)
if(d[j]==2):
c=c+1
if(c&1):
s=0
for j in list... | vfc_1446 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BTCH2020/problems/UNQCARD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n1 2 2 3 5\n9\n1 2 2 3 3 5 8 8 9\n",
"output": "3\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 652 | Solve the following coding problem using the programming language python:
Shubham recently learned the lexicographical order in strings.
Now, he has two strings s1 and s2 of the equal size and Shubham wants to compare those two strings lexicographically.
Help Shubham with the strings comparison.
Note:
Letters a... | ```python
t=eval(input())
while t:
t=t-1
s1=input().lower()
s2=input().lower()
res="equal"
for i in range(len(s1)):
if(s1[i]!=s2[i]):
res="first" if s1[i]<s2[i] else "second"
break
print(res)
``` | vfc_1450 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDFXOQ16/problems/CDFX01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nabc\nacb\nAB\nba\n",
"output": "first\nfirst\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 653 | Solve the following coding problem using the programming language python:
You have a laser with P amount of energy in it. You are playing a game where you have to use the laser to destroy some crystals, each with some health of their own. Initially, you have 0 points.
Each crystal has an associated health. The health ... | ```python
def game(n,l,p):
if(len(l)==0):
return 0
l.sort()
if(len(l)>=1 and p<l[0]):
return 0
l.sort()
c=0
ma=set()
ma.add(0)
while(len(l)):
if(p>=l[0]):
p-=l[0]
c+=1
ma.add(c)
l=l[1:]
... | vfc_1454 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFJ2020/problems/JUN1",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n200\n100\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 654 | Solve the following coding problem using the programming language python:
Three numbers A, B and C are the inputs. Write a program to find second largest among them.
-----Input-----
The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C... | ```python
# cook your dish here
x=int(input())
for i in range(x):
s=list(map(int,input().split()))
s.sort()
print(s[1])
``` | vfc_1458 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW017",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n120 11 400\n10213 312 10\n10 3 450\n",
"output": "120\n312\n10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 655 | Solve the following coding problem using the programming language python:
Chef had a sequence of positive integers with length $N + K$. He managed to calculate the arithmetic average of all elements of this sequence (let's denote it by $V$), but then, his little brother deleted $K$ elements from it. All deleted elemen... | ```python
def __starting_point():
t=int(input())
for _ in range(t):
n,k,v=map(int,input().split())
li=list(map(int,input().split()))
sumn=0
for i in range(n):
sumn=sumn+li[i]
sumk=v*(n+k)-sumn
e=int(sumk/k)
r=sumk%k
if e<=0:
print(-1)
elif r!=0:
print(-1)
else:
print(e)
__starting_poin... | vfc_1462 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AVG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 3 4\n2 7 3\n3 1 4\n7 6 5\n3 3 4\n2 8 3\n",
"output": "4\n-1\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 656 | Solve the following coding problem using the programming language python:
Write a program to obtain a number $N$ and increment its value by 1 if the number is divisible by 4 $otherwise$ decrement its value by 1.
-----Input:-----
- First line will contain a number $N$.
-----Output:-----
Output a single line, the new ... | ```python
# cook your dish here
n = int(input())
if(n%4==0):
print(n+1)
else:
print(n-1)
``` | vfc_1466 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DECINC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 657 | Solve the following coding problem using the programming language python:
You will be given a two-dimensional array with row consisting values 0 or 1.
A move consists of choosing any column or row, and toggling all the 0’s as 1’s and 1’s as 0’s.
After making the required moves, every row represents a binary number... | ```python
def matrixScore(A):
"""
:type A: List[List[int]]
:rtype: int
"""
m,n = len(A),len(A[0])
# 行变换
for i in range(m):
if A[i][0] == 1: continue
for j in range(n):
A[i][j] = 1 - A[i][j]
# 列变换
... | vfc_1470 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFDEC20/problems/COFDQ2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 4\n0 0 1 1\n1 0 1 0\n1 1 0 0\n",
"output": "39\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 658 | Solve the following coding problem using the programming language python:
A sequence of integers ($a_1, a_2, \ldots, a_k$) is said to be UpDown, if these inequalities hold true:
- $a_1 \le a_2$
- $a_2 \ge a_3$
- $a_3 \le a_4$
and so on.
That is, every even-indexed element should be at least as large as its adjacent el... | ```python
# cook your dish here
t=int(input())
for _ in range(t):
n=int(input())
array=list(map(int, input().split()))
list_sub=[]
idx=0
counter=0
for i in range(n-1):
if counter%2==0 and array[i]<=array[i+1]:
counter+=1
elif counter%2==1 and array[i]>=array[i+1]:
... | vfc_1474 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ZCOPRAC/problems/UPDOWSEQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7\n100 1 10 3 20 25 24\n5\n3 3 2 4 1\n",
"output": "7\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 659 | Solve the following coding problem using the programming language python:
Binod is a youtuber and he is busy in the fame of social media so he asked you to help him solve a problem.
You have been given an array of $positive$ $integers$ $a_{1},a_{2},a_{3},...,a_{i},...,a_{n}$ of size n.You have to find the smallest len... | ```python
#binarr
def binarr(a, k, s):
a.sort(reverse=True)
arr = [0]*k
for i in range(k):
arr[i] = a[i]
if sum(arr) <= s:
return binarr(a, k+1, s)
return len(arr)
try:
n, k, s = list(map(int, input().split()))
a = list(map(int, input().split()))
print(binar... | vfc_1478 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COVO2020/problems/BINARR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1:\n5 1 5\n1 2 3 4 5\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 660 | 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 the sum of the factorial of the digits, he wrote all those interesting numbers in the diary(in increasing order) and went... | ```python
t = int(input())
for i in range(t):
n = int(input())
if n == 1 or n == 2 or n == 145 or n == 40585:
print(1)
else:
print(0)
``` | vfc_1482 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK22020/problems/ITGUY26",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n10\n",
"output": "1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 661 | Solve the following coding problem using the programming language python:
Raju has created a program to find the square root of a number. But his program can store only integers. Being a newbie, he didn't know about rounding the numbers. Hence his program returns the absolute value of the result if possible. For examp... | ```python
try:
from math import sqrt
t,x=list(map(int,input().split()))
for _ in range(t):
n=int(input())
if(n<0):
print("no")
else:
diff=(x/100)*n
ans=int(sqrt(n))
ans1=ans**2
if(n-ans1<=diff):
print("yes")
else:
print("no")
except:
pass
``` | vfc_1486 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMT2020/problems/ROOTSQR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 20\n5\n3\n",
"output": "yes\nno\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 662 | Solve the following coding problem using the programming language python:
Kabir wants to impress Tara by showing her his problem solving skills. He has decided to give the correct answer to the next question which will be asked by his Algorithms teacher.
The question asked is:
Find the sum of alternate consecutive d$d... | ```python
# cook your dish here
for t in range(int(input().strip())):
d = int(input().strip())
L, R = map(int, input().strip().split(" "))
if L % 2 == 0:
L += 1
sum = (((((R - L + 2)//2)//d)+1)//2) - 1
sum = (sum * 2 * d * (sum + 1) * d) + (sum+1) *d * (L + d -1)
print(sum%1000000007)
``... | vfc_1490 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/HECS2020/problems/CC002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n10 33\n",
"output": "114\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 663 | Solve the following coding problem using the programming language python:
You are given a string $S$ and an integer $L$. A operation is described as :- "You are allowed to pick any substring from first $L$ charcaters of $S$, and place it at the end of the string $S$.
A string $A$ is a substring of an string $B$ if $A... | ```python
def least_rotation(S: str) -> int:
"""Booth's algorithm."""
f = [-1] * len(S) # Failure function
k = 0 # Least rotation of string found so far
for j in range(1, len(S)):
sj = S[j]
i = f[j - k - 1]
while i != -1 and sj != S[k + i + 1]:
if sj < S[k +... | vfc_1494 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BIT32020/problems/BIT3B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 rga\n2 cab\n",
"output": "arg\nabc\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 664 | Solve the following coding problem using the programming language python:
This year $p$ footballers and $q$ cricketers have been invited to participate in IPL (Indian Programming League) as guests. You have to accommodate them in $r$ rooms such that-
- No room may remain empty.
- A room may contain either only footbal... | ```python
# cook your dish here
MOD = 998244353
fball = [ [0]*101 for _ in range(101) ]
cric = [ [0]*101 for _ in range(101) ]
def calSNum(n, r):
if n == r or r == 1:
fball[r][n] = 1
return
if n > 0 and r > 0 and n > r:
fball[r][n] = (fball[r-1][n-1]%MOD + (r*fball[r][n-1])%MOD )%MOD
return
fball[r][n]... | vfc_1498 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FCIPL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 1 4\n2 4 4\n2 5 4\n2 8 4\n",
"output": "0\n3\n10\n609\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 665 | Solve the following coding problem using the programming language python:
Chef organised a chess tournament, which spanned over $M$ months. There were $N$ players, and player $i$ was rated $R_i$ before the start of the tournament. To see the progress of the players, he noted their rating changes at the end of each mon... | ```python
# cook your dish here
t=int(input())
for _ in range(t):
n,m=list(map(int,input().split()))
r=list(map(int,input().split()))
rating=[[r[i]]*(m) for i in range(n)]
ranking=[[0]*m for i in range(n)]
for i in range(n):
diff=list(map(int,input().split()))
for j in range(m):
rating[i][j]+=diff[j]
if ... | vfc_1502 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ELOMAX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n2500 2500 2520\n10 -5 -20\n10 15 20\n-15 17 13\n2 3\n2125 2098\n-20 10 -10\n10 10 -20\n",
"output": "2\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 666 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
# cook your dish here
t = int(input())
for _ in range(t):
s = ''
n = int(input())
if n==1:
print(1)
continue
for i in range(1, n+1):
s = s + str(i)
print(s)
p = 1
for i in range(n-1):
s = ''
for j in range(n):
s = s + str(p... | vfc_1506 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2021/problems/ITGUY49",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "1\n12\n34\n123\n456\n789\n1234\n5678\n9101112\n13141516\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 667 | Solve the following coding problem using the programming language python:
Diana is planning to make a very long journey. Her journey consists of $N$ bus routes, numbered from $1 to N$ in the order she must take them. The buses themselves are very fast but do not run often. The $i-th$ bus route only runs every $Xi$ day... | ```python
t = int(input())
for _ in range(t):
nd = list(map(int, input().split()))
n = nd[0]
d = nd[1]
cutOff = []
x = d
buses = list(map(int, input().split()))
for i in range(len(buses)-1,-1,-1):
x = x - x%buses[i]
print(x)
``` | vfc_1510 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COX22020/problems/CCODEX2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 10\n3 7 2\n4 100\n11 10 5 50\n1 1\n1\n",
"output": "6\n99\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 668 | Solve the following coding problem using the programming language python:
You are given an array A with size N (indexed from 0) and an integer K. Let's define another array B with size N · K as the array that's formed by concatenating K copies of array A.
For example, if A = {1, 2} and K = 3, then B = {1, 2, 1, 2, 1, ... | ```python
def max_sum(arr):
# Finds the maximum sum of sub-arrays of arr
max_till_now = -1000000 #minimum possible number
current_sum = 0
for i in range(len(arr)):
if current_sum < 0:
# If sum of previous elements is negative, then ignore them. Start fresh
# with `curren... | vfc_1514 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/KCON",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3\n1 2\n3 2\n1 -2 1\n\n\n",
"output": "9\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 669 | Solve the following coding problem using the programming language python:
Nadaca is a country with N$N$ cities. These cities are numbered 1$1$ through N$N$ and connected by M$M$ bidirectional roads. Each city can be reached from every other city using these roads.
Initially, Ryan is in city 1$1$. At each of the follow... | ```python
T = int(input())
for _ in range(T):
N, M, K = [int(x) for x in input().split()]
UV = [[int(x) for x in input().split()] for _ in range(M)]
Q = int(input())
AB = [[int(x) for x in input().split()] for _ in range(Q)]
X = [[i] for i in range(N)]
for u, v in UV:
X[u - 1] += [v - 1]
... | vfc_1518 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WNDR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 3 3\n1 2\n1 3\n1 4\n0\n4 3 3\n1 2\n1 3\n1 4\n1\n2 2\n4 3 3\n1 2\n1 3\n1 4\n1\n2 1\n",
"output": "28\n4\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 670 | Solve the following coding problem using the programming language python:
Sereja has an array A of N positive integers : A[1], A[2], A[3], ... , A[N].
In a single operation on the array, he performs the following two steps :
- Pick two indices i, j s.t. A[i] > A[j]
- A[i] -= A[j]
Sereja can apply these operation... | ```python
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
def main():
t=int(input())
while t!=0:
t=t-1
n=int(input())
if n==1:
print(input())
else:
a=list(map(int,input().split(" ")))
p=a[0]
for i in range(1,n):
p=gcd(p,a[i])
if p==1:
break
print(n*p)
def __starting... | vfc_1522 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK64/problems/SEAARASU",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n1\n3\n2 4 6\n",
"output": "1\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 671 | Solve the following coding problem using the programming language python:
Chef is going to start playing Fantasy Football League (FFL) this season. In FFL, each team consists of exactly $15$ players: $2$ goalkeepers, $5$ defenders, $5$ midfielders and $3$ forwards. Chef has already bought $13$ players; he is only miss... | ```python
for i in range(int(input())):
n,s =map(int,input().split())
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
m=[]
n=[]
for i in range(len(l1)):
if l2[i]==0:
m.append(l1[i])
else:
n.append(l1[i])
if len(m)>0 and len(n)>0:
if 100-s>=(min(m)+min(n)):
print("yes")
else:
... | vfc_1526 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FFL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 90\n3 8 6 5\n0 1 1 0\n4 90\n5 7 6 5\n0 1 1 0\n",
"output": "yes\nno\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 672 | Solve the following coding problem using the programming language python:
In my town ,there live a coder named Chef . He is a cool programmer . One day , he participate in a programming contest ,the contest give him only one problem . If he can’t solve the problem ,the problem setter will kill him . But the round allo... | ```python
# cook your dish here
from math import sqrt
for i in range(int(input())):
x1,y1,x2,y2=list(map(float,input().split()))
m=(y2-y1)/(x2-x1)
c=y2-m*x2
print('Test case : ',i+1)
q=int(input())
for i in range(q):
x3,y3=list(map(float,input().split()))
if(y3-m*x3-c==0):
print("YES")
else:
d=(abs(y3... | vfc_1530 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ABCC2020/problems/POINT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 5 6 5\n2\n4 5\n6 8\n3 4 7 10\n1\n7 4\n",
"output": "Test case : 1\nYES\nNO\n3.000000\nTest case : 2\nNO\n3.328201\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 673 | Solve the following coding problem using the programming language python:
Its Christmas time and Santa has started his ride to deliver gifts to children waiting for him in a 1-dimentional city. All houses in this city are on a number line numbered as 1, 2, 3… and so on. Santa wants to deliver to houses from n to m, bu... | ```python
from math import gcd
from math import ceil
from itertools import combinations as c
t=int(input())
for _ in range(t):
n,m,a,d=list(map(int,input().split()))
l=[]
for i in range(5):
l.append(a+i*d)
ans=m-n+1
for i in range(1,6):
x=list(c(l,i))
for j ... | vfc_1534 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NQST2020/problems/XMASGIFT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 20 2 1\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 674 | Solve the following coding problem using the programming language python:
Chef bought an electronic board and pen. He wants to use them to record his clients' signatures.
The board is a grid with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$) of pixels. Initially, all pixels are white. ... | ```python
import numpy as np
for _ in range(int(input())):
ans = np.float('inf')
n, m = (int(x) for x in input().split())
sig = np.zeros((n,m))
img = np.zeros((3*n,3*m))
for row in range(n):
sig[row,:] = np.array([int(x) for x in input()])
for row in range(n):
img[row+n,m:2*m] = np.array([int(x) for x in inpu... | vfc_1538 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SIGNTURE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 3\n100\n010\n000\n000\n010\n001\n4 4\n0000\n0110\n0000\n0011\n1100\n0000\n1100\n0000\n3 3\n100\n000\n001\n000\n010\n000\n3 3\n000\n010\n000\n100\n000\n001\n3 3\n111\n000\n000\n001\n001\n001\n",
"output": "0\n2\n1\n0\n2\n... |
apps | verifiable_code | 675 | Solve the following coding problem using the programming language python:
A permutation $p_1,p_2...p_N$ of $\{1, 2, ..., N\}$ is beautiful if $p_i \& p_{i+1}$ is greater than 0 for every $1 \leq i < N$ . You are given an integer $N$, and your task is toconstruct a beautiful permutation of length $N$ or determine that ... | ```python
import math
def ispoweroftwo(y):
return math.ceil(math.log(y,2))==math.floor(math.log(y,2))
t=int(input())
for i in range(t):
n=int(input())
a=[]
if(ispoweroftwo(n) and n!=1):
print(-1,end=" ")
if(n==1):
print(1)
if(n>=3 and not(ispoweroftwo(n))):
a.append(2)
a.append(3)
a.append(1)
if(n>... | vfc_1542 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/POSAND",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n3\n5\n",
"output": "-1\n1 3 2\n2 3 1 5 4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 676 | Solve the following coding problem using the programming language python:
There is an event in DUCS where boys get a chance to show off their skills to impress girls. The boy who impresses the maximum number of girls will be honoured with the title “Charming Boy of the year”.
There are $N$ girls in the department. Eac... | ```python
from collections import Counter
for _ in range(int(input())):
n=int(input())
l=[i for i in input().split()]
ll=[]
c=Counter(l)
cc=[]
m=0
for l,count in c.most_common(len(l)-1):
if m==0:
ll.append(l)
cc.append(count)
... | vfc_1546 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DCC2020/problems/DCC202",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10\njohn berry berry thomas thomas john john berry thomas john\n4\nramesh suresh suresh ramesh\n",
"output": "john\nramesh\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 677 | Solve the following coding problem using the programming language python:
Computation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calculate the day from a particular given date.
You are required to find a day from a particular date given to you.
-----Input-----
It con... | ```python
import sys
import datetime
a,b,c = list(map(int,sys.stdin.readline().split()))
d = datetime.date(c,b,a)
print(d.strftime("%A"))
``` | vfc_1550 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/TCTR2012/problems/NOPC10",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "14 3 2012\n",
"output": "Wednesday\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 678 | Solve the following coding problem using the programming language python:
Snackdown 2019 is coming! People have started to spread the word and tell other people about the contest.
There are $N$ people numbered $1$ through $N$. Initially, only person $1$ knows about Snackdown. On each day, everyone who already knows ab... | ```python
# cook your dish here
test_case = int(input())
while test_case :
n_people = int(input())
array = list(map(int, input().strip().split()))
sums =[0 for i in range(n_people)]
sums[0] = array[0]
for i in range(1, n_people) :
sums[i] = sums[i-1] + array[i]
# print(sums)
k = 1
count = 0
i = 0
... | vfc_1554 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SPREAD2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7\n2 1 1 5 5 5 5\n5\n5 1 3 2 1\n",
"output": "2\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 679 | Solve the following coding problem using the programming language python:
Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approaching fast, he is doing book exercises day and night. He writes down and keeps updating the remaining number of ... | ```python
t=eval(input())
a=[]
b=[]
top=-1
for __ in range(0,t):
x=input().split()
if(x[0]!="-1" and x[0]!="0"):
add=int(x[0])
if top!=-1 and add>a[top][0] :
b[top]+=1
else:
a.append((add,x[1]))
b.append(0)
top+=1
elif (x[0]=="-1"):
#print("%s %s" %(b[t... | vfc_1558 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC12/problems/BEX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n9 english\n6 mathematics\n8 geography\n-1\n3 graphics\n-1\n",
"output": "1 mathematics\n0 graphics\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 680 | Solve the following coding problem using the programming language python:
You are given two integer sequences $A_1, A_2, \ldots, A_N$ and $B_1, B_2, \ldots, B_M$. For any two sequences $U_1, U_2, \ldots, U_p$ and $V_1, V_2, \ldots, V_q$, we define
Score(U,V)=∑i=1p∑j=1qUi⋅Vj.Score(U,V)=∑i=1p∑j=1qUi⋅Vj.Score(U, V) = \su... | ```python
t = int(input())
l,r,x = 0,0,0
ans = []
for i in range(t):
(n,m) = tuple(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
suma = sum(a)
sumb = sum(b)
q = int(input())
for j in range(q):
l1 = list(map(int,input().split()))
if l1[0] == 1:
l = l1[1]
... | vfc_1562 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ARRQRY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 4\n2 -1 5\n3 3 2 4\n6\n3\n1 2 3 -2\n3\n1 1 3 1\n2 2 4 2\n3\n",
"output": "72\n24\n90\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 681 | Solve the following coding problem using the programming language python:
You are playing following game: given an array A of N natural numbers. All numbers in the array A are at most M. On every turn you may pick any two different elements Ai and Aj (i≠j), such that Ai, Aj ≤ M, and add K to both. The game ends when y... | ```python
from math import ceil
from bisect import bisect_right as b_r
from bisect import bisect_left as b_l
ar = list(map(int , input().split()))
a = [int(ceil((ar[1]-int(x)+1)/ar[2])) for x in input().split()]
s = sum(a)
ar[1] = max(a)
m = ar[1] - (s-ar[1])%2
mi = s%2
print(int( (m-mi)//2 +1)%(10**9+7))
``` | vfc_1566 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RRGAME",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 3 2\n1 2 3\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 682 | Solve the following coding problem using the programming language python:
Rohit collects coins: he has exactly one coin for every year from 1 to n. Naturally, Rohit keeps all the coins in his collection in the order in which they were released. Once Rohit's younger brother made a change — he took all the coins whose r... | ```python
n=int(input())
a=list(map(int,input().split()))
l,r=-1,-1
for i in range(n):
if a[i]!=i+1:
l=i
break
for i in range(n-1,-1,-1):
if a[i]!=i+1:
r=i
break
j=r+1
for i in range(l,r+1):
if a[i]==j:
j-=1
continue
else:
print(0,0)
re... | vfc_1570 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BRBG2020/problems/PRMA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n1 6 5 4 3 2 7 8\n",
"output": "2 6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 683 | Solve the following coding problem using the programming language python:
-----Problem Statement-----
Write a program that accepts a number, n, and outputs the same.
-----Input-----
The only line contains a single integer.
-----Output-----
Output the answer in a single line.
-----Constraints-----
- 0 ≤ n ≤ 105
--... | ```python
# cook your dish here
a = int(input())
print(a)
``` | vfc_1574 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/START01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "123\n",
"output": "123\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 684 | Solve the following coding problem using the programming language python:
Congratulations !!! You have successfully completed the heist by looting all the gifts in Santa's locker. Now it's time to decide who gets to take all the gifts, you or the Grinch, there will be no splitting. So you and Grinch decide to play a g... | ```python
# cook your dish here
import math
# Function to find the Largest
# Odd Divisor Game to check
# which player wins
def findWinner(n, k):
cnt = 0;
# Check if n == 1 then
# player 2 will win
if (n == 1):
print("Grinch");
# Check if n == 2 or n is odd ... | vfc_1578 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NQST2020/problems/WINALL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1\n2\n3\n4\n5\n6\n12\n",
"output": "Grinch\nMe\nMe\nGrinch\nMe\nGrinch\nMe\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 685 | Solve the following coding problem using the programming language python:
You are given an axis-aligned rectangle in a 2D Cartesian plane. The bottom left corner of this rectangle has coordinates (0,0)$(0, 0)$ and the top right corner has coordinates (N−1,N−1)$(N-1, N-1)$. You are also given K$K$ light sources; each l... | ```python
# https://www.codechef.com/problems/RECTLIT
def assess(sq,points):
EWct = 0
NSct = 0
for a,b in points:
EW = (a == 0 or a == sq)
NS = (b == 0 or b == sq)
if EW and NS:
return 'yes'
EWct += EW
NSct += NS
if NSct + EWct == 0 or len... | vfc_1582 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RECTLIT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 10\n0 0\n1 0\n2 10\n1 2\n1 1\n",
"output": "yes\nno\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.