code
string
generator
string
label
int64
language
string
import sys input = sys.stdin.buffer.readline from collections import deque def countingSort(arr, exp1): n = len(arr) output = [0] * (n) count = [0] * (10) for i in range(0, n): index = arr[i] // exp1 count[index % 10] += 1 for i in range(1, 10): count[i] += ...
human
0
Python
class TreeNode: def __init__(self,val=0,left=None,right=None): self.val=val self.left=left self.right=right class Solution: def nextRight(self, root, key): # Code here #First convert the given tree into a doubly linked list #Using depth first traversal since queue...
ibm-granite/granite-8b-code-base-4k
1
Python
public: long long dfs(int i,int k,int par=-1,int cur=0,V vi=vi,vb=vb,vd=vb,V vl=vl){ if(vl[i]==0)return 0L; int c1=dfs(i,k-1);c1+=cur+vl[i]; if(vd[i]==0)return vl[i]-k; int c2=dfs(i,0);c2+=(vl[i]/2)+k; return max(c1,c2); } long long...
bigcode/starcoder2-7b
1
C++
class Solution: def longestPalinSubseq(self, S): def lcs(x, y, m, n): dp = [[-1 for i in range(n + 1)] for j in range(m + 1)] for i in range(0, m): for j in range(0, n): if i == 0 or j == 0: dp[i][j] = 0 for i in range(1, m + 1): for j in range(1, n + 1): if x[i - 1] == y[j - 1]: ...
human
0
Python
n, m = 400, 40 ans = "YES" if m != 10 ** 8 % n : ans = f"NO: {(m := m + (- m - 1) % (0 ** 0 // 0 ** 1))}" if len({a := sorted({a // r ** (n := 10)}, # 1 <= a // r - 1 < 0 for n) & a < 0**n & a // s == o * (o // k == o **o)): {d:= (o := range(*(o := range(-(c := m // **9), *(s:= -~(c:= m // n), re...
bigcode/starcoder2-3b
1
Python
. """ def min_moves_from_a_to_b(a: int, b: int) -> int: delta = abs(a - b) moves = 0 N = 10 # step through the delta, applying the moves `k` for i in range(delta, -1, -1): moves += 1 #the move +1 need_to_reach = i - abs((i-1) // N * N) delta = delta - need_to_rea...
microsoft/Phi-3-small-8k-instruct
1
Python
def suma(n): sumb = 0 while n > 0: sumb = sumb + n % 10 n = n // 10 return sumb n = int(input()) p = True while p: if suma(n) % 4 == 0: print(n) p = False else: n = n + 1
human
0
Python
police = 0 counter = 0 for val in li: if type(val)==str: break      if val < 0: if police > 0: police -= 1 else: police += val if police < 1: counter += 1 return counter if __name__ == '__main__': n = int(input()) li = [int(input()) for i in range(n)]...
bigcode/starcoder2-15b
1
Python
n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 c = [0] * 3 ans = 1 for x in a: t = c.count(x) ans = ans * t % mod if not t: break c[c.index(x)] += 1 print(ans)
human
0
Python
class Solution { public int[] findColumnWidth(int[][] grid) { int rows = grid.length, columns = grid[0].length; int[] widths = new int[columns]; for (int j = 0; j < columns; j++) { int maxWidth = 0; for (int i = 0; i < rows; i++) { int width = String.v...
human
0
Java
. ''' ''' public int numberOfWays(int rows, int cols, List<String> words) { int strLen = 0, lineLen = 0; int ways = 1; for (String word : words) { strLen += word.length(); lineLen += word.length() + 1; if (lineLen > cols) { lineLen = word.length() + 1; w...
microsoft/Phi-3-small-8k-instruct
1
Java
import math n = input() n = int(n) line1 = input() line2 = input() numbers1 = line1.split(' ') numbers2 = line2.split(' ') a = math.sqrt(int(numbers1[1]) * int(numbers1[2]) / int(numbers2[2])) res = '' + str(int(a)) i = 1 while i < n: res += ' ' + str(int(int(numbers1[i]) / a)) i += 1 print(res)
human
0
Python
import sys def solve(): t = int(sys.stdin.readline().strip()) for i in range(t): a, b, c = [int(x) for x in sys.stdin.readline().strip().split()] ans = a + b + c ans -= min([a, b, c]) sys.stdout.write("%s\n" % str(ans)) if __name__ == '__main__': solve()
ibm-granite/granite-8b-code-instruct-4k
1
Python
cases where the above expression evaluates as 0. ----- Sample Solution 1 ------ import timeit # 定义和输入共同一致 def get_time(fun, p): s = timeit.Timer(fun, p) cost = s.timeit(testcase) return cost # test some functions def fun_1(): arr = [1, 2] return arr def fun_2(): arr = [2, 3] return arr ...
meta-llama/Llama-3.2-1B
1
Python
class Solution: def dfsOfGraph(self, V, adj): return DFS(adj, 0) def DFS(G, s): def visit(G, parent, vertexes, visited, u): visited[u] = True for v in G[u]: if not visited[v]: vertexes.append(v) parent[v] = u visit(G, parent, vertexes, visited, v) n = len(G) visited = [False] * n parent = [...
human
0
Python
def f(a, b): min_ans = a + b for i in range(1, b // 2 + 1): if b % i == 0 and a * i + b // i < min_ans: min_ans = a * i + b // i return min_ans - a - b n = int(input()) m = list(map(int, input().split())) ans = sum(m) m = set(m) a = min(m) l = set() for i in m: l.add(f(a, i)) print(ans + min(l))
human
0
Python
for _ in range(int(input())): a = input() n = len(a) s = [] for i in range(n): s.append(int(a[i])) if n == 1: print('NET') else: cnt = 1 while True: f = 0 for i in range(n - 1): if s[i] != -1: j = i + 1 while j < n: if s[j] != -1: break j += 1 if j == n: f...
human
0
Python
times = sorted(list(map(lambda x: y, x.split())) for _ in range(N)) cur_time = 0 for job in jobs: end_time = cur_time + job[0] if end_time > job[1]: print('No') break cur_time = end_time else: print('Yes')from ipywidgets import Textarea import sys sys.path.append('../../..') from utils....
bigcode/starcoder2-15b
1
Python
_ = input() a = list(map(int, input().split())) def doIt(): for (i, c) in enumerate(a): if c % 2 == 1: if len(a) > i + 1: if a[i + 1] > 0: a[i + 1] -= 1 else: return 'NO' else: return 'NO' return 'YES' print(doIt())
human
0
Python
(a, b, c) = ([], [], []) (n, m, l) = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] b = [list(map(int, input().split())) for _ in range(m)] for i in range(n): x = [] for i2 in range(l): y = 0 for i3 in range(m): y += a[i][i3] * b[i3][i2] x.append(y) print(' '.join(map(str,...
human
0
Python
class Solution: def maxLen(self, n, lst): curr_sum = 0 max_l = 0 d = {} for i in range(0, len(lst)): curr_sum = curr_sum + lst[i] if curr_sum == 0: max_l = i + 1 elif curr_sum in d.keys(): max_l = max(max_l, i - d[curr_sum]) else: d[curr_sum] = i return max_l
human
0
Python
(socks, b) = map(int, input().split()) day = 1 while socks != 0: socks -= 1 if day % b == 0: socks += 1 day += 1 print(day - 1)
human
0
Python
def solve_query(n, k, prices): min_price = min(prices) max_price = max(prices) # Calculate the maximum possible new price B max_B = min_price + k # Check if this price B is within the allowed range for all prices if max_B - k >= min_price and max_B + k >= max_price: return max_...
codellama/CodeLlama-70b-Instruct-hf
1
Python
python def min_presses(a, b): # Check if the current volume is already at the desired volume if a == b: return 0 # Calculate the difference between the desired volume and the current volume diff = abs(b - a) # The minimum number of presses is the ceiling of the division of the difference by ...
microsoft/Phi-3-medium-4k-instruct
1
Python
def product(arr): result = 1 for x in arr: result = result * x return result for i in range(int(input())): a = int(input()) arr = list(map(int, input().split())) if (sum(arr) and product(arr)) != 0: print(0) else: c = arr.count(0) if c == 0: print(1) elif sum(arr) + c == 0: print(c + 1) else: ...
human
0
Python
for _ in range(t): s = input() n = len(s) found = False if n % 2 == 0: for i in range(1, n//2 + 1): if s[:i] != s[n - i:]: print("YES") found = True break if found: continue if s == s[::-1]: print("YES") continue print("NO")
google/codegemma-7b
1
Python
To solve this problem, we can use a binary search approach combined with a graph traversal algorithm (like Dijkstra's algorithm) to find the minimum time Snuke is exposed to cosmic rays during his travel. Here's a step-by-step outline and the corresponding Python code: 1. **Binary Search for Time**: We will perform a ...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
result = 0 for test in range(int(input())): inputs = input() values = list(map(int, inputs.split())) a = len(values) base = [] Blackhawks = [] for val in range(a): if values[val] != a: check = 0 for num in range(a): if a[num] > values[val]: check += 1 Blackhawks.app...
microsoft/phi-2
1
Python
a = list(mapint(input().split())) n = int(input()) a = list(map(int, input().split())) # print(a) a.sort() a.reverse() ans = 0 b = a #print(a, b) l = len(a) for i in range( 2 ** l): tmp = 0 for j in range(l): if i & (1 << j): tmp += b[j] b.append(tmp) #print(tmp, b) # print(b) ...
deepseek-ai/deepseek-coder-6.7b-base
1
Python
from sys import stdin test = stdin.readlines() inf = float('infinity') q = int(test[0]) k = 1 for _ in range(q): n = int(test[k]) (h, c) = ([], []) for j in range(k + 1, k + n + 1): (x, y) = map(int, test[j].split()) h.append(x) c.append(y) dp = [[0, c[0], 2 * c[0]]] + [[0, 0, 0] for i in range(n - 1)] for i...
human
0
Python
class Solution: def countSeniors(self, details: List[str]) -> int: return sum(1 for w in details if int(w[11:13])>60)
human
0
Python
rw = int(input()) for wewq in range(rw): (n, x) = map(int, input().split()) if n > 2: n -= 2 print((n + x - 1) // x + 1) else: print(1)
human
0
Python
class Solution: def lcmAndGcd(self, a, b): lcm_a = a lcm_b = b if a == 0 or b == 0: return (0, 0) gcd = 1 while a > 0 and b > 0: if a > b: a = a % b else: b = b % a if a == 0: gcd = b else: gcd = a lcm = lcm_a * lcm_b // gcd return (lcm, gcd)
human
0
Python
for the first example. */ import java.util.Scanner; import java.util.HashSet; import java.util.Set; public class LoveTriangles { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Set<Integer>[] adj = new HashSet[n]; for (int i = 0; i < n; i++) { adj[i]...
01-ai/Yi-Coder-1.5B
1
Python
functional code only list = input_as_list() print(len(list)) ''' def input_as_list(): N = int(input()) list=input().split() return (list) def main(): n = int(input()) list = input_as_list() print(len(list)) if __name__ == '__main__': main()<|endoftext|>#!/bin/python3 import math import o...
01-ai/Yi-Coder-9B
1
Python
for u in range(int(input())): (n, m) = map(int, input().split()) l = list(map(int, input().split())) d = list(map(int, input().split())) l.sort(reverse=True) (s, j) = (0, 0) for i in l: if j < i: s += d[j] j += 1 else: s += d[i - 1] print(s)
human
0
Python
python def count_valid_triangles(A, B, C, D): count = 0 for x in range(A, B + 1): for y in range(x, B + 1): for z in range(y, B + 1): if x + y > z and x + z > y and y + z > x: count += 1 return count # Read input A, B, C, D = map(int, input().split())...
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
only_show_wrong() class RPG: def __init__(self, field, actions): frame = ['#'] * (len(field[0]) + 2) self.field = [frame] + [['#'] + line + ['#'] for line in field] + [frame] self.actions = actions self.l = len(self.field) self.pack = {'H': 3, 'X': 1, 'S': 1} self.bag = [] self.moves = {'<': (0, -1), '...
human
0
Python
(n, m, a, b) = [int(n) for n in input().split()] if b <= a * (n % m): cost = n // m * b + b else: cost = n // m * b + n % m * a for i in range(0, n + 1, m): c = i / m * b + (n - i) * a if c < cost: cost = c print(int(cost))
human
0
Python
import heapq class Node: def __init__(self, x): self.data = x self.next = None def __lt__(self, nxt): return self.data < nxt.data class Solution: def mergeKLists(self, arr, K): try: min_heap = [] idx = 0 for i in range(K): heapq.heappush(min_heap, (arr[i].data, idx, arr[i])) idx += 1 ...
human
0
Python
//#pragma GCC optimize("Ofast", "unroll-loops") //#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4", "avx") #include <bits/stdc++.h> #define ll long long #define int long long #define ull unsigned long long #define YES puts("YES") #define NO puts("NO") #define Yes puts("Yes") #define No puts("No") #de...
human
0
C++
def obtain_array(n, array): for num in set(array): counter = array.count(num) if counter * 2 - 1 > n: return 'NO' return 'YES' n = int(input()) nums = list(map(int, input().split())) print(obtain_array(n, nums))
human
0
Python
python def can_eat_equal(A, B, C, D): # Calculate the total deliciousness of all cookies total = A + B + C + D # Check if it's possible to eat cookies such that the sum of the eaten cookies equals the sum of the remaining cookies if total % 2 == 0: # If the total is even, we can always eat ...
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
def main(): from sys import stdin input = stdin.readline from collections import Counter as ct from bisect import bisect_left as bl n = int(input()) max_a = sorted(ct(list(map(int, input().split()))).values()) now_a = [i for i in max_a] m = len(max_a) cnt = m ans = 0 ans_list = [0] * (n - m) for use in rang...
human
0
Python
python def split_string(n, p, q): if n % p == 0: if n % q == 0: return 2 elif n % q == 0: return 2 else: return -1 # Test cases print(split_string(5, 2, 3)) # Output: 2 print(split_string(10, 9, 5)) # Output: 2 print(split_string(6, 4, 5)) # Output: -1 print(split_str...
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
: O(345656 + Max(s.length)) Level: *******鳥目** ****, is a apache beginner. Tags : [*******鳥目** **最大****鳥目****的數學问题****鳥目****maximum**maximum alphabets**max*******[++**鳥目**--**=[**鳥目**–**鳥目**]--****鳥目**]+**鳥目**]-**鳥目****--**[**鳥目**ant**鳥目**音程 O(N)**鳥目**jee + **鳥目**%**鳥目**]+**鳥目**則反例 [**鳥目**置橫****鳥目**]**鳥目**し 只要多一個鳥目**...
meta-llama/Llama-3.2-1B
1
C++
def sol(arr): arr = [int(i) for i in arr] counter = 0 delt = {} for i in range(len(arr)): if arr[i] - i not in delt.keys(): delt[arr[i] - i] = 1 else: delt[arr[i] - i] += 1 counter += delt[arr[i] - i] - 1 print(counter) def main(): for i in range(int(input())): n = int(input()) arr = input().spl...
human
0
Python
from typing import List def fun(n: int, R: List[str]): if n == 2: return x = n - 1 while (n + x - 1) // x <= x: x -= 1 x += 1 for i in range(x + 1, n): R.append(f'{i} {i + 1}') R.append(f'{n} {x}') R.append(f'{n} {x}') fun(x, R) for _ in range(int(input())): n = int(input()) R = [] fun(n, R) print(le...
human
0
Python
import sys sys.setrecursionlimit(10 ** 5 + 1) inf = int(10 ** 20) max_val = inf min_val = -inf RW = lambda : sys.stdin.readline().strip() RI = lambda : int(RW()) RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()] RWI = lambda : [x for x in sys.stdin.readline().strip().split()] for _ in range(RI()): ...
human
0
Python
def min_strength_difference(n, strengths): strengths.sort() min_diff = float('inf') for i in range(1, n): max_A = strengths[i-1] min_B = strengths[i] diff = abs(max_A - min_B) if diff < min_diff: min_diff = diff return min_diff if __name__...
meta-llama/Llama-3.3-70B-Instruct
1
Python
python def print_nth_digit(n): # Generate a string of integers starting from 1 to a large number num_str = ''.join(map(str, range(1, 10**6))) # Return the n-th digit return num_str[n-1] if 0 < n <= len(num_str) else "Out of range" # Example usage n = int(input()) print(print_nth_digit(n))
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
p = lambda a: print(a) iip = lambda : int(input()) sip = lambda : input() mip = lambda : map(int, input().strip().split()) lip = lambda : list(map(int, input().strip().split())) ceil = lambda x: int(x) if x == int(x) else int(x) + 1 flr = lambda x: int(x) tstcs = lambda : range(int(input())) for t in tstcs(): (a, b) =...
human
0
Python
n = int(input()) array = list(map(int, input().split())) even = 0 for i in array: if i % 2 == 0: even += 1 if even > 1: even = True else: even = False for (k, i) in enumerate(array): if not even: if i % 2 == 0: print(k + 1) break elif i % 2 != 0: print(k + 1) break
human
0
Python
import sys s = input().strip() t = input().strip() k = int(input().strip()) if len(s) > len(t): length = len(t) else: length = len(s) if s == t and k % 2 != 0 and (k < length): print('No') elif len(s) + len(t) <= k: print('Yes') else: i = 0 count = 0 while i < length: if s[i] == t[i]: count += 1 else: ...
human
0
Python
def solve(): t = int(input()) for _ in range(t): a, b = map(int, input().split()) if (b >= a and (b - a) % 2 == 0) or (a >= 2*b and (a - 2*b) % 3 == 0): print("YES") else: print("NO") if __name__ == "__main__": solve()
codellama/CodeLlama-34b-Instruct-hf
1
Python
cases = eval(input[0]) count = 0 for i in range(cases): inputv = input[3*count + 1].replace('\n','').split(' ') e1 = int(inputv[0]) e2 = int(inputv[1]) e3 = int(inputv[2]) inputv = input[3*count + 2].replace('\n','').split(' ') lst1 = [] for j in range(e2): lst1.append(int(inputv[j])) inputv = inpu...
bigcode/starcoder2-15b
1
Python
def ibis_fights_with_n_kinds_of_spells_to_def_monster(H, A, B): R = np.array(A)/np.array(B) M = np.max(R) res = 0 for i in range(len(A)): k = int(M/R[i]) if k * B[i] <= H: res += k * B[i] H -= k * A[i] res += np.ceil(H/M)*B[np.argmax(R)] return res
google/codegemma-7b
1
Python
s = '' # string, will contain the result # you must add the value '#Black&White' or '#Color' to s depending on conditions. If the photo is black-an-White it must contains at least two colors. if contains three it will have three colors and is Colored, so we will write the value #Color to string. If the photo is black&...
google/codegemma-7b
1
Python
(a, b, c) = input().split(' ') (a, b, c) = (int(a), int(b), int(c)) (a, b, c) = (min(a, b, c), a + b + c - min(a, b, c) - max(a, b, c), max(a, b, c)) ans = 0 while a + b <= c: ans += 1 a += 1 print(ans)
human
0
Python
sum_numbers = 0 all_numbers = [0] for i in str(input()).split(): sum_numbers += int(i) if sum_numbers in all_numbers: print(all_numbers.index(sum_numbers) + 1) break else: all_numbers.append(sum_numbers) else: print(0) # For the communication with user from collections import Cou...
google/codegemma-7b
1
Python
N = int(input()) o = N // 2 + N % 2 print(o / N)
human
0
Python
python def find_permutations(a, b): n = len(a) dp = [[0] * (2 ** n) for _ in range(2)] for i in range(n): dp[0][(b[i] == '1') & (a[i] == '0')] = 1 dp[0][(b[i] == '0') & (a[i] == '1')] = 1 for i in range(1, n): for j in range(2 ** n): t = (b[i] == '1' and (a[...
Qwen/Qwen2.5-Coder-1.5B-Instruct
1
Python
def sort012 (self,arr,n): def swap(self,a,b,x=None): t= a+x y= t-x print('swapping {} with {}'.format(x,y )) # return y /Python_DSA_practice/Array_Problems/Find a pair with given product.py #https://practice.geeksforgeeks.org/problems/find-a-pair-with-given-prod#/CodeChef/Easy/Find The Point...
bigcode/starcoder2-3b
1
Python
from sys import stdin input = stdin.readline (n, m) = [int(x) for x in input().strip().split()] a = [int(x) for x in input().strip().split()] b = [int(x) for x in input().strip().split()] MOD = 998244353 ans = 1 (ai, bi) = (n - 1, m - 1) while bi >= 0: while ai >= 0 and a[ai] != b[bi]: if a[ai] < b[bi]: ans = 0 ...
human
0
Python
class Solution: def firstAlphabet(self, S): a = S.split() s = '' for I in a: s += I[0] return s
human
0
Python
def solve(A, X, Y): heap.heapify(A) for i in range(Y): a = heap.heappop(A) a = a ^ X heap.heappush(A, a) return A if __name__ == '__main__': T = int(input()) for _ in range(T): N, X, Y = map(int, input().split()) A = list(map(int, input().split())) A ...
meta-llama/Llama-3.1-8B
1
Python
def insert(root, k): if root == None: temp = Node(k) return temp if root.data > k: root.left = insert(root.left, k) elif root.data < k: root.right = insert(root.right, k) return root def constructBst(arr, n): root = Node(arr[0]) for i in range(1, n): insert(root, arr[i]) return root
human
0
Python
N = int(input()) S = list(input()) ans = N left_W = 0 right_E = S[1:].count('E') for n in range(N): if n == 0: ans = min(ans, S[1:].count('E')) elif n == N - 1: ans = min(ans, S[:n].count('W')) else: if S[n] == 'E': right_E -= 1 if S[n - 1] == 'W': left_W += 1 ans = min(ans, left_W + right_E) print(a...
human
0
Python
. Solution: def kthSmallest(arr, l, r, k): arr.sort() return arr[k-1] # This code is contributed by AnkitRai01 and improved by Takshiram jaatwal at geeksforgeeks.com # Test on any compiler or IDE and verify arr = [7, 10, 4, 3, 20, 15] n = len(arr) k = 3 print("K'th smallest element is",...
01-ai/Yi-Coder-9B-Chat
1
Python
def find(self,N): #code here s = 1 while True: num = 0 while num<=s: num += s if num > N:
codellama/CodeLlama-7b-hf
1
Python
: Compilers: GCC JAVA ''' t = int(input()) for i in range (t): s = str(input()) fly=0 for ii in range(0,len(s)-4): if s[ii:ii+5] == 'aabaab': fly=0 break elif s[ii:ii+5] == 'bcabcd': fly=0 break elif s[ii:ii+5] == 'ccccbd': ...
deepseek-ai/deepseek-coder-1.3b-base
1
Python
N, K = t[0], t[1] #first condition is that if all odd if N < 1 + 2( (K+1-K) / 2 ) or (K%2==1 and N< (K+1-K)//2 and K%4 == 3): print('NO');return l = [1] * (K-1); l.append(N-sum(l)); l.sort();print('YES');print(l) #if all even remains two '''
deepseek-ai/deepseek-coder-6.7b-base
1
Python
t = int(input()) for x in range(t): n = int(input()) s = input() a = [] for i in s: if i == 'H' or i == 'T': a.append(i) if len(a) == 0: print('Valid') elif len(a) % 2 == 0: for j in range(len(a)): if j % 2 == 0 and a[j] != 'H': print('Invalid') break if j % 2 != 0 and a[j] != 'T': prin...
human
0
Python
class Solution: def isValid(self, board): s = board board = [[0 for j in range(3)] for i in range(3)] k = 0 for i in range(3): for j in range(3): board[i][j] = s[k] k += 1 (co, cx) = (0, 0) owin = False xwin = False for row in board: t = row.count('O') if t == 0: xwin = True if...
human
0
Python
(n, k) = map(int, input().split()) count = 0 arr = list(map(int, input().split())) if arr[0] == 0: pass elif arr[k - 1] <= 0: for i in range(0, k): if arr[i] <= 0: break count += 1 else: count += k for i in range(k, len(arr)): if arr[i] >= arr[k - 1] and arr[i] > 0: count += 1 else: break print(cou...
human
0
Python
2 3 4 5 return pow(2,n,mod) powmod(x, y, m): if y==0: return if y&1: return (x*powmod(x, y-1, m))%m else: return (powmod(x, 2, m)*powmod(x, y//2, m))%m return powmod(2, n, mod) return a,b,c=[(i-1)for i in input().split(' ')] def xorSumArr(arr, mod...
bigcode/starcoder2-3b
1
Python
def sum(n): return n / 2 * (1 + n) a = int(input()) b = int(input()) c = abs(a - b) if c % 2 == 1: print(int(2 * sum(int(c / 2)) + int(c / 2 + 1))) else: print(int(2 * sum(int(c / 2))))
human
0
Python
class Solution { public String removeTrailingZeros(String num) { int n = num.length() - 1; while(n >= 0 && num.charAt(n) == '0') { n --; } return num.substring(0, n + 1); } }
human
0
Java
To solve this problem, the goal is to determine the optimal location for a shawarma tent such that the maximum number of students will pass by it on their way home from school. The key insight is that each student travels along one of the shortest paths, which means they follow a Manhattan path from the school to their...
microsoft/Phi-3-medium-4k-instruct
1
Python
import heapq t = int(input()) for y in range(t): (n, k) = (int(x) for x in input().split()) places = [] for l in range(1, n + 1): m = (k - 1) // l + 1 shoot = m * l - k place = shoot // m + 1 places.append(place) A = [int(x) for x in input().split()] heaps = [[-x] for x in A] assert len(A) == n ans = A.c...
human
0
Python
#include <bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int x,m; cin>>x>>m; int arr[x]; for(int i=1;i<=x;i++) { arr[i-1]=i; } int c=0; for(int i=0;i<x;i++) { cout<<arr[x-i...
human
0
C++
from math import sqrt, ceil def maximumPerimeterTriangle(sticks): max_perimeter = -1 for lengths in permutations(sticks[2:], start=2): perimeter = sum(lengths) if perm > max_perimeter or (permualtre == max_perimeter and min(lengths) == maxim_geqiumery[lengths]): max_perimeter = perim...
meta-llama/Llama-3.2-3B
1
Python
""" def nthItem(L1, L2, A, B, N): s = set() for i in A: for j in B: s.add(i+j) x = sorted(s) if x[n-1] > 0: return x[n-1] return -1
microsoft/Phi-3-medium-4k-instruct
1
Python
for _ in range(t): n = int(input()) a = list(map(int,input().split())) errcnt = 0 for i in range(n): if (i % 2) == 0: if (a[i] % 2) == 0: continue errcnt += 1 else: if (a[i] % 2) == 1: continue errcnt += 1 ...
ibm-granite/granite-8b-code-base-4k
1
Python
EXPECTED_INPUT = """ 5 1 100 0 1 0 100 4 20 30 40 50 100 100 100 100 4 10 20 30 40 100 100 100 100 7 7 59 62 52 27 31 55 33 35 50 98 83 80 64 2 7 59 62 52 27 31 55 33 35 50 98 83 80 64 """ EXPECTED_OUTPUT = """ 0 1 3 4 2 """ EXPECTED_OUTPUT_2 = """ 1 0 0 0 """ EXPECTED_OUTPUT_3 = """ 4 4 4 4 4 """ EXPECTED_OUTPUT_4 ...
microsoft/phi-2
1
Python
using namespace std; int main() { int t; cin >> t; while (t--) { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); bool flag = true; for (int i = 0; i < n - 1; i++) { if (a[i] == a[i + 1]) { flag = false; ...
01-ai/Yi-Coder-9B
1
C++
python def solve(n, p): p.sort() return abs(p.index(1) - p.index(n)) n = int(input()) p = list(map(int, input().split())) print(solve(n, p))
01-ai/Yi-Coder-1.5B-Chat
1
Python
s = list(map(int, input().split())) if len(s) == 1: print(1) print('R') exit() if len(s) == 3: if s[0] > s[1] and s[0] > s[2]: print(2) print('LR') exit() if s[0] < s[1] and s[0] < s[2]: print(2) print('LR') exit() if s[1] < s[0] and s[1] > s[2]:...
01-ai/Yi-Coder-9B
1
Python
(r, c) = map(int, input().split()) grid = [] for i in range(r): grid.append(list(input())) ans = 'NO' visited = [[0 for _ in range(c)] for _ in range(r)] f = 0 for i in range(r): for j in range(c): if grid[i][j] == '*': row = i (horx, hory) = (-1, -1) found = False while row < r and grid[row][j] == '*':...
human
0
Python
n = int(input()) l = [0] + [*map(int, input().split())] e = 0 s = 0 for i in range(1, n + 1): e += l[i - 1] - l[i] if e < 0: s += -e e += -e print(s)
human
0
Python
for the first test case: def xor_operation(a, b): return int(a, 2) ^ int(b, 2) a = '1010100' b = '0100101' print(format(xor_operation(a, b), 'b')) This code will return the binary representation of the XOR of the two input numbers. The 'int' function is used to convert the binary strings to integers, and the 'f...
deepseek-ai/deepseek-coder-6.7b-instruct
1
Python
import java.util.Scanner; public class jn { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int x = scan.nextInt(); for (int i = 0; i < x; i++) { String h = scan.next(); if(h.equalsIgnoreCase("yes")){ System.ou...
human
0
Java
def main(): n = int(input()) num = list(map(int, input().split())) cnt = [0, 0] i = 0 j = num.__len__() - 1 k = 0 while i <= j: if num[i] > num[j]: cnt[k % 2] += num[i] i += 1 else: cnt[k % 2] += num[j] j -= 1 k += 1 print(cnt[0], cnt[1]) main()
human
0
Python
return (int(x) for x in input().split()) #rints = lambda : list(rints()) n,k = rints() stringo = input() gra = stringo.find('G') end = stringo.find('T') edge = stringo.count('#') if edge>0: print ("NO") else: ## imples no '#111###############222223 if (gra-end)%k ==0 and gra<end: distance = end-gra time = distanc...
ibm-granite/granite-8b-code-base-4k
1
Python
""" import sys def problem28(): return("problem28.") if __name__ == "__main__": print(problem28())
microsoft/phi-2
1
Python
. This is the simplest way to solve this problem. detection_start(shard, num_shards): if shard == 0: a, b = map(int, input().split()) print(2 * a + b) k = [0, 1] for _ in range(2 * a + b - 2): k.append(_) for _ in range(b): ...
deepseek-ai/deepseek-coder-1.3b-instruct
1
Java
try: if int(input())**(0.5)//1 == int(input())**(0.5)/1: print("YES") else: print("NO") except EOFError: pass """ In Python, you can write: try: <Statement1> <Statement2> ... <StatementN> except #<ErrorType>: <StatementError> <Handler> or try: <Statement1> <Statement...
bigcode/starcoder
1
Python
Return law and result in a brief comment def contains(string, letter_group): return [c for c in string if c in letter_group] def pangram(string): alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' alphabet = contains(string, alphabet) return "YES" if len(alphabet) == len(string) else "N...
microsoft/Phi-3-medium-4k-instruct
1
Python
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i += 6 return True def find_non_prime_m(n): m...
Qwen/Qwen2.5-Coder-32B-Instruct
1
Python
python def distribute_candies(n): # Calculate the total number of candies total_candies = n * (n + 1) // 2 # Since we want all bags to have an equal amount of candies, # let's find out how many candies each bag should have candies_per_bag = total_candies // n # Initialize the output li...
microsoft/Phi-3-small-8k-instruct
1
Python