text
stringlengths
37
1.41M
# 文字列を取得 C1 = str(input()) C2 = str(input()) # 文字列の結合 ori_str = C1 + C2 # 末尾から1文字ずつ取得して逆さま文字を生成 rev_str = ori_str[-1::-1] # 比較結果を出力 if ori_str == rev_str: print("YES") else: print("NO")
def isStable(before_sort, after_sort): num = len(before_sort) for i in range(0, num-1): for j in range(i+1, num): for a in range(0, num-1): for b in range(a+1, num): if before_sort[i][1] == after_sort[j][1] and \ before_sort[i] ...
from string import ascii_lowercase S = input() string = ascii_lowercase for s in string: if s not in S: print(s) exit() print('None')
from math import gcd n = int(input()) A = list(map(int, input().split())) f1 = True f2 = True c = [0] * (10**6+5) for a in A: c[a] += 1 for i in range(2, 10**6+5): cnt = 0 for j in range(i, 10**6+5, i): cnt += c[j] if cnt > 1: f1 = False g = 0 for i in range(len(A)): g = gcd(g, A[i]) if g != 1: ...
p = input() q = input() s = list(p) t = list(q) s.sort() t.sort() answer = True for i in range(len(s)): front = s[i] rear = t.pop() f = ord(front) r = ord(rear) if t == []: answer = False break if f == r: continue elif f < r: answer = True break ...
def check_my(string): if 1 <= int(string) <= 12: return 'YorM' else: return 'Y' s = input() my_set = (check_my(s[0:2]), check_my(s[2:4])) if my_set == ('YorM', 'YorM'): print('AMBIGUOUS') elif my_set == ('YorM', 'Y'): print('MMYY') elif my_set == ('Y', 'YorM'): print('YYMM') else: ...
heights = [] for i in range(10): heights.append(int(input())) for i in range(10): for j in range(i,10): if (heights[j] > heights[i]): w = heights[i] heights[i] = heights[j] heights[j] = w print(heights[0]) print(heights[1]) print(heights[2])
N=int(input()) def prime_factorization(n): arr=[] temp=n for i in range(2,int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp//=i arr.append([i,cnt]) if temp!=1: arr.append([temp,1]) if ar...
import sys input = sys.stdin.readline def main(): N = int(input()) s = input().rstrip() n_R = s.count("R") n_B = s.count("B") if n_R > n_B: ans = "Yes" else: ans = "No" print(ans) if __name__ == "__main__": main()
import math x, y, X, Y = [float(i) for i in input().split()] print(math.sqrt((x-X)**2 + abs(y-Y)**2))
S = input() def kaibun(S): for i in range(len(S) // 2): if S[i] != S[len(S) - i - 1]: return False return True if kaibun(S) and kaibun(S[:(len(S) - 1)//2]) and kaibun(S[(len(S) + 3) // 2-1:]): print('Yes') else: print('No')
S = str(input()) str_keyence = "keyence" if S.find("keyence")==0 or S.rfind("keyence")==len(S)-7: print("YES") else: for i in range(1,7): #print(str_keyence[0:i],str_keyence[i:]) #print(S.find(str_keyence[0:i])) #print(S.find(str_keyence[i:])) if S.find(str_keyence[0:i])==0 and S.rfind(str...
w=input() ans="Yes" for i in w: if w.count(i)%2!=0: ans="No" break print(ans)
age, b = map(int, input().split()) if age >= 13: print(b) elif 6 <= age < 13: print(b // 2) else: print(0)
x,a,b = map(int, input().split()) d = b-a if (d <= 0): print('delicious ') elif(d <= x): print('safe') else: print('dangerous')
a = input().split() li = [] for i in a: if i not in li: li.append(i) print(len(li))
import math class Debt(object): def __init__(self): self.debt = 100000 def spend_a_week(self): self.debt = self._ceil_1000(self.debt * 1.05) def _ceil_1000(self, debt): return int(math.ceil(debt / 1000) * 1000) def run(): n = int(input()) debt = Debt() for _ i...
s = input() if (s[0]==s[1] and s[1]==s[2]) : print("Yes") elif (s[1]==s[2] and s[2]==s[3]) : print("Yes") else: print("No")
from decimal import Decimal l=int(input()) print(Decimal((l/3)**3))
#!/usr/bin/env python3 import sys try: from typing import List except ImportError: pass def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"): pars = list(range(N)) def getpar(n: int): if pars[n] == n: return n pars[n] = getpar(pars[n]) return p...
x,y=map(int,input().split()) a=[4, 6, 9, 11] if x==2 and y==2: print('Yes') else: if (x==2 and y!=2) or (x!=2 and y==2): print('No') elif x in a and y in a: print('Yes') elif not x in a and not y in a: print('Yes') else: print('No')
a, b, x = map(int, input().split()) if a > x: print('NO') elif a+b >= x: print('YES') else: print('NO')
d = int(input()) s = "Christmas" for _ in range(25-d): s += " Eve" print(s)
A,B=map(int,input().split()) if((A!=1 and B!=1 and A>B)or(A==1 and B!=1)): print("Alice") elif(A==B): print("Draw") else: print("Bob")
import math a,b = list(map(int,input().split())) number = int(str(a)+str(b)) root = math.sqrt(number) if int(root + 0.5) ** 2 == number: print("Yes") else: print("No")
A = input().split(" ") a = A[0] b = A[1] c = A[2] if a == b and b == c: print(1) elif a == b or a == c and b != c : print(2) elif b == c and a != b : print(2) else : print(3)
A = [int(input()) for _ in range(6)] def check(): if A[-2]-A[0]>A[-1]: return ':(' return 'Yay!' print(check())
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 = int(input()) ans = len(make_divisors(N-1))-1 for i in make_divi...
import sys input() numbers = map(int, input().split()) evens = [number for number in numbers if number % 2 == 0] if len(evens) == 0: print('APPROVED') sys.exit() for even in evens: if even % 3 != 0 and even % 5 != 0: print('DENIED') sys.exit() print('APPROVED')
if __name__ == "__main__": a = [] for i in range(0,10): val = input() a.append(int(val)) a.sort() a.reverse() for i in range(0,3): print(a[i])
x = int(input()) r = x // 11 * 2 if x % 11 == 0: pass elif x % 11 > 6: r += 2 else: r += 1 print(r)
a, b, x = map(int, input().split()) import math theta1 = math.atan((b - x/a**2)*2/a) theta2 = math.atan((a*b**2/(2*x))) if b < a*math.tan(theta2): theta = theta2 else: theta = theta1 print(math.degrees(theta))
m = input() x = ord(m) if x >= 97 and x <= 122: print("a") else: print("A")
def bubbleSort( cards ): n = len( cards ) for i in range( 0, n ): for j in range( n-1 , i, -1 ): if int( cards[j][1] ) < int( cards[ j-1 ][1] ): cards[j], cards[ j-1 ] = cards[ j-1 ], cards[j] print( " ".join( map( str, cards ) ) ) def selectionSort( cards ): n = len...
n = int(input()) dict = set() for _ in range(n): c, s = input().split() if c == 'insert': dict.add(s) else: print(('no', 'yes')[s in dict])
a=input() b=input() la,lb = len(a), len(b) if a==b: print('No') elif (la< lb and set(a)==set(b)): print('Yes') else: sa = sorted(a) sb = sorted(b, reverse = True) if (sa[:lb] < sb): print('Yes') else: print('No')
import collections def func(a,b,c): g=0 l=[a,b,c] d=collections.Counter(l) x=len(d) if x==3: g=2 elif x==2: g=1 return g N=int(input()) A=input() B=input() C=input() count=0 for i in range(N): count+=func(A[i],B[i],C[i]) print(count)
input_value = raw_input().split(' ') ret = 'a == b' if int(input_value[0]) < int(input_value[1]): ret = 'a < b' if int(input_value[0]) > int(input_value[1]): ret = 'a > b' print(ret)
s = input() def solve(x): l = [] for c in x: if c in l: return False l.append(c) return True if solve(s): print('yes') else: print('no')
def GCD(a, b): if b == 0: return a return GCD(b, a % b) def LCM(a, b): return a * b // GCD(a, b) import sys s = sys.stdin.readlines() n = len(s) for i in range(n): x, y = map(int, s[i].split()) print(GCD(x, y), LCM(x, y))
n = int(raw_input()) A = map(int, raw_input().split(" ")) count = 0 def merge(left, right): global count sorted_list = list() left_index = 0 right_index = 0 while left_index < len(left) and right_index < len(right): if left[left_index] <= right[right_index]: sorted_list.ap...
import sys s = input().strip() if s[2] == s[3] and s[4] == s[5]: print("Yes") else : print("No")
data = input() a, b, c = [int(i) for i in data.split()] if a < b < c: print('Yes') else: print('No')
soboe = raw_input() al = soboe.split(' ') a = int(al[0]) b = int(al[1]) if a < b : print('a < b') elif a > b : print('a > b') elif a == b : print('a == b')
s = input() n = len(s) if s != s[::-1]: print("No") else: t = s[:int((n - 1) / 2)] u = s[int((n + 1) / 2):] if t == t[::-1] and u == u[::-1]: print("Yes") else: print("No")
A = [1,3,5,7,8,10,12] B = [4,6,9,11] a,b = [int(i) for i in input().split()] if a in A and b in A: print('Yes') elif a in B and b in B: print('Yes') else: print('No')
from sys import stdin def main(): nums = [int(n) for n in stdin] primes = list(filter(is_prime, nums)) print(len(primes)) def is_prime(n): if 1 == n: return False if 2 == n: return True if 0 == n % 2: return False for i in range(3, n, 2): if not i <= int...
h, w = map(int, input().split()) L = [input() for _ in range(h)] r = 0 for i in range(h): for j in range(w): if L[i][j] == '#': if j < r: print('Impossible') exit() else: r = j else: print('Possible')
X = int(input()) if (X==3) or (X==5) or (X==7): print('YES') else: print('NO')
def solve(): S = input() for _ in range(len(S)): S = S[:-2] if S[:len(S) // 2] == S[len(S) // 2:]: print(len(S)) exit() if __name__ == "__main__": solve()
s = str(input()) print("Sunny" if s == "Rainy" else "Cloudy" if s == "Sunny" else "Rainy")
A=[] for i in range(3): A.append(list(map(int, input().split()))) N = int(input()) b = [] for i in range(N): b.append(int(input())) flugs = [[False] * 3 for i in range(3)] for i in range(3): for j in range(3): if A[i][j] in b: flugs[i][j] = True result = 'No' for i in range(3): if all(flugs[...
def pencil_unit(N): _ = N % 10 if _ == 3: return 'bon' elif _ in [0,1,6,8]: return 'pon' else: return 'hon' N = int(input()) print(pencil_unit(N))
s=int(input()) a=s//100 b=s%100 if a>0 and a<=12: if b>0 and b<=12: print("AMBIGUOUS") else: print("MMYY") else: if b>0 and b<=12: print("YYMM") else: print("NA")
li1 = [] li2 = [] for i, s in enumerate(input()): if s == "\\": li1.append(i) elif s == "/" and li1: j = li1.pop() c = i - j while li2 and li2[-1][0] > j: c += li2[-1][1] li2.pop() li2.append((j, c)) if li2: li3 = list(zip(*li2))[1] print(s...
lst = input().split() for i in range(3): lst[i] = int(lst[i]) lst.sort() print(lst[0] + lst[1])
def gcd(a,b): r = a % b while r > 0: a = b b = r r = a % b return b def lcm(a,b): return a*b / gcd(a,b) while True: try: a,b = map(int, raw_input().split()) print str(gcd(a,b)) + " " + str(lcm(a,b)) except EOFError: break
import math from datetime import date def main(): line = input().split() a = [int(x) for x in line] a.sort() if a[0] == 5 and a[1] == 5 and a[2] == 7: print("YES") else: print("NO") main()
N = int(input()) r = [2,1] for _ in range(N-1):r.append(r[-1]+r[-2]) print(r[-1])
# 0123の周期でXORはリセットされるため剰余だけ考える def solve(x): if x % 4 == 3: return 0 elif x % 4 == 0: return x elif x % 4 == 1: return x ^ (x - 1) elif x % 4 == 2: return x ^ (x - 1) ^ (x - 2) a, b = map(int, input().split()) print(solve(a - 1) ^ solve(b))
n = int(input()) if n==2: a = int(input()) b = int(input()) print(int(a+b)) else: print('Hello World')
# A,Restaurnat # すぬけくんはレストランに通うのが好きです。 # すぬけくんの行きつけのレストランは何を食べても1食800円で、15食食べる毎にその場で200円もらえます。 # すぬけくんは今まで合計N食食べました。今までに払った金額をx円、レストランにもらった金額をyとして、x - yを求めなさい。 # 1 <= N <= 100 # N = 食数 N = int(input()) # x:今までに支払った金額 x = 800 * N # print(x) # y:レストランにもらった金額 y = int((N // 15) * 200) answer = int(x - y) print(answer)
S = input() for i,s in enumerate(S): if s == 'A': if i != len(S) and S[i+1] == 'C': print('Yes') break else: print('No')
print('YES' if input() in ['7','5','3'] else 'NO')
import bisect def sieve(n): is_prime =[1]*n is_prime[0]=0 for i in range(2,int((n**0.5)//1+2)): if is_prime[i-1]: j=i*2 while j<=n: is_prime[j-1]=0 j+=i table=[i for i in range(3,n+1) if is_prime[i-1] and is_prime[i//2]] return table ...
def main(): a,op,b = (x for x in input().split()) if op == '+': print(int(a)+int(b)) else: print(int(a)-int(b)) if __name__ == '__main__': main()
def gcd(a,b): if(b==0): return a return gcd(b,a%b) while True: try: a,b = map(int, input().split()) g = gcd(a,b) print("%s %d"%(g,a/g*b)) except: break
r =float(input()) pi = 3.141592653589 s=r**2*pi c=2*pi*r print(s,c)
A = str(input()) A = list(A) B = str(input()) B = list(B) if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]: print("YES") else: print("NO")
import math a = int(input()) b = 0 for i in range(1,a+1): for j in range(1,a+1): for k in range(1,a+1): b+=math.gcd(math.gcd(i,j),k) print(b)
#!/usr/bin/env python3 N = int(input()) L = sorted([int(s) for s in input().split()]) def check_search(middle, idx_short2, l_lng, l_lows): return l_lows[middle] + l_lows[idx_short2] > l_lng l_lows = L[:2] triangles = 0 for l_lng in L[2:]: for idx, l_low in enumerate(l_lows): left = 0 right...
a = input() a = int(a) h = a//3600 m = a%3600//60 s = a%60 print(str(h)+":"+str(m)+":"+str(s))
str1=input() str2=input() str=str1*2 if str2 in str: print("Yes") else: print("No")
s = str(input()) a = set(s) if len(a) == 3: print('Yes') else: print('No')
a,b,c=map(int,input().split()) if b>=c: print('delicious') elif a>=c-b: print('safe') else: print('dangerous')
n = int(input()) ans = '' if n > 999: ans = "ABD" else: ans = "ABC" print(ans)
H,W = map(int,input().split()) ikeg = '#'*(W+2) print(ikeg) for i in range(H): print('#'+input()+'#') print(ikeg)
def insertion_sort(l, n, g): global count for i in range(g, n): v = l[i] j = i - g while j >= 0 and l[j] > v: l[j + g] = l[j] j -= g count += 1 l[j + g] = v def shell_sort(l, n): for i in range(m): insertion_sort(l, n, G[i]) def...
n = int(input()) s = input() if s.count('B') < n/2: print('Yes') else: print('No')
def insertion_sort(l, g): cnt = 0 for i in range(g, len(l)): tmp = l[i] j = i - g while j >= 0 and l[j] > tmp: l[j+g] = l[j] cnt += 1 j -= g l[j+g] = tmp return l, cnt def shell_sort(l, lg): tot = 0 for g in lg: sl, cnt =...
n = int(input()) odd = list() even = list() for i in range(n): if i % 2 == 0: even.append(i) elif i % 2 != 0: odd.append(i) print(len(odd) * len(even))
import math a, b, x = list(map(float, input().split())) if x <= 0.5 * a * a * b: res = math.degrees(math.atan(2 * x / (a * b * b))) elif x < a * a * b: res = math.degrees(math.atan(a / (2 * (b - x / a ** 2)))) else: res = 90.0 print(f'{90 - res:.7f}')
import collections def main(): s = str(input()) if len(s) % 2 == 0: for i in range(len(s)//2): if s[0+2*i:2+2*i] != 'hi': print('No') break else: print('Yes') else: print('No') if __name__ == '__main__': main()
numbers = input() number_list = [int(i) for i in numbers.split()] if number_list[0] <= number_list[2] and number_list[2] <= number_list[1]: print('Yes') else: print("No")
num = int(input()) total = num +num**2 +num**3 print(total)
num=int(input()) val=0 for i in input().split(): val+=int(i) print("YES" if val%2==0 else "NO")
import math import numpy as np A,B = np.array(input().split(),dtype = int) def gcd(x,y): if y == 0: return x else: return gcd(y,x%y) print(int(A*B/(gcd(A,B))))
N = int(input()) count = int(0) g = N while g >= 3: g = g - 3 count = count + 1 print(count)
n = int(input()) A = list(map(int,input().split())) odd_pair = 1 all_pair = 1 for a in A: all_pair*=3 if a%2==0: odd_pair*=2 print(all_pair-odd_pair)
def consecutive_integers(N: int, K: int)->int: return N - (K-1) if __name__ == "__main__": N, K = map(int, input().split()) ans = consecutive_integers(N, K) print(ans)
s = input() start_with_a = s[0] == 'A' contains_c = s[2:-1].count('C') == 1 all_lowercases = s.replace('A', '').replace('C', '').islower() print('AC' if all([start_with_a, contains_c, all_lowercases]) else 'WA')
print("NO" if input().count("x")>=8 else "YES")
N = int(input()) print(N//2 if N%2 else N//2-1)
from collections import defaultdict def fraction(a, b): """a/b を既約分数 numer/denom として求める denom は必ず非負整数 numer = denom = 0 のときは numer/denom = 0/0 numer = 0 のときは numer/denom = 0/1 denom = 0 のときは numer/denom = 1/0 """ numer, denom = a, b if numer == denom == 0: return 0, 0 elif ...
# -*- coding: utf-8 -*-S x,a,b = [int(i) for i in input().split()] A = abs(x - a) B = abs(x - b) if A < B: print("A") if A > B: print("B")
a, b, c = eval(input().replace(' ', ',')) print("Yes" if a < b < c else "No")
import datetime S = input() S = datetime.datetime.strptime(S, '%Y/%m/%d') a = int(S.year) if a != 2018: S = S.replace(2018) print(S.strftime('%Y/%m/%d'))
def INT(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) X = INT() i = 1 place = 0 while place < X: place += i i += 1 ans = i - 1 print(ans)
import sys def I(): return int(sys.stdin.readline().rstrip()) N = I() mod = 10**9+7 import math def sieve_of_eratosthenes(n): prime_list = [] # n以下の素数のリスト A = [1]*(n+1) # A[i] = iが素数なら1,その他は0 A[0] = A[1] = 0 for i in range(2,math.floor(math.sqrt(n))+1): if A[i]: prime_list.ap...
x = int(input()) print('Yes' if 30 <= x else 'No')