input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
from collections import Counter
n=int(input().rstrip())
d=dict()
for _ in range(n):
s=input().rstrip()
if s not in d:
d[s]=1
else:
d[s]+=1
ans=Counter(d).most_common()
ans.sort(key=lambda x: (-x[1],x[0]))
m=ans[0][1]
for i in ans:
if i[1]!=m:
break
print((i[0])) | #import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_ri... | p02773 |
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max_vote:
ans.append(i)
print(("\n".join(sorted(ans)))) | def main():
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in range(n):
s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max_vote:
... | p02773 |
def main():
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
for _ in [0]*n:
s.append(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max_vote:
... | def main():
from collections import Counter
import sys
input = sys.stdin.readline
n=int(eval(input()))
s=[]
ap = s.append
for _ in [0]*n:
ap(input().rstrip())
c = Counter(s)
ans=[]
max_vote = max(c.values())
for i,j in list(c.items()):
if j == max... | p02773 |
import collections
N = int(input())
S = [input() for _ in range(N)]
if len(S) == len(set(S)):
[print(a) for a in sorted(S)]
else:
c = collections.Counter(S)
ans = sorted([i[0] for i in c.items() if i[1] == c.most_common()[0][1]])
[print(a) for a in ans]
| import collections
N = int(input())
S = [input() for _ in range(N)]
if len(S) == len(set(S)):
ans = S
else:
ans = []
c = collections.Counter(S)
c_common = c.most_common()
max_vote = c_common[0][1]
for k in range(len(set(S))):
if c_common[k][1]== max_vote:
ans.append(c_common[k][0])
... | p02773 |
from collections import Counter
N = int(input())
c = Counter()
for i in range(N):
k = input()
v = c.setdefault(k, 0)
c[k] = v + 1
ans = sorted([k for k,n in c.items() if n == max(c.values())])
[print(k) for k in ans]
| from collections import Counter
N = int(input())
c = Counter()
l = 0
for i in range(N):
k = input()
v = c.setdefault(k, 0)
c[k] = v + 1
if l < c[k]:
l = c[k]
ans = sorted([k for k, n in c.items() if n==l])
[print(k) for k in ans]
| p02773 |
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
c = sorted(list(c.items()), key=lambda x: (-x[1], x[0]))
num = c[0][1]
for i, j in c:
if j == num:
print(i)
else:
quit() | from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
num = max(c.values())
ans = [i for i, j in list(c.items()) if j == num]
ans.sort()
print(('\n'.join(ans))) | p02773 |
import collections, sys
n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
s.append(sys.stdin.readline().replace('\n',''))
if len(set(s)) == 1:
print((s[0]))
sys.exit()
c = collections.Counter(s)
max = c.most_common()[0][1]
l = []
l.append(c.most_common()[0][0])
for i in range(0,len(s... | import collections, sys
n = sys.stdin.readline()
s = []
for _ in range(0,int(n)):
s.append(sys.stdin.readline().replace('\n',''))
c = collections.Counter(s)
max = c.most_common()[0][1]
l = sorted(list(dict([x for x in list(c.items()) if x[1]==max]).keys()))
for k in l:
print(k) | p02773 |
def resolve():
import sys
from collections import Counter
n = int(eval(input()))
s = [sys.stdin.readline().rstrip() for i in range(n)]
d = Counter(s).most_common()
e = d[0][1]
f = ([i for i in set(s) if s.count(i) == e])
f = sorted(f)
for i in f:
print(i)
resolve() | def resolve():
import sys
from collections import Counter
n = int(eval(input()))
s = [sys.stdin.readline().rstrip() for i in range(n)]
d = Counter(s).most_common()
e = d[0][1]
ans = []
for i in range(len(d)):
if d[i][1] != e:
break
else:
... | p02773 |
import collections
n = int(input())
words = []
for i in range(n):
words.append(input())
c = collections.Counter(words)
max_w = []
for i in c.most_common():
if i[1]==c.most_common()[0][1]:
max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]
| import collections
n = int(input())
words = []
[words.append(input()) for i in range(n)]
c = collections.Counter(words)
cc = c.most_common()
max_w = []
for i in cc:
if i[1]==cc[0][1]:
max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]
| p02773 |
import sys
from collections import Counter
input = sys.stdin.readline
def main():
N = int(input())
S = [""] * N
for i in range(N):
S[i] = input().rstrip()
c = Counter(S)
max_v = max(c.values())
ans = [k for k, v in c.items() if v == max_v]
ans.sort()
print(*... | import sys
from collections import Counter
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = [""] * N
for i in range(N):
S[i] = input().rstrip()
c = Counter(S)
max_v = max(c.values())
ans = [k for k, v in list(c.items()) if v == max_v]
ans.sort()
... | p02773 |
from collections import defaultdict
n = int(input())
S = [input() for _ in range(n)]
d = defaultdict(int)
for s in S:
d[s] += 1
m = max(d.values())
items = d.items()
a = sorted([c[0] for c in items if c[1] == m])
[print(i) for i in a]
| from collections import Counter
def main():
n = int(input())
S = [input() for _ in range(n)]
c = Counter(S).most_common()
V = c[0][1]
ans = [k for k, v in c if v == V]
[print(a) for a in sorted(ans)]
if __name__ == '__main__':
main()
| p02773 |
import sys
input = sys.stdin.readline
N = int(eval(input()))
S = []
for x in range(N):
S.append(input().rstrip())
S_label_n = []
S_label = list(set(S))
for x in S_label:
S_label_n.append(S.count(x))
max_n =max(S_label_n)
maxIndex = [i for i, x in enumerate(S_label_n) if x ==max_n ]
ans_list = []
fo... | import sys
input = sys.stdin.readline
N = int(eval(input()))
dictS = {}
for x in range(N):
tmp = input().rstrip()
if tmp in dictS:
dictS[tmp] = dictS[tmp]+1
else:
dictS[tmp]=1
max_n =max(dictS.values())
maxIndex = [x for x in list(dictS.items()) if x[1] ==max_n ]
ans_li... | p02773 |
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
a = c.most_common()[0][1]
ans = []
for i in range(len(c)):
if c.most_common()[i][1] == a:
ans.append(c.most_common()[i][0])
ans.sort()
print(*ans,sep="\n")
|
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
C = c.most_common()
a = C[0][1]
ans = []
for i in range(len(c)):
if C[i][1] == a:
ans.append(C[i][0])
ans.sort()
print(*ans,sep="\n")
| p02773 |
from collections import Counter
n = int(input())
S = [input() for i in range(n)]
L = Counter(S)
m = 0
for v in L.values():
m = max(m, v)
ans = []
for k, v in L.items():
if v == m:
ans.append(k)
ans.sort()
print(*ans, sep="\n")
| from collections import Counter
N = int(input())
S = [input() for i in range(N)]
C = Counter(S)
max_cnt = max(C.values())
names = [names for names, values in C.items() if values == max_cnt]
names.sort()
print(*names, sep="\n")
| p02773 |
from collections import Counter
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
counted = Counter(s)
#最頻値が同値である場合全て出力したい
#頻出数ではなく、文字だけ出力したい
#print(s.most_common()[0])
ret = [letter for letter,count in counted.most_common() if count == counted.most_common()[0][1]]
new_ret=sorte... | from collections import Counter
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得
ans=[]
counted = Counter(s)#
counted_sort=counted.most_common()
for i in range(len(counted_sort)):
if counted_sort[i][1]==counted_sort[0][1]:
ans.append(counted_sort[i][0])
[print(... | p02773 |
n, k = list(map(int, input().split()))
a = [eval(input()) for i in range(n+k)]
cnt = {i:0 for i in range(n)}
for i in range(n,n+k):
for j in range(n):
if a[i] >= a[j]:
cnt[j] += 1
break
print(sorted(list(cnt.items()), key = lambda x:x[1], reverse = True)[0][0] + 1) | n, k = list(map(int, input().split()))
a = [eval(input()) for i in range(n+k)]
c = [0]*n
for i in range(n,n+k):
for j in range(n):
if a[i] >= a[j]:
c[j] += 1
break
print(c.index(max(c)) + 1) | p00516 |
T=int(eval(input()))
Query=[]
for i in range(T):
Query.append(list(map(int,input().split())))
for i in range(T):
appear=[]
appear.append(Query[i][0])
while(True):
if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1]:
print('No')
break;
Query[i][0]=Query[i][0]%Qu... | def gcd(a,b):
while b:
a,b=b,a%b
return a
T=int(eval(input()))
Query=[]
for i in range(T):
Query.append(list(map(int,input().split())))
for i in range(T):
while(True):
if Query[i][0]%Query[i][1]>Query[i][2] or Query[i][0]<Query[i][1] or Query[i][1]>Query[i][3]:
print('No')
... | p03297 |
t = int(eval(input()))
a = []
for i in range(t):
a.append(list(map(int,input().split())))
for j in a:
b = j[0]
for k in range(j[1]):
if j[0] < j[1]:
print("No")
break
j[0] %= j[1]
if j[0] <= j[2]:
j[0] += j[3]
else:
print("No")
break
if j[0] < j[1]... | def gcd(x, y):
while y:
x, y = y, x % y
return x
t = int(eval(input()))
a = []
d = 0
for i in range(t):
a.append(list(map(int,input().split())))
for j in a:
if j[0] < j[1] or j[1] > j[3]:
print("No")
else:
b = j[0] % j[1]
k = gcd(j[1],j[3])
c = j[0] % k
d = j[2] % k
... | p03297 |
def main():
t = int(eval(input()))
for _ in range(t):
a, b, c, d = list(map(int, input().split()))
if (a < b or d < b):
print("No")
continue
if (c >= b - 1):
print("Yes")
continue
a %= b
if a > c:
print("No")
continue
d %= b
if d == ... | def gcd(a, b):
if b == 0:return a
return gcd(b, a % b)
t = int(eval(input()))
for _ in range(t):
a, b, c, d = list(map(int, input().split()))
#exception
if a < b or d < b:
print("No")
continue
if c >= b:
print("Yes")
continue
g = gcd(d, b)
... | p03297 |
t = int(eval(input()))
for i in range(t):
a, b, c, d = list(map(int, input().split()))
rec = [a]
flag = False
num = 0
while True and num < 100000:
if a < b:
break
else:
a = a % b
if a <= c:
a += d
else:
bre... | T = int(eval(input()))
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
for i in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b:
print('No')
elif d < b:
print('No')
elif c >= b:
print('Yes')
else:
... | p03297 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from math import ceil
def solve(A, B, C, D):
zaiko = A
visited = set([zaiko])
while zaiko >= B:
zaiko -= B
if zaiko > C:
zaiko -= ceil((zaiko - C) / B) * B
if zaiko < 0 or zaiko > C: return False
za... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
from math import ceil
def gcd(a, b):
assert a > 0 and b > 0
while b > 0:
r = a % b
a = b
b = r
return a
def solve(A, B, C, D):
if A < B or D < B: return False
if A % B > C: return False
if D % B == 0: retur... | p03297 |
class query:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def isEternal(self):
if self.a < self.b:
return "No"
if self.a % self.b > self.c:
return "No"
if self.d < self.b:
retur... | def gcd(a, b):
r = a % b
while r != 0:
a, b, r = b, r, b % r
return b
class query:
def __init__(self, a, b, c, d):
self.a = a
self.b = b
self.c = c
self.d = d
def isEternal(self):
if self.a < self.b:
return "No"
if s... | p03297 |
from math import gcd
def solve(a,b,c,d):
if a < b:
return False
if d < b:
return False
g = gcd(b,d)
c += 1
m = c + (a-c)%g
return b <= m
T = int(eval(input()))
for _ in range(T):
print(('Yes' if solve(*list(map(int,input().split()))) else 'No')) | import math
for _ in range(int(eval(input()))):
a,b,c,d = list(map(int,input().split()))
print(('Yes' if b <= min(a, d, c+1+(a-c-1)%math.gcd(b,d)) else 'No')) | p03297 |
import math
for _ in range(int(eval(input()))):
a,b,c,d = list(map(int,input().split()))
print(('Yes' if b <= min(a, d, c+1+(a-c-1)%math.gcd(b,d)) else 'No')) | from math import gcd
def solve(a,b,c,d):
if a < b:
return False
if d < b:
return False
g = gcd(b,d)
m = b - (b-a-1)%g - 1
return m <= c
T = int(eval(input()))
for _ in range(T):
print(('Yes' if solve(*list(map(int,input().split()))) else 'No'))
| p03297 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, perm... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, perm... | p03297 |
def solve(P):
A, B, C, D = P
if A<B or D<B:
return False
if C >= B-1:
return True
g = gcd(B,D)
return B + A%g - g <= C
from math import gcd
T = int(eval(input()))
for _ in range(T):
P = list(map(int, input().split()))
print(("Yes" if solve(P) else "No")) | def solve(P):
A, B, C, D = P
if A<B or D<B:
return False
if C >= B-1:
return True
g = gcd(B,D)
return A%g + ((B-A%g-1)//g)*g <= C
from math import gcd
T = int(eval(input()))
for _ in range(T):
P = list(map(int, input().split()))
print(("Yes" if solve(P) else "... | p03297 |
t = int(eval(input()))
abcd_list = [[int(i) for i in input().split()] for _ in range(t)]
for i in range(len(abcd_list)):
a, b, c, d = abcd_list[i]
_a = a
is_ok = True
for j in range(100000):
if d < b:
is_ok = False
break
if _a - b > c:
... | def gcd(a, b):
while b:
a, b = b, a % b
return a
t = int(eval(input()))
abcd_list = [[int(i) for i in input().split()] for _ in range(t)]
for i in range(len(abcd_list)):
a, b, c, d = abcd_list[i]
if b > a:
print("No")
continue
if b > d:
print("No")
continue... | p03297 |
def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
T = int(eval(input()))
for _ in range(T):
a, b, c, d = list(map(int, input().split()))
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
... | def gcd(a, b):
return a if b == 0 else gcd(b, a % b)
T, *L = list(map(int, open(0).read().split()))
for a, b, c, d in zip(*[iter(L)] * 4):
if a < b or d < b:
flag = False
elif c >= b - 1:
flag = True
else:
g = gcd(b, d)
flag = (b + a % g - g) <= c
i... | p03297 |
def judge(a,b,c,d):
#calc border
if a-c<0:
border = 0
else:
if (a-c)%b == 0:
border = int((a-c)/b)
else:
border = int((a-c)/b)+1
start = a-border*b
return start
def check(a,b,c,d):
if a-b<0:
return False
... |
def findGCD(a,b):
if a%b == 0:
return b
else:
return findGCD(b,a%b)
def judge(a,b,c,d):
if a<b or d<b:
return False
elif c >= b:
return True
else:
g = findGCD(b,d)
thr = b-g+a%g
if thr > c:
return False
... | p03297 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 解説pdf https://img.atcoder.jp/agc026/editorial.pdf を見た
import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys
def gcd(a, b):... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# 本番中には解けなかった。解説pdfにある3つの場合分けはできた。
# B個の購入を可能なかぎりしたあとの個数が、「Cより大きくBより小さい」値に
# なることがあるとNoになる、ということには気づいたのだが、
# どう解いてよいか混乱して手がつけられなかった
#
#
# 解説pdf https://img.atcoder.jp/agc026/editorial.pdf を見た
#
# B個の購入を行った直後の個数の遷移を、mod Bの世界で考える。
# 最初は A mod B個。
# B個の購入を可... | p03297 |
import sys
iT = int(eval(input()))
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]
#わからんから解説見た。解説見たけどgcdの下りが自分で導出できんかったのでとりあえずバカループでなんとかしてみた。これで通るかな。
def f調1(iA,iB,iC,iD):
if iA < iB or iD < iB:
return False
if iC >= iB :
return True
iJ = iA % iB
iK ... | import sys
iT = int(eval(input()))
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]
def fGcd(iX,iY):
while iY:
iX,iY= iY,iX%iY
return iX
#これものすごくわりきってるけど通るのか?
def fFunc(iA,iB,iC,iD):
if iA < iB or iD < iB:
return False
elif iC >= iB :
... | p03297 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
import math
for i in range(int(eval(input()))):
a, b, c, d = list(map(int, input().split()))
if a < b:
print('No')
conti... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
import math
for i in range(int(eval(input()))):
a, b, c, d = list(map(int, input().split()))
if a < b:
print('No')
conti... | p03297 |
T = int(eval(input()))
a = []
for i in range(T):
a.append(list(map(int, input().split())))
for r in a:
s, b, c, d = r[0], r[1], r[2], r[3]
mod_list = []
if (s < b) or (b>d):
print('No')
continue
if (c>b):
print('Yes')
continue
while True:
s =... | def gcd(a, b):
while b:
a, b = b, a % b
return a
T = int(eval(input()))
a = []
for i in range(T):
a.append(list(map(int, input().split())))
for r in a:
s, b, c, d = r[0], r[1], r[2], r[3]
mod_list = []
if (s < b) or (b>d):
print('No')
continue
if (c>b):
... | p03297 |
def gcd(X,Y):
if X < Y:
tmp = X
X = Y
Y = tmp
if Y == 0:
return 0
while X % Y != 0:
r = X % Y
X = Y
Y = r
return Y
T = int(input())
Q = [list(map(int, input().split())) for _ in range(T)]
for q in Q:
A,B,C,D = q
if B > A:
print('No')
elif B > D:
print... | def gcd(X,Y):
if X < Y:
tmp = X
X = Y
Y = tmp
if Y == 0:
return 0
while X % Y != 0:
r = X % Y
X = Y
Y = r
return Y
T = int(input())
Q = [list(map(int, input().split())) for _ in range(T)]
for q in Q:
A,B,C,D = q
if B > A:
print('No')
elif B > D:
print... | p03297 |
def main():
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
n = 0
while n < K:
if C < B or C < A:
C = C * 2
n += 1
if C > B > A:
print('Yes')
return
elif B < A:
B = B * 2
... | def main():
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
cnt = 0
while A >= B:
B = B * 2
cnt += 1
while B >= C:
C = C * 2
cnt += 1
if cnt <= K:
print('Yes')
else:
print('No')
main()
| p02601 |
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
while k != 0:
if a > b:
b *= 2
k -= 1
if b > c:
c *= 2
k -= 1
if a < b and b < c:
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
ans = 'Yes'
while a >= b:
b *= 2
k -= 1
while b >= c:
c *= 2
k -= 1
if k < 0:
ans = 'No'
print(ans) | p02601 |
A, B, C=list(map(int, input().split()))
K=int(eval(input()))
i=0
while i<K:
if B<A:
B*=2
i+=1
elif C<B:
C*=2
i+=1
if A<B<C:
print('Yes')
else:
print('No') | A, B, C=list(map(int, input().split()))
K=int(eval(input()))
i=0
while i<K:
if B<=A:
B*=2
elif C<=B:
C*=2
i+=1
if A<B<C:
print('Yes')
else:
print('No') | p02601 |
#!/usr/bin python3
# -*- coding: utf-8 -*-
RGB_ = list(map(int, input().split()))
K = int(eval(input()))
from itertools import product
L = list(product(list(range(3)), repeat=K))
for l in L:
RGB=RGB_[:]
for i in l:
RGB[i] = RGB[i]*2
if RGB[2]>RGB[1]>RGB[0]:
print('Yes'... | #!/usr/bin python3
# -*- coding: utf-8 -*-
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
ret = 0
while B<=A:
B *= 2
ret += 1
while C<=B:
C *= 2
ret += 1
if ret <=K:
print('Yes')
else:
print('No')
| p02601 |
import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし
def ... | import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
A,B,C = MI()
K = I()
a = 0 # 魔術を行った回数
while B <= A:
B *= 2
a += 1
while C <= B:
C *= 2
a += 1
print(('Yes' if a <= K else 'No'))
| p02601 |
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
while k > 0:
if b < a:
b *= 2
k -= 1
elif c < b:
c *= 2
k -= 1
if a < b and b < c:
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
if b > a:
multiplier = 2 ** k
if c * multiplier > b:
ans = 'Yes'
else:
ans = 'No'
else:
while b <= a:
b *= 2
k -= 1
multiplier = 2 ** k
if c * multiplier > b:
ans = 'Yes'
else:
ans = 'No'
print(an... | p02601 |
def LI():
return list(map(int,input().split()))
red,green,blue=LI()
k=int(eval(input()))
for i in range(0,k+1):
r=red
g=green*pow(2,i)
b=blue*pow(2,k-i)
if r<g<b:
print("Yes")
# print(red,green,blue)
exit()
print("No")
| a,b,c=list(map(int,input().split()))
k=int(eval(input()))
for i in range(0,k+1):
if a<b*2**i<c*2**(k-i):
print("Yes")
exit()
print("No") | p02601 |
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
a, b, c = list(map(int, readline().split()))
k = int(readline())
cnt = 0
while a >= b:
b *= 2
cnt += 1
while b >= c:
c *= 2
... | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
cnt = 0
while a >= b:
b *= 2
cnt += 1
while b >= c:
c *= 2
cnt += 1
if cnt <= k:
print("Yes")
else:
print("No")
| p02601 |
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
i = 0
while i < K:
if B <= A:
B *= 2
i += 1
else:
if C <= B:
C *= 2
i += 1
if A < B < C:
print("Yes")
else:
print("No")
| A, B, C = list(map(int, input().split()))
K = int(eval(input()))
for i in range(K):
if B <= A:
B *= 2
else:
if C <= B:
C *= 2
if A < B < C:
print("Yes")
else:
print("No")
| p02601 |
a,b,c=list(map(int,input().split()))
k=int(eval(input()))
if a<b:
if b<c:
print('Yes')
else:
count=0
while b>=c:
b*=2
count+=1
if count<=k:
print('Yes')
else:
print('No')
else:
count=0
while a>=b:
... | a,b,c=list(map(int,input().split()))
k=int(eval(input()))
if a<b:
if b<c:
print('Yes')
else:
count=0
while b>=c:
c*=2
count+=1
if count<=k:
print('Yes')
else:
print('No')
else:
count=0
while a>=b:
... | p02601 |
A,B,C=list(map(int,input().split()))
K=int(eval(input()))
while K>0:
while B<=A:
B*=2
K-=1
while C<=B:
C*=2
K-=1
if K>=0:
print("Yes")
else:
print("No") | A,B,C=list(map(int,input().split()))
K=int(eval(input()))
while B<=A:
B*=2
K-=1
while C<=B:
C*=2
K-=1
if K>=0:
print("Yes")
else:
print("No") | p02601 |
from sys import stdin
input = stdin.readline
a,b,c = list(map(int, input().split()))
k = int(eval(input()))
cnt = 0
while a >= b:
b *= 2
cnt += 1
while b >= c:
c *= 2
cnt += 1
if(cnt <= k):
print("Yes")
else:
print("No") | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
ans = False
for i in range(k + 1):
for j in range(k-i+1):
for l in range(k-i-j+1):
aa = a * pow(2,i)
bb = b * pow(2,j)
cc = c * pow(2,l)
# print("{0} {1} {2}".format(aa,bb,cc))
... | p02601 |
A, B, C = list(map(int,input().split()))
K = int(eval(input()))
ans = 0
if A < B < C:
a = "Yes"
else:
while True:
if B < A:
B *= 2
ans += 1
if ans == K:
break
if B > C:
C *= 2
ans += 1
if ans == K:
... | A, B, C = list(map(int,input().split()))
K = int(eval(input()))
ans = 0
if A < B < C:
a = "Yes"
else:
while True:
if B <= A:
B *= 2
ans += 1
if ans == K:
break
if A < B < C:
a = "Yes"
break
if B >= C... | p02601 |
A,B,C=list(map(int,input().split()))
K=int(eval(input()))
i=0
while i<K:
if A>=B:
B*=2
elif B>=C:
C*=2
i+=1
print(('Yes' if A<B<C else 'No')) | A,B,C=list(map(int,input().split()))
K=int(eval(input()))
i=0
while i<K:
if A>=B:
i+=1
B*=2
else:
break
while i<K:
if B>=C:
i+=1
C*=2
else:
break
print(('YNeos'[(A>=B)or(B>=C)::2])) | p02601 |
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
# 標準入力を取得
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
# 求解処理
ans = str()
k_b = 0
if A >= B:
k_b = int(math.log(A / B) / math.log(2)) + 1
if k_b > K:
ans = "No"
else:
if 2**(K - k_b) * C > 2**k_b * B:
ans = "Yes... | # -*- coding: utf-8 -*-
def get_input() -> tuple:
"""
標準入力を取得する.
Returns:\n
tuple: 標準入力
"""
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
return A, B, C, K
def main(A: int, B: int, C: int, K: int) -> None:
"""
メイン処理.
Args:\n
... | p02601 |
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
while K > 0:
if A > B:
B *= 2
K -= 1
else:
if B > C:
C *= 2
K -= 1
if A < B and B < C:
print("Yes")
else:
print("No") | A, B, C = list(map(int, input().split()))
K = int(eval(input()))
n = 0
while A >= B:
B *= 2
n += 1
while B >= C:
C *= 2
n += 1
if n <= K:
print("Yes")
else:
print("No") | p02601 |
import math
a,b,c = list(map(int,input().split()))
k = int(eval(input()))
ans = 0
while(a >= b):
b = pow(b,2)
ans += 1
while(b >= c):
c = pow(c,2)
ans += 1
if(ans <= k):
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
ans = 0
while b <= a:
b *= 2
ans += 1
while c <= b:
c *= 2
ans += 1
print(('Yes' if ans <= k else 'No')) | p02601 |
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
answer = "No"
while K >= 1:
if A>=B:
B *= 2
K -= 1
elif B>=C:
C *= 2
K -= 1
if A<B and B<C:... | # -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
answer = "No"
for i in range(K):
if A>=B:
B *= 2
elif B>=C:
C *= 2
if A<B and B<C:
answer = "Yes"
print... | p02601 |
#template
def inputlist(): return [int(j) for j in input().split()]
#template
A,B,C = inputlist()
K = int(eval(input()))
count = 0
while count < K:
if A > B:
B = 2*B
count +=1
continue
if B > C:
C = 2*C
count +=1
continue
if A < B<C:
pr... | a,b,c = list(map(int,input().split()))
k = int(eval(input()))
ans = 'No'
for i in range(k+1):
if a < b*(2**i) < c*(2**(k-i)):
ans = 'Yes'
print(ans)
| p02601 |
import itertools
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
targets = [A, B, C]
answer = 'No'
def check(targets):
if targets[1] > targets[0] and targets[2] > targets[1]:
return True
else:
return False
cases = itertools.product([0, 1, 2], repeat=K)
for case in... | import itertools
def check(targets):
if targets[1] > targets[0] and targets[2] > targets[1]:
return True
else:
return False
if __name__ == "__main__":
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
targets = [A, B, C]
answer = 'No'
cases =... | p02601 |
r, g, b = list(map(int, input().split()))
k = int(eval(input()))
def dfs(i , r, g, b):
if i > k: return False
if r < g < b: return True
if dfs(i+1, r*2, g, b ): return True
if dfs(i+1, r, g*2, b ): return True
if dfs(i+1, r, g, b*2): return True
return False
print(('Yes' i... | r, g, b = list(map(int, input().split()))
K = int(eval(input()))
for i in range(K+1):
for j in range(K+1-i):
for k in range(K+1-i-j):
rr, gg, bb = r * (1<<i), g * (1<<j), b * (1<<k)
if rr < gg < bb:
print('Yes')
exit()
print('No')
| p02601 |
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
while K > 0:
if B < A:
B *= 2
K -= 1
elif C < B:
C *= 2
K -= 1
if B > A and C > B:
break
if B > A and C > B:
print("Yes")
else:
print("No") | A, B, C = list(map(int, input().split()))
K = int(eval(input()))
for i in range(K):
if B <= A:
B *= 2
elif C <= B:
C *= 2
if B > A and C > B:
print("Yes")
else:
print("No") | p02601 |
A, B, C = [int(v) for v in input().strip().split(" ")]
K = int(input().strip())
while K > 0:
if B <= A:
B *= 2
K -= 1
elif C <= B:
C *= 2
K -= 1
if C > B > A:
print("Yes")
else:
print("No") | A, B, C = [int(v) for v in input().strip().split(" ")]
K = int(input().strip())
while K > 0:
if B <= A:
B *= 2
K -= 1
elif C <= B:
C *= 2
K -= 1
else:
break
if C > B > A:
print("Yes")
else:
print("No") | p02601 |
a = list(map(int,input().split()))
k = int(eval(input()))
#青>緑>赤
r,g,b = 0,0,0
for i,num in enumerate(a):
if i==0:
r = num
elif i==1:
g = num
elif i==2:
b = num
count = 0
while count<k:
if g<r:
g *= 2
count += 1
elif b<g:
b *= 2
... | import sys
r,g,b = list(map(int,input().split()))
k = int(eval(input()))
#青>緑>赤
count = 0
if g*(2**k)>r:
while g<=r:
g*=2
count += 1
else:
print("No")
sys.exit(0)
if b*(2**(k-count))>g:
print("Yes")
else:
print("No") | p02601 |
rgb = list(map(int, input().split(' ')))
r = rgb[0]
g = rgb[1]
b = rgb[2]
k = int(eval(input()))
for i in range(k):
if(r >= g):
g = g * 2
elif(g >= b):
b = b * 2
if (r < g < b):
print('Yes')
else:
print('No')
| def resolve():
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
for i in range(k):
if (a >= b):
b *= 2
elif (b >= c):
c *= 2
if(a < b < c):
print('Yes')
else:
print('No')
if __name__ == "__main__":
... | p02601 |
a,b,c = list(map(int,input().split()))
k = int(eval(input()))
for _ in range(k):
if b <= a:
b *= 2
else:
c *= 2
if a < b < c:
print("Yes")
else:
print("No") | a,b,c,k=list(map(int,open(0).read().split()))
while k>0:
if b<=a:b*=2
else:c*=2
k-=1
print(('YNeos'[a>=b or b>=c::2])) | p02601 |
A,B,C = list(map(int,input().split()))
K = int(eval(input()))
flag = True
for i in range(K+1):
num = K-i
for j in range(num+1):
num2 = num-j
if A*2**i<B*2**j:
if B*2**j<C*2**num2:
print("Yes")
flag = False
break
if flag ==False:
break
i... | N,M,K = list(map(int,input().split()))
num = int(eval(input()))
while num>0:
if K<=M or K<=N:
K = K*2
num -= 1
elif M<=N:
M = M*2
num -= 1
elif M>N:
K = K*2
num -= 1
if N<M and M<K:
print('Yes')
else:
print('No')
| p02601 |
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
flg = False
for i in range(k+1):
d = 2**i*b
e = 2**(k-i)*c
if a < d < e:
flg = True
break
if flg:
print('Yes')
else:
print('No') | a, b, c = list(map(int, input().split()))
k = int(eval(input()))
cnt = 0
while a >= b:
b *= 2
cnt += 1
while b >= c:
c *= 2
cnt += 1
if cnt <= k: print('Yes')
else: print('No') | p02601 |
l = list(map(int, input().split()))
k = int(eval(input()))
while(k > 0):
if l[0] > l[1]:
l[1] *= 2
k -= 1
elif l[1] > l[2]:
l[2] *= 2
k -= 1
if l[0] < l[1] and l[1] < l[2]:
print('Yes')
exit()
print('No') | r,g,b = list(map(int, input().split()))
k = int(eval(input()))
for _ in range(k):
if r >= g:
g *= 2
elif g >= b:
b *= 2
if r < g and g < b:
print('Yes')
exit()
print('No') | p02601 |
a, b, c = list(map(int, input().split(' ')))
k = int(eval(input()))
def Base_to_3(X):
if(int(X/3)):
return Base_to_3(int(X/3))+str(X%3)
return str(X%3)
for i in range(3**k):
comb = Base_to_3(i)
red = a*(2**comb.count('0'))
green = b*(2**comb.count('1'))
blue = c*(2**comb.co... | a, b, c = list(map(int, input().split(' ')))
k = int(eval(input()))
cnt = 0
while a >= b:
cnt+=1
b *= 2
while b >= c:
cnt+=1
c *= 2
if cnt <= k:
print('Yes')
else:
print('No') | p02601 |
# B
R, G, B = list(map(int, input().split()))
K = int(eval(input()))
ans = 'No'
num = 0
while (True):
if (num == K):
break
if (R > G):
G *= 2
num += 1
if (R < G):
break
while (True):
if (num == K):
break
... | # B
R, G, B = list(map(int, input().split()))
K = int(eval(input()))
ans = 'No'
num = 0
while (True):
if (num == K):
break
if (R >= G):
G *= 2
num += 1
if (R < G):
break
while (True):
if (num == K):
break
... | p02601 |
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
def combinations(k):
result = []
for b in range(k + 1):
for c in range(k + 1 - b):
result.append([b, c])
return result
def magic(A, B, C, K):
if A < B < C:
return True
for l in combina... | A, B, C = list(map(int, input().split()))
K = int(eval(input()))
def combinations(k):
result = []
for b in range(k + 1):
for c in range(k + 1 - b):
result.append([b, c])
return result
def magic(A, B, C, K):
if A < B < C:
return True
for b_count, c_c... | p02601 |
A,B,C = list(map(int, input().split()))
K = int(eval(input()))
for i in range(K):
if B >= C or A >= C:
C *= 2
else:
if A >= B:
B *= 2
if C > B and B > A:
print("Yes")
else:
print("No") | A,B,C = list(map(int, input().split()))
K = int(eval(input()))
cnt = 0
while (A >= B):
B *= 2
cnt += 1
while(B >= C):
C *= 2
cnt += 1
if cnt <= K:
print("Yes")
else:
print("No") | p02601 |
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
# C > B > A
for i in range(K):
if C >= B and B > A:
# C > B > A
C = C * 2
elif C >= A and A >= B:
# C > A >= B
B = B * 2
elif (
(A >= B and B >= C)
or (B >= A and A >= C)
... | A, B, C = list(map(int, input().split()))
K = int(eval(input()))
# C > B > A
for i in range(K):
if C >= A and A >= B:
# C >= A >= B
B = B * 2
else:
C = C * 2
if C > B and B > A:
print("Yes")
else:
print("No") | p02601 |
import copy
def magic(arr,i,k):
if(k==0):
if(arr[0] < arr[1] and arr[1] < arr[2]):
return True
else:
return False
k-=1
arr[i]*=2
return magic(arr.copy(),0,k) or magic(arr.copy(),1,k) or magic(arr.copy(),2,k)
if __name__ == "__main__":
arr = list(map(int,input().split()))
... | a,b,c = list(map(int,input().split()))
k = int(eval(input()))
for i in range(k):
if(a >= b):
b*=2
continue
if(b >= c):
c*=2
continue
if(a<b and b<c):
print("Yes")
exit()
else:
print("No") | p02601 |
#-------------
A,B,C = list(map(int, input().split()))
K = int(eval(input()))
#-------------
while True :
if A > B :
B = B*2
K -= 1
if B > C :
C = C*2
K -= 1
if K == 0 :
break
if A<B<C :
print("Yes")
else:
print("No") | #-------------
A,B,C = list(map(int, input().split()))
K = int(eval(input()))
#-------------
card = []
for i in range(K):
B_x = B*(2**i)
C_x = C*(2**(K-i))
card.append([A,B_x,C_x])
cnt = 0
for i in range(len(card)):
if card[i][2] > card[i][1] > card[i][0] :
cnt +=1
if cnt >= 1:
print("Ye... | p02601 |
a,b,c = list(map(int, input().split()))
k = int(eval(input()))
while k:
if a>=b:
b *= 2
k -= 1
elif b>=c:
c *= 2
k -= 1
if a<b and b<c:
print("Yes")
else:
print("No")
| a,b,c = list(map(int, input().split()))
k = int(eval(input()))
while k:
if a>=b:
b *= 2
k -= 1
elif b>=c:
c *= 2
k -= 1
else:
break
if a<b and b<c:
print("Yes")
else:
print("No")
| p02601 |
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))
def main():
count = 0
A,B,C = ... | from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))
def main():
count = 0
A,B,C = ... | p02601 |
#!/usr/bin/env python
ta, tb, tc = list(map(int, input().split()))
k = int(eval(input()))
def dfs(s):
a = ta
b = tb
c = tc
if len(s) == k:
#print(s)
for i in range(k):
if 'A' == s[i]:
a *= 2
elif 'B' == s[i]:
b *= 2... | #!/usr/bin/env python
a, b, c = list(map(int, input().split()))
k = int(eval(input()))
t = 0
while a>=b:
b *= 2
t += 1
while b>=c:
c *= 2
t += 1
if t<=k:
print('Yes')
else:
print('No')
| p02601 |
import math
A, B, C = list(map(int, input().split()))
K = int(eval(input()))
x = 0
if A < B < C:
print("Yes")
if A >= B:
x = math.ceil(math.log(A/B, 2))
B =B*(2**x)
if A != B:
if x > K:
print("No")
elif B < C:
print("Yes")
else:
x += 1
B = B*2
if B >= C:
y = mat... | A, B, C = list(map(int, input().split()))
K = int(eval(input()))
i = 0
while A >= B:
B *= 2
i += 1
while B >= C:
C *= 2
i += 1
if i > K:
print("No")
else:
print("Yes")
| p02601 |
m = int(eval(input()))
def calc(m):
for h in range(1, 3500):
for n in range(1, 3500):
for w in range(1, 3500):
if 4 * h * n * w == m * (w * n + w * h + h * n):
return h, n, w
print(('{0[0]} {0[1]} {0[2]}'.format(calc(m)))) | N = int(eval(input()))
def calc(N):
for h in range(1, 3500):
for n in range(1, 3500):
if 4 * h * n - N * n - N * h > 0 and (N * h * n) % (4 * h * n - N * n - N * h) == 0:
w = (N * h * n) / (4 * h * n - N * n - N * h)
return h, n, int(w)
print(('{0[0]} {0[1]... | p03589 |
N=int(eval(input()))
s=False
for i in range(1,3501):
for j in range(1,3501):
if (4*i*j-N*i-N*j)==0:
continue
else:
w=(N*i*j)/(4*i*j-N*i-N*j)
if w%1==0 and w>0:
p=i
q=j
s=True
break
... | N=int(eval(input()))
s=False
for i in range(1,3501):
for j in range(1,3501):
if (4*i*j-N*i-N*j)>0:
w=(N*i*j)/(4*i*j-N*i-N*j)
if w%1==0:
p=i
q=j
s=True
break
if s==True:
break
print(("{} {} {}".... | p03589 |
def c_4_over_n(N):
for h in range(1, 3501):
for n in range(1, 3501):
# 条件式をwについて整理したときの分子と分母
numerator = N * h * n
denominator = 4 * h * n - N * n - N * h
if denominator > 0 and numerator % denominator == 0:
w = numerator // denominator
... | def c_4_over_n(N):
for h in range(1, 3501):
for n in range(1, h + 1):
# 条件式をwについて整理したときの分子と分母
numerator = N * h * n
denominator = 4 * h * n - N * n - N * h
# このときwが正整数になる
if denominator > 0 and numerator % denominator == 0:
... | p03589 |
n=int(eval(input()))
mod=10**9+7
fra=[1]*(n+2)
inv=[1]*(n+2)
t1=1
t2=1
for i in range(1,n+2):
t1*=i
t1%=mod
t2*=pow(i,mod-2,mod)
t2%=mod
fra[i]=t1
inv[i]=t2
ans=fra[n]
for i in range((n+1)//2,n):
ans-=fra[i-1]*inv[2*i-n]*fra[i]%mod
ans%=mod
print(ans) | n=int(eval(input()))
mod=10**9+7
fra=[1]*(n+2)
inv=[1]*(n+2)
t=1
for i in range(1,n+2):
t*=i
t%=mod
fra[i]=t
t=pow(fra[n+1],mod-2,mod)
for i in range(n+1,0,-1):
inv[i]=t
t*=i
t%=mod
ans=fra[n]
for i in range((n+1)//2,n):
ans-=fra[i-1]*inv[2*i-n]*fra[i]%mod
ans%=mod
prin... | p03365 |
# seishin.py
N = int(eval(input()))
MOD = 10**9 + 7
fact = [1]*(N+1)
rfact = [1]*(N+1)
for i in range(1, N+1):
fact[i] = r = i*fact[i-1] % MOD
rfact[i] = pow(r, MOD-2, MOD)
ans = 0
cnt = 0
for K in range(1, N):
if not K >= N-K >= 1:
continue
res = fact[K]*fact[K-1]*rfact[2*K-N... | # seishin.py
N = int(eval(input()))
MOD = 10**9 + 7
fact = [1]*(N+1)
rfact = [1]*(N+1)
for i in range(1, N+1):
fact[i] = r = i*fact[i-1] % MOD
rfact[i] = pow(r, MOD-2, MOD)
ans = cnt = 0
for K in range((N+1)//2, N):
res = fact[K]*fact[K-1]*rfact[2*K-N] % MOD
ans += (res - cnt) * K % MOD... | p03365 |
# seishin.py
N = int(eval(input()))
MOD = 10**9 + 7
fact = [1]*(N+1)
for i in range(1, N+1):
fact[i] = r = i*fact[i-1] % MOD
ans = cnt = 0
for K in range((N+1)//2, N):
res = fact[K]*fact[K-1]*pow(fact[2*K-N], MOD-2, MOD) % MOD
ans += (res - cnt) * K % MOD
cnt = res
ans %= MOD
print... | N = int(eval(input()))
MOD = 10**9 + 7
fact = [1]*(N+1)
for i in range(1, N+1):
fact[i] = r = i*fact[i-1] % MOD
cnts = [0]*(N+1)
rev = 1
for K in range(N-1, (N+1)//2-1, -1):
cnts[K] = fact[K]*fact[K-1]*rev % MOD
rev = rev * (2*K-N) * (2*K-N-1) % MOD
ans = 0
for K in range((N+1)//2, N):
... | p03365 |
Md,MN=1000000007,1000006
fac,ifac,a,res,inv=[1,1],[1,1],[0],0,[1,1]
for i in range(2,MN):
inv.append(inv[Md%i]*(Md-Md//i)%Md)
fac.append(fac[-1]*i%Md)
ifac.append(ifac[-1]*inv[i]%Md)
def C(x,y):
if(x<y):
return 0
return fac[x]*ifac[y]*ifac[x-y]
def D(x,y):
return C(x-y+1,y)
... | Md,MN=1000000007,1000006
fac,ifac,a,res,inv=[1,1],[1,1],[0],0,[1,1]
for i in range(2,MN):
inv.append(inv[Md%i]*(Md-Md//i)%Md)
fac.append(fac[-1]*i%Md)
ifac.append(ifac[-1]*inv[i]%Md)
n=int(eval(input()))
for i in range(1,n):
if i*2-n>=0:
a.append(fac[i-1]*ifac[i+i-n]*fac[i]%Md)
els... | p03365 |
n = int(eval(input()))
p = 10**9 + 7
def fact(n):
n_ = 1
yield n_
for i in range(1, n+1):
n_ = (n_*i) % p
yield n_
def invfact(n, f, p):
for i in range(n):
yield pow(f[i], p-2, p)
ans = 0
m = n - 1
f = list(fact(m))
rf = list(invfact(n, f, p))
perm = 0
f... | n = int(eval(input()))
p = 10**9 + 7
def fact(n):
n_ = 1
yield n_
for i in range(1, n+1):
n_ = (n_*i) % p
yield n_
def invfact(n, f, p):
m = pow(f[n], p-2, p)
yield m
for i in range(n, 0, -1):
m = m * i % p
yield m
ans = 0
m = n - 1
f = lis... | p03365 |
n = int(eval(input()))
p = 10**9 + 7
def fact(n):
n_ = 1
yield n_
for i in range(1, n+1):
n_ = (n_*i) % p
yield n_
def invfact(n, f, p):
m = pow(f[n], p-2, p)
yield m
for i in range(n, 0, -1):
m = m * i % p
yield m
ans = 0
m = n - 1
f = lis... | n = int(eval(input()))
p = 10**9 + 7
def fact(n):
n_ = 1
yield n_
for i in range(1, n+1):
n_ = (n_*i) % p
yield n_
def invfact(n, f, p):
m = pow(f[n], p-2, p)
yield m
for i in range(n, 0, -1):
m = m * i % p
yield m
ans = 0
m = n - 1
f = lis... | p03365 |
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
def read():
return int(eval(input()))
def reads():
return [int(x) for x in input().split()]
MOD = 10**9 + 7
N = read()
NN = N + 1
f... | from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
def read():
return int(eval(input()))
def reads():
return [int(x) for x in input().split()]
MOD = 10**9 + 7
N = read()
NN = N +... | p03365 |
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
M = 10**9+7 # 出力の制限
N = n+3 # 必要なテーブルサイズ
g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g... | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n = int(eval(input()))
M = 10**9+7 # 出力の制限
N = n+3 # 必要なテーブルサイズ
g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g... | p03365 |
characteristic=10**9+7
def plus(input1,input2):
return (input1+input2)%characteristic
def minus(input1,input2):
return (input1-input2)%characteristic
def times(input1,input2):
return (input1*input2)%characteristic
def exponen(input1,input2):
binaryl=list(str(bin(input2))[2:])
binarysize=len... | P=10**9+7
def egcd(a, b):
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b)
(x, lastx) = (lastx - q * x, x)
(y, lasty) = (lasty - q * y, y)
return (lastx, lasty, a)
def inv(x):
return egcd(x,P)[0]
N=int(eval(input()))
Fa... | p03365 |
#!/usr/bin/env python3
import sys
def solve(N: int, S: str):
d = dict()
for length in range(N//2,0,-1):
for j in range(0,N-length+1):
if j == 0:
s = S[:length]
else:
s = s[1:]+S[j+length-1]
if d.get(s) != None:
... | #!/usr/bin/env python3
import sys
def solve(N: int, S: str):
a = ""
ans = 0
for i in range(N):
a += S[i]
while(len(a) > 0):
if a in S[i+1:]:
ans = max(ans,len(a))
break
else:
a = a[1:]
... | p02913 |
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
from collections import defaultdict
input = lambda : given().rstrip()
LMIIS = lambda : list(map(int,input(... | #coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
from collections import defaultdict
input = lambda : given().rstrip()
LMIIS = lambda : list(map(int,input(... | p02913 |
import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
q = deque([])
for i in range(x):
q.append(S[i])
d[''.join(q)] = 0
for i in range(x, N):
q.append(S[i])
q.popleft()
k = ''.join(q)
... | import sys
input = sys.stdin.readline
from collections import *
def judge(x):
d = defaultdict(int)
for i in range(N-x+1):
k = hash(S[i:i+x])
if k in d:
if i>=d[k]+x:
return True
else:
d[k] = i
return False
... | p02913 |
def resolve():
import sys
input=sys.stdin.readline
N = int(input().rstrip())
S = input().rstrip()
def z_algo(s):
"""
param s:str
return list of int with length len(s)
"""
# initialization
n=len(s)
z=[0]*n
z[0]=n
... | def resolve():
import sys
input=sys.stdin.readline
N = int(input().rstrip())
S = input().rstrip()
def z_algo(s):
"""
param s:str
return list of int with length len(s)
"""
# initialization
n=len(s)
z=[0]*n
z[0]=n
... | p02913 |
def Z_algo(S):
n = len(S)
LCP = [0]*n
i = 1
j = 0
c = 0
for i in range(1, n):
if i+LCP[i-c] < c+LCP[c]:
LCP[i] = LCP[i-c]
else:
j = max(0, c+LCP[c]-i)
while i+j < n and S[j] == S[i+j]: j+=1
LCP[i] = j
c = i
... | def check(x, N, S):
candidate = set()
for i in range(N - 2*x + 1):
candidate.add(S[i:i+x])
if S[i+x:i+2*x] in candidate:
return True
return False
def main():
n = int(eval(input()))
s = input().rstrip()
l = 0
r = n
while l < r:
mid = (l+r... | p02913 |
# ABC141E - Who Says a Pun?
class RollingHash:
def __init__(self, source: str, base=1000000007, mod=9007199254740997):
self.source = source
self.length = len(source)
self.base = base
self.mod = mod
self.hash = self._get_hash_from_zero()
self.power = self._get_... | # ABC141E - Who Says a Pun?
class RollingHash:
def __init__(self, source: str, base=1000000007, mod=9007199254740997):
self.source = source
self.length = len(source)
self.base = base
self.mod = mod
self.hash = self._get_hash_from_zero()
self.power = self._get_... | p02913 |
from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(sour... | # ABC141E - Who Says a Pun?
def resolve():
N = int(eval(input()))
S = input().rstrip()
ok, ng = 0, N // 2 + 1
while ng - ok > 1:
mid = (ok + ng) // 2
flg = False
memo = set()
for i in range(N - 2 * mid + 1):
memo.add(hash(S[i : i + mid]))
... | p02913 |
from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(sour... | from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(sour... | p02913 |
from typing import List, Tuple
class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7):
self._base = base
self._mod = mod
self._hash, self._power = self._build(sour... | class RollingHash:
"""Rolling Hash"""
__slots__ = ["_base", "_mod", "_hash", "_power"]
def __init__(self, source: str, base: int = 1007, mod: int = 10 ** 9 + 7) -> None:
self._base = base
self._mod = mod
self._hash = [0] * (len(source) + 1)
self._power = [0] * (len... | p02913 |
import sys
input = sys.stdin.readline
N=int(eval(input()))
S=input().strip()
dp=[[0]*(N+1) for _ in range(N+1)]
for i in range(N-1,-1,-1):
for j in range(N-1,i,-1):
if S[i]==S[j]:
dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1)
#print(dp)
ans=0
for i in range(N):
for j in range(N):
... | import sys
input = sys.stdin.readline
N=int(eval(input()))
S=input().strip()
"""dp=[[0]*(N+1) for _ in range(N+1)]
for i in range(N-1,-1,-1):
for j in range(N-1,i,-1):
if S[i]==S[j]:
dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1)
#print(dp)
ans=0
for i in range(N):
for j in range(N):
... | p02913 |
import sys
input = sys.stdin.readline
class AtCoder:
def main(self):
N = int(eval(input()))
S = input().rstrip()
dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
ans = 0
for i in range(N)[::-1]:
for j in range(N)[::-1]:
if S... | import sys
input = sys.stdin.readline
class AtCoder:
def main(self):
N = int(eval(input()))
S = input().rstrip()
ans = 0
for i in range(N - 1):
ans = max(self.longest_common_subsequence(S[i:]), ans)
print(ans)
# Z-Algorithm を使った連続する部分文字列長... | p02913 |
from collections import defaultdict
import sys
input = sys.stdin.readline
exit = sys.exit
def main():
N = int(input().strip())
S = input().strip()
half_N = N//2
cand = []
flag = True
cappend = cand.append
for i in range(N):
tmp = []
tappend = tmp.append
... | import sys
input = sys.stdin.readline
def main():
N = int(eval(input()))
S = input().strip()
ans = 0
for k in range(N):
now_S = S[k:]
ans_length = [-1] * (len(now_S)+1)
j = -1
for i, c in enumerate(now_S):
left_end = now_S[j]
righ... | p02913 |
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import a... | # 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import a... | p02913 |
def solve():
N = int(eval(input()))
Ss = input().rstrip()
for L in reversed(list(range(1, N//2+1))):
setCand = set()
RHs = []
for i in range(N-L+1):
if i <= N-2*L or L <= i:
RH = hash(Ss[i:i+L])
if i <= N-2*L:
RHs.ap... | def solve():
N = int(eval(input()))
Ss = input().rstrip()
def isOK(L):
setCand = set()
RHs = []
for i in range(N-L+1):
RH = hash(Ss[i:i+L])
RHs.append(RH)
if i-L >= 0:
setCand.add(RHs[i-L])
if RH in setCand:... | p02913 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.