code string | generator string | label int64 | language string |
|---|---|---|---|
.
Input:
N = 3, M = 3
Mat = [[1,2,3], [6,5,4], [7,9,8]]
Output:
2
Input:
N = 3, M = 3
Mat = [[1,2,3], [4,5,6], [7,8,9]]
Output:
3
Input:
N = 3, M = 3
Mat = [[1,2,3], [3,2,1], [7,9,8]]
Output:
3
Input:
N = 3, M = 3
Mat = [[1,2,3], [3,2,1], [2,3,1]]
Output:
2
Input:
N = 3, M = 3
Mat = [[1,2,3], [2,2,2], [2,3,1]]... | microsoft/Phi-3-mini-4k-instruct | 1 | Python |
python
def can_reach(n, t, a):
visited = [False] * (n + 1)
current = 1
visited[current] = True
while current != t:
next_cell = current + a[current - 1]
if next_cell > n or visited[next_cell]:
return "NO"
visited[next_cell] = True
current = next_cell
... | Qwen/Qwen2.5-Coder-7B-Instruct | 1 | Python |
return sys.stdin._ readline()
Return code only
In order to use the official checker run your solution with the flag -stdio . You can do that via the command-line interface or via your platform language (ide) settings e.g. for Python 3.n and Pypy 3.n on SPOJ you need to select old interpreter for this procedure to work.... | 01-ai/Yi-Coder-9B | 1 | Python |
for _ in [0] * int(input()):
arr = [int(a) for a in input().split()]
(o, e) = (0, 0)
for b in arr:
if b % 2 == 0:
e += 1
else:
o += 1
if e == 2:
print('No')
elif e == 1 or e == 0:
if arr[0] == 0 or arr[1] == 0 or arr[2] == 0:
print('No')
else:
print('Yes')
else:
print('Yes')
| human | 0 | Python |
(h, w) = map(int, input().split())
fl = '#' * (w + 2)
print(fl)
for _ in range(h):
s = '#' + input() + '#'
print(s)
print(fl)
| human | 0 | Python |
def k_divisible_numbers(k, a, b):
# Function to find the number of k-divisible numbers from 1 to n
def count_up_to(n):
return n // k
# Adjust for inclusive range
result = count_up_to(b) - count_up_to(a - 1)
return result
# Input reading
k, a, b = map(int, input().split())
# Output the res... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
n = input()
l = []
if len(n) == 1:
print(n[0])
else:
for i in range(len(n)):
if n[i] in '123':
l.append(n[i])
l.sort()
n = l[0]
for i in range(1, len(l) - 1):
n = n + '+' + l[i]
print(n + '+' + l[-1])
| human | 0 | Python |
t = int(input())
for i in range(t):
n = int(input())
arr = list(map(int, input().split()))
odd_p = 0
even_p = 0
for i in range(n):
if i % 2 == 0 and arr[i] % 2 != 0:
odd_p += 1
elif i % 2 == 1 and arr[i] % 2 == 0:
even_p += 1
if odd_p == even_p:
print(even_p)
else:
print(-1)
| human | 0 | Python |
from itertools import cycle
def encode(message, key):
c = cycle(str(key))
return [ord(i) + int(ord(next(c))) - 144 for i in message]
| human | 0 | Python |
python
def is_prime(num):
if num < 2:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
def next_prime(x):
x += 1
while not is_prime(x):
x += 1
return x
n = int(input())
print(next_prime(n)) | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
F = lambda : map(int, input().split())
(m, n) = F()
area = m * n
if area % 2 == 0:
print(int(area / 2))
else:
print(int((area - 1) / 2))
| human | 0 | Python |
n = int(input())
a = [int(temp) for temp in input().split()]
for i in range(1, n + 1):
print(a.index(a.index(i) + 1) + 1)
| human | 0 | Python |
(n, m) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort()
sm = sum(a)
b = []
for elem in a:
if elem != 0:
b.append(elem)
ans = 0
sh = 0
for i in range(len(b)):
if b[i] > sh:
sh += 1
print(sm - max(a) - len(b) + sh)
| human | 0 | Python |
n = int(input())
answer = 0
if n % 2 == 0:
answer -= n ** 2 // 4
answer += n ** 2 // 4 + n // 2
print(answer)
else:
answer -= (n + 1) ** 2 // 4
answer += (n + 1) ** 2 // 4
answer -= (n + 1) // 2
print(answer)
| human | 0 | Python |
t = int(input())
for i in range(t):
s = input()
a = s.count('1')
d = len(s) - a
k = min(a, d)
if k % 2 == 1:
print('DA')
else:
print('NET')
| human | 0 | Python |
class Solution:
def articulationPoints(self, V, adj):
global time, disc, low, ans
ans = set()
disc = [-1 for i in range(V)]
low = [-1 for i in range(V)]
for i in range(V):
time = 0
if disc[i] == -1:
dfs(adj, i, -1)
if not ans:
return [-1]
ans = list(ans)
ans.sort()
return ans
def dfs(a... | human | 0 | Python |
def gcd(a, b):
while b!= 0:
a, b = b, a % b
return a
n = int(input())
nums = list(map(int, input().split()))
g = nums[0]
for i in range(1, n):
g = gcd(g, nums[i])
print(g * n) | meta-llama/Llama-3.3-70B-Instruct | 1 | Python |
import itertools
def longest_common_subsequence(words):
if not words:
return 0
shortest_word = min(words, key=len)
def is_subsequence(word, subsequence):
j = 0
for char in word:
if j < len(subsequence) and char == subsequence[j]:
j += 1
return j... | meta-llama/Llama-3.3-70B-Instruct | 1 | Python |
python
def repeatedStringMatch(A, B):
if len(B) <= len(A):
if B in A:
return 1
A += A
if B in A:
return 2
return -1
n = len(A)
i = 1
while len(A) * i <= len(B):
if B in A * i:
return i
i += 1
return -1 | meta-llama/Llama-3.1-8B-Instruct | 1 | Python |
if n==1:
print(1)
else:
t = 1
for i in range(1,n):
t = (2*i+1)*n
print(t) | google/codegemma-7b | 1 | Python |
from collections import defaultdict
def max_subset_with_pow2_distance(points):
points.sort()
n = len(points)
best_subset = [points[0]]
best_size = 1
for i in range(n):
current = points[i]
dp = defaultdict(int)
dp[current] = 1
for j in range(i+1, n)... | Qwen/Qwen2.5-Coder-32B-Instruct | 1 | Python |
parent = {-1, -1, -1, ...}
def find(self, i):
if self.parent[i] < 0:
return i
else:
self.parent[i] = self.find(self.parent[i])
return self.parent[i]
def union(self, i, j):
x, y = self.find(i), self.find(j)
if x == y:
return
... | meta-llama/Llama-3.1-8B | 1 | Python |
from sys import stdin, stdout
t = int(stdin.readline())
for k in range(t):
(n, m) = map(int, stdin.readline().split())
abs_list = []
for _ in range(m):
abs_list.append(list(map(int, stdin.readline().split())))
abs_list.sort(key=lambda x: -x[0])
abs_list[0].append(abs_list[0][0])
for i in range(1, m):
abs_list... | human | 0 | Python |
for python 3
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int t,n;
int main()
{
struct coins
{
int val;
coins(int v):val(v){}
};
int x = 0;
coins can[26];
priority_queue<int, vector<int>, less<int>>can1;
int i;
for(i=0;i<n;i++){
tuple<int,int,int> t1{can[i].val++, can[i].val++;,abs(can[i... | meta-llama/Llama-3.2-1B | 1 | Python |
def toPostorder(prelist, inlist):
parent = prelist[0]
split_index = inlist.index(parent)
if split_index != 0:
yield from toPostorder(prelist[1:split_index + 1], inlist[0:split_index])
if split_index != len(inlist) - 1:
yield from toPostorder(prelist[split_index + 1:], inlist[split_index + 1:])
yield parent
nod... | human | 0 | Python |
def main():
a=[int(x) for x in input().split()]
n=int(input())
b=[int(x) for x in input().split()]
fretsAndNoteNo=[] #(fret number, note number)
for base in a:
for noteNo,note in enumerate(b):
fret=note-base
fretsAndNoteNo.append((fret,noteNo))
... | human | 0 | Python |
if you have successfully solved all the examples (without passing them to your function manually). You don't need comments or types inside the code.
"""
# Functional solution
test_cases = int(input())
def matrix_pal(matrix): # O(n^2)
"""
Make properly palindromic matrices.
Counts change operations.
... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
from typing import Optional
class Solution:
def moveToFront(self, head: Optional['Node']) -> Optional['Node']:
if head.next == None:
return head
else:
stack = [head]
order = [head]
while len(stack) > 0:
current = stack.pop()
if current.next:
stack.append(current.next)
order.append(c... | human | 0 | Python |
for this problem
*/<|endoftext|>#include <iostream>
#include <algorithm>
using namespace std;
int read_array(int *arr, int n)
{
int i; int arr_sum; //chia arr them xong
for(i=0;i<n;i++)
{
cin>>arr[i];
arr_sum=arr_sum+arr[i];
}
return arr_sum;
}
/* Dinh nghia ham lam trinh duyet ca... | 01-ai/Yi-Coder-1.5B | 1 | Python |
n = int(input())
s = [input() for _ in range(n)]
t = ''
for i in set(s[0]):
if all((i in s[j] for j in range(n))):
t += i * min((s[k].count(i) for k in range(len(s))))
print(''.join(sorted(t)))
| human | 0 | Python |
sys.setrecursionlimit(100000)
def getint(): return int(sys.stdin.readline())
def getS(): return sys.stdin.readline()[-2]
def getIntList(): return list(map(int, sys.stdin.readline().split()))
class pair:
def __init__(self, v):
self.f = v[0]
self.s = v[1]
n = getint()
for _ in range(n):
m = getint()
... | google/codegemma-7b | 1 | Python |
problem = map(int, input().split())
prepare = map(int, input().split())
problem = list(set(problem))
def calculate(a1, a2):
if a1 > a2:
return 1
else:
return 0
ans = 0
i = 0
j = 0
while(i < len(prepare) and j < len(problem)):
if problem[j] == prepare[i]:
ans += calculate(problem[j], ... | bigcode/starcoder2-15b | 1 | Python |
S = input()
K = int(input())
P = set()
for i in range(len(S)):
for k in range(K + 1):
sub = S[i:k + i]
P.add(sub)
P = sorted(list(P))
print(P[K])
| human | 0 | Python |
t
3
import sys
if sys.stdin.isatty():
from bisect import bisect_left as bf
else:
input = sys.stdin.readline
from bisect import bisect_left as bf
t = int(input())
while t > 0:
t -= 1
n, m = [int(x) for x in input().split()]
bl1 = [[int(x) for x in input().split()] for x in range(n)]
bl2 ... | bigcode/starcoder2-7b | 1 | Python |
t = int(input())
count = 0
while t != 0:
l = [int(k) for k in input().split()]
if sum(l) >= 2:
count += 1
t = t - 1
print(count)
| human | 0 | Python |
from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_c... | human | 0 | Python |
if __name__ == "__main__":
sys.stdin = open("/Users/test/Documents/test/input00.txt", "r")
n, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
ans = sorted(a, reverse=True)
if ans[1] == 0:
print(0)
else:
print(ans[1]) | meta-llama/Llama-3.1-8B | 1 | Python |
for i in range(t):
s = str(input())
Set = set()
for i in range(len(s)):
if(i < (len(s)-2)):
Set.update(s[i]+s[i+1]+s[i+2])
print(''.join(sorted(Set))) | bigcode/starcoder | 1 | Python |
n = int(input())
answ = 0
passengers = 0
while n != 0:
a = input().split()
passengers -= int(a[0])
passengers += int(a[1])
if passengers > answ:
answ = passengers
n -= 1
print(answ)
| human | 0 | Python |
. No output, print or logging is allowed. But this is a problem from a very popular online competitive programming platform.
My code below:
https://leetcode.com/problems/difference-between-the-results-of-the-operations/discuss/287286/Recursive-C++-solutions-with-6-ms-%2B-1-kB
'''
A segregation (radix sort algorithm) ... | microsoft/Phi-3-small-8k-instruct | 1 | C++ |
w = input()
ans = True
for i in w:
cnt = 0
for j in w:
if i == j:
cnt += 1
if cnt % 2 != 0:
ans = False
break
if ans:
print('Yes')
else:
print('No')
| human | 0 | Python |
from functools import lru_cache
@lru_cache()
def pentabonacci(n):
return n if n in (0, 4) else 1 if n in (1, 2) else 2 if n == 3 else sum((pentabonacci(n - k) for k in range(1, 6)))
def count_odd_pentaFib(n):
return sum((1 for i in range(n + 1) if pentabonacci(i) % 2)) - (1 if n > 1 else 0)
| human | 0 | Python |
*) take input size, then input nums.
*) seperate into 3 list; nList, eList, and oList.
*) compare between head of eList and head of oList to find out what our target is (the even/odd part).
* return the smallest value between len(e) and len(o) in array format.
"""
n, e, o = (int(input()), [], [])
def q5(n, e, o):
... | 01-ai/Yi-Coder-9B | 1 | Python |
t = int(input())
from collections import deque
def solve():
n = int(input())
As = list(map(int, input().split()))
edges = [[] for i in range(n + 1)]
q = deque([])
for i in range(1, n + 1):
cnt = i * 2
while cnt <= n:
edges[i].append(cnt)
cnt += i
dp = [1] * (n + 1)
s = 1
for i in range(1, n + 1):
i... | human | 0 | Python |
def napolean(arr, n):
res = [0] * n
p = 0
for i in range(n):
v = n - i - 1
k = arr[v]
p = max(p, k)
if p >= 1:
res[v] = 1
p = p - 1
return res
t = int(input())
ans = []
for i in range(t):
p = int(input())
a = list(map(int, input().split()))
ans.append(napolean(a, p))
for l in ans:
print(*l)
| human | 0 | Python |
def sum_of_intervals(intervals):
(s, top) = (0, float('-inf'))
for (a, b) in sorted(intervals):
if top < a:
top = a
if top < b:
(s, top) = (s + b - top, b)
return s
| human | 0 | Python |
python
def is_prime(num):
"""Check if a number is prime."""
if num < 2:
return False
for i in range(2, int(num ** 0.5) + 1):
if num % i == 0:
return False
return True
def count_twin_primes(n, m):
"""Count pairs of twin primes (i, i+2) where both are primes."""
twin_c... | Qwen/Qwen2.5-Coder-1.5B | 1 | Python |
l.pop()
return l
def get_max(l):
return max(l)
def get_min(l):
return min(l)
def solve(l):
if len(l) == 1:
return l[0]
if len(l) == 2:
return get_min(l)
if len(l) == 3:
return get_min(l)
if len(l) == 4:
return get_min(l)
if le... | google/codegemma-2b | 1 | Python |
n = int(input())
if n < 1 or n > 10 ** 9:
raise SystemExit
c = n // 100
n -= c * 100
c += n // 20
d = n // 20
n -= d * 20
c += n // 10
d = n // 10
n -= d * 10
c += n // 5
d = n // 5
n -= d * 5
c += n // 1
print(c)
| human | 0 | Python |
from collections import Counter
def minSteps(s, t):
count_s = Counter(s)
count_t = Counter(t)
return sum(abs(count_s[key] - count_t[key]) for key in count_s | count_t) | Qwen/Qwen2.5-Coder-7B-Instruct | 1 | Python |
a = int(input())
d = str(a)
b = len(d)
e = 1
if a < 10:
print(1)
else:
if int(d[0]) == 1:
for i in range(b):
if int(d[i]) == 1:
e = e + pow(2, b - i - 1)
if int(d[i]) > 1:
e = e + pow(2, b - i) - 1
break
print(e - 1)
if int(d[0]) > 1:
f = pow(2, b)
print(f - 1)
| human | 0 | Python |
python
def find_minimum_time(n, m, tasks):
total_time = 0
current_house = 1
for i in range(1, m + 1):
clockwise_distance = (tasks[i - 1] - current_house + n) % n
counterclockwise_distance = (current_house - tasks[i - 1] + n) % n
if clockwise_distance < counterclockwise_... | microsoft/Phi-3-small-8k-instruct | 1 | Python |
w = list(map(int, input().split()))
w.sort(reverse=True)
a = 0
b = 0
for i in w:
if a == b:
if i == 100:
a += 1
else:
b += 1
elif a > b:
if i == 100:
a += 1
else:
b += 1
elif a < b:
if i == 200:
b += 1
... | ibm-granite/granite-8b-code-base-4k | 1 | Python |
python
def max_min_difference(t, n, k, a):
# Your code here
pass
# Input
t = 2
n1, k1 = 4, 1
a1 = [5, 5, 5, 5]
n2, k2 = 3, 2
a2 = [0, 0, 0]
# Print output
print(max_min_difference(t, (n1, k1), a1))
print(max_min_difference(t, (n2, k2), a2)) | microsoft/Phi-3-small-8k-instruct | 1 | Python |
n = input().split(' ')
n = list(map(int, n))
arr = input().split(' ')
arr = list(map(int, arr))
ans = 0
for i in range(0, len(arr)):
if i < n[1]:
flag = 1
for j in range(i - 1, -1, -1):
if arr[i] > arr[j]:
flag = -1
break
else:
flag = 1
for j in range(i - 1, i - n[1], -1):
if arr[i] > arr[j]:
... | human | 0 | Python |
def SplitIt(s, n):
if s.count(s[-1]) >= 2:
return 'YES'
return 'NO'
for _ in range(int(input())):
n = int(input())
s = input()
print(SplitIt(s, n))
| human | 0 | Python |
from datetime import timedelta, datetime
st = input()
et = input()
time_format = '%H:%M'
start = datetime.strptime(st, time_format)
end = datetime.strptime(et, time_format)
half_minute = (end - start).total_seconds() / 2
half = start + timedelta(seconds=half_minute)
print(half.strftime(time_format))
| human | 0 | Python |
input = sys.stdin.readline
def solve():
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# Count the frequency of each element in both permutations
freq_a = [0] * (n + 1)
freq_b = [0] * (n + 1)
for i in range(n):
freq_a[a[i]] += 1
fre... | Qwen/Qwen2.5-Coder-7B | 1 | Python |
production = True
import sys, math, collections
def input(input_format=0, multi=0):
if multi > 0:
return [input(input_format) for i in range(multi)]
else:
next_line = sys.stdin.readline()[:-1]
if input_format >= 10:
use_list = False
input_format = int(str(input_format)[-1])
else:
use_list = True
i... | human | 0 | Python |
TT = int(input())
while TT:
NN = int(input())
if NN <= 30:
print('NO')
else:
XX = NN - 30
print('YES')
if XX == 6 or XX == 10 or XX == 14:
print(6, 10, 15, XX - 1, end=' ')
else:
print(6, 10, 14, XX, end=' ')
TT -= 1
| human | 0 | Python |
n = int(input())
aline = input().split(' ')
bline = input().split(' ')
cline = input().split(' ')
a = [int(i) for i in aline]
b = [int(i) for i in bline]
c = [int(i) for i in cline]
def dicfunc(abc):
dic = dict()
for i in abc:
if i in dic.keys():
dic[i] += 1
else:
dic[i] = 1
return dic
(dica, dicb, dicc) ... | human | 0 | Python |
### Coding Technique..
1-> I have written all function then using **if else** where it get max value ( if it is true will display) then using recursion using **helping function** I've written code in this line.
2-> i've used help function to find out that for some number ( 1 for [news.Naruto] ) recusrions will g... | deepseek-ai/deepseek-coder-1.3b-base | 1 | Python |
. 5
import sys
min_operation_array_number = int(sys.stdin.readline().strip())
initial_array = sorted(sys.stdin.read().split(), reverse=(True))
i=0
number_ops_applied= [10**(24)*int(x.strip('>'))for x in initial_array[:-1]]
temp_no=int(re.findall("[~]$|(>.)+[^<]+[=>$-].*$<.+?>(=+|=>)",initial_array[len(initial_ar... | Qwen/Qwen2.5-Coder-1.5B | 1 | Python |
input = sys.stdin.readline
def solve(n, p):
if n == 1:
return 1
adj = [[] for _ in range(n+1)]
for i in range(n):
for j in range(i+1, n):
if p[i] > p[j]:
adj[p[i]].append(p[j])
adj[p[j]].append(p[i])
visited = [False] * (n+1)
ans = 0
... | 01-ai/Yi-Coder-9B | 1 | Python |
python
import math
def min_buses(N, C, K, T):
T.sort()
buses = 1
prev_time = T[0]
prev_cap = C
for t in T[1:]:
if t > prev_time + K:
buses += 1
prev_time = t
prev_cap = C
elif prev_cap == 0:
buses += 1
prev_time = t
... | codellama/CodeLlama-34b-Instruct-hf | 1 | Python |
w, m, k = map(int, raw_input().split())
ans = 0
while log10(w) + log10(k) >= log10(m):
w -= m * k
m += 1
ans += 1
print ans<|endoftext|># Link: https://codeforces.com/problemset/problem/1178/C
s = input()
n = len(s)
is_valid = True
i = 0
while is_valid:
if i + 2 < n:
if s[i] == '1' and s[i+1] ... | 01-ai/Yi-Coder-9B | 1 | Python |
python
def print_words(sentence, i=0, words=None):
if words is None:
words = []
word = ''
while i < len(sentence):
if sentence[i] == ' ':
words.append(word)
break
elif sentence[i] != ' ':
word += sentence[i]
i += 1
if i < len(sentence... | 01-ai/Yi-Coder-1.5B-Chat | 1 | Python |
need to be integer (month) and float (money).
Try to write a function that takes care of negative and decimal numbers.
In this kata we consider that the money in the bank is an integer.
The money has to the nearest integer: use method `round()`, or equivalent operations.
## Solution:
```python
def nbMonths(start_price_... | deepseek-ai/deepseek-coder-6.7b-instruct | 1 | Python |
class Solution:
def successfulPairs(self, spells: List[int], potions: List[int], success: int) -> List[int]:
potions.sort()
n = len(potions)
ans = []
for x in spells:
left = 0
right = n-1
pos = -1
while(left <= right):... | human | 0 | Python |
class Solution:
def __init__(self):
self.count = []
def coinChange(self, coins: List[int], amount: int) -> int:
if len(self.count) < amount:
self.count = [-1] * (amount + 1)
self.skip = [False] * (amount + 1)
if amount is 0:
return 0
elif amount < 0:
return -1
else:
if self.count[amount] < ... | human | 0 | Python |
def combinationSum(self, arr, target):
#code here
arr=list(set(arr))
arr.sort()
res=[]
self.findsum(0,arr,target,res,[])
return res
def findsum(self,ind,arr,target,res,r):
if ind==len(arr):
if target==0:
res.append(r.copy())
... | 01-ai/Yi-Coder-9B | 1 | Python |
ob = []
clue = []
n = int(input())
sum_x = 0
sum_y = 0
for i in range(n):
(x, y) = list(map(int, input().strip().split()))
sum_x += x
sum_y += y
for i in range(n):
(x, y) = list(map(int, input().strip().split()))
sum_x += x
sum_y += y
print(sum_x // n, sum_y // n)
| human | 0 | Python |
q = int(input())
for i in range(q):
n = int(input())
arr = []
for j in range(n * 2):
temp = [int(x) for x in input().split()]
arr.append(temp)
s = 0
for j in range(n):
for k in range(n):
index = 2 * n - 1 - j
temp = max(arr[j][k], arr[j][-k - 1], arr[index][k], arr[index][-k - 1])
s += temp
print(s... | human | 0 | Python |
python
def determine_winner(n, rounds):
mishka_wins = 0
chris_wins = 0
for m, c in rounds:
if m > c:
mishka_wins += 1
elif c > m:
chris_wins += 1
if mishka_wins > chris_wins:
return "Mishka"
elif chris_wins > mishka_wins:
return "Chris"
els... | Qwen/Qwen2.5-Coder-7B-Instruct | 1 | Python |
import sys
input = sys.stdin.readline
from collections import defaultdict
def check(s, k, n):
c = 0
d = 0
for i in range(k):
if s[i] == '?':
d += 1
else:
c += s[i]
if d % 2 != abs(c) % 2 or d < abs(c):
return False
for i in range(k, n):
if s[i] == '?':
d += 1
else:
c += s[i]
if s[i - k] ==... | human | 0 | Python |
t = int(input())
for _ in range(t):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
tmp = min(a[2], b[1])
ans += tmp * 2
a[2] -= tmp
b[1] -= tmp
for i in range(2, -1, -1):
if i == 0:
for j in range(2, -1, -1):
tmp = min(a[i], b[j])
a[i] -= tmp
b[j] -= tmp
cont... | human | 0 | Python |
class Solution:
def getSpecialNumber(self, n):
digits = []
n -= 1
while n:
digits.append(n % 6)
n //= 6
ans = 0
for d in reversed(digits):
ans = ans * 10 + d
return ans
| human | 0 | Python |
, no explanation.
def wow_factor(s):
count = 0
for i in range(len(s)):
if s[i] == 'v':
count += s[i:].count('vv')
return count
if __name__ == '__main__':
s = input()
print(wow_factor(s)) | microsoft/Phi-3-mini-4k-instruct | 1 | Python |
To solve this problem, you are tasked with either finding an independent set with at least \(\lceil\frac{k}{2}\rceil\) vertices or finding a simple cycle of length at most \(k\) in a given connected undirected graph. This problem is based on a classic result in graph theory related to finding either a small independent... | microsoft/Phi-3-medium-4k-instruct | 1 | Python |
(n, m) = [int(tt) for tt in input().split()]
arr = [int(tt) for tt in input().split()]
ans = 1
for i in range(n - 1):
if arr[i + 1] - arr[i] > m:
ans = 1
else:
ans = ans + 1
print(ans)
| human | 0 | Python |
java
public class Solution {
private int res = Integer.MAX_VALUE;
private int[] buckets;
public int minSessions(int[] tasks, int sessionTime) {
int n = tasks.length;
buckets = new int[n];
// sort in reverse order
Integer[] task_i = new Integer[n];
for (int i = 0; i <... | 01-ai/Yi-Coder-9B-Chat | 1 | Java |
sys.setrecursionlimit(2147483648)
class (object):
def read_input(self):
C = map(int, raw_input().split())
return C
def solve (self, C, a, b):
N = C[0]
a, b = C[1], C[2]
if a == b :
print('Final!')
return
if N == 2 and (a != 1 or b != 1):
... | bigcode/starcoder2-3b | 1 | Python |
compiles successfully if you are using the "Universal侄 return "in your submission.
"""
import bisect
from collections import defaultdict
from typing import List
# Accepted but slow, needs improvement
def closet_targets(arr: List[str], target_word: str, start_index: int):
# this shouldn't happen
if not arr:
... | 01-ai/Yi-Coder-1.5B | 1 | Python |
t = int(input())
def primefactors(n: int) -> int:
i = 2
f = 0
while i * i < n:
if n % i == 0:
f += 1
while n % i == 0:
n = n // i
i += 1
if n != 1:
f += 1
return f
for _ in range(t):
(n, m) = [int(x) for x in input().split()]
max_cols = primefactors(m)
if max_cols == 0:
print(0)
continue
for... | human | 0 | Python |
import sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = 'x' in file.mode or 'r' not in file.mode
self.write = self.buffer.wr... | human | 0 | Python |
s = str(input())
ans = 0
for i in range(len(s)):
for j in range(i + 1, len(s)):
if s[i] == s[j]:
s = s[:i] + s[j + 1:]
ans += 1
break
print(ans) | meta-llama/Llama-3.2-3B | 1 | Python |
for $2$
'''
class PandemoniumPoint(unittest.TestCase):
def expected(self, arr):
pro=math.prod(arr)
return 1 if pro==0 else max(1, (pro // max(pro,sum(arr)))-2)
def actual(self, arr):
res = 0
while sum(arr) != 0 or math.prod(arr) != 0:
res += 1
for x i... | deepseek-ai/deepseek-coder-1.3b-base | 1 | Python |
# ---------------------------------------- fast io ----------------------------------------
import os, sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | human | 0 | Python |
t = int(input())
for _ in range(t):
(x, m) = map(int, input().split())
h = 0
prev = 1
c = 0
while h < x and m > 0:
h += prev
prev = h
m -= 1
if h >= x:
h = 0
c += 1
print(c + m)
| human | 0 | Python |
l = int(input())
m = int(input())
n = int(input())
d = int(input())
k = d // k
l = d // l
m = d // m
n = d // n
print(k + l + m + n)
# Проверка на наличие драгонов
# Управляем простое ввод данных
print("Введите количество драгонов")
k = int(input())
l = int(input())
m = int(input())
n = int(input())
d = int(input(... | microsoft/phi-2 | 1 | Python |
def is_black_and_white(n, m, photo):
for row in photo:
if any(pixel in row for pixel in ['C', 'M', 'Y']):
return "#Color"
return "#Black&White"
n, m = map(int, input().split())
photo = [input().split() for _ in range(n)]
print(is_black_and_white(n, m, photo)) | codellama/CodeLlama-70b-Instruct-hf | 1 | Python |
-----Sample Input-----
4
4
LRUD
4
LURD
5
RRUDU
5
LLDDR
------Sample Output-----
1 2
1 4
3 4
-1
Complete detailed textbook-level python code solutions
def optimize_robot_path(n, path):
# The function to optimize the robot path
# Check if there are more right movements than left to infer a 'right turn'
... | microsoft/Phi-3.5-mini-instruct | 1 | Python |
class Solution:
def printFibb(self, n):
lst = []
i = 0
j = 1
if n >= 1:
lst.append(1)
while n > 1:
temp = i + j
lst.append(temp)
i = j
j = temp
n -= 1
return lst
| human | 0 | Python |
c = int(input())
groups = [None] * 5
d = sorted(map(int, input().split()), reverse=True)
t = 0
for i in range(5):
groups[i] = d.count(i)
t += groups[4] + groups[3] + groups[2] // 2 + groups[2] % 2
groups[1] -= groups[3] + groups[2] % 2 * 2
if groups[1] > 0:
t += groups[1] // 4
if groups[1] % 4 > 0:
t += 1
print(t)... | human | 0 | Python |
def sum_array(arr):
if arr == None or arr == []:
return 0
mi = min(arr)
ma = max(arr)
st = (arr.count(mi) - 1) * mi + (arr.count(ma) - 1) * ma
for i in arr:
if i not in [mi, ma]:
st += i
return st
| human | 0 | Python |
input()
s1 = set(input().split())
input()
s2 = set(input().split())
print(len(s1 & s2))
| human | 0 | Python |
.
class Solution:
def invalidTransactions(self, transactions: List[str]) -> List[str]:
# Your code here
## answer
import java.util.*;
public class Solution {
public List<String> invalidTransactions(String[] transactions) {
List<String> invalidTransactions = new ArrayList<>();
Map<St... | microsoft/Phi-3-medium-4k-instruct | 1 | Java |
(n, k) = map(int, input().split())
d = [i % k for i in map(int, input().split())]
from collections import Counter
c = Counter(d)
ans = 0
for i in [*c.keys()]:
for j in [*c.keys()]:
if i + j in [0, k]:
if i == j:
ans += c[i] // 2
c[i] = 0
else:
ans += min(c[i], c[j])
c[i] = c[j] = 0
print(ans * ... | human | 0 | Python |
// Don't Code Unless You are 100% sure it is correct.
// Find the best way to solve that particular problem.
#include <bits/stdc++.h>
#ifndef LOCAL
#define dbg(x...)
#endif
#define endl '\n'
#define int long long
using namespace std;
void solve() {
string s;
cin >> s;
int n = s.size();
vector<int> v(26)... | human | 0 | C++ |
def max_mean_subsegment(n, a):
max_mean = float('-inf')
max_length = 0
for l in range(n):
total = 0
for r in range(l, n):
total += a[r]
mean = total / (r - l + 1)
if mean > max_mean:
max_mean = mean
max_length = r - l + 1
... | meta-llama/Llama-3.3-70B-Instruct | 1 | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.