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 | 686 | Solve the following coding problem using the programming language python:
Chef has been working in a restaurant which has N floors. He wants to minimize the time it takes him to go from the N-th floor to ground floor. He can either take the elevator or the stairs.
The stairs are at an angle of 45 degrees and Chef's... | ```python
n=int(input())
l=[]
for i in range(0,n):
a,b,c=map(int,input().split())
n1=(2**0.5)*(a/b)
n2=2*(a/c)
if n1>n2:
l.append("Elevator")
else:
l.append("Stairs")
for i in l:
print(i)
``` | vfc_1586 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ELEVSTRS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 10 15\n2 10 14\n7 14 10\n",
"output": "Elevator\nStairs\nStairs\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 687 | Solve the following coding problem using the programming language python:
The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ..., N.
He calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of i... | ```python
from sys import stdin
t = int(stdin.readline())
def count(n, arr):
loc = 0
glob = 0
for i in range(n-1):
if arr[i] > arr[i+1]:
loc += 1
for i in range(n-1):
for j in range(i+1, n):
if glob > loc:
return 0
if arr[i] > arr[j]:
glob += 1;
if glob == loc:
return 1
return 0
for _ in ... | vfc_1590 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK28/problems/LEPERMUT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n1\n2\n2 1\n3\n3 2 1\n4\n1 3 2 4\n",
"output": "YES\nYES\nNO\nYES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 688 | Solve the following coding problem using the programming language python:
You are given a string s of length 8 consisting solely of '0's and '1's. Assume that the characters of the string are written in a circular fashion. You need to find the number of 0-1 or 1-0 transitions that one has to make while making a single... | ```python
n = int(input())
# this code only for 8 bits string and it isn't possible to more than 8 bits of string
# for i in range(n):
# s = input()
# subString1, subString2 = s[:4], s[4:]
# rev = subString2[::-1]
# print( 'uniform' if(subString1 == rev) else 'non-uniform')
for i in range... | vfc_1594 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/STRLBP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n00000000\n10101010\n10000001\n10010011\n",
"output": "uniform\nnon-uniform\nuniform\nnon-uniform\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 689 | Solve the following coding problem using the programming language python:
In africa jungle , there were zebra's who liked to spit.
There owner watched them for whole day and noted in his sheet where each zebra spitted.
Now he's in a confusion and wants to know if in the jungle there are two zebra's which spitted at ea... | ```python
# cook your dish here
t=int(input())
i=0
a=0
d=dict()
while i<t:
l=input().split()
d[int(l[0])]=int(l[0])+int(l[1])
i+=1
for k in d:
if d[k] in d:
if d[d[k]]==k:
a=1
break
if a==1:
print("YES")
else:
print("NO")
``` | vfc_1598 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CMR12121/problems/ZBJNG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n0 1\n1 -1\n",
"output": "YES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 690 | Solve the following coding problem using the programming language python:
You are a king and you are at war. If the enemy breaks through your frontline you lose.
Enemy can break the line only if the sum of morale of any $K$ continuous soldiers is strictly less than $M$. So, you being a motivational orator decides to b... | ```python
n,k,m = map(int,input().split())
ar = list(map(int,input().split()))
fsum = [ar[0]]
for i in range(1,n):
fsum.append(fsum[i-1]+ar[i])
i = k
#print(fsum)
c = 0
while i <= n:
if i == k:
s = fsum[i-1]
else:
s = fsum[i-1]-fsum[i-k-1]
if s == 0:
c = -1
break
if s... | vfc_1602 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INTW2020/problems/MORALE99",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6 2 5\n1 1 1 1 1 1\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 691 | Solve the following coding problem using the programming language python:
You are given a sequence $A_1, A_2, \ldots, A_N$. For each valid $i$, the star value of the element $A_i$ is the number of valid indices $j < i$ such that $A_j$ is divisible by $A_i$.
Chef is a curious person, so he wants to know the maximum sta... | ```python
T = int(input())
for _ in range(T):
n = int(input())
arr = list(map(int, input().split()))
a = [0 for _ in range(max(arr)+1)]
star_val = []
for i in range(len(arr)):
j = 1
val = 0
while j*arr[i] <= len(a):
val += a[j*arr[i]-1]
j += 1
star_val.append(val)
a[arr[i]-1] += 1
print(max(star_v... | vfc_1606 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MSV",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n8 1 28 4 2 6 7\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 692 | Solve the following coding problem using the programming language python:
There is crazy man named P29892P. He always tries to do crazy things as he thinks. One day he invented a machine and named it as ANGEN. The ANGEN is used to perform range operations. The range operation means performing operations on range value... | ```python
VQ = "UAMmSs"
n = int(input())
a = list(map(int, input().split()))
for _ in range(int(input())):
q, x, y = input().split()
if q not in VQ:
print("!!!")
continue
if q == "U":
a[int(x) - 1] = int(y)
continue
l = int(x) - 1
r = int(y)
if q == "A":
print(sum(a[l:r]))
continue
if q == "M":
pri... | vfc_1610 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CRES2016/problems/CRES104",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n1 2 5 3 10 6\n6\nA 1 5\nM 1 3\nm 5 6\ns 3 6\nU 1 7\nS 1 2\n",
"output": "21\n5\n6\n5\n2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 693 | Solve the following coding problem using the programming language python:
Write a program to find the factorial value of any number entered by the user.
-----Input-----
The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains an integer N.
-----Output-----
For ea... | ```python
# cook your dish here
x=int(input())
for i in range(x):
s=int(input())
fact=1
for i in range(1,s+1):
fact=fact*i
print(fact)
``` | vfc_1614 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW018",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n4\n5\n",
"output": "6\n24\n120\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 694 | Solve the following coding problem using the programming language python:
The MarkiT online virtual market startup wants to organize its grand opening in NIT Patna.
but they want maximum crowd for their inauguration. So the manager told this to Praveen a student in NITP who suggested them:
The first-year students co... | ```python
import math
def fun(num1,num2):
if num1>num2:
a=num1
b=num2
else:
a=num2
b=num1
rem=a%b
while(rem!=0):
a=b
b=rem
rem=a%b
gcd=b
return (int((num1*num2)/gcd))
for _ in range (int(input())):
hours=int(input())*24
x,y,z=list(map(int,input().split()))
lcm=x
lcm=fun(x,y)
lcm=fun(lcm,z)
... | vfc_1618 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/STRT2020/problems/CRWDCN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10\n8 10 6\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 695 | Solve the following coding problem using the programming language python:
You are given three non-negative integers $X$, $Y$ and $N$. Find the number of integers $Z$ such that $0 \le Z \le N$ and $(X \oplus Z) < (Y \oplus Z)$, where $\oplus$ denotes the bitwise XOR operation.
-----Input-----
- The first line of the i... | ```python
# cook your dish here
tc=int(input())
for j in range(tc):
ip=list(map(int,input().rstrip().split()))
x=ip[0]
y=ip[1]
n=ip[2]
cnt=0
if(x==y):
print('0')
continue
ln=bin(x).replace("0b", "")
rn=bin(y).replace("0b", "")
ll=len(ln)
rl=len(rn)
#print(ln)
#print(rn)
if(ll==len(rn)):
for i in ra... | vfc_1622 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/XORCOMP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 2 10\n2 1 10\n0 0 7\n",
"output": "6\n5\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 696 | Solve the following coding problem using the programming language python:
You are given a permutation of natural integers from 1 to N, inclusive. Initially, the permutation is 1, 2, 3, ..., N.
You are also given M pairs of integers, where the i-th is (Li Ri). In a single turn you can choose any of these pairs (let's s... | ```python
t=int(input())
for _ in range(t):
n,m=list(map(int,input().split()))
l=list(map(int,input().split()))
k=[]
for i in range(m):
a,b=list(map(int,input().split()))
k.append([a,b])
k.sort()
c=[]
flag=1
x=k[0][0]
y=k[0][1]
for i in k[1:]:
if i[0]<=y:
y=max(y,i[1])
else:
c.append([x-1,y-1]... | vfc_1626 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PERMSUFF",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7 4\n3 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\n2 3\n",
"output": "Possible\nImpossible\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 697 | Solve the following coding problem using the programming language python:
In Programmers Army Land, people have started preparation as sports day is scheduled next week.
You are given a task to form 1 team of $k$ consecutive players, from a list of sports player whose powers are given to you.
You want your team to win... | ```python
# cook your dish here
def func(arr, k):
sumi = 0
for j in range(k):
sumi += arr[j]
maxi = sumi
for i in range(k,len(arr)):
sumi -= arr[i - k]
sumi += arr[i]
maxi = max(maxi,sumi)
return maxi
for _ in range(int(input())):
n, k = map(int,input().split())
... | vfc_1630 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ARYS2020/problems/CSHIP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 3\n1 2 3 4 5\n",
"output": "12\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 698 | Solve the following coding problem using the programming language python:
For years you have been working hard in Santa's factory to manufacture gifts for kids in substandard work environments with no pay. You have finally managed to escape the factory and now you seek revenge. You are planning a heist with the Grinch... | ```python
import math
t = int(input())
def phi(n):
res = n
i = 2
while i*i<=n:
if n%i==0:
res/=i
res*=(i-1)
while n%i==0:
n/=i
i+=1
if n>1:
res/=n
res*=(n-1)
return int(res)
while t:
a,m = list(map(int,input().split()))
g = math.gcd(a,m)
print(phi(m//g))
t-=1
``` | vfc_1634 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/NQST2020/problems/HEIST101",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4 9\n5 10\n42 9999999967\n",
"output": "6\n1\n9999999966\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 699 | Solve the following coding problem using the programming language python:
Chef wants to host some Division-3 contests. Chef has $N$ setters who are busy creating new problems for him. The $i^{th}$ setter has made $A_i$ problems where $1 \leq i \leq N$.
A Division-3 contest should have exactly $K$ problems. Chef wa... | ```python
for T in range(int (eval(input()))):
N,K,D=list(map(int,input().split()))
A=list(map(int,input().split()))
P=sum(A)//K
print(min(P,D))
``` | vfc_1638 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DIVTHREE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 5 31\n4\n1 10 3\n23\n2 5 7\n20 36\n2 5 10\n19 2\n3 3 300\n1 1 1\n",
"output": "0\n2\n7\n4\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 700 | Solve the following coding problem using the programming language python:
Now-a-days, Manish is becoming famous for bank robbery in the country because of his cleverness, he never robs own his own.He has four workers A , B, C, and D , all working under him.All of the four take some amount for that. There are total N ... | ```python
for t in range(int(input())):
n = int(input())
l = []
m = []
x = list(map(int,input().split()))
l.append(x)
m.append(list(x))
for i in range(1,n):
x = list(map(int,input().split()))
l.append(x)
temp = []
for i in range(4):
temp.append (x[i]+min(m[-1][:i]+m[-1][i+1:]))
m.append(temp)
print... | vfc_1642 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ICOD2016/problems/ICODE16D",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3\n4 7 2 9\n5 6 4 7\n2 6 4 3\n",
"output": "10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 701 | Solve the following coding problem using the programming language python:
You are given a sequence of N$N$ powers of an integer k$k$; let's denote the i$i$-th of these powers by kAi$k^{A_i}$. You should partition this sequence into two non-empty contiguous subsequences; each element of the original sequence should app... | ```python
# cook your dish here
def main():
for _ in range(int(input())):
N, k = [int(x) for x in input().split()]
Powers = [k ** int(x) for x in input().split()]
s1, s2 = 0, sum(Powers)
ans = (0, None)
i = 0
while i < N - 1:
s1 += Powers[i]
s2 -= Powers[i]
... | vfc_1646 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MXM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5 2\n1 1 3 3 5\n",
"output": "4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 702 | Solve the following coding problem using the programming language python:
This is a peculiar functioning setup.
Two Tanks are separated from each other by a wall .There is a pipe in the wall which connects both tanks which allows flow of water between them . Due to this ,there is change in temperature of both tanks ... | ```python
for i in range(int(input())):
m,tc,th=map(int,input().split())
x=(th-tc)
if x%3!=0:
print("Yes")
else:
if (x//3)<=m:
print("No")
else:
print("Yes")
``` | vfc_1650 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COCA2020/problems/HOTNCOLD",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 5 10\n2 2 5\n",
"output": "Yes\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 703 | Solve the following coding problem using the programming language python:
Chef gives an integer $K$ in the input. If the given number is beautiful binary number, print it, Else find its previous beautiful binary number. A beautiful binary number is a number whose binary representation does not contain any consecutive... | ```python
pref = []
for i in range(10 ** 5 + 10):
b = bin(i)[2:]
if not any(b[j] == b[j+1] == '1' for j in range(len(b) - 1)):
pref.append(i)
else:
pref.append(pref[-1])
for i in range(int(input())):
print(pref[int(input())])
``` | vfc_1654 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK02020/problems/ITGUY10",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n6\n8\n",
"output": "2\n5\n8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 704 | Solve the following coding problem using the programming language python:
Eugene has to do his homework. But today, he is feeling very lazy and wants to you do his homework. His homework has the following given maths problem.
You are given three integers: A, N, M. You write the number A appended to itself N times in a... | ```python
# cook your dish here
for _ in range(int(input())):
a,n,m = map(int,input().split(' '))
s = len(str(a))
#print(s)
c = 10**s - 1
w = c*m
b = pow(10,n*s,w)-1
d = b//c
ans = (d%m)*(a%m)
print(ans%m)
``` | vfc_1658 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/KBIGNUMB",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n12 2 17\n523 3 11\n\n\n",
"output": "5\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 705 | Solve the following coding problem using the programming language python:
A city of dimension N x N is constructed with grid of lanes. These lanes are fenced by government so that no one can cross any grid diagonally. Although a train
line runs diagonally from (0,0) to (N,N).
Our chef has a weird kind of phobia and i... | ```python
ar = []
ar.append(1)
for i in range(1, 31):
ar.append(ar[i-1]*(4*i-2)/(i+1))
t = int(input())
while(t>0):
n = int(input())
if(n==0):
print(0)
else:
print(ar[n]*2)
t=t-1
``` | vfc_1662 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALGT2013/problems/TNMALG02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n5\n",
"output": "4\n84\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 706 | Solve the following coding problem using the programming language python:
Chef has $N$ small boxes arranged on a line from $1$ to $N$. For each valid $i$, the weight of the $i$-th box is $W_i$. Chef wants to bring them to his home, which is at the position $0$. He can hold any number of boxes at the same time; however... | ```python
t=int(input())
for i in range(t):
x,y=0,0
n,m=list(map(int,input().split()))
l=list(map(int,input().split()))
if(max(l)>m):
print(-1)
else:
for i in range(len(l)):
y+=l[i]
if(y>m):
y=l[i]
x+=1
if(y>0):
x+=1
print(x)
``` | vfc_1666 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFNWRK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 1\n2\n2 4\n1 1\n3 6\n3 4 2\n3 6\n3 4 3\n",
"output": "-1\n1\n2\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 707 | Solve the following coding problem using the programming language python:
In 17th century our Chef was a Wizard. He asked his small son "Anshu" to bring him the secret of the Magical Mountain. The boy after travelling a lot reached the Mountain.
The description of the Mountain was as follows:
- Mountain contains N ma... | ```python
for t in range(eval(input())):
n = eval(input())
a = [ [] for i in range(n+1) ]
for i in range(n-1):
x,y = list(map( int, input().split() ))
a[x].append(y)
a[y].append(x)
vis = [0] * (n+1)
vis[1] = 1
ans = [1]
t1 = [1]
t2 = []
while len(t1) > 0 :
for u in t1:... | vfc_1670 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDVA16/problems/CDVA1602",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n1 2\n1 3\n2 4\n2 5\n",
"output": "1 2 3 4 5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 708 | Solve the following coding problem using the programming language python:
You are given a square matrix $M$ with $N$ rows (numbered $1$ through $N$) and $N$ columns (numbered $1$ through $N$). Initially, all the elements of this matrix are equal to $A$. The matrix is broken down in $N$ steps (numbered $1$ through $N$)... | ```python
# cook your dish here
for _ in range(int(input())):
n,k = list(map(int,input().split()))
mod = 10**9+7
s=0
for i in range(1,n+1):
p = pow(k,(2*i)-1,mod)
# print(p)
s=(s+p)%mod
# print(k)
k = (p*k)%mod
print(s)
``` | vfc_1674 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MATBREAK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 2\n",
"output": "511620149\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 709 | Solve the following coding problem using the programming language python:
$Gogi$, $Tapu$ and $Sonu$ are the elite members of $Tapu$ $Sena$. $Gogi$ is always stoned and asks absurd questions, But this time he asked a question which seems to be very serious and interesting. $Tapu$ wants to solve this question to impress... | ```python
# cook your dish here
try:
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
gcd = max(a[0], a[-1])
print(gcd)
except EOFError:pass
``` | vfc_1678 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CORE2020/problems/CORE2002",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1\n2\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 710 | Solve the following coding problem using the programming language python:
Blob is a computer science student. He recently got an internship from Chef's enterprise. Along with the programming he has various other skills too like graphic designing, digital marketing and social media management. Looking at his skills Che... | ```python
def maxval(arr):
fn = [float('-inf')]*(len(arr)+1)
sn = [float('-inf')]*len(arr)
tn = [float('-inf')]*(len(arr)-1)
fon = [float('-inf')]*(len(arr)-2)
for i in reversed(list(range(len(arr)))):
fn[i] = max(fn[i + 1], arr[i])
for i in reversed(list(range(len(arr) - 1))):
s... | vfc_1682 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/WNTR2020/problems/WC04",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n3 9 10 1 30 40\n",
"output": "46\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 711 | Solve the following coding problem using the programming language python:
The notorious hacker group "Sed" managed to obtain a string $S$ from their secret sources. The string contains only lowercase English letters along with the character '?'.
A substring of $S$ is a contiguous subsequence of that string. For exampl... | ```python
def convertToParitys(s):
"""
This converts the string s to an int, which is a bitMap of the parity of each letter
odd ? = first bit set
odd a = second bit set
odd b = third bit set
etc
"""
keys = '?abcdefghijklmnopqrstuvwxyz'
paritys = {c:0 for c in keys}
for... | vfc_1686 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SEDPASS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\naa?\na???\n????\nasfhaslskfak\naf??avvnfed?fav?faf????\n\n",
"output": "2\n6\n4\n2\n27\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 712 | Solve the following coding problem using the programming language python:
Chef got into a fight with the evil Dr Doof. Dr Doof has decided to destroy all even numbers from the universe using his Evil-Destroy-inator. Chef has $N$ integers with him. To stop Doof, Chef has to find an odd number which is an integer multip... | ```python
def gcd(a,b):
if b==0: return a
return gcd(b,a%b)
for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
value = arr[0]
if n!=1:
for i in arr[1:]:
value = value*i//gcd(value, i)
if value%2==0:
print("NO")
else:
print("YES")
``` | vfc_1690 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COLE2020/problems/CLLCM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n1 2 5 4 3\n1\n7\n",
"output": "NO\nYES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 713 | Solve the following coding problem using the programming language python:
Chef has a sequence of $N$ integers, $A_1, A_2, ... , A_N$. He likes this sequence if it contains a subsequence of $M$ integers, $B_1, B_2, ... , B_M$ within it.
A subsequence is a sequence that can be derived from another sequence by deleting ... | ```python
t=int(input())
i=0
while i<t:
n=int(input())
A=[]
A=input().split()
m=int(input())
B=[]
B=input().split()
j=0
a=-1
while j<m:
c=1
if B[j] in A:
b=A.index(B[j])
A.remove(B[j])
if b>=a:
a=b
c=1
else:
c=0
break
else:
c=0
break
j+=1
if c==1:
print("Yes")
else... | vfc_1694 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFSQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15\n4\n1 3 4 2\n2\n1 2\n",
"output": "Yes\nNo\nYes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 714 | Solve the following coding problem using the programming language python:
It's John's birthday; he has brought some candies in distribute among N of his friends. Being a good friend, he decided to distribute all of his candies equally among his friend and he don't want to keep any for himself. He left the task of dist... | ```python
# cook your dish here
import math
for t in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
div=sum(a)/n
div=math.ceil(div)
count=div*n-sum(a)
for i in a:
if i>div:
count+=i-div
print(count)
``` | vfc_1698 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/WNTR2020/problems/WC07",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n7 8 6 4\n6\n7 3 10 2 3 8\n1\n10\n",
"output": "4\n10\n0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 715 | Solve the following coding problem using the programming language python:
Recently Rocky had participated in coding competition and he is sharing one of the problem with you which he was unable to solve. Help Rocky in solving the problem.
Suppose the alphabets are arranged in a row starting with index 0$0$ from AtoZ$A... | ```python
# cook your dish here
s = input().strip()
start_w = 27
w_dict = {}
words = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
for word in words:
w_dict[word] = start_w
start_w = start_w - 1
total_wt = 0
for c in s:
to... | vfc_1702 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CFUN2020/problems/CODSTAN6",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "A\nAND\n",
"output": "27\n65\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 716 | Solve the following coding problem using the programming language python:
Chef has created a special dividing machine that supports the below given operations on an array of positive integers.
There are two operations that Chef implemented on the machine.
Type 0 Operation
Update(L,R):
for i = L to R:
a[i] = a[i] /... | ```python
import math
n=1001
a=[True]*n
l=[]
for i in range(2,33):
if(a[i]):
for j in range(i*i,n,i):
a[j]=False
for pr in range(2,1001):
if(a[pr]):
l.append(pr)
t=int(input())
for j in range(t):
n,m=list(map(int,input().strip().split()))
arr=[int(num) for num in input().strip().split()]
Matrix =[]
index=[... | vfc_1706 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SEPT16/problems/DIVMAC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n6 7\n2 5 8 10 3 44\n1 2 6\n0 2 3\n1 2 6\n0 4 6\n1 1 6\n0 1 6\n1 4 6\n2 2\n1 3\n0 2 2\n1 1 2\n",
"output": "5 3 5 11\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 717 | Solve the following coding problem using the programming language python:
Today is rose day, batch mates of Kabir and Tara decided to celebrate this day by exchanging roses with each other.
Note:$Note:$ exchanging means both the boy and the girl will give rose to each other.
In the class there are B$B$ boys and G$G$... | ```python
for i in range(int(input())):
print(2*(sum(list(map(int, input().split())))-1))
``` | vfc_1710 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/HECS2020/problems/CC001",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 3\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 718 | Solve the following coding problem using the programming language python:
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cas... | ```python
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
inp = lambda: list(map(int,sys.stdin.readline().rstrip("\r\n").split()))
#_______________________________________________________________________________ _______________________
# from math import *
# from bisect import *
# from heapq import *
... | vfc_1714 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY57",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "0\n0\n1 1\n0\n1 1\n2 3 5\n0\n1 1\n2 3 5\n8 13 21 34\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 719 | Solve the following coding problem using the programming language python:
-----Problem-----
Suppose there is a circle. There are N Juice shops on that circle. Juice shops are numbered 0 to N-1 (both inclusive). You have two pieces of information corresponding to each of the juice shop:
(1) the amount of Juice that a ... | ```python
import re,sys
def isCirlePossible(juices,distances):
if juices == [] or distances == []:
return -1;
total_juice_consumed = 0
juice_consumed = 0
start=0
for i in range(0,len(juices)):
diff = juices[i] - distances[i]
if juice_consumed >= 0:
juice_consumed += diff
else:
juice_consumed = diff
... | vfc_1718 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMN2016/problems/SUMTOUR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 5\n10 3\n3 4\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 720 | Solve the following coding problem using the programming language python:
All strings in Chefland are beautiful because they are binary strings (a binary string contains only characters '0' and '1'). The beauty of a binary string $S$ is defined as the number of pairs $(i, j)$ ($1 \le i \le j \le |S|$) such that the su... | ```python
t = int(input())
for _ in range(t):
s = input()
pref = [0]*len(s)
if s[0]=="1":
pref[0]+=1
for i in range(1,len(s)):
if s[i]=="1":
pref[i]+=1
pref[i]=pref[i]+pref[i-1]
k=1
cnt=0
while (k+k*k)<=len(s):
r = k+k*k
i=r-1
while i<len(s):
if (i-r)>=0:
if pref[i]-pref[i-r]==k:
cnt+=... | vfc_1722 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BDGFT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n010001\n10\n",
"output": "4\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 721 | Solve the following coding problem using the programming language python:
Do you know that The Chef has a special interest in palindromes? Yes he does! Almost all of the dishes in his restaurant is named by a palindrome strings. The problem is that a name of a dish should not be too long, so The Chef has only limited ... | ```python
# cook your dish here
def permutation(n,p):
r=26
if n==1:
return 26
elif n==2:
return 52
elif n==3:
return 728
else:
if n%2==0:
return ((2*(bin_expo(r,((n//2)+1),p)-r)*bin_expo(25,1000000005,p)))%p
else:
n=n+1
retu... | vfc_1726 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TAPALIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1\n2\n3\n4\n100\n\n\n",
"output": "26\n52\n728\n1404\n508533804\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 722 | Solve the following coding problem using the programming language python:
The kingdom of the snakes is an NxN grid. Their most-valued possession is a huge collection of poison, which is stored in the central KxK grid. It is guaranteed that both N and K are odd. What we mean by 'central' is this: suppose in the NxN gri... | ```python
'''input
2
7 3 5
5 2 5 2
2 4 2 6
6 2 6 4
5 6 5 7
7 1 7 4
7 3 7
1 1 6 1
1 2 3 2
5 2 5 2
2 6 2 6
6 2 6 4
5 6 5 7
7 1 7 4
'''
for _ in range(int(input())):
n, k, m = list(map(int, input().split()))
row_s = []
col_s = []
for _ in range(m):
h_x, h_y, t_x, t_y = list(map(int, input().split()))
if h_x == t_... | vfc_1730 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PROTEPOI",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7 3 7\n1 1 6 1\n1 2 3 2\n5 2 5 2\n2 4 2 6\n6 2 6 4\n5 6 5 7\n7 1 7 4\n7 3 7\n1 1 6 1\n1 2 3 2\n5 2 5 2\n2 6 2 6\n6 2 6 4\n5 6 5 7\n7 1 7 4\n",
"output": "3\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 723 | Solve the following coding problem using the programming language python:
In this problem, you will be given a polynomial, you have to print what it becomes after differentiation.
Following are the rules for differentiation:
- For a polynomial f(x), its differentiation is defined as f'(x).
- If a is a constant, then ... | ```python
def ans(l):
s = ""
i = 0
while (i < len(l)):
temp = l[i]
k = temp[1]
if (k != 0):
s += str(temp[0]) + "x^" + str(k)
else:
s += str(temp[0])
i += 1
if (i < len(l)):
s += " + "
if (len(s) > 0):
return s
else:
return "0"
test = int(input())
while (test != 0):
test -= 1
N = int(i... | vfc_1734 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCFEB16/problems/POLYDIFR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n1 2\n3\n1 3\n1 1\n1 0\n",
"output": "2x^1\n3x^2 + 1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 724 | Solve the following coding problem using the programming language python:
Petya is preparing a problem for a local contest in his school. The problem is to find a longest increasing subsequence in a given permutation. A permutation of size n$n$ is a sequence of n$n$ numbers a1,…,an$a_1, \ldots, a_n$ such that every nu... | ```python
# cook your dish here
for _ in range(int(input())):
n,k = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
ls = a
if n==1:
print("YES")
print(1)
continue
if k==1:
print("NO")
continue
if k==2 and n>2:
if ls[0]!... | vfc_1738 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/INVLIS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3 2\n1 2\n2 1\n1\n",
"output": "YES\n2 3 1\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 725 | Solve the following coding problem using the programming language python:
The Little Elephant and his friends from the Zoo of Lviv were returning from the party. But suddenly they were stopped by the policeman Big Hippo, who wanted to make an alcohol test for elephants.
There were N elephants ordered from the left to ... | ```python
def magic():
def check(art,k,m):
n=len(art)
for i in range(n-k+1):
maxi=0
maxi=max(art[i:i+k])
total=0
total=art[i:i+k].count(maxi)
if total>=m:
return False
return True
for _ in range(eval(input())):
n,k,m=list(map(int,input().split()))
arr=list(map(int,input().split())... | vfc_1742 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/LEALCO",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5 3 2\n1 3 1 2 1\n5 3 3\n7 7 7 7 7\n5 3 3\n7 7 7 8 8\n4 3 1\n1 3 1 2\n",
"output": "0\n1\n1\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 726 | Solve the following coding problem using the programming language python:
Today, Chef decided to cook some delicious meals from the ingredients in his kitchen. There are $N$ ingredients, represented by strings $S_1, S_2, \ldots, S_N$. Chef took all the ingredients, put them into a cauldron and mixed them up.
In the ca... | ```python
# cook your dish here
t=int(input())
while t>0:
n=int(input())
li=[]
c,o,d,e,h,f=0,0,0,0,0,0
for i in range(0,n):
s=input()
for i in range(len(s)):
if s[i]=='c':
c=c+1
elif s[i]=='o':
o=o+1
elif s[i]=='d':
d=d+1
elif s[i]=='e':
e=e+1
elif s[i]=='h':
h=h+1
elif ... | vfc_1746 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CFMM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n6\ncplusplus\noscar\ndeck\nfee\nhat\nnear\n5\ncode\nhacker\nchef\nchaby\ndumbofe\n5\ncodechef\nchefcode\nfehcedoc\ncceeohfd\ncodechef\n",
"output": "1\n2\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 727 | Solve the following coding problem using the programming language python:
To protect people from evil,
a long and tall wall was constructed a few years ago.
But just a wall is not safe, there should also be soldiers on it,
always keeping vigil.
The wall is very long and connects the left and the right towers.
The... | ```python
D=[0]*31
D[1]=2
D[2]=5
for i in range(3,31):
best=10**10
for p in range(1,i+1):
best=min(best,D[p-1]+D[i-p]+i+1)
D[i]=best
t=int(input())
for i in range(t):
n,m=list(map(int,input().split()))
maxi=(n+2)*(n+1)/2-1
mini=D[n]
if mini<=m<=maxi: print(0)
elif m<mini: print(-1)
else: print(m-maxi)
``` | vfc_1750 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK23/problems/NOKIA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n3 8\n3 9\n2 4\n5 25\n",
"output": "0\n0\n-1\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 728 | Solve the following coding problem using the programming language python:
Given a square matrix of size N×N, calculate the absolute difference between the sums of its diagonals.
-----Input-----
The first line contains a single integer N. The next N lines denote the matrix's rows, with each line containing N space-se... | ```python
def diagonal_difference(matrix):
l = sum(matrix[i][i] for i in range(N))
r = sum(matrix[i][N-i-1] for i in range(N))
return abs(l - r)
matrix = []
N = eval(input())
for _ in range(N):
matrix.append(list(map(int, input().split())))
print(diagonal_difference(matrix))
``` | vfc_1754 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COFI2016/problems/CF212",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n11 2 4\n4 5 6\n10 8 -12\n",
"output": "15\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 729 | Solve the following coding problem using the programming language python:
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_... | ```python
t=int(input())
for _ in range(t):
n,m=map(int,input().split())
d={}
e={}
l=[]
for i in range(n):
d[i]=0
for i in range(m):
e[i]=0
for i in range(n):
l.append(input())
for i in range(n):
for j in range(m):
if l[i][j]=='1':
d[i]=1
e[j]=1
#ans=[]
if sum(d.values())+sum(e.values())==0... | vfc_1758 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/ORMATRIX",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 3\n010\n000\n001\n",
"output": "1 0 1\n2 1 1\n1 1 0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 730 | Solve the following coding problem using the programming language python:
Every Friday Chef and his N - 1 friends go for a party. At these parties, they play board games. This Friday, they are playing a game named "Boats! Boats! Boats!". In this game players have to transport cookies between Venice and Constantinople.... | ```python
# cook your code here
for _ in range(eval(input())):
n=eval(input())
ind=0
m=-1
for i in range(n):
l=[int(x) for x in input().split()]
sc=l[0]
for j in range(1,len(l)):
sc+=int(l[j]>=4)+int(l[j]>=5)+2*int(l[j]>=6)
if sc==m:
ind=-2
if sc>m :
m=sc
ind=i+1
if (ind==-2):
p... | vfc_1762 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/SEPT16/problems/RESCALC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n6 1 2 3 4 5 6\n9 3 3 3 4 4 4 5 5 5\n2\n5 2 3 4 5 6\n7 1 1 2 2 3 3 4\n3\n4 1 1 2 3\n4 1 2 2 3\n4 1 2 3 3\n",
"output": "chef\n2\ntie\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 731 | Solve the following coding problem using the programming language python:
-----Indian National Olympiad in Informatics 2014-----
Nikhil’s slogan has won the contest conducted by Drongo Airlines and he is entitled to a free ticket between any two destinations served by the airline. All cities served by Drongo Airlines ... | ```python
c,f=list(map(int,input().split()))
l=[[1000001 for i in range(c)] for j in range(c)]
while f:
x,y,cost=list(map(int,input().split()))
l[x-1][y-1]=cost
l[y-1][x-1]=cost
f-=1
for i in range(c):
l[i][i]=0
for k in range(c):
for x in range(c):
for y in range(c):
... | vfc_1766 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INOIPRAC/problems/INOI1402",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 5\n1 2 10\n1 3 24\n2 3 2\n2 4 15\n3 4 7\n",
"output": "19\nNote : Your program should not print anything other than what is specified in the output format. Please remove all diagnostic print statements before making your fi... |
apps | verifiable_code | 732 | Solve the following coding problem using the programming language python:
Alice and Bob are walking on an infinite straight street. Initially, both are at the position $X=0$ and they start walking in the direction of increasing $X$. After $N$ seconds, they stop. Let's denote Alice's speed and Bob's speed during the $i... | ```python
# cook your dish here
for tc in range(int(input())):
n = int(input())
li1 = list(map(int,input().split(' ')))
li2 = list(map(int,input().split(' ')))
walk = 0
sum1 = 0
sum2 = 0
for i in range(n):
if li1[i] == li2[i] and sum1 == sum2:
walk += li1[i]
sum1 += li1[i]
sum2 += li2[i]
print(wal... | vfc_1770 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/WWALK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n4\n1 3 3 4\n1 2 4 4\n2\n2 3\n3 2\n2\n3 3\n3 3\n",
"output": "5\n0\n6\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 733 | Solve the following coding problem using the programming language python:
Given a string consisting of only lowercase English alphabets, your task is to find the smallest palindromic substring.
In case there are multiple palindromic substrings of the same length present, print the lexicographically smallest substring.... | ```python
# cook your dish here
T = int(input())
for t in range(T):
N = int(input())
s = sorted(list(str(input())))
print(s[0])
``` | vfc_1774 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENCD2020/problems/ECAPR201",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\nzy\n1\ncd\n",
"output": "y\nc\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 734 | Solve the following coding problem using the programming language python:
Chef has $N$ markers. There is a cap on each marker. For each valid $i$, the $i$-th marker has colour $a_i$. Initially, for each valid $i$, the colour of the cap on the $i$-th marker is also $a_i$.
Chef wants to rearrange the caps in such a way ... | ```python
# cook your dish here
from collections import Counter,defaultdict
for i in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
coun=Counter(arr)
check=True
for j in coun:
if coun[j]>n//2:
print("No")
check=False
break
if check==True:
print("Yes")
narr=sorted(arr)
... | vfc_1778 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MARCAPS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n9\n1 1 1 2 2 2 3 3 3\n2\n1 1\n",
"output": "Yes\n2 2 2 3 3 3 1 1 1\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 735 | Solve the following coding problem using the programming language python:
Harish has decided to go to Arya's hotel this morning. We all know he is crazy for masala dosas. And as usual he is always hungry. He decided to order all the masala dosas at once. But then he realised that he did not have enough money to buy al... | ```python
for _ in range(eval(input())):
n=eval(input())
if n%2:
print('NO')
else:
print('YES')
``` | vfc_1782 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCMAY16/problems/MDOSA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n16\n27\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 736 | Solve the following coding problem using the programming language python:
Gargi is thinking of a solution to a problem. Meanwhile, her friend asks her to solve another problem. Since Gargi is busy in her own problem, she seeks your help to solve the new problem.
You are given a string S containing characters a-z (low... | ```python
t = int(input())
for i in range(t):
s = input().rstrip()
sumv = 0
for j in range(len(s)):
sumv += ord(s[j])
minv = 10 ** 8;
for i in range(ord('a'), ord('z') + 1):
val = abs(sumv - i * len(s))
if minv > val:
minv = val
print(minv)
``` | vfc_1786 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/RECJ1601/problems/SIDSTR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\nabba\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 737 | Solve the following coding problem using the programming language python:
Rodriguez is a happy and content farmer. He has got a square field of side length $x$. Miguel, his son has himself grown into a man and his father wants to gift him something out of which he can make a living. So he gift's his son a square piece... | ```python
from math import sqrt
def isPrime(n):
for i in range(2, int(sqrt(n))+1):
if(n%i==0): return True
return False
ans = []
for _ in range(int(input())):
x, y = map(int, input().split())
ans.append('NO' if(isPrime(x**2-y**2)) else 'YES')
print('\n'.join(ans))
``` | vfc_1790 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COTS2020/problems/CDCUR02",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7 5\n6 5\n",
"output": "YES\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 738 | Solve the following coding problem using the programming language python:
Calculate the power of an army of numbers from 1 to $N$, both included.
-----Input:-----
- First line will contain a single integer $N$.
-----Output:-----
For each testcase, output in a single line containing the answer.
-----Constraints-----... | ```python
# cook your dish here
# cook your dish here
#powerful numbers
n = int(input())
plist = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 2... | vfc_1794 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/FULU2020/problems/ARMY1N",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "24\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 739 | Solve the following coding problem using the programming language python:
Mr. X stays in a mansion whose door opens in the North. He travels every morning to meet his friend Ms. Y walking a predefined path.
To cut the distance short, one day he decides to construct a skywalk from his place to his friend’s place. Help... | ```python
#!/usr/bin/env python
from math import sqrt
def process(S):
P = [0,0,'S']
for i in S:
if i == 'L':
if P[-1] == 'N': P[-1] = 'W'
elif P[-1] == 'S': P[-1] = 'E'
elif P[-1] == 'E': P[-1] = 'N'
elif P[-1] == 'W': P[-1] = 'S'
elif i == 'R':
if P[-1] == 'N': P[-1] = 'E'
elif P[-1] == 'S': ... | vfc_1798 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COZL2012/problems/RBX12R01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 L 2 R 2 L 1\n",
"output": "5.0NW\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 740 | Solve the following coding problem using the programming language python:
There is a field with plants — a grid with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$); out of its $NM$ cells, $K$ cells contain plants, while the rest contain weeds. Two cells are adjacent if they have a commo... | ```python
t=int(input())
while(t):
t-=1
d={}
n,m,k=[int(x) for x in list(input().split())]
sum=0
while(k):
k-=1
x,y=[int(x) for x in list(input().split())]
a=[-1,1,0,0]
b=[0,0,-1,1]
for i in range(4):
if((x+a[i],y+b[i]) in d):
sum-=1
else:
sum+=1
d[(x,y)]=1
print(sum)
``` | vfc_1802 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FENCE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 4 9\n1 4\n2 1\n2 2\n2 3\n3 1\n3 3\n4 1\n4 2\n4 3\n4 4 1\n1 1\n",
"output": "20\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 741 | Solve the following coding problem using the programming language python:
Given a positive integer K > 2, with prime
factorization:
K = p1^a1 * p2^a2 ... * pn^an
Compute the following:
S = a1*p1 + a2*p2 ... + an*pn.
-----Input-----
A list of <100 integers, one on each line,
all less than $2*10^{18}$.
-----Output-... | ```python
import random
import os
yash=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,3... | vfc_1806 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALGOTH10/problems/FACTSUM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "6\n7\n",
"output": "5\n7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 742 | Solve the following coding problem using the programming language python:
Rakesh has built a model rocket and wants to test how stable it is. He usually uses a magic box which runs some tests on the rocket and tells if it is stable or not, but his friend broke it by trying to find out how stable he is (very delicate m... | ```python
import random
def sign(i):
if i>0:
return 1
elif i<=0:
return 0
bleh = []
for _ in range(int(input())):
p = list(map(int,input().rstrip().split()))
max_rows = len(p)
if all([x==0 for x in p]):
print(1)
continue
if max_rows <= 1:
bleh.append(max_... | vfc_1810 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CUBE2020/problems/STROCK",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n10 12 4 5 3\n",
"output": "0\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 743 | Solve the following coding problem using the programming language python:
Yesterday, Chef found $K$ empty boxes in the cooler and decided to fill them with apples. He ordered $N$ apples, where $N$ is a multiple of $K$. Now, he just needs to hire someone who will distribute the apples into the boxes with professional p... | ```python
# cook your dish here
t=int(input())
for i in range(t,0,-1):
x,y=map(int,input().split())
k=x//y
if k%y==0:
print("NO")
else:
print("YES")
``` | vfc_1814 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DSTAPLS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n5 1\n4 2\n10 10\n",
"output": "NO\nNO\nYES\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 744 | 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 (odd) to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of tes... | ```python
t=int(input())
for _ in range(t):
n=int(input())
l1=[]
if n==1:
print('*')
elif n==3:
print('*')
print('**')
print('*')
else:
s1=""
n1=n//2
n1+=1
for i in range(1,n1+1):
s1=""
if i==1:
... | vfc_1818 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ANITGUY6",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n3\n5\n7\n",
"output": "*\n*\n**\n*\n*\n**\n* *\n**\n*\n*\n**\n* *\n* *\n* *\n**\n*\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 745 | Solve the following coding problem using the programming language python:
You want to build a temple for snakes. The temple will be built on a mountain range, which can be thought of as n blocks, where height of i-th block is given by hi. The temple will be made on a consecutive section of the blocks and its height sh... | ```python
# cook your dish here
t = int(input())
while t:
t -= 1
n = int(input())
arr = list(map(int, input().split()))
sumi = sum(arr)
prev = 1
for i in range(n):
arr[i] = min(arr[i], prev)
prev = arr[i] + 1
prev = 1
for i in range(n - 1, -1, -1):
arr[i] = min(arr[i], prev)
prev = arr[i] + 1
temp = 0... | vfc_1822 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SNTEMPLE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3\n1 2 1\n4\n1 1 2 1\n5\n1 2 6 2 1\n",
"output": "0\n1\n3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 746 | Solve the following coding problem using the programming language python:
Given a complete binary tree with the height of H, we index the nodes respectively top-down and left-right from 1. The i-th node stores a positive integer Vi. Define Pi as follows: Pi=Vi if the i-th node is a leaf, otherwise Pi=max(Vi*PL, Vi*PR)... | ```python
def treeProduct(num, h, root, ch):
if ch >= h:
return num[root]
left = (root * 2) + 1
right = (root * 2) + 2
ret1 = treeProduct(num, h, left, ch + 1)
ret2 = treeProduct(num, h, right, ch + 1)
return num[root] * max(ret1, ret2)
def main():
n = int(input())
while n!=0:
line = str(input())
s = ... | vfc_1826 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MAY11/problems/TPRODUCT",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 2 3\n3\n3 1 5 2 6 4 7\n0\n",
"output": "3\n105\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 747 | Solve the following coding problem using the programming language python:
Chef received a new sequence $A_1, A_2, \ldots, A_N$. He does not like arbitrarily ordered sequences, so he wants to permute the elements of $A$ in such a way that it would satisfy the following condition: there is an integer $p$ ($1 \le p \le N... | ```python
for _ in range(int(input())):
n = int(input())
arr= list(map(int,input().split()))
arr.sort()
d={}
for i in arr:
if i not in d:
d[i]=1
else:
d[i]+=1
flag = True
for i in d:
if d[i]>2:
flag=False
break
if arr.count(max(arr))!=1:
flag=False
if flag==True:
arr1=[]
... | vfc_1830 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/INCRDEC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n4\n1 3 2 4\n4\n1 3 2 4\n6\n1 10 10 10 20 15\n5\n1 1 2 2 3\n4\n1 2 3 3\n",
"output": "YES\n1 2 3 4\nYES\n4 3 2 1\nNO\nYES\n1 2 3 2 1\nNO\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 748 | Solve the following coding problem using the programming language python:
Chef has a cubic die with 6 faces kept on an infinite plane. Each face has a distinct integer in the range [1,6] written on it, but the exact arrangement of the numbers on the faces of the die is unknown to Chef. Curiosity gets the better of Ch... | ```python
from itertools import permutations
def solve(n,a):
ans=[]
for des in desire:
check=1
for i in range(n-1):
if (a[i]==a[i+1]):
return [-1]
if a[i+1]==des[a[i]-1]:
check=0
break
if check:
ans=des
break
if ans:
return ans
return [-1]
per=permutations([1,2,3,4,5,6])
... | vfc_1834 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFDICE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n9\n1 3 4 6 1 3 4 6 1\n10\n1 2 1 3 1 4 1 5 1 6\n6\n1 2 3 4 5 6\n4\n1 3 3 1\n",
"output": "2 1 6 5 4 3\n-1\n4 5 6 1 2 3\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 749 | Solve the following coding problem using the programming language python:
The Government of Siruseri is no different from any other when it comes to being "capital-centric" in its policies. Recently the government decided to set up a nationwide fiber-optic network to take Siruseri into the digital age. And as usual, t... | ```python
n=int(input())
l=[]
for i in range(n):
l.append([int(x) for x in input().split()])
d=[10**9]*(n)
q=set([int(x) for x in range(1,n)])
d[1]=0
#print(q)
def extract():
mini=10**9
o=0
for i in range(1,len(d)):
if d[i]<mini and i in q:
mini=d[i]
o=i
q.remove(o)
return o
while len(q)!... | vfc_1838 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/IARCSJUD/problems/HISPDNET",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n0 7 8 10\n7 0 4 5\n8 4 0 6\n10 5 6 0\n",
"output": "9\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 750 | Solve the following coding problem using the programming language python:
Some programming contest problems are really tricky: not only do they
require a different output format from what you might have expected, but
also the sample output does not show the difference. For an example,
let us look at permutations.
A p... | ```python
def invper(ar):
ar1=[0]*(len(ar))
for i in range(len(ar)):
ar1[ar[i]-1]=i+1
return ar1
t=int(input())
while(t!=0):
ar=list(map(int,input().split()))
ar1=invper(ar)
if(ar==ar1):
print("ambiguous")
else:
print("not ambiguous")
t = int(input())
``` | vfc_1842 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PERMUT2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1 4 3 2\n5\n2 3 4 5 1\n1\n1\n0\n",
"output": "ambiguous\nnot ambiguous\nambiguous\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 751 | Solve the following coding problem using the programming language python:
There are n villages in a Chefland. Some of the villages have electricity facilities, other doesn't. You can consider the villages arranged in line in the order 1 to n from left to right. i-th of village can be considered at xi coordinates.
Che... | ```python
for _ in range(int(input())):
n=int(input())
s=list(input())
coord=list(map(int,input().split()))
p=0
i=0
h=[]
for i in range(0,n):
if s[i]=='1':
h.append(i)
if h[0]!=0:
p=p+coord[h[0]]-coord[0]
if h[len(h)-1]!=n-1:
p=p+coord[n-1]-coord[h[len(h)-1]]
for j in range(0,len(h)-1):
if h[j]+1==... | vfc_1846 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/CHEFELEC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n01\n1 2\n3\n100\n1 5 6\n",
"output": "1\n5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 752 | Solve the following coding problem using the programming language python:
Many internet protocols these days include the option of associating a
media type with the content being sent.
The type is usually inferred from the file extension.
You are to write a program that facilitates the lookup of media types for
a numb... | ```python
# cook your dish here
n,m=list(map(int,input().split()))
a={}
for i in range(n):
x,y=input().split()
a[x]=y
for i in range(m):
c=input().strip()
if '.' not in c:
print("unknown")
else:
h=c.split('.')[-1]
if h in a:
print(a[h])
else:
print('unknown')
``` | vfc_1850 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MIME2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 6\nhtml text/html\nhtm text/html\npng image/png\nsvg image/svg+xml\ntxt text/plain\nindex.html\nthis.file.has.lots.of.dots.txt\nnodotsatall\nvirus.exe\ndont.let.the.png.fool.you\ncase.matters.TXT\n",
"output": "text/html\nt... |
apps | verifiable_code | 753 | Solve the following coding problem using the programming language python:
It's autumn now, the time of the leaf fall.
Sergey likes to collect fallen leaves in autumn. In his city, he can find fallen leaves of maple, oak and poplar. These leaves can be of three different colors: green, yellow or red.
Sergey has collect... | ```python
for t in range(int(input())):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
max=0
g=l1[0]+l2[0]+l3[0]
y=l1[1]+l2[1]+l3[1]
r=l1[2]+l2[2]+l3[2]
if g%2==0:
g-=1
if y%2==0:
y-=1
if r%2==0:
r-=1
if max<g:
max=g
if max<r:
... | vfc_1854 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/BOUQUET",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n1 2 3\n3 2 1\n1 3 4\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 754 | Solve the following coding problem using the programming language python:
Chef has a number N, Cheffina challenges the chef to check the divisibility of all the permutation of N by 2. If any of the permutations is divisible by 2 then print 1 else print 0.
-----Input:-----
- First-line will contain $T$, the number of ... | ```python
# cook your dish here
for i in range(int(input())):
n = int(input())
flag = 0
while(n>0):
if((n%10)%2 == 0):
flag = 1
break
n = n//10
if(flag == 0):
print(0)
else:
print(1)
``` | vfc_1858 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ITGUY03",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n19\n385\n",
"output": "0\n1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 755 | Solve the following coding problem using the programming language python:
Akshay is interested in mathematics, one day he came across a problem of modulus operator.He has a list of M integers say arr[M] and has to find all integers K such that :
- K > 1
- arr[1]%K = arr[2]%K = arr[3]%K = … = arr[M]%K where '%' is a m... | ```python
l = []
for _ in range(int(input())):
l.append(int(input()))
for i in range(2,max(l)):
r = [x%i for x in l]
if len(set([x%i for x in l])) == 1:
print(i, end = ' ')
``` | vfc_1862 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INEK2019/problems/IF05",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n38\n6\n34\n",
"output": "2 4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 756 | Solve the following coding problem using the programming language python:
Farmer Feb has three fields with potatoes planted in them. He harvested x potatoes from the first field, y potatoes from the second field and is yet to harvest potatoes from the third field. Feb is very superstitious and believes that if the sum... | ```python
# cook your dish here
import math
try:
def prime(n):
for i in range(2, int(math.sqrt(n)) + 1):
if n % i == 0:
return False
return True
for t in range(int(input())):
x, y = list(map(int, input().split()))
s = x + y
i = s
while(1):
if prime(s + 1):
ans = s + 1
break
else... | vfc_1866 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/POTATOES",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1 3\n4 3\n",
"output": "1\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 757 | Solve the following coding problem using the programming language python:
Saket loves to play with strings. One day , while he was having fun with Cyclic Permutations of available strings to him, he observed that despite being scarce in numbers Vowels were really clingy.Being clingy means for almost every given string... | ```python
for t in range(int(input())):
n=int(input())
s=input().strip()
c=0
flag=0
for i in range(n):
if (s[i]=="A" or s[i]=="E" or s[i]=="I" or s[i]=="O" or s[i]=="U") and (s[i-1]=="A" or s[i-1]=="E" or s[i-1]=="I" or s[i-1]=="O" or s[i-1]=="U") :
flag=1
if flag and n!=1:
print("Yes")
else:
... | vfc_1870 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ALQU2018/problems/VOWPAIR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\nAUXFC\n6\nXBCDEF\n",
"output": "Yes\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 758 | Solve the following coding problem using the programming language python:
Everyone loves short problem statements.
Given a function $ f(x) $ find its minimum value over the range $ 0 < x < π/2$
$
f(x) = ( x^2 + b*x + c ) / sin( x )
$
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the t... | ```python
import sys
import math
input=sys.stdin.readline
def binary(l,r,co,b,c):
x=(l+r)/2
#print(x)
val1=(2*x+b)*math.sin(x)
val2=(x**2+b*x+c)*math.cos(x)
x=(l+r)/2
val=val1-val2
if(abs(val)<.0000001 or co==150):
return (l+r)/2
if(val<0):
return binary((l+r)/2,r,co+1,b,c)
else:
return binary(l,(l+r)/2,... | vfc_1874 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ICM2020/problems/ICM2003",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2\n",
"output": "5.8831725615\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 759 | Solve the following coding problem using the programming language python:
Tara was completing an Algorithms assignment and got stuck on a question. She thought of who can help her, and got reminded of Kabir who has good problem solving skills. The question is:
Given N$N$ the number of elements in the sequence A1$A_1$,... | ```python
# cook your dish here
store=[0]*(10**5+1)
def sieve():
for i in range(2,10**5+1):
if(store[i]==0):
store[i]=1
for j in range(i,10**5+1,i):
store[j]=i
sieve()
# print(store)
for _ in range(int(input())):
n=int(input())
li=[int(x) for x in input().split()]
dp=[0]*(10**5+1)
for i in li:
dp[... | vfc_1878 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/HECS2020/problems/CC005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n7\n3 2 15 6 8 5 10\n",
"output": "5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 760 | Solve the following coding problem using the programming language python:
Sereja has a string A consisting of n lower case English letters.
Sereja calls two strings X and Y each of length n similar if they can be made equal by applying the following operation at most once in each of them.
- Chose any two position i... | ```python
import math
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
def modin(a, m):
g, x, y = egcd(a, m)
return x % m
# def gcdexten(a,b,x,y):
# if a == 0:
# x = 0
# y = 1
# return b
# x1 = y1 = 0
# gcd = gcd... | vfc_1882 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MARCH16/problems/SEATSTR2",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\nz\nabcd\n\n\n",
"output": "0\n144\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 761 | Solve the following coding problem using the programming language python:
Chef spent N days working really hard! He planned loads of tasks: as many as Ai tasks to do on the ith day! Chef's work was brutal, so he only managed to finish Bi tasks on the ith day.
The good news is that Chef has a Time Machine!
The Time Ma... | ```python
t=int(input())
def diffe(a,b):
return int(a-b)
while t :
t=t-1
lia=[]
lib=[]
lik=[]
lim=[]
liab=[]
likm=[]
n,k,m=list(map(int,input().split()))
lia=list(map(int,input().split()))
lib=list(map(int,input().split()))
lik=list(map(int,input().split()))
lim=list(map(int,input().split()))
liab... | vfc_1886 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/JAN16/problems/CHEFTMA",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4 2 2\n5 7 6 1\n3 3 1 1\n6 3\n1 4\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 762 | Solve the following coding problem using the programming language python:
The chef is trying to decode some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cas... | ```python
t=int(input())
while(t):
n=int(input())
cnt=1;
for i in range(n):
s=""
for j in range(n):
s=s+str(bin(cnt))[2:][: : -1]+" "
cnt=cnt+1
print(s)
t=t-1
``` | vfc_1890 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY60",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n2\n3\n4\n",
"output": "1\n1 01\n11 001\n1 01 11\n001 101 011\n111 0001 1001\n1 01 11 001\n101 011 111 0001\n1001 0101 1101 0011\n1011 0111 1111 00001\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 763 | Solve the following coding problem using the programming language python:
You are given two binary strings $S$ and $P$, each with length $N$. A binary string contains only characters '0' and '1'. For each valid $i$, let's denote the $i$-th character of $S$ by $S_i$.
You have to convert the string $S$ into $P$ using ze... | ```python
def solve(s, p):
diffs = 0
for x, y in zip(s, p):
if x == y:
continue
if x == '0':
if diffs < 1:
return "No"
diffs -= 1
else:
diffs += 1
return "Yes" if diffs == 0 else "No"
for _ in range(int(input())):
l = int(input())
s = input().strip()
p = input().strip()
print(solve(s, p))... | vfc_1894 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SWAP10HG",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n2\n00\n00\n3\n101\n010\n4\n0110\n0011\n",
"output": "Yes\nNo\nYes\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 764 | Solve the following coding problem using the programming language python:
Chef has just found a recipe book, where every dish consists of exactly four ingredients.
He is going to choose some two dishes and prepare them for dinner.
Of course, he likes diversity and wants to know whether the two dishes are similar.
Two ... | ```python
# cook your dish here
t=int(input())
i=0
while i<t:
a=[]
a=input().split()
b=[]
b=input().split()
j=0
c=0
while j<4:
if a[j] in b:
c+=1
j+=1
if c>=2:
print("similar")
else:
print("dissimilar")
i+=1
``` | vfc_1898 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SIMDISH",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\neggs sugar flour salt\nsugar eggs milk flour\naa ab ac ad\nac ad ae af\ncookies sugar grass lemon\nlemon meat chili wood\none two three four\none two three four\ngibberish jibberish lalalalala popopopopo\njibberisz gibberisz pop... |
apps | verifiable_code | 765 | Solve the following coding problem using the programming language python:
Chef likes to travel a lot. Every day Chef tries to visit as much cities as possible. Recently he had a quite a few trips of great Chefland for learning various recipes. Chefland had N cities numbered from 1 to N. People in Chefland are very fri... | ```python
n=int(input())
a=list(map(int,input().split()))
q=int(input())
while q>0:
i=1
tot=a[0]
b=list(map(int,input().split()))
if b[0]==1:
#p,f=map(int,raw_input().split())
a[b[1]-1]=b[2]
else:
#r=int(raw_input())
tot=a[0]
while 1+i*b[1]<=n:
tot=tot*a[i*b[1]]
i=i+1
m=(str)(tot)
tot=tot%10000... | vfc_1902 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/JUNE16/problems/FRJUMP",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 3 4 5\n3\n2 1\n1 3 10\n2 2\n",
"output": "1 120\n5 50\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 766 | Solve the following coding problem using the programming language python:
Chef has an array of N natural numbers. Cheffina challenges the chef to choose the two numbers from the array and following the condition as the area of the rectangle formed from the two numbers is maximum. Cheffina also asks the chef to choose ... | ```python
import sys
import math
import bisect
from sys import stdin,stdout
from math import gcd,floor,sqrt,log
from collections import defaultdict as dd
from bisect import bisect_left as bl,bisect_right as br
sys.setrecursionlimit(100000000)
ii =lambda: int(input())
si =lambda: input()
jn =la... | vfc_1906 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ANITGUY7",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n4 2 1 5 3\n",
"output": "20 2\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 767 | Solve the following coding problem using the programming language python:
Indian National Olympiad in Informatics 2012
The Republic of Tutaria is celebrating its 37th year of independence. To mark the occasion, the nation is organising a contest where all its N citizens take part. The event has three tracks, a COBOL p... | ```python
# cook your dish here
while True:
try:
n=int(input())
lis=[]
for i in range(n):
k=list(map(int,input().split()))
k.append(k[1]+k[2])
lis.append(k)
#print(lis)
p=sorted(lis,key=lambda x:x[3],reverse=True)
#print(p)... | vfc_1910 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/INOIPRAC/problems/INOI1201",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "and output corresponding to the example above.\nSample input\n3\n18 7 6\n23 10 27\n20 9 14\nSample output\n74\nNote: Your program should not print anything other than what is specified in the output format. Please remove all diagn... |
apps | verifiable_code | 768 | Solve the following coding problem using the programming language python:
The MEX of a set of integers is defined as the smallest non-negative integer that does not belong to this set. For example, $\mathrm{MEX}(\{0,2,3\}) = 1$ and $\mathrm{MEX}(\{1,3\}) = 0$.
Chef has a tree with $N$ nodes (numbered $1$ through $N$).... | ```python
# cook your dish here
# cook your dish here
from math import log2;
import sys;
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
inf = float("inf")
def find_height(node):
nodes[node]=1
for i in graph[node]:
nodes[node]+=find_height(i)
return nodes[node]
def find_sum(node... | vfc_1914 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUBMEXS",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n1 1\n5\n1 1 2 2\n\n",
"output": "4\n9\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 769 | Solve the following coding problem using the programming language python:
Pushkar is very good in Number Theory. He takes two numbers $A\ and\ B$ and declares them a Pushkar Pair. Pushkar Pair has a property that $A$ has a $Modular\ Inverse$ modulo $B$.
He asks you to tell him the largest number $L$ that divides bot... | ```python
import math
for i in range(int(input())):
a,b = map(int,input().split())
print(math.gcd(a,b))
``` | vfc_1918 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CACD2020/problems/PPPR",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 4\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 770 | Solve the following coding problem using the programming language python:
You are given an array $a$ of length $n$. A subsequence of this array is valid, if it satisfies these two conditions:
- There shouldn't be any two even numbers within a distance of $K$, both which have been chosen in the subsequence. i.e. there ... | ```python
import sys
import math
def main(arr,k):
x=[]
y=[]
for e in arr:
if e%2==0:
x.append(e)
y.append(0)
else:
x.append(0)
y.append(e)
a=[0]*n
b=[0]*n
a[0]=x[0]
b[0]=y[0]
for i in range(1,n):
if i<k:
a[i]=max(x[i],a[i-1])
b[i]=max(y[i],b[i-1])
else:
a[i]=max(x[... | vfc_1922 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/EOSUBSEQ",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n3\n2 1\n2 2\n5 2\n1 2 3 4 6\n",
"output": "3\n2\n11\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 771 | Solve the following coding problem using the programming language python:
Sultan, the freestyle wrestler, you all know him. He broke multiple records in the history of all wrestling leagues. Now 20 years have passed, Sultan has grown old. He has two sons, he wants them to be like him. Sultan being orthodox goes to his... | ```python
from operator import itemgetter
t=int(input())
for i in range(t):
n=int(input())
m,f=list(map(int,input().split()))
x=list(map(int,input().split()))
my,fy=0,0
check=[0]*n
#print check
for j in range(n):
if x[j]>0 and x[j]%m==0 and check[j]==0:
check[j]=1
my+=1
#print check
for j in range(n):
... | vfc_1926 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CDGO2016/problems/CDGO1602",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n7\n2 3\n4 5 7 8 9 10 14\n6\n5 7\n1 2 8 9 10 11\n",
"output": "Yes\nMultan\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 772 | Solve the following coding problem using the programming language python:
You are given a binary string S of N bits. The bits in the string are indexed starting from 1. S[i] denotes the ith bit of S.
Let's say that a sequence i1, i2, …, iK(1 ≤ K; 1 ≤ i1 < i2 < … < iK ≤ N) produces a palindrome when applied to S, if t... | ```python
def powerset(s):
n = len(s)
masks = [1 << j for j in range(n)]
for i in range(2**n):
yield [j + 1 for j in range(n) if (masks[j] & i)]
def is_power2(num):
return num != 0 and ((num & (num - 1)) == 0)
def special(l):
n = len(l)
for i in range(n):
lis = [i + 1]
... | vfc_1930 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LTIME32/problems/EXPALIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n11010\n101001011\n\n\n",
"output": "9\n18\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 773 | Solve the following coding problem using the programming language python:
A permutation of length n is an array of size n consisting of n distinct integers in the range [1, n]. For example, (3, 2, 4, 1) is a permutation of length 4, but (3, 3, 1, 4) and (2, 3, 4, 5) are not, as (3, 3, 1, 4) contains duplicate elements... | ```python
tests = int(input())
for t in range(tests):
n = int(input())
permut='2'
permut_list=[]
if n%2==0:
for i in range(2, n+1):
if i%2==1:
permut=permut+' '+str(i+1)
else:
permut=permut+' '+str(i-1)
print(permut)
pass
elif n==1:
print(1)
pass
... | vfc_1934 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/MINPERM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2\n3\n5\n6\n\n\n",
"output": "2 1\n2 3 1\n2 1 4 5 3\n2 1 4 3 6 5\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 774 | Solve the following coding problem using the programming language python:
Nobody knows, but $N$ frogs live in Chef's garden.
Now they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.
Chef knows all $P$ pairs of fr... | ```python
# cook your dish here
n, k, p = [int(i) for i in input().split()]
n_sep = list(map(int, input().split()))
count = 0
sep_sort = sorted(n_sep)
hashing = {sep_sort[0]: 0}
for j in range(1, n):
if (abs(sep_sort[j] - sep_sort[j - 1]) > k):
count += 1
hashing[sep_sort[j]] = count
#print(hashing)
for i in range... | vfc_1938 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FROGV",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 3 3\n0 3 8 5 12\n1 2\n1 3\n2 5\n",
"output": "Yes\nYes\nNo\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 775 | Solve the following coding problem using the programming language python:
After six days, professor GukiZ decided to give more candies to his students. Like last time, he has $N$ students, numbered $1$ through $N$. Let's denote the number of candies GukiZ gave to the $i$-th student by $p_i$. As GukiZ has a lot of stud... | ```python
try:
# https://www.codechef.com/LTIME63B/problems/GHMC
# Finally.... I properly understood what needs to be done.
def ctlt(arr, val):
# find number of values in sorted arr < val
if arr[0] >= val: return 0
lo = 0
hi = len(arr)
while hi-lo > 1:
md = (hi+l... | vfc_1942 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/GHMC",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 3 5 3\n2 1 5\n3 2 8 2\n3 8\n",
"output": "12\n-1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 776 | Solve the following coding problem using the programming language python:
You are given an integer $D$. Find an integer sequence $A_1, A_2, \ldots, A_N$ such that the following conditions are satisfied:
- $1 \le N \le 10^5$
- $1 \le A_i \le 10^5$ for each valid $i$
- $\sum_{i=1}^N \sum_{j=i}^N \left( \mathrm{min}(A_i,... | ```python
# cook your dish here
t=int(input())
for i in range(t):
D=int(input())
P=10**5-2
ans=[]
if(D==0):
ans.append(1)
while(D>0):
P=min(P,D)
ans.append(P+2);
ans.append(P+1);
ans.append(1);
D=D-P;
print(len(ans))
print(*ans,sep=" ",end="\n")
``` | vfc_1946 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/DIANE",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2\n5\n200\n13\n",
"output": "3\n3 3 2\n5\n2 8 5 1 10\n7\n12 10 15 11 19 13 15\n4\n5 4 4 10\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 777 | Solve the following coding problem using the programming language python:
Pankaj likes to eat Ice cream when he is working late into the night. Today has been yet another long day for Pankaj. So, he wants to eat ice cream now. He opens the fridge and sees that he has 2 types of containers holding the ice cream.
The fi... | ```python
import math
t=eval(input())
while t:
t=t-1
r1,h1,r2,h2=list(map(float,input().split()))
vol1=(math.pi*r1*r1*h1)/3 + (2*math.pi*r1*r1*r1)/3
vol2=math.pi*r2*r2*h2
print("%.8f %.8f" % (vol1,vol2))
``` | vfc_1950 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCFEB16/problems/ICECREAM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1.00 1.00 1.00 1.00\n3.02 7.23 5.20 6.00\n\n\n",
"output": "3.141592654 3.141592654\n126.739919445 509.691992118\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 778 | Solve the following coding problem using the programming language python:
Given an Integer N, write a program to reverse it.
-----Input-----
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
-----Output-----
For each test case, display the revers... | ```python
# cook your dish here
x=int(input())
for i in range(x):
s=input()
print(int(s[::-1]))
``` | vfc_1954 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/FLOW007",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n12345\n31203\n2123\n2300\n",
"output": "54321\n30213\n3212\n32\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 779 | Solve the following coding problem using the programming language python:
Tanish is the president of the chemistry club at his school. He considers everyone who doesn't like chemistry as his enemy. After years of research, he has invented a lethal poison, which he named success. Now Tanish plans to kill all his enemie... | ```python
t=int(input())
for i in range(t):
n=int(input())
N=list(map(int,input().split()))
N.sort()
k=n-1
ave=N[k]
for j in range(n-1):
ave=(ave+N[k-1])/2
k=k-1
print(ave)
``` | vfc_1958 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/PROC18B",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n9 3\n3\n3 2 9\n",
"output": "6.00000000\n4.00000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 780 | Solve the following coding problem using the programming language python:
"Ring Ring!!"
Sherlock's phone suddenly started ringing. And it was none other than Jim Moriarty..
"Long time no see ! You miss me right ? Anyway we'll talk about it later . Let me first tell you something. Dr.Watson is with me . And you've go... | ```python
import sys
user_input = sys.stdin.readline().split()
T = int(user_input[0])
for j in range(T) :
var = sys.stdin.readline().split()
N = int(var[0])
M = int(var[1])
if (N%M)%2 :
print("ODD")
else :
print("EVEN")
``` | vfc_1962 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/LOCMAY18/problems/REMAIN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 4\n6 5\n",
"output": "EVEN\nODD\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 781 | Solve the following coding problem using the programming language python:
Xorgon is an extremely delicious treat formed by the sequence $S$ of binary integers $s_1, s_2,..,s_N$. A really interesting property found in a Xorgon is that the xor of all elements in any contiguous subsequence of length $K$ in $S$ will resul... | ```python
# cook your dish here
from sys import stdin,stdout
a0=0
a1=1
n,k=stdin.readline().strip().split(' ')
n,k=int(n),int(k)
arr=list(map(int,stdin.readline().strip().split(' ')))
def solve(n,k,arr):
sol=[]
l=0;u=k;
while l!=u:
sol.append(arr[l:min(len(arr),u)])
l=min(l+k,len(arr))
u=min(u+k,len... | vfc_1966 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/AGPR2020/problems/ALPR2005",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "7 5\n1 0 0 1 1 1 1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 782 | Solve the following coding problem using the programming language python:
Naman owns a very famous Ice Cream parlour in Pune. He has a wide range of flavours with different pricing.
Every flavour costs ₹ X per gram and quantity of each flavour in the parlour is indefinite. Now, Naman has
received an order for a pa... | ```python
test = int(input())
for i in range(test):
flavor = int(input())
rate = input()
gaf = input()
gaf = gaf.split()
gaf = [int(x) for x in gaf]
rate = rate.split()
rate = [int(x) for x in rate]
rate.sort()
c = gaf[0] - gaf[1]
sum = rate[0]*c
t = True
if gaf[0] < gaf[1]:
t = False
j = 0
while(j<gaf[... | vfc_1970 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CCWR2016/problems/CCWR01",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n5\n4 6 8 1 10\n10 3\n2\n1 2\n1 2\n",
"output": "18\nNot Possible\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 783 | Solve the following coding problem using the programming language python:
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following mean... | ```python
# cook your dish here
epi=10**-2
def vision(t):
a1=x0+(dx*t)-x1
a2=y0+(dy*t)-y1
a3=z0+(dz*t)-z1
b=4*((a1*d1)+(a2*d2)+(a3*d3))*((a1*d1)+(a2*d2)+(a3*d3))
a=4*((a1*a1)+(a2*a2)+(a3*a3))
value=(b-(a*c))
return value
xrange=range
for _ in range(int(input())):
x1,y1,z1,x0,y0,z0,dx,dy,dz,cx,cy,cz,r=list(map(i... | vfc_1974 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/VSN",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n3 0 0 -10 -10 0 0 10 0 0 -3 0 3\n",
"output": "1.0000000000\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 784 | Solve the following coding problem using the programming language python:
Spring is interesting season of year. Chef is thinking about different things, but last time he thinks about interesting game - "Strange Matrix".
Chef has a matrix that consists of n rows, each contains m elements. Initially, the element aij of... | ```python
import sys
import os
import random
import math
#nonlocal defs
n, m, p = list(map(int, input().split()))
arr = [dict() for _ in range(n)]
for _ in range(p):
i,j = list(map(int,input().split()))
i -= 1
j -= 1
if j not in arr[i]:
arr[i][j] = j+1
else:
arr[i][j] += 1
def chefbm(arr,i):
for (e,f) in arr... | vfc_1978 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/MAY14/problems/CHEFBM",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 4 6\n2 2\n3 2\n3 2\n4 3\n4 4\n4 3\n",
"output": "3\n3\n-1\n4\n",
"type": "stdin_stdout"
}
]
} |
apps | verifiable_code | 785 | Solve the following coding problem using the programming language python:
One of Chef's friends offered him a deal: during $D$ days, they are going to exchange money. For each $i$ ($1 \le i \le D$), on the $i$-th day, Chef's friend would give Chef $A$ rupees, while Chef would give his friend $2^{i-1}$ rupees ($1$ rupe... | ```python
# cook your dish here
a = int(input())
for i in range(a):
b = int(input())
li = []
if b == 2:
print(2,1)
elif b == 3:
print(3,2)
elif b == 4:
print(4,2)
else:
for t in range(b+1):
if ((b*t)+1-(2**t))<0:
li.append(t-1)
break
for o in range(b+1):
if b<=2**(o):
li.append(o)
... | vfc_1982 | {
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/TRICKYDL",
"time_limit": "None"
} | {
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n5\n8\n9\n1000000000\n",
"output": "4 3\n5 3\n5 4\n35 30\n",
"type": "stdin_stdout"
}
]
} |
Subsets and Splits
Random Hard Python Problems
Retrieves a random sample of 10 hard difficulty questions along with their answers and problem IDs, providing basic filtering but limited analytical value.