code
string
generator
string
label
int64
language
string
python MOD = 10**9 + 7 def count_abc_numbers(s): # Count the number of '?' in the string count_question_marks = s.count('?') # Calculate the number of possible strings total_strings = 3**count_question_marks # Count occurrences of A, B, C in positions where question marks can be a_cou...
microsoft/Phi-3.5-mini-instruct
1
Python
#include<bits/stdc++.h> #define ll long long #define fr(i,a,b) for(int i = a ; i < b ; i++) #define read(x) int x ; cin>>x #define yy cout<<"YES"<<endl; #define nn cout<<"NO"<<endl; using namespace std; void init_code(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.t...
human
0
C++
def solve(): import sys import heapq input = sys.stdin.read().split() index = 0 t = int(input[index]) index += 1 results = [] for _ in range(t): n = int(input[index]) k = int(input[index + 1]) index += 2 a = list(map(int, input[index:index + n])) ...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
if you are able to construct the BST. Solution: from typing import List class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right def constructTree(postorder: List[int]) -> TreeNode: def helper(postorder, start, end): ...
Qwen/Qwen2.5-Coder-1.5B
1
Python
n = int(input()) s1 = 'I hate that ' s2 = 'I love that ' s11 = 'I hate it' s22 = 'I love it' s = '' for i in range(n - 1): if i % 2 == 0: s += s1 else: s += s2 if n % 2 == 1: s += s11 else: s += s22 print(s)
human
0
Python
from math import ceil m = int(input()) a = [int(s) for s in input().split()] sum = 0 for i in range(m): sum += a[i] q = sum // m a.sort() ans = 0 for i in range(m - (sum - q * m)): ans += abs(a[i] - q) for i in range(m - (sum - q * m), m): ans += abs(a[i] - q - 1) print(ans // 2)
human
0
Python
n = int(input()) hm = [] gems = ['Power', 'Time', 'Space', 'Soul', 'Reality', 'Mind'] for i in range(n): s = input() if s == 'purple': hm += ['Power'] elif s == 'green': hm += ['Time'] elif s == 'blue': hm += ['Space'] elif s == 'orange': hm += ['Soul'] elif s == 'red': hm += ['Reality'] elif s == 'yel...
human
0
Python
for _ in range(int(input())): n = int(input()) data = [int(x) for x in input().split()] ans = [data[0]] for q in range(1, n - 1): if data[q] > data[q - 1] and data[q] > data[q + 1] or (data[q] < data[q - 1] and data[q] < data[q + 1]): ans.append(data[q]) ans.append(data[-1]) print(len(ans)) for q in ans: ...
human
0
Python
for input ------ n, m = 3, 5 a = [1, 2, 3] Find a non-empty subsequence that sums to a multiple of 5. Output: "YES" ------ n, m = 1, 6 a = [5] Find a non-empty subsequence that sums to a multiple of 6. Output: "NO" ------ n, m = 4, 6 a = [3, 1, 1, 3] Find a non-empty subsequence that sums to a multiple of 6. Outp...
deepseek-ai/deepseek-coder-6.7b-instruct
1
Python
class Solution: def validateBinaryTreeNodes(self, n: int, leftChild: List[int], rightChild: List[int]) -> bool: parent_found = [False] * n for i in range(n): if leftChild[i] != -1: if parent_found[leftChild[i]]: return False else: ...
human
0
Python
Note In the first test case, the process is as follows: - res = 0, cur = 0, ok = true. - s[1] = '-', res = res + 1, cur = cur - 1. cur < 0, ok = false. - s[2] = '-', res = res + 1, cur = cur - 1. cur < 0, ok = false. - ok = false. So, the result is 7. In the second test case, the process is as follows: - res = 0, cu...
01-ai/Yi-Coder-1.5B-Chat
1
Java
R = lambda : [int(x) for x in input().split()] nb_cases = int(input()) a = [0, 0] b = [0, 0] for _ in range(nb_cases): (server, worked, failed) = R() if server == 1: a[0] += worked a[1] += failed else: b[0] += worked b[1] += failed print('LIVE' if a[0] >= a[1] else 'DEAD') print('LIVE' if b[0] >= b[1] else '...
human
0
Python
need check how could result will display. This version of check allows calculate first square for number b as described below - For each divisior d (between 1-1e10), calculate sum of squares $f(t=d), b/d > t$ - that we convert with binary number search of sum of t that less/biger than middle and to the right d that m...
deepseek-ai/deepseek-coder-6.7b-instruct
1
Python
, no extra formatting. def profit(n, m, l, s, c): cost = [0] * (m + 1) profit = [0] * (m + 1) for i in range(n): cost[l[i]] += s[i] profit[l[i]] += c[l[i]] profit_dict = {} current_profit = 0 for i in range(1, m + 1): if i in profit_dict: current_profit -= ...
microsoft/Phi-3.5-mini-instruct
1
C++
num = input() n = int(num) l = list() for i in range(n): str1 = input() nums = str1.split() tot = 0 for i in nums: if i.isnumeric: tot = int(tot) + int(i) l.append(tot) count = 0 for j in l: if int(j) > 1: count = count + 1 print(count)
human
0
Python
python import sys file_id = int(input()) def get_score(file_id): file = open("future_input/" + str(file_id) + ".in", "r") scores = file.readlines() try: return float(scores[-2]) except ValueError: try: return float(scores[-3]) except ValueError: return 0...
meta-llama/Llama-3.1-8B-Instruct
1
Python
/ask2018/2/tests/gencmp.c /* To use it: 1. Set the value of N 2. g++ gencmp.c -o gencmp 3. ./gencmp > input 4. Upload input as stdin */ #include <bits/stdc++.h> using namespace std; #define N 3 int main() { ios_base::sync_with_stdio(false); cin.tie(0); mt19937 rng(chrono::steady_clock::now().time_since_epoc...
bigcode/starcoder2-3b
1
Python
cities = list(map(int, input().split())) dp = [0] * (5 * 10**5 + 1) for city in cities: dp[city] = max(dp[city], dp[city - 1] + city) print(dp[max(cities)])
Qwen/Qwen2.5-Coder-7B
1
Python
n=int(input()) array=[int(x) for x in input().split()] dp=[1]*n maxval=max(array) for x in array: if x==maxval: dp[(array.index(x))]=-1 for i in range(1,n): dp[i]+=dp[i-1] print(dp[i])
meta-llama/Llama-3.2-3B
1
Python
n = int(input()) li = list(map(int, input().split(' '))) print(max(li))
human
0
Python
from sys import stdin input = stdin.readline #// - remember to add .strip() when input is a string t = int(input()) for _ in range(t): n, m = map(int,input().split()) grid = [] for i in range(n): row = list(map(int,input().split())) grid.append(row) new = [] for i in range(l...
human
0
Python
def solve(n): digits = [int(d) for d in str(n)] length = len(digits) result = [] for i in range(length): if digits[i] != 0: result.append(digits[i] * (10 ** (length - i - 1))) return len(result), result def main(): import sys input = sys.stdin.read data = i...
codellama/CodeLlama-70b-Instruct-hf
1
Python
def isPossible(self,N, arr): def Solution(self,Arr,N): # First of all find sum of # all array elements sm = 0 for i in range(N): sm += Arr[i] # Return true if sum is divisible by 3 if (sm % 3 == 0): return 1 # Return false if sum is not # divi...
deepseek-ai/deepseek-coder-6.7b-base
1
Python
def is_letter_x(n, paper): # Check the first character on the first diagonal diag_char = paper[0][0] # Check the first character on the second diagonal anti_diag_char = paper[0][n-1] # Ensure the two diagonal characters are different if diag_char == anti_diag_char: return "NO" #...
microsoft/Phi-3-medium-4k-instruct
1
Python
k = 0 j = 0 imp = 0 pair = 0 x = int(input()) l = list(map(int, input().split())) for x in l: if x % 2 == 0: k += 1 imp = l.index(x) + 1 else: j += 1 pair = l.index(x) + 1 if k > j: print(pair) else: print(imp)
human
0
Python
for the problem. """ def solve(): q = int(input()) for _ in range(q): n = int(input()) boards = [list(map(int, input().split())) for _ in range(n)] boards.sort(key=lambda x: (x[0], -x[1])) ans, prev_h, prev_c = 0, 0, 0 for h, c in boards: if h > prev_h: ...
01-ai/Yi-Coder-9B-Chat
1
Python
. - response: def max_bishop_attack(n, m, grid): max_sum = -1 for i in range(n): for j in range(m): attack_sum = 0 # Check diagonals for valid bishop placement and calculate sum for dx, dy in [(-1, -1), (-1, 1), (1, -1), (1, 1)]: x, y = i + dx, j +...
microsoft/Phi-3-medium-4k-instruct
1
Python
: Return 0 in all test cases, if your solution is correct. ''' import math import os import random import re import sys # Complete the minDist function below. def minDist(A, x, y): if x not in A or y not in A: return -1 n = len(A) start,finish = 0,0 mindist = float('inf') for i in range(n...
ibm-granite/granite-8b-code-instruct-4k
1
Python
python for _ in range(int(input())): n = int(input()) weights = list(map(int, input().split())) freq = {} for w in weights: if w in freq: freq[w] += 1 else: freq[w] = 1 done = False best_result = 0 for s in range(n+1): pairs_count = 0 ...
meta-llama/Llama-3.1-8B-Instruct
1
Python
python def calc_product_days(m, d): product_days = 0 for month in range(1, m + 1): for day in range(1, d + 1): if day >= 2 and day // 10 >= 2 and day % 10 >= 2 and day // 10 * day % 10 == month: product_days += 1 return product_days m, d = map(int, input().split()) print...
01-ai/Yi-Coder-1.5B-Chat
1
Python
desc = input() desc_list = desc.split(" ") rank, suit = n chain = 0 for card in desc_list: if card[0] == rank or card[1] == suit: chain += 1 if chain: print('YES') else: print('NO')
ibm-granite/granite-8b-code-base-4k
1
Python
import math t = int(input()) for _ in range(t): n = int(input()) l = list(input()) c = 0 while c < n and l[c] == '1': c += 1 print(c)
human
0
Python
from collections import Counter k = int(input()) s = input() def k_string(k, s): c = Counter(s).most_common() for (i, q) in c: if q % k != 0: return '-1' snew = '' for (i, q) in c: snew += i * (q // k) return snew * k print(k_string(k, s))
human
0
Python
import math import random import time import csv import numpy as np import pandas as pd from itertools import zip_longest import io # import cProfile def setIO(IO="stdio"): if IO == "filein": global input input = lambda : f_in.readline().rstrip() elif IO == "fileout": out = io.BytesIO()...
Qwen/Qwen2.5-Coder-7B
1
Python
mod = 10 ** 9 + 7 (n, X) = map(int, input().split()) s = [int(x) for x in input().split()] s = sorted(s, reverse=True) dp = [[0 for _ in range(X + 1)] for _ in range(n)] dp[-1][X] = 1 for i in range(n): for x in range(X + 1): dp[i][x % s[i]] += dp[i - 1][x] dp[i][x % s[i]] %= mod dp[i][x] += dp[i - 1][x] * (n - ...
human
0
Python
python def find_array(n, a): b = [0] * n mex = 0 for i in range(n): while mex in set(b[:i]): mex += 1 b[i] = mex return b if all(b[i] == a[i] for i in range(n)) else -1 n = int(input()) a = list(map(int, input().split())) print(find_array(n, a))
Qwen/Qwen2.5-Coder-1.5B
1
Python
for i in range(int(input())): (n, k) = map(int, input().split()) print(k.bit_length() + (n - 2 ** k.bit_length() - 1) // k + 1)
human
0
Python
public class JavadocCommentAndVariableNames{     /** * An example class with example variable and method       for java */     // an example variable     char x ;     //An implementation to return the smallest array     /**      * An abstract example  java class with   an interface abstract method * method i...
meta-llama/Llama-3.1-8B
1
Java
def decentNumber(n): # Initialize variables to store counts of 5's and 3's count_of_5 = 0 count_of_3 = 0 # Try to find the maximum number of 5's that satisfy the conditions while n > 0: if n % 3 == 0: count_of_5 = n break n -= 5 # Calculate the n...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
from math import floor, log2 dp = [0] * 100 def precompute(): dp[1] = 1 for i in range(2, 100): dp[i] = (dp[i - 1] << 1) + i def get_val(i): return dp[i] + i + 1 def main(): n = int(input()) ans = 0 for i in range(0, floor(log2(n)) + 1): if n & 1 << i: ans = ans + get_val(i) print(ans) precompute() tt ...
human
0
Python
for testcase in range(test): n = int(input()) s = input() cache = {(): 0} def solve(s): if not s in cache: cache[s] = min(len(s), solve(s[1:])) + min(len(s), solve(s[:-1])) return cache[s] print(solve(s))
bigcode/starcoder
1
Python
def restore_permutation(t, test_cases): results = [] for n, a in test_cases: i, j = 0, n p = [] used = [0] * (n + 1) while len(p) < n: if a[i] == a[j] and used[a[i]] < 2: p.append(a[i]) used[a[i]] += 2 i += 1 ...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
from __future__ import division, print_function import math import os import sys from fractions import * from sys import * from decimal import * from io import BytesIO, IOBase from itertools import * from collections import * M = 10 ** 9 + 7 if sys.version_info[0] < 3: from __builtin__ import xrange as range from fut...
human
0
Python
import os import sys from io import BytesIO, IOBase import threading from bisect import bisect_right from math import gcd, log from collections import Counter, defaultdict, deque from pprint import pprint from itertools import permutations from bisect import bisect_right from random import randint as rti def main(tnum...
human
0
Python
t = int(input()) for i in range(t): s = input() if len(s) <= 10: print(s) else: count = 0 word = s[0] for j in range(1, len(s) - 1): count += 1 word = word + str(count) + s[len(s) - 1] print(word)
human
0
Python
def safemesh(i,j,k,prev): if i==N: return 0 if dp[i][j][k][prev]!=-1: return dp[i][j][k][prev] maks=-99999999 curr = meshes[i][j] l = meshes[i] nex = 999999 possible_floor = j if k>0: nex = meshes[i][j-1] for floornum in range(possible_floor+1): val= 0...
01-ai/Yi-Coder-9B
1
Python
for t in range(t): n = int(input()) a=list(range(1,n+1)) if(n%2==1): a=a+[n+1]//2+a[:-1] print(*a) else: a=a+[n+1]//2+a[:-2] print(*a); Function Attrs: nounwind declare ptr @seq_stdout() local_unnamed_addr #0 ; Function Attrs: inaccessiblememonly nounwind declare noalias ...
bigcode/starcoder2-7b
1
Python
S = input() c = 0 for i in range(len(S) // 2): if S[i] == 'A' and S[len(S) - 1 - i] == 'A' or (S[i] == 'b' and S[len(S) - i - 1] == 'd') or (S[i] == 'H' and S[len(S) - i - 1] == 'H') or (S[i] == 'I' and S[len(S) - i - 1] == 'I') or (S[i] == 'd' and S[len(S) - i - 1] == 'b') or (S[i] == 'M' and S[len(S) - i - 1] == 'M'...
human
0
Python
To solve this problem, we need to find a permutation of integers from 1 to N such that the sum of the averages of all consecutive triplets is minimized. The key observation here is that to minimize the sum of averages, we should aim to minimize the sum of the triplets themselves. ### Key Insight: For a given triplet \...
microsoft/Phi-3-medium-4k-instruct
1
Python
t = int(input()) for zzz in range(t): count = 0 stairCount = 0 maxi = int(input()) i = 1 while True: if count + i * (i + 1) // 2 <= maxi: count = count + i * (i + 1) // 2 stairCount += 1 i = 2 * i + 1 else: break print(stairCount)
human
0
Python
t = int(input()) while t: n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] if max(a) == max(b): print('NO') else: print('YES') t -= 1
human
0
Python
python def count_patties(N, X): total_layers = N * (1 + N) if X > total_layers: return -1 start_pos = (X - 1) * 2 - (N - 1) patties = 0 current_layer = N while start_pos > 0 and patties < X: if start_pos > current_layer: patties += current_layer cu...
microsoft/Phi-3.5-mini-instruct
1
Python
l = [] for i in range(4): b = input() l.append(b) for i in range(4): for j in range(3): if i == 0: if l[i][j] == '#' and l[i][j + 1] == '#' or (l[i][j] == '.' and l[i][j + 1] == '.'): if l[i][j] == l[i + 1][j] and l[i][j + 1] == l[i + 1][j + 1]: print('YES') exit() if l[i + 1][j] == '#' and l[...
human
0
Python
python def facDigits(N): if N < 0: return 0 if N <= 1: return 1 # using the mathematical relation between factorial and number of digits # log(a*b) = log(a) + log(b) log_sum = 0 for i in range(2, N+1): log_sum += math.log10(i) return math.floor(log_sum) + 1
01-ai/Yi-Coder-9B-Chat
1
Python
returns 1 if N is prime else returns 0. */ typedef std::vector<int> IntVector; using namespace std; // Sieve of Eratosthenes void printAllPrimes(int N) { BitArray<uint64_t> b(N - 1, 1); b[0] = 0; // must mark 0 and 1 as not prime for (auto i = 2; i * i <= N; ++i) { if (b[i - 1]) { ...
deepseek-ai/deepseek-coder-1.3b-base
1
Python
python def solve(n, m, k): if m < 1 or k < 1: return "No" if n <= m and n <= k: return "Yes" return "No"
01-ai/Yi-Coder-1.5B-Chat
1
Python
#!/usr/bin/python n = int(raw_input()) candidates = [] for i in range(n): candidates += map(int, raw_input().split()) candidates.sort(reverse=True) max_val = candidates[0] max_k = sum(((max_val - i) % 2600) / 2600 ) for i in range(1, len(candidates)): val = candidates[i] k = sum(((max_val - val) % 2600) /...
microsoft/phi-2
1
Python
import sys reader = (line.rstrip() for line in sys.stdin) input = reader.__next__ def getInts(): return [int(s) for s in input().split()] def getInt(): return int(input()) def getStrs(): return [s for s in input().split()] def getStr(): return input() def listStr(): return list(input()) M = 10 ** 9 + 7 def s...
human
0
Python
You are given several queries. In the i-th query you are given a single positive integer n_{i}. You are to represent n_{i} as a sum of maximum possible number of composite summands and print this maximum number, or print -1, if there are no such splittings. An integer greater than 1 is composite, if it is not prime, i...
deepseek-ai/deepseek-coder-6.7b-base
1
Python
if testes == 1: from itertools import combinations t = int(input()) for _ in range(t): print(s[0]) return if testes == 2: try: import string except: input='' isalpha0 = ''.join(c for c in string.ascii_lowercase if c not in string.punctuation) if not input: return VOLLOW = [] for lines in input.split('\...
meta-llama/Llama-3.2-3B
1
Python
from re import * T = int(input()) for _ in range(T): U = input().strip() LengthAlphaN10U = bool(search('^[a-zA-Z0-9]{10}$', U)) Ucase2U = bool(search('([A-Z].*){2}', U)) Digits3U = bool(search('([0-9].*){3}', U)) NoRepeatU = not bool(search('(.).*\\1', U)) print('Valid' if LengthAlphaN10U and Ucase2U and Digits3U...
human
0
Python
def can_sort_with_one_swap(N, p): sorted_p = sorted(p) mismatch_indices = [i for i in range(N) if p[i] != sorted_p[i]] if len(mismatch_indices) == 0: return "YES" if len(mismatch_indices) == 2 and p[mismatch_indices[0]] == sorted_p[mismatch_indices[1]] and p[mismatch_indices[1]] == sorted_p[mism...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
Count the number of returnable rooms in the given snake exhibition. -----Note----- In the first test case, all rooms are returnable except room $2$. The snake in the room $2$ is trapped and cannot exit. This test case corresponds to the picture from the problem statement. In the second test case, all rooms are retu...
Qwen/Qwen2.5-Coder-7B-Instruct
1
Python
text = input().split() dic = dict(zip(text, [0 for i in range(len(text))])) for i in text: dic[i] = dic[i] + 1 max_ = max(dic.values()) for (key, value) in dic.items(): if value == max_: most = key max_ = 0 for i in dic.keys(): if len(i) > max_: max_ = len(i) amax_ = i print(most, amax_)
human
0
Python
python def abbreviate(word): if len(word) <= 10: return word else: return word[0] + str(len(word) - 2) + word[-1] n = int(input()) for i in range(n): word = input() print(abbreviate(word))
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
def reverseWords(self, S): return "".join(reversed(S.split("."))) # Testcase 1: testcase1 = "i.like.this.program.very.much" testcase_ref = "".join(reversed(testcase1.split("."))) assert (testcase1 == Solution().reverseWords(testcase1)),testdata1: 1 testcase2 = "pqr.mno" testcase_ref = "".join(reversed(testc...
meta-llama/Llama-3.2-3B
1
Python
t = int(input()) while t: t -= 1 (a, b) = input().split() a = int(a) b = int(b) total = 0 odd_c = 0 if b ** 2 > a: print('NO') elif a % 2 == 0 and b % 2 == 0 or (a % 2 != 0 and b % 2 != 0): print('YES') else: print('NO')
human
0
Python
from collections import defaultdict def count_pairs(n, heights): count = 0 height_sum_counts = defaultdict(int) for i, height in enumerate(heights, start=1): diff = i - height if diff > 0: count += height_sum_counts[diff] height_sum_counts[i + height] += 1 ...
codellama/CodeLlama-70b-Instruct-hf
1
Python
if num % 4 == 0 or num % 7 == 0:         return True     while num > 0:         if num % 10 != 4 and num % 10 != 7:             return False         num //= 10     return True def solve(n):     divs = 0     for i in range(1, n + 1):         if n % i == 0:             if is_overlucky(i):                 divs += 1     re...
bigcode/starcoder2-7b
1
Python
def min_blows_to_defeat_zmei(t, queries): results = [] for _ in range(t): n, x = queries[_][0] blows = queries[_][1] # Find the maximum net decrease in heads per blow max_net_decrease = max([min(d, x) - h for d, h in blows]) # If the best move results in...
codellama/CodeLlama-70b-Instruct-hf
1
Python
# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py import os import sys import threading from io import BytesIO, IOBase import math from heapq import heappop, heappush, heapify, heapreplace from collections import defaultdict, deque, OrderedDict, Counter from bisect import...
human
0
Python
def find_height(self, tree, n, k): # This is complete function tree.sort(reverse=True) low=0 high=tree[0] ans=0 while(low<=high): mid=(low+high)//2 sum1=0 for i in range(n): if(tree[i]>=mid): sum1+=tr...
01-ai/Yi-Coder-9B
1
Python
n = int(input()) a = list(map(int, input().split())) s = 0 for i in a: s += i s = s / 2 a = sorted(a) ss = 0 dem = 0 for i in a: if ss + i < s: ss += i dem += 1 print(n - dem)
human
0
Python
if it has no errors. # Sample Output 13 import math # Complete the solution to find the number in the n-th position of the sequence. def find_number_in_pos(n): # This is the main function that calculates the nth element in the sequence. # # Approach: # We can observe that every turn, 1 is added to ...
microsoft/Phi-3-mini-4k-instruct
1
Python
s = input() res = set() for i in range(len(s)): res.add(s[-i if i else len(s):] + s[:len(s) - i]) print(len(res))
human
0
Python
check = input() d = 'Danil' o = 'Olya' s = 'Slava' a = 'Ann' n = 'Nikita' friends = [d, o, s, a, n] unique_friends = 0 for friend in friends: test = check.count(friend) unique_friends += test if unique_friends == 1: print('YES') else: print('NO')
human
0
Python
n = int(input()) s = input() max = 0 maxs = '' for i in range(n - 1): c = s[i] + s[i + 1] count = 1 for j in range(i + 1, n - 1): if s[j] + s[j + 1] == c: count += 1 if max < count: max = count maxs = c print(maxs)
human
0
Python
print("Here's a short print of a 4x4 with 3 different colors") print("Y for yellow Domino, b for blue, and c for black. Also looks like it's a 3x4, it's off by 1. but enjoy") print(27 * "Y") print("b" + "b" + "b"+"c" + "b"+"c" + "c" + "d" + "d") print("Y" + "Y" + "b" + "Y" + "Y") print(q* "Y") Alternate ways I've figu...
meta-llama/Llama-3.2-3B
1
Python
from sys import stdin def main(): inp = stdin nums = sum(list(map(int, inp.readline().split()))) if nums % 5 == 0 and nums != 0: print(nums // 5) else: print(-1) main()
human
0
Python
for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) start = 'a' alpha = [] for i in range(26): alpha.append(start) start = chr(ord(start) + 1) alphar = alpha.copy() alphar.reverse() d = dict(zip(alpha, alphar)) m = max(a) if m == 0: ans = ['a'] index = 0 for i in range...
human
0
Python
def extended_euclidean(a, b): if a == 0: return b, 0, 1 else: gcd, x, y = extended_euclidean(b % a, a) return gcd, y - (b // a) * x, x def find_point(a, b, c): gcd, x, y = extended_euclidean(a, b) if c % gcd!= 0: return None x *= -c // gcd y *= -c // gcd retu...
meta-llama/Llama-3.3-70B-Instruct
1
Python
lis = input() c = 0 g1 = 0 g2 = 0 for i in lis: if i == 'G': c += 1 else: c = 0 g1 = max(g1, c) lis = lis[::-1] c = 0 for i in lis: if i == 'G': c += 1 else: c = 0 g2 = max(g2, c) g = max(g1,g2) print(g1+ g2 - max(g1,g2))
bigcode/starcoder2-15b
1
Python
i.e. the code without any comment and detailed explanation # Input from stdin import sys input = sys.stdin.readline # To store values n, weights = 0, [] # Taking input for number of test cases t = int(input()) max_possible_final_score = 0 for _ in range(t): # Taking input for number of bricks n = int(input(...
microsoft/Phi-3-mini-4k-instruct
1
Python
class TrieNode: def __init__(self): self.word = False self.children = {} class Trie: def __init__(self): self.head = TrieNode() self.head.word = True def insert(self, word): itr = self.head for c in word: if c not in itr.children: itr.children[c] = TrieNode() itr = itr.children[c] itr.wor...
human
0
Python
def activitySelection(start,end,n): start_ INDEX_ = [i[0]for i in sorted(enumerate(start), key=lambda x:x[1])] end INDEX_ = [i[0]for i in sorted(enumerate(end),key=lambda x:x[1])] act = 0 endindx = 0 for startindx in start INDEX_ : if endindx<=startindx: act+=1 e...
bigcode/starcoder2-15b
1
Python
if __name__ == '__main__': t = int(raw_input()) for case in range(t): n = int(raw_input()) x = raw_input() x = x.replace('2', '1').replace('0', '9') x = ("0" + x)[:n] maxi = int("".join([str((int(x[i]) + int(x[i + 1])) % 3) for i in xrange(0, n, 2)]), 3) b = x ...
microsoft/phi-2
1
Python
t = int(input()) for i in range(t): n = int(input()) s = input() if n < 11: print('NO') elif n >= 11 and s[n - 11] == '8': print('YES') else: r = n - 11 if s[0:r].find('8') == -1: print('NO') else: print('YES')
human
0
Python
n = int(input()) arr = list(map(int, input().split())) (odds, evens) = (0, 0) for i in arr: if i % 2 == 0: evens += 1 else: odds += 1 if odds < evens: print(odds) else: odds -= evens print(evens + odds // 3)
human
0
Python
for i in range(0, int(input())): (a, b) = map(int, input().split()) print(a * b)
human
0
Python
python Return_Only(['4\n' '-324142\n' '"Hello World!" + int(input()) + str(324 + 7 + int(input()) if 5 > 2 and "Yes!" else + int(input( )) % 2 <==> True: while -3842 else Return([[],' return "044"' ]])"]] )
01-ai/Yi-Coder-9B-Chat
1
Python
flats = [int(j) for j in input().split()] for i in range(len(flats)): if i > 0 and i < len(flats) - 1 and flats[i-1] == flats[i+1]: flats[i] = 0 if len(flats) == 0: quit() print(min(flats))
microsoft/phi-2
1
Python
from heapq import * class Point: def __init__(self, x, y): self.x = x self.y = y self.distance = x ** 2 + y ** 2 def __lt__(self, other): return self.distance > other.distance class Solution: def kClosest(self, points: List[List[int]], K: int) -> List[List[int]]: distance_heap = [] for (x, y) in poi...
human
0
Python
def main(): n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) for i in range(3): l, r = map(int, sys.stdin.readline().split()) for j in range(l, r + 1): a[j] += (r - l + 1) * a[j] print(*a) if __name__ == '__main__': main()
meta-llama/Llama-3.2-3B
1
Python
(display minimum number of moves needed in one row cell): -----Code (python)-----def swap_rows(matrix, row1, row2): matrix[row1], matrix[row2] = matrix[row2], matrix[row1] def swap_columns(matrix, col1, col2): for row in matrix: row[col1], row[col2] = row[col2], row[col1] def make_matrix_beautiful(mat...
microsoft/Phi-3-mini-4k-instruct
1
Python
def maxHeapify(i): l = 2 * i r = 2 * i + 1 largest = 0 if l <= H and A[l] > A[i]: largest = l else: largest = i if r <= H and A[r] > A[largest]: largest = r if largest != i: (A[i], A[largest]) = (A[largest], A[i]) maxHeapify(largest) H = int(input()) A = list(map(int, input().split())) A = [-1] + A for...
human
0
Python
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() sum_a = sum(a) if sum_a > 0: print((n + 1) * sum_a) else: print(sum_a)
meta-llama/Llama-3.3-70B-Instruct
1
Python
n = int(input()) lis = input().split() for i in range(len(lis)): lis[i] = int(lis[i]) i = 0 s1 = 0 s2 = 0 while i < n - 1: M = max(lis[0], lis[n - i - 1]) if i % 2 == 0: s1 += M else: s2 += M if lis[len(lis) - 1] == M: lis = lis[:len(lis) - 1] else: lis = lis[1:] i += 1 if n % 2 == 0: s2 += lis[0] else:...
human
0
Python
def evaluate(s: str): if s[1] == '>': return s[0] else: return s[2] es = {'A': 0, 'B': 0, 'C': 0} for i in range(3): c = input() es[evaluate(c)] += 1 valid = True l = {0: -1, 1: -1, 2: -1} for (i, j) in es.items(): if not valid: break for (z, zz) in l.items(): if j == z: if l[z] == -1: l[z] = i ...
human
0
Python
t = int(input()) for i in range(t): n = int(input()) mylist = [] arr = map(int, input().split()) for j in range(n): mylist.append(next(arr)) mylist.sort(reverse=True) for a in mylist: print(a, end=' ')
human
0
Python
def JobScheduling(self,Jobs, n): # code here Jobs.sort(key=lambda x:x[2],reverse=True) dp=[0]*(n+1) for i in range(n): for j in range(Jobs[i][1]-1,0,-1): dp[j]=max(dp[j],dp[j-1]+Jobs[i][2]) dp[0]=max(dp[0],Jobs[i][2]) return [n,dp[0]] /12. ...
bigcode/starcoder2-15b
1
Python