text
stringlengths
37
1.41M
a,b = input().split() if a =="H": print("H") if b =="H" else print("D") else: print("D") if b =="H" else print("H")
string1 = input() string2 = input() count = 0 for i in range(len(string1)): if string1[i] != string2[i]: count += 1 print(count)
# A - abc of ABC # 標準入力S S = input() abc_list = ["a", "b", "c"] for i in S: if i in abc_list: abc_list.remove(i) if len(abc_list) == 0: print('Yes') else: print('No')
S=input() print('YES' if S.replace('A','')=='KIHBR' and 'KIH' in S and 'AA' not in S else 'NO')
x = input().split() t = '' if x[0] == x[1]: t = x[0] elif x[1] == x[2]: t = x[1] elif x[0] == x[2]: t = x[0] for i in x: if t != i: print(i)
from collections import Counter def main(): n = int(input()) a = input() b = input() c = input() cnt = 0 for es in zip(a, b, c): ec = Counter(es) l = len(ec) if l == 3: cnt += 2 elif l == 2: cnt += 1 print(cnt) if __name__ == "__m...
N=int(input()) if N==0: print("1") elif N==1: print("0")
x = int(input()) ans = 8 if x < 600: ans=8 elif x < 800: ans=7 elif x < 1000: ans=6 elif x < 1200: ans=5 elif x < 1400: ans=4 elif x < 1600: ans=3 elif x < 1800: ans=2 else: ans=1 print(ans)
s = input() res = "" for i in range(len(s)): if s[i]!="?": res += s[i] else: res+="D" print(res)
sing = input() if sing[-1] == 's': plu = sing + 'es' else : plu = sing + 's' print(plu)
r = int(input()) s = float() s = r*3.1415926535*2 print(s)
print(' ' + ' '.join(str(i) for i in range(1, int(input()) + 1) if i % 3 == 0 or '3' in str(i)))
list = input().split() a=int(list[0]) b=int(list[1]) c = a*b if c%2==1: print("Odd") if c%2==0: print("Even")
input_line = input() # W,H,x,y,r input_data = input_line.strip().split(' ') W, H, x, y, r = [int(i) for i in input_data] if x < 0 or y < 0: print("No") elif W >= (x+r) and H >= (y+r): print("Yes") else: print("No")
#! python 3 # distance_ii.py import math def minkovski(a, b, p): if p == 'inf': tmp_arr = [abs(x-y) for x, y in zip(a, b)] max_val = tmp_arr[0] for i in range(1, len(a)): if max_val < tmp_arr[i]: max_val = tmp_arr[i] return max_val else: dst ...
x = input() num = [0] for i in x: if i == "S": num.append(num[-1] - 1) else: num.append(num[-1] + 1) print(max(max(num), 0) * 2)
s = input() + '*' ans = 0 before_s = s[0] i = 1 while i < len(s): if s[i] == before_s: # print('hi',before_s, s[i:i+2]) before_s = s[i:i+2] ans += 1 i += 2 else: # print(i, before_s, s[i]) before_s = s[i] ans += 1 i += 1 print(ans)
def main(): s=input() t=set(s) if len(s)==len(t): print('yes') else: print('no') main()
dict = {0: 'Sunny', 1: 'Cloudy', 2: 'Rainy'} S = input() for i, k in enumerate(dict.items()): if k[1] == S: print(dict[(k[0] + 1) % 3]) exit()
from datetime import datetime as dt s = input() s = dt.strptime(s, '%Y/%m/%d') cm = dt.strptime("2019/4/30", '%Y/%m/%d') # print((s-cm).days) if (s-cm).days > 0: print("TBD") else: print("Heisei")
s=input() if "C" in s and "F" in s and s.find("C")<len(s)-1-s[::-1].find("F"): print("Yes") else: print("No")
numberOfDataSets = 0 sideLengthList = [] while 1: try: data = raw_input().split() if len(data) == 1 : numberOfDataSets = int(data[0]) if numberOfDataSets != 0 : sideLengthList = [] elif len(data) == 3 and numberOfDataSets != 0: numberOfDataSets -= 1 sideLengthList.append(data) if numberOf...
import sys s = input() for i in range(97, 123): st = chr(i) if st not in s: print(st) sys.exit() print(None)
import datetime as dt S=input() s=dt.datetime.strptime(S,'%Y/%m/%d') A='2019/04/30' a=dt.datetime.strptime(A,'%Y/%m/%d') if s<=a: print('Heisei') else: print('TBD')
def gcd(a,b): return a if b==0 else gcd(b,a%b) def lcm(a,b): return a*b/gcd(a,b) while 1: try: a,b=map(int,raw_input().split()) print gcd(a,b),lcm(a,b) except: break
# -*- coding: utf-8 -*- buf = str(raw_input()) char_list = list(buf) res = "" for i in char_list: if i.isupper(): res += i.lower() elif i.islower(): res += i.upper() else: res += i print res
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) def gcd_list(numbers): return reduce(math.gcd, numbers) n = int(input()) print(gcd_list(list(map(int,input().split()))))
N = int(input()) x = list(input().split()) num = [int(x[i]) for i in range(N)] num_sorted = sorted(num) min_center = num_sorted[N // 2 - 1] max_center = num_sorted[N // 2] for i in range(N): if num[i] <= min_center: print(max_center) else: print(min_center)
s=list(input()) t=list(input()) s.sort() t.sort(reverse=True) list=[s]+[t] list.sort() if list[0]==t: print("No") else: print("Yes")
# coding: utf-8 import math as m N = int(input()) # フラクタルのステップをnとする # 端点p1, p2を与えてs, t, uを計算 class Point(object): def __init__(self, x, y): self.x = x self.y = y def rotateX(s, t, theta): return m.cos(theta)*(t.x - s.x) - m.sin(theta)*(t.y - s.y) + s.x def rotateY(s, t, theta): return...
# coding: utf-8 # Your code here! A=set(map(int,input().split())) if len(A)==2: print("Yes") else: print("No")
import math x=input() y=input() flag=True if(x[0]!=y[2]): flag=False elif(x[2]!=y[0]): flag=False elif(x[1]!=y[1]): flag=False if(flag): print("YES") else: print("NO")
N = input() if (N[0] == N[1]) and (N[1]==N[2]) and (N[2]==N[0]): print(N) elif int(N[0]) == int(N[1]) and int(N[1]) > int(N[2]): print(N[0]*3) elif int(N[0]) > int(N[1]): print(N[0]*3) else: print(str(int(N[0])+1)*3)
a = list(map(int,input().split())) if a[0]==a[1]+a[2] or a[1]==a[0]+a[2] or a[2]==a[0]+a[1]: print('Yes') else: print('No')
import sys ## io ## def IS(): return sys.stdin.readline().rstrip() def II(): return int(IS()) def MII(): return list(map(int, IS().split())) def MIIZ(): return list(map(lambda x: x-1, MII())) ## dp ## def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)] def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in...
def check_num(n): if n % 3 == 0\ or n % 10 == 3\ or str(n).find("3") != -1: print(" {0}".format(n), end="") n = int(input()) for i in range(3, n+1): check_num(i) print()
import math from collections import defaultdict def prime_factorize(n): prime_numbers = [] for p in range(2, int(math.sqrt(n)+1)): if n % p != 0: continue while n % p == 0: n /= p prime_numbers.append(p) if n != 1: prime_numbers.append(n) retu...
#coding:utf-8 input_line = input().split(" ") D = int(input_line[0]) T = int(input_line[1]) S = int(input_line[2]) if D/S <= T: print("Yes") else: print("No")
import math def calc_yakusu_num(n): num = 0 for i in range(1, int(math.sqrt(n)) + 1): if n % i == 0: if i == n // i: num += 1 else: num += 2 return num - 1 def calc_yakusu(n): yakusu = [] for i in range(1, int(math.sqrt(n)) + 1): ...
a,b= input().split() a,b=int(a),int(b) if a+b <24: print(a+b) elif a+b>=24: print(a+b-24)
# -*- coding: utf-8 -*- def linear_search(S, T): count = 0 for i in xrange(len(T)): if T[i] in S: count += 1 return count if __name__ == '__main__': n = input() S = map(int, raw_input().split()) q = input() T = map(int, raw_input().split()) print linear_search(S, ...
s = sorted(input()) t = sorted(input()) t.reverse() st = [s, t] if st == sorted(st) and s != t: print("Yes") else: print("No")
# -*- coding: utf-8 -*- # C - Factors of Factorial # 標準入力の取得 N = int(input()) # N以下の素数リストを作成 prime_number_list = [] for n in range(2, N+1): is_prime_number = True for i in range(2, int(n**0.5)+1): if n % i == 0: is_prime_number = False if is_prime_number: prime_number_list.appen...
class Dice: def __init__(self, men): self.men = men def throw(self, direction): if direction == "E": pmen = men[:] men[0] = pmen[3] men[1] = pmen[1] men[2] = pmen[0] men[3] = pmen[5] men[4] = pmen[4] men[5] = pm...
string = input() numbers = string.split() a, b = int(numbers[0]), int(numbers[1]) d = a//b r = a%b f = a/b print(d, r, "{:.12f}".format(f))
def fibonacci(N, dp): if dp[N] != 0: return dp[N] if N == 1 or N == 0: dp[N] = 1 else: dp[N] = fibonacci(N - 1, dp) + fibonacci(N - 2, dp) return dp[N] def main(): N = int(input()) dp = [0] * (N + 1) print(fibonacci(N, dp)) if __name__ == '__main__': main()
from collections import deque s = list(input()) s = deque(s) cnt = 0 while len(s) > 1: left = s.popleft() right = s.pop() if left == right:continue if left != 'x' and right != 'x': print(-1) exit() if left == 'x': s.append(right) else: s.appendleft(left) cnt ...
import math r = float(input()) #r = (float(x) for x in input().split()) d = r * r * math.pi R = 2 * r * math.pi print ("{0:.6f} {1:.6f}".format(d,R))
N = int(input()) ans = 'second' for _ in range(N): if int(input()) % 2 == 1: ans = 'first' break print(ans)
#解説、答え参照済み class UnionFind(): def __init__(self, n): self.n=n self.parents=[-1]*n #各要素の親要素の番号を格納するリスト def find(self, x): #要素xが属するグループの根を返す if self.parents[x]<0: return x else: self.parents[x]=self.find(self.parents[x]) return self.parents[x] ...
def main(): n = int(input()) c = 0 if n % 2 == 1: print(0) return i = 10 x, _ = divmod(n, i) while x: c += x i *= 5 x, _ = divmod(n, i) print(c) if __name__ == '__main__': main()
x = input() y = x.split(" ") y = [int(z) for z in y] if y[0] < y[1] and y[1] < y[2]: print("Yes") else: print("No")
s = sorted(list(set(input()))) if len(s) == 1 or len(s)==3: ans = "No" elif len(s) == 2 or len(s)==4: if s == ["N","S"] or s == ["E", "W"]: ans = "Yes" elif s == ["E", "N", "S", "W"]: ans = "Yes" else: ans = "No" print(ans)
class Queue(object): def __init__(self, _max): if type(_max) != int: raise ValueError self._array = [None for i in range(0, _max)] self._head = 0 self._tail = 0 self._cnt = 0 def enqueue(self, value): if self.is_full(): raise IndexError ...
letter = input() dict = {'A': 'T', 'C':'G', 'T':'A', 'G':'C'} if letter in dict: print(dict[letter])
while 1: h,w = map(int, raw_input().split()) if h==w==0: break for i in range(0,h/2): print ("#." * (w/2) + "#" * (w%2)) print (".#" * (w/2) + "." * (w%2)) if h % 2 == 1: print ("#." * (w/2) + "#" * (w%2)) print ""
S = list(input()) ans = "AC" if S[0] != "A": ans = "WA" if S[2:-1].count("C") != 1: ans = "WA" else: S.pop(S[2:-1].index("C") + 2) if not "".join(S[1:]).islower(): ans = "WA" print(ans)
S = input() S_set = set(S) if len(S_set) % 2 == 0: if S_set == set() or S_set == set(['N', 'S']) or S_set == set(['E', 'W']) or S_set == set(['N', 'S', 'E', 'W']): print('Yes') else: print('No') else: print('No')
from collections import Counter S = Counter(list(input())) T = Counter(list(input())) if len(S) != len(T): print("No") else: Sv = [] Tv = [] for v in S.values(): Sv.append(v) for v in T.values(): Tv.append(v) Svc = Counter(Sv) Tvc = Counter(Tv) if Svc == Tvc: prin...
while True: ( H, W) = [ int(i) for i in input().split()] if H == W == 0: break for h in range( H): for w in range( W): if h == 0 or h == H-1: print( '#', end='') elif w == 0 or w == W-1: pass print( '#', end='') else: print( '.', end='') print() pr...
n = input().split() a = n[0] b = n[1] c = n[2] if a[-1] == b[0] and b[-1] == c[0]: print('YES') else: print('NO')
a,b,c,d = input() print("Yes" if (a==b and b==c) or (b==c and c ==d) else "No")
n = int(input()) ans = 0 for a in range(10**5 + 1): if a**2 <= n: ans = max(ans, a**2) print(ans)
days = ["SUN", 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'] days.reverse() d = input() print(days.index(d)+1)
s = input() if all(s[i] != s[i+1] for i in range(3)): print('Good') else: print('Bad')
class Trio: __pre=None __val=None __nex=None def __init__(self,val,p=None,n=None): self.__pre=p self.__val=val self.__nex=n def get_pre(self):return self.__pre def get_nex(self):return self.__nex def set_pre(self,n):self.__pre=n def set_nex...
N = int(input()) ans = 0 for i in range(int(pow(N,1/2))+1): if i**2 <=N: ans = i**2 print(ans)
a, b, c = map(int, input().split()) # 少なくとも一つ、奇数が存在する場合 if a % 2 != 0 or b % 2 != 0 or c % 2 != 0: print(0) exit() # 全て偶数で、A=B=Cの場合 if a == b and b == c: print(-1) exit() cnt = 0 while True: cnt += 1 next_a = b // 2 + c // 2 next_b = a // 2 + c // 2 next_c = a // 2 + b // 2 a = nex...
s = [x for x in input().split()] print(*[(s[0][0]).upper(), (s[1][0]).upper(), (s[2][0]).upper()], sep="")
SA = input() SB = input() SC = input() S_dict={'a':SA,'b':SB,'c':SC} ans_dict={'a':'A','b':'B','c':'C'} person = 'a' while True: S = S_dict[person] if len(S) <= 0: print(ans_dict[person]) break else: S_dict[person] = S[1:] person = S[0]
n=int(input()) i=0 while not 2**i<=n<2**(i+1): i+=1 print(2**i)
def main(): alphabets_table = [0 for i in range(26)] while True: try: input_string = input() lower_string = input_string.lower() for i, _letter in enumerate("abcdefghijklmnopqrstuvwxyz"): alphabets_table[i] += lower_string.count(_letter) exce...
C1=input() C2=input() C1new="".join(list(reversed(C1))) C2new="".join(list(reversed(C2))) if (C1==C2new)&(C2==C1new): print("YES") else: print("NO")
a,b = (int(x) for x in input().split()) c = (a*b)%2 if c == 0: print ('Even') else: print ('Odd')
def binary_search(c1, c2): m = (c1 + c2 + 1) // 2 if abs(c1 - c2) <= 1: return m else: s = list(h) c = 0 for j in s: j -= b * m if j > 0: c += (a + j - b - 1) // (a - b) if c > m: break if c > m: ...
input() if len(["" for i in input().split() if int(i)%2 == 1])%2 == 0: print("YES") else: print("NO")
s = input() a, b = s[:2], s[2:] if '01' <= a <= '12': if '01' <= b <= '12': print('AMBIGUOUS') else: print('MMYY') else: if '01' <= b <= '12': print('YYMM') else: print('NA')
import string S = input() alphabet = string.ascii_lowercase def least_char_notin(s): for c in alphabet: if c not in s: return c return None def next_char(c): return chr(ord(c)+1) def is_diverse(s): if len(s) == len(set(s)): return True return False def next_diverse(...
import itertools n = int(input()) def Eratosthenes(n): Primes = [2] All = [x for x in range(3, n+1)] check = True max_check = int((n**(1/2)//1)) while check: if All[0] > max_check: return Primes + All[1:] All = [x for x in All if x % Primes[-1] != 0] Primes.appe...
# coding: utf-8 # Here your code ! import collections s=int(input()) deq =collections.deque() for i in range(s): n=input().split() if n[0]=="insert": deq.appendleft(n[1]) elif n[0]=="delete": try: deq.remove(n[1]) except ValueError: pass elif n[0]=="delet...
def main(): k = int(input()) if k % 2: res = (k // 2) * (k - k // 2) else: res = (k // 2) ** 2 print(res) if __name__ == '__main__': main()
a, b = map(int, input().split()) if a > b: for _ in range(a): print(b, end="") else: for _ in range(b): print(a, end="")
# coding=utf-8 def merge(a, left, mid, right): n1 = mid-left n2 = right - mid left_list = [a[left + i] for i in range(n1)] right_list = [a[mid + i] for i in range(n2)] left_list.append(1000000007) right_list.append(1000000007) i = 0 j = 0 ctr = 0 for k in range(left, right): ...
x=int(input()) ans=0 X=0 while X<x: ans+=1 X+=ans #print(X,ans) print(ans)
s=input() t=input() s1={} t1={} for i in range(len(s)): if s[i] in s1 and t[i] in t1: if s1[s[i]]!=t1[t[i]]: print("No") break elif s[i] not in s1 and t[i] not in t1: s1[s[i]]=i t1[t[i]]=i else: print("No") break else: print("Yes")
number = int(input()) print(int((number + 1) * number / 2))
s = input() if s in ['hi','hihi','hihihi','hihihihi','hihihihihi']: print('Yes') else: print('No')
s = input() pc = s.find("C") if -1 < pc and -1 < s.find("F", pc): print("Yes") else: print("No")
s = input() a = ['a', 'i', 'u', 'e', 'o'] for i in a: if s == i: print('vowel') exit() print('consonant')
N = int(input()) A = list(map(int, input().split())) for a in A: if a%2==0 and not (a%3==0 or a%5==0): print("DENIED") exit() print("APPROVED")
test_string = input() words = test_string.split(", ") cases_switched_strings = [] for word in words: cases_switched_strings.append(word.swapcase()) output = ", ".join(cases_switched_strings) print(output)
for i in range (1,10): print("{}x{}={}".format(i,1,i*1)) print("{}x{}={}".format(i,2,i*2)) print("{}x{}={}".format(i,3,i*3)) print("{}x{}={}".format(i,4,i*4)) print("{}x{}={}".format(i,5,i*5)) print("{}x{}={}".format(i,6,i*6)) print("{}x{}={}".format(i,7,i*7)) print("{}x{}={}".format(i,8...
import math def isPrime(a): mx = math.sqrt(a) tmp = 2 while tmp <= mx: if a % tmp == 0: return False tmp += 1 return True x = int(input()) tmp = 0 while True: if isPrime(x + tmp): f = 1 print(x+tmp) break tmp += 1
from decimal import Decimal import math def main(): x = Decimal(input()) y = 0 p = Decimal(100) gr = Decimal('1.01') while p < x: p *= gr p = math.floor(p) y += 1 print(y) main()
N = int(input()) if N%2 == 1 : print(0) exit() n = 0 i = 0 for i in range(1,26) : n += N//((5**i)*2) print(n)
a, b = [int(i) for i in input().split()] a, b = [a, b] if a < b else [b, a] print(str(a) * b)
n = int(input()) s = input() pre = s[:n//2] after = s[n//2:] if n % 2 == 0 and pre == after: print('Yes') else: print('No')
def calc(a, b, op): """ a: int b: int op: operator returns the result of arithmetic operation >>> calc(1, 2, '+') 3 >>> calc(56, 18, '-') 38 >>> calc(13, 2, '*') 26 >>> calc(100, 10, '/') 10 >>> calc(27, 81, '+') 108 """ def add(a, b): return ...
class common_function(): """ 1. よく使いそうで予め用意しておいた変数をまとめた 2. よく使いそうな関数群をまとめた """ def __init__(self): """ 1. 英字の一覧をリストに格納しておいた変数 """ self.sletter = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', ...
a,b=list(input()),list(input()) a.reverse() print("YES" if a == b else "NO")