input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
n,*a=list(map(int,open(0).read().split()))
a.sort(reverse=True)
for i in range(1,n):
if a[i]==a[i-1]:
a[i]=0
else:
a[i-1]=0
a.sort()
print((a[-1]*a[-2])) | n,*a=list(map(int,open(0).read().split()))
a.sort()
x,y,i=0,0,0
while i<n:
if a[i-1]==a[i]:
x,y=y,a[i]
i+=1
i+=1
print((x*y)) | p03625 |
from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
a = Counter(A)
sides = [0, 0]
for i in list(a.keys()):
if a[i] >= 4:
sides.append(i)
sides.append(i)
elif a[i] >= 2:
sides.append(i)
sides.sort()
print((sides.pop() * sides.pop())... | from collections import Counter
N = int(eval(input()))
A = list(map(int, input().split()))
a = Counter(A)
sides = [0, 0]
for i in list(a.keys()):
if a[i] >= 4:
sides.append(i)
sides.append(i)
elif a[i] >= 2:
sides.append(i)
sides.sort(reverse=True)
print((sides[0] * sid... | p03625 |
def C_Make_a_Rectangle(lst):
N = lst[0]
A = lst[1:]
from collections import Counter, deque
c = sorted(list(Counter(A).items()), reverse=True) # リストの要素が何回現れたか
# cの0番要素は値、1番要素は度数
ans = deque([])
for k, v in c:
if v == 1:
continue
elif v == 2 or v == 3... | def c_make_a_rectangle(N, A):
from collections import Counter
count = Counter(A) # リストの要素が何回現れたか
cond = [] # 同じ長さのものが2個ある棒の長さ
for k, v in list(count.items()):
if v == 1: # 1個しかない棒では長方形を作れない
continue
else:
cond.extend([k] * (v // 2))
if len(cond) ... | p03625 |
from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = [0] * 2
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
b.sort()
print((b[-1] * b[-2])) | from collections import Counter as C
_ = eval(input())
a = C([int(x) for x in input().split()])
b = []
for k, v in list(a.items()):
if 4 <= v:
b.append(k)
if 2 <= v:
b.append(k)
else:
if len(b) <= 1:
print((0))
else:
b.sort()
print((b[-1] * b[-2]... | p03625 |
n=int(eval(input()))
b=sorted([int(i) for i in input().split()],reverse=True)
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
A=groupby(b)
l=len(A)
B=[]
for i in range(l):
A... | n=int(eval(input()))
a=sorted(list(map(int,input().split())),reverse=True)
x,y=0,0
def groupby(a):
a2=[[a[0],1]]
for i in range(1,len(a)):
if a2[-1][0]==a[i]:
a2[-1][1]+=1
else:
a2.append([a[i],1])
return a2
b=groupby(a)
l=len(b)
for i in range(l):
i... | p03625 |
from collections import Counter
n = int(eval(input()))
a = list(map(int, input().split()))
d = Counter(a)
ans = -1
for k in sorted(d.keys())[::-1]:
if ans == -1 and d[k] >= 4:
print((k*k))
exit()
elif ans == -1 and d[k] >= 2:
ans = k
elif ans != -1 and d[k] >= 2:
... | from collections import Counter
n = int(eval(input()))
d = Counter(list(map(int, input().split())))
ans = -1
for k in sorted(d.keys())[::-1]:
if ans == -1 and d[k] >= 4:
print((k*k))
exit()
elif ans == -1 and d[k] >= 2:
ans = k
elif ans != -1 and d[k] >= 2:
pri... | p03625 |
a, b, c, d = input().split()
print((max(int(a) * int(b), int(c) * int(d)))) | a, b, c, d = list(map(int, input().split())); print((max(a * b, c * d))) | p03826 |
a,b,c,d = list(map(int,input().split()))
print((int(max(a*b,c*d))))
| a,b,c,d = list(map(int,input().split()))
print((max(a*b,c*d))) | p03826 |
a,b,c,d=list(map(int,input().split()))
if a*b >= c*d:
print((a*b))
else:
print((c*d)) | a,b,c,d=list(map(int,input().split()))
print((max(a*b,c*d)))
| p03826 |
A,B,C,D = list(map(int,input().split()))
print((max(A*B,C*D))) | # python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
A,B,C,D = list(map(int,input().split()))
print((max(A*B,C*D))) | p03826 |
A, B, C, D = list(map(int, input().split()))
area1 = A * B
area2 = C * D
print((area1 if area1 >= area2 else area2)) | A, B, C, D = list(map(int, input().split()))
areas = [A * B, C * D]
print((max(areas))) | p03826 |
a,b,c,d = list(map(int,input().split()))
ans = a*b, c*d
print((max(ans))) | A,B,C,D = list(map(int,input().split()))
if A * B > C * D:
print((A * B))
elif A * B < C * D:
print((C * D))
else:
print((A * B)) | p03826 |
a = list(map(int,input().split()))
x = a[0] * a[1]
y = a[2] * a[3]
if x >= y:
print(x)
else:
print(y) | a = list(map(int,input().split()))
b = a[0] * a[1]
c = a[2] * a[3]
if b > c:
print(b)
else:
print(c) | p03826 |
A, B, C, D = list(map(int, input().split()))
if A*B>C*D:
print((A*B))
else:
print((C*D)) | A, B, C, D = list(map(int, input().split()))
print((max(A*B, C*D))) | p03826 |
A, B, C, D = list(map(int,input().split()))
if A * B == C * D:
print((A * B))
else:
print((max(A * B, C * D))) | a, b, c, d = list(map(int,input().split()))
print((max(a * b, c * d))) | p03826 |
a, b, c, d = list(map(int, input().split()))
s1 = a * b
s2 = c * d
if s1 > s2:
print(s1)
else:
print(s2) | a, b, c, d = list(map(int, input().split()))
print((max(a*b, c*d))) | p03826 |
vertical1, horizontal1, vertical2, horizontal2 = list(map(int, input().split()))
area1 = vertical1 * horizontal1
area2 = vertical2 * horizontal2
if area1 < area2:
print(area2)
else:
print(area1) | A, B, C, D = list(map(int, input().split()))
print((max(A * B, C * D))) | p03826 |
A,B,C,D=list(map(int,input().split()))
if A*B>=C*D:
print((A*B))
else:
print((C*D)) | A,B,C,D = list(map(int,input().split()))
print((max(A*B,C*D)))
| p03826 |
A,B,C,D = list(map(int,input().split()))
X = A*B
Y = C*D
if X >= Y:
print(X)
else:
print(Y)
| A, B, C, D = list(map(int, input().split()))
print((max(A * B, C * D)))
| p03826 |
# -*- coding: utf-8 -*-
a, b, c, d = list(map(int, input().split()))
sq = [a * b, c * d]
if sq[0] > sq[1]:
ans = sq[0]
else:
ans = sq[1]
print(ans) | # -*- coding: utf-8 -*-
a, b, c, d = list(map(int, input().split()))
ans = max(a * b, c * d)
print(ans) | p03826 |
a,b,c,d = list(map(int,input().split()))
if a*b > c*d:
print((a*b))
else:
print((c*d))
| a,b,c,d = list(map(int,input().split()))
if a*b >= c*d:
print((a*b))
else:
print((c*d)) | p03826 |
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
A, B, C, D = list(map(int, readline().split()))
if A * B > C * D:
print((A * B))
else:
print((C * D))
... | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
A, B, C, D = list(map(int, readline().split()))
print((max(A * B, C * D)))
return
if __name__ == '__main__':
... | p03826 |
a, b, c, d = list(map(int, input().split()))
print((max(a * b, c * d) if a * b != c * d else a * b)) | a, b, c, d = list(map(int, input().split()))
print((max(a * b, c * d))) | p03826 |
import sys
from itertools import dropwhile
a = []
for v in sys.stdin:
a.append(int(v))
m = max([a.count(v) for v in set(a)])
try:
next(dropwhile(lambda x: True, (print(v) for v in set(a) if a.count(v) == m)))
except StopIteration:
pass
| a = [0] * 101
while True:
try:
a[int(eval(input()))] += 1
except:
break
maxv = max(a)
for i, v in enumerate(a):
if maxv == v:
print(i) | p00028 |
# 0028
array = []
while True:
try:
a = eval(input())
array.append(int(a))
except EOFError:
break
s = set(array)
mx = array.count(max(s, key = array.count))
for a in sorted(s):
if array.count(a) == mx:
print(a) | # 0028
array = []
while True:
try:
a = eval(input())
array.append(int(a))
except EOFError: break
s = set(array)
mx = max(sorted(s, reverse=True), key = array.count)
for a in sorted(s, key = array.count, reverse=True):
print(a)
if a == mx: break | p00028 |
d=[0 for i in range(101)]
while True:
try:
n=eval(input())
d[n]+=1
except:
break
for e in [i for i,e in enumerate(d) if e==max(d)]:
print(e) | d=[0]*101
while True:
try:
n=eval(input())
d[n]+=1
except:
break
tmp=max(d)
for i in range(101):
if d[i]==tmp: print(i) | p00028 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(eval(input()))
i = 1
num = [0] * 13
while True:
cnt = 0
for j in range(1, i+1):
if i % j == 0:
cnt += 1
if cnt >= 12:
i += 1
continue
if num[cnt] == 0:
num[cnt] = i
if num[n] > 0... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(eval(input()))
i = 1
num = [0] * 13
while True:
cnt = 0
for j in range(1, i+1):
if i % j == 0:
cnt += 1
if cnt > 12:
i += 1
continue
if num[cnt] == 0:
num[cnt] = i
if num[n] > ... | p01048 |
from collections import Counter
n = int(input())
s = Counter([input() for i in range(n)])
print(*['{} x {}'.format(k, s[k]) for k in ['AC', 'WA', 'TLE', 'RE']], sep='\n')
| n = int(input())
s = [input() for i in range(n)]
print(*['{} x {}'.format(k, s.count(k)) for k in ['AC', 'WA', 'TLE', 'RE']], sep='\n')
| p02613 |
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
t = S(... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(N):
t = S(... | p02613 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = [0]*4
for i in range(N):
S = readline().decode().rstrip()
if S == 'AC':
cnt[0] +=1
if S == 'WA':
cnt[1] +=1
if S == 'TLE':
c... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
S = read().decode().rstrip().split()
for s in ['AC','WA','TLE','RE']:
print(("{0} x {1}".format(s,S.count(s)))) | p02613 |
N,M = list(map(int,input().split()))
if N ==1 and M ==1:
print((0))
elif N ==1 and M != 1:
print((int(M*(M-1)/2)))
elif N != 1 and M ==1:
print((int(N*(N-1)/2)))
else:
a = N*(N-1)
b = M*(M-1)
print((int((a+b)/2))) | N,M = list(map(int,input().split()))
a = N*(N-1)
b = M*(M-1)
print((int((a+b)/2))) | p02729 |
a,b = input().split()
a = int(a)
b = int(b)
A = a-1
B = b-1
S = a*A/2
F = b*B/2
if a<1.9 and b<1.9:
print((0))
elif a<1.9 and b>1.9:
print((int(F)))
elif a>1.9 and b<1.9:
print((int(S)))
elif a>1.9 and b>1.9:
print((int(S+F)))
| a,b = input().split()
a = int(a)
b = int(b)
S = a*(a-1)/2
F = b*(b-1)/2
if a<1.9 and b<1.9:
print((0))
elif a<1.9 and b>1.9:
print((int(F)))
elif a>1.9 and b<1.9:
print((int(S)))
elif a>1.9 and b>1.9:
print((int(S+F)))
| p02729 |
import itertools
n, m = list(map(int, input().split()))
nn = []
i = 0
for _ in range(n):
nn.append(i)
i += 2
mm = []
i = 1
for _ in range(m):
mm.append(i)
i += 2
ans = 0
l = nn + mm
for v in itertools.combinations(l, 2):
if (v[0] + v[1]) % 2 == 0:
ans += 1
print(ans)... | n, m = list(map(int, input().split()))
print((n*(n-1)//2 + m*(m-1)//2))
| p02729 |
# -*- coding: utf-8 -*-
m, n = list(map(int, input().split(' ')))
print((int(m * (m - 1) / 2 + n * (n - 1) / 2)))
| # -*- coding: utf-8 -*-
n, m = list(map(int, input().split()))
print((n * (n -1) // 2 + m * (m - 1) // 2)) | p02729 |
a,b=list(map(int,input().split()))
import itertools
a1 = len(list(itertools.combinations(list(range(a)), 2)))
b1 = len(list(itertools.combinations(list(range(b)), 2)))
print((a1+b1)) | a,b=list(map(int,input().split()))
print((a*(a-1)//2+b*(b-1)//2)) | p02729 |
n,m = list(map(int, input().split()))
s = 0
for i in range(n):
s += i
for i in range(m):
s += i
print(s) | n,m = list(map(int, input().split()))
print((n*(n-1)//2 + m*(m-1)//2)) | p02729 |
n, m = list(map(int, input().split()))
a = []
for i in range(1,n+1):
a.append(2*i)
for j in range(1, m+1):
a.append(2*j - 1)
counter = 0
for i in range(len(a)-1):
for j in range(i+1, len(a)):
if (a[i] + a[j]) % 2 == 0:
counter += 1
print(counter) | n, m = list(map(int, input().split()))
ans = n * (n-1) // 2 + m * (m-1) // 2
print(ans) | p02729 |
N, M = list(map(int, input().split()))
if N <= 1: a = 0
else: a = N*(N-1) // 2
if M <= 1: b = 0
else: b = M*(M-1) // 2
print((a+b)) | N, M = list(map(int, input().split()))
# 下の式はN=0,1(M=0,1)の場合も成り立つ
a = N*(N-1) // 2
b = M*(M-1) // 2
print((a+b)) | p02729 |
import itertools
import math
N,M=list(map(int,input().split()))
if N==M==1 or N==M==0:
print((0))
exit()
if N==0:
even=0
odd=math.factorial(M)/(math.factorial(M-2)*2)
print((int(odd+even)))
exit()
if M==0:
odd=0
even=math.factorial(N)/(math.factorial(N-2)*2)
print((int(odd+even)))
e... | import itertools
import math
N,M=list(map(int,input().split()))
ans = 0
even = 0
odd = 0
if N > 1:
even += math.factorial(N) / (math.factorial(2)*math.factorial(N - 2))
if M > 1:
odd += math.factorial(M) / (math.factorial(2)*math.factorial(M - 2))
ans=even+odd
print((int(ans))) | p02729 |
n,m = list(map(int,input().split()))
print(((n*(n-1)//2) + (m*(m-1)//2))) | #!/usr/bin/env python3
n,m = list(map(int,input().split()))
print(((n*(n-1)//2) + (m*(m-1)//2)))
| p02729 |
import math
n, m = list(map(int, input().split()))
def combinations_count(a, b):
return math.factorial(a+b) // (2 * math.factorial(a+b-2))
print((combinations_count(n, m)-(n*m))) | n, m = list(map(int, input().split()))
print(((n*(n-1)//2)+(m*(m-1)//2))) | p02729 |
N, M = list(map(int, input().split()))
print((M * (M - 1) // 2 + N * (N - 1) // 2))
| N, M = list(map(int, input().split()))
print((N * (N - 1) // 2 + M * (M - 1) // 2))
| p02729 |
N,M=list(map(int,input().split()))
print((int(1/2*N*(N-1)+1/2*M*(M-1)))) | N,M=list(map(int,input().split()))
print((N*(N-1)//2+M*(M-1)//2)) | p02729 |
N,M=list(map(int,input().split()))
if N >= 2 or M >= 2:
print((int(N*(N-1)/2+M*(M-1)/2)))
else:
print((0)) | N,M=list(map(int,input().split()))
print((int(N*(N-1)/2+M*(M-1)/2))) | p02729 |
N, M = list(map(int, input().split()))
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans = 0
if N >= 2:
ans += combinations_count(N, 2)
if M >= 2:
ans += combinations_count(M, 2)
print(ans) | N, M = list(map(int, input().split()))
print((N*(N-1)//2 + M*(M-1)//2)) | p02729 |
n,m=list(map(int,input().split()))
if (n>0) and (m>0):
print((int(n*(n-1)/2+m*(m-1)/2)))
else:
print((int(max(n,m)*(max(n,m)-1)/2))) | n,m=list(map(int,input().split()))
print((int(n*(n-1)/2+m*(m-1)/2)))
| p02729 |
import math
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n, m = list(map(int, input().split()))
if not 0 <= n <= 100 and 0 <= m <= 100 and 2 <= n + m:
print('Unsupported...')
if n >= 2:
n_comb = combinations_count(n, 2)
else:
n_co... | """
A-The Number of Even Pairs
"""
n, m = list(map(int, input().split()))
print(((n * (n-1)) // 2 + (m * (m-1)) // 2))
| p02729 |
from operator import mul
from functools import reduce
N, M=list(map(int, input().split()))
def combinations_count(n, r):
r = min(r, n - r)
numer = reduce(mul, list(range(n, n - r, -1)), 1)
denom = reduce(mul, list(range(1, r + 1)), 1)
return numer // denom
if N>=2 and M>=2:
print((com... | N, M = list(map(int, input().split()))
print((N * (N - 1) // 2 + M * (M - 1) // 2)) | p02729 |
import math
N,M =list(map(int,input().split()))
if N==1 :
N1=0
elif N==0:
N1=0
else:
N1=(math.factorial(N))//(math.factorial(N-2)*2)
if M==1:
M1=0
elif M ==0:
M1=0
else:
M1=(math.factorial(M))//(math.factorial(M-2)*2)
print((str(N1+M1))) | a,b =list(map(int,input().split()))
sum=a*(a-1)//2+b*(b-1)//2
print(sum)
| p02729 |
N, M = list(map(int,input().split()))
print((N*(N-1)//2+M*(M-1)//2))
| N, M = list(map(int,input().split()))
print(((N*(N-1)+M*(M-1))//2)) | p02729 |
N, M = list(map(int, input().split()))
a = []
b = []
if M == 0:
for i in range(1,(2*N)+1):
if i%2==0 and i>0:
a.append(i)
elif N == 0:
for i in range(1,(2*M)+1):
if i%2==1:
b.append(i)
else:
for i in range(1,(2**N)+1):
if i%2==0 and i>0:
... | N, M = list(map(int, input().split()))
a = []
b = []
if M == 0:
for i in range(1,(2*N)+1):
if i%2==0 and i>0:
a.append(i)
elif N == 0:
for i in range(1,(2*M)+1):
if i%2==1:
b.append(i)
else:
for i in range(1,501):
if i%2==0 and i>0:
a... | p02729 |
from itertools import combinations
N, M = list(map(int, input().split()))
nlist = []
mlist = []
for i in range(N):
nlist.append(i)
for j in range(M):
mlist.append(j)
if N == 1 and M == 1:
print((0))
exit()
if N == 1:
print((len(list(combinations(mlist,2)))))
exit()
if M == 1... | N, M = list(map(int, input().split()))
print((N * (N-1) // 2 + M * (M-1) // 2)) | p02729 |
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction
mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35
def main():
n,m = l... | n,m = list(map(int,input().split()))
ans = n*(n-1)//2
ans += m*(m-1)//2
print(ans) | p02729 |
i = list(map(int, input().split()))
N = i[0]
M = i[1]
print((((N*(N-1))//2) + ((M*(M-1))//2))) | i = list(map(int, input().split()))
N = i[0]
M = i[1]
guusuu = (N * (N-1)) // 2
kisuu = (M * (M-1)) // 2
print((guusuu + kisuu)) | p02729 |
import math
n,m = list(map(int, input().split()))
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
a = 0
b = 0
if n >=2:
a = combinations_count(n, 2)
if m >= 2:
b = combinations_count(m, 2)
print((a+b)) | n, m = list(map(int, input().split()))
a = n*(n-1)//2
b = m*(m-1)//2
print((a+b)) | p02729 |
n, m = list(map(int, input().split()))
print((m*(m-1)//2 + n*(n-1)//2))
| print((sum([int(i)*(int(i)-1)//2 for i in input().split()])))
| p02729 |
def nCr(n, r):
return (fact(n) / (fact(r)
* fact(n - r)))
# Returns factorial of n
def fact(n):
res = 1
if n == 0:
res == 1
elif n == 1:
res == 1
else:
for i in range(2, n + 1):
res = res * i
return res
inList = lis... | def nCr(n, r):
return (fact(n) / (fact(r)* fact(n - r)))
def fact(n):
res = 1
if n == 0:
res == 1
elif n == 1:
res == 1
else:
for i in range(2, n + 1):
res = res * i
return res
inList = list(map(int, input().split()))
N = inList[0]
M = inLi... | p02729 |
for e in iter(input,'0 0'):
w,h=list(map(int,e.split()))
M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
for i in range(1,w):
for j in range(1,h):
a,b,c,d=[*M[i-1][j][:2],*M[i][j-1][2:]]
M[i][j]=[d,a+b,b,c+d]
print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5))
| def s():
for e in iter(input,'0 0'):
w,h=list(map(int,e.split()))
M=[[[1,0]*2 for _ in[0]*h]for _ in[0]*w]
for i in range(1,w):
for j in range(1,h):
a,b=M[i-1][j][:2]
c,d=M[i][j-1][2:]
M[i][j]=[d,a+b,b,c+d]
print(((sum(M[w-2][h-1][:2])+sum(M[w-1][h-2][2:]))%10**5))
if'__main__'==__name... | p00470 |
while True:
w, h = list(map(int, input().split()))
if w | h == 0:
break
dp = [[[0] * (w + 1) for _ in range(h + 1)] for _ in range(4)]
#0:u -> u, 1: u -> r, 2: r -> u, 3: r -> r
dp[0][1][0] = dp[3][0][1] = 1
for y in range(h):
for x in range(w):
dp[0][y +... | while True:
w, h = list(map(int, input().split()))
if w | h == 0:
break
dp = [[[0] * (w + 1) for _ in range(h + 1)] for _ in range(4)]
dp[0][1][0] = dp[3][0][1] = 1
for y in range(h):
for x in range(w):
dp[0][y + 1][x] += dp[0][y][x] + dp[2][y][x]
... | p00470 |
a=65280; b=61680; c=52428; d=43690; e=65535
base = [a, b, c, d, e, 0]
L = {el: 1 for el in base}
for i in range(6):
R = dict(L)
for p in R:
if R[p] < 16:
L[p ^ e] = min(L.get(p ^ e, 16), R[p] + 1)
if R[p]+3 < 16:
for q in R:
if R[p] + R[q] + 3 <=... | a=65280; b=61680; c=52428; d=43690; e=65535
L = {el: 1 for el in [a, b, c, d, e, 0]}
for i in range(6):
R = sorted(L.items(), key=lambda x: x[1])
for p, l in R:
if l < 16:
L[p ^ e] = min(L.get(p ^ e, 16), l+1)
if l+3 < 16:
for q, r in R:
... | p01105 |
a=65280; b=61680; c=52428; d=43690; e=65535
L = {el: 1 for el in [a, b, c, d, e, 0]}
for i in range(6):
R = sorted(L.items(), key=lambda x: x[1])
for p, l in R:
if l < 16:
L[p ^ e] = min(L.get(p ^ e, 16), l+1)
if l+3 < 16:
for q, r in R:
... | a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
while Q:
l, p = heappop(Q)
if L[p] < l: continue
if l+1 < L.get(p ^ e, 17):
L[p^e] = l+1
if l+1 < 16: heappush(Q... | p01105 |
a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
base = [a, b, c, d, e, 0]
Q = [(1, el) for el in base]
L = {el: 1 for el in base}
H = []
get = L.get
push = H.append
while Q:
l, p = heappop(Q)
if L[p] < l: continue
if l+1 < get(p ^ e, 17):
L[p ^ e] = l+1
... | a=65280; b=61680; c=52428; d=43690; e=65535
from heapq import heappush, heappop
Q = [(1, a), (1, b), (1, c), (1, d)]
L = {a: 1, b: 1, c: 1, d: 1, e: 1, e: 1, 0: 1}
H = []
get = L.get
push = H.append
while Q:
l, p = heappop(Q)
if L[p] < l: continue
if l+1 < get(p ^ e, 17):
L[p ^ e] = l+1
... | p01105 |
import sys
input = sys.stdin.readline
from heapq import heappush, heappop
N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
L = 1 << (i-1)
... | import sys
input = sys.stdin.readline
from heapq import heappush, heappop
N = int(eval(input()))
A = [int(x) for x in input().split()]
a_to_i = {a:i for i,a in enumerate(A)}
# sparse table を使ってRMQ
# parityの同じところだけを見るようにしておく
U = len(A).bit_length()
sp = [None,A]
for i in range(2,U):
L = 1 << (i-1)
... | p03641 |
from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
... | from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
... | p03641 |
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]... | p03641 |
# AOJ DSL_2_A "Range Minimum Query"
# SegmantTreeの実装
import sys
input = sys.stdin.readline
# 初期化最大値
INF = (1 << 31) - 1
class SegmentTree:
def __init__(self, N):
self.N = 2**(N-1).bit_length()
self.data = [[INF, -1] for _ in range(2*self.N-1)]
# O(N)で初期化
def compose(self... | import sys
input = sys.stdin.readline
# O(NlogN)構築、クエリO(1)のRMQ
# 変更はできない
class SparseTable():
def __init__(self, N, A):
self.N = N
self.logN = N.bit_length()
self.A = A
self.table = [[i for i in range(N)]]
for k in range(self.logN):
tab = []
... | p03641 |
import sys
input = sys.stdin.readline
def digit_sum(n, b):
res = 0
while n > 0:
res += n % b
n //= b
return res
def main():
n = int(eval(input()))
s = int(eval(input()))
ans = -1
if n < s:
ans = -1
elif n == s:
ans = n + 1
els... | import sys
input = sys.stdin.readline
def digit_sum(n, b):
if b == 1:
return n
res = 0
while n > 0:
res += n % b
n //= b
return res
def main():
n = int(eval(input()))
s = int(eval(input()))
ans = -1
if n == s:
ans = n + 1
else... | p04016 |
def digit_sum(n, s):
if s > n:
return -1
if s == n:
return n + 1
b = 2
while b**2 < n:
if f(b, n) == s:
return b
b += 1
p = int(n * 0.5)
while p >= 1:
b = (n - s) // p + 1
if b > 1 and f(b, n) == s:
retur... | def digit_sum(n, s):
if s > n:
return -1
if s == n:
return n + 1
b = 2
while b**2 < n:
if f(b, n) == s:
return b
b += 1
p = int(n ** 0.5)
while p >= 1:
b = (n - s) // p + 1
if b > 1 and f(b, n) == s:
retu... | p04016 |
import math
def f(b,n):
if n<b:
return n
else:
return f(b,n//b)+(n%b)
N=int(eval(input()))
S=int(eval(input()))
if N==S:
print((N+1))
else:
for b in range(2,int(math.sqrt(N))+2):
if f(b,N)==S:
print(b)
exit()
ans=10**13
for p in ran... | import math
n=int(eval(input()))
s=int(eval(input()))
def f(b,n):
if n<b:
return n
else:
return f(b,n//b)+(n%b)
def abc(N,S):
if N==S:
return N+1
else:
for b in range(2,int(math.sqrt(N))+2):
if f(b,N)==S:
return b
t... | p04016 |
from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(100000)
def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
S = int(eval(input()))
RN = int(sqrt(N))
RN += ((RN+1)**2 == N)
def func(b, N):
if b == 0:
return -1
tmp = 0
while ... | from math import sqrt, factorial
from sys import setrecursionlimit
setrecursionlimit(10000000)
def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
S = int(eval(input()))
RN = int(sqrt(N)) + 1
RN += ((RN+1)**2 == N)
def func(b, N):
if b <= 1:
return -1
tmp = 0
... | p04016 |
from collections import deque
x = int(eval(input()))
q = deque()
q.append((0, 0)) # (t, pos)
while q:
t, pos = q.popleft()
# print(t, pos)
if pos == x:
print(t)
break
else:
q.append((t+1, pos))
q.append((t+1, pos+t+1))
if pos-t >= 1:
... | x = int(eval(input()))
s = 0
for i in range(1, x+1):
s += i
if s >= x:
print(i)
break | p03779 |
Acsum=[]
acsum=0
for i in range(10**5):
acsum+=i
Acsum.append(acsum)
def binarysearch(x):
ng=-1
ok=10**5
while abs(ok-ng)>1:
mid=(ok+ng)//2
if Acsum[mid]>=x:
ok=mid
else:
ng=mid
return ok
n=int(eval(input()))
print((binarysearch(n))) | Acsum=[]
acsum=0
for i in range(5*10**4):
acsum+=i
Acsum.append(acsum)
def binarysearch(x):
ng=-1
ok=5*10**4
while abs(ok-ng)>1:
mid=(ok+ng)//2
if Acsum[mid]>=x:
ok=mid
else:
ng=mid
return ok
n=abs(int(eval(input())))
print((binarysearch(n)))
| p03779 |
x=int(eval(input()))
n=1
while 1/2*(n**2+n)<x:
n+=1
print(n) | x=int(eval(input()))
#n=1
#while 1/2*(n**2+n)<x:
# n+=1
#print(n)
left=0
right=x
while right-left>1:
mid=(left+right)//2
if (mid**2+mid)/2==x:
right=mid
break
if (mid**2+mid)/2<x:
left=mid
else:
right=mid
print(right) | p03779 |
n = int(eval(input()))
x,count = 1,1
while x < n:
x += count
count += 1
print((count if x == n else count-1)) | n = int(eval(input()))
x,count = 1,1
while x <= n:
x += count
count += 1
print((count-1)) | p03779 |
X = int(eval(input()))
dp = {}
dp[0] = 0
for i in range(1,X+1):
dp_ = dp.copy()
for key in list(dp.keys()):
if not key+i in list(dp.keys()): dp_[key+i] = i
else: dp_[key+i] = min(dp_[key+i], i)
#if not key-i in dp.keys(): dp_[key-i] = i
#else: dp_[key-i] = min(dp_[ke... | import math
X = int(eval(input()))
n = math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)
| p03779 |
import sys
input = sys.stdin.readline
def main():
X = int(eval(input()))
x = 0
for i in range(1, X+1):
x += i
if x >= X:
print(i)
return
if __name__ == '__main__':
main()
| import sys
import math
input = sys.stdin.readline
def main():
X = int(eval(input()))
print((math.ceil((-1 + math.sqrt(1+8*X))/2)))
if __name__ == '__main__':
main()
| p03779 |
x = int(eval(input()))
min_dt = 1001001001
min_i = 0
for i in range(1, x+1):
dt = abs(x - (i+1)*i//2)
if dt<min_dt:
min_dt = dt
min_i = i
if min_dt == 0:
print(i)
break
else:
print((min_i+min_dt))
| x = int(eval(input()))
i = 1
while True:
if (i+1)*i//2 >= x:
print(i)
break
i += 1
| p03779 |
import copy
X=int(eval(input()))
ava={0}
ava2={0}
for i in range(1,10**9):
ava=copy.deepcopy(ava2)
#print(i,ava,ava2)
if X not in ava:
for item in ava:
ava2.add(item+i)
ava2.add(item-i)
else:
print((i-1))
break | X=int(eval(input()))
for i in range(10**9):
if (i*(i+1))//2>=X:
print(i)
break | p03779 |
x=int(eval(input()))
num,i=0,0
while num<x:
i+=1
num+=i
print(i) | x=int(eval(input()))
t=0
a=0
while a<x:
t+=1
a+=t
print(t) | p03779 |
n = int(eval(input()))
dx =[0, 1]
l = [0]
i = 0
while(n not in l):
i += 1
l = list(set(l))
for j in range(len(l)):
a = l[0]
l.remove(l[0])
for k in range(2):
l.append(a + dx[k]*i)
print(i)
| import math
n = int(eval(input()))
print((math.ceil((-1+(1+8*n)**(1/2))/2))) | p03779 |
X=int(eval(input()))
#幅
from collections import deque
def dfs_2(start,goal):
q = deque([]) # スタック
q.append([start])
flg = 0
while flg==0:
p = q.popleft() # スタック取りだし(先頭)
jp = len(p)
# if p[-1]-jp == goal or p[-1]+jp == goal:
if p[-1]+jp == goal:
return jp
else:
... | X=int(eval(input()))
s=0
for t in range(X+1):
s+=t
if s>=X:
print(t)
break | p03779 |
import bisect
x = int(eval(input()))
xx = x//2
a = []
s = 0
for i in range(xx):
s += i+1
a.append(s)
#print (s)
r = bisect.bisect_left(a, x)
print((r+1))
| import bisect
x = int(eval(input()))
xx = x//2
a = []
s = 0
for i in range(x+1):
if (i * (i+1))/2 >= x:
print(i)
exit() | p03779 |
int_x = int(eval(input()))
li_dist = list()
for i in range(1, int_x + 1):
if len(li_dist) == 0:
li_dist = [i, -i, 0]
else:
li_dist = [x + y for x in [i, -i, 0] for y in li_dist]
if int_x in li_dist:
print(i)
exit(0)
| x = int(eval(input()))
w = 0
for i in range(1, x + 1):
w += i
if w >= x:
print(i)
exit(0)
| p03779 |
def main():
x = int(eval(input()))
i = 1
p = 0
while True:
if i == (x - p):
print(i)
break
if i + 1 == (x - p):
print((i + 1))
break
else:
p += i
i += 1
if __name__ == '__main__':
mai... | def main():
x = int(eval(input()))
k = int(x ** .5)
i = 0
while True:
p = i * (i + 1) // 2
if p >= x:
print(i)
break
i += 1
if __name__ == '__main__':
main()
| p03779 |
import bisect
x = int(eval(input()))
a = [1]
s = 1
for i in range(2, x+1):
s += i
a.append(s)
if x in a:
print((a.index(x) + 1))
exit()
print((bisect.bisect_right(a, x)+1))
| import bisect
from math import sqrt
x = int(eval(input()))
a = [1]
s = 1
for i in range(2, 2*int(sqrt(x))):
s += i
a.append(s)
if x in a:
print((a.index(x) + 1))
exit()
print((bisect.bisect_right(a, x)+1))
| p03779 |
import bisect
from math import sqrt
x = int(eval(input()))
a = [1]
s = 1
for i in range(2, 2*int(sqrt(x))):
s += i
a.append(s)
if x in a:
print((a.index(x) + 1))
exit()
print((bisect.bisect_right(a, x)+1))
| from math import sqrt
x = int(eval(input()))
t = (-1+sqrt(8*x+1))/2
a = int(t)
if a == t:
print(a)
else:
print((a+1))
| p03779 |
x=int(eval(input()))
import math
print((math.ceil((-1+math.sqrt(1+8*x))/2))) | x=int(eval(input()))
import math
print((math.ceil((-1+math.sqrt(1+8*x))/2)))
#{1,2,3,..n}はΣkなので 1/2n(n+1)=xを解くとできる
| p03779 |
from math import ceil
x = int(eval(input()))
n = (2 * x + 0.25) ** 0.5 - 0.5
print((ceil(n))) | print((int((2*int(eval(input()))+1/4)**0.5+0.5-10**(-5)))) | p03779 |
def main():
X = int(eval(input()))
cur = 0
p = 0
for _ in range(X):
if cur == p:
cur += 1
p = 1
else:
p += 1
print(cur)
if __name__ == '__main__':
main() | def main():
X = int(eval(input()))
i = 1
while (i*(i+1))//2 < X:
i += 1
print(i)
if __name__ == '__main__':
main() | p03779 |
x = int(eval(input()))
temp = 0
for i in range(x+1):
temp += i
if temp >= x:
print(i)
exit()
| x = int(eval(input()))
for i in range(10**6):
if i*(i+1)//2 >= x:
print(i)
exit()
| p03779 |
def create_koho(X):
koho = [1]
koho_sum = 1
i = 1
while koho_sum < X:
i += 1
koho.append(i)
koho_sum += i
return koho
X = int(eval(input()))
koho = create_koho(X)
nokori = X
ans = 0
for i in reversed(koho):
if nokori >= i:
nokori -= i
... | X = int(eval(input()))
i = 1
koho_sum = i
while koho_sum < X:
i += 1
koho_sum += i
print(i)
| p03779 |
# -*- coding: utf-8 -*-
X = int(eval(input()))
sumX = []
sum = 0
for i in range(1,X+1):
sum += i
sumX.append(sum)
# print(sumX)
for i in range(X):
j = X - i
if X > sumX[j-1]:
print((j+1))
exit()
print((1))
| # -*- coding: utf-8 -*-
X = int(eval(input()))
# sumX = []
sum = 0
for i in range(1,X+1):
sum += i
# print("sum=",sum)
if sum >= X:
print(i)
# print("i=", i)
break
| p03779 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
x = int(eval(input()))
i, pos = 0, set([0])
while True:
inner = False
new_pos = set()
for p in pos:
if p + i == x or p - i == x:
inner = True
break
new_pos.add(p)
new_pos.add(p + i)
new_pos... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
x = int(eval(input()))
total = 0
for i in range(x + 1):
total += i
if total >= x:
print(i)
break
| p03779 |
X = int(eval(input()))
def jump(s, t):
ns = set()
for n in s:
ns.add(n - t)
ns.add(n)
ns.add(n + t)
return ns
def main():
t = 0
curr = set([0])
while X not in curr:
t += 1
curr = jump(curr, t)
print(t)
if __name__ == '__main__':
... | X = int(eval(input()))
def main():
t = 0
curr = 0
while curr < X:
t += 1
curr += t
print(t)
if __name__ == '__main__':
main() | p03779 |
n = int(eval(input()))
ls = [e for e in range(n+1)]
if (int((2*n)**(1/2))+1)*(int((2*n)**(1/2)))/2 < n:
print((int((2*n)**(1/2))+1))
else:
print((int((2*n)**(1/2)))) | n = int(eval(input()))
if (int((2*n)**(1/2))+1)*(int((2*n)**(1/2)))/2 < n:
print((int((2*n)**(1/2))+1))
else:
print((int((2*n)**(1/2)))) | p03779 |
import sys
x = int(sys.stdin.readline().rstrip())
def main():
l = 0
r = x + 1
while l + 1 < r:
m = (l + r) // 2
if (1 + m) * m // 2 >= x:
r = m
else:
l = m
return r
if __name__ == '__main__':
ans = main()
print(ans) | import sys
x = int(sys.stdin.readline().rstrip())
def main():
n = int((x * 2) ** 0.5)
res = n if (1 + n) * n // 2 >= x else n + 1
print(res)
if __name__ == '__main__':
main() | p03779 |
def main():
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
from itertools import accumulate
S = [i for i in accumulate(list(range(1, N+1)))]
def is_ok(mid):
if N <= S[mid]:
return True
else:
return False
def binary_s... | def main():
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
from itertools import accumulate
S = [i for i in accumulate(list(range(1, min(N+1, 100000))))]
def is_ok(mid):
if N <= S[mid]:
return True
else:
return False
... | p03779 |
def main():
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
from itertools import accumulate
S = [i for i in accumulate(list(range(1, min(N+1, 100000))))]
def is_ok(mid):
if N <= S[mid]:
return True
else:
return False
... | def main():
import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
from itertools import accumulate
S = [i for i in accumulate(list(range(1, min(N+1, 44725))))]
def is_ok(mid):
if N <= S[mid]:
return True
else:
return False
... | p03779 |
X = int(eval(input()))
ans = 0
for i in range(1,X+1):
if ans + i <= X:
ans += i
else:
print(i)
exit()
if ans == X:
print(i)
exit() | X = int(eval(input()))
ans = 0
for i in range(1,X+1):
ans += i
if X <= ans:
print(i)
exit() | p03779 |
import sys
def solve():
x = int(input())
t = 1
while calc_sum(t) < x:
t += 1
print(t)
def calc_sum(t):
return t * (t + 1) // 2
def debug(x, table):
for name, val in table.items():
if x is val:
print('DEBUG:{} -> {}'.format(name, val), file=sys.... | import sys
def solve():
x = int(eval(input()))
k = 0
while k * (k + 1) // 2 < x:
k += 1
print(k)
if __name__ == '__main__':
solve() | p03779 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.