s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s008310611 | p02540 | u274811210 | 1600634727 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1521 | 159508 | 3166 |
class SegTree: # モノイドに対して適用可能、Nが2冪でなくても良い
def __init__(self ,N ,seg_func ,unit):
self.N = 1 << ( N -1).bit_length()
self.func = seg_func
self.unit = unit
self.tree = [self.unit ] *( 2 *self.N)
def build(self ,init_value): # 初期値を[N,2N)に格納
for i in range(len(init_value)... |
s831289559 | p02540 | u137226361 | 1600634561 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 49476 | 862 | import sys
input = sys.stdin.readline
n = int(input())
par = [i for i in range(n)]
size = [1] * n
def find(x):
if par[x] == x:
return x
else:
a = find(par[x])
par[x] = a
return a
def unite(x, y):
x = find(x)
y = find(y)
a= size[x]
b= size[y]
if a >= b:
... |
s478596638 | p02540 | u486467381 | 1600634515 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 40052 | 588 | str = input()
N = int(str)
A = [[0] * 2 for i in range(N)]
count = 1
def hoge(K, count):
countX = count
k = K[-1]
AA1 = A[k]
for i in range(N):
AA2 = A[i]
if (AA2[0] > AA1[0] and AA2[1] > AA1[1] or AA2[0] < AA1[0] and AA2[1] < AA1[1]) and not(i in K):
countX += 1
... |
s054624342 | p02540 | u966648240 | 1600634490 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 47688 | 533 | N=int(input())
X=[]
par=[0]*(N)
for i in range(N):
a,b=map(int, input().split())
X.append([a,b])
par[i]=i
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return 0
par[x] = ... |
s295072697 | p02540 | u966648240 | 1600634294 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 47688 | 602 | N=int(input())
X=[]
par=[0]*(N)
for i in range(N):
a,b=map(int, input().split())
X.append([a,b])
par[i]=i
def find(x):
if par[x] == x:
return x
else:
par[x] = find(par[x])
return par[x]
def same(x,y):
return find(x) == find(y)
def unite(x,y):
x = find(x)
y = find(y)... |
s317788273 | p02540 | u844789719 | 1600633346 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1184 | 183236 | 6290 | import heapq
N, *XY = [int(_) for _ in open(0).read().split()]
X = XY[::2]
Y = XY[1::2]
y_k = {}
k_y = {}
for y, k in zip(Y, range(N)):
y_k[y] = k
k_y[k] = y
class UnionFind():
def __init__(self, n):
self.n = n
self.root = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def find(self... |
s705648136 | p02540 | u678167152 | 1600633234 | Python | PyPy3 (7.3.0) | py | Runtime Error | 770 | 109580 | 2309 | # Binary Indexed Tree (Fenwick Tree)
class BIT:
def __init__(self, n):
self.n = n
self.bit = [0]*(n+1)
self.el = [0]*(n+1)
def sum(self, i):
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i, x):
# assert i > 0
self.el[i] += x
while i <= self.... |
s724397593 | p02540 | u678167152 | 1600633179 | Python | PyPy3 (7.3.0) | py | Runtime Error | 695 | 109368 | 2311 | # Binary Indexed Tree (Fenwick Tree)
class BIT:
def __init__(self, n):
self.n = n
self.bit = [0]*(n+1)
self.el = [0]*(n+1)
def sum(self, i):
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i, x):
# assert i > 0
self.el[i] += x
while i <= self.... |
s169256999 | p02540 | u015019251 | 1600632434 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 38028 | 910 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020
@author: saito
"""
# %% import phase
# %% define phase
def root(x):
if par[x] == x:
return x
else:
par[x] = root(par[x])
return par[x]
def same(x, y):
return root(x) == root(y)
def unite(x, y):
x = root(x)
y... |
s552664111 | p02540 | u678167152 | 1600632250 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1474 | 119496 | 2230 | # Binary Indexed Tree (Fenwick Tree)
class BIT:
def __init__(self, n):
self.n = n
self.bit = [0]*(n+1)
self.el = [0]*(n+1)
def sum(self, i):
s = 0
while i > 0:
s += self.bit[i]
i -= i & -i
return s
def add(self, i, x):
# assert i > 0
self.el[i] += x
while i <= self.... |
s832430912 | p02540 | u415718506 | 1600632104 | Python | Python (3.8.2) | py | Runtime Error | 34 | 9916 | 2884 | import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict
from atcoder.fenwicktree import FenwickTree
# available on Google, not available on Codeforces
# import numpy as np
# import scipy
def solve(grid, n): # fix inputs here
console("----- solving ------... |
s691734051 | p02540 | u015019251 | 1600632001 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 38268 | 882 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020
@author: saito
"""
# %% import phase
# %% define phase
def root(x):
if par[x] == x:
return x
else:
par[x] = root(par[x])
return par[x]
def same(x, y):
return root(x) == root(y)
def unite(x, y):
x = root(x)
y... |
s212726066 | p02540 | u015019251 | 1600631561 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 38140 | 852 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020
@author: saito
"""
# %% import phase
# %% define phase
def root(x):
if par[x] == x:
return x
else:
par[x] = root(par[x])
return par[x]
def same(x, y):
return root(x) == root(y)
def unite(x, y):
x = root(x)
y... |
s286717298 | p02540 | u023229441 | 1600630963 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 105204 | 2949 | n=int(input())
class UnionFind():
def __init__(self,num):
self.n = num #class内変数nに、外部から入力した値numを代入
self.parents = [-1 for i in range(self.n)]
#parentsは要素の親(1こ上のやつ)番号0~n-1を格納、自分が最親なら-(要素数)を格納(初期値は-1)
#xの最親は誰?
def find(self,x):
if self.parents[x]<0:
retu... |
s159106478 | p02540 | u773081031 | 1600630903 | Python | Python (3.8.2) | py | Runtime Error | 931 | 112088 | 394 | n = int(input())
z = [[map(int, input().split())] for i in range(n)]
a = []
for i in range(n):
z_ = z
f = z_.pop(i)
x = [f]
for j in z_:
if f[0]>j[0] and f[1]>j[1]:
x.append(j)
elif f[0]<j[0] and f[1]<j[1]:
x.append(j)
a.append(x)
for i in range(n):
ans = a[i]
for j in range(n):
... |
s904166734 | p02540 | u773081031 | 1600630861 | Python | Python (3.8.2) | py | Runtime Error | 30 | 8944 | 405 | n = int(input())
z = [[x, y] for i in range(n) x, y = map(int, input().split())]
a = []
for i in range(n):
z_ = z
f = z_.pop(i)
x = [f]
for j in z_:
if f[0]>j[0] and f[1]>j[1]:
x.append(j)
elif f[0]<j[0] and f[1]<j[1]:
x.append(j)
a.append(x)
for i in range(n):
ans = a[i]
for j in ... |
s921197543 | p02540 | u370721525 | 1600630337 | Python | Python (3.8.2) | py | Runtime Error | 2207 | 47832 | 426 | N = int(input())
l = []
for i in range(N):
l.append(list(map(int, input().split())))
def main(n, tmp):
global l
for i in range(n+1, N):
if (l[n][0]-l[i][0]) * (l[n][1]-l[i][1]) > 0:
tmp.append(i)
tmp = main(i, tmp)
return list(set(tmp))
ans = [True] * N
for i in range(N):
if ans[i] == True:
... |
s433226463 | p02540 | u171731224 | 1600630309 | Python | Python (3.8.2) | py | Runtime Error | 2274 | 2688080 | 335 | n=int(input())
l=[]
grid=[[0]*n for i in range(n)]
for i in range(n):
x=list(map(int,input().split()))
grid[x[0]-1][x[1]-1]=1
l.append(x)
def dfs(i,j):
if(i<0 or j<0 or i>n or j>n):
return 0
if(grid[i][j]==1):
return 1
c=dfs(i+1,j+1)+dfs(i-1,j-1)+1
return c
for i in range(n):
print(dfs(l[i][0],l... |
s660409731 | p02540 | u366886346 | 1600630103 | Python | Python (3.8.2) | py | Runtime Error | 36 | 9168 | 3 | あ |
s666409859 | p02540 | u569511944 | 1600629812 | Python | PyPy2 (7.3.0) | py | Runtime Error | 2464 | 329000 | 1116 | n=input()
a=[[int(i) for i in raw_input().split()]for j in range(n)]
c={}
for i in range(n):
c[i]=a[i][0]-1
a.sort()
miny=a[0][1]
pos=0
l=[i for i in range(n)]
r=[0 for i in range(n)]
dx={}
dy={}
def find(x):
if l[x]==x:
return l[x]
return find(l[x])
for i in range(1,n):
if a[i][1]>miny:
... |
s819021227 | p02540 | u061835391 | 1600628910 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9244 | 291 | n=int(input())
l=[]
m=[]
for i in range(0,n):
p,q=map(int,input().split())
w.append((p,q))
h=[]
for i in range(0,len(w)):
c=1
for j in range(0,len(w)):
s,t=w[i]
f,g=w[j]
if (s,t)<(f,g):
c=c+1
elif (s,t)>(f,g):
c=c+1
h.append(c)
for i in h:
print(i)
|
s582655063 | p02541 | u785989355 | 1600702400 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 68828 | 4043 | from collections import defaultdict
def _is_prime(n):
'''
Reference:
M. Forisek and J. Jancina,
Fast Primality Testing for Integers That Fit into a Machine Word
'''
if n <= 1:
return False
if n == 2 or n == 7 or n == 61:
return True
if n % 2 == 0:
return False
... |
s983190171 | p02541 | u923270446 | 1600693674 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 68732 | 6093 | from math import ceil
n = int(input())
import math
import numpy as np
import decimal
import collections
import itertools
import sys
import random
#Union-Find
class UnionFind():
def __init__(self, n):
self.n = n
self.par = [-1 for i in range(self.n)]
def find(self, x):
if self.par[x] < 0... |
s793389684 | p02541 | u454093752 | 1600689141 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 68716 | 348 | import sympy.ntheory.modular
N = int(input())
N *= 2
K = [[1, N]]
for i in range(2, max(int(N**0.5)+2, 2)):
if N % i == 0:
K.append([i, N//i])
ans = float("inf")
for i in range(len(K)):
a, b = K[i]
x = sympy.ntheory.modular.crt([a, b], [0, -1])
if x is None:
pass
else:
ans ... |
s737336763 | p02541 | u829416877 | 1600664952 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9232 | 121 | N = int(input())
for i in range(1,N):
X = i*(i+1)/2/N
Y = i*(i+1)/2//N
if X == Y:
ans = i
break
print(ans) |
s148265871 | p02541 | u516018862 | 1600646439 | Python | PyPy3 (7.3.0) | py | Runtime Error | 106 | 68812 | 112 | n, i, sum_ = int(input()), 1, 1
while True:
if sum_ % n == 0:
print(i)
break
i += 1
sum += i
|
s695707408 | p02541 | u645855527 | 1600637399 | Python | PyPy3 (7.3.0) | py | Runtime Error | 137 | 74608 | 1423 | from collections import Counter
# 拡張ユークリッド互除法
# gcd(a,b) と ax + by = gcd(a,b) の最小整数解を返す
def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y, x = egcd(b % a, a)
return g, x - (b // a) * y, y
def chineseRem(b1, m1, b2, m2):
# 中国剰余定理
# x ≡ b1 (mod m1) ∧ x ≡ b2 (mod m2) <=> x ≡ ... |
s934714736 | p02541 | u879921371 | 1600637373 | Python | Python (3.8.2) | py | Runtime Error | 23 | 9116 | 1227 | import numpy as np
import itertools
def factorization(num):
return factor
def main():
n2=int(input())
n=n2
if n==1:
print(1)
exit()
num=n
factor = []
while num > 1:
for i in range(num - 1):
k = i + 2
if num % k == 0:
factor.append(k)
num = int(num / k)
br... |
s233869141 | p02541 | u588341295 | 1600636953 | Python | PyPy3 (7.3.0) | py | Runtime Error | 243 | 382404 | 4791 | import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)]... |
s113218681 | p02541 | u015019251 | 1600636363 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9092 | 372 | # -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020
@author: saito
"""
# %% import phase
import math
# %% define phase
# %% input phase
N = int(input())
# %% process phase
s = int(math.sqrt(2*N))
t = s-1
old = (t*t + t)/2
for i in range(N-s):
j = i+s;
new = old + j
if new % N == 0:
... |
s895343275 | p02541 | u474212171 | 1600635942 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8916 | 554 | z=int(input())
def solv_quadratic_equation(a, b, c):
""" 2次方程式を解く """
D = (b**2 - 4*a*c) ** (1/2)
x_1 = (-b + D) / (2 * a)
x_2 = (-b - D) / (2 * a)
return x_1,x_2
ans=0
i=1
# print(10**15)
# a,b=solv_quadratic_equation(1,1,1000000000000000)
# print(a,b)
while True:
a,b=solv_quadratic_equation(1,1,... |
s277684726 | p02541 | u476674874 | 1600635265 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9000 | 97 | N = int(input())
ans = resolve(N)
print(ans)
if __name__ == '__main__':
main()
|
s286343027 | p02541 | u104282757 | 1600634870 | Python | Python (3.8.2) | py | Runtime Error | 123 | 27164 | 1140 | from itertools import chain, combinations
import numpy as np
import sympy
def ext_gcd(a, b):
x0, y0, x1, y1 = 1, 0, 0, 1
while b != 0:
q, a, b = a // b, b, a % b
x0, x1 = x1, x0 - q * x1
y0, y1 = y1, y0 - q * y1
return a, x0, y0
def solve(n):
# prime factorization
factori... |
s452628927 | p02541 | u550289743 | 1600634716 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9156 | 157 | N=int(input())
for p in range(1, 2 * N - 1):
sq = int(math.sqrt(2*N * p))
if 2*N*p % sq == 0 and 2*N*p ==sq *(sq+1):
print(sq)
break
|
s742091211 | p02541 | u550289743 | 1600634500 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9148 | 137 | N = int(input())
for p in range(1, 2 * N - 1):
sq = int(math.sqrt(2*N * p))
if 2*N*p % sq == 0 :
print(sq)
break
|
s621420527 | p02541 | u216928054 | 1600634396 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 68836 | 2583 | import sys
def debug(*x):
print(*x, file=sys.stderr)
def ex():
for i in range(2, 100):
for j in range(1, i - 1):
if (j * (j + 1) // 2) % i == 0:
# debug("i, j", i, j)
break
else:
debug("i", i)
def blute(N):
for i in range(1, N):
... |
s392239503 | p02541 | u789290859 | 1600634033 | Python | Python (3.8.2) | py | Runtime Error | 132 | 9656 | 500 | def solv_quadratic_equation(a, b, c):
""" 2次方程式を解く """
D = (b**2 - 4*a*c) ** (1/2)
x_1 = (-b + D) / (2 * a)
x_2 = (-b - D) / (2 * a)
return x_1, x_2
N = int(input())
a = N
i = 0
li = []
while True:
x_1,x_2 = solv_quadratic_equation(float(1),float(1),float(-2*N))
if x_1.is_integer() and x_... |
s105078806 | p02541 | u968431218 | 1600634020 | Python | Python (3.8.2) | py | Runtime Error | 443 | 9608 | 135 | n=int(input())
for i in range(1,n):
#print(i)
if (1+8*n*i)**0.5==int((1+8*n*i)**0.5):
k=(1+8*n*i)**0.5
break
print(int((-1+k)/2)) |
s173807989 | p02541 | u773081031 | 1600634018 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9012 | 141 | import math
n = int(input())
a = 0
whil True:
a += 1
sq = math.sqrt(2*a*n)
k = math.floor(sq)
if k*(k+1)==2*a*n:
break
print(k)
|
s768386170 | p02541 | u401686269 | 1600634010 | Python | PyPy3 (7.3.0) | py | Runtime Error | 170 | 74760 | 585 | from math import prod
def factorize(n):
out=[]
i = 2
while 1:
if n%i==0:
out.append(i)
n //= i
else:
i += 1
if n == 1:break
if i > int(n**.5+3):
out.append(n)
break
return out
N = int(input())
if N == 1:... |
s920634227 | p02541 | u968431218 | 1600633904 | Python | Python (3.8.2) | py | Runtime Error | 443 | 9620 | 144 | n=int(input())
for i in range(1,(n-1)//2+1):
#print(i)
if (1+8*n*i)**0.5==int((1+8*n*i)**0.5):
k=(1+8*n*i)**0.5
break
print(int((-1+k)/2)) |
s448679086 | p02541 | u347502437 | 1600633631 | Python | Python (3.8.2) | py | Runtime Error | 2283 | 2145688 | 975 | from math import sqrt
from math import ceil
def mpfli(N): #minimum prime factor listのこと
li = [i for i in range(N+1)]
li2 = [i for i in range(N+1)]
for i in range(2,ceil(sqrt(N+1))):
for j in range(2*i, N + 1):
if li[j]== li2[j]:
if li[j] % li[i] == 0:
... |
s013830489 | p02541 | u101017353 | 1600633546 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 69972 | 336 | import collections
def cal(c):
x=1+4*c*2
if x<=0:
return -1,-1
else:
x=x**0.5
x1=(-1+x)/2
x2=(-1-x)/2
return x1,x2
def cal2(val):
return (val**2+val)/2
n=int(input())
base=n
out=1
while out%n!=0:
x,_=cal(base)
if x!=-1:
out=cal2(int(x))
base+=... |
s057497752 | p02541 | u546157297 | 1600633520 | Python | Python (3.8.2) | py | Runtime Error | 512 | 342344 | 145 | def main2():
import numpy as np
N = int(input())
Ds = np.where((np.arange(1,N+1).cumsum()%N) == 0)
print(Ds[0][0]+1)
main2() |
s107093143 | p02541 | u101017353 | 1600633455 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 69848 | 360 | import collections
def cal(c):
x=1+4*c*2
if x<=0:
return -1,-1
else:
x=x**0.5
x1=(-1+x)/2
x2=(-1-x)/2
return x1,x2
def cal2(val):
return (val**2+val)/2
n=int(input())
base=n
out=out2=1
while out%n!=0 and out2%n!=0:
x1,x2=cal(base)
if x1!=-1:
out=c... |
s531478441 | p02541 | u546157297 | 1600633368 | Python | Python (3.8.2) | py | Runtime Error | 511 | 500120 | 156 | def main2():
import numpy as np
N = int(input())
D = np.arange(1, N+1)
Ds = np.where((D.cumsum()%N) == 0)
print(Ds[0][0]+1)
main2() |
s489258212 | p02541 | u874320250 | 1600633277 | Python | PyPy3 (7.3.0) | py | Runtime Error | 255 | 68572 | 145 | import math
N = int(input())
for a in range(1, N):
k = math.sqrt(2 * N * a + 1 / 4) - 1 / 2
if k % 1 == 0:
break
print(int(k))
|
s559376183 | p02541 | u320027541 | 1600633110 | Python | Python (3.8.2) | py | Runtime Error | 251 | 27152 | 175 | import numpy
N = int(input())
i = 1
while True:
root = numpy.sqrt(8 * N * i + 1)
if root.is_integer():
print(int((root - 1) / 2))
exit()
i += 1
|
s229427234 | p02541 | u475402977 | 1600632977 | Python | Python (3.8.2) | py | Runtime Error | 2230 | 808440 | 1010 | import sys
def make_prime_table(n):#nまでの整数について,それに含まれる最大の素数
sieve = list(range(n + 1))
sieve[0] = -1
sieve[1] = -1
for i in range(4, n + 1, 2):
sieve[i] = 2
for i in range(3, int(n ** 0.5) + 1, 2):
if sieve[i] != i:
continue
for j in range(i * i, n + 1, i * 2):
... |
s268673960 | p02541 | u091051505 | 1600632894 | Python | PyPy3 (7.3.0) | py | Runtime Error | 144 | 74616 | 1062 | def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
from collections import Counter
n = int(input(... |
s900035815 | p02541 | u091051505 | 1600632839 | Python | PyPy3 (7.3.0) | py | Runtime Error | 247 | 77876 | 1028 | def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
from collections import Counter
n = int(input(... |
s372353445 | p02541 | u091051505 | 1600632734 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 15780 | 1028 | def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
from collections import Counter
n = int(input(... |
s444476353 | p02541 | u401686269 | 1600632493 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9456 | 387 | def factorize(n):
out=[]
i = 2
while 1:
if n%i==0:
out.append(i)
n //= i
else:
i += 1
if n == 1:break
if i > int(n**.5+3):
out.append(n)
break
return out
N = int(input())
f = factorize(N)[-1]
for i in ran... |
s975544507 | p02541 | u914098558 | 1600631813 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9028 | 166 | try:
N=int(input())
sum=0
for i in range(1,100000)
sum=sum+i
if sum%N==0:
print(i)
break
except:
pass
|
s053892911 | p02541 | u914098558 | 1600631740 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9004 | 170 | try:
N=int(input())
sum=0
i=1
for i in range(1,100000)
sum=sum+i
if sum%N==0:
print(i)
break
except:
pass
|
s292118932 | p02541 | u504856568 | 1600631578 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9168 | 153 | N = int(input())
A = (-1 + math.sqrt(1 + 8 * N))/2
B = N
while not A.is_integer():
B = B + N
A = (-1 + math.sqrt(1 + 8 * B))/2
print(int(A)) |
s841204797 | p02541 | u566383189 | 1600631521 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9092 | 136 | n = input()
num = 1 + 8*n
root = int(math.sqrt(num))
while((root*root)!=num):
num+=8*n
root = int(math.sqrt(num))
print((root-1)/2)
|
s393154663 | p02541 | u504856568 | 1600631500 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9172 | 167 | N = int(input())
A = float((-1 + math.sqrt(1 + 8 * N))/2)
B = N
while not A.is_integer():
B = B + N
A = float((-1 + math.sqrt(1 + 8 * B))/2)
print(int(A)) |
s577763113 | p02541 | u504856568 | 1600631467 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9160 | 162 | N = int(input())
A = float((-1 + math.sqrt(1 + 8 * N))/2)
B = N
while not A.is_integer():
B = B + N
A = float((-1 + math.sqrt(1 + 8 * B))/2)
print(A) |
s848614192 | p02541 | u111365362 | 1600631451 | Python | PyPy3 (7.3.0) | py | Runtime Error | 716 | 82404 | 1113 | n = int(input())
n *= 2
ans = []
ans2 = []
for i in range(2,32*10**6):
if n % i == 0:
ans.append(i)
n //= i
cnt = 1
while n % i == 0:
n //= i
cnt += 1
ans2.append(cnt)
if n != 1:
ans.append(n)
ans2.append(1)
#print(ans)
#print(ans2)
l = len(ans)
for i in range(l):
ans[i] **= ans2... |
s141097248 | p02541 | u460763828 | 1600631430 | Python | Python (3.8.2) | py | Runtime Error | 1364 | 27172 | 325 | import numpy as np
def main():
N = int(input())
a = 1
while True:
if isinstance(np.sqrt(2 * a * N), float):
k = int(np.sqrt(2 * a * N))
if k * (k + 1) / 2 == a * N:
print(k)
break
a += 1
return
if __name__ == '__main__':
ma... |
s665470491 | p02541 | u460763828 | 1600631269 | Python | Python (3.8.2) | py | Runtime Error | 1366 | 27176 | 301 | import numpy as np
def main():
N = int(input())
a = 1
while True:
if isinstance(np.sqrt(2 * a * N), float):
k = int(np.sqrt(2*a*N))
if k*(k+1)/2 == a*N:
print(k)
return
a += 1
if __name__ == '__main__':
main() |
s002291816 | p02541 | u098368455 | 1600631220 | Python | PyPy3 (7.3.0) | py | Runtime Error | 607 | 68612 | 793 | def euclid(x, y):
c0, c1 = x, y
a0, a1 = 1, 0
b0, b1 = 0, 1
while c1 != 0:
m = c0 % c1
q = c0 // c1
c0, c1 = c1, m
a0, a1 = a1, (a0 - q * a1)
b0, b1 = b1, (b0 - q * b1)
return a0, b0
n=int(input())
n*=2
soinsu=[]
num=n
for i in range(2,n):
if(i*i>n... |
s414857998 | p02541 | u966648240 | 1600630773 | Python | Python (3.8.2) | py | Runtime Error | 2227 | 775372 | 174 | N=int(input())
sum=[0]*(N+1)
sum[1]=1
ans=0
for i in range(N+1):
sum[i]=i+sum[i-1]
for j in range(N+1):
if sum[j]%N==0 and j !=0 :
ans=j
break;
print(ans) |
s088981188 | p02541 | u253333670 | 1600630754 | Python | Python (3.8.2) | py | Runtime Error | 29 | 8948 | 897 | from math import sqrt
def arr():
return list(map(int, input().split()))
def isPrime(n):
if (n <= 1):
return False
if (n <= 3):
return True
if (n % 2 == 0 or n % 3 == 0):
return False
i = 5
while(i * i <= n):
if (n % i == 0 or n % (i + 2) == 0):
ret... |
s695621571 | p02541 | u966648240 | 1600630685 | Python | Python (3.8.2) | py | Runtime Error | 2231 | 868260 | 174 | N=int(input())
sum=[0]*2*N
sum[1]=1
ans=0
for i in range(2*N):
sum[i]=i+sum[i-1]
for j in range(0,2*N):
if sum[j]%N==0 and j !=0 :
ans=j
break;
print(ans) |
s126688441 | p02541 | u966648240 | 1600630565 | Python | Python (3.8.2) | py | Runtime Error | 2231 | 878332 | 174 | N=int(input())
sum=[0]*2*N
sum[1]=1
ans=0
for i in range(2*N):
sum[i]=i+sum[i-1]
for j in range(0,2*N):
if sum[j]%N==0 and j !=0 :
ans=j
break;
print(ans) |
s142867805 | p02541 | u460763828 | 1600630553 | Python | Python (3.8.2) | py | Runtime Error | 753 | 27152 | 239 | import numpy as np
def main():
N = int(input())
a = 1
while True:
k = int(np.sqrt(2 * a * N))
if k*(k+1) == 2*a*N:
print(k)
return
a += 1
if __name__ == '__main__':
main() |
s716375637 | p02541 | u327466606 | 1600630361 | Python | PyPy3 (7.3.0) | py | Runtime Error | 440 | 68912 | 955 | from math import gcd
from collections import Counter
from itertools import product
min2 = lambda x,y: x if x < y else y
def lcm(A):
m = 1
for a in A:
m *= a//gcd(m,a)
return m
def chinese_remainder_theorem(R, M):
"""
returns x and lcm(M) s.t.
all(x%m == r for r,m in zip(R,M))
"... |
s538863521 | p02541 | u880400515 | 1600630302 | Python | PyPy3 (7.3.0) | py | Runtime Error | 181 | 69784 | 149 | import math
N = int(input())
for i in range(1, N):
if (((-1 + math.sqrt(1 + 8 * N * i)) / 2).is_integer()):
print(int(a))
break
|
s640144226 | p02541 | u516079739 | 1600629994 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9092 | 104 | n = int(input())
s=0
v=[]
for i in range(1,n):
s=s+i
if s%n==0:
v.append(i)
print(v[0]) |
s107956380 | p02541 | u867539710 | 1600629257 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9012 | 71 | n=int(input())
count=0
x=1
sm=1
while sm%n!=0:
x+=1
sm+=x
print(x) |
s018127996 | p02542 | u941407962 | 1600686182 | Python | PyPy3 (7.3.0) | py | Runtime Error | 1425 | 102908 | 2813 |
import sys;input=sys.stdin.readline
from collections import deque, defaultdict
def encode(i, j):
return 2 + K + i*M + j
from heapq import heappush, heappop
class MinCostFlow:
INF = 10**18
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def addEdge(self, fr, to, cap, ... |
s962135297 | p02542 | u864197622 | 1600640404 | Python | Python (3.8.2) | py | Runtime Error | 849 | 64088 | 712 | from networkx import*
N, M = map(int, input().split())
X = [[0 if a == "#" else 1 if a == "." else 2 for a in input()] for _ in range(N)]
cnt = sum(sum([1 if a == 2 else 0 for a in x]) for x in X)
G = MultiDiGraph()
t = N * M
G.add_node(t, demand = cnt)
for i in range(N):
for j in range(M):
if X[i][j] == 0:... |
s951524513 | p02542 | u297574184 | 1600637911 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 74696 | 1678 | import networkx as nx
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
def solve():
INF = float('inf')
def max2(x, y): return x if x >= y else y
N, M = map(int, input().split())
Sss = ['#'*(M+2)] + ['#'+input()+'#' for _ in range(N)] + ['#'*(M+2)]
poss = []
for i in range(1... |
s321416919 | p02542 | u325227960 | 1600637428 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 68784 | 5541 | import types
_atcoder_code = """
# Python port of AtCoder Library.
__version__ = '0.0.1'
"""
atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)
_atcoder_maxflow_code = """
from __future__ import annotations
from typing import NamedTuple, Optional, List
class MFGraph:
class Edge(Named... |
s307029842 | p02542 | u340781749 | 1600635075 | Python | Python (3.8.2) | py | Runtime Error | 259 | 105488 | 4591 | import os
import sys
from heapq import heappop, heappush
import numpy as np
def solve(n, m, field):
MINCOSTFLOW_LINKS = []
MINCOSTFLOW_LINK_INDICES = []
MINCOSTFLOW_CURRENT_LINK_INDEX = []
INF = 10 ** 10
def mincostflow_init(m):
""" m:辺数(逆辺除く) """
MINCOSTFLOW_LINKS.append(np.zero... |
s268523972 | p02542 | u340781749 | 1600634654 | Python | Python (3.8.2) | py | Runtime Error | 285 | 105632 | 4621 | import os
import sys
from heapq import heappop, heappush
import numpy as np
def solve(n, m, field):
MINCOSTFLOW_LINKS = []
MINCOSTFLOW_LINK_INDICES = []
MINCOSTFLOW_CURRENT_LINK_INDEX = []
INF = 10 ** 10
def mincostflow_init(m):
""" m:辺数(逆辺除く) """
MINCOSTFLOW_LINKS.append(np.zero... |
s537202768 | p02542 | u994521204 | 1600633501 | Python | Python (3.8.2) | py | Runtime Error | 988 | 68204 | 806 | import networkx as nx
n, m = map(int, input().split())
S = [list(input()) for _ in range(n)]
G = nx.DiGraph()
start = (n, m)
cnt = 0
goal = (n, m + 1)
for i in range(n):
for j in range(n):
if S[i][j] != "#":
if S[i][j] == "o":
cnt += 1
G.add_edge(start, (i, j)... |
s509077674 | p02542 | u994521204 | 1600633293 | Python | Python (3.8.2) | py | Runtime Error | 1031 | 68476 | 802 | import networkx as nx
n, m = map(int, input().split())
S = [list(input()) for _ in range(n)]
G = nx.DiGraph()
start = (n, n)
cnt = 0
goal = (n, n + 1)
for i in range(n):
for j in range(n):
if S[i][j] != "#":
if S[i][j] == "o":
cnt += 1
G.add_edge(start, (i, j)... |
s153736109 | p02542 | u994521204 | 1600633245 | Python | Python (3.8.2) | py | Runtime Error | 354 | 58084 | 848 | import networkx as nx
import sys
input = sys.stdin.buffer.readline
n, m = map(int, input().split())
S = [list(input()) for _ in range(n)]
G = nx.DiGraph()
start = (n, n)
cnt = 0
goal = (n, n + 1)
for i in range(n):
for j in range(n):
if S[i][j] != "#":
if S[i][j] == "o":
cnt... |
s759766995 | p02546 | u793981991 | 1600719364 | Python | PyPy2 (7.3.0) | py | Runtime Error | 405 | 85680 | 575 | import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n, q = list(map(int, input().split()))
count = (n - 2) ** 2
c = [n] * n
r = [n] * n
mc = n
mr = n
for _ in range(q):
m,q = list(map(int, input().split()))
if m == 1:
pos = r[q-1]
if q < mc:
mc = q
for p in ran... |
s976586160 | p02546 | u817565863 | 1600707832 | Python | Python (3.8.2) | py | Runtime Error | 30 | 8956 | 94 | p=input()
if p[len(p)-1]=='s':
p.append('es')
print(p)
else:
p.append('s')
print(p)
|
s912385241 | p02546 | u224989615 | 1600702132 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9156 | 225 | n = int(input())
count = 0
for i in range(n):
d1, d2 = map(int, input().split())
if count > 2:
break
else:
if d1 == d2:
count += 1
else:
count = 0
if count > 2:
print("Yes")
else:
print("No") |
s942124955 | p02546 | u224989615 | 1600701823 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74336 | 212 | n = int(input())
count = 0
for i in range(n):
d1, d2 = map(int, input().split())
if count > 2:
break
elif d1 == d2:
count += 1
else:
count == 0
if count > 2:
print("Yes")
else:
print("No") |
s086544729 | p02546 | u224989615 | 1600701669 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9168 | 212 | n = int(input())
count = 0
for i in range(n):
d1, d2 = map(int, input().split())
if count > 2:
break
elif d1 == d2:
count += 1
else:
count == 0
if count > 2:
print("Yes")
else:
print("No") |
s813446537 | p02546 | u224989615 | 1600701121 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9080 | 214 | n = int(input())
count = 0
for i in range(n):
d1, d2 = map(int, input().split())
if count == 3:
break
elif d1 == d2:
count += 1
else:
count == 0
if count == 3:
print("Yes")
else:
print("No") |
s762877870 | p02546 | u956223466 | 1600697845 | Python | Python (3.8.2) | py | Runtime Error | 22 | 8800 | 51 | w=input()
a='es' is w[-1]=='s' else 's'
print(w+a)
|
s773060261 | p02546 | u956223466 | 1600697787 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8796 | 42 | w=input()
a=w[-1]=='s'?'es':'s'
print(w+a) |
s162093523 | p02546 | u689723321 | 1600697395 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8992 | 79 | S=input()
l=len(S)
s=list(S)
if s[l]=="s":
print(S+"es")
else:
print(S+"s") |
s650432712 | p02546 | u654571388 | 1600695379 | Python | Python (3.8.2) | py | Runtime Error | 30 | 8952 | 83 | val = input()
valf=val[-1]
if(valf==s):
print(val+"es")
else
print(val+"s") |
s239189491 | p02546 | u005788584 | 1600693141 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8976 | 238 | nk=map(int,input().split())
a=[]
for i in range(k):
lr=map(int,input().split())
for i in range(l,r+1):
a.append(i)
a=list(set(a))
dp=[0]*n
dp[0]=1
for i in range(1,n):
for j in a:
if i>=j:
dp[i]+=dp[i-j]
print(dp[-1])
|
s031404546 | p02546 | u867616076 | 1600691450 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9048 | 76 | s = raw_input()
if(s[-1] == 's'):
s += 'es'
else:
s += 's'
print(s)
|
s783184437 | p02546 | u574888872 | 1600685195 | Python | Python (3.8.2) | py | Runtime Error | 69 | 16208 | 355 | from unittest import TestCase, main
from A import func
class test(TestCase):
def test_with_valid_params(self):
test_patterns = [
("apple","apples"),
("bus","buses"),
("box","boxs")
]
for S,result in test_patterns:
with self.subTest(S=S):
self.assertEqual(func(S),result)
... |
s593165411 | p02546 | u807772568 | 1600682441 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 74600 | 1336 | import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
return list(map(int,input().split()))
def m(): #複数文字
return map(int,input().split())
def onem(): #Nとかの取得
return int(input())
def s(x): #圧縮
a = []
if l... |
s910199198 | p02546 | u840649762 | 1600673441 | Python | Python (3.8.2) | py | Runtime Error | 29 | 8948 | 395 | import random
exit = False
count = 0
countNum = 0
randomArray1 = random.randint(1,6)
randomArray2 = random.randint(1,6)
while count < 4:
randomArray1 = random.randint(1,6)
randomArray2 = random.randint(1,6)
print(randomArray1,randomArray2)
countNum += 1
if randomArray1 == randomArray2:
... |
s538877372 | p02546 | u267933821 | 1600669841 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9020 | 76 | S=input()
s=len(S)
if S[s] == "s":
print(S+"es")
else:
print(S+"s")
|
s985345440 | p02546 | u313165242 | 1600652563 | Python | Python (3.8.2) | py | Runtime Error | 22 | 8880 | 96 | def change_code(src):
if src[:1] == s:
src=src + "es"
else:
src = src + "s"
return src |
s341679771 | p02546 | u696886537 | 1600633207 | Python | Python (3.8.2) | py | Runtime Error | 31 | 8944 | 107 | f=open('in','r')
input=lambda:f.readline().strip()
s=input()
if s[-1]!='s':print(s+'s')
else:print(s+'es') |
s388133068 | p02546 | u883375836 | 1600620421 | Python | Python (3.8.2) | py | Runtime Error | 28 | 8956 | 74 | input=(S)
if S[-1]!="s":
print(S+"s")
elif S[-1]=="s":
print(S+"es") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.