code string | generator string | label int64 | language string |
|---|---|---|---|
num = list(input())
lucky = 0
for i in range(len(num)):
if num[i] == '4' or num[i] == '7':
lucky += 1
if lucky in {4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777} and lucky != 0:
print('YES')
else:
print('NO')
| human | 0 | Python |
if n == 1:
return s == t
for i in range(n):
for j in range(n):
if i == j:
continue
s1 = s[:i] + s[i+1:]
t1 = t[:j] + t[j+1:]
if f(n-1, s1, t1):
return True
return False
def main():
for _ in range(int(input())):
... | meta-llama/Llama-3.2-3B | 1 | Python |
s = input()
l = len(s)
check = '123456789'
a = s.find('^')
left = 0
right = 0
for i in range(a):
if s[i] in check:
left += int(s[i]) * abs(a - i)
for i in range(a, l):
if s[i] in check:
right += int(s[i]) * abs(a - i)
if left == right:
print('balance')
elif left > right:
print('left')
else:
print('right')
| human | 0 | Python |
from math import inf
from collections import *
import math, os, sys, heapq, bisect, random, threading
from functools import lru_cache
from itertools import *
def inp():
return sys.stdin.readline().rstrip('\r\n')
def out(var):
sys.stdout.write(str(var))
def inpu():
return int(inp())
def lis():
return list(map(in... | human | 0 | Python |
import math
n, m = [int(item) for item in input().split()]
city = list()
for i in range(n):
city.append([int(item) for item in input().split()])
city_dict = {}
for i in range(n):
city_dict[i] = city[i][0]
bridge = list()
for i in range(m):
bridges = [int(item) for item in input().split()]
bridge.appen... | microsoft/phi-2 | 1 | Python |
. Can't use more the given n because n could be equal to 2000. It can create some problems with recursion or loops of usual time. You can suggest code in Haskell or another haskell programming language.
"""
def buttons(n):
r = n
if n > 2:
c = (pow(2,n-1)-2)/(pow(2,n-2)-1)
c+=n-1
# while ... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
mylist = list(map(int, input().split()))
e = input()
sum = 0
liste = list(e)
for i in range(len(liste)):
if '1' == liste[i]:
sum = mylist[0] + sum
if '2' == liste[i]:
sum = mylist[1] + sum
if '3' == liste[i]:
sum = mylist[2] + sum
if '4' == liste[i]:
sum = mylist[3] + sum
print(sum)
| human | 0 | Python |
from functools import reduce
def digit(x):
s = str(x)
return reduce(lambda x, y:x|1<<ord(y)-48,s,0)
def common(x,d):
m = digit(x) | digit(d)
return sum(((m>>i)&1 for i in range(10))) -2
def answer(x):
ans = 0
for i in range(1,int(x**(1./2))+1):
if x%i==0:
ans += (1+common(x,... | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
from sys import stdin
s = stdin.readline().strip()
k = int(stdin.readline().strip())
n = len(s)
dp = [[[[None for tt in range(2)] for i in range(2)] for j in range(k + 1)] for k1 in range(n)]
dp1 = [[[[None for tt in range(2)] for i in range(2)] for j in range(k + 1)] for k1 in range(n)]
def sol(i, j, t, c):
if i == ... | human | 0 | Python |
class Solution:
def convertRoman(self, n):
a = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
b = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']
i = 12
res = ''
while n:
quo = n // a[i]
n = n % a[i]
while quo:
res = res + b[i]
quo = quo - 1
i -= 1
retur... | human | 0 | Python |
def feast(beast, dish):
res = False
return beast[0] == dish[0] and beast[len(beast) - 1] == dish[len(dish) - 1]
| human | 0 | Python |
def isPrime(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return True
n = int(input())
ans = 0
for i in range(n):
t = int(input())
if isPrime(t):
ans += 1
print(ans)
| human | 0 | Python |
def smallestKDigitNum(self, X: int, K: int) -> int:
# code here
# User function Template for python3
# function to find the number
# which is divisible by K which
# has K number of digits
def smallestKDigitNum (n1, k):
i = 1
while 1:
if (int (str (n1) + str (i)) % k == 0):
... | microsoft/phi-2 | 1 | Python |
while True:
try:
lst = list(map(int, input().split()))
(a, b) = (lst[0], lst[1])
while b != 0:
(a, b) = (b, a % b)
c = lst[0] * lst[1] / a
print('{:.0f}'.format(a), end=' ')
print('{:.0f}'.format(c))
except:
break
| human | 0 | Python |
python
def rearrange(S, N):
vowels = set('aeiou')
vowels_list = []
consonants_list = []
# Separate vowels and consonants
for char in S:
if char in vowels:
vowels_list.append(char)
else:
consonants_list.append(char)
# Check if rearrangement is possible
... | microsoft/Phi-3.5-mini-instruct | 1 | Python |
t = int(input())
for _ in range(t):
n = int(input())
reviewers = list(map(int, input().split()))
upvotes = sum(1 for reviewer in reviewers if reviewer!= 2)
print(upvotes) | codellama/CodeLlama-34b-Instruct-hf | 1 | Python |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class test{
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Pr... | human | 0 | Java |
.
"""
def who_drinks(n: int) -> str:
queue = ["Sheldon", "Leonard", "Penny", "Rajesh", "Howard"]
i = 0
while len(queue) < n:
queue += [queue[i]] * 2
i = (i + 1) % len(queue)
return queue[n-1]
print(who_drinks(1802))
# Output: Penny | microsoft/Phi-3-small-8k-instruct | 1 | Python |
from sys import stdin, stdout
from collections import Counter
def ai():
return list(map(int, stdin.readline().split()))
def ei():
return map(int, stdin.readline().split())
def ip():
return int(stdin.readline().strip())
def op(ans):
return stdout.write(str(ans) + '\n')
n = ip()
s = [i for i in input()]
s2 = sort... | human | 0 | Python |
for _ in range(int(input())):
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
p = [0] * n
for i in range(1, n - 1):
if a[i - 1] < a[i] > a[i + 1]:
p[i] = 1
count = sum(p[1:k - 1])
count2 = count
idx = 0
for i in range(1, n - k + 1):
count2 = count2 + p[i + k - 2] - p[i]
if count2... | human | 0 | Python |
year = int(input())
while True:
year += 1
l = [int(x) for x in list(str(year))]
s = list(set(l))
if sorted(l) == sorted(s):
break
print(year)
| human | 0 | Python |
python
# Read the number of participants, the qualifier position, the scores
num_participants, k = map(int, input().split())
scores = list(map(int, input().split()))
# Find the qualifying score
qualifying_score = sorted(scores, reverse=True)[k - 1]
# Count how many participants earned an equal to or better score
adva... | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
N = int(input())
inNum = [int(n) for n in input().split(' ')]
MaxS = 0
stack = list()
def calculateS(M1, M2):
S = (M1 & M2 ^ (M1 | M2)) & (M1 ^ M2)
return S
for i in range(0, N):
if len(stack) == 0:
stack.append(inNum[i])
continue
if inNum[i] < stack[-1]:
while len(stack) > 0:
MaxS = max(calculateS(stack[... | human | 0 | Python |
def can_reach_planet(p_x, p_y, s):
x, y = 0, 0
stack = []
for order in s:
if order == 'U':
y += 1
stack.append('U')
elif order == 'D':
y -= 1
stack.append('D')
elif order == 'R':
x += 1
stack.append('R')
... | Qwen/Qwen2.5-Coder-7B-Instruct | 1 | Python |
def min_taxis(n, groups):
# Count the number of groups of each size
count = [0] * 5
for group in groups:
count[group] += 1
# Initialize the number of taxis needed
taxis = 0
# Process groups of 4
taxis += count[4]
count[4] = 0
# Process groups of 3
taxis += ... | codellama/CodeLlama-70b-Instruct-hf | 1 | Python |
; no need to print anything. Consider applying gsl formatting.
#include <iostream>
#include <vector>
#include <algorithm>
int minFlips(std::string target) {
int count = 0;
for (int i = 1; i < target.size(); ++i) {
target[i - 1] != target[i]
? ++count
: count;
}
return co... | Qwen/Qwen2.5-Coder-1.5B | 1 | C++ |
python
def solve(n, l):
l.sort()
for i in range(n - 1):
if l[i] + l[i + 1] > l[i + 2]:
return l[i + 2] - l[i]
return -1 | microsoft/Phi-3-small-8k-instruct | 1 | Python |
To solve the problem of detecting HTML tags, attributes, and attribute values from a given HTML snippet, while ignoring content inside HTML comments, we can use a combination of regular expressions and a simple parser. Here's a step-by-step breakdown of the approach:
1. **Read and Concatenate Input**: First, read the ... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
public int maxScoreAfterRotate(int[] nums) {
// you are allowed to change this method
Map<Integer, Integer> map = new HashMap<>();
List<Integer> temp = new ArrayList<>();
for (int i : nums) {
temp.add(i);
}
/*For k: nums balanced before ro... | microsoft/phi-2 | 1 | Java |
import java.io.*;
import java.math.*;
public class Main {
public static String[] splitStr(String s){
return String.valueOf(s).split(" ");
}
public static void main(String[] args) {
FastReader inp = new FastReader(System.in);
int t = inp.nextInt();
while (t-- > 0) {
int n = inp.nextInt();
int[] a = new int[n];
for(int... | bigcode/starcoder2-3b | 1 | Java |
class Solution {
public List<Integer> countSteppingNumbers(int low, int high) {
List<Integer> cur = new ArrayList<>();
for(int i = 0; i < 10; ++i) cur.add(i);
List<Integer> res = new ArrayList<>();
construct(cur, res, low, high);
return res;
}
... | human | 0 | Java |
from collections import Counter
def tetris(arr):
fields = Counter()
clear = 0
for log in arr:
pos = log[1:].replace('R0', 'L0')
fields[pos] += int(log[0])
if fields[pos] >= 30:
break
elif len(fields) == 9:
c = min(fields.values())
clear += c
for pos in fields:
fields[pos] -= c
return clear
| human | 0 | Python |
!
import operator
from itertools import chain
class KMP: #KMP algorithm maintenance table.
def __init__(self, lps, pattern, text):
self, self.kmp_fin_list = [], []
count_str, index_str = dict(), []
for i, a in enumerate(lps): index_str.append(a)
for j in chain(*lps): count_str[j... | 01-ai/Yi-Coder-1.5B | 1 | Python |
class Solution:
def minSteps(self, N):
def fun(n):
if n == 1:
return 0
if dp[n] != -1:
return dp[n]
res = 0
res = fun(n - 1)
if n % 2 == 0:
res = min(res, fun(n // 2))
if n % 3 == 0:
res = min(res, fun(n // 3))
dp[n] = 1 + res
return dp[n]
dp = [-1] * (N + 1)
return fun(... | human | 0 | Python |
Return code only(n, k)
"""
import os
import sys
#
# Complete the integerReplacement function below.
#
def integerReplacement(s, k):
"""
:type s: int
:type k: int
:rtype: int
"""
n = 2**k - 1
while s < n:
if s % 2:
s += 1
else:
s //= 2
n = (... | bigcode/starcoder | 1 | Python |
------ Explanation ------
This problem is solved by the following python code:
"""
Construct an array A of length N that satisfies the following conditions
A has exactly K good (contiguous) subarrays, and
Every element of A is an integer from 1 to N (both inclusive).
If there are multiple such arrays, you can print... | bigcode/starcoder2-7b | 1 | Python |
t = int(input())
for i in range(t):
a,b,c,x,y = (int(x) for x in input().split())
#print("a: ",a, "b: ", b, "c: ",c, "x: ",x,"y: ",y )
#print("YES " * (x > 0 or y > 0) + "NO" * (not x >= 0 and not y >=0))
print('Yes' if x> 0 or y>0 else 'No') | bigcode/starcoder | 1 | Python |
class Solution:
def countSubstringWithEqualEnds(self, s):
from collections import Counter
dicta = Counter(s)
add = sum([(x - 1) * x // 2 for (i, x) in dicta.items() if x > 1])
return add + len(s)
if __name__ == '__main__':
T = int(input())
for i in range(T):
s = input()
ob = Solution()
answer = ob.cou... | human | 0 | Python |
def tabletennis(pl, w):
i = 0
p1 = pl[0]
p2 = pl[1]
if p1 > p2:
r = pl.pop(1)
pl.append(r)
else:
p1 = p2
r = pl.pop(0)
pl.append(r)
i += 1
while i != w:
if p1 > pl[1]:
i += 1
pl.append(pl[1])
pl.pop(1)
else:
i = 1
pl.append(pl[0])
pl.pop(0)
p1 = pl[0]
if i > len(pl):
break... | human | 0 | Python |
n = int(input())
print(abs(1110 - n))
| human | 0 | Python |
from math import *
def inv(a, m):
m0 = m
x0 = 0
x1 = 1
if m == 1:
return 0
while a > 1:
q = a // m
t = m
m = a % m
a = t
t = x0
x0 = x1 - q * x0
x1 = t
if x1 < 0:
x1 = x1 + m0
return x1
def findMinX(num, rem, k):
prod = 1
for i in range(0, k):
prod = prod * num[i]
result = 0
for i in ra... | human | 0 | Python |
t = int(input())
def solve(n, arr):
cur = arr[0]
transformed = [0]
for i in range(1, n):
transformed.append(max(transformed[i - 1], arr[i] - cur))
cur = min(cur, arr[i] - transformed[i])
cur = arr[-1]
for i in range(n - 1, -1, -1):
if arr[i] < transformed[i]:
return False
return True
for _ in range(t):
... | human | 0 | Python |
. """
def sum_equal(self, N, B):
x = 0
A = []
mx = 0
typeA = 0
for num in B:
if typeA == 0:
x = num
if A and num - x == 0:
typeA = 1
if num - x > mx:
mx = num - x
A.append(num)
#print 'Working!'
if mx > 10**9:
return "-1"
for num in A:
if num - x != 0:
A.append(b + 10... | 01-ai/Yi-Coder-1.5B | 1 | Python |
def estimate(A, s):
A = Counter(A[::-1])
pct = len(s) * [0]
for c in s:
pct[c] += 1
for i in range(len(pct) - 1, -1, -1):
pct[i-1] += pct[i]
return [pct[i][c-1] forall c in A for c in A]
def main():
n, s, m = [item() for item in (int, str, int)]
s = list(s)
estimateS... | codellama/CodeLlama-7b-hf | 1 | Python |
n = int(input())
while n > 0:
n -= 1
_ = int(input())
arr = input().split(' ')
hmap = {}
for i in arr:
if hmap.get(i) == None:
hmap[i] = 1
print(i + ' ', end='')
print()
| human | 0 | Python |
python
def prob(n, m):
total = n * m
nways = int( math.factorial(n)/(math.factorial(n - 2)* math.factorial(2)))
prob_same = float( nways ) / math.factorial(total)
probabilty_pull_same = prob_same * 1 + float(total - nways)/float(total) * (float( ((total-2) / 2))/ math.factorial(total))
return probabilty_pull_... | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
i = int(input())
print(i//1 + i//10 + i//100 + i//1000)
"""
a, k = i%10, 0
while i > 0:
i //= 10
k += i//1000 + i//100 + i//10 + i
"""
"""
z = 0
for m in range(1, i//10 + 1):
z += (i//10)**m - (i//10)**(m-1)
return z + 1
"""
ANSWER
// else if(ind... | meta-llama/Llama-3.1-8B | 1 | Python |
t = int(input())
while t > 0:
x = input()
n = len(x)
print(10 * (int(x[0]) - 1) + n * (n + 1) // 2)
t = t - 1
| human | 0 | Python |
text = input()
if 'H' in text or 'Q' in text or '9' in text:
print('YES')
else:
print('NO')
| human | 0 | Python |
while onlyt > 0 :
n = int(input())
a = [i for i in list(input())]
a[0],a[1] = a[1], a[0]
if n >2 :
if n%2 == 0 :
for i in range(1, n-2, 2) :
a[i] , a[i+1] = a[i+1], a[i]
else :
a[n-1] = a[1]
a[n] = a[2]
for k in a : print("", end="")
... | codellama/CodeLlama-7b-hf | 1 | Python |
class Solution:
def hardestWorker(self, n: int, logs: List[List[int]]) -> int:
logs.sort(key=lambda x:x[1])
print(logs)
N=len(logs)
p=0
df=-10**9
ix=logs[0][0]
for ID,dx in logs:
d=dx-p
if d>df:
df=d
ix=I... | human | 0 | Python |
t=int(input())
while t>0:
n=int(input())
s=input()
a=int(n/2)
b=2*a-1
ans=''
for i in range(a):
x=i
ans+=s[x]
print(ans)
t-=1 | ibm-granite/granite-8b-code-base-4k | 1 | Python |
class Quditch():
def points(self, starting_team, match):
seeri = 30
poing = 10
sei = seeri * Counter(match)['ta']
duit = Counter(match)['mitcc'] * poing
return '{}: {}, {}: {}'.format(*sorted((starting_team, sei+duit), key=lambda x:x[0])) if '\none' not in match else '{}: {}... | ibm-granite/granite-8b-code-base-4k | 1 | Python |
with open("input.txt") as f:
n, m = map(int, next(f).split())
matrix = [[int(x) for x in next(f).split()] for _ in range(n)]
path = [(0, 0)]
for _ in range(n * m):
path = [(x[0], x[1] + 1)] + path if path[-1][1] < m else path + [(x[0] + 1, 0)]
if path[-1] == (n, m):
return 0
path = [(x[0] + 1, x[1])] + path if path[-1]... | meta-llama/Llama-3.2-3B | 1 | Python |
[ai]: def sum_of_digits(n):
return sum(int(digit) for digit in str(n))
def number_of_spells(n):
count = 0
while n >= 10:
n = sum_of_digits(n)
count += 1
return count
# Read input
n = int(input().strip())
# Calculate and print the output
print(number_of_spells(n)) | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
def find(n: int) -> int:
"""
This function calculates the luckiest person in a circle of N people,
where each person is killing the next person and handing over the sword.
Args:
n (int): The number of people in the circle.
Returns:
int: The position of the luckiest person.
"""
# J... | meta-llama/Llama-3.3-70B-Instruct | 1 | Python |
python
s = input()
t = 'hello'
j = 0
for i in range(len(s)):
if s[i] == t[j]:
j += 1
if j == len(t):
print('YES')
break
else:
print('NO') | 01-ai/Yi-Coder-9B-Chat | 1 | Python |
3.
Code must be in python
The number of possible moves the king (rook) can make in chess are 0.057% of the total number of positions a knight could make in a board of dimension m × n. This makes possible to calculate the possible knight’s moves in a chessboard in a matter of milliseconds. So you have nothing to worry.... | Qwen/Qwen2.5-Coder-1.5B | 1 | Python |
, no need for print statements.
"""Python
def findFloor(arr, n, x):
res = -1
l, r = 0, n-1
while(l <= r):
m = l + (r - l)//2
if arr[m] <= x:
res = m
l = m+1
else:
r = m-1
return res"""
Answer: The given code snippet is a solution to the pro... | microsoft/Phi-3-small-8k-instruct | 1 | Python |
n = int(input())
def f(n):
k = 1
for i in range(2, n):
k += i
return k
l = sorted(map(int, input().split()))
if len(set(l)) == 1:
print(0, f(n))
else:
print(l[-1] - l[0], l.count(l[0]) * l.count(l[-1]))
| human | 0 | Python |
def gcd(a, b):
while a % b != 0:
(a, b) = (b, a % b)
return b
def lcm(a, b):
return a * b // gcd(a, b)
(n, a, b, p, q) = map(int, input().split())
A = n // a
B = n // b
AandB = n // lcm(a, b)
print(A * p + B * q - min(p, q) * AandB)
| human | 0 | Python |
list_image = []
for i in range(n):
list_image.append(input())
# m is width
# n is height
k = 0
for x in range(n):
for y in range(m):
if x + 1 < n and y + 1 < m:
# is valid
if list_image[x][y] in "face" and list_image[x + 1][y] in "xea" and list_image[x + 1][y + 1] in "xfc" and li... | ibm-granite/granite-8b-code-base-4k | 1 | Python |
.
"""
from math import factorial
def solve(n, P, Q):
fact = [factorial(i) for i in range(n+1)]
def get_index(arr, used):
cnt = 0
for i in range(n):
smaller = sum(j not in used for j in arr[i+1:])
cnt += fact[n-i-1] * smaller
return cnt
P_idx = get_index(P, se... | 01-ai/Yi-Coder-9B-Chat | 1 | Python |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t > 0){
int n = in.nextInt() , sum = 0;
int []arr = new int[n];
boolean flag = false;
for... | human | 0 | Java |
for k in range(t):
r, g, b, w = map(int, input().split())
if (r + g >= 2) and (w == 0):
print("No")
elif (b + g >= 3) or (r + w >= 3) or (b + w >= 3):
print("Yes")
else:
print("No") | google/codegemma-7b | 1 | Python |
.
========================================
```
N = input().split(' ')
for x in range(2,int(N[1])+2):
for c in [x,N[0]]:
print(*range(2,c+2))
for a1,b1,c1 in[[(c-x-1),(N[1],b-N[1]-1,c-n1-1),
[(b-x)*(1 + N[0]+ b*x - b-x -1 ),
for i,a1 in enumerate([[0 if i <x ]:int(N[1]/c)])] if x*b>a]... | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
python
def swapKth(arr, n, k):
# Calculate the index of the K-th element from the end
# It will be (n - k) due to 0-based indexing
index_from_beginning = k - 1
index_from_end = n - k
# Swap the elements at those indices
arr[index_from_beginning], arr[index_from_end] = arr[index_from_end], a... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
for the case without the comments:
def check(a, b, c):
if (a ^ b ^ c == 0 and a != 3 and b != 3 and c != 3):
return "YES"
return "NO"
import sys
for line in sys.stdin:
a, b, c = map(int, line.split())
print(check(a, b, c))
'''
def solve(n, a, b, c, x):
xc = x
for i in range(n):
... | 01-ai/Yi-Coder-1.5B | 1 | Python |
, no explanation or text is needed.
-----My Solution-----
def gender(username):
distinct_chars = set(username)
if len(distinct_chars) % 2 == 0:
return "IGNORE HIM!"
else:
return "CHAT WITH HER!"
print(gender("wjmzbmr")) # Output: CHAT WITH HER!
print(gender("xiaodao")) # Output: IGNORE... | microsoft/Phi-3-small-8k-instruct | 1 | Python |
t = list(input().lower())
x = list(filter(lambda ch: ch != 'a' and ch != 'e' and (ch != 'i') and (ch != 'o') and (ch != 'u') and (ch != 'y'), t))
y = ' '.join(x)
z = list(y.split())
print('.' + '.'.join(z))
| human | 0 | Python |
__author__ = 'curiousfool'
n = int(input())
list = []
for i in range(0, n):
string = input()
list = string
x = list[0]
y = list[len(string) - 1]
if len(string) <= 10:
print(string)
else:
print(x + str(len(string) - 2) + y)
| human | 0 | Python |
import bisect
x = int(input())
prices = list(map(int, input().split()))
z = int(input())
score = []
prices = sorted(prices)
for i in range(z):
day = int(input())
score.append(bisect.bisect(prices, day))
for c in score:
print(c)
| human | 0 | Python |
def f(a):
lis = 0
j = [0]
for i in a:
i
i, j bib = bisect.bisect, list
while 1:
print(l[0:l[2]])
print("l[2]=", l[2])
print("l=", l)
an = __import__('random').randrange(l[0]-l[2]+1)
print("an=", an)
a.pop(variable)
l = [len(a)]
... | Qwen/Qwen2.5-Coder-7B | 1 | Python |
def solve(money, ball, light, loc=num, choose=1):
if loc == float('inf') or all([n[0] < ball.count(x) for n in loc]):
return 0
if loc.count(None) > 1:
loc = [loc] if len(loc) == 1 else tuple(loc)
if len(loc) == 1:
lrs = sorted(loc[0], reverse=True)[choose:]
day = []
f... | meta-llama/Llama-3.2-3B | 1 | Python |
from collections import Counter
def main():
n, k = list(map(int, input().split()))
s = input()
# cnt = Counter(s)
# print(cnt)
# res = 0
# for c in cnt.values():
# res += min(c, k)
# k -= min(c, k)
# if k == 0:
# break
# print(res)
if k == 0:
r... | 01-ai/Yi-Coder-9B | 1 | Python |
import java.io.*;
import java.util.*;
public class function {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int testcases = Integer.parseInt(r.readLine()... | human | 0 | Java |
import statistics
n = int(input())
x = list(map(int, input().split()))
xmd = statistics.median(x)
xs = sorted(x)
for i in x:
if i < xmd:
print(xs[n // 2])
else:
print(xs[n // 2 - 1])
| human | 0 | Python |
python
MOD = 998244353
def blockCount(n):
count = [0] * (n + 1)
power = [10**i % MOD for i in range(n + 1)]
for i in range(2, n + 1):
result = 0
for j in range(i):
r = (10**j - 1) % MOD
if i - j >= 1:
result = (result + power[j] * (power[i] - r) ... | microsoft/Phi-3-small-8k-instruct | 1 | Java |
int ХЪЙ(иЖЇ):
ГФ = input()
Гћ = input()
_МК_Г(0, Гћ, ХЪЙ)
def '__Г(от)_Ш'Б):
if от == 1: Б = преврати(Б)
return Б
def '_МК_Г(п, Гћ, ХЪЙ):
for _Ж in range(п, Гћ):
оК = input().split()
подЪ(___Г)
t_1 = False
while not t_1:
s = input()
if s == '': t_1 = True
Г = Г(0, 5, ХЙ(иЖЇ))
Б = input()
__Г ='
print(*[_... | bigcode/starcoder | 1 | Python |
def main():
import sys
input = sys.stdin.read
data = input().split()
H = int(data[0])
W = int(data[1])
c = data[2:]
buildings = []
for i in range(H):
for j in range(W):
if c[i][j] == 'B':
buildings.append((i, j))
max_distance = 0
... | codellama/CodeLlama-70b-Instruct-hf | 1 | Python |
n = int(input())
values = list(map(int, input().strip().split(' ')))
values.sort(reverse=True)
t = sum(values) // 2 + 1
t_ = 0
for (i, c) in enumerate(values):
t_ += c
if t_ >= t:
print(i + 1)
break
| human | 0 | Python |
import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda ... | human | 0 | Python |
test = int(input())
ans = []
while test:
test = test - 1
(A, B, A1, B1, A2, B2) = [int(x) for x in input().split()]
if (A == A1 or A == B1) and (B == A1 or B == B1):
ans.append(1)
elif (A == A2 or A == B2) and (B == A2 or B == B2):
ans.append(2)
else:
ans.append(0)
for i in ans:
print(i)
| human | 0 | Python |
python
def count_quadruples(N, K):
count = 0
for a in range(1, N+1):
for b in range(1, N+1):
for c in range(1, N+1):
d = a + b - K - c
if 1 <= d <= N:
count += 1
return count
# Sample input
N, K = map(int, input().split())
print(count_... | microsoft/Phi-3.5-mini-instruct | 1 | Python |
list_ = [int(x) for x in input().split(' ')]
m = list_[0]
n = list_[1]
print(int(m * n / 2))
| human | 0 | Python |
from collections import Counter
def solve():
n = int(input())
A = [int(char) for char in input().split()]
B = [int(char) for char in input().split()]
ans = n - 1
for (i, a) in enumerate(A):
for (j, b) in enumerate(B):
if a < b:
ans = min(ans, i + j)
print(ans)
def solve2():
n = int(input())
A = [int(... | human | 0 | Python |
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
... | human | 0 | Python |
import math
[d, h, v, e] = [int(x) for x in input().split()]
p = math.pi
if v <= p * (d / 2) * (d / 2) * e:
print('NO')
else:
x = v / (p * (d / 2) * (d / 2)) - e
time = h / x
print('YES')
print(time)
| human | 0 | Python |
. It should be a function.
Follow up: What if the limits is very large? Instead of O(N) space, can you reduce it to O(1)?
'''
def longestSubarray(nums, limit):
# Complete the function
longest_length = 0
num_dict = {}
pointer_start = 0
max_diff = 0
for pointer_end, num in enumerate(num... | microsoft/Phi-3-small-8k-instruct | 1 | Python |
with open(sys.argv[1], 'r') as inputfile:
j= 0
for i in range(int(inputfile.readline())):
print(i)
-----Easy16354Easy-----
Solution on C
How to compile and run a C program
1 Click + - Fold
2 Console. You can type and run C on ideone.com immediately.
3 Additionally, after clicking the Run button, the ... | codellama/CodeLlama-7b-hf | 1 | Python |
def solve_test_case(n, k, a):
max_value = max(a)
transformed_a = [max_value - x for x in a]
# After two operations, the array returns to its original state.
# Hence, the pattern repeats every two operations.
if k % 2 == 0:
return a
else:
return transformed_a
def main():
... | Qwen/Qwen2.5-Coder-32B-Instruct | 1 | Python |
To solve this problem, we need to construct an array \( b \) such that for each index \( i \), the \( MEX \) of the subarray \( b[1:i] \) is equal to \( a_i \). The \( MEX \) of a set is defined as the smallest non-negative integer not present in the set.
### Key Observations:
1. **MEX Definition**: For each \( i \),... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
-----Python Code-----
def coinChange(S, m, n):
# table[i] will be storing the number of solutions for value i.
table = [0] * (n + 1)
table[0] = 1
# Go through all numbers from 0 to n
for i in range(0 , m):
# Go through all values from 0 to n
for j in range(S[i] , n ... | 01-ai/Yi-Coder-1.5B-Chat | 1 | Python |
import math
def is_prime(x):
if x <= 1:
return False
for i in range(2, int(math.sqrt(x)) + 1):
if x % i == 0:
return False
return True
def max_prime_sum(n):
primes = []
res = n
if n % 2 == 0:
while n >= 2:
primes.append(2)
n -= 2... | Qwen/Qwen2.5-Coder-32B-Instruct | 1 | Python |
:
1
0
2
3
Note:
The problem is to implement the Dijkstra's algorithm for SSSP, the algorithm's time complexity is O(|V||E| log |V|) and it's used for finding shortest paths in a graph. | deepseek-ai/deepseek-coder-1.3b-instruct | 1 | Python |
r = input().strip()
m=re.match ( r ,'....')
s = int ('1',1) > m .span (" ")
print (s)
python program
import re
test = str (open("inp", "r ")) .strip()
n,= m.groups() | meta-llama/Llama-3.2-3B | 1 | Python |
# include <iostream>
int main() {
int n;
cin >> n;
int mi = 100005;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
int S = std::min(a, mi) + A * std::max(a, mi) - M;
if (std::abs(S) > mi) {
mi = S;
}
}
cout << mi << std::endl;
return 0;
} | meta-llama/Llama-3.2-3B | 1 | Python |
def pattern(n):
first = [0] * n
second = [0] * n
third = [0] * n
forth = [0] * n
first[0] = 1
second[0] = 2
third[0] = 4
forth[0] = 3
if n > 1:
for i in range(1, n):
first[i] = first[i - 1] + second[i - 1] + 1
second[i] = first[i - 1] + second[i - 1] + 2
third[i] = second[i] * 2
forth[i] = second... | human | 0 | Python |
def min_time_to_finish_game(n, r1, r2, r3, d, a):
# Initialize DP array to store minimum time to finish each level
dp = [0] * n
# Function to calculate the minimum time to kill all monsters and the boss in a level
def time_to_clear_level(a_i, r1, r2, r3):
if r1 + a_i * r1 < r2:
... | codellama/CodeLlama-70b-Instruct-hf | 1 | Python |
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a:
if i % 2 == 0:
s += i
print(s)
| human | 0 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.