Dataset Preview
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code: DatasetGenerationCastError
Exception: DatasetGenerationCastError
Message: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 1 new columns ({'bad_solution'}) and 1 missing columns ({'output'}).
This happened while the json dataset builder was generating data using
hf://datasets/Roxygr/code_repair-1/questions.jsonl (at revision 892f5689b9e9b0f8f20f2ba4edfbb823d48aa0c9)
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback: Traceback (most recent call last):
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2013, in _prepare_split_single
writer.write_table(table)
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table
pa_table = table_cast(pa_table, self._schema)
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast
return cast_table_to_schema(table, schema)
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2256, in cast_table_to_schema
raise CastError(
datasets.table.CastError: Couldn't cast
id: int64
bad_solution: string
to
{'id': Value(dtype='int64', id=None), 'output': Value(dtype='string', id=None)}
because column names don't match
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1396, in compute_config_parquet_and_info_response
parquet_operations = convert_to_parquet(builder)
File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1045, in convert_to_parquet
builder.download_and_prepare(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1029, in download_and_prepare
self._download_and_prepare(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1124, in _download_and_prepare
self._prepare_split(split_generator, **prepare_split_kwargs)
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1884, in _prepare_split
for job_id, done, content in self._prepare_split_single(
File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2015, in _prepare_split_single
raise DatasetGenerationCastError.from_cast_error(
datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
All the data files must have the same columns, but at some point there are 1 new columns ({'bad_solution'}) and 1 missing columns ({'output'}).
This happened while the json dataset builder was generating data using
hf://datasets/Roxygr/code_repair-1/questions.jsonl (at revision 892f5689b9e9b0f8f20f2ba4edfbb823d48aa0c9)
Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
id int64 | output string |
|---|---|
1 | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
n, *a = map(int, read().split())
maxa = max(a) + 1 # aはint配列
d = [i for i in range(maxa)]
for p0 in range(2, maxa):
if p0 == d[p0]:
for p1 in range(p0 ** 2, maxa, p0):
... |
2 | from bisect import bisect_right
import math
N,D,A = map(int,input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
X.insert(0,[-1,-1])
def update(m,i,j,a): #ノード値の更新 i<=x<j
l,r = T[m][0]
if r<=i or l>=j:
return
if i<=l and r<=j:
T[m][1] -= a*(r-l)
... |
3 | def _main(N, M, K, A, B):
sum_k = 0.0
a_index = 0
A_len = len(A)
b_index = 0
B_len = len(B)
while sum_k < K:
current_a = A[a_index] if a_index < A_len else None
current_b = B[b_index] if b_index < B_len else None
if current_a is None and current_b is None:
bre... |
4 | def calc(n, N, x):
m, M = -1, -1
L, R = 0, 10**18
while L+1 < R:
P = (L+R)//2
if n <= x*P:
R = P
else:
L = P
if n <= x*R <= N:
m = x*R
L, R = 0, 10**18
while L+1 < R:
P = (L+R)//2
if N < x*P:
R = P
else:
... |
5 | import sys
def chk(i,j):
tmp=[p[i][k] for k in range(M)]
tmp[j]=p[i][j]+1
for k in range(M-1,-1,-1):
if tmp[k] > p[i+x[j]][k] :
p[i+x[j]]=[tmp[k] for k in range(M)]
return
N,M=map(int,input().split())
x=[0,2,5,5,4,5,6,3,7,6]
a=list(map(int,input().split()))
a.sort()
b=[]
fo... |
6 | import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().sp... |
7 | from typing import List
def FUNC(numbers: List[float], threshold: float) -> bool:
""" Check if in given list of numbers, are any two numbers closer to each other than
given threshold.
>>> FUNC([1.0, 2.0, 3.0], 0.5)
False
>>> FUNC([1.0, 2.8, 3.0, 4.0, 5.0, 2.0], 0.3)
True
"""
for idx, e... |
8 | def main():
import sys
H, W = map(int, sys.stdin.readline().split())
A = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
B = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
X = [[None] * W for i in range(H)]
for h in range(H):
for w in range(W):
... |
9 | import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))
h, w = lmi()
s = [input() for i in range(h)]
a = [[] for i in range(h)]
al = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
k = 0
for j in ... |
10 |
def main():
H, W = map(int, input().split()) # 横に2個
state = [[0 if a == '.' else 1 for a in list(input())] for _ in range(H)]
checked = [[False for _ in range(W+1)] for _ in range(H+1)]
qs = []
for h in range(H):
for w in range(W):
if state[h][w] == 1:
qs.append... |
11 | import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10**9 + 1
N, M = map(int, readline().split())
data = np.array(read().split(), np.int64)
A = data[::3]
B = data[1::3]
C = data[2::3]
D = A[N:]
E = B[N:]
... |
12 | #!/usr/bin/env python3
# vim: set fileencoding=utf-8
# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation
"""Module docstring
"""
import functools
import heapq
import itertools
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from co... |
13 |
def submit():
n = int(input())
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
# 順番にグリーディ
a = alist.copy()
b = blist.copy()
score_a = 0
for i in range(0, n):
if a[i] < b[i]:
score_a += a[i]
b[i] -= a[i]
a[i] ... |
14 | """ B
https://atcoder.jp/contests/abc175/tasks/abc175_b
"""
import sys
import math
from functools import reduce
from bisect import bisect_left
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def readStringSet(n):
return sys.stdin.readline().split(" ")[:n]
de... |
15 | from collections import deque,defaultdict
import bisect
N = int(input())
S = [input() for i in range(N)]
def bend(s):
res = 0
k = 0
for th in s:
if th == '(':
k += 1
else:
k -= 1
res = min(k,res)
return res
species = [(bend(s),s.count('(')-s.count(')')) ... |
16 | import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
import copy
def input():
return sys.stdin.readline()[:-1]
def ruiseki(lst):
return [0]+list(accumulate(lst))
mod=pow(10,9)+7
n=int(input())
s=... |
17 | n,a,b=map(int,input().split())
mod=10**9+7
J=pow(2,n)%mod
def find_power(n,mod):
# 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである)
powlist=[0]*(n+1)
powlist[0]=1
powlist[1]=1
for i in range(2,n+1):
powlist[i]=powlist[i-1]*i%(mod)
return powlist
def find_inv_power(n):
#0!からn!までの逆元を素数10... |
18 | import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return... |
19 | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permut... |
20 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... |
21 | # /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd
from itertools import permutations
def lcm(a, b):
return (a*b) // gcd(a,b)
def intinput():
return int(input())
def mulinputs():
return map(int,input().sp... |
22 | import sys
input = sys.stdin.readline
import math
INF = 1e+11
A,B,Q=map(int, input().split())
s = [[0] for _ in range(A+2)]
t = [[0] for _ in range(B+2)]
s[0]=-INF
t[0]=-INF
for i in range(A):
s[i+1]=int(input())
for i in range(B):
t[i+1]=int(input())
s[A+1]=INF
t[B+1]=INF
x = [int(input()) for _ in range(Q)]... |
23 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
import collections
class Node(object):
def __init__(self):
self.edges = set()
self.distance = 1
def main():
N = int(input())
nodes = [Node() for _ in range(N)]
if N == 0:
print('Second', flush=True)
return
elif N == 1:
print('First', flus... |
24 | from collections import Counter
def find_key_from_value(input_dict, target_value):
return [key for key, value in input_dict.items() if value == target_value][0]
N = int(input())
V= list(map(int,input().split()))
eve, odd = Counter([V[i] for i in range(0,N,2)]), Counter([V[i] for i in range(1,N,2)])
eve_key = fin... |
25 | def rev(a):
L = []
for i in range(N):
L.append(a % 3)
a //= 3
return int("".join(map(str, L)), 3)
def salsa():
lazy[0] *= -1
def rumba():
i = 0
for k in range(N):
if lazy[i] < 0:
lazy[3*i+1] *= -1
lazy[3*i+2] *= -1
lazy[3*i+3] *= ... |
26 | from typing import List
def FUNC(paren_string: str) -> List[str]:
""" Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
separate those group into separate strings and return the list of those.
Separate groups are balanced (each open brace is properly clos... |
27 | from collections import defaultdict
def solve():
n = int(input())
v = list(map(int, input().split()))
evens = v[::2]
odds = v[1::2]
d_even, d_odd = defaultdict(int), defaultdict(int)
for e in evens:
d_even[e] += 1
for o in odds:
d_odd[o] += 1
# if top_e != top_o:
#... |
28 |
def FUNC(number: float) -> float:
""" Given a positive floating point number, it can be decomposed into
and integer part (largest integer smaller than given number) and decimals
(leftover part always smaller than 1).
Return the decimal part of the number.
>>> FUNC(3.5)
0.5
"""
return ... |
29 | import heapq
class pqheap:
def __init__(self):
self.p = list()
self.q = list()
def insert(self,x):
heapq.heappush(self.p, x)
return
def erase(self,x):
heapq.heappush(self.q, x)
return
def minimum(self):
while self.q and self.p[0] == self.q[0]:
... |
30 | import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return sys.stdin.readline()[:-1]
def main():
n = II()
s = S()
inf = n + 2
m = [[0 for i in range(n)] for i in ... |
31 | from typing import List
def FUNC(operations: List[int]) -> bool:
""" You're given a list of deposit and withdrawal operations on a bank account that starts with
zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
at that point function should return True. Oth... |
32 | # coding: utf-8
import sys
from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as n... |
33 | from typing import List
def FUNC(numbers: List[float]) -> float:
""" For a given list of input numbers, calculate Mean Absolute Deviation
around the mean of this dataset.
Mean Absolute Deviation is the average absolute difference between each
element and a centerpoint (mean in this case):
MAD = av... |
34 | #!/usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import bisect
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
# INF = sys.maxsize
INF = 10 ** 10
# INF = float("inf")
def dp(*x): # debugprint
print(*x)
f = open(sys.argv[1])
input = f.buf... |
35 | # E
N=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
if a>b:
a,b=b,a
while a%b:
a,b=b,(a%b)
return b
def fast_factorization_init(N):
res=list(range(N))
for i in range(2,N):
if i*i>N:
break
for j in range(i*i,N,i):
if res[j]==j:
... |
36 | from heapq import heappush, heappop
from collections import defaultdict
N, K = map(int, input().split())
TD = [list(map(int, input().split())) for _ in range(N)]
DT = [[d, t] for t, d in TD]
DT.sort(reverse = True)
#print(DT)
h_in = []
cnt = defaultdict(int)
tmp = []
kiso = 0
for d, t in DT:
if cnt[t] == 0:
... |
37 |
n, k = [0] * 2
a = []
def format_input(filename = None):
global n, k
global a
if filename == None:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
elif filename == '__random__':
from random import randint as rng
n = rng(2, 2 * 10**5)
k = rng(1, 10**18)
a = [rng(1, n) for i... |
38 | #####segfunc#####
def segfunc(x, y):
if x[0]>y[0]:
return y
elif x[0]<y[0]:
return x
elif x[1]>y[1]:
return y
else:
return x
#################
#####ide_ele#####
ide_ele = (float("inf"),-1)
#################
class SegTree:
"""
init(init_val, ide_ele): 配列init_valで... |
39 | #!/usr/bin/env python3
import sys
def factoring(n: int):
factors = []
p = 1
while p * p <= n:
if n % p == 0:
factors.append(p)
if n != p * p:
factors.append(n // p)
p += 1
return factors
def solve(N: int, M: int):
if N == 1:
print(M)
... |
40 | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1,... |
41 | class SegmentTree:
def __init__(self,siz,v = 0):
self.n = 1
self.v = v
while self.n < siz: self.n *= 2
self.node = [self.v]*(2*self.n-1)
def merge(self,x,y): return x | y
def update(self,i,x):
i += self.n-1
self.node[i] = x
while i > 0:
i... |
42 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7
DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(... |
43 | import sys
input=sys.stdin.readline
import collections
def main():
N = int(input())
Q = [collections.deque(map(int, input().split())) for _ in range(N)]
games = N*(N-1)//2
days = 0
while True:
gamed = [0 for _ in range(N)]
b = False
for i in range(len(Q)):
if ga... |
44 | from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
return int(input())
#入力:N,M(int:整数)
def input2():
return map(int,input().split())
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
return list(ma... |
45 | from typing import List
def FUNC(numbers: List[int], delimeter: int) -> List[int]:
""" Insert a number 'delimeter' between every two consecutive elements of input list `numbers'
>>> FUNC([], 4)
[]
>>> FUNC([1, 2, 3], 4)
[1, 4, 2, 4, 3]
"""
if not numbers:
return []
result = []... |
46 | import math
def main():
N,D,A = map(int, input().split())
X,H = [0]*N,[0]*N
tmp = [(0,0) for _ in range(N)]
for i in range(N):
tmp[i] = list(map(int, input().split()))
tmp[i][0] -= 1
# 座標順になるようにソートしておく
tmp = sorted(tmp, key=lambda x:x[0])
for i,l in enumerate(tmp): (X[i],H[i]... |
47 | from typing import List
def FUNC(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((... |
48 | N, M = map(int, input().split())
A = list(map(int, input().split()))
def dfs(choices, s, cost, i):
if i == len(choices):
return -1
if cost == 0:
return int(s)
if cost < 0:
return -1
tmp1 = dfs(
choices,
s + str(choices[i][0]),
cost - choices[i][... |
49 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for ... |
50 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))
from collections import defaultdict
def main():
n, m = map(int, input().split())
a = []
for _ in range(n):
a.append(list(map(int, input().split())))
sports = [1 for _ in range(m)]
ans = 10**18
for _ in range(m-1):
... |
51 | import sys
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readints():return list(map(int,readline().split()))
h,w = readints()
start = readints()
start = (start[0]-1)*w + start[1]-1
goal = readints()
goal = (goal[0]-1)*w + goal[1]-1
maze = [readstr() for i in range(h)]
d... |
52 | from bisect import bisect_left
def main():
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
a[i] += a[i - 1]
for i in range(1, m):
b[i] += b[i - 1]
answer = 0
if a[-1] + b[-1] <= k:
pri... |
53 | import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
def input():
return sys.stdin.readline().rstrip()
def main():
N=int(input())
d={}
c=0
edge1=[[] for _ in range(N*(N-1)//2)]
edge2=[[] for _ in range(N*(N-1)//2)]
for i in range(N):
l=list(map(lambda x: ... |
54 | import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
tmp=gcd(tmp,a[i])
if tmp>1:
print('not coprime')
exit()
# pairwize coprime なら素因数が2度現れることはない
def f(x):
res=set()
for i in range(2,int(x**(1/2)... |
55 | from itertools import accumulate,chain
import sys
sys.setrecursionlimit(10000000)
MOD = 10**9+7
# mを法とするときのa^n
def modpow(a,n,m):
res = 1
t = a
while n:
if n%2:
res = (res*t)%m
t = (t*t)%m
n //= 2
return res
# factorio = tuple(chain((1,),accumulate(range(1,N+1), ... |
56 | def main():
from bisect import bisect_right
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
def calc(x):
tmp = 0
for a in A:
tmp += N - bisect_right(A, x - a - 0.5)
return tmp
l = 0
r = 3 * 10 ** 5
while r - l > 1:
... |
57 | from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline
def main():
n, a, b, c... |
58 | from typing import List
def FUNC(strings: List[str], substring: str) -> List[str]:
""" Filter an input list of strings only for ones that contain given substring
>>> FUNC([], 'a')
[]
>>> FUNC(['abc', 'bacd', 'cde', 'array'], 'a')
['abc', 'bacd', 'array']
"""
return [x for x in strings if x... |
59 | def main():
_range = range
h, w = map(int, input().split())
s = [input() + '#' for _ in _range(h)]
s.append('#' * (w + 1))
t = [[-1] * w for _ in _range(h + 1)]
tstart = [-1] * (w + 1)
for i in _range(h + 1):
ystart = -1
si = s[i]
ti = t[i]
for j in _range(w + 1):
if si[j] == '#':
... |
60 | n = int(input())
s = list(map(str, input().strip()))
seed = 13331
mod = 10 ** 9 + 7
lsd = [1] * 6000
hs = [1] * 6000
hs[0] = ord(s[0]) - ord('a')
for i in range(1, n):
lsd[i] = lsd[i - 1] * seed % mod
hs[i] = (hs[i - 1] * seed + ord(s[i]) - ord('a')) % mod
def check(x):
from collections import defaultdict... |
61 | def kakaka():
a = list(map(int, input().split()))
b = map(int, input().split())
c = int(input())
def start_process():
return
def main():
all_num, inst_num = map(int, input().split())
data = list(input())
data_la = []
ans_0, ans_1 = 0, 0
for i in range(all_num):
if data[i] =... |
62 | from pprint import pprint
import queue
def solve(n, a, b):
state = queue.Queue()
state.put((0, b[:]))
while not state.empty():
count, b_tmp = state.get()
# print("next:" + str(count))
# pprint(b_tmp)
for i, b_i in enumerate(b_tmp):
i_a = (i - 1 + n) % n
... |
63 | import sys
input = sys.stdin.readline
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def sieve_optimized(limit):
# Preprocessing step takes O(N log log N) time complexity.
n = limit
# Filimitd all primes upto n (including n)
sievebound = (n-1)//2
sieve = [-1]*(sievebound ... |
64 | import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().spli... |
65 | def solve(n, m, work_list):
# 1-origin
dp = [[0] * (m + 1) for i in range(n + 1)]
# time O(N log(N))
work_list.sort()
# time O(NM)
for key, value in enumerate(work_list, 1):
work_day, work_value = value[0], value[1]
prev_key = key - 1
for day in range(1, m + 1):
... |
66 | def main():
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
maxA = max(A)
prime = [i % 2 != 0 for i in range(maxA+1)]
prime[2] = True
f = [False] * (maxA+1)
for i in range(3, int(maxA**.5)+1):
... |
67 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
#from mat... |
68 | from typing import List, Tuple
def FUNC(numbers: List[int]) -> Tuple[int, int]:
""" For a given list of integers, return a tuple consisting of a sum and a product of all the integers in a list.
Empty sum should be equal to 0 and empty product should be equal to 1.
>>> FUNC([])
(0, 1)
>>> FUNC([1, ... |
69 | class RollingHash:
def __init__(self, s):
b1, b2 = 1007, 2009
self.mod1, self.mod2 = 10**9+7, 10**9+9
self.size = len(s)
self.string = s
self.hash1 = self.make_hashtable(b1, mod1)
self.hash2 = self.make_hashtable(b2, mod2)
self.pow1 = self.make_powtable(b1, m... |
70 | def get_cache(chars, start, end, cache=dict()):
pair = (start, end)
block = cache.get(pair)
if block is not None:
return block
else:
block = chars[start:end]
cache[pair] = block
return block
def get_skip(chars, previous_start, previous_end, cache=dict()):
pair = (pr... |
71 | N,K = list(map(int,input().split()))
sys.setrecursionlimit(10**10)
A = input()
A = list(A)
A = list(map(int,A))
def serch_right(x,K,t):
global count0,count1
if x<0 or len(A)<=x:
return count1
if A[x]==0:
if t == 0:
t=0
count1 +=1
elif t==1 :
if co... |
72 | from typing import List, Tuple
def FUNC(numbers: List[int]) -> List[int]:
""" From a given list of integers, generate a list of rolling maximum element found until given moment
in the sequence.
>>> FUNC([1, 2, 3, 2, 3, 4, 2])
[1, 2, 3, 3, 3, 4, 4]
"""
running_max = None
result = []
fo... |
73 | #単位元を設定
ide = 0
class SegmentTree:
def __init__(self,n):
#セグ木の頂点はindex == 1から。index == 0は無視すること。
#つまり、STtable[0]は無視。頂点はSTtable[1]。
self.n = n
tmp = 0
while True:
if 2 ** tmp >= self.n:
break
tmp += 1
self.STtable = [ide] * (2*2**tmp)
self.STtable_size = len(self.STtable)
def upda... |
74 |
def FUNC(string: str) -> bool:
""" Test if given string is a palindrome """
return string == string[::-1]
def FUNC(string: str) -> str:
""" Find the shortest palindrome that begins with a supplied string.
Algorithm idea is simple:
- Find the longest postfix of supplied string that is a palindrom... |
75 | N = int(input())
A = list(map(int, input().split()))
N = len(A) // 3
A = A[:3*N]
#print(N, A)
A.append(0)
A.append(0)
ans = 0
def ind(a, b):
t = sorted((a, b))
return t[0] * (N+1) + t[1]
def inv(i):
b = i % (N+1)
a = i // (N + 1)
return a, b
dp = [-1] * (N+1)**2
dp[ind(A[0],A[1])] = 0
dp1 = [-1] * (N+1)
dp1... |
76 | import collections
from scipy.sparse.csgraph import floyd_warshall
import sys
sys.setrecursionlimit(10**8)
n=int(input())
arr=[input() for _ in range(n)]
g=[[] for _ in range(n)]
for i in range(n):
for j in range(n):
if i==j:
continue
if arr[i][j]=='1':
g[i].append(j)
colors=[0]*n
def dfs(v,col... |
77 | from math import gcd
def pairwise_coprime(a):
check = [set() for _ in range(10 ** 6 + 10)]
for i, aa in enumerate(a):
now = aa
while now % 2 == 0:
if i > 0 and len(check[2]) > 0 and i not in check[2]:
return False
now //= 2
check[2].add(i)
... |
78 | #!/usr/bin/env python3
INF = 10**7
import sys
input = sys.stdin.readline
from collections import*
def bfs(sx, sy, gx, gy, c):
q = deque([(sx, sy)])
dist = [[INF] * W for _ in range(H)]
dist[sx][sy] = 0
while q:
x, y = q.popleft()
if (x, y) == (gx, gy): return dist[gx][gy]
f... |
79 | from collections import deque
H,W = map(int,input().split())
maze = []
for i in range(H):
maze.append(input())
q = deque()
saitan = [1000000]*H*W
start = []
sumi= []
for i in range(H):
for k in range(W):
if maze[i][k] == '#':
start.append(i*W+k)
for i in start:
q.append(i)
sumi.appe... |
80 | #!/usr/bin/env python3
import sys
from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
n, m, k = MI()
a = deque(LI())
b = deque(LI())
read = []
... |
81 | from typing import List
def FUNC(a: str, b: str) -> str:
""" Input are two strings a and b consisting only of 1s and 0s.
Perform binary XOR on these inputs and return result also as a string.
>>> FUNC('010', '110')
'100'
"""
def FUNC(i, j):
if i == j:
return '1'
els... |
82 | from typing import List, Optional
def FUNC(strings: List[str]) -> Optional[str]:
""" Out of list of strings, return the FUNC one. Return the first one in case of multiple
strings of the same length. Return None in case the input list is empty.
>>> FUNC([])
>>> FUNC(['a', 'b', 'c'])
'a'
>>> FU... |
83 | from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator ... |
84 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
H,W,K = map(int, readline().split())
S = [list(map(int, readline().strip())) for j in range(H)]
print(H,W,S)
white = 0
for line in S:
white += sum(line)
if white <= K:
... |
85 | def examA():
N, A, B = LI()
if (A-B)%2==0:
ans = "Alice"
else:
ans = "Borys"
print(ans)
return
def examB():
K = I()
A = LI()
cur = 2
for i in range(K-1,-1,-1):
a = A[i]
if A[i]>cur:
print(-1)
exit()
cur = (cur//a+1)*a-1... |
86 | from collections import defaultdict
N = int(input())
L = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]
def make_hash(a, b):
a, b = min(a, b), max(a, b)
return N*a+b
def un_hash(n):
a = n//N
b = n % N
return a, b
from_to = defaultdict(lambda: set())
pointed = defaultdict(int... |
87 | def main():
import sys
sys.setrecursionlimit(1000000)
N = int(input())
A = [[]]
for _ in range(N):
A.append([0]+list(map(int,input().split())))
#AR[i][j] => iにとって選手jとの試合が何番目か
AR = [[]]
for i in range(1,N+1):
AR.append([0]*(N+1))
for j in range(1,N):
... |
88 | char_num = int(input())
char_length = 10
chars = []
for i in range(char_num):
chars.append(input())
class CharArrange:
def __init__(self, char):
self.char = char
def char_run(self):
list_char = self.str2ord_list(self.char)
for pos in range(1, len(list_char)):
self.inse... |
89 | import copy
from heapq import heappop, heapify, heappush
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
ans = 0
A.sort(reverse=True)
F.sort()
s = []
for i in range(N):
s.append([A[i]*F[i], A[i], F[i]])
s.sort(reverse=True, key=lambda x: x[0])... |
90 |
def FUNC(a: int, b: int) -> int:
""" Return a greatest common divisor of two integers a and b
>>> FUNC(3, 5)
1
>>> FUNC(25, 15)
5
"""
while b:
a, b = b, a % b
return b
|
91 | #!/usr/bin/env python3
import collections as cl
import sys
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def main():
N = II()
targets = LI()
MAX_INT = max(targets) + 1
t... |
92 | import sys
input = sys.stdin.readline
def main():
H,W = map(int,input().split())
CH,CW = map(int,input().split())
DH,DW = map(int,input().split())
S=[None]*H
for i in range(H):
S[i] = input()
from collections import deque
def cango_step(x,y):
cand =[]
if x+1<=H-1... |
93 | # -*- coding: utf-8 -*-
import sys
from collections import deque
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input(... |
94 | import sys
from collections import deque
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def solve(inputs):
head = int(inputs[0][:2])
tail = int(inputs[0][2:])
YY = 1
BOTH = 2
NA = -1
head_type = NA
tail_type = NA... |
95 | from typing import List
def FUNC(string: str) -> List[str]:
""" Return list of all prefixes from shortest to longest of the input string
>>> FUNC('abc')
['a', 'ab', 'abc']
"""
result = []
for i in range(len(string)-1):
result.append(string[:i+1])
return result
|
96 |
def FUNC(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> FUNC(0)
'0'
>>> FUNC(5)
'0 1 2 3 4 5'
"""
return ' '.join([str(x) for x in range(n)])
|
97 | import sys
import numpy as np
import math
def ReadInputNum():
input_num=[]
for i in range(5):
input_num.append(int(input()))
return tuple(input_num)
def CheckRangeInput(*argv):
for num in argv:
if num<=123 and isinstance(num,int):
pass
# print("good") ... |
98 | from copy import copy
n = int(input())
a = list(map(int, input().split()))
ok, ng = n, 0
while ok-ng > 1:
x = (ok+ng)//2
#d = defaultdict(int)
d = dict()
last = 0
valid = True
if x == 1:
for i in range(n-1):
if a[i] >= a[i+1]:
valid = False
break
if valid:
ok = x
else:
ng = x
continue
... |
99 | import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
H, W = list(map(int, input().split()))
grid = []
for i in range(H):
grid.append(input()[0:W])
num_yoko = [[0 for i in range(W)] for j in range(H)]
num_tate = [[0 for i in range(W... |
100 |
def FUNC(string: str) -> int:
""" Given a string, find out how many distinct characters (regardless of case) does it consist of
>>> FUNC('xyzXYZ')
3
>>> FUNC('Jerry')
4
"""
return len(set(string))
|
End of preview.
README.md exists but content is empty.
- Downloads last month
- 132