text
stringlengths
37
1.41M
from math import atan, degrees a,b,x= map(int,input().split()) yoseki = a**2*b if x <= yoseki/2: # b*y*a/2==x y= 2*x/b/a # 90からシータを引けば良い print(90-degrees(atan(y/b))) else: # a*y*a/2==yoseki-x y = 2*(yoseki-x)/a**2 print(degrees(atan(y/a)))
N = int(input()) total = 0 for c in str(N): total += int(c) if N % total == 0: print('Yes') else: print('No')
# C 白昼夢 s = input()[::-1] cnt = 0 while cnt < len(s): if not s[cnt:cnt+7] == "remaerd": if not s[cnt:cnt+6] == "resare": if not s[cnt:cnt+5] in ["maerd", "esare"]: print("NO") exit() else: cnt += 5 else: cnt += 6 else: cnt += 7 print("YES")
X = int(input()) q = X // 100 if X%100<=q*5: print('1') else: print('0')
a = int(input()) b = int(input()) c = int(input()) d = int(input()) if (a >= b)and(c >= d): print(b + d) elif(a >= b)and(c <= d): print(b + c) elif(a <= b)and(c <= d): print(a + c) else: print(a + d)
A = ["a", "i", "u", "e", "o"] a = input() if a in A: print("vowel") else: print("consonant")
# -*- coding: utf-8 -*- #k回対戦済 S = input() #リストに変換 S_list = [] for i in range(0,len(S)): S_list.append(S[i]) #print(S_list) #勝ち数 Nvic = S_list.count("o") if Nvic + 15 - len(S) < 8: print("NO") else: print("YES")
from math import gcd n=int(input()) lcm=0 for i in range(n): t=int(input()) if lcm==0: lcm=t else: lcm=(t*lcm)//gcd(t,lcm) print(lcm)
import math N = int(input()) T = [int(input()) for _ in range(N)] def lcm(x, y): return (x * y)//math.gcd(x,y) g = 1 for i in T: g = lcm(g,i) print(g)
S=input() N=int(input()) for i in range(N): command=input().split() if command[0]=="replace": a=int(command[1]) b=int(command[2]) x=command[3] A=S[:a] B=S[b+1:] S=A+x+B elif command[0]=="reverse": a=int(command[1]) b=int(command[2]) A=S[:a] B=S[a:b+1] C=S[b+1:] T="" for p in range(len(B)): T+=B[len(B)-1-p] S=A+T+C else: #command[0]=="print" a=int(command[1]) b=int(command[2]) print(S[a:b+1])
a, b, c = [int(x) for x in input().split(" ")] if a < b: if b < c: print("Yes") else: print("No") else: print("No")
# gcdは最大公約数 from fractions import gcd # lcmは最小公倍数 def lcm(x, y): return (x * y) // gcd(x, y) def main(): from sys import stdin, setrecursionlimit setrecursionlimit(10**6) r = stdin.readline()[:-1] #n = int(stdin.readline()[:-1]) #r = [stdin.readline() for i in range(n)] #t = [int(stdin.readline()) for i in range(n)] a = int(r) print(lcm(2,a)) if __name__ == '__main__': main()
while(True): num = input() if num == '0': break x = 0 for i in num: x += int(i) print(x)
def bubble_sort(a,n): m=0 flag=True while(flag): flag=False for i in range(n-1,0,-1): if(a[i-1] > a[i]): tmp=a[i-1] a[i-1]=a[i] m+=1 a[i]=tmp flag=True b=list(map(str,a)) print(" ".join(b)) print(m) a=[] n=int(input()) s=input() a=list(map(int,s.split())) bubble_sort(a,n)
s_1 = input() s_2 = input() ans = "YES" if s_1[0] != s_2[2] or s_1[1] != s_2[1] or s_1[2] != s_2[0]: ans = "NO" print(ans)
#!/usr/bin/env python def f(x: int) -> int: """ >>> f(0) 1 >>> f(1) 0 """ if x == 1: return 0 else: return 1 if __name__ == '__main__': x = int(input()) print(f(x))
import sys def divisors(n,TF): divisors = [] for i in range(2, int(n**0.5)+1): if n % i == 0: divisors.append(i) if TF == 1: if i != n // i: divisors.append(n//i) return divisors N = int(input()) if N == 2: print(1) sys.exit() ans = len(divisors(N - 1, 1)) + 2 A = divisors(N, 0) for i in A: x = N while x % i == 0: x //= i if x % i == 1: ans += 1 print(ans)
a,b,s = open(0).read().split() if (int(a), int(b)) == tuple(map(len, s.split('-'))): print('Yes') else: print('No')
a=int(input()) b=int(input()) if a==b:print("EQUAL") elif a>b:print("GREATER") else:print("LESS")
def bubblesort(a, n): flag = 1 count = 0 while flag: flag = 0 for j in range(n-1, 0, -1): if a[j] < a[j-1]: count += 1 a[j], a[j-1] = a[j-1], a[j] flag = 1 return count def main(): n = int(input()) data = list(map(int, input().split())) c = bubblesort(data, n) print(*data) print(c) if __name__ == "__main__": main()
s = input() import string a = list(string.ascii_lowercase) for item in a: if item not in s: print(item) break else: print('None')
A,B,C = map(int,input().split()) if C > B and C > A and B > A: print("Yes") else: print("No")
s=input() a,b=s.split() a=int(a) b=int(b) print("%d %d"%(a*b,2*a+2*b))
S = input() if len(S) > 9: print('NO') exit() if S.replace('A', '') != 'KIHBR': print('NO') exit() for i in range(1, len(S)): if S[i] == 'A' and S[i-1] not in ('H', 'B', 'R'): print('NO') exit() print('YES')
MOD=10**9+7 N=int(input()) ans=pow(10,N,MOD) ans-=2*pow(9,N,MOD) ans+=pow(8,N,MOD) ans%=MOD print(ans)
def main(): a, b = input(), input() len_a, len_b = len(a), len(b) if len_a < len_b: print("LESS") elif len_a > len_b: print("GREATER") else: if a < b: print("LESS") elif a > b: print("GREATER") else: print("EQUAL") if __name__ == "__main__": main()
def check(h): if h > 1: return 2*(check(h//2))+1 elif h==1: return 1 print(check(int(input())))
n = int(input()) ans = "Christmas" for _ in range(25-n): ans += " Eve" print(ans)
def main(): line = input() A, B, X = [int(n) for n in line.split()] if A > X: print('NO') elif B + A < X: print('NO') else: print('YES') main()
S = list(input()) res = True n = S.count("N") s = S.count("S") w = S.count("W") e = S.count("E") if (n > 0) ^ (s > 0): res = False if (w > 0) ^ (e > 0): res = False if res: print("Yes") else: print("No")
n = int(raw_input()) print '', for i in range(1, n+1): if i % 3 == 0: print '%s' % i, elif '3' in str(i): print '%s' % i,
#template def inputlist(): return [int(k) for k in input().split()] #template A,B = inputlist() if (A+B) % 2 == 0: print((A+B)//2) else: print("IMPOSSIBLE")
li = [] for i in range(3): a,b = map(int,input().split()) li.append(a) li.append(b) li.sort() if li==[1, 2, 2, 3, 3, 4]: print("YES") else: print("NO")
def triple(x): return x*x*x x=int(input()) print(triple(x))
#! env/bin/local python3 # -*- coding: utf-8 -*- def seki(array1: list, array2: list): results = [] for a in array1: if a in array2: results.append(a) array2.remove(a) return results def main(): n = int(input()) sentences = [] while True: try: sentences.append(sorted(input(), reverse=True)) except EOFError: break pocket = sentences[0].copy() for n, sentence in enumerate(sentences): pocket = seki(pocket, sentence) print(''.join(sorted(pocket))) if __name__ == '__main__': main()
N=int(input()) def gcd(x,y): if y==0: return x else: return gcd(y,x%y) def lcm(x,y): return x*y//gcd(x,y) ans=1 for _ in range(N): T=int(input()) ans=lcm(ans,T) print(ans)
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) def gcd_list(numbers): return reduce(math.gcd, numbers) N,X=map(int,input().split()) A=list(map(int,input().split())) B=[abs(a-X) for a in A] print(gcd(*B))
input() a = list(map(int, input().split())) a.reverse() print(a[0], end = "") for i in a[1:]: print(" ", end = "") print(i, end = "") print("")
N=int(input()) if N > 2: print(N//3) else: print(0)
d = int(input()) a = 'Christmas' b = ' Eve' if d == 25: print(a) elif d == 24: print(a + b) elif d == 23: print(a + b * 2) else: print(a + b * 3)
data=input() x = data.split(" ") tmp=x[2] x[2]=x[1] x[1]=x[0] x[0]=tmp print(x[0],x[1],x[2])
num = list(map(int, input().split(' '))) if num[0] <= num[2] and num[1] >= num[2]: print("Yes") else: print("No")
A, B, C = (int(x) for x in input().split()) if B//A >= C: print(C) else: print(B//A)
import math def isPrime(num): for i in range(int(math.sqrt(num)), 1, -1): if num % i == 0: return None return num inputs = [] while True: try: inputs.append(input()) except(EOFError): break inputs.pop(0) print(len([x for x in list(map(isPrime, map(int, inputs))) if x is not None]))
S = input() CFlag = False FFlag = False for T in S: if T=='C': CFlag = True if CFlag and T=='F': FFlag = True break if FFlag: print('Yes') else: print('No')
S = input() def solve(T) : while 1: for i in ("dream", "dreamer", "erase", "eraser"): if T.endswith(i): T = T[: -len(i)] break else: print("NO") break if not T: print("YES") break solve(S)
def solve(): N = int(input()) word_count = {} max_count = 0 for i in range(N): word = input() word_count[word] = word_count.get(word, 0) + 1 max_count = max(word_count[word], max_count) ans_words = [] for w,c in word_count.items(): if c == max_count: ans_words.append(w) print('\n'.join(sorted(ans_words))) if __name__ == "__main__": solve()
lst = [] s = sorted(list(input())) lst.append(s) t = sorted(list(input()),reverse=True) lst.append(t) lst.sort() if lst[0] == lst[1]: answer = "No" elif lst[0] == s: answer = "Yes" else: answer = "No" print(answer)
# -*- coding: utf-8 -*- # ALDS1_3_D_Areas on the Cross-Section Diagram from collections import deque def make_h_list(slope): """ 入力データから高さのリストを作る """ h_list =deque([0]) for s in slope: d = 0 if s == "\\": d = -1 elif s == "/": d = 1 h_list.append(h_list[-1] + d) return h_list def trim_edge(h_list, left=True): """ 水溜りの境界を探す """ if left: while h_list: h = h_list.popleft() if h not in h_list: continue if h_list[0] - h < 0: h_list.appendleft(h) return h_list else: while h_list: h = h_list.pop() if h not in h_list: continue if h_list[-1] - h < 0: h_list.append(h) return h_list def make_w_list(h_list): """ 水たまりのリストを作る """ w_list = [] water = [] h_list = trim_edge(h_list) while h_list: h = h_list.popleft() if not water: water.append(h) elif water[0] == h: water.append(h) w_list.append(water) water = [] h_list.appendleft(h) h_list = trim_edge(h_list) else: water.append(h) if water[0] < water[-1]: water.pop(0) return w_list def calc_area(water): """ 面積計算 """ h = water[0] s = 0 for i in range(len(water) - 1): s += (water[i+1] - h) + (water[i+1] - water[i]) / 2 return abs(int(s)) in_data = str(input()) h_list = make_h_list(in_data) h_list = trim_edge(h_list, left=False) if type(h_list) != None: w_list = make_w_list(h_list) a_list = [calc_area(water) for water in w_list] else: a_list = [] print(sum(a_list)) print(len(a_list), *a_list)
D = int(input()) L = 25 - D F ="Christmas" # print("Christmas") for i in range(L): F += " Eve" print(F)
N = int(input()) b = 0 for a in range(N+1): b = b + a print(b)
s=input() p=input() s += s a = s.count(p) if a == 0: print('No') else: print('Yes')
N=int(input()) x=0 for i in range(1,N): x=x+(N-1)//i print(x)
num = input().split() num_i = [int(s) for s in num] x, a, b = num_i if(abs(a-x) > abs(b-x)): print('B') else: print('A')
n = int(input()) def primes(n): primes = [1] * (n+1) primes[0] = 0 primes[1] = 0 for i in range(2, int(n**0.5) + 1): if not primes[i] : continue for j in range(i * 2, n + 1, i): primes[j] = 0 for i in range(len(primes)): if i %5 != 1: primes[i] = 0 return primes # n<= 55555 primes_list = primes(55556) # 考え方 # 以下のような。5で割ってあまりが1になるような素数だけを出力しておく # [11, 31, 41, 61, 71, 101,...] # ここからどの5つをとっても、5で割れば割り切れるので、条件を満たすことができる ans = [] for i in range(len(primes_list)): if primes_list[i]: ans.append(i) if len(ans) == n: break ans = map(str, ans) print(" ".join(ans))
s = input() t = input() temp = s ans = 'No' for i in range(len(s)): temp = temp[-1] + temp[:-1] if temp == t: ans = 'Yes' break print(ans)
# APC 1, A - two integers import itertools X = [int(el) for el in input().split(' ')] if X[0] % X[1] == 0: print(-1) else: print(X[0])
N = int(input()) num_even = N//2 num_odd = N - num_even print(num_odd/N)
x=int(input()) a=int(input()) b=int(input()) x-=a while x>=0: x-=b print(x+b)
import re s = input().rstrip() print('Yes' if re.search('AC', s) else 'No')
N = int(input()) A = input() B = input() C = input() ans = 0 for i in range(N): if (A[i] is B[i]) & (A[i] is C[i]): ans += 0 elif (A[i] is B[i]) | (B[i] is C[i]) | (A[i] is C[i]): ans += 1 else: ans += 2 print(ans)
import math def LI(): return list(map(int, input().split())) a, b, x = LI() if x == (a**2*b)/2: ans = 45 elif x > (a**2*b)/2: ans = math.degrees(math.atan((2*(b-x/(a**2)))/a)) else: ans = math.degrees(math.atan(a*b**2/(2*x))) print(ans)
#bit使うversion S = input() N = len(S) res = 0 for i in range(2**(N-1)): formula = "" for j in range(N-1): if (i>>j) & 1: formula += S[j] formula += "+" else: formula += S[j] formula += S[N-1] res += eval(formula) print(res)
N=int(input()) if N%2==0: print('{:.10f}'.format(0.5)) else: print('{:.10f}'.format((N+1)/(2*N)))
l=list(input()) if l[0]==l[1] or l[1]==l[2] or l[2]==l[3]: print("Bad") else: print("Good")
def gcd(X,Y): x = X y = Y if y > x: x,y = y,x while x % y: x,y = y,x%y return y number = [int(i) for i in input().split()] print(gcd(number[0],number[1]))
while True: cards = input() if cards == '-': break n = int(input()) for _ in range(n): shuffle = int(input()) cards = cards[shuffle:] + cards[:shuffle] print(cards)
from string import ascii_lowercase S = input() for c in ascii_lowercase: if c not in S: print(c) exit() print('None')
number = int(input()) date = input() date = list(date) cnt =0 cnt2 =0 for i in range(number): if date[i] =="R": cnt +=1 for s in range(cnt): if date[s] =="W": cnt2 +=1 print(cnt2)
import math from functools import reduce def lcm_base(x, y): return (x * y) // math.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) if __name__ == '__main__': n = int(input()) A = list(map(int,input().split())) ans = lcm(*A) - 1 tmp = 0 for i in A: tmp += ans % i print(tmp)
a= int(input()) b= int(input()) result = a%500 if result - b <= 0: print("Yes") else: print("No")
L = int(input()) l = float(L/3) result = float(l ** 3) print(result)
from typing import List def get_value(card: str) -> int: return card[1] def bublle_sort(C: List[str]) -> None: for i in range(len(C)): for j in reversed(range(i + 1, len(C))): if get_value(C[j]) < get_value(C[j - 1]): C[j], C[j - 1] = C[j - 1], C[j] def selection_sort(C: List[str]) -> None: for i in range(len(C)): min_j = i for j in range(i, len(C)): if get_value(C[j]) < get_value(C[min_j]): min_j = j C[i], C[min_j] = C[min_j], C[i] def is_stable(A_in, A_out) -> bool: for i in range(len(A_in)): for j in range(i + 1, len(A_in)): for a in range(len(A_out)): for b in range(a + 1, len(A_out)): if get_value(A_in[i]) == get_value(A_in[j]) and A_in[i] == A_out[b] and A_in[j] == A_out[a]: return False return True N = int(input()) C = [str(i) for i in input().split()] C1 = [i for i in C] C2 = [i for i in C] bublle_sort(C1) print(' '.join(C1)) if is_stable(C, C1): print('Stable') else: print('Not stable') selection_sort(C2) print(' '.join(C2)) if is_stable(C, C2): print('Stable') else: print('Not stable')
a, b = (int(x) for x in input().split()) x = (a+b) / 2 if (a+b) % 2 == 0: print(int(x)) else: print(int(x + 0.5))
while True: x = list(input()) if x[0] == "0": break sum = 0 for i in range(len(x)): sum += int(x[i]) print(sum) #print(x)
S = input() for i in range(0, len(S) - 1, ): if S[i] == S[i + 1]: print('Bad') exit() print('Good')
s=list(input()) ans=list() for i in s: if i=="0": ans.append(0) elif i=="1": ans.append(1) else: try: ans.pop(-1) except: pass for i in ans: print(i,end="") print()
N=int(input()) history=[] for i in range(N): s = input() if i == 0: history.append(s) continue if s not in history and history[-1][-1]==s[0]: history.append(s) else: print('No') exit() print('Yes')
S = str(input()) Flag = False for i in S: if not S.count(i) % 2 == 0: Flag = True if Flag: print('No') else: print('Yes')
from fractions import gcd from functools import reduce def lcm(x,y): return (x*y)//gcd(x,y) def lcm_list(nums): return reduce(lcm,nums,1) mod=10**9+7 n=int(input()) A=list(map(int,input().split())) num=lcm_list(A) cnt=0 for i in A: cnt +=num//i print(cnt%mod)
x=list(map(int,input().split())) if x[0]>x[2]: print(str(x[0]-x[2])+" "+str(x[1])) elif x[0]+x[1]>x[2]: print("0"+" "+str(x[0]+x[1]-x[2])) else: print("0"+" "+"0")
def circle_in_rectangle(radius, pos, height, width): """ radius: int pos: tuple, (x, y) height: int, height of rectangle width: int, width of rectangle returns True if circle is in rectangle, otherwise False >>> circle_in_rectangle(1, (1, 1), 4, 5) True >>> circle_in_rectangle(1, (2, 4), 4, 5) False """ (x, y) = pos if x < radius or x > width - radius: return False if y < radius or y > height - radius: return False return True if __name__ == '__main__': #import doctest #doctest.testmod() (w, h, x, y, r) = input().split(' ') if circle_in_rectangle(int(r), (int(x), int(y)), int(h), int(w)): print('Yes') else: print('No')
s = input() sum = 0 for c in s: if c == '+': sum += 1 else: sum -= 1 print(sum)
n = int(input()) s = input() abc = 'ABC' print(s.count(abc))
x = int(input()) n = 1 while n*(n+1)//2 < x: n += 1 print(n)
S=input() L={'U','D','L'} R={'U','D','R'} for i in range(len(S)): if i%2==0: if not S[i] in R: print('No') exit() else: if not S[i] in L: print('No') exit() else: print('Yes')
def my_func(i): return i*i raw_input() while True: try: splited = map(int, raw_input().split()) sort_num = sorted(splited) if my_func(sort_num[0])+my_func(sort_num[1]) == my_func(sort_num[2]): print 'YES' else: print 'NO' except EOFError: break
import math def main(): str = input() if str == 'ABC': print('ARC') elif str == 'ARC': print('ABC') if __name__ == "__main__": main()
# cording: utf-8 import math num = float(input()) print(str(num**2*math.pi) + " " + str(2*num*math.pi))
W, H, x, y = map(int, input().split()) # 大きくない方とかって書いてあるけど、別にイコールの場合でもいいんかい! # 中心の座標を求める centerX = (W / 2) centerY = (H / 2) if ((x, y) == (centerX, centerY)): print((W * H) / 2, 1) else: print(W * H / 2, 0)
left_a, left_b, right_a, right_b = map(int, input().split()) left_weight = left_a + left_b right_weight = right_a + right_b if left_weight == right_weight: print('Balanced') elif left_weight > right_weight: print('Left') elif right_weight > left_weight: print('Right')
s = str(input()) count = 0 for i in range(len(s)): if(s[i] == "o"): count += 1 if((count + (15 - len(s))) >= 8): print("YES") else: print("NO")
import sys S = input() for i in range(1,6): if S == "hi" * i: print("Yes") sys.exit() print("No")
#! /usr/bin/env python # -*- coding: utf-8 -*- x_list = [] while True: x = int(raw_input()) if x == 0: break else: x_list.append(x) for i, x in enumerate(x_list, 1): print("Case %d: %d") % (i, x)
x=str(input()) if x == "Sunny":print("Cloudy") elif x== "Rainy":print("Sunny") else: print("Rainy")
while True: str_shuffled = input() if str_shuffled == '-': break shuffle_time = int(input()) for _ in range(shuffle_time): num_to_shuffle = int(input()) str_shuffled = str_shuffled[num_to_shuffle:] + str_shuffled[:num_to_shuffle] print(str_shuffled)
from collections import deque SA = input() SB = input() SC = input() def calculate(SA,SB,SC): a1 = list(SA) a2 = list(SB) a3 = list(SC) q1 = deque() for a in a1: q1.append(a) q2 = deque() for a in a2: q2.append(a) q3 = deque() for a in a3: q3.append(a) arr = [q1,q2,q3] stt = ["A","B","C"] currentIndex = 0 while currentIndex >= 0: if len(arr[currentIndex]) == 0: break currentValue = arr[currentIndex].popleft() if currentValue == "a": currentIndex = 0 continue if currentValue == "b": currentIndex = 1 continue if currentValue == "c": currentIndex = 2 continue print(stt[currentIndex]) calculate(SA,SB,SC)
S = str(input()) # S を abc を並び替えて作ることができるなら Yes を、そうでないなら No を出力せよ。 abc = [S[0], S[1], S[2]] if "a" in abc and "b" in abc and "c" in abc: print("Yes") else: print("No")
sample_string = input() test_string = input() if test_string in sample_string * 2: print("Yes") else: print("No")
n = int(input()) data = [int(i) for i in input().split(' ')] def bubble_sort(raw_list): n_list = len(raw_list) n_swap = 0 sorted_i = 1 flag = True while flag: flag = False for j in reversed(range(sorted_i, n_list)): if raw_list[j] < raw_list[j-1]: raw_list[j-1], raw_list[j] = raw_list[j], raw_list[j-1] n_swap += 1 flag = True sorted_i += 1 print(' '.join([str(i) for i in raw_list])) print(n_swap) bubble_sort(data)