Datasets:
id stringlengths 2 5 | title stringclasses 1
value | text stringlengths 5 289k |
|---|---|---|
d1 | 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... | |
d10 | 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)
| |
d100 | 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':
... | |
d1000 | try:
for _ in range(int(input())):
k=int(input())
for i in range(1,k+1):
print(" "*(k-i),end="")
if i%2==1:
for j in range(0,i):
print(chr(65+j),end="")
else:
for j in range(0,i):
print(j+1,end="")
print()
except:
pass | |
d1001 | # cook your dish here
from math import ceil
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
ans=ceil(n/min(a))
print(int(ans)) | |
d1002 | for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
g=1
for j in range(1,n):
if j-5<0:
mi=min(a[0:j])
#print(a[0:j])
if mi>a[j]:
g=g+1
else:
mi=min(a[j-5:j])
#print(a[j-5:j])
if mi>a[j]:
g=g+1
print(g)
| |
d1003 | # cook your dish here
def solution(b,n1,d):
first=b[0]
b.sort()
for j in range(n1-1):
if(a[j+1]-a[j]>d):
return "NO"
for j in range(n1):
if(b[j]==first):
pos=j
if(pos==0 or pos==n1-1):
return "YES"
rec=1
for j in range(pos-1,n1-2):
if(a[j+2]-a[j]>d):
rec=0
break
if(rec):
return "YES"
r... | |
d1004 | t=eval(input())
for i in range(0,t):
x=input()
nm=x.split(' ')
nm[0]=int(nm[0])
nm[1]=int(nm[1])
csoint=[]
lsoint=[]
csofloat=[]
lsofloat=[]
for j in range(0,nm[0]):
a=input()
b=a.split(' ')
b[0]=int(b[0])
b[1]=int(b[1])
csoint.append(b[0])
... | |
d1005 | a=int(input())
if(a%2==0):
print("4")
print(a/2,a/2,a/2,a/2)
else:
print("6")
print((a-1)/2,(a-1)/2,(a-1)/2,(a-1)/2,(a-1)/2,(a+1)/2) | |
d1006 | MAXX = 10**9+1
N = eval(input())
nodes = list(map(int, input().split(" ")))
edges = [set() for _ in range(N)]
for _ in range(N-1):
a, b = list(map(int, input().split(" ")))
edges[a-1].add(b-1)
edges[b-1].add(a-1)
path = [[] for _ in range(N)]
visited, tovisit = set(), [(0, 0)]
while tovisit:
p, v = tovi... | |
d1007 | for _ in range(int(input())):
n,d=map(str,input().split())
k=list(n)
dd,c,n=d,0,len(n)
for x in range(n):
if int(k[n-x-1])>int(d):
k.pop(n-x-1)
c+=1
else:
d=k[n-x-1]
print(''.join(k)+c*dd) | |
d1008 | import math
for _ in range(int(input())):
n=int(input())
ar=[int(x) for x in input().split()]
# dp=[1]*n
f=0
g=ar[0]
for i in range(1,n):
g=math.gcd(g,ar[i])
if g==1:
f=1
print(n)
break
if f==0:
print(-1)
| |
d1009 | t=int(input())
for k in range(t):
n=int(input())
l=[int(i) for i in input().split()]
m={}
count=1
for i in range(1,n):
if l[i]==l[i-1]:
count+=1
else:
if l[i-1] not in m:
m[l[i-1]]=(count*(count+1))/2
else:
... | |
d101 | n = int(input())
for _ in range(n):
a, b, c = list(map(int, input().split()))
print(min((a+b+c)//2, a+b, a+c, b+c))
| |
d1010 | # cook your dish here
from sys import stdin
import functools
def gcd(a, b):
if (a == 0):
return b
return gcd(b % a, a)
MAX=10001
def func(ind, g, dp, n, a):
if (ind == n):
if (g == 1):
return 1
else:
return 0
if (dp[ind][g] != -1):
return dp[ind][g]
ans = (func(ind + 1, g, dp, n, a) +... | |
d1011 | #code snippet reference:http://www.geeksforgeeks.org/searching-for-patterns-set -2-kmp-algorithm/
def KMPMatch(pattern, string):
M = len(pattern)
N = len(string)
nonlocal ans
lps = [0]*M
j = 0
LPSCompute(pattern, M, lps)
i = 0
while i < N:
if pattern[j] == string[i]:
i+=1
j+=1
if j==M:
ans+... | |
d1012 | t=int(input())
def do():
n,k=map(int,input().split())
s=input()
upper=0
lower=0
for i in s:
if i.isupper():
upper+=1
else:
lower+=1
if lower>k and upper<=k:
print('chef')
elif(upper>k and lower<=k):
print('brother')
elif(upper<=k and lower<=k):
print('both')
else:
print('none')
return
for i ... | |
d1013 | import sys
from collections import defaultdict
from copy import copy
MOD = 10**9 + 7
R = lambda t = int: t(input())
RL = lambda t = int: [t(x) for x in input().split()]
RLL = lambda n, t = int: [RL(t) for _ in range(n)]
# primes up to n
def primes(n):
P = []
n = int(n)
U = [1] * (n+1)
p = 2
... | |
d1014 | # cook your dish here
from collections import defaultdict
d=defaultdict(list)
def dfs(i):
p=0
nonlocal v
e=[i]
while(e!=[]):
p+=1
x=e.pop(0)
v[x]=1
for i in d[x]:
if v[i]==-1:
v[i]=1
e.append(i)
return p
n,... | |
d1015 | from math import log2, ceil
MOD = int(1e9 + 7)
srt = lambda s: ''.join(sorted(s))
for _ in range(int(input())):
s = srt(input())
res = -1
for p in range(ceil(log2(int(s))), int(log2(int(s[::-1]))) + 1):
if int(srt(str(pow(2, p)))) == int(s):
if res == -1: res = 0
res... | |
d1016 | # cook your dish here
try:
for _ in range(int(input())):
k = int(input())
num = 1
for i in range(1,k+1,1):
for j in range(1,k+1,1):
print(num*2,end="")
num = num +1
print("")
except:
pass | |
d1017 | # cook your dish here
for t in range(int(input())):
c=0
for i in range(int(input())):
s,j=list(map(int,input().split()))
if (j-s)>5:
c+=1
print(c)
| |
d1018 | # cook your dish here
for t in range(int(input())):
a1,a2,a3,a4,a5,p=[int(x)for x in input().rstrip().split()]
if (a1+a2+a3+a4+a5)*p >120:
print("Yes")
else:
print("No")
| |
d1019 |
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
hrs = arr[0] - arr[1]
for i in range(1, n-1):
if hrs > arr[i] - arr[i+1]:
hrs = arr[i] - arr[i+1]
print(hrs) | |
d102 | import os
from io import BytesIO
# input = BytesIO(os.read(0, os.fstat(0).st_size)).readline
for i in range(int(input())):
a, b, c, r = list(map(int, input().split()))
a, b = min(a, b), max(a, b)
left = max(c - r, a)
right = min(c + r, b)
if right >= a and left <= right:
print(b - a - (righ... | |
d1020 | # cook your dish here
for i in range(int(input())):
N=int(input())
L=list(map(int,input().split()))
l,h=0,N-1
flag=1
if L[l]!=1 and L[h]!=1:
flag=0
else:
while(l<h):
if (L[l]!=L[h]) or (L[l+1]-L[l]!=1 and L[h-1]-L[h]!=1):
flag=0
break
l+=1
h-=1
if flag:
print("yes")
else:
print("no") | |
d1021 | # cook your dish here
for _ in range(int(input())):
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
m=0
for i in range(n):
if i%2==0:
if m<0:
m-=a[i]
else:
m+=a[i]
else:
if m<0:
m+=a[i]
else:
m-=a[i]
if abs(m)>=k:
print(1)
else:
print(2)
| |
d1022 | class Node:
def __init__(self,x):
self.x=x
self.next=None
self.prev=None
self.flag=True
for t in range(1):
n=int(input())
arr=list(map(int,input().split()))
for i in range(n):
arr[i]=Node(arr[i])
for i in arr:
d=[i.x%3==0,i.x,i.x//3,i.x*2... | |
d1023 | # cook your dish here
# cook your dish here
import math
test=int(input())
for _ in range(test):
n=int(input())
l=list(map(int,input().split()))
f=0
for i in range(math.ceil(n//2)):
if n%2==1:
f=1
break
else:
if l[i]!=l[i+n//2]:
if min(l[i],l[i+n//2])==-1:
l[i]=max(l[i],l[i+n//2])
l[i+n//2... | |
d1024 | # cook your dish here
for _ in range(int(input())):
n = int(input())
count = 1
l = 3*(n-1)
i = 0
if n==1:
print(1)
continue
while count<=l-n:
for j in range(i+1):
if j==i:
print(count)
count += 1
elif j==0:
... | |
d1025 | # cook your dish here
extra, less = 0,0
for _ in range(int(input())):
sli,mem,sma,luc = list(map(int, input().split()))
total = sma
t = sma
while mem > 1:
t *= luc
total += t
mem -= 1
if total <= sli:
extra += sli-total
print('POSSIBLE',sli-total)
else:
... | |
d1026 | from collections import defaultdict as dd,deque as dq
def opbfs(u,vis,ll,parr):
q=dq([(u,0)])
uu=u
su=0
while q:
u,lol=q.pop()
par=parr[u]
if(lol%2==0):
vis[u]=1
su+=ll[u-1]
ll[u-1]=0
for j in d[u]:
if(j!=par):
q.appendleft((j,lol+1))
ll[uu-1]=su
def bfs(height,d,parr):
q=dq([1])
while... | |
d1027 | d=1000000007
for _ in range(int(input())):
l=sorted(list(map(int,input().split())))
ans=(l[0]%d)*((l[1]-1)%d)*((l[2]-2)%d)
print(ans%d) | |
d1028 | T=int(input())
for i in range(T):
n,m=list(map(int,input().split()))
if(m<=2):
print("impossible")
else:
l=[0]*m
if(m%2==0):
a=m//2
else:
a=(m//2)+1
for j in range(a):
if(j%2==0):
l[j]="a"
l[m-j-1]="a"
else:
l[j]="b"
l[m-j-1]="b... | |
d1029 | def power(x, y):
if y == 0:
return 1
if y % 2 == 0:
return power(x, y // 2) * power(x, y // 2)
return x * power(x, y // 2) * power(x, y // 2)
# Function to calculate order of the number
def order(x):
# Variable to store of the number
n = 0
while (x != 0):
n = n + 1
x = x // 10
return n
# Function t... | |
d103 | s = []
for i in range(1, 10):
k = 0
for l in range(1, 10):
k *= 10
k += i
s.append(k)
s.sort()
q = int(input())
while q:
n = int(input())
l = 0
r = len(s)
while l + 1 < r:
m = (l + r) // 2
if s[m] <= n:
l = m
else:
r = m
... | |
d1030 | T = int(input())
for _ in range(T):
n,m = map(int,input().split())
completed = list(map(int,input().split()))
jobs = []
for i in range(1,n+1):
if i not in completed:
jobs.append(i)
jobs.sort()
chef = []
ass = []
for i in range(len(jobs)):
if i%2==0:
chef.append(str(jobs[i]))
else:
ass.append(str(... | |
d1031 | t = int(input())
while(t>0):
t-=1;
n,l,r = list(map(int,input().split()));
a = bin(l)[2:];
b = bin(r)[2:];
# find matching
z = 0;
l = min(len(a),len(b));
for i in range(l):
if a[i]==b[i]:
z+=1;
else:
break;
#find base string
a = a[z:]
b = b[z:]
if(len(a)==0 and len(b)==0):
print(n);
else :
m... | |
d1032 | import math
t = eval(input())
while(t > 0):
h,s = input().split()
h = int(h)
s = int(s)
if(((h*h*h*h) - (16*s*s)) < 0):
print("-1")
else:
B = (math.sqrt((h*h) + math.sqrt((h*h*h*h) - (16*s*s))))/math.sqrt(2)
P = (2*s)/B
if(B > P):
print('{0:.6f}'.format(P),'{0:.6f}'.format(B),'{0:.6f}'.format(h))
else... | |
d1033 | a = [1]
M = 10**6 + 3
for ii in range(1, 1000005):
a.append((a[-1]*ii)%M)
for __ in range(eval(input())):
n, x = list(map(int, input().split()))
if n>=M: print(0)
else: print((a[n]*x)%M)
| |
d1034 | print(0) | |
d1035 | from math import log2;
import bisect;
from bisect import bisect_left,bisect_right
import sys;
from math import gcd,sqrt
sys.setrecursionlimit(10**7)
from collections import defaultdict
inf=float("inf")
# n=int(input())
# n,m=map(int,input().split())
# l=list(map(int,input().split()))
def get_factors(x):
if x==1:
ret... | |
d1036 | # cook your dish here
from collections import namedtuple
CurrentPosition = namedtuple('current_position', 'points, cell, pairs')
T = int(input())
for _ in range(T):
R, C, N = map(int, input().split())
Sx, Sy = map(int, input().split())
tx = map(int, input().split())
ty = map(int, input().split())
... | |
d1037 | # cook your dish here
t=int(input())
for _ in range(t):
x1,y1,x2,y2=map(int,input().split())
x3,y3,x4,y4=map(int,input().split())
if (x1==x3 and y1==y3)or(x2==x4 and y2==y4):
print("yes")
elif (x1==x4 and y1==y4)or(x2==x3 and y2==y3):
print("yes")
else:
if(y1==y2)and(y1==y3)and(y1==y4):
a1=max(x1,x2);a2=m... | |
d1038 | for _ in range(int(input())):
s = input().strip()
a = []
last = 0
for i in range(len(s)):
if s[i] == 'P':
a.append(i - last)
last = i + 1
x = 0
a = a[::-1]
for v in a[::2]:
x ^= v % 3
print('Yes' if x else 'No') | |
d1039 | MOD = int(1e9+7)
def mult(a, b):
rsp = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
for i in range(3):
for j in range(3):
for k in range(3):
rsp[i][j] += a[i][k] * b[k][j]
rsp[i][j] %= MOD
return rsp
ident = [[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]
m = [[1, 1, 0],
[1, 0, 1],
[1, 0, 0]]
powers = [m]
f... | |
d104 | t = int(input())
for _ in range(t):
n, m = [int(x) for x in input().split()]
grid = [[int(x) for x in input().split()] for _ in range(n)]
rows = sum(1 for x in grid if all(y == 0 for y in x))
cols = sum(1 for j in range(m) if all(grid[i][j] == 0 for i in range(n)))
res = min(rows, cols)
prin... | |
d1040 | t=int(input())
for i in range(t):
ans=0
x,y=list(map(int,input().split()))
if y>x:
if (y-x)%4==0:ans=3
elif (y-x)%2==0: ans=2
else: ans=1
if y<x:
if (y-x)%2==0:ans=1
else: ans=2
print(ans)
| |
d1041 | t=int(input())
for _ in range(t):
n,q=map(int,input().split())
s=input()
l=[0]*(n-1)
for i in range(n-2):
a,b,c=s[i],s[i+1],s[i+2]
if len(set([a,b,c]))<3:
l[i]=l[i-1]+1
else:
l[i]=l[i-1]
for i in range(q):
left,right=map(int,input().split())
left-=1
right-=1
if right-left+1 <3:
print('N... | |
d1042 | # cook your dish here
for u in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
d=[]
dd=[]
s=1
for i in range(n-1):
s=l[i]
d.append(s)
dd.append([i,i])
for j in range(i+1,n):
s=s*l[j]
d.append(s)
dd.append([i,j])
d.append(l[n-1])
dd.append([n-1,n-1])
k=len(d)
m=max(d)
x,y... | |
d1043 | # cook your dish here
def G(x, y):
while(y):
x, y = y, x % y
return x
# t=int(input())
# l=list(map(int,input().split()))
for _ in range(int(input())):
n,p=map(int,input().split())
c=0
for i in range(1,n+1):
if G(i,p)==1:
c+=1
ans=c*(c-1)//2
print(ans) | |
d1044 | test_case = int(input())
for w in range(test_case):
n, k = map(int,input().split())
l = list(map(str,input().split()))
ans = []
for q in range(k):
l2 = list(map(str,input().split()))
ans.extend(l2[1:])
for i in l:
if i in ans:
print('YES',end=' ')
else:
print('NO',end=' ')
print()# cook your dish he... | |
d1045 | # cook your dish here
number = int(input())
for i in range(number):
a = list(input())
for k in range(len(a)):
a[k] = eval(a[k])
print(sum(a)) | |
d1046 |
vow = ['a', 'e', 'i','o', 'u']
for _ in range(int(input())):
name = str(input())
tmp = ''
for i in range(len(name)):
if name[i] not in vow and name[i].isalpha():
tmp+='1'
elif name[i] in vow and name[i].isalpha():
tmp+='0'
print( int(tmp, 2)% (10**9 + 7)) | |
d1047 | for t in range(int(input())):
limakMax, bobMax = list(map(int, input().split()))
limakEat = 0; bobEat = 0
eating = 1
while limakEat <= limakMax or bobEat <= bobMax:
if eating % 2 != 0 and limakEat <= limakMax:
limakEat += eating
eating += 1
if limakEat > limakMax:
print("Bob")
break
elif eatin... | |
d1048 | import sys
def input(): return sys.stdin.readline().strip()
def iinput(): return int(input())
def rinput(): return list(map(int, sys.stdin.readline().strip().split()))
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
t=iinput()
for _ in range(t):
n=iinput()
p=[]
mi=[]
for i in... | |
d1049 | t=int(input())
for i in range(t):
a,k=list(map(int,input().split()))
x1,x2,x3=list(map(int,input().split()))
big=max(x1,x2,x3)
small=min(x1,x2,x3)
q=big-small-2*k
if q>=a:
print(0)
elif -1*q>=0:
print(a*a)
else:
print(a*(a-q))
| |
d105 | from sys import stdin
input = stdin.readline
q = int(input())
for rwerew in range(q):
n = int(input())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
for i in range(n):
p[i] -= 1
przyn = [0] * n
grupa = []
i = 0
while i < n:
if przyn[i] == 1:
i += 1
else:
nowa_grupa = [i]
j... | |
d1050 | #
for _ in range(int(input())):
n,k = list(map(int,input().split()))
arr = list(map(int,input().split()))
s=set(arr)
t1=len(s)
max=-1
for i in range(n-k+1):
temp=set(arr[i:i+k])
#print(temp,i,k+i+1)
t=len(temp)
if t1 == t:
if max<sum(arr[i:k+i]):
max=sum(arr[i:k+i])
print(max)
| |
d1051 | # cook your dish here
t=int(input())
for j in range(t):
s=input()
st=[]
ans=0
for i in range(len(s)):
if(s[i]=='>'):
if(len(st)!=0 and st[-1]=='<'):
st.pop()
if(len(st)==0):
ans=i+1
else:
break
... | |
d1052 | # cook your dish here
t=int(input())
for i in range(0,t):
my_ip = int(input().strip())
for xyz in range(my_ip+1):
for abc in range(0,xyz+1):
if abc == xyz:
print(xyz,end="")
else:
print('*',end="")
print() | |
d1053 | from collections import deque
T=int(input())
def break_down(num):
count=0
while(len(num)!=1):
temp=0
for i in range(0,len(num)):
temp=temp+int(num[i])
num=str(temp)
count=count+1
return (int(num),count)
def digit_sum(num):
temp=0
for i in ran... | |
d1054 | # cook your dish here
for _ in range(int(input())):
n=int(input())
A=list(map(int,input().split()))
A.sort()
for i in range(len(A)):
if A[i]==1:
print(i)
break | |
d1055 | test=int(input())
for i in range(test):
s=input()
b=len(s)
list1=[]
for j in range(len(s)):
if s[j]=='.':
list1.append(j)
for i in list1:
if b-i-1 in list1 :
if i!=b-i-1 and ((s[i] and s[b-i-1]) != 'a' ):
s=s[:i]+'a'+s[i+1:b-i-1]+'a'+s[b-i:]
... | |
d1056 | # cook your dish here
m,n=[int(i) for i in input().split()]
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
ans=0
w=0
q=m
for m in range(q):
if(arr[m]>n):
w=1
break
ans+=1+(arr[m]*(arr[m]+1))//2
n-=arr[m]
if(n==0):
print(ans)
else:
if(w==1):
... | |
d1057 | n=int(input())
for i in range(n):
a,b,c=map(int,input().split())
if a>0 and b>0 and c>0 and a+b+c==180:
print("YES")
else:
print("NO") | |
d1058 | import math
def magic(a,digits):
m=a%10
if(m==4):
return a+3
elif(m==7):
p=list(str(a))
#print p
for i in range(digits-1,-1,-1):
#print p[i]
if (p[i]=='4'):
#print 'four'
p[i]='7'
p = ''.join(str(n) for ... | |
d1059 | # cook your dish here
t=int(input())
for i in range(0,t):
p=input()
l=list(p)
for j in range(0,len(l)):
l[j]=int(l[j])
l[j]=l[j]-2
for j in range(0,len(l)):
l[j]=str(l[j])
q=''.join(l)
print(q) | |
d106 | import math
t = int(input())
for test in range(t):
n,k = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(1,n):
if(A[i]>k):
ans = 0
break
rem = k-A[i]
ans+=rem//A[0]
print(ans) | |
d1060 | n = int(input())
a = []
for i in range(n):
a.append(int(input()))
m1 = 0
m2 = 0
for e in a:
if (e > m1):
m2 = m1
m1 = e
elif (e > m2 and e != m1):
m2 = e
ans = 0
for e in a:
temp = m1%e
if (temp>ans):
ans = temp
print(max(m2%m1,ans)) | |
d1061 | def countSubstr(str, n, x, y):
tot_count = 0
count_x = 0
for i in range(n):
if str[i] == x:
count_x += 1
if str[i] == y:
tot_count += count_x
return tot_count
t=int(input())
for _ in range(t):
n=int(input())
str=input()
... | |
d1062 | # cook your dish here
def value(a, b, c):
if(c == '&'):
return a&b
elif(c == '^'):
return a^b
elif(c == '|'):
return a|b
def break_rules(n, operator):
if(len(n) == 1):
return n
elif(len(n) == 2):
return [value(n[0], n[1], operator[0])]
else:
cont_... | |
d1063 | # cook your dish here
def read_i_l(l=False):
m = list(map(int, input().strip().split(" ")))
if l:
return list(m)
else:
return m
def i():
return int(input().strip())
T = i()
L = []
"""for current in range(T):
line = ""
for i in range(current):
line+=str((T-i)%10)
for i... | |
d1064 | number = int(input())
for i in range(number):
x = list(map(int, input().split(' ')))
print(x[0]%x[1]) | |
d1065 | from math import gcd
import sys
input=lambda : sys.stdin.readline().strip()
c=lambda x: 10**9 if(x=="?") else int(x)
def main():
for _ in range(int(input())):
s=list(input())[::-1]
l=['F','E','H','C']
i=0
while(i<len(s)):
if(i+3<len(s)):
f=True
for j in range(i,i+4):
if(l[j-i]==s[j] or s[j]=='?... | |
d1066 | # cook your dish here
for a in range(int(input())):
N,M=map(int,input().split())
b=[]
for o in range(N):
b.append(input())
c=[]
for d in b:
f=[]
for e in range(len(d)):
if d[e]=='1':
f.append(e)
c.append(f)
i=[]
for g in range(len(c)):
for h in range(len... | |
d1067 | for _ in range(int(input())):
n=input().rstrip()
n=[ele for ele in n]
l=len(n)
m=10**18+8
ini=1
for i in range(l-1,-1,-1):
if int(n[i])<=m:
if ini==1:
m=int(n[i])
else:
m=max(m,n[i])
else:
m=int(n[i])-1
n[i]=str(m)
for j in range(l-1,i,-1):
n[j]='9'
i=0
while n[i]=='0':
i+=1... | |
d1068 | # Fibonacci Series using
# Optimized Method
# function that returns nth
# Fibonacci number
MOD = 1000000007
def fib(n):
F = [[2, 2],
[1, 0]]
power(F, n - 1)
ans = [6, 2]
return (F[0][0] * 6 + F[0][1] * 2) % MOD
# return F[0][0]
def multiply(F, M):
x = (F[0][0] * M[... | |
d1069 | # cook your dish here
t=int(input())
for _ in range(t):
N, M=map(int,input().split())
if(N%2==0 or M%2==0):
print("YES")
else:
print("NO") | |
d107 | t = int(input())
for ti in range(t):
n = int(input())
lri = [None for _ in range(n)]
for _ in range(n):
li, ri = list(map(int, input().split()))
lri[_] = (li, ri, _)
lri.sort()
t = [None for _ in range(n)]
ct, t[lri[0][2]], eg = 1, 1, lri[0][1]
for i in range(1, n):
if lri[i][0] <= eg:
t[lri[i][2... | |
d1070 | #Note that it's python3 Code. Here, we are using input() instead of raw_input().
#You can check on your local machine the version of python by typing "python --version" in the terminal.
#Read the number of test cases.
T = int(input())
for tc in range(T):
# Read integers a and b.
(a, b) = list(map(int, input().split(... | |
d1071 | # cook your dish here
# cook your dish here
class Animal:
def __init__(self):
start, end, starting_time = map(int, input().split())
self.ending_time = starting_time + abs(start - end)
self.velocity = 1 if end >= start else -1
self.eaten_by = -1, 10 ** 10
... | |
d1072 | # cook your dish here
t=int(input())
while t>0:
n,q=list(map(int,input().split()))
blst=[0]
for i in range(1,65):
blst.append(0)
i=1
while n>0:
if n%2:
blst[i]=1
n//=2
i+=1
while q>0:
n=int(input())
if n==1:
p=int(input())
... | |
d1073 | t=int(input())
for i in range(t):
n=int(input())
r=int(n**(.5))
d=n-r*r
m=d%r
print('X'*m+'D'*(m>0)+'X'*(r-m)+'D'*(r+d//r))
| |
d1074 | import sys
def fin(): return sys.stdin.readline().strip()
def fout(s, end="\n"): sys.stdout.write(str(s)+end)
MOD = pow(10, 9)+7
t = int(input())
while t>0:
t -= 1
n, m = list(map(int, fin().split()))
if n == 1:
print(m%MOD)
continue
dp1 = m*(m-1)
dp2 = m
for i in range(3, n+1):
temp = dp2
dp2 = dp1
d... | |
d1075 | # cook your dish here
t=int(input())
j=0
while j<t:
n=int(input())
lst=list(map(int,input().split()))
s=set()
d=list()
for i in lst:
if i in s:
s.remove(i)
d.append(i)
else:
s.add(i)
x=len(d)
if x%2==0:
print(x//2)
else:
... | |
d1076 | gb = [0, 1, 2, 2, 3, 3]
ga = [0 for x in range(70)]
gag = [0 for x in range(70)]
ga[0] = 1
gag[0] = 0
for i in range(1, 70):
if i % 4 == 0:
ga[i] = 1.5 * ga[i-1]
gag[i] = 0
else:
ga[i] = 2 * ga[i-1]
gag[i] = gag[i-1] + 1
def g(n):
if n < 6:
return gb[n]
else:
x = n / 6
a = 0
for i, k in enumerate... | |
d1077 | # cook your dish here
class TestCase:
def __init__(self):
[self.node_count, self.query_count] = read_line()
def fill_nodes(self):
self.nodes = {n+1: [] for n in range(self.node_count)}
for i in range(self.node_count -1):
new_node_1, new_node_2 = read_line()
... | |
d1078 | t = int(input())
for i in range(t):
n = int(input())
dir = []
for j in range(n):
dir.append(input().strip().split())
for j in range(n-1):
if dir[j+1][0] == 'Right':
dir[j][0] = 'Left'
else:
dir[j][0] = 'Right'
dir[n-1][0] = 'Begin'
for j... | |
d1079 | t=int(input())
for i in range(t):
n,w1,w2,w3=map(int,input().split())
if n>=w1+w2+w3:
print(1)
elif n>=w1+w2 or n>=w2+w3:
print(2)
else:
print(3) | |
d108 | t = int(input())
for _ in range(t):
a, b, c, d = [int(i) for i in input().split(" ")]
sgn = (a+b)%2
small = False
large = False
if a == 0 and d == 0:
small = True
if b == 0 and c == 0:
large = True
okay = [True] * 4
if sgn == 0:
okay[0] = False
okay[1] = False
else:
okay[2] = False... | |
d1080 | # cook your dish here
x=int(input())
for i in range(x):
h=input()
print(h.count('4'))
| |
d1081 | def res(s):
if len(s) == 2:
if s[0] == s[1]:
print("NO")
else:
print("YES")
elif s[0] != s[1]:
counte = 0
for i in range(2, len(s)):
if i % 2 == 0:
if s[i] != s[0]:
counte = 1
break
else:
if s[i] != s[1]:
counte = 1
break
if counte == 0:
print("YES")
else:
p... | |
d1082 | # cook your dish here
import string
from collections import OrderedDict
from itertools import zip_longest
dic = OrderedDict(zip(string.ascii_uppercase, range(0, 26)))
keys = [98, 57, 31, 45, 46]
t = int(input()) # number of test cases
s1 = []
for i in range(t):
s = input()
for i in s:
if i in dic.keys():
... | |
d1083 | counter = -1
def flattree(node):
nonlocal counter
if visited[node]==1:
return
else:
visited[node]=1
counter += 1
i_c[node] = counter
flat_tree[counter] = swt[node]
for i in graph[node]:
if visited[i]==0:
flattree(i)
... | |
d1084 | for i in range(eval(input())):
n,m,z,l,r,b = list(map(int, input().split()))
rows=n
columns=m
hand_rest=n*(m+1)
if(m%2==0):
hand_rest -=max(0,n-l-r)
if(l+r+(2*b)<=hand_rest):
# print "kanu"
print(min(n*m,l+r+z+b))
else:
temp=l+r+(hand_rest-l-r)/2
# print "parth"
print(min(n*m,temp+z)) | |
d1085 | # cook your dish here
s=input()
s1=s[::-1]
arr=[]
cnt=0
for i in range(len(s1)):
arr.append(s1[i])
for i in range(len(arr)):
if(arr[i]=="1"):
for j in range(i,len(arr)):
if(arr[j]=="1"):
arr[j]="0"
else:
arr[j]="1"
cnt+=1
print(cnt) | |
d1086 | d = {}
for i in range(26):
char = chr(i+ord('a'))
d[char] = []
for i in range(26):
char = chr(i+ord('a'))
temp = list(map(int,input().strip().split()))
for j in range(26):
if (temp[j] == 1):
follow= chr(j+ord('a'))
d[follow].append(char)
def f(char,i,n,count):
if (i==n):
return count+1
else:
ans ... | |
d1087 | # cook your dish here
mod = 10**9 + 7
from math import gcd
def fac50():
f = [0]*51
f[0] ,f[1] = 1,1
for i in range(1,51):f[i] = (f[i-1]*i)%mod
return f
def gcd110():
gc = [[0]*111 for i in range(111)]
for i in range(111):
for j in range(111):gc[i][j] = gcd(i,j)
return gc
factorials,g... | |
d1088 | #!/usr/bin/env python
def iscycle(E, v, EXPLORED_NODES, EXPLORED_EDGES):
EXPLORED_NODES.add(v)
r = False
for e in [x for x in E if v in x]:
if e in EXPLORED_EDGES: continue
if e[0] == v: w = e[1]
else: w = e[0]
if w in EXPLORED_NODES:
return True
else:
EXPLORED_EDGES.add(e)
r = r or iscyc... |
AppsRetrieval — RTEB open subset, unified schema
A normalised copy of the dataset behind the mteb task AppsRetrieval, one of the 17 open tasks in the
RTEB(beta) retrieval benchmark. Same queries, documents and relevance
judgements as the benchmark evaluates — reshaped into one strict schema shared by all 17.
| Source | CoIR-Retrieval/apps @ f22508f96b7a (the revision pinned in mteb) |
| Domain · languages | code · eng |
| Queries / documents / qrels | 3,765 / 8,765 / 3,765 |
| Qrels per query | min 1 · mean 1.0 · max 1 |
| Score values | 1 ×3,765 |
| Layout | queries · corpus · qrels, split test |
| License | mit |
Schema
| config | columns | rules |
|---|---|---|
queries |
id: string, text: string |
ids unique and non-empty; every query has ≥ 1 qrel |
corpus |
id: string, title: string, text: string |
title is always present ("" when the source has none) |
qrels |
query-id: string, corpus-id: string, score: int32 |
referential integrity to both tables; no duplicate pairs; no floats |
Files are Parquet, sorted by id, zstd-compressed, sharded at 500 MB. Every rule above is enforced by a validator
before publishing; provenance.json records the source file hashes, what changed, and the output file hashes.
What changed from the source
- byte-preserved all text — no whitespace or newline normalisation (code dataset)
- cast
qrels.scoreint64 -> int32 - dropped 5,000 queries that have no qrels in the evaluated split (mteb does the same at load time)
- dropped non-schema columns from
corpus:partition,language,meta_information - dropped non-schema columns from
queries:partition,language,meta_information,title - renamed
_id→id - renamed source splits (
queries←queries/queries,corpus←corpus/corpus,qrels←default/test) totest
Load it
from datasets import load_dataset
queries = load_dataset("Hyukkyu/rteb-AppsRetrieval", "queries", split="test")
corpus = load_dataset("Hyukkyu/rteb-AppsRetrieval", "corpus", split="test")
qrels = load_dataset("Hyukkyu/rteb-AppsRetrieval", "qrels", split="test")
License and attribution
The data is redistributed under the source's terms — mit. All credit belongs to the
original authors; see the source repository and the references in mteb's task metadata (https://arxiv.org/abs/2105.09938).
This repository is an independent repackaging and is not affiliated with the RTEB or MTEB maintainers.
- Downloads last month
- 26