text
stringlengths
37
1.41M
import math x = int(input()) initial = 100 count = 0 while initial < x: initial += initial//100 count += 1 print(count)
# coding: utf-8 a = int(input()) b = int(input()) if a + b == 3: print("3") elif a + b == 4: print("2") else: print("1")
def makelist(n, m): return [[0 for i in range(m)] for j in range(n)] a = int(input()) s = input() if a < 3200: print("red") else: print(s)
s = input() a = 'AKIHABARA' lis = ['KIHABARA', 'AKIHBARA', 'AKIHABRA', 'AKIHABAR', 'KIHBARA', 'KIHABRA', 'KIHABAR', 'AKIHABR', 'KIHBRA','AKIHBR', 'KIHBR', 'AKIHABARA','AKIHBRA', 'AKIHBARA','KIHBAR', 'KIHABR'] if s not in lis: print('NO') else: print('YES')
def main(): h = int(input()) if h == 1: minimum = 1 else: if h % 2 == 1: h -= 1 minimum = 0 power = 0 while True: minimum += 2 ** power power += 1 if 2 ** power > h: break print(minimum) if __na...
while 1: w,h=map(int,input().split()) if w==0 and h==0: break for a in range(w): print('#'*h) print()
# -*-coding:utf-8 import fileinput def main(): W = input().lower() count = 0 while True: T = input() if(T == 'END_OF_TEXT'): break inputList = T.lower().split() for i in inputList: if(W == i): count += 1 print(count) if __nam...
a, b = [int(i) for i in input().split(" ")] num1 = a // b num2 = a % b num3 = "{:.8f}".format(a / b) print(num1, num2, num3)
# -*- coding: utf-8 -*- from functools import reduce def mean_material(a, b): return (a+b)/2 n = int(input()) l_v = sorted(list(map(int, input().split()))) print(reduce(mean_material, l_v))
x=input() if x[-1]==("s"): print(x+"es") elif x[-1]!=("s"): print(x+"s")
s = list(input()) #不等号の向きを記録する memo = "" #不等号の連続した個数を記録する cnt = 0 #1つ前に数えた不等号の連続した個数を記録する before_cnt = 0 #出力する答え ans = 0 #文字列Sの連続した不等号の向きを数える for x in s: #初めはmemoが空白なので,memoに不等号の向きを記録 if memo == "": memo = x #不等号の向きが同じ場合は、数を1カウントしてループに戻る if memo == x: cnt += 1 #不等号...
n=list(input()) if n[len(n)-1]=="s": n.append("es") else: n.append("s") print("".join(n))
def solve(A, i, m, n): """Return if it is possible to make value m with some elements in A. n is length of A. i is index. Using Divide-and-Conquer method. """ if m == 0: return True if i >= n or m < 0: return False return solve(A, i + 1, m, n) or solve(A, i + 1, m - A[i...
S=list(input()) count=S.count("R") if S==["R","S","R"]: count=1 print(count)
n = int(input()) if n <= 599: print('8') elif n <= 799: print('7') elif n <= 999: print('6') elif n <= 1199: print('5') elif n <= 1399: print('4') elif n <= 1599: print('3') elif n <= 1799: print('2') else: print('1')
import sys K = int(input()) if K%5==0 or K%2==0: print("-1") sys.exit() A = 0 for i in range(K): A = (10 * A + 7) % K if A == 0: print(i+1) break
class Sequence: def __init__(self,num, seq): self.n = num self.sequence = seq def LinearSearch(A, n, key): i=0 A[n] = key while A[i] != key: i += 1 if i==n: return "NOT_FOUND" return i if __name__ == "__main__": n = int(raw_input()) x = map(int, raw_inp...
def fac1(num, div): """How many times can the factorial of `num` be divided by `div`?""" if num == 0: return 0 return num // div + fac1(num // div, div) def fac2(num, div): """How many times can the double factorial of `num` be divided by `div`?""" return fac1(num // 2, div) def main(): ...
A,B = input().split() A = int(A) B = int(B) if A * B % 2 ==0: print ('Even') else : print ('Odd')
#!/usr/bin/env python3 def next_line(): return input() def next_int(): return int(input()) def next_int_array_one_line(): return list(map(int, input().split())) def next_int_array_multi_lines(size): return [int(input()) for _ in range(size)] def next_str_array(size): return [input() for _ ...
nums = input().split() W = int( nums[0]) H = int( nums[1]) x = int( nums[2]) y = int( nums[3]) r = int( nums[4]) if (x - r) >= 0 and (x + r) <= W: if (y - r) >= 0 and (y + r) <= H: print( "Yes") else: print( "No") else: print( "No")
def gcd(a,b): if b == 0: return a else: return gcd(b,a%b) def lcm(a,b): d = (a*b) / gcd(a,b) print d while True: try: x = map(int,raw_input().split(" ")) a,b = x[0],x[1] print gcd(a,b),(a*b)/gcd(a,b) except EOFError: break
s = list(map(str,input())) if s[0] != "A": print("WA") elif s[2:-1].count("C") != 1: print("WA") else: del s[0] s.remove("C") if "".join(s).islower(): print("AC") else: print("WA")
#List of Top 3 Hills set = [] a = 9 for i in range(10): n = int(input()) set.append(n) set.sort() while a >= 7: print(set[a]) a -= 1
# coding: utf-8 cnt = int() m = int() g = [] def insersion_sort(a, n, g): global cnt for i in xrange(g, n): v = a[i] j = i - g while j >= 0 and a[j] > v: a[j+g] = a[j] j = j - g cnt += 1 a[j+g] = v return list(a) def shell_sort(a, n): ...
S = input() charset = set(list(S)) if 'A' in charset: charset.remove('A') if 'C' in charset: charset.remove('C') # print(f'S:{S} charset:{charset}', file=sys.stderr) if S[0] == 'A' and S[2:-1].count('C') == 1 and ''.join(charset).islower(): print('AC') else: print('WA')
s=input() if s=="AKIHABARA": print("YES") elif s=="KIHABARA" or s=="AKIHBARA" or s=="AKIHABRA" or s=="AKIHABAR": print("YES") elif s=="KIHBARA" or s=="KIHABRA" or s=="KIHABAR" or s=="AKIHBRA" or s=="AKIHBAR" or s=="AKIHABR": print("YES") elif s=="KIHBRA" or s=="KIHBAR" or s=="KIHABR" or s=="AKIHBR": pr...
S=input() i=[] i.extend(S) if i[0]==i[1]: print('Bad') elif i[1]==i[2]: print('Bad') elif i[2]==i[3]: print('Bad') else: print('Good')
s = input() if len(s)%2 == 0: f = len(s)//2 else: f = len(s)//2+1 for i in range(f): print(s[2*i],end="")
N = int(input()) x = int(input()) y = int(input()) A = [x, y] if x < y: x, y = y, x for i in range(N - 2): a = int(input()) A.append(a) if x <= a: y = x x = a elif y < a: y = a if x == y: for i in range(N): print(x) else: for a in A: if a == x: ...
s=[1, 2, 3, 5, 6, 9, 10, 13, 17] n=int(input()) print ("No" if n in s else "Yes")
N = int(input()) S = input() result = 0 for i in range(1, N+1): S_forward = S[:i] S_backward = S[i:] is_same = [] for j in S_forward: if j in S_backward: if j not in is_same: is_same.append(j) result = max(result, len(is_same)) print(result)
n = input() if len(n)==3: print("ABC"+n) elif len(n)==2: print("ABC"+"0"+n) else: print("ABC"+"00"+n)
def toggle(c): L = c.lower() if c == L: return c.upper() else: return L print(''.join(map(toggle, input())))
a=2 b=1 N=int(input()) for i in range(N): a=a+b a,b=b,a print(a)
#!/usr/bin/env python3 def main(): D, N = map(int, open(0).read().split()) if N == 100: print(101*100**D) else: print(N*100**D) main()
N = int(input()) S = list(input()) ans = 'No' n = int(N / 2) if S[:n] == S[n:]: ans = 'Yes' print(ans)
def main(): N = int(input()) if N == 0: print(0) ans = '' base = 1 while N != 0: if N % (base * -2) == 0: ans += '0' else: ans += "1" N -= base base *= -2 ans = list(ans) ans.reverse() print(''.join(ans)) if __name__ ==...
x = input().split() a = int(x[0]) b = int(x[1]) if a <= 9 and b <= 9: print(a * b) else: print('-1')
S = input() T = input() for _ in range(len(S)): S_lst = list(S) tmp = S[0] for i in range(len(S) - 1): S_lst[i] = S_lst[i+1] S_lst[-1] = tmp S = ''.join(S_lst) if S == T: print("Yes") exit() else: print("No")
Weather = ['Sunny','Cloudy','Rainy'] S = input() for i,s in enumerate(Weather): if s == S: print(Weather[(i+1)%3])
from collections import deque # 両端を扱うならdequeが速い # 内側を扱うならリストが速い S = input() q = deque() for s in list(S): q.append(s) Q = int(input()) direction = True for _ in range(Q): line = input() # TrueならFalseに、FalseならTrueに変える if line == "1": direction = not direction else: if (directio...
str = list(input()) q = int(input()) for i in range(q): s = list(input().split()) s[1] = int(s[1]) s[2] = int(s[2]) if s[0] == 'print': print(''.join(str[s[1]:s[2]+1])) elif s[0] == 'reverse': str[s[1]:s[2]+1] = ''.join(reversed(str[s[1]:s[2]+1])) elif s[0] == 'replace': ...
x = int(input()) while True: i = 2 prime = True while i * i <= x: if x % i == 0: prime = False break i += 1 if prime: print(x) quit() x += 1
n=int(input()) if (((n/1.08)//1)*1.08)//1==n: print(int((n/1.08)//1)) elif (((n/1.08)//1+1)*1.08)//1==n: print(int(((n+1)/1.08)//1)) else: print(":(")
n = int(input()) if n == 1: print(1) elif n % 2 == 0: print(0.5) else: import math print(math.ceil(n/2)/n)
s = input() cnt = 0 for i in range(len(s)-1): if(s[i] == s[i+1]): cnt = cnt + 1 if cnt == 0: print("Good") else: print("Bad")
# Compatible with Python3 # -*- coding: utf-8 -*- [print(i) for i in sorted([input() for j in range(10)], key=int, reverse=True)[:3]]
n = int(input()) def make_divisors(n): x = 0 i = 1 while i*i <= n: if n % i == 0: x += 1 if i != n // i: x += 1 i += 1 return x s = 0 for i in range(1, n+1, 2): #print(make_divisors(i)) if make_divisors(i) == 8: s += 1 print(s)
last_week_contest = input() if last_week_contest == 'ABC': this_week_contest = 'ARC' print(this_week_contest) elif last_week_contest == 'ARC': this_week_contest = 'ABC' print(this_week_contest)
from collections import deque n = deque(list(input())) digit = n.popleft() cnt = 1 while n: if cnt == 3: break d = n.popleft() if d == digit: cnt += 1 else: digit = d cnt = 1 if cnt == 3: print('Yes') else: print('No')
N = input() for n in N: if n == "7": print("Yes") break else: print("No")
def resolve(): X, A, B = list(map(int, input().split())) if B <= A: print("delicious") elif B <= A+X: print("safe") else: print("dangerous") if '__main__' == __name__: resolve()
K = int(input()) if K == 1: print("ACL") elif K == 2: print("ACLACL") elif K == 3: print("ACLACLACL") elif K == 4: print("ACLACLACLACL") elif K == 5: print("ACLACLACLACLACL")
S=input() x=int(S[:2]) y=int(S[2:4]) if 1<=x<=12: if 1<=y<=12: print("AMBIGUOUS") else: print("MMYY") else: if 1<=y<=12: print("YYMM") else: print("NA")
def main(): N = int(input()) if N <= 3: print(N - 1) return # (1) 2 <= k <= sqrt(N) で題意を満たすkの個数 ans_1 = 0 k = 2 while k ** 2 <= N: n = N while n % k == 0: n //= k n %= k if n == 1: ans_1 += 1 k += 1 # (2) sqrt(N)...
s=input() li=list(s) adana_li=[] for i in range(3): adana_li.append(li[i]) adana=li[0]+li[1]+li[2] print(adana)
def shuffle(index): global a a = a[index:]+a[:index] while True: a = input() if a == '-': break for i in range(int(input())): shuffle(int(input())) print(a)
from collections import namedtuple C = namedtuple("C", "m v") def bubble_sort(A0): A = A0.copy() for i in range(n - 1): for j in range(n - 1, i, -1): if A[j].v < A[j - 1].v: A[j], A[j - 1] = A[j - 1], A[j] return A, True def selection_sort(A0): A = A0.copy() f...
# coding: utf-8 num = int(input()) str = input().split() table = [int(i) for i in str] list.sort(table) print(table[num-1] - table[0])
A,B,C = map(int, open(0).read().split()) if A <= C <= B: print("Yes") elif A >= C >= B: print("Yes") else: print("No")
x = input().split(' ') x = list(map(int,x)) print("Yes") if (x[0]/x[1])<= x[2] else print("No")
N = int(input()) def Sieve_of_Eratosthenes(n): is_prime = [True] * (n+1) is_prime[0] = False is_prime[1] = False for i in range(2, int(n**0.5)+1): if not is_prime[i]: continue for j in range(i*2, n+1, i): is_prime[j] = False #return is_prime return [i for i in range(n+1) if is_prime[i] ...
def compare(a, b): if a < b : return "<" elif a > b : return ">" else: return "==" (a, b) = input().split(" ") print("a " + compare(int(a), int(b)) + " b")
str = input() words = ["dream", "dreamer", "erase", "eraser"] def replace(S, s): reversedS = S[::-1] reverseds = s[::-1] replaced = reversedS.replace(reverseds, "", 1) return replaced[::-1] while True: tmp = str for word in words: if str.endswith(word): str = replace(str, w...
def insert_sort(A, n, g, cnt): for i in range(g, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j+g] = A[j] j -= g cnt += 1 A[j+g] = v return cnt def shellSort(A, n): cnt = 0 G = []; h = 0 while h <= n: if 3 * h + 1 <=...
from collections import deque list = list(input()) queue = deque([]) queue2 = [] total = 0 for i in range(len(list)): if list[i] == '\\': queue.append(i) elif list[i] == '/' and len(queue) > 0: j = queue.pop() total += (i - j) temp = i ...
def main(): n = int(input()) alp = 'abcdefghijklmnopqrstuvwxyz' answer = '' while n >= 1: n -= 1 answer += alp[n % 26] n //= 26 real_answer = '' for i in range(1, len(answer) + 1): real_answer += answer[-i] print(real_answer) if __name__ == '__main__': ...
#関数リスト import sys input = sys.stdin.readline def RD(): return input().rstrip() def I(): return int(input().rstrip()) def MI(): return map(int, input().split()) def MF(): return map(float,input().split()) def LI(): return list(map(int, input().split())) def LF(): return list(map(float,input().split())) def main(): ...
#素因数分解 def Prime_Factorization(n): R=[] N=n for k in range(2,int(-(-n**0.5//1))+1): if N%k==0: C=0 while N%k==0: C+=1 N//=k R.append([k,C]) if N!=1: R.append([N,1]) if not R: R.append([N,1]) r...
import itertools def solve(T,X): """ >>> solve(8,3) 2.6666666667 """ print(T/X) def main(): T,X = map(int,input().split()) solve(T,X) def _test(): import doctest doctest.testmod() if __name__ == "__main__": import sys argv = sys.argv if len(sys.argv) == 1: ...
S = input() for alph in 'abcdefghijklmnopqrstuvwxyz': if alph not in S: print(alph) exit() print('None')
# A - A?C # 'ABC'には'ARC'を、'ARC'には'ABC'を返す S = str(input()) if S == 'ABC': print('ARC') elif S == 'ARC': print('ABC')
def insetion_sort(A, n, g, cnt) : cnt = 0 for i in range(g, n) : v = A[i] j = i - g while j >= 0 and A[j] > v : A[j+g] = A[j] j = j -g cnt += 1 A[j+g] = v return cnt def shell_sort(A, n) : c...
from sys import stdin import math a=input() if (a[0]<a[2]): print("<") elif(a[0]==a[2]): print("=") else: print(">")
import sys import math def gcd(x, y): if y == 0: return x return gcd(y, x%y) x, y = map(int, raw_input().split()) print gcd(min(x, y), max(x, y))
import sys strs = sys.stdin.readlines() for c in range(ord('a'), ord('z') + 1): count = 0 for str in strs: count += str.lower().count(chr(c)) print('{0} : {1}'.format(chr(c), count))
A = int(input()) B = int(input()) print([i+1 for i in range(3) if i+1 != A and i+1 != B][0])
dict = {} n = int(raw_input()) for _ in xrange(n): com, word = raw_input().split() if com == "insert": dict[word] = True else: if word in dict: print "yes" else: print "no"
money = input() lis = money.split() if int(lis[0]) + int(lis[1]) >= int(lis[2]): print("Yes") else: print("No")
def is_the_day(m,d): return d >= 22 and (d%10) >= 2 and (d//10) >= 2 and (d%10)*(d//10) == m M,D = map(int,input().split()) ans = 0 for m in range(1,M+1): for d in range(1,D+1): ans += int(is_the_day(m,d)) print(ans)
class UnionFind: """ size の要素数の UnionFind を管理する data 中の負数の要素が根となる """ def __init__(self, size): # 根は子を含む集合のデータ数を負数でもつ self.data = [-1] * size def merge(self, x, y): x = self.root(x) y = self.root(y) if x == y: return False # y の方がデータ数を多く ...
while True: x = input() if x == '0': break print(sum(int(c) for c in x))
contests = ['ABC', 'ARC'] before_contest = input() print(contests[0] if before_contest == contests[1] else contests[1])
def ask(i): print(i) return input() def solve(l, r): m = (l + r) // 2 res = ask(m) if res == "Vacant": quit() if (m % 2 == 0 and a0 == res) or (m % 2 == 1 and a0 != res): solve(m + 1, r) else: solve(l, m) N = int(input()) a0 = ask(0) if a0 == "Vacant": quit() s...
def main(): N = int(input()) for i in range(1, 10): if int(str(i) * 3) >= N: print(str(i) * 3) break if __name__ == '__main__': main()
def main(): _ = int(input()) s = input().rstrip() r, b = 0, 0 for c in s: if c == "R": r += 1 else: b += 1 if r > b: print("Yes") else: print("No") if __name__ == "__main__": main()
x=int(input()) p=x%100 q=x//100 if 0<=p<=5*q: print(1) else: print(0)
def dfs(S, mx): if len(S) == N: print(S) else: for i in range(a, mx+2): if i == mx+1: dfs(S+chr(i), mx+1) else: dfs(S+chr(i), mx) return N = int(input()) a = ord('a') dfs('a', a)
N = int(input()) A = list(map(int, input().split(' '))) uniqu_a = list(set(A)) if N == len(uniqu_a): print('YES') else: print('NO')
def between_two_integers(A: int, B: int, C: int)->bool: return A <= C and C <= B if __name__ == "__main__": A, B, C = map(int, input().split()) yes = between_two_integers(A, B, C) print('Yes' if yes else 'No')
i = list(map(int,input().split())) if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1]) or (i[1] == i[2] and i[1] != i[0]): print("Yes") else: print("No")
A, B, C = [int(num) for num in input().split()] sum = A + B print('Yes' if sum >= C else 'No')
s=str(input()) s=list(s) temp=0 for i in range(len(s)): if s[i]=="C": temp=1 if temp==1 and s[i]=="F": temp=2 if temp==2: print("Yes") else: print("No")
def codefes17f_a(): s = str(input()) if s.replace('A', '') != 'KIHBR': return print('NO') if 'AA' in s: return print('NO') if not 'KIH' in s: return print('NO') return print('YES') if __name__ == '__main__': codefes17f_a()
N,M= map(int,(input().split())) """nを素因数分解""" """2以上の整数n => [[素因数, 指数], ...]の2次元リスト""" 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 ...
A, B = [int(v) for v in input().strip().split(" ")] if A > 8 or B > 8: print(":(") else: print("Yay!")
def insert(dic,text): dic[text] = 1 def find(dic,text): if text in dic: print('yes') else: print('no') num = int(input()) d = {} while num > 0: ope , s = input().split() if ope == 'insert': insert(d,s) elif ope == 'find': find(d,s) num -= 1
s=input() count=1 ans='Yes' for i in s: if count%2==1: if i=='R' or i=='U' or i=='D': count+=1 continue else: ans='No' break else: if i=='L' or i=='U' or i=='D': count+=1 continue else: ans='No' ...
N=int(input()) if N==2: print(1) exit() def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) # divisors.sort() return divisors #N-1の約数(1は除く) Nそのもの #2 d=make_divisors(N-1) if not 2 in d: d.ap...