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 | 986 | Solve the following coding problem using the programming language python:
Problem Statement:Captain America and Iron Man are at WAR and the rage inside Iron Man is rising.
But Iron Man faces a problem to identify the location of Captain America.
There are N buildings situtaed adjacently to each other and Captain Ame... | ```python
t = int(input())
while t> 0:
t =t -1
n,k = list(map(int,input().split()))
a = [0]*n
done = True
def swap(z):
for j in range(0,n):
if a[j] == 0:
a[j] = z
done = True
break
else:
if a[j] > z:
swap(j)
a[j] = z
else:
done = False
break
for i in range(0,n):
... | vfc_2786 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COWS2016/problems/CVW",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 1\n3 0\n3 2\n",
"output": "2 1\n1 2 3\nCAPTAIN AMERICA EVADES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 987 | Solve the following coding problem using the programming language python:
Back in 2015, Usain Bolt announced that he'll be retiring after the 2017 World Championship. Though his final season did not end gloriously, we all know that he is a true legend and we witnessed his peak during 2008 - 2013.
Post retirement, Usa... | ```python
for i in range(int(input())):
finish,distanetobolt,tigerAcceleration,boltspeed=map(int,input().split())
t1=((2*(finish+distanetobolt)/(tigerAcceleration))**0.5)
t2=(finish/boltspeed)
if t1>t2:
print("Bolt")
elif t1<t2:
print("Tiger")
else:
print("Tiger")
``` | vfc_2790 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/USANBOLT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10 100 10 10\n100 10 5 10\n",
"output": "Bolt\nTiger\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 988 | Solve the following coding problem using the programming language python:
You are given a sequence of non-negative integers $A_1, A_2, \ldots, A_N$. At most once, you may choose a non-negative integer $X$ and for each valid $i$, change $A_i$ to $A_i \oplus X$ ($\oplus$ denotes bitwise XOR).
Find the minimum possible v... | ```python
# cook your dish here
# cook your dish here
test=int(input())
for _ in range(test):
n=int(input())
a=[(bin(int(x))[2:][::-1]+("0")*32)for x in input().split()]
res=""
mysum=0
for i in range(32):
mycount=0
for j in range(n):
if(a[j][i]=="0"):
mycount+=1
if(mycount==n):
break
if(mycount>(... | vfc_2794 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MINARRS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5\n2 3 4 5 6\n4\n7 7 7 7\n3\n1 1 3\n",
"output": "14\n0\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 989 | Solve the following coding problem using the programming language python:
Chef and Paja are bored, so they are playing an infinite game of ping pong. The rules of the game are as follows:
- The players play an infinite number of games. At the end of each game, the player who won it scores a point.
- In each game, one ... | ```python
n=int(input())
while(n>0):
x,y,z=map(int,input().split())
t=(x+y)//z
if t%2==0:
print('Chef')
else:
print('Paja')
n-=1
``` | vfc_2798 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PAJAPONG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 3 3\n5 7 2\n38657 76322 564\n",
"output": "Paja\nChef\nPaja\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 990 | Solve the following coding problem using the programming language python:
Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a ... | ```python
try:
n,m,a=map(int,input().split())
if n%a!=0:
number1=(n//a)+1
else:
number1=(n//a)
if m%a!=0:
number2=(m//a)+1
else:
number2=(m//a)
print(number1*number2)
except:
pass
``` | vfc_2802 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CSTR2020/problems/MALLTILE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "s\ninput\n6 6 4\noutput\n4\n",
"output": "",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 991 | Solve the following coding problem using the programming language python:
The Chef once decided to prepare some nice dishes on his birthday. There are N items kept on his shelf linearly from position 1 to N. Taste of the i-th item is denoted by a integer Ai.
He wants to make Q dishes. A dish will be made using some i... | ```python
n,k, q = list(map(int, input().split()))
mod = 10 ** 9 + 7
A = [0] * n
a, b, c, d, e, f, r, s, t, m, x = list(map(int, input().split()))
A[0] = x
for x in range(1, n):
if pow(t, x+1, s) <= r:
A[x] = (a*pow(A[x-1], 2, m) + b*A[x-1] + c) % m
else:
A[x] = (d*pow(A[x-1], 2, m) + e*A[x-1] + f) % m
def ... | vfc_2806 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFCK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2 1\n1 1 1 1 1 1 1 1 1 100 1\n1 1 1 3 1 1 1 2\n",
"output": "13 13\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 992 | Solve the following coding problem using the programming language python:
January and February are usually very cold in ChefLand. The temperature may reach -20 and even -30 degrees Celsius. Because of that, many people seal up windows in their houses.
Sergey also lives in ChefLand. He wants to seal the window in his h... | ```python
from math import sqrt
import sys
sys.setrecursionlimit(10**8)
intMax = 10**18
def knapsack(rl,l,c,m):
if m==0 and rl>0:
return intMax
if rl<=0:
return 0
return min(c[m-1]+knapsack(rl-l[m-1],l,c,m),knapsack(rl,l,c,m-1))
for _ in range(int(input())):
n= int(input())
cost=[]
length=[]
sides=[]
for i ... | vfc_2810 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SEALUP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n0 0\n1000 0\n1000 2000\n0 2000\n2\n1000 10\n2000 15\n",
"output": "50\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 993 | Solve the following coding problem using the programming language python:
Supermarket Dilemma
Chef is going to local supermarket but there appears a problem with chef as he is confused about which Supermarket he can choose to go as he is not able to decide whether he can park his car in that particular supermarket’s p... | ```python
import math
def check(s):
if s==2:
return 1
for i in range(2,math.ceil(math.sqrt(s))+1):
if s%i == 0:
return 0
return 1
def Solve(slots):
if slots<3:
return 0
#check
s = math.sqrt(slots)
if math.floor(s) == math... | vfc_2814 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NITJ2021/problems/CIN002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n5\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 994 | Solve the following coding problem using the programming language python:
You are given an integer sequence $A_1, A_2, \ldots, A_N$ and an integer $X$. Consider a $N \times N$ matrix $B$, where $B_{i,j} = A_i + A_j$ for each valid $i$ and $j$.
You need to find the number of square submatrices of $B$ such that the sum ... | ```python
# cook your dish here
import sys
input=sys.stdin.readline
for _ in range(int(input())):
n,x=list(map(int,input().split()))
l=[0]
pre=[0]*(n+1)
sum=0
i=1
for m in input().split():
l.append(int(m))
sum+=int(m)
pre[i]=sum
i+=1
dict={}
k=[]
i=1
while (i*i)<=x:
if x%i==0:
k.append(i)
if (... | vfc_2818 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SQRSUBMA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 36\n1 2 3 1 12\n4 54\n3 3 3 3\n",
"output": "6\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 995 | Solve the following coding problem using the programming language python:
Mr. Krabs loves money. He enters a bank and sees that there are n rooms arranged in a row. The only rooms with doors are the two rooms on either corner. Initially, all the rooms are locked (including the corner ones). To enter a room, it must be... | ```python
rooms=int(input())
money=list(map(int,input().split()))
keys=int(input())
rev=-1
a,b=0,-1
tot=[]
#print(money[-3:-1])
x=0
for i in range(keys):
#print(money[b:-1],money[0:a])
x=sum(money[b:])+sum(money[0:keys-abs(b)])
tot.append(x)
b-=1
print(max(tot))
``` | vfc_2822 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFJ2020/problems/JUN2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n1 2 3 4 5 6 1\n3\n",
"output": "12\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 996 | Solve the following coding problem using the programming language python:
The game of billiards involves two players knocking 3 balls around
on a green baize table. Well, there is more to it, but for our
purposes this is sufficient.
The game consists of several rounds and in each round both players
obtain a score, bas... | ```python
s1=s2=lead=0
mlead1=mlead2=0
for _ in range(int(input())):
x, y= list(map(int, input().split()))
s1, s2= s1+x, s2+y
if(s1>s2):
lead=(s1-s2)
mlead1= max(mlead1, lead)
else:
lead=(s2-s1)
mlead2= max(mlead2, lead)
if(mlead1<(mlead2)):
print('2', mlead2)
else:
... | vfc_2826 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TLG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n140 82\n89 134\n90 110\n112 106\n88 90\n",
"output": "1 58\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 997 | Solve the following coding problem using the programming language python:
Dr. S. De teaches computer architecture in NIT Patna. Whenever he comes across any good question(with complexity $k$), he gives that question to students within roll number range $i$ and $j$
At the start of semester he assigns score of $10$ to e... | ```python
try:
t=int(input())
for a in range(t):
l=input().split()
n=int(l[0])
m=int(l[1])
d={}
s=0
for b in range(m):
l1=input().split()
i=int(l1[0])
j=int(l1[1])
k=int(l1[2])
for c in range(i,j+1):
if c not in d:
d[c]=10
for c in range(i,j+1):
d[c]=d[c]*k
for i in d:
... | vfc_2830 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/STRT2020/problems/PROFDE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3\n1 3 5\n2 5 2\n3 4 7\n",
"output": "202\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 998 | Solve the following coding problem using the programming language python:
You are given an N × N grid initially filled by zeros. Let the rows and columns of the grid be numbered from 1 to N, inclusive. There are two types of operations can be applied to the grid:
- RowAdd R X: all numbers in the row R should be incre... | ```python
n,q=map(int,input().split())
dr={}
dc={}
for i in range(1,n+1):
dr[i]=0
dc[i]=0
mer=0
mec=0
for i in range(q):
s,j,k=input().split()
j=int(j)
k=int(k)
if s=="RowAdd":
dr[j]+=k
if dr[j]>mer:
mer=dr[j]
else:
dc[j]+=k
if mec<dc[j]:
mec=dc[j]
# m=max(list(dr.values()))+max(list(dc.values()))
... | vfc_2834 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ROWCOLOP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 4\nRowAdd 1 3\nColAdd 2 1\nColAdd 1 4\nRowAdd 2 1\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 999 | 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 cases... | ```python
try:
for _ in range(int(input())):
k=int(input())
for i in range(1,k+1):
print(" "*(k-i),end="")
if i%2==1:
for j in range(0,i):
print(chr(65+j),end="")
else:
for j in range(0,i):
print(j+1,end="")
print()
except:
pass
``` | vfc_2838 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK12020/problems/ITGUY16",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "A\n12\nA\n12\nABC\n1234\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1000 | Solve the following coding problem using the programming language python:
The activity of a panipuri seller is "making a panipuri and putting it on the palte of his customer".
$N$ customers are eating panipuri, Given an array $A$ of length $N$, $i^{th}$ customer takes $A_i$ seconds to eat a panipuri.
The Spee... | ```python
# cook your dish here
from math import ceil
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
ans=ceil(n/min(a))
print(int(ans))
``` | vfc_2842 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ECPG2020/problems/ECPC10B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n2 4 6 3\n5\n2 3 4 6 5\n",
"output": "2\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1001 | Solve the following coding problem using the programming language python:
Chef wants to buy a new phone, but he is not willing to spend a lot of money. Instead, he checks the price of his chosen model everyday and waits for the price to drop to an acceptable value. So far, he has observed the price for $N$ days (numbe... | ```python
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
g=1
for j in range(1,n):
if j-5<0:
mi=min(a[0:j])
#print(a[0:j])
if mi>a[j]:
g=g+1
else:
mi=min(a[j-5:j])
#print(a[j-5:j])
if mi>a[j]:
g=g+1
print(g)
``` | vfc_2846 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/S10E",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n375 750 723 662 647 656 619\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1002 | Solve the following coding problem using the programming language python:
Chef works in a similar way to a travelling salesman ― he always travels to new cities in order to sell his delicious dishes.
Today, Chef is planning to visit $N$ cities (numbered $1$ through $N$). There is a direct way to travel between each pa... | ```python
# cook your dish here
def solution(b,n1,d):
first=b[0]
b.sort()
for j in range(n1-1):
if(a[j+1]-a[j]>d):
return "NO"
for j in range(n1):
if(b[j]==first):
pos=j
if(pos==0 or pos==n1-1):
return "YES"
rec=1
for j in range(pos-1,n1-2):
if(a[j+2]-a[j]>d):
rec=0
break
if(rec):
retur... | vfc_2850 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TRVLCHEF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5 3\n3 2 1 4 5\n5 4\n10 1 3 2 9\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1003 | Solve the following coding problem using the programming language python:
In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints.
The power of each warrior is determined by the amount of chakra he possesses which is some ... | ```python
t=eval(input())
for i in range(0,t):
x=input()
nm=x.split(' ')
nm[0]=int(nm[0])
nm[1]=int(nm[1])
csoint=[]
lsoint=[]
csofloat=[]
lsofloat=[]
for j in range(0,nm[0]):
a=input()
b=a.split(' ')
b[0]=int(b[0])
b[1]=int(b[1])
csoint.append... | vfc_2854 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/OCT12/problems/DRGNBOOL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3\n10 1\n20 2\n5 2\n5 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36\n\n\n",
"output": "8\n89\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1004 | Solve the following coding problem using the programming language python:
A group of rebels travelling on a square hoverboard is ambushed by Imperial Stormtroopers.Their big hoverboard is an easy target, so they decide to split the board into smaller square hoverboards so that they can bolt away easily.But they should... | ```python
a=int(input())
if(a%2==0):
print("4")
print(a/2,a/2,a/2,a/2)
else:
print("6")
print((a-1)/2,(a-1)/2,(a-1)/2,(a-1)/2,(a-1)/2,(a+1)/2)
``` | vfc_2858 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SOPC2015/problems/SOPC1505",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n",
"output": "6\n1 1 1 1 1 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1005 | Solve the following coding problem using the programming language python:
Takaki Tono is a Computer Programmer in Tokyo. His boss at work shows him an online puzzle, which if solved would earn the solver a full expense paid trip to Los Angeles, California. Takaki really wants to solve this, as the love of his life, Ak... | ```python
MAXX = 10**9+1
N = eval(input())
nodes = list(map(int, input().split(" ")))
edges = [set() for _ in range(N)]
for _ in range(N-1):
a, b = list(map(int, input().split(" ")))
edges[a-1].add(b-1)
edges[b-1].add(a-1)
path = [[] for _ in range(N)]
visited, tovisit = set(), [(0, 0)]
while tovisit:
p... | vfc_2862 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LTIME38/problems/CLOSEFAR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 7 4 5\n1 2\n2 3\n2 4\n2 5\n7\nC 1 5\nF 1 5\nC 2 4\nC 1 2\nF 1 3\nF 3 4\nF 2 4\n",
"output": "1\n4\n2\n1\n6\n5\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1006 | Solve the following coding problem using the programming language python:
Chef Leonardo has a decimal integer $N$ and a non-zero decimal digit $d$. $N$ does not contain the digit zero; specifically, $N$ should always be treated as a decimal integer without leading zeroes.
Chef likes $d$ and does not like any other dig... | ```python
for _ in range(int(input())):
n,d=map(str,input().split())
k=list(n)
dd,c,n=d,0,len(n)
for x in range(n):
if int(k[n-x-1])>int(d):
k.pop(n-x-1)
c+=1
else:
d=k[n-x-1]
print(''.join(k)+c*dd)
``` | vfc_2866 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHDIGER",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n35 4\n42 4\n24 9\n",
"output": "34\n24\n24\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1007 | Solve the following coding problem using the programming language python:
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that
GCD of all integers in that subarray is 1.
Formally,
For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1.... | ```python
import math
for _ in range(int(input())):
n=int(input())
ar=[int(x) for x in input().split()]
# dp=[1]*n
f=0
g=ar[0]
for i in range(1,n):
g=math.gcd(g,ar[i])
if g==1:
f=1
print(n)
break
if f==0:
print(-1)
``` | vfc_2870 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUBGCD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n7 2\n3\n2 2 4\n",
"output": "2\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1008 | Solve the following coding problem using the programming language python:
You are given an array A consisting of N integers. A group of disjoint subarrays in it will be a collection of subarrays of the array. Formally a group of subarrays consisting of K subarrays can be denoted by 2 * K indices, [i1, j1], [i2, j2] , ... | ```python
t=int(input())
for k in range(t):
n=int(input())
l=[int(i) for i in input().split()]
m={}
count=1
for i in range(1,n):
if l[i]==l[i-1]:
count+=1
else:
if l[i-1] not in m:
m[l[i-1]]=(count*(count+1))/2
else:
... | vfc_2874 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MXSUBARR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3 4\n3\n1 2 2\n5\n1 1 2 2 2\n\n\n",
"output": "1\n3\n18\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1009 | Solve the following coding problem using the programming language python:
Chef is playing a game on a sequence of $N$ positive integers, say $A_1, A_2, ... A_N$ The game is played as follows.
- If all the numbers are equal, the game ends.
- Otherwise
- Select two numbers which are unequal
- Subtract the smaller number... | ```python
# cook your dish here
from sys import stdin
import functools
def gcd(a, b):
if (a == 0):
return b
return gcd(b % a, a)
MAX=10001
def func(ind, g, dp, n, a):
if (ind == n):
if (g == 1):
return 1
else:
return 0
if (dp[ind][g] != -1):
return dp[ind][g]
ans = (func(ind + 1, g, d... | vfc_2878 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AMSGAME2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n2 3 5 7\n4\n3 4 8 16\n3\n6 10 15\n",
"output": "11\n7\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1010 | Solve the following coding problem using the programming language python:
Anmol gained a lot of weight last semester. So this semester, he decided to run everyday. There is a very long straight road starting at his hostel. There are N poles on the road - P1, P2, P3,..., PN on the road. All the poles lie on the same si... | ```python
#code snippet reference:http://www.geeksforgeeks.org/searching-for-patterns-set -2-kmp-algorithm/
def KMPMatch(pattern, string):
M = len(pattern)
N = len(string)
nonlocal ans
lps = [0]*M
j = 0
LPSCompute(pattern, M, lps)
i = 0
while i < N:
if pattern[j] == string[i]:
i+=1
j+=1
if j==... | vfc_2882 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCAPR16/problems/RUNNING",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 1\n1 5 10 12 14\n5\n5 2\n5 8 13 16 21\n3 5\n5 3\n2 6 8 11 16\n2 3 5\n",
"output": "1\n2\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1011 | Solve the following coding problem using the programming language python:
Chef is a really nice and respectful person, in sharp contrast to his little brother, who is a very nasty and disrespectful person. Chef always sends messages to his friends in all small letters, whereas the little brother sends messages in all ... | ```python
t=int(input())
def do():
n,k=map(int,input().split())
s=input()
upper=0
lower=0
for i in s:
if i.isupper():
upper+=1
else:
lower+=1
if lower>k and upper<=k:
print('chef')
elif(upper>k and lower<=k):
print('brother')
elif(upper<=k and lower<=k):
print('both')
else:
print('none')
ret... | vfc_2886 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GOODBAD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 1\nfrauD\n5 1\nFRAUD\n4 4\nLife\n10 4\nsTRAWBerry\n",
"output": "chef\nbrother\nboth\nnone\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1012 | Solve the following coding problem using the programming language python:
Alice likes prime numbers. According to Alice, only those strings are nice whose sum of character values at a prime position is prime. She has a string $S$. Now, she has to count the number of nice strings which come before string $S$( including... | ```python
import sys
from collections import defaultdict
from copy import copy
MOD = 10**9 + 7
R = lambda t = int: t(input())
RL = lambda t = int: [t(x) for x in input().split()]
RLL = lambda n, t = int: [RL(t) for _ in range(n)]
# primes up to n
def primes(n):
P = []
n = int(n)
U = [1] * (n+1)
... | vfc_2890 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENJU2020/problems/ECJN207",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nabc\n",
"output": "10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1013 | Solve the following coding problem using the programming language python:
Navnit is a college student and there are $N$ students in his college .Students are numbered from $1$ to $N$.
You are given $M$ facts that "Student $A_i$ and $B_i$".The same fact can be given multiple times .If $A_i$ is a friend of $B_i$ ,then $... | ```python
# cook your dish here
from collections import defaultdict
d=defaultdict(list)
def dfs(i):
p=0
nonlocal v
e=[i]
while(e!=[]):
p+=1
x=e.pop(0)
v[x]=1
for i in d[x]:
if v[i]==-1:
v[i]=1
e.append(i)
retu... | vfc_2894 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INDC2021/problems/NAV28",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3\n1 2\n3 4\n1 5\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1014 | Solve the following coding problem using the programming language python:
A number K$K$ is said to be magical if it can be represented as a power of 2 only.That is K$K$=2x$2^{x}$ for some natural number x$x$.
Given a string of digits S$S$ of length N$N$, Let P be a valid arrangement of S.
By valid arrangement we mean... | ```python
from math import log2, ceil
MOD = int(1e9 + 7)
srt = lambda s: ''.join(sorted(s))
for _ in range(int(input())):
s = srt(input())
res = -1
for p in range(ceil(log2(int(s))), int(log2(int(s[::-1]))) + 1):
if int(srt(str(pow(2, p)))) == int(s):
if res == -1: res = 0
... | vfc_2898 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALQU2018/problems/POWTWO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n35566\n31\n",
"output": "65536\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1015 | 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
try:
for _ in range(int(input())):
k = int(input())
num = 1
for i in range(1,k+1,1):
for j in range(1,k+1,1):
print(num*2,end="")
num = num +1
print("")
except:
pass
``` | vfc_2902 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2021/problems/ITGUY50",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "2\n24\n68\n246\n81012\n141618\n2468\n10121416\n18202224\n26283032\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1016 | Solve the following coding problem using the programming language python:
You have been recently hired as a developer in CodeChef. Your first mission is to implement a feature that will determine the number of submissions that were judged late in a contest.
There are $N$ submissions, numbered $1$ through $N$. For each... | ```python
# cook your dish here
for t in range(int(input())):
c=0
for i in range(int(input())):
s,j=list(map(int,input().split()))
if (j-s)>5:
c+=1
print(c)
``` | vfc_2906 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/JDELAY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n1 3\n4 4\n4 10\n1 11\n2 7\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1017 | Solve the following coding problem using the programming language python:
Chef recently started working at ABC corporation. Let's number weekdays (Monday through Friday) by integers $1$ through $5$. For each valid $i$, the number of hours Chef spent working at the office on weekday $i$ was $A_i$.
Unfortunately, due to... | ```python
# cook your dish here
for t in range(int(input())):
a1,a2,a3,a4,a5,p=[int(x)for x in input().rstrip().split()]
if (a1+a2+a3+a4+a5)*p >120:
print("Yes")
else:
print("No")
``` | vfc_2910 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LOSTWKND",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n14 10 12 6 18 2\n10 10 10 10 10 3\n",
"output": "No\nYes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1018 | Solve the following coding problem using the programming language python:
Chef has a garden with $N$ plants arranged in a line in decreasing order of height. Initially the height of the plants are $A_1, A_2, ..., A_N$.
The plants are growing, after each hour the height of the $i$-th plant increases by $i$ millimeters.... | ```python
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
hrs = arr[0] - arr[1]
for i in range(1, n-1):
if hrs > arr[i] - arr[i+1]:
hrs = arr[i] - arr[i+1]
print(hrs)
``` | vfc_2914 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/INFTINCR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n8 4 2\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1019 | Solve the following coding problem using the programming language python:
The snakes want to build a temple for Lord Cobra. There are multiple strips of land that they are looking at, but not all of them are suitable. They need the strip of land to resemble a coiled Cobra. You need to find out which strips do so.
Form... | ```python
# cook your dish here
for i in range(int(input())):
N=int(input())
L=list(map(int,input().split()))
l,h=0,N-1
flag=1
if L[l]!=1 and L[h]!=1:
flag=0
else:
while(l<h):
if (L[l]!=L[h]) or (L[l+1]-L[l]!=1 and L[h-1]-L[h]!=1):
flag=0
break
l+=1
h-=1
if flag:
print("yes")
else:
pr... | vfc_2918 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TEMPLELA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7\n5\n1 2 3 2 1\n7\n2 3 4 5 4 3 2\n5\n1 2 3 4 3\n5\n1 3 5 3 1\n7\n1 2 3 4 3 2 1\n4\n1 2 3 2\n4\n1 2 2 1\n",
"output": "yes\nno\nno\nno\nyes\nno\nno\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1020 | Solve the following coding problem using the programming language python:
Vanja and Miksi have already finished everything for this year at their university, so they decided to spend their free time playing a game with a binary sequence $A_1, A_2, \dots, A_N$ (i.e. a sequence containing only integers $0$ and $1$).
At ... | ```python
# cook your dish here
for _ in range(int(input())):
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
m=0
for i in range(n):
if i%2==0:
if m<0:
m-=a[i]
else:
m+=a[i]
else:
if m<0:
m+=a[i]
else:
m-=a[i]
if abs(m)>=k:
print(1)
else:
print(2)
``` | vfc_2922 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MIXGA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 1\n1 0\n3 5\n0 1 0\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1021 | Solve the following coding problem using the programming language python:
The chef likes to play with numbers. He takes some integer number x, writes it down on his iPad, and then performs with it n−1 operations of the two kinds:
- divide the number x by 3 (x must be divisible by 3);
- multiply the number x by 2.
Afte... | ```python
class Node:
def __init__(self,x):
self.x=x
self.next=None
self.prev=None
self.flag=True
for t in range(1):
n=int(input())
arr=list(map(int,input().split()))
for i in range(n):
arr[i]=Node(arr[i])
for i in arr:
d=[i.x%3==0,i.x,i.... | vfc_2926 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/BRBG2020/problems/THTOG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n4 8 6 3 12 9\n",
"output": "9 3 6 12 4 8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1022 | Solve the following coding problem using the programming language python:
There are $N$ cities on a circle, numbered $1$ through $N$. For each $i$ ($1 \le i \le N-1$), cities $i$ and $i+1$ are directly connected by a bidirectional road with length $A_i$, and cities $N$ and $1$ are also directly connected by a bidirect... | ```python
# cook your dish here
# cook your dish here
import math
test=int(input())
for _ in range(test):
n=int(input())
l=list(map(int,input().split()))
f=0
for i in range(math.ceil(n//2)):
if n%2==1:
f=1
break
else:
if l[i]!=l[i+n//2]:
if min(l[i],l[i+n//2])==-1:
l[i]=max(l[i],l[i+n//2])
... | vfc_2930 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/OPPOSITE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n4\n1 1 1 1\n4\n1 1 1 2\n4\n1 -1 -1 4\n4\n1 -1 2 -1\n",
"output": "YES\n1 1 1 1\nNO\nYES\n1 4 1 4\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1023 | Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test case... | ```python
# cook your dish here
for _ in range(int(input())):
n = int(input())
count = 1
l = 3*(n-1)
i = 0
if n==1:
print(1)
continue
while count<=l-n:
for j in range(i+1):
if j==i:
print(count)
count += 1
elif j==0:... | vfc_2934 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY05",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n2\n3\n4\n5\n",
"output": "1\n1\n23\n1\n23\n456\n1\n23\n4 5\n6789\n1\n23\n4 5\n6 7\n89101112\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1024 | Solve the following coding problem using the programming language python:
Note : This question carries $100$ $points$
CodeLand is celebrating a festival by baking cakes! In order to avoid wastage, families follow a unique way of distributing cakes.
For $T$ families in the locality, $i$-th family (1 <= $i$ <= $T$) has ... | ```python
# cook your dish here
extra, less = 0,0
for _ in range(int(input())):
sli,mem,sma,luc = list(map(int, input().split()))
total = sma
t = sma
while mem > 1:
t *= luc
total += t
mem -= 1
if total <= sli:
extra += sli-total
print('POSSIBLE',sli-total)
... | vfc_2938 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PCO12020/problems/MORECAKE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n100 4 2 2\n100 4 3 2\n100 4 3 3\n200 4 4 2\n10 3 2 2\n",
"output": "POSSIBLE 70\nPOSSIBLE 55\nIMPOSSIBLE 20\nPOSSIBLE 140\nIMPOSSIBLE 4\nPOSSIBLE\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1025 | Solve the following coding problem using the programming language python:
You are given a tree rooted at node $1$ with $N$ vertices. The $i$$th$ vertex initially has value $A_i (1 \leq i \leq N)$. You are also given $Q$ queries.
In each query you are given a vertex $V$. Let $S = \{ S_1 , S_2 , ... S_x \} $ denote th... | ```python
from collections import defaultdict as dd,deque as dq
def opbfs(u,vis,ll,parr):
q=dq([(u,0)])
uu=u
su=0
while q:
u,lol=q.pop()
par=parr[u]
if(lol%2==0):
vis[u]=1
su+=ll[u-1]
ll[u-1]=0
for j in d[u]:
if(j!=par):
q.appendleft((j,lol+1))
ll[uu-1]=su
def bfs(height,d,parr):
q=dq([... | vfc_2942 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CENS20F",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 3\n6 2 7 3\n1 2\n2 3\n3 4\n3\n2\n1\n",
"output": "13 5 0 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1026 | Solve the following coding problem using the programming language python:
This is probably the simplest problem ever. You just need to count the number of ordered triples of different numbers (X1, X2, X3), where Xi could be any positive integer from 1 to Ni, inclusive (i = 1, 2, 3).
No, wait. I forgot to mention that ... | ```python
d=1000000007
for _ in range(int(input())):
l=sorted(list(map(int,input().split())))
ans=(l[0]%d)*((l[1]-1)%d)*((l[2]-2)%d)
print(ans%d)
``` | vfc_2946 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/THREEDIF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 3 3\n2 4 2\n1 2 3\n25 12 2012\n1 1 2013\n",
"output": "6\n4\n1\n578880\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1027 | Solve the following coding problem using the programming language python:
Chef recently learned about concept of periodicity of strings. A string is said to have a period P, if P divides N and for each i, the i-th of character of the string is same as i-Pth character (provided it exists), e.g. "abab" has a period P = ... | ```python
T=int(input())
for i in range(T):
n,m=list(map(int,input().split()))
if(m<=2):
print("impossible")
else:
l=[0]*m
if(m%2==0):
a=m//2
else:
a=(m//2)+1
for j in range(a):
if(j%2==0):
l[j]="a"
l[m-j-1]="a"
else:
l[j]="b"
l... | vfc_2950 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PERPALIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n3 1\n2 2\n3 3\n4 4\n6 3\n",
"output": "impossible\nimpossible\naba\nabba\nabaaba\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1028 | Solve the following coding problem using the programming language python:
Chef has some numbers. His girlfriend Chefina feels good when chef gives her a particular pattern number also called as Armstrong number.
Armstrong number is a number whose sum of its all individual digit raise to the power of the number of digi... | ```python
def power(x, y):
if y == 0:
return 1
if y % 2 == 0:
return power(x, y // 2) * power(x, y // 2)
return x * power(x, y // 2) * power(x, y // 2)
# Function to calculate order of the number
def order(x):
# Variable to store of the number
n = 0
while (x != 0):
n = n + 1
x = x // 10
return n
# ... | vfc_2954 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SPTC2020/problems/CPCEJC5",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n153\n11\n1634\n",
"output": "FEELS GOOD\nFEELS BAD\nFEELS GOOD\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1029 | Solve the following coding problem using the programming language python:
After a long and successful day of preparing food for the banquet, it is time to clean up. There is a list of n jobs to do before the kitchen can be closed for the night. These jobs are indexed from 1 to n.
Most of the cooks have already left a... | ```python
T = int(input())
for _ in range(T):
n,m = map(int,input().split())
completed = list(map(int,input().split()))
jobs = []
for i in range(1,n+1):
if i not in completed:
jobs.append(i)
jobs.sort()
chef = []
ass = []
for i in range(len(jobs)):
if i%2==0:
chef.append(str(jobs[i]))
else:
ass.a... | vfc_2958 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CLEANUP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6 3\n2 4 1\n3 2\n3 2\n8 2\n3 8\n",
"output": "3 6\n5\n1\n1 4 6\n2 5 7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1030 | Solve the following coding problem using the programming language python:
Let's consider a rooted binary tree with the following properties:
- The number of nodes and edges in the tree is infinite
- The tree root is labeled by $1$
- A node labeled by $v$ has two children: $2 \cdot v$ (the left child of $v$), and $2 \c... | ```python
t = int(input())
while(t>0):
t-=1;
n,l,r = list(map(int,input().split()));
a = bin(l)[2:];
b = bin(r)[2:];
# find matching
z = 0;
l = min(len(a),len(b));
for i in range(l):
if a[i]==b[i]:
z+=1;
else:
break;
#find base string
a = a[z:]
b = b[z:]
if(len(a)==0 and len(b)==0):
print(n);
... | vfc_2962 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK69/problems/BINTREEQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n11 9 11\n10 2 2\n8 1 8\n",
"output": "2\n10\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1031 | Solve the following coding problem using the programming language python:
Chef taught his brother Chefu about right angled triangle and its properties. Chefu says that he has understood everything about right angled triangles. Chef wants to check learning of his brother by asking the following question "Can you find a... | ```python
import math
t = eval(input())
while(t > 0):
h,s = input().split()
h = int(h)
s = int(s)
if(((h*h*h*h) - (16*s*s)) < 0):
print("-1")
else:
B = (math.sqrt((h*h) + math.sqrt((h*h*h*h) - (16*s*s))))/math.sqrt(2)
P = (2*s)/B
if(B > P):
print('{0:.6f}'.format(P),'{0:.6f}'.format(B),'{0:.6f}'.format(... | vfc_2966 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK71/problems/RIGHTTRI",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 6\n6 10\n258303 89837245228\n616153 77878145466\n",
"output": "3.00000 4.00000 5.00000\n-1\n-1\n285168.817674 546189.769984 616153.000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1032 | Solve the following coding problem using the programming language python:
Help Saurabh with his Chemistry Assignment.
Saurabh has been given a chemistry assignment by Ruby Mam. Though the assignment is simple but
Saurabh has to watch India vs Pakistan Match and he has no time to do the assignment by himself.
So Sau... | ```python
a = [1]
M = 10**6 + 3
for ii in range(1, 1000005):
a.append((a[-1]*ii)%M)
for __ in range(eval(input())):
n, x = list(map(int, input().split()))
if n>=M: print(0)
else: print((a[n]*x)%M)
``` | vfc_2970 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/REC2016/problems/RECIICHA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2\n2 1\n",
"output": "2\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1033 | Solve the following coding problem using the programming language python:
Given the values at the leaf nodes of a complete binary tree. The total number of nodes in the binary tree, is also given. Sum of the values at both the children of a node is equal to the value of the node itself. You can add any value or subtra... | ```python
print(0)
``` | vfc_2974 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/KM252020/problems/KM25P5C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1:\nInput:\n1\n50\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1034 | Solve the following coding problem using the programming language python:
A manufacturing project consists of exactly $K$ tasks. The board overviewing the project wants to hire $K$ teams of workers — one for each task. All teams begin working simultaneously.
Obviously, there must be at least one person in each team. F... | ```python
from math import log2;
import bisect;
from bisect import bisect_left,bisect_right
import sys;
from math import gcd,sqrt
sys.setrecursionlimit(10**7)
from collections import defaultdict
inf=float("inf")
# n=int(input())
# n,m=map(int,input().split())
# l=list(map(int,input().split()))
def get_factors(x):
if x... | vfc_2978 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/HIRINGWO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3\n2 6\n",
"output": "4\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1035 | Solve the following coding problem using the programming language python:
Mathison and Chef are playing a new teleportation game. This game is played on a $R \times C$ board where each cell $(i, j)$ contains some value $V_{i, j}$. The purpose of this game is to collect a number of values by teleporting from one cell t... | ```python
# cook your dish here
from collections import namedtuple
CurrentPosition = namedtuple('current_position', 'points, cell, pairs')
T = int(input())
for _ in range(T):
R, C, N = map(int, input().split())
Sx, Sy = map(int, input().split())
tx = map(int, input().split())
ty = map(int, input().spl... | vfc_2982 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MATTEG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 5 2\n2 2\n1 2\n2 1\n10 11 62 14 15\n57 23 34 75 21\n17 12 14 11 53\n84 61 24 85 22\n43 89 14 15 43\n3 3 2\n0 0\n1 1\n1 1\n9 8 7\n5 6 4\n1 3 2\n2 2 1\n1 1\n2\n2\n5 6\n8 3\n",
"output": "188\n24\n3\n",
"type": "stdin... |
apps | verifiable_code | 1036 | Solve the following coding problem using the programming language python:
Consider a 2d-grid. That is, each cell is identified by (i,j). You have received reports of two snake-sightings on this grid. You want to check whether they could be partial sightings of the same snake or not.
Each of the snake sightings corresp... | ```python
# cook your dish here
t=int(input())
for _ in range(t):
x1,y1,x2,y2=map(int,input().split())
x3,y3,x4,y4=map(int,input().split())
if (x1==x3 and y1==y3)or(x2==x4 and y2==y4):
print("yes")
elif (x1==x4 and y1==y4)or(x2==x3 and y2==y3):
print("yes")
else:
if(y1==y2)and(y1==y3)and(y1==y4):
a1=max(x... | vfc_2986 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SAMESNAK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 1 8 1\n11 1 7 1\n2 1 8 1\n11 1 9 1\n2 1 8 1\n3 1 3 -2\n2 1 8 1\n2 1 2 -2\n",
"output": "yes\nno\nno\nyes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1037 | Solve the following coding problem using the programming language python:
Ada is playing pawn chess with Suzumo.
Pawn chess is played on a long board with N$N$ squares in one row. Initially, some of the squares contain pawns.
Note that the colours of the squares and pawns do not matter in this game, but otherwise, the... | ```python
for _ in range(int(input())):
s = input().strip()
a = []
last = 0
for i in range(len(s)):
if s[i] == 'P':
a.append(i - last)
last = i + 1
x = 0
a = a[::-1]
for v in a[::2]:
x ^= v % 3
print('Yes' if x else 'No')
``` | vfc_2990 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ADAPWNS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n..P.P\n",
"output": "Yes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1038 | Solve the following coding problem using the programming language python:
Two's company, three's a crowd!
It's been one year since Chef met his brother. Last year, his younger brother came to visit him during this time of the year. This year, the Chef is planning to go visit his brother. Chef's brother has planned to ... | ```python
MOD = int(1e9+7)
def mult(a, b):
rsp = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
for i in range(3):
for j in range(3):
for k in range(3):
rsp[i][j] += a[i][k] * b[k][j]
rsp[i][j] %= MOD
return rsp
ident = [[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
m = [[1, 1, 0],
[1, 0, 1],
[1, 0, 0]]
powe... | vfc_2994 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CROWD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n4\n",
"output": "1\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1039 | Solve the following coding problem using the programming language python:
“I am not in danger, Skyler. I am the danger. A guy opens his door and gets shot, and you think that of me? No! I am the one who knocks!”
Skyler fears Walter and ponders escaping to Colorado. Walter wants to clean his lab as soon as possible and... | ```python
t=int(input())
for i in range(t):
ans=0
x,y=list(map(int,input().split()))
if y>x:
if (y-x)%4==0:ans=3
elif (y-x)%2==0: ans=2
else: ans=1
if y<x:
if (y-x)%2==0:ans=1
else: ans=2
print(ans)
``` | vfc_2998 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EOOPR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n0 5\n4 -5\n0 10000001\n",
"output": "1\n2\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1040 | Solve the following coding problem using the programming language python:
A string with length $L$ is called rich if $L \ge 3$ and there is a character which occurs in this string strictly more than $L/2$ times.
You are given a string $S$ and you should answer $Q$ queries on this string. In each query, you are given a... | ```python
t=int(input())
for _ in range(t):
n,q=map(int,input().split())
s=input()
l=[0]*(n-1)
for i in range(n-2):
a,b,c=s[i],s[i+1],s[i+2]
if len(set([a,b,c]))<3:
l[i]=l[i-1]+1
else:
l[i]=l[i-1]
for i in range(q):
left,right=map(int,input().split())
left-=1
right-=1
if right-left+1 <3:
... | vfc_3002 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/RICHSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10 2\nhelloworld\n1 3\n1 10\n",
"output": "NO\nYES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1041 | Solve the following coding problem using the programming language python:
Ripul was skilled in the art of lapidary. He used to collect stones and convert it into decorative items for sale. There were n stone shops. Each shop was having one exclusive stone of value s[i] , where 1<=i<=n. If number of stones collected ... | ```python
# cook your dish here
for u in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
d=[]
dd=[]
s=1
for i in range(n-1):
s=l[i]
d.append(s)
dd.append([i,i])
for j in range(i+1,n):
s=s*l[j]
d.append(s)
dd.append([i,j])
d.append(l[n-1])
dd.append([n-1,n-1])
k=len(d)
m=m... | vfc_3006 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COH12020/problems/RIPUGEMS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n1 2 3\n",
"output": "6 1 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1042 | Solve the following coding problem using the programming language python:
Chef wants to gift pairs to his friends this new year. But his friends like good pairs
only.
A pair (a , b) is called a good pair if 1 <= a < b <= N such that GCD(a*b , P) = 1.
Since Chef is busy in preparation for the party, he wants your help ... | ```python
# cook your dish here
def G(x, y):
while(y):
x, y = y, x % y
return x
# t=int(input())
# l=list(map(int,input().split()))
for _ in range(int(input())):
n,p=map(int,input().split())
c=0
for i in range(1,n+1):
if G(i,p)==1:
c+=1
ans=c*(c-1)//2
print... | vfc_3010 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NITJ2021/problems/CIN004",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 3\n3 3\n————————————————————————————————————————\n",
"output": "1\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1043 | Solve the following coding problem using the programming language python:
Forgotten languages (also known as extinct languages) are languages that are no longer in use. Such languages were, probably, widely used before and no one could have ever imagined that they will become extinct at some point. Unfortunately, that... | ```python
test_case = int(input())
for w in range(test_case):
n, k = map(int,input().split())
l = list(map(str,input().split()))
ans = []
for q in range(k):
l2 = list(map(str,input().split()))
ans.extend(l2[1:])
for i in l:
if i in ans:
print('YES',end=' ')
else:
print('NO',end=' ')
print()# cook yo... | vfc_3014 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FRGTNLNG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 2\npiygu ezyfo rzotm\n1 piygu\n6 tefwz tefwz piygu ezyfo tefwz piygu\n4 1\nkssdy tjzhy ljzym kegqz\n4 kegqz kegqz kegqz vxvyj\n",
"output": "YES YES NO\nNO NO NO YES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1044 | Solve the following coding problem using the programming language python:
You're given an integer N. Write a program to calculate the sum of all the digits of N.
-----Input-----
The first line contains an integer T, the total number of testcases. Then follow T lines, each line contains an integer N.
-----Output--... | ```python
# cook your dish here
number = int(input())
for i in range(number):
a = list(input())
for k in range(len(a)):
a[k] = eval(a[k])
print(sum(a))
``` | vfc_3018 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW006",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n12345\n31203\n2123\n",
"output": "15\n9\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1045 | Solve the following coding problem using the programming language python:
You are given Name of chef's friend and using chef's new method of calculating value of string , chef have to find the value of all the names. Since chef is busy , he asked you to do the work from him .
The method is a function $f(x)$ as follows... | ```python
vow = ['a', 'e', 'i','o', 'u']
for _ in range(int(input())):
name = str(input())
tmp = ''
for i in range(len(name)):
if name[i] not in vow and name[i].isalpha():
tmp+='1'
elif name[i] in vow and name[i].isalpha():
tmp+='0'
print( int(tmp, 2)% (10**9 + 7))
``` | vfc_3022 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LDT42020/problems/NAMEVAL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\ncodechef\n",
"output": "173\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1046 | Solve the following coding problem using the programming language python:
Bears love candies and games involving eating them. Limak and Bob play the following game. Limak eats 1 candy, then Bob eats 2 candies, then Limak eats 3 candies, then Bob eats 4 candies, and so on. Once someone can't eat what he is supposed to ... | ```python
for t in range(int(input())):
limakMax, bobMax = list(map(int, input().split()))
limakEat = 0; bobEat = 0
eating = 1
while limakEat <= limakMax or bobEat <= bobMax:
if eating % 2 != 0 and limakEat <= limakMax:
limakEat += eating
eating += 1
if limakEat > limakMax:
print("Bob")
break
... | vfc_3026 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CANDY123",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n3 2\n4 2\n1 1\n1 2\n1 3\n9 3\n9 11\n9 12\n9 1000\n8 11\n",
"output": "Bob\nLimak\nLimak\nBob\nBob\nLimak\nLimak\nBob\nBob\nBob\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1047 | Solve the following coding problem using the programming language python:
Chef bought a huge (effectively infinite) planar island and built $N$ restaurants (numbered $1$ through $N$) on it. For each valid $i$, the Cartesian coordinates of restaurant $i$ are $(X_i, Y_i)$.
Now, Chef wants to build $N-1$ straight narrow ... | ```python
import sys
def input(): return sys.stdin.readline().strip()
def iinput(): return int(input())
def rinput(): return list(map(int, sys.stdin.readline().strip().split()))
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
t=iinput()
for _ in range(t):
n=iinput()
p=[]
mi=[]... | vfc_3030 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WTBTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n0 0\n0 1\n0 -1\n3\n0 1\n1 0\n-1 0\n",
"output": "0.5\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1048 | Solve the following coding problem using the programming language python:
There are three squares, each with side length a placed on the x-axis. The coordinates of centers of these squares are (x1, a/2), (x2, a/2) and (x3, a/2) respectively. All of them are placed with one of their sides resting on the x-axis.
You are... | ```python
t=int(input())
for i in range(t):
a,k=list(map(int,input().split()))
x1,x2,x3=list(map(int,input().split()))
big=max(x1,x2,x3)
small=min(x1,x2,x3)
q=big-small-2*k
if q>=a:
print(0)
elif -1*q>=0:
print(a*a)
else:
print(a*(a-q))
``` | vfc_3034 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TALESQUA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 0\n1 2 3\n1 1\n1 2 3\n1 1\n1 4 6\n",
"output": "0.000000\n1.0000\n0.0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1049 | Solve the following coding problem using the programming language python:
-----
ARRAY AND DISTINCT ELEMENTS
-----
Chef is multitalented but he mistakenly took part in 2 contest which will take place
at the same time. So while chef is busy at one cooking contest, he wants you to
take part in coding contest. Chef wants... | ```python
#
for _ in range(int(input())):
n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))
s=set(arr)
t1=len(s)
max=-1
for i in range(n-k+1):
temp=set(arr[i:i+k])
#print(temp,i,k+i+1)
t=len(temp)
if t1 == t:
if max<sum(arr[i:k+i]):
max=sum(arr[i:k+i])
print(max)
``` | vfc_3038 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APO12020/problems/APOC2_02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10 6\n8 8 3 5 3 8 5 7 7 7\n",
"output": "37\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1050 | Solve the following coding problem using the programming language python:
Lira is now very keen on compiler development. :)
She knows that one of the most important components of a compiler, is its parser.
A parser is, in simple terms, a software component that processes text, and checks it's semantic correctness, or... | ```python
# cook your dish here
t=int(input())
for j in range(t):
s=input()
st=[]
ans=0
for i in range(len(s)):
if(s[i]=='>'):
if(len(st)!=0 and st[-1]=='<'):
st.pop()
if(len(st)==0):
ans=i+1
else:
... | vfc_3042 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/COMPILER",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n<<>>\n><\n<>>>\n\n",
"output": "4\n0\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1051 | 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 i in range(0,t):
my_ip = int(input().strip())
for xyz in range(my_ip+1):
for abc in range(0,xyz+1):
if abc == xyz:
print(xyz,end="")
else:
print('*',end="")
print()
``` | vfc_3046 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PTRN2020/problems/ITGUY38",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n3\n4\n\n",
"output": "0\n*1\n**2\n0\n*1\n**2\n***3\n0\n*1\n**2\n***3\n****4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1052 | Solve the following coding problem using the programming language python:
You are given positive integers $N$ and $D$. You may perform operations of the following two types:
- add $D$ to $N$, i.e. change $N$ to $N+D$
- change $N$ to $\mathop{\mathrm{digitsum}}(N)$
Here, $\mathop{\mathrm{digitsum}}(x)$ is the sum of de... | ```python
from collections import deque
T=int(input())
def break_down(num):
count=0
while(len(num)!=1):
temp=0
for i in range(0,len(num)):
temp=temp+int(num[i])
num=str(temp)
count=count+1
return (int(num),count)
def digit_sum(num):
temp=0
fo... | vfc_3050 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MINDSUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2 1\n9 3\n11 13\n\n",
"output": "1 9\n3 2\n1 4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1053 | Solve the following coding problem using the programming language python:
Chef has a binary array in an unsorted manner. Cheffina challenges chef to find the transition point in the sorted (ascending) binary array. Here indexing is starting from 0.
Note: Transition point always exists.
-----Input:-----
- First-line w... | ```python
# cook your dish here
for _ in range(int(input())):
n=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(len(A)):
if A[i]==1:
print(i)
break
``` | vfc_3054 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ANITGUY5",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n0 1 0 0 1\n\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1054 | Solve the following coding problem using the programming language python:
Chef likes strings a lot but he likes palindromic strings even more. Today he found an old string s in his garage. The string is so old that some of its characters have faded and are unidentifiable now. Faded characters in the string are represe... | ```python
test=int(input())
for i in range(test):
s=input()
b=len(s)
list1=[]
for j in range(len(s)):
if s[j]=='.':
list1.append(j)
for i in list1:
if b-i-1 in list1 :
if i!=b-i-1 and ((s[i] and s[b-i-1]) != 'a' ):
s=s[:i]+'a'+s[i+1:b-i-1]+'a'+... | vfc_3058 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LEXOPAL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\na.ba\ncb.bc\na.b\n",
"output": "abba\ncbabc\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1055 | Solve the following coding problem using the programming language python:
Chef is planning a huge party for all of you and has ordered M pizzas. He wants to invite as many people to the party. However, he knows that everyone will have exactly one slice of a pizza (regardless of the size) and he wants to make sure that... | ```python
# cook your dish here
m,n=[int(i) for i in input().split()]
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
ans=0
w=0
q=m
for m in range(q):
if(arr[m]>n):
w=1
break
ans+=1+(arr[m]*(arr[m]+1))//2
n-=arr[m]
if(n==0):
print(ans)
else:
if(w==1... | vfc_3062 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PIZPAR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 10\n1 2 3 4 5\n\n",
"output": "31\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1056 | Solve the following coding problem using the programming language python:
Write a program to check whether a triangle is valid or not, when the three angles of the triangle are the inputs. A triangle is valid if the sum of all the three angles is equal to 180 degrees.
-----Input-----
The first line contains an integ... | ```python
n=int(input())
for i in range(n):
a,b,c=map(int,input().split())
if a>0 and b>0 and c>0 and a+b+c==180:
print("YES")
else:
print("NO")
``` | vfc_3066 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW013",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 \n40 40 100\n45 45 90\n180 1 1\n\n",
"output": "YES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1057 | Solve the following coding problem using the programming language python:
Alice is a very brilliant student. He considers '4' and '7' as Magic numbers. The numbers containing only magic numbers are also magical. Given a magic number N ,he wants to know what could be the next magical number greater than the given numbe... | ```python
import math
def magic(a,digits):
m=a%10
if(m==4):
return a+3
elif(m==7):
p=list(str(a))
#print p
for i in range(digits-1,-1,-1):
#print p[i]
if (p[i]=='4'):
#print 'four'
p[i]='7'
p = ''.join(s... | vfc_3070 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALKH2012/problems/NMAGIC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n47\n\n\n",
"output": "7\n74\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1058 | Solve the following coding problem using the programming language python:
There is a popular apps named “Exbook” like “Facebook”. To sign up in this app , You have to make a strong password with more than 3 digits and less than 10 digits . But I am a pro hacker and so I make a Exbook hacking site . You need to login i... | ```python
# cook your dish here
t=int(input())
for i in range(0,t):
p=input()
l=list(p)
for j in range(0,len(l)):
l[j]=int(l[j])
l[j]=l[j]-2
for j in range(0,len(l)):
l[j]=str(l[j])
q=''.join(l)
print(q)
``` | vfc_3074 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ABCC2020/problems/PASSHACK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3527\n47269\n",
"output": "1305\n25047\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1059 | Solve the following coding problem using the programming language python:
You have an array A of size N containing only positive numbers. You have to output the maximum possible value of A[i]%A[j] where 1<=i,j<=N.
-----Input-----
The first line of each test case contains a single integer N denoting the size of the a... | ```python
n = int(input())
a = []
for i in range(n):
a.append(int(input()))
m1 = 0
m2 = 0
for e in a:
if (e > m1):
m2 = m1
m1 = e
elif (e > m2 and e != m1):
m2 = e
ans = 0
for e in a:
temp = m1%e
if (temp>ans):
ans = temp
print(max(m2%m1,ans))
``` | vfc_3078 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCMAR16/problems/MOD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1060 | Solve the following coding problem using the programming language python:
Chef and Abhishek both are fighting for the post of Chairperson to be part of ACE committee and are trying their best. To select only one student their teacher gave them a binary string (string consisting of only 0's and 1's) and asked them to f... | ```python
def countSubstr(str, n, x, y):
tot_count = 0
count_x = 0
for i in range(n):
if str[i] == x:
count_x += 1
if str[i] == y:
tot_count += count_x
return tot_count
t=int(input())
for _ in range(t):
n=int(input())
str... | vfc_3082 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CEFT2020/problems/QFUN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\n1010\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1061 | Solve the following coding problem using the programming language python:
Chef is playing with an expression which consists of integer operands and the following binary
Bitwise operators - AND, OR and XOR. He is trying to figure out that what could be the Maximum possible answer of the expression, given that he can p... | ```python
# cook your dish here
def value(a, b, c):
if(c == '&'):
return a&b
elif(c == '^'):
return a^b
elif(c == '|'):
return a|b
def break_rules(n, operator):
if(len(n) == 1):
return n
elif(len(n) == 2):
return [value(n[0], n[1], operator[0])]
else:
... | vfc_3086 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BIT2C",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3^40|10^2\n92^95|56&2&3\n",
"output": "43\n95\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1062 | Solve the following coding problem using the programming language python:
Ho, Ho, Ho!
It's Christmas time and our friendly grandpa Santa Claus is busy distributing gifts to all the nice children. With the rising population, Santa's workload every year gets increased and he seeks your help to wrap the gifts with fancy ... | ```python
# cook your dish here
def read_i_l(l=False):
m = list(map(int, input().strip().split(" ")))
if l:
return list(m)
else:
return m
def i():
return int(input().strip())
T = i()
L = []
"""for current in range(T):
line = ""
for i in range(current):
line+=str((T-i)%10)... | vfc_3090 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NQST2020/problems/ICEWRAP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n",
"output": "4 4 4 4 4 4 4\n4 3 3 3 3 3 4\n4 3 2 2 2 3 4\n4 3 2 1 2 3 4\n4 3 2 2 2 3 4\n4 3 3 3 3 3 4\n4 4 4 4 4 4 4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1063 | Solve the following coding problem using the programming language python:
Write a program to find the remainder when an integer A is divided by an integer B.
-----Input-----
The first line contains an integer T, the total number of test cases. Then T lines follow, each line contains two Integers A and B.
-----Outp... | ```python
number = int(input())
for i in range(number):
x = list(map(int, input().split(' ')))
print(x[0]%x[1])
``` | vfc_3094 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2\n100 200\n40 15\n",
"output": "1\n100\n10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1064 | Solve the following coding problem using the programming language python:
Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - ... | ```python
from math import gcd
import sys
input=lambda : sys.stdin.readline().strip()
c=lambda x: 10**9 if(x=="?") else int(x)
def main():
for _ in range(int(input())):
s=list(input())[::-1]
l=['F','E','H','C']
i=0
while(i<len(s)):
if(i+3<len(s)):
f=True
for j in range(i,i+4):
if(l[j-i]==s[j] o... | vfc_3098 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MANYCHEF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n???C???\n",
"output": "CHEFCIELISACHEF\nCHEFCIELISOURCHEF\nTAKEITEASY\nCHEFCHEF\nAAACHEF\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1065 | Solve the following coding problem using the programming language python:
Chefland is a grid with N$N$ rows and M$M$ columns. Each cell of this grid is either empty or contains a house. The distance between a pair of houses is the Manhattan distance between the cells containing them.
For each d$d$ between 1$1$ and N+M... | ```python
# cook your dish here
for a in range(int(input())):
N,M=map(int,input().split())
b=[]
for o in range(N):
b.append(input())
c=[]
for d in b:
f=[]
for e in range(len(d)):
if d[e]=='1':
f.append(e)
c.append(f)
i=[]
for g in range(len(c)):
for h in... | vfc_3102 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/AVGMAT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 4\n0011\n0000\n0100\n",
"output": "1 0 1 1 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1066 | Solve the following coding problem using the programming language python:
-----
CHEF N TIMINGS
-----
One day chef was working with some random numbers. Then he found something
interesting. He observed that no 240, 567, 9999 and 122 and called these numbers
nice as the digits in numbers are in increasing order. Also h... | ```python
for _ in range(int(input())):
n=input().rstrip()
n=[ele for ele in n]
l=len(n)
m=10**18+8
ini=1
for i in range(l-1,-1,-1):
if int(n[i])<=m:
if ini==1:
m=int(n[i])
else:
m=max(m,n[i])
else:
m=int(n[i])-1
n[i]=str(m)
for j in range(l-1,i,-1):
n[j]='9'
i=0
while n[i]=='... | vfc_3106 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APO12020/problems/APOC2_04",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n132\n",
"output": "129\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1067 | Solve the following coding problem using the programming language python:
Chef has a strip of length $N$ units and he wants to tile it using $4$ kind of tiles
-A Red tile of $2$ unit length
-A Red tile of $1$ unit length
-A Blue tile of $2$ unit length
-A Blue tile of $1$ unit length
Chef is having an infinite ... | ```python
# Fibonacci Series using
# Optimized Method
# function that returns nth
# Fibonacci number
MOD = 1000000007
def fib(n):
F = [[2, 2],
[1, 0]]
power(F, n - 1)
ans = [6, 2]
return (F[0][0] * 6 + F[0][1] * 2) % MOD
# return F[0][0]
def multiply(F, M):
x = (F[... | vfc_3110 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COG2020/problems/COG2004",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1068 | Solve the following coding problem using the programming language python:
Ada's classroom contains $N \cdot M$ tables distributed in a grid with $N$ rows and $M$ columns. Each table is occupied by exactly one student.
Before starting the class, the teacher decided to shuffle the students a bit. After the shuffling, ea... | ```python
# cook your dish here
t=int(input())
for _ in range(t):
N, M=map(int,input().split())
if(N%2==0 or M%2==0):
print("YES")
else:
print("NO")
``` | vfc_3114 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ADASCOOL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 3\n4 4\n",
"output": "NO\nYES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1069 | Solve the following coding problem using the programming language python:
Shivam is the youngest programmer in the world, he is just 12 years old. Shivam is learning programming and today he is writing his first program.
Program is very simple, Given two integers A and B, write a program to add these two numbers.
-... | ```python
#Note that it's python3 Code. Here, we are using input() instead of raw_input().
#You can check on your local machine the version of python by typing "python --version" in the terminal.
#Read the number of test cases.
T = int(input())
for tc in range(T):
# Read integers a and b.
(a, b) = list(map(int, inpu... | vfc_3118 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW001",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2\n100 200\n10 40\n",
"output": "3\n300\n50\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1070 | Solve the following coding problem using the programming language python:
and Bengali as well.
There are N$N$ cats (numbered 1$1$ through N$N$) and M$M$ rats (numbered 1$1$ through M$M$) on a line. Each cat and each rat wants to move from some point to some (possibly the same) point on this line. Naturally, the cats a... | ```python
# cook your dish here
# cook your dish here
class Animal:
def __init__(self):
start, end, starting_time = map(int, input().split())
self.ending_time = starting_time + abs(start - end)
self.velocity = 1 if end >= start else -1
self.eaten_by = -1, 10 ** 10
... | vfc_3122 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CATSRATS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n8 7\n2 5 1\n1 4 1\n9 14 10\n20 7 9\n102 99 1\n199 202 1\n302 299 3\n399 402 3\n6 3 1\n10 15 10\n100 101 1\n201 200 1\n300 301 5\n401 400 5\n1000 1010 1020\n8 8\n2 8 2\n12 18 2\n22 28 4\n32 38 4\n48 42 2\n58 52 3\n68 62 1\n78 72 ... |
apps | verifiable_code | 1071 | Solve the following coding problem using the programming language python:
Bob just learned about bitwise operators. Since Alice is an expert, she decided to play a game, she will give a number $x$ to Bob and will ask some questions:
There will be 4 different kinds of queries:-
-
Alice gives an integer $i$ and Bob has... | ```python
# cook your dish here
t=int(input())
while t>0:
n,q=list(map(int,input().split()))
blst=[0]
for i in range(1,65):
blst.append(0)
i=1
while n>0:
if n%2:
blst[i]=1
n//=2
i+=1
while q>0:
n=int(input())
if n==1:
p=int(... | vfc_3126 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENDE2020/problems/ENCDEC03",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2\n2\n1\n1\n1\n",
"output": "ON\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1072 | Solve the following coding problem using the programming language python:
Problem description.
Winston and Royce love sharing memes with each other. They express the amount of seconds they laughed ar a meme as the number of ‘XD’ subsequences in their messages. Being optimization freaks, they wanted to find the string ... | ```python
t=int(input())
for i in range(t):
n=int(input())
r=int(n**(.5))
d=n-r*r
m=d%r
print('X'*m+'D'*(m>0)+'X'*(r-m)+'D'*(r+d//r))
``` | vfc_3130 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/XDS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n9\n",
"output": "XXXDDD\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1073 | Solve the following coding problem using the programming language python:
You are given two integers $N$ and $M$. Find the number of sequences $A_1, A_2, \ldots, A_N$, where each element is an integer between $1$ and $M$ (inclusive) and no three consecutive elements are equal. Since this number could be very large, co... | ```python
import sys
def fin(): return sys.stdin.readline().strip()
def fout(s, end="\n"): sys.stdout.write(str(s)+end)
MOD = pow(10, 9)+7
t = int(input())
while t>0:
t -= 1
n, m = list(map(int, fin().split()))
if n == 1:
print(m%MOD)
continue
dp1 = m*(m-1)
dp2 = m
for i in range(3, n+1):
temp = dp2
dp2 ... | vfc_3134 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CARR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2\n3 4\n",
"output": "4\n60\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1074 | Solve the following coding problem using the programming language python:
Chef is making Window frames for his new office, for this he has n wooden Logs whose lengths are l1, l2, … ln respectively. Chef Doesn’t want to break any logs or Stick 2 or more logs together.
To make a h × w Window Frame, he needs two Logs w... | ```python
# cook your dish here
t=int(input())
j=0
while j<t:
n=int(input())
lst=list(map(int,input().split()))
s=set()
d=list()
for i in lst:
if i in s:
s.remove(i)
d.append(i)
else:
s.add(i)
x=len(d)
if x%2==0:
print(x//2)
els... | vfc_3138 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NITJ2021/problems/CIN005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\n1 2 1 2\n8\n1 2 1 3 4 1 5 6\n",
"output": "1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1075 | Solve the following coding problem using the programming language python:
Henry and Derek are waiting on a room, eager to join the Snackdown 2016 Qualifier Round. They decide to pass the time by playing a game.
In this game's setup, they write N positive integers on a blackboard. Then the players take turns, startin... | ```python
gb = [0, 1, 2, 2, 3, 3]
ga = [0 for x in range(70)]
gag = [0 for x in range(70)]
ga[0] = 1
gag[0] = 0
for i in range(1, 70):
if i % 4 == 0:
ga[i] = 1.5 * ga[i-1]
gag[i] = 0
else:
ga[i] = 2 * ga[i-1]
gag[i] = gag[i-1] + 1
def g(n):
if n < 6:
return gb[n]
else:
x = n / 6
a = 0
for i, k in... | vfc_3142 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SNCKQL16/problems/FDIVGAME",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n3 4\n3\n1 3 5\n",
"output": "Henry\nDerek\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1076 | Solve the following coding problem using the programming language python:
You are given an unweighted tree with N$N$ nodes (numbered 1$1$ through N$N$). Let's denote the distance between any two nodes p$p$ and q$q$ by d(p,q)$d(p, q)$.
You should answer Q$Q$ queries. In each query, you are given parameters a$a$, da$d_a... | ```python
# cook your dish here
class TestCase:
def __init__(self):
[self.node_count, self.query_count] = read_line()
def fill_nodes(self):
self.nodes = {n+1: [] for n in range(self.node_count)}
for i in range(self.node_count -1):
new_node_1, new_node_2 = read_line()... | vfc_3146 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DDQUERY",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3\n1 2\n2 3\n3 4\n3 5\n2 1 4 1\n2 2 4 2\n1 1 2 1\n",
"output": "3\n5\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1077 | Solve the following coding problem using the programming language python:
Chef recently printed directions from his home to a hot new restaurant across the town, but forgot to print the directions to get back home. Help Chef to transform the directions to get home from the restaurant.
A set of directions consists of s... | ```python
t = int(input())
for i in range(t):
n = int(input())
dir = []
for j in range(n):
dir.append(input().strip().split())
for j in range(n-1):
if dir[j+1][0] == 'Right':
dir[j][0] = 'Left'
else:
dir[j][0] = 'Right'
dir[n-1][0] = 'Begin'
... | vfc_3150 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK29/problems/DIRECTI",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBegin on Old Madras Road\nLeft on Domlur Flyover\nLeft on 100 Feet Road\nRight on Sarjapur Road\nRight on Hosur Road\nRight on Ganapathi Temple Road\n\n",
... |
apps | verifiable_code | 1078 | Solve the following coding problem using the programming language python:
For her next karate demonstration, Ada will break some bricks.
Ada stacked three bricks on top of each other. Initially, their widths (from top to bottom) are $W_1, W_2, W_3$.
Ada's strength is $S$. Whenever she hits a stack of bricks, consider ... | ```python
t=int(input())
for i in range(t):
n,w1,w2,w3=map(int,input().split())
if n>=w1+w2+w3:
print(1)
elif n>=w1+w2 or n>=w2+w3:
print(2)
else:
print(3)
``` | vfc_3154 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BRKBKS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 1 2 2\n2 1 1 1\n3 2 2 1\n",
"output": "2\n2\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1079 | Solve the following coding problem using the programming language python:
Kostya likes the number 4 much. Of course! This number has such a lot of properties, like:
- Four is the smallest composite number;
- It is also the smallest Smith number;
- The smallest non-cyclic group has four elements;
- Four is the maximal... | ```python
# cook your dish here
x=int(input())
for i in range(x):
h=input()
print(h.count('4'))
``` | vfc_3158 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LUCKFOUR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n447474\n228\n6664\n40\n81\n",
"output": "4\n0\n1\n1\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1080 | Solve the following coding problem using the programming language python:
Every day, Mike goes to his job by a bus, where he buys a ticket. On the ticket, there is a letter-code that can be represented as a string of upper-case Latin letters.
Mike believes that the day will be successful in case exactly two different ... | ```python
def res(s):
if len(s) == 2:
if s[0] == s[1]:
print("NO")
else:
print("YES")
elif s[0] != s[1]:
counte = 0
for i in range(2, len(s)):
if i % 2 == 0:
if s[i] != s[0]:
counte = 1
break
else:
if s[i] != s[1]:
counte = 1
break
if counte == 0:
print("YES")
... | vfc_3162 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TICKETS5",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nABABAB\nABC\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1081 | Solve the following coding problem using the programming language python:
A spy needs your help to encrypt a 5 letter message.
To encrypt the message the following steps are need to be done:
1)Each letter of the message will be converted to it's equivalent number (i.e A=0, B=1,..Z=25)
2)98, 57, 31, 45, 46 are the 5 ... | ```python
# cook your dish here
import string
from collections import OrderedDict
from itertools import zip_longest
dic = OrderedDict(zip(string.ascii_uppercase, range(0, 26)))
keys = [98, 57, 31, 45, 46]
t = int(input()) # number of test cases
s1 = []
for i in range(t):
s = input()
for i in s:
if i in dic.key... | vfc_3166 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/STRG2020/problems/ENCYP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nHELLO\nHELL\n",
"output": "BJQEI\nBJQE\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1082 | Solve the following coding problem using the programming language python:
$Jaggu$ monkey a friend of $Choota$ $Bheem$ a great warrior of $Dholakpur$. He gets everything he wants. Being a friend of $Choota$ $Bheem$ he never has to struggle for anything, because of this he is in a great debt of $Choota$ $Bheem$, he real... | ```python
counter = -1
def flattree(node):
nonlocal counter
if visited[node]==1:
return
else:
visited[node]=1
counter += 1
i_c[node] = counter
flat_tree[counter] = swt[node]
for i in graph[node]:
if visited[i]==0:
fl... | vfc_3170 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFY2020/problems/GKSMNHM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "10\n10 12 6 8 1 19 0 5 13 17\n1 2\n1 3\n1 4\n3 10\n4 8\n8 9\n4 5\n5 7\n5 6\n3\n1 1\n2 3 20\n1 8\n",
"output": "10\n23\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1083 | Solve the following coding problem using the programming language python:
Probably everyone has experienced an awkward situation due to shared armrests between seats in cinemas. A highly accomplished cinema manager named "Chef" decided to solve this problem.
When a customer wants to buy a ticket, the clerk at the tic... | ```python
for i in range(eval(input())):
n,m,z,l,r,b = list(map(int, input().split()))
rows=n
columns=m
hand_rest=n*(m+1)
if(m%2==0):
hand_rest -=max(0,n-l-r)
if(l+r+(2*b)<=hand_rest):
# print "kanu"
print(min(n*m,l+r+z+b))
else:
temp=l+r+(hand_rest-l-r)/2
# print "parth"
print(min(n*m,temp+z))
``` | vfc_3174 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/DEC15/problems/CHCINEMA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2 2 3 2 1 1\n3 3 1 2 0 9\n",
"output": "4\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1084 | Solve the following coding problem using the programming language python:
You are given a binary string S. You need to transform this string into another string of equal length consisting only of zeros, with the minimum number of operations.
A single operation consists of taking some prefix of the string S and flippin... | ```python
# cook your dish here
s=input()
s1=s[::-1]
arr=[]
cnt=0
for i in range(len(s1)):
arr.append(s1[i])
for i in range(len(arr)):
if(arr[i]=="1"):
for j in range(i,len(arr)):
if(arr[j]=="1"):
arr[j]="0"
else:
arr[j]="1"
cnt+=1
print(cnt)
``` | vfc_3178 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PREFINVS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "01001001\n",
"output": "6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 1085 | Solve the following coding problem using the programming language python:
-----Problem-----
Once THANMAY met PK who is from a different planet visiting earth. THANMAY was very fascinate to learn PK's language. The language contains only lowercase English letters and is based on a simple logic that only certain cha... | ```python
d = {}
for i in range(26):
char = chr(i+ord('a'))
d[char] = []
for i in range(26):
char = chr(i+ord('a'))
temp = list(map(int,input().strip().split()))
for j in range(26):
if (temp[j] == 1):
follow= chr(j+ord('a'))
d[follow].append(char)
def f(char,i,n,count):
if (i==n):
return count+1
el... | vfc_3182 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMN2016/problems/THANPK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0... |
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.