code
string
generator
string
label
int64
language
string
from math import log10 t = int(input()) def isRound(n): if n <= 9: return True else: while n >= 10: if n % 10 != 0: return False n = n / 10 return True for i in range(t): s = input() n = int(s) if isRound(n): print(1) print(n) else: nums = [] while n >= 10: ex = int(log10(n)) rem = ...
human
0
Python
python def solve(): n, B, x, y = map(int, input().split()) a = [0] for i in range(1, n + 1): if a[-1] + x <= B: a.append(a[-1] + x) else: a.append(a[-1] - y) return sum(a) t = int(input()) for _ in range(t): print(solve())
01-ai/Yi-Coder-9B-Chat
1
Python
def generateBinaryStrings(self, N): ans, cur = [[]], [] while cur: ns = [] for syms in cur: for i in '01': nms = syms+[i] if len(nms) == N and nms not in ans: ans.append(nms) ns.append(nms) cur = ns return ans}
meta-llama/Llama-3.1-8B
1
Python
def vasilys_triangle(x, y): x1 = max(-x, -y, 0) y1 = max(x, y, 0) x2 = min(x, y) y2 = x2 return (x1, y1, x2, y2)
microsoft/Phi-3-small-8k-instruct
1
Python
n = int(input()) c = 0 l = [] for _ in range(n): m = list(map(int, input().split())) l.append(m) for j in l: if sum(j) >= 2: c += 1 print(c)
human
0
Python
, no extra print statements. Input Format: The first line contains the integers N, leaves and the array frogs[]. Output Format: Return the number of unvisited leaves. Sample Input: 3 4 3 2 4 Sample Output: 1 Explanation: Leaf 1 will not be visited by any frog. Sample Input: 3 6 1 3 5 Sample Output: 0 Explanation:...
microsoft/Phi-3-mini-4k-instruct
1
Python
def max_steps(n, m, x, y, vectors): total_steps = 0 for dx, dy in vectors: steps = 0 while 1 <= x + dx * steps <= n and 1 <= y + dy * steps <= m: steps += 1 total_steps += steps - 1 x += dx * (steps - 1) y += dy * (steps - 1) return total_steps def main()...
codellama/CodeLlama-70b-Instruct-hf
1
Python
needs to take care of the minimum element which is repeated exactly K times. ***************************************************************/ #include <bits/stdc++.h> using namespace std; class Solution{ public: int findDuplicate(int arr[], int n) { unordered_map<int,int> mp; for(int i=0;i<n;i++){ ...
01-ai/Yi-Coder-1.5B
1
Python
test_cases = int(input()) for i in range(test_cases): x = input() times = int(x[-1]) - 1 s1 = 10 * times n2 = len(x) s2 = n2 * (n2 + 1) // 2 print(s1 + s2)
human
0
Python
def can_reorder(a, m): n = len(a) m_sum = 0 a = sorted(a, reverse=True) for i, val in enumerate(a): partial = 0 for j in range(i, n): partial += val / (j + 1) m_sum += partial if m_sum == m: return "YES" else: return "NO" test_cases = int(inp...
meta-llama/Llama-3.1-8B-Instruct
1
Python
(l, r, k) = map(int, input().split()) p = 1 ok = False while p <= r: if l <= p: print(p, end=' ') ok = True p *= k if ok: print('') else: print(-1)
human
0
Python
s = input() s = s.lower() for char in s: if not char in 'aoyeui': print('.', end='') print(char, end='')
human
0
Python
def count_set_bits(num): return bin(num).count('1') def max_chocolates(T, test_cases): results = [] for _ in range(T): N, K = test_cases[_][0] numbers = test_cases[_][1] bit_counts = [count_set_bits(num) for num in numbers] bit_counts.sort(reverse=True) results.appen...
codellama/CodeLlama-70b-Instruct-hf
1
Python
n = int(input()) def fact(n): if n == 0: return 1 return n * fact(n - 1) def nCr(n, r): return int(fact(n) / (fact(r) * fact(n - r))) print(nCr(2 * (n - 1), n - 1))
human
0
Python
class Solution { public List<Integer> targetIndices(int[] nums, int target) { Arrays.sort(nums); List<Integer> res = new ArrayList<>(); for (int i = 0; i < nums.length; i++) { if (nums[i] == target) res.add(i); } return res; } }
human
0
Java
python def find_median(arr): arr.sort() n = len(arr) if n % 2 == 0: #even return (arr[n//2] + arr[(n//2) - 1]) // 2 else: #odd return arr[n//2]
01-ai/Yi-Coder-1.5B-Chat
1
Python
class Solution: def minSum(self, nums1: List[int], nums2: List[int]) -> int: l1 = l2 = 0 cnt1 = cnt2 = 0 for k in nums1: if k == 0: cnt1 += 1 else: l1 += k for k in nums2: if k == 0: cnt2 += 1 ...
human
0
Python
t = int(input()) while t: n = int(input()) num = n c = 0 while(n>1): if(n%6 == 0): n = n//6 c +=1 else: b = math.gcd(n,6) if(b==2 or b==3): n *= 2 c +=1 else: print("-1") ...
ibm-granite/granite-8b-code-base-4k
1
Python
python from collections import defaultdict import math import random import sys input=sys.stdin.readline N = int(2e5)+10 def isprime(x): f = 1 for i in range(2,int((x)**(1/2))+1): if x % i == 0: f = 0 break if x == 1: return False else: return f for _ in ...
meta-llama/Llama-3.1-8B-Instruct
1
Python
used = -set() while ( x != O ). add O. modOo OO) if ajfaj-Xej-joj) { retj-O ; Oe} return lture For each test cases in the input find integer, l2 O- 0050 find integer ' , r2 (5 -OOS -OsO find IK' (IOOI0 and all digits of X'12O5O)O'l 213O 63 '3 32 are not same numbers of this numbers X)1 4O4 .4 ...
01-ai/Yi-Coder-9B
1
Python
import math import heapq, bisect import sys from collections import deque, defaultdict from fractions import Fraction mod = 10 ** 9 + 7 mod1 = 998244353 import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.b...
human
0
Python
for i in range(int(input())): (A, B) = [int(x) for x in input().split()] if str(B) != len(str(B)) * str(9): print(A * (len(str(B)) - 1)) else: print(A * len(str(B)))
human
0
Python
from heapq import heappush, heappop, heapify class Solution: def minCost(self, a, n): heapify(a) s = 0 while len(a) != 1: x = heappop(a) + heappop(a) s += x heappush(a, x) return s
human
0
Python
(n, a, b, c) = map(int, input().split()) mn = 999999999999999 for x in range(0, 104, 4): if x >= n % 100: k = x - n % 100 for i in range(k + 1): for j in range(k // 2 + 1): for m in range(k // 3 + 1): if i + 2 * j + 3 * m == k: val = i * a + j * b + m * c if val < mn: mn = val print(...
human
0
Python
from collections import Counter from itertools import combinations def is_subsequences(s_1, s_2) -> bool: i = j = 0 while i < len(s_1) and j < len(s_2): if s_1[i] == s_2[j]: i += 1 j += 1 return i == len(s_1) q = int(input()) while q > 0: (s, t, p) = (input(), input(), input()) if not is_subsequences(s, t)...
human
0
Python
mesEl = list(input().split()) for i in range(int(input())): print(' '.join(mesEl)) (a, b) = input().split() if mesEl[0] == a: mesEl[0] = b else: mesEl[1] = b print(' '.join(mesEl))
human
0
Python
python def solve(n, p): p.sort() for i in range(1, n): if p[i] != p[i - 1] + 1: return False return True def main(): q = int(input()) for _ in range(q): n = int(input()) p = list(map(int, input().split())) if solve(n, p): print("YES") ...
01-ai/Yi-Coder-1.5B-Chat
1
Python
def add_binary(n1, n2): n = n1 + n2 def decToBin(num): if num == 0: return '' else: return decToBin(num // 2) + str(num % 2) if n == 0: return 0 else: return decToBin(n)
human
0
Python
def get_position(z, M): (x, y) = (0, 1) for i in M: if z in i: x = i.index(z) + 1 return (x, y) else: y += 1 L = [] for i in range(5): L.append([int(x) for x in input().split()]) (x, y) = get_position(1, L) print(abs(x - 3) + abs(y - 3))
human
0
Python
def max_distance(s): max_dist = 0 chars = {'a': [], 'b': [], 'c': []} for i in range(len(s)): chars[s[i]].append(i) for i in chars: for j in chars: if i!= j and chars[i] and chars[j]: max_dist = max(max_dist, abs(chars[i][0] - chars[j][-1])) ...
meta-llama/Llama-3.3-70B-Instruct
1
Python
if root is None: return None if root.left is None and root.right is None: if root.data == key: return None else: return root key_node = None q = [] q.append(root) temp = None # Do level order traversal to find # the deepest node(temp) and no...
01-ai/Yi-Coder-9B
1
Python
from the solution (4 lines max): 83f61be68a72910cb3050b084a3496f3d111c7159cb5d9821fc0e854798015f5 import random n = int(input()) a = set() for _ in range(n): ax, ay = map(int, input().split()) a.add((ax, ay)) a.add((-ax, ay)) a.add((ax, -ay)) a.add((-ax, -ay)) for (x, y) in a: cnt = 0 for (a...
Qwen/Qwen2.5-Coder-1.5B
1
Python
runs on online judge and cannot be used at home or on codeforces */ #include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; for (int x; cin >> x;) a.push_back(x); set<int> s(a.begin() + 1, a.end()); vector<char> b(s.begin(), s.end()); n -= s...
deepseek-ai/deepseek-coder-1.3b-base
1
Python
def getTranspose(v, g): vt = defaultdict(list) for u in g: for val in g[u]: vt[val].append(u) return vt def SCTarjansUtil(g, s, visited, stck, scc): visited[s] = True; stck.append(s); for val in g[s]: if visited[val] == False: SCTarjansUtil(g, val, visited, stck, scc) if s == scc[0]: while stck:...
bigcode/starcoder2-7b
1
Python
(D, G) = list(map(int, input().split())) p = list() c = list() for _ in range(D): (P, C) = list(map(int, input().split())) p.append(P) c.append(C) ans = 1 << 29 for bit in range(1 << D): sum_ = 0 num_ = 0 for i in range(D): if bit & 1 << i: sum_ += c[i] + p[i] * 100 * (i + 1) num_ += p[i] if sum_ >= G: ...
human
0
Python
class Solution { public int maxValue(int[][] A, int K) { int res=0; int n=A.length; TreeMap<Integer,Integer>treemap=new TreeMap<>(); Arrays.sort(A,(a,b)->{ return a[1]-b[1]; }); Seg segs[]=new Seg[K+1]; for(int i=0;i<segs.length;i...
human
0
Java
. n = int(input()) a = [int(x) for x in input().split()] if(n == 2): print(1, a[0], a[1], a[2], 1) elif(n % 2): mid = int((n - 1) / 2) a[n - 1], a[mid] = a[n - 1], a[mid] a.reverse() for x in a: print(x, end=' ')
Qwen/Qwen2.5-Coder-1.5B
1
Python
import java.util.HashSet; class Solution { public int countDistinctIntegers(int[] arr) { HashSet<String> set = new HashSet<>(); for (int v :arr) { set.add(Integer.toString(v)); while (v > 0 && v % 10 ==0) { v /= 10; } String rev = new...
human
0
Java
(n, m) = [int(x) for x in input().split()] arr = [True] * m for i in range(n): (l, r) = [int(x) for x in input().split()] for j in range(l - 1, r): arr[j] = False print(arr.count(True)) for (i, val) in enumerate(arr): if val: print(i + 1, end=' ')
human
0
Python
t = int(input()) for _ in range(t): a = input() n = len(a) x = list(a) coun = 0 for i in x: if i == 'L': coun += 1 else: coun += 1 break (count, temp) = (1, 1) for i in range(1, len(x)): if x[i] == x[i - 1] and x[i] == 'L': temp += 1 else: count = max(count, temp) temp = 1 if x.count('...
human
0
Python
result = 1 for i in range(t): if i == 0: word = input() last = word continue word = input() if word == last: continue else: result += 1 last = word print(result)
01-ai/Yi-Coder-9B
1
Python
(n, _, *l) = map(int, open(0).read().split()) c = [0] * -~n for (a, b) in zip(l[::2], l[1::2]): c[a] ^= 1 c[b] ^= 1 print('YNEOS'[any((i for i in c))::2])
human
0
Python
on the top line (not on the bottom lines) #include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; void printAnswer(int a){ cout<< a<<endl; } int main(){ int t; cin>> t; for(int i = 0; i < t; t++){ int n; cin>> n; vector<int> a(n); ...
deepseek-ai/deepseek-coder-1.3b-base
1
Python
def min_moves(n, alarms): x_coords = set() y_coords = set() for x, y in alarms: x_coords.add(x) y_coords.add(y) return min(len(x_coords), len(y_coords)) # Reading input n = int(input()) alarms = [tuple(map(int, input().split())) for _ in range(n)] # Calculating and printing t...
codellama/CodeLlama-70b-Instruct-hf
1
Python
import math test = int(input()) for _ in range(test): n = int(input()) eights = math.ceil(n / 4) num_s = '9' * (n - eights) + '8' * eights num = int(num_s) print(num)
human
0
Python
from collections import defaultdict # n = int(input()) # size of array # lst = list(map(int, input().split())) # array elements arr = [0] * (2*n) arr[a] = -1 for i in range(n): arr[n+i] = lst[i] for i in range(n-1, 0, -1): arr[i] = lst[i-1] for i in range(n, 2*n): arr[i] += arr[i-1] for i in range(n-1, -1,...
01-ai/Yi-Coder-9B
1
Python
def sepperate(word): sepperated = [] temp = '' for i in word: if i.isspace(): sepperated.append(temp) temp = '' else: temp += i sepperated.append(temp) return sepperated in1 = input() in2 = input() kn = sepperate(in1) scores = sepperate(in2) n = int(kn[0]) k = int(kn[1]) calculating = True while calcu...
human
0
Python
t = int(input()) for c in range(t): n = input() L = [int(n[i]) * 10 ** (len(n) - i - 1) for i in range(len(n)) if n[i] != '0'] print(len(L)) for el in L: print(el, end=' ') print()
human
0
Python
class Solution: def countBuildings(self, h, n): count = 1 max = h[0] for j in range(n): if h[j] > max: count = count + 1 max = h[j] return count
human
0
Python
python class TrieNode: def __init__(self): self.children = {} self.valid_word = False class StreamChecker: def __init__(self, words): self.root = TrieNode() self.stream = deque([]) for word in words: node = self.root for ch in reversed(word): ...
deepseek-ai/deepseek-coder-1.3b-instruct
1
Python
I = input s = [I(), I()] d = {} for _ in '0' * int(I()): (m, h, t, k) = I().split() t = int(t) * (2 * (h == 'h') - 1) a = d.get(t, 0) d[t] = [a + 1, max(a, 2)][k == 'r'] if d[t] == 2: print(s[t < 0], abs(t), m) d[t] = 3
human
0
Python
import sys from collections import Counter input = sys.stdin.readline def solve(): (A, B, k) = [int(x) for x in input().split(' ')] a = [int(x) for x in input().split(' ')] b = [int(x) for x in input().split(' ')] x = Counter(a) y = Counter(b) ans = k * (k - 1) // 2 for z in x: ans -= x[z] * (x[z] - 1) // 2 ...
human
0
Python
: 4 Yes :22:21:04:32:33:28:43:44 Input may contain: one or more blank lines. -- **Test Cases** __open 5 issue, good contribute__. For further information please contact commit@open.issue. Learn more about tracking tickets here: https://github.com/open/issues/
meta-llama/Llama-3.2-1B
1
Python
n = int(input()) a = [int(i) for i in input().split()] a.sort() f = True if n % 2 == 0: for i in range(n): if a[i] != i // 2 * 2 + 1: f = False break else: for i in range(n): if a[i] != (i + 1) // 2 * 2: f = False break print(2 ** (n // 2) % (10 ** 9 + 7) if f else 0)
human
0
Python
fibb = [0, 0, 1] for i in range(58): fibb.append((fibb[-1] + fibb[-2]) % 10) fibb[0] = fibb[-1] def solve(x): t = 2 ** (x.bit_length() - 1) % 60 print(fibb[t]) n = int(input()) for i in range(n): x = int(input()) solve(x)
human
0
Python
import os import 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() self.writable = 'x' in file.mode or 'r' not in file.mode self.write = self.buffer.write if self.writable else None de...
human
0
Python
import sys (K, A, B) = map(int, input().split()) if B - A <= 2: print(K + 1) sys.exit() S = A K -= A - 1 S += (B - A) * (K // 2) if K % 2: S += 1 print(S)
human
0
Python
t = int(input()) while t != 0: t -= 1 n = int(input()) arr = list(map(int, input().split())) arr.sort() min_ans = float('-inf') curr_sub = 0 for i in arr: if i - curr_sub > min_ans: min_ans = i - curr_sub curr_sub += i - curr_sub print(min_ans)
human
0
Python
for _ in range(int(input())): (a, b, c) = map(int, input().split()) min_move = float('inf') for a_cnt in range(1, 50000): for b_cnt in range(a_cnt, 50000, a_cnt): if c % b_cnt <= b_cnt - c % b_cnt: c_cnt = c - c % b_cnt else: c_cnt = c + b_cnt - c % b_cnt move = abs(a - a_cnt) + abs(b - b_cnt) + a...
human
0
Python
S = list((char for char in input())) N = len(S) c = 0 for i in S: if 65 <= ord(i) <= 90: c += 1 F = [] if c > N / 2: for i in S: if 65 <= ord(i) <= 90: F.append(i) else: F.append(chr(ord(i) - 32)) else: for i in S: if 97 <= ord(i) <= 122: F.append(i) else: F.append(chr(ord(i) + 32)) P = '' P = ...
human
0
Python
t = int(input().strip()) for case in range(t): str1 = input().strip() str2 = input().strip() chars1 = set() chars2 = set() for c in str1: chars1.add(c) for c in str2: chars2.add(c) if len(chars1 & chars2) > 0: print('YES') else: print('NO')
human
0
Python
def solve(x): log_2 = (x + 1).bit_length() - 1 if x < 8: return log_2 return log_2 + bin(x + 1 - (1 << log_2) >> 1 & (1 << log_2 - 2) - 1).count('1') for i in range(int(input())): n = int(input()) if n == 1: print(1) elif n % 2 == 0: print(n + 1 - solve(n + 1)) else: print(solve(n))
human
0
Python
# # This is the code made by Shir (Rodrigo ROldan Herrera) for # for UdeA - Técnica de la programación as second problem assignment if False: # code to insert - Code compiles from colorama import Fore, Style, init init() # getpass.getpass('') # browser, screenshots = ["Mozilla/5.0", "Firefox/55.0"] ...
meta-llama/Llama-3.1-8B
1
Python
To solve this problem, we need to determine the minimum number of special exchanges required to sort a permutation of integers from 1 to \( n \). A special exchange allows us to permute a subarray such that no element remains in its original position within that subarray. Here's a step-by-step breakdown of the solutio...
microsoft/Phi-3-medium-4k-instruct
1
Python
for _ in range(t): n = int(input()) array = list(map(int, input().split(" "))) first = [] second = [] two = [] array2 = sorted(array) diff = 0 for i in range(n-1): diff = abs(array[i]-array[i+1]) if not diff in first: first.append(diff) if (i != n-2) ...
bigcode/starcoder
1
Python
import io from itertools import permutations import os from collections import Counter, defaultdict, deque def solve(N, S): freq = [Counter(s) for s in S] for common in '01': good = [] for i in range(3): if freq[i][common] >= N: good.append(i) if len(good) >= 2: (i, j) = good[:2] s1 = S[i] s2 =...
human
0
Python
class Solution: def hasAllCodes(self, s: str, k: int) -> bool: def binary_code_of_length_k(k): if k == 1: return ['0', '1'] t = binary_code_of_length_k(k - 1) return ['0' + i for i in t] + ['1' + i for i in t] k_string = binary_code_of_length_k(k) for i in k_string: if s.find(i) == -1: retu...
human
0
Python
n = int(input()) c = list(map(int, input().split())) a = [] for i in c: a.append(i) a.sort() l = 1 p = set() f = dict() for i in range(n - 1, -1, -1): if not a[i] in p: p.add(a[i]) f[a[i]] = l l += a.count(a[i]) for i in c: print(f[i], end=' ')
human
0
Python
mat = [] for i in range(0, n): x = input() list = x.split() for j in range(0, len(list)): list[j] = int(list[j]) mat.append(list) ans = 0 for i in range(0, n): r = 0 c = 0 for j in range(0, n): r += mat[i][j] c += mat[j][i] for k in range(0, n): #print(r,c,k) if(r > c): ans +=1 break els...
ibm-granite/granite-8b-code-base-4k
1
Python
const int MAXN = 1e5+5; class Solution { public: vector<int> successfulPairs(vector<int>& spells, vector<int>& potions, long long success) { vector<int> cnt(MAXN, 0); for (int i : potions) { ++cnt[i]; } for (int i = MAXN-2; i >= 0; --i) { cnt[i] += cnt[i+1]; ...
human
0
C++
def minSwap(arr, n, k): window_size = sum(1 for i in arr if i <= k) min_swaps = n count = sum(1 for i in arr[:window_size] if i <= k) for i in range(n - window_size + 1): min_swaps = min(min_swaps, window_size - count) if i == n - window_size: break if arr[i] <= k: ...
meta-llama/Llama-3.3-70B-Instruct
1
Python
import java.util.Arrays; class Solution { public int matchPlayersAndTrainers(int[] players, int[] trainers) { int i = 0; int j = 0; int n = players.length; int m = trainers.length; int res = 0; Arrays.sort(players); Arrays.sort(trainers); while (i < n...
human
0
Java
S=S[::-1] Output=S[int(input())-1] print(Output)/Algorithm/0004_1-2FourDivide.py import sys Case=int(input()) for i in range(0,Case): S=list(sys.stdin.readline().split()) a=int(S[0].strip()) b=int(S[1].strip()) count=0 while a%b!=0: a=a*10+9 count+=1 if count==0: count=b ...
bigcode/starcoder2-3b
1
Python
order = lambda xs: ' '.join(sorted(xs.split(), key=min))
human
0
Python
def solve(s): sm = 0 init = 0 cur = 0 for i in range(len(s)): sm += 1 if s[i] == '-': cur -= 1 if s[i] == '+': cur += 1 if init + cur < 0: sm += (i + 1) * abs(init + cur) init += abs(init + cur) print(sm) def main(): for _ in range(int(input())): s = str(input()) solve(s) main()
human
0
Python
#include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; void primeFactors(int n, map<int, int> &M) { if (n % 2 == 0) { M[2]++; while (n % 2 == 0) n /= 2; } for (int i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) { M[i]++;...
meta-llama/Llama-3.3-70B-Instruct
1
C++
p = int(input()) a = 0 b = [] conta = 0 conta2 = 0 for x in range(p): a = input() for y in a: if y != 0: conta += 1 b.append([y, len(a) - conta]) conta = 0 for y in range(len(b)): if b[y][0] != '0': conta2 += 1 print(conta2) for y in range(len(b)): if b[y][0] != '0': print(str(b[y][0]) + '0' * i...
human
0
Python
class Solution: def maxSumSequence(self, n, a): dp = [0] * n dp[0] = a[0] d = {} d[dp[0]] = [0] for i in range(1, n): s = 0 for j in range(i - 1, -1, -1): if a[j] < a[i]: s = max(s, dp[j]) dp[i] = s + a[i] if dp[i] not in d: d[dp[i]] = [i] else: d[dp[i]].append(i) r = max(d...
human
0
Python
import collections import os import random import re import sys # # Complete the 'mex' function below. # # The function is expected to return an INTEGER. # The function accepts INTEGER_ARRAY a as parameter. # s = collections.Counter() def mex(a): global s if len(a)==0: return 0 m = min(a) n ...
bigcode/starcoder2-7b
1
Python
python def solve_summing_string(s): s_list = list(s) s_list.sort() return ''.join(s_list) # Example usage sum_str = "3+2+1" print(solve_summing_string(sum_str)) # Output: 1+2+3
Qwen/Qwen2.5-Coder-1.5B
1
Python
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; vector<int> g[maxn]; int cmp[maxn]; struct edge { int u, v, w; edge() { u = v = w = 0; } edge(int _u, int _v, int _w) { u = _u, v = _v, w = _w; } bool operator<(edge b) { ...
human
0
C++
def time_to_bed(current_time, sleep_duration): # Split current time and convert to integers current_hour, current_minute = map(int, current_time.split(':')) # Split sleep duration and convert to integers sleep_hours, sleep_minutes = map(int, sleep_duration.split(':')) # Calculate bedtime i...
microsoft/Phi-3.5-mini-instruct
1
Python
n,k = int(sys.stdin.readline()), int(sys.stdin.readline()) lines = sys.stdin.readlines() presses = map(int,lines[0].split()) def findBestPrice(k, prices): if len(prices) < k+1: return None if len(prices) == k+1: return max(prices)-min(prices) if len(prices) == k+2: return [a - b fo...
bigcode/starcoder2-15b
1
Python
import sys def poorDragons(): (k, l, m, n, d) = map(int, sys.stdin.readlines()) cnt = 0 for i in range(1, d + 1): if i % k == 0: cnt += 1 elif i % l == 0: cnt += 1 elif i % m == 0: cnt += 1 elif i % n == 0: cnt += 1 return cnt print(poorDragons())
human
0
Python
n = int(input()) s = int(input()) c = 1 for i in range(n - 1): snew = int(input()) if snew != s: c += 1 s = snew print(c)
human
0
Python
from collections import defaultdict import os import sys from io import BytesIO, IOBase _str = str str = lambda x=b"": x if type(x) is bytes else _str(x).encode() BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buff...
human
0
Python
def solve(): n, k1, k2 = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) if n in a: print("YES") else: print("NO") t = int(input()) for _ in range(t): solve()
codellama/CodeLlama-34b-Instruct-hf
1
Python
python t=int(input()) def can_represent(n,k): if n>k*(k-1): return "YES" else: return "NO" for _ in range(t): n,k=map(int,input().split()) print(can_represent(n,k))
01-ai/Yi-Coder-9B-Chat
1
Python
import numpy N,M=list(map(int,input().strip().split(" "))) arr=[] ans = [] ans1 = [] for x in range(0,N): list_m=list(map(int,input().strip().split(" "))) arr.append(list_m) for x in range(0,M): sum=0 for i in range(0,len(arr)): sum= sum+arr[i][x] ans.append(sum) a=numpy.array(ans) answer...
google/codegemma-2b
1
Python
python def count_points(points, queries): ans = [] for x, y, r in queries: inside = 0 for dx, dy in points: d = (x - dx) * (x - dx) + (y - dy) * (y - dy) if d <= r * r: inside += 1 ans.append(inside) return ans
01-ai/Yi-Coder-1.5B-Chat
1
Java
''' INFINITY = 9999999999999999 while True: try: s = input().lower() t = input().lower() except EOFError: exit() ind = {} for idx, ele in enumerate(s): if ele in ind: ind[ele] = min(idx, ind[ele]) else: ind[ele] = idx pass_st = 0 ...
01-ai/Yi-Coder-1.5B
1
Python
s=[] for _ in range (w): a=str(input()) s.append(a) output=0 count=0 for i in range(len(s)): if i==0: output+=1 else: if s[i][0]!=s[i-1][1] : output+=1 print(output)
Qwen/Qwen2.5-Coder-7B
1
Python
(N, K) = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) S = 0 ans = 0 for a in A: if S + a < K: S += a ans += 1 else: ans = 0 print(ans)
human
0
Python
a = [int(input()) for i in range(n)] a.sort() for i in range(1,n-1): if i%2 != a[i%2]: print(i+1) break with open('test', 'r') as f: s = f.read().splitlines() # print(s) ll = [] m = int(s[0]) n = 2 * m d = int(s[1]) a, i = s[m:m+n], 1 # print(a) for val in a: ...
microsoft/phi-2
1
Python
public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = scanner.nextInt(); } Arrays.sort(a); int result = 0; ...
microsoft/Phi-3.5-mini-instruct
1
Java
n = int(input()) s = input() p = (0, 0) d = {p: 1} for i in s: if i == 'R': p = (p[0], p[1] + 1) if i == 'L': p = (p[0], p[1] - 1) if i == 'U': p = (p[0] + 1, p[1]) if i == 'D': p = (p[0] - 1, p[1]) d.update({p: d.get(p, 0) + 1}) sm = 0 for j in d: x = d.get(j) sm += (x - 1) * x // 2 print(sm)
human
0
Python
t = int(input()) for i in range(t): n = int(input()) dic = dict() flag = 0 for i in range(n): string = input() for i in range(len(string)): if string[i] in dic: dic[string[i]] += 1 else: dic[string[i]] = 1 for i in dic: if dic[i] % n != 0: flag = 1 print('NO') break if flag != 1: pr...
human
0
Python
from heapq import heappop, heappush from collections import defaultdict class Solution: def reachableNodes(self, edges: List[List[int]], M: int, N: int) -> int: graph = defaultdict(dict) for (i, j, l) in edges: graph[i][j] = graph[j][i] = l heap_queue = [(-M, 0)] seen = defaultdict(int) while heap_queue...
human
0
Python
#include <bits/stdc++.h> #define Endl '\n' #define ll long long #define PB(a) push_back(a) #define pas {cout<<"NO"<<Endl;continue;} #define bitsN(n) __builtin_popcount(n); #define YON(f) cout<<(f?"YES":"NO")<<Endl; #define lpn(a,n,x) (lower_bound(a,a+n,x)-a) #define upn(a,n,x) (upper_bound(a,a+n,x)-a) #define...
human
0
C++
#include<cstdio> const int SIZE = 200000; int p[SIZE]; int ans[SIZE][2]; int ans_cnt; bool judge(int a[], int n){ static int used[SIZE+1]; for(int i = 1; i <= n; i++) used[i] = 0; for(int i = 0; i < n; i++) used[a[i]] = 1; for(int i = 1; i <= n; i++) { if(!used[i]) return 0; } ...
human
0
C++