Dataset Viewer
Auto-converted to Parquet Duplicate
_id
stringlengths
2
5
partition
stringclasses
2 values
text
stringlengths
5
289k
language
stringclasses
1 value
meta_information
dict
title
stringclasses
1 value
d1
train
for _ in range(int(input())): n = int(input()) mass = [] zo = 0 oz = 0 zz = 0 oo = 0 ozs = [] zos = [] ozss = set() zoss = set() for j in range(n): k = input() mass.append(k) if k[0] == '0' and k[-1] == '1': zoss.add(k) zos.appe...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1259/D" }
d2
train
q=int(input()) for e in range(q): x,y,k=list(map(int,input().split())) x,y=abs(x),abs(y) x,y=max(x,y),min(x,y) if(x%2!=k%2): k-=1 y-=1 if(x>k): print(-1) continue if((x-y)%2): k-=1 x-=1 print(k)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1036/B" }
d3
train
import sys import random from fractions import Fraction from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): return list(input()) def rinput(): return ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1408/A" }
d4
train
def solve(): n, k = map(int,input().split()) lst = list(map(int,input().split())) lst.sort() ans = 0 for i in range(n - k - 1, n): ans += lst[i] print(ans) for i in range(int(input())): solve()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1430/B" }
d5
train
for _ in range(int(input())): input() nums = [int(x) for x in input().split()] new_ar = list(zip(nums,[i for i in range(len(nums))])) new_ar.sort() maxx = new_ar[0][1] minn = new_ar[0][1] s="1" for j in range(1,len(new_ar)): if(new_ar[j][1]>maxx): maxx = new_ar[j...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1265/B" }
d6
train
def possible(a): ans = set() s = set() lmax = 0 for i in range(len(a)): lmax = max(lmax, a[i]) s.add(a[i]) if lmax == i + 1 and len(s) == i + 1: ans.add(i + 1) return ans t = int(input()) for case_num in range(t): n = int(input()) a = list(map(int, input...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1330/B" }
d7
train
import sys input = sys.stdin.readline for f in range(int(input())): n,m=list(map(int,input().split())) neig=[0]*n for i in range(n): neig[i]=[0] for i in range(m): a,b=list(map(int,input().split())) a-=1 b-=1 neig[a][0]+=1 neig[a].append(b) lev=[1...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1368/E" }
d8
train
import sys def I(): return sys.stdin.readline().rstrip() class Heap: def __init__( self ): self.l = [ -1 ] self.n = 0 def n( self ): return self.n def top( self ): return self.l[ 1 ] def ins( self, x ): self.l.append( x ) n = len( self.l ) - 1 ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1251/E2" }
d9
train
import sys input = sys.stdin.readline def main(): n, k = map(int, input().split()) string = input().strip() if "W" not in string: ans = min(n, k) * 2 - 1 print(max(ans, 0)) return L_s = [] cnt = 0 bef = string[0] ans = 0 for s in string: if s == ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1427/B" }
d10
train
for _ in range(int(input())): s = input() p = [i for i in s.split("0") if i!=""] p.sort(reverse=True) ans = 0 for i in range(0,len(p),2): ans+=len(p[i]) print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1398/B" }
d11
train
for _ in range(int(input())): # n, x = map(int, input().split()) n = int(input()) arr = list(map(int, input().split())) ans = [arr[0]] for i in range(1, n - 1): if arr[i - 1] < arr[i] and arr[i] > arr[i + 1]: ans.append(arr[i]) elif arr[i - 1] > arr[i] and arr[i] < arr[i ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1364/B" }
d12
train
n = int(input()) def area(width, height) : return (width+1) * (height+1) def calcul(s1, c, s2) : maxx, maxy, minx, miny = 0, 0, 0, 0 x, y = 0, 0 for k in range(len(s1)) : if s1[k] == "W" : y += 1 if s1[k] == "S" : y -= 1 if s1[k] == "A" : x -...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1202/C" }
d13
train
from math import * mod = 1000000007 for zz in range(int(input())): n = int(input()) a = [ int(i) for i in input().split()] b = [int(i) for i in input().split()] ha = True hp = False hm = False for i in range(n): if b[i] != a[i]: if b[i] > a[i]: if (hp): ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1333/B" }
d14
train
for i in range(int(input())): n,g,b=map(int,input().split()) nn=(n+1)//2 print(max(nn+(nn-1)//g*b,n))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1303/B" }
d15
train
for _ in range(int(input())): a1, b1 = list(map(int, input().split())) a2, b2 = list(map(int, input().split())) if a1 > b1: a1, b1 = b1, a1 if a2 > b2: a2, b2 = b2, a2 flag = False if a1 == a2 and a1 == b1 + b2: flag = True if b1 == b2 and b1 == a1 + a2: flag ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1351/B" }
d16
train
from math import * zzz = int(input()) for zz in range(zzz): a, b, x, y = list(map(int, input().split())) print(max(x*b, (a-x-1)*b, y*a, (b - y - 1)*a))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1315/A" }
d17
train
from math import sqrt class pro(object): def __init__(self,dif,sc): self.dif=dif self.sc=sc def __lt__(self,other): return self.dif>other.dif T=int(input()) mul=[1] for i in range(100): mul.append(mul[i]*10/9) inf=1000000007 for t in range(T): n=int(input()) effi,tim=list(m...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1056/F" }
d18
train
class BIT(): def __init__(self,n): self.BIT=[0]*(n+1) self.num=n def query(self,idx): res_sum = 0 while idx > 0: res_sum += self.BIT[idx] idx -= idx&(-idx) return res_sum #Ai += x O(logN) def update(self,idx,x): while idx <= self....
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1400/D" }
d19
train
import math T = int(input()) for _ in range(T): n = int(input()) print(1/math.tan(math.pi/2/n))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1354/C1" }
d20
train
for _ in range(int(input())): n, k, d = list(map(int, input().split())) a = list(map(int, input().split())) s = {} for q in range(d): s[a[q]] = s.get(a[q], 0)+1 ans = len(s) for q in range(d, n): if s[a[q-d]] == 1: del s[a[q-d]] else: s[a[q-d]] -= ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1225/B2" }
d21
train
q = int(input()) for _ in range(q): n, m = list(map(int, input().split())) info = [list(map(int, input().split())) for i in range(n)] info = sorted(info) now =(m, m) time = 0 flag = True for i in range(n): t, l, h = info[i] l_now = now[0] - (t - time) h_now = now[1] +...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1304/C" }
d22
train
t = int(input()) for _ in range(t): n = list(input().strip()) s = list(map(int, input().strip().split())) check = set(s) found = False for i in range(1, 1025): newset = set([e^i for e in s]) if check == newset: print(i) found = True break if ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1362/B" }
d23
train
import sys input = sys.stdin.readline for _ in range(int(input())): a, k = list(map(int, input().split())) for _ in range(k - 1): if '0' in str(a): break a += int(min(list(str(a)))) * int(max(list(str(a)))) print(a)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1355/A" }
d24
train
import heapq for _ in range(int(input())): n = int(input()) voters = [] for i in range(n): m,p = list(map(int, input().split())) voters.append((m, -p)) voters.sort() for i in range(n): voters[i] = (voters[i][0], -voters[i][1]) ans = 0 costs = [] heapq.heapify(co...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1251/E1" }
d25
train
for _ in range(int(input())): d=int(input()) anws=False if d**2>=4*d: root=(d**2-4*d)**0.5 a=(d+root)/2 b=(d-root)/2 anws=True if anws: print("Y {:.9f} {:.9f}".format(a,b)) else: print("N")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1076/C" }
d26
train
import os from io import BytesIO import sys import threading sys.setrecursionlimit(10 ** 9) threading.stack_size(67108864) def main(): # input = BytesIO(os.read(0, os.fstat(0).st_size)).readline def ad(i, j): nonlocal g if j in g[i]: g[i].remove(j) g[j].remove(i) ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1282/E" }
d27
train
for _ in range(int(input())): n, m = list(map(int, input().split())) if n < m: n, m = m, n # n > m if m == 1: print("YES") continue if m == 2 and n == 2: print("YES") continue print("NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1345/A" }
d28
train
tests = int(input()) for test in range(tests): n = int(input()) a = [int(i) for i in input().split()] d = {} for i in range(n): s = 0 while a[i] % 2 == 0: a[i] //= 2 s += 1 if a[i] in list(d.keys()): d[a[i]] = max(s, d[a[i]]) else: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1259/B" }
d29
train
import sys INF = 10**20 MOD = 10**9 + 7 I = lambda:list(map(int,input().split())) from math import gcd from math import ceil from collections import defaultdict as dd, Counter from bisect import bisect_left as bl, bisect_right as br """ Facts and Data representation Constructive? Top bottom up down """ def check(s): ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1379/A" }
d30
train
input=__import__('sys').stdin.readline for _ in range(int(input())): n=int(input()) s=list(map(int,input().split())) g=[[-1]for _ in range(n+1)] for i in range(n): g[s[i]].append(i) inf=10**10 ans=[-1]*n lstunused=n for i in range(1,n+1): g[i].append(n) mx=0 for j in range(1,len(g[i])): mx=max(mx,g[i...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1417/C" }
d31
train
t = int(input()) for i in range(t): n = int(input()) s = input() ans = 0 for y in range(1, n): if s[y] == s[y-1]: ans += 1 print((ans + ans % 2) // 2)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1437/B" }
d32
train
DIR = {"N": (0, 1), "S": (0, -1), "W": (-1, 0), "E": (1, 0)} for t in range(int(input())): path = input() tracks = set() x, y = 0, 0 time = 0 for char in path: x1 = x + DIR[char][0] y1 = y + DIR[char][1] if (x, y, x1, y1) in tracks or (x1, y1, x, y) in tracks: time += 1 ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1351/C" }
d33
train
from sys import stdin, stdout from collections import defaultdict input = stdin.readline for _ in range(int(input())): n = int(input()) chanek = 0 flag = 1 while n>0: if n%4==0 and n!=4: if flag: chanek += 1 n-=1 flag = 0 else: n-=1 flag = 1 elif n%2: if flag: chanek += 1 n-...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1425/A" }
d34
train
t=int(input()) for i in range(t): n=int(input()) print(2) print(n-1,n) for i in range(n-2,0,-1): print(i,i+2)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1430/C" }
d35
train
for _ in range(int(input())): n = int(input()) if(n%2): print("7"+"1"*((n-3)//2)) else: print("1"*(n//2))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1295/A" }
d36
train
import sys input=sys.stdin.readline for _ in range(int(input())): N=int(input()) e=list(map(int,input().split())) e.sort() ans=0 val=0 g=0 for i in range(0,N): g+=1 val=e[i] if g>=val: ans+=1 g=0 val=0 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1355/B" }
d37
train
n=int(input()) a=list(map(int,input().split())) k=[] for i in range(n): for j in range(a[i]): k.append(i+1) m=int(input()) b=list(map(int,input().split())) for i in b: print(k[i-1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/474/B" }
d38
train
3 from math import factorial as fact N = 55 c = [1] for i in range(N): c.append(fact(i)) dp = [0] * N dp[0] = 1 for i in range(1, N): for j in range(i): dp[i] += dp[j] * c[i - j - 1] def get_kth_cycle(n, k): if n == 1: return [1] ans = [-1] * n ans[0] = n - 1 fin = [i for i in range(n)] fin[0] = n - 1 in...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1279/E" }
d39
train
q = int(input()) for z in range(q): n, k1, k2 = map(int, input().split()) arr1 = list(map(int, input().split())) arr2 = list(map(int, input().split())) if max(arr1) > max(arr2): print('YES') else: print('NO')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1270/A" }
d40
train
t=int(input()) for tt in range(t): a,b,p=map(int,input().split()) s=input() n=len(s) cost = [0]*n cost[-1] = 0 typ = '' i=n-2 while i>=0: if s[i]==typ: cost[i] = cost[i+1] else: typ = s[i] cost[i] = cost[i+1] + (a if typ=='A' else b) ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1315/B" }
d41
train
def main(): from sys import stdin, stdout for _ in range(int(stdin.readline())): n = int(stdin.readline()) inp1 = [-1] * (n + 1) inp2 = [-1] * (n + 1) for i, ai in enumerate(map(int, stdin.readline().split())): if inp1[ai] < 0: inp1[ai] = i ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1223/D" }
d42
train
t = int(input()) for tt in range(t): n,k=list(map(int,input().split())) s = input() ans = [] if s[0] == ')': for i in range(n): if s[i] == '(': ans.append([1,i+1]) s = s[i::-1] + s[i+1:] break for i in range(1,(k-1)*2): if i...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1227/C" }
d43
train
LOG = 20 def solve(s): n = len(s) res = 0 z = 0 for t in range(0, n): if s[t] == '0': z += 1 continue for l in range(1, min(LOG, n - t + 1)): x = int(s[t:t+l], 2) # print(l, t, x, l + z) if l + z >= x: res += 1 # print(t, l, x, res, z) z = 0 return res t = int(input()) while t > 0: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1217/C" }
d44
train
def check(M): sm = 0 for i in range(n): if a[i] > M: sm += b[i] return sm <= M gans = [] for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) L = 0 R = max(a) while R - L > 1: M = (L + R) ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1443/C" }
d45
train
t=int(input()) for you in range(t): n=int(input()) for i in range(n): print(4*n-2*i,end=" ") print()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1443/A" }
d46
train
import sys import random from fractions import Fraction from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): return list(input()) def rinput(): return ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1419/B" }
d47
train
# # ------------------------------------------------ # ____ _ Generatered using # / ___| | | # | | __ _ __| | ___ _ __ ______ _ # | | / _` |/ _` |/ _ \ '_ \|_ / _` | # | |__| (_| | (_| | __/ | | |/ / (_| | # \____\____|\____|\___|_| |_/...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1380/B" }
d48
train
import sys input = sys.stdin.readline from bisect import bisect_right bin_s = [1] while bin_s[-1] <= 10 ** 9: bin_s.append(bin_s[-1] * 2) def main(): n, q = map(int, input().split()) alst = list(map(int, input().split())) dp = [[-1, -1] for _ in range(n)] dp[0] = [alst[0], 0] for i, a in enum...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1420/C1" }
d49
train
for haaghfj in range(int(input())): x,y,k = list(map(int,input().split())) print(k + (y * k + k - 1 +x-2) // (x - 1))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1418/A" }
d50
train
import sys #sys.stdin=open("data.txt") input=sys.stdin.readline # this math tutorial is boring classy=set() for i in range(19): for j in range(i): for k in range(j): for a in range(10): # a=0 for good measure for b in range(10): for c in range(10): ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1036/C" }
d51
train
for tcase in range(int(input())): n=int(input()) ls = list(map(int, input().split())) oneneed = 2*(n - ls.count(1)) ldct = {0:0} ctr = 0 eaten = 0 for i in range(n-1,-1,-1): eaten += 1 ctr += (1 if ls[i] == 2 else -1) if ctr not in ldct: ldct[ctr] = eaten ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1278/C" }
d52
train
def main(): t = int(input()) for z in range(t): n, k, d1, d2 = map(int, input().split()) if n % 3 != 0: print('no') continue f = 0 for i in [-1, +1]: for j in [-1, +1]: w = (k - i * d1 - j * d2) if f == 0 and (w ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/451/C" }
d53
train
n=int(input()) a=sorted(int(input()) for _ in range(n)) print(sum(a[i]*a[-i-1] for i in range(n))%10007)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/717/C" }
d54
train
import sys input = sys.stdin.readline def compress(array): array2 = sorted(set(array)) memo = {value : index for index, value in enumerate(array2)} for i in range(len(array)): array[i] = memo[array[i]] + 1 return array t = int(input()) base = 10 ** 6 for _ in range(t): n, b = list(map(st...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1304/D" }
d55
train
for i in range(int(input())): n=int(input()) s=list(map(int,input().split())) a=0 for i in s: if i<2049:a+=i if a<2048:print("NO") else:print("YES")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1221/A" }
d56
train
for __ in range(int(input())): n = int(input()) print((n + 1) // 2)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1371/A" }
d57
train
for _ in range(int(input())): n, k = map(int, input().split()) mat = [[0] * n for _ in range(n)] for i in range(n): b = False for j in range(n): if i*n+j == k: b = True break mat[(i+j)%n][j] = 1 if b: break if k%...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1371/D" }
d58
train
t = int(input()) for case in range(t): n = int(input()) arr = list(map(int, input().split())) if arr[-1] > arr[0]: print("YES") else: print("NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1375/C" }
d59
train
mem = [[[0 for i in range(51)] for j in range(31)] for k in range(31)] def f(n, m, k): if mem[n][m][k]: return mem[n][m][k] if (n*m == k) or (k == 0): return 0 cost = 10**9 for x in range(1, n//2 + 1): for z in range(k+1): cost = min(cost, m*m + f(n-x, m, k-z) + f(x...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/598/E" }
d60
train
for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) ans,small,big=0,2*10**9,-1 for i in range(len(a)-1): if a[i]==-1 and a[i+1]!=-1: small=min(small, a[i+1]) big=max(big, a[i+1]) if a[i]!=-1 and a[i+1]==-1: small = min(small, ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1301/B" }
d61
train
n = int(input()) for _ in range(n): a, b = list(map(int, input().split())) print(a ^ b)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1421/A" }
d62
train
import sys import math #from queue import * import random #sys.setrecursionlimit(int(1e6)) input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): return(int(input())) def inara(): return(list(map(int,input().split()))) def insr(): s = input() return(list...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1380/A" }
d63
train
T = int(input()) def solve(S): res = [S[0]] pos = 0 # think... for s in S[1:]: # can we change? if 0 <= pos-1 < len(res) and res[pos-1] == s: pos = pos-1 elif 0 <= pos+1 < len(res) and res[pos+1] == s: pos = pos+1 elif pos == 0 and s not in res: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1303/C" }
d64
train
def solve(): n, k = map(int,input().split()) lst1 = list(map(int,input().split())) lst1.sort(reverse=True) ind = 0 ans = 0 lst2 = list(map(int,input().split())) lst2.sort() for i in range(k): lst2[i] -= 1 if lst2[i] == 0: ans += lst1[ind] ans += lst1[ind] ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1369/C" }
d65
train
import sys import random from fractions import Fraction from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): return list(input()) def rinput(): return ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1408/C" }
d66
train
import math from collections import deque from sys import stdin, stdout from string import ascii_letters import sys letters = ascii_letters input = stdin.readline #print = stdout.write for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) ans = [999999999] * n ans[0] = 1 ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1418/C" }
d67
train
#list(map(int,input().split())) t=int(input()) for _ in range(t): n=int(input()) aa=list(map(int,input().split())) bb=list(map(int,input().split())) aa.sort() bb.sort() print(*aa) print(*bb)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1305/A" }
d68
train
for _ in range(int(input())): n = int(input()) s = input() t = input() d = {} for i in range(ord('a'), ord('z') + 1): d[chr(i)] = 0 for cs in s: d[cs] += 1 for ct in t: d[ct] += 1 ok = True for e in d: if d[e] % 2 == 1: ok = False i...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1243/B2" }
d69
train
from itertools import groupby def main(): N = int(input()) S = input() C = [len(list(x[1])) for x in groupby(S)] M = len(C) dup_idx = [] for i, c in enumerate(C): if c > 1: dup_idx.append(i) dup_idx.reverse() curr = 0 while dup_idx: i = dup_idx[...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1430/D" }
d70
train
t = int(input()) for case in range(t): a, b = list(map(int, input().split())) s = input() z = 10000 total = 0 act = False for i in range(len(s)): cur = s[i] if cur == '0': z += 1 act = False else: if not act: act = Tr...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1443/B" }
d71
train
import sys input = sys.stdin.readline from collections import defaultdict class Unionfind: def __init__(self, n): self.par = [-1]*n self.rank = [1]*n def root(self, x): r = x while not self.par[r]<0: r = self.par[r] t = x ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1332/C" }
d72
train
t=int(input()) while t>0 : n=int(input()) a=list(map(int,input().split())) an=0 s=0 for i in a : if s+i>=0 : s+=i else : s+=i an-=s s=0 print(an) t-=1
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1405/B" }
d73
train
t = int(input()) for _ in range(t): n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] if len(set(a)) > k: print(-1) continue l = list(set(a)) l.extend([1]*(k - len(l))) print(n*k) for _ in range(n): print(*l, end=" ") print()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1348/B" }
d74
train
def solve(): n = int(input()) a = list(map(int, input().split())) c = [0] * (n + 1) def inc(): for i in range(n - 1): if a[i] > a[i + 1]: return False return True def calc(): for i in range(n + 1): c[i] = 0 for i in a: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1375/D" }
d75
train
def read_int(): return int(input()) def read_ints(): return list(map(int, input().split(' '))) t = read_int() for case_num in range(t): n, k = read_ints() p = [] for i in range(n): ai, bi = read_ints() p.append((bi, ai, i + 1)) p.sort() dp = [[0 for j in range(k + 1)] for...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1354/F" }
d76
train
import math T = int(input()) for _ in range(T): n = int(input()) diags = 1/math.sin(math.pi/2/n) print(diags * math.cos(math.pi/4/n))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1354/C2" }
d77
train
t = int(input()) for _ in range(t): n = int(input()) if n%4 == 0: print("YES") else: print("NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1369/A" }
d78
train
3 import math import os import sys DEBUG = 'DEBUG' in os.environ def inp(): return sys.stdin.readline().rstrip() def dprint(*value, sep=' ', end='\n'): if DEBUG: print(*value, sep=sep, end=end) INF = 10 ** 20 def solve(N, A, B): dp = {A[0]: 0, A[0] + 1: B[0], A[0] + 2: B[0] * 2} for i...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1221/D" }
d79
train
import sys q = int(sys.stdin.readline().strip()) for t in range(0, q): n, m = list(map(int, sys.stdin.readline().strip().split())) L = [] R = [0] * n C = [0] * m for i in range (0, n): L.append(sys.stdin.readline().strip()) for j in range (0, m): if L[i][j] != "*": ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1194/B" }
d80
train
from math import ceil t = int(input()) for _ in range(t): n = int(input()) pf = [] for i in range(2, ceil(n**0.5)+1): while n % i == 0: pf.append(i) n //= i if n > 1: pf.append(n) if len(pf) == 2 and pf[0] != pf[1]: print(pf[0], pf[1], pf[0]*pf[1]) print(1) else: pg = [] ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1419/E" }
d81
train
def solve(L, R): res = 0 for i in range(32): for j in range(32): l = (L >> i) << i r = (R >> j) << j #print(l, r) if l>>i&1==0 or r>>j&1==0: continue l -= 1<<i r -= 1<<j if l & r: continue...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1245/F" }
d82
train
for _ in range(int(input())): a, b, c = input(), input(), input() n = len(a) ok = True for i in range(n): if c[i] not in [a[i], b[i]]: ok = False print('YES' if ok else 'NO')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1301/A" }
d83
train
for __ in range(int(input())): n = int(input()) ar = list(map(int, input().split())) ar.reverse() print(*ar)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1405/A" }
d84
train
def one(): return int(input()) def two(): return list(map(int, input().split())) def lis(): return list(map(int, input().split())) def st(): return input() for _ in range(one()): x, y, a, b = list(map(int, input().split())) d = y - x if d%(a+b)==0: print(d//(a+b)) else: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1304/A" }
d85
train
# encoding: utf-8 from sys import stdin def solve(a): # root node of tries denotes empty stack stack = [None] node_stack = [[1, {}]] trie = node_stack[-1] counter = 0 for i in range(len(a)): el = a[i] if len(stack) == 0 or stack[-1] != el: current_node = node_sta...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1241/F" }
d86
train
import sys input=sys.stdin.readline for _ in range(int(input())): s=input().rstrip() x=int(input()) n=len(s) ans=["1" for i in range(n)] for i in range(n): if s[i]=="0": if i-x>=0: ans[i-x]="0" if i+x<n: ans[i+x]="0" for i in rang...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1400/C" }
d87
train
def solve(): n = int(input()) lst = list(map(int,input().split())) if sum(lst) <= n // 2: print(n//2) print("0 " * (n // 2)) else: print(n//2 + (n // 2) % 2) print("1 " * (n//2 + (n // 2) % 2)) for i in range(int(input())): solve()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1407/A" }
d88
train
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') def gcd(a, b): while b: a, b = b, a%...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1389/E" }
d89
train
n = input() a = list(map(int, input().split())) for i in a: if i % 7 == 0 or (i // 7) % 2 == 1 or i <= 14: print('NO') else: print('YES')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1266/B" }
d90
train
from sys import stdin tt = int(stdin.readline()) for loop in range(tt): n = int(stdin.readline()) a = list(map(int,stdin.readline().split())) lis = [ [1] ] now = [] tmp = 0 for i in range(1,n): if len(now) == 0: now.append(a[i]) tmp = 1 elif now[-1] ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1437/D" }
d91
train
import math from collections import deque from sys import stdin, stdout from string import ascii_letters import sys letters = ascii_letters input = stdin.readline #print = stdout.write for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) can = list(map(int, input().split()))...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1418/B" }
d92
train
t = int(input()) for faw in range(t): n = int(input()) a = [0] + list(map(int,input().split())) nun = [] ans = [] f = True for i in range(1, n + 1): if a[i] == a[i-1]: if len(nun) == 0: f = False break else: ans.appe...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1227/B" }
d93
train
for _ in range(int(input())): print("YES" if set(input()).intersection(input()) else "NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1223/B" }
d94
train
for tc in range(int(input())): n,m = list(map(int, input().split())) al = list(map(int, input().split())) bl = list(map(int, input().split())) aidx = {} for i,e in enumerate(al): aidx[e]=i midx = -1 res = 0 for i,e in enumerate(bl): idx = aidx[e] if idx <= midx: ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1279/C" }
d95
train
T = int(input()) for test in range(T): n,t = list(map(int,input().split())) a = list(map(int,input().split())) res = [] j=0 for i in a: if(i*2<t): res+=["0"] elif(i*2>t): res+=["1"] else: res.append(["0","1"][j]) j = 1-j pri...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1417/B" }
d96
train
#JMD #Nagendra Jha-4096 import sys import math #import fractions #import numpy ###File Operations### fileoperation=0 if(fileoperation): orig_stdout = sys.stdout orig_stdin = sys.stdin inputfile = open('W:/Competitive Programming/input.txt', 'r') outputfile = open('W:/Competitive Programming/output...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1326/A" }
d97
train
import sys from operator import itemgetter def count(a, b, num_a, num_b, cur_time): current_result = 0 #print('count time = ', cur_time, "num_a =", num_a, 'num_b = ', num_b) if num_a * a + num_b * b <= cur_time and cur_time >= 0: cur_time -= num_a * a + num_b * b current_result = num_a + num_b if num_a < tota...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1282/C" }
d98
train
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ def solve(): s,c = input().split() # i,jでjが複数あるとき n = len(s) for i in range(n-1): prev = s[i] pos = i for j in range(i+1, n): if s[j]<prev: prev = s[j] pos = j...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1281/B" }
d99
train
q = int(input()) for _ in range(q): c, m, x = list(map(int, input().split())) print(min([c, m, (c + m + x) // 3]))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1221/C" }
d100
train
for _ in range(int(input())): # a, b = map(int, input().split()) n = int(input()) # arr = list(map(int, input().split())) s = input() l = 0 r = n - 1 if s.count('0') == n: print(s) continue if s.count('1') == n: print(s) continue while s[l] == '0': ...
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1369/B" }
End of preview. Expand in Data Studio

Employing the CoIR evaluation framework's dataset version, utilize the code below for assessment:

import coir
from coir.data_loader import get_tasks
from coir.evaluation import COIR
from coir.models import YourCustomDEModel

model_name = "intfloat/e5-base-v2"

# Load the model
model = YourCustomDEModel(model_name=model_name)

# Get tasks
#all task ["codetrans-dl","stackoverflow-qa","apps","codefeedback-mt","codefeedback-st","codetrans-contest","synthetic-
# text2sql","cosqa","codesearchnet","codesearchnet-ccr"]
tasks = get_tasks(tasks=["codetrans-dl"])

# Initialize evaluation
evaluation = COIR(tasks=tasks,batch_size=128)

# Run evaluation
results = evaluation.run(model, output_folder=f"results/{model_name}")
print(results)
Downloads last month
489