text
stringlengths
37
1.41M
a, b = input().split() if a==b=="H" or a==b=="D": print("H") else: print("D")
S = input() # S = 'AaCa' # print( S[1], S[-1], S[3:-2]) b = True b = b and (S[0]=='A') b = b and ( S[2:-1].count('C')==1 ) b = b and ( 'a' <= S[1] <= 'z') b = b and ( 'a' <= S[-1] <= 'z') for c in S[3:]: b = b and ( ('a' <= c <= 'z') or (c=='C') ) print( "AC" if b else "WA" )
from collections import deque def main(): d = deque() for _ in range(int(input())): command = input() if command[0] == 'i': d.appendleft(command[7:]) elif command[6] == ' ': try: d.remove(command[7:]) except ValueError: pass elif len(command) == 11: d.popleft() else: d.pop() print(*d) if __name__ == '__main__': main()
s = input() prev = 'D' ans = [] for i in s: if(i=='P' or i=='D'): prev=i ans.append(i) else: ans.append('D') print(''.join(ans))
def input_int(): return(int(input())) def input_int_list(): return(list(map(int,input().split()))) def input_int_map(): return(map(int,input().split())) import heapq def run(): n, ticket_count = input_int_map() nums = input_int_list() nums = list(map(lambda x: x * (-1), nums)) # 各要素を-1倍 heapq.heapify(nums) for _ in range(ticket_count): num = (heapq.heappop(nums) * (-1)) num = num // 2 heapq.heappush(nums, num * (-1)) nums = list(map(lambda x: x * (-1), nums)) print(sum(nums)) run() # 2 4 3 # 3 4 3 # 2 6 3
S=input() s=len(S) if S[s-1] == "s": print(S+"es") else: print(S+"s")
x = int(input()) ans = "No" if x == 2: ans = "Yes" while ans == "No": for i in range(2,max(x//2,3)): ans = "Yes" if x % i == 0: x += 1 ans = "No" break print(x)
input_line = raw_input().split() a = int(input_line[0]) b = int(input_line[1]) c = int(input_line[2]) if( (a<b)and(b<c) ): print 'Yes' else: print 'No'
s="Christmas" for i in range(25-int(input())): s += " Eve" print(s)
# S の長さが K 以下であれば、S をそのまま出力してください。 # S の長さが K を上回っているならば、 # 先頭 K 文字だけを切り出し、末尾に ... を付加して出力してください。 # K は 1 以上 100 以下の整数 # S は英小文字からなる文字列 # S の長さは 1 以上 100 以下 K = int(input()) S = str(input()) if K >= len(S): print(S) else: print((S[0:K] + '...'))
array = [] for i in range(3): val = input().split() array.append(val) A,B = [int(s) for s in array[1]] if array[2][0] == array[0][0]: print(str(A - 1) + " " + str(B)) else: print(str(A) + " " + str(B - 1))
import sys alphabet = "abcdefghijklmnopqrstuvwxyz" s = set(sorted(input().strip())) for i in alphabet: if not i in s: print(i) sys.exit() print("None")
import math def prime_check(x): if x == 2: return True limit = math.floor(math.sqrt(x)+1) cnt = 0 for i in range(2,limit): if x%i == 0: cnt += 1 if cnt == 0: return True else: return False X = int(input()) while True: if prime_check(X): print(X) break else: X += 1
n = int(input()) if n%2 ==1: print(0) exit() cnt = 0 i = 1 if n%2 == 0: while n//(2*(5**i)) > 0: cnt += n//(2*(5**i)) i +=1 print(cnt)
String1, String2, String3 = input().split() print('A' + String2[0] + 'C')
import math import collections import fractions import itertools import functools import operator def yakusu_rekkyo(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] def solve(): n = int(input()) cnt = 0 for i in range(1,n+1): hoge = 0 for j in yakusu_rekkyo(i): if j%2 == 1: hoge += 1 if hoge == 8: cnt += 1 print(cnt) return 0 if __name__ == "__main__": solve()
class UnionFind(): def __init__(self,n): self.n=n self.parents =[-1]*n def find(self, x): if self.parents[x]<0: return x else: self.parents[x]=self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x=self.find(x) y=self.find(y) if x==y: return if self.parents[x]>self.parents[y]: x,y=y,x self.parents[x]+=self.parents[y] self.parents[y]=x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x)==self.find(y) def members(self, x): root=self.find(x) return list(i for i in range(self.n) if self.find(i) == root) def roots(self): return list(i for i, x in enumerate(self.parents) if x < 0) def group_count(self): return len(self.roots) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) adj=[] N, M = map(int, input().split()) for m in range(M): a,b=map(int, input().split()) adj.append([a-1,b-1]) ans = 0 for i in range(M): uf = UnionFind(N) for j in range(M): if i == j: continue uf.union(*adj[j]) if len(set(uf.roots()))!=1: ans += 1 print(ans)
a = int(input()) if a % 2 == 0: print(str(int(a//2))) else: print(str(int(a//2)+1))
def main(): N = list(input().split()) N.sort() if N[0] + N[3] + N[2] + N[1] == "1974": return "YES" return "NO" if __name__ == '__main__': print(main())
N=int(input()) if N%2==1: print(int((N-1)/2+1)) else: print(int(N/2))
N = int(input()) i = 1 sum = 0 while True: if i%3!=0 and i%5!=0: sum +=i i+=1 if i==N+1: break print (sum)
n = str(input())[-1] if n == '3': print('bon') elif (n == '0') or (n == '1') or (n == '6') or (n == '8'): print('pon') else: print('hon')
n=int(input()) if n==0 or n==1 or n==2: print(0) elif n==3: print(1) elif n%2==1:#奇数 print(int(n/2)) elif n%2!=1:#偶数 print(int(n/2)-1)
ans = [] while True: arr = map(str, raw_input().split()) if arr[1] is '?': break val = eval(arr[0] + arr[1] + arr[2]) ans.append(val) print("\n".join(map(str, ans)))
# A - One Card Poker # Alice と Bob は 2人で1枚のポーカーをやっている # カードの強さは以下の通り # 弱 2 < 3 < 4 < ・・・・・ < 12 < 13 < 1 強 # 1.各プレイヤーは、トランプからカードを1枚選んで、自分の手札とします。 # 2.両プレイヤーは、手札を見せ合います。強いカードを持っているプレイヤーが勝ちです。 #  なお、両プレイヤーの持っているカードの強さが同じ場合は引き分けです。 # Alice が持っているカードを A # Bob が持っているカードを B # 勝敗を判定するプログラムを作る # A B を標準入力から得る A, B = map(int, input().split()) # print(A, B) # Alice が 勝つなら Alice # Bob が 勝つなら Bob # 引き分けなら Draw if A == B: answer = "Draw" elif A == 1: answer = "Alice" elif B == 1: answer = "Bob" elif A > B: answer = "Alice" else: answer = "Bob" # 結果を出力 print(answer)
print('Yes' if '7' in list(str(input().split())) else 'No')
# -*- coding: utf-8 -*- s = list(input()) for i, posi in enumerate(s): num = i+1 if num % 2 == 0 and posi == 'R': print('No') exit(0) elif num % 2 != 0 and posi == 'L': print('No') exit(0) print('Yes')
n = int(input()) if n%10 == (n-n%100)/100: print("Yes") else: print("No")
n = int(input()) s = input() if n % 2 == 1: res = "No" else: if s[:n//2] == s[n//2:]: res = "Yes" else: res = "No" print(res)
if input() in ['hi' * i for i in range(20)]: print('Yes') else: print('No')
word = raw_input() count = 0 while 1: line = raw_input() if line == "END_OF_TEXT": break for target in line.split(" "): if word.lower() == target.lower(): count += 1 print(count)
def gcd(a,b): if b==0: return a c=a%b return gcd(b,c) x,y=map(int,input().split()) if x<y: x,y=y,x m=gcd(x,y) print(m)
def main(): S = input() T = input() cnt = 0 for a, b in zip(S, T): cnt += a != b print(cnt) if __name__ == '__main__': main()
def gcd(x, y): if x == y: return x while(1): if x < y: temp = x x = y y = temp x = x%y if x == 0: return y x, y = map(int, raw_input().split()) print gcd(x, y)
from collections import deque n = int(input()) queue = deque() for _ in range(n): tmp = input().split() cmd = tmp[0] if cmd == 'insert': queue.appendleft(tmp[1]) elif cmd == 'delete': try: queue.remove(tmp[1]) except ValueError: pass elif cmd == 'deleteFirst': queue.popleft() else: queue.pop() print(' '.join(queue))
A=input() A=A.split() D=int(A[0]) T=int(A[1]) S=int(A[2]) if S*T>=D: print("Yes") else: print("No")
def answer(destination, services): P, M = ("POSSIBLE", "IMPOSSIBLE") dic = {} for a, b in services: if dic.get(a) is None: dic[a] = [b] else: dic[a].append(b) if dic.get(b) is None: dic[b] = [a] else: dic[b].append(a) if dic.get(destination) is None: return M arr = dic[destination] for i in arr: if 1 in dic[i]: return P return M n, m = map(int, input().split()) services = [] for _ in range(m): a, b = map(int, input().split()) services.append((a, b)) print(answer(n, services))
def main(): """ ????????? """ num = int(input()) for i in range(num): m = list(map(int,input().split())) m.sort() a = (m[0] ** 2) + (m[1] ** 2) b = (m[2] ** 2) if a == b: print("YES") else: print("NO") if __name__ == '__main__': main()
print('YES' if int(''.join(input().split()))%4 == 0 else 'NO')
class Dice: def __init__(self, face_vals): self.faces = dict(zip(['top', 'front', 'right', 'left', 'back', 'bottom'], face_vals)) def roll(self, direction): if direction == 'N': self.faces['top'], self.faces['front'], self.faces['bottom'], \ self.faces['back'] = self.faces['front'], self.faces['bottom'], \ self.faces['back'], self.faces['top'] elif direction == 'S': self.faces['top'], self.faces['front'], self.faces['bottom'], \ self.faces['back'] = self.faces['back'], self.faces['top'], \ self.faces['front'], self.faces['bottom'] elif direction == 'E': self.faces['top'], self.faces['right'], self.faces['bottom'], \ self.faces['left'] = self.faces['left'], self.faces['top'], \ self.faces['right'], self.faces['bottom'] else: self.faces['top'], self.faces['right'], self.faces['bottom'], \ self.faces['left'] = self.faces['right'], self.faces['bottom'], \ self.faces['left'], self.faces['top'] face_vals = input().split() dice = Dice(face_vals) for i in input(): dice.roll(i) print(dice.faces['top'])
count = 0 INFTY = 10 ** 10 def merge(A, left, mid, right): global count n1 = mid - left; n2 = right - mid; L = [] R = [] for i in range(n1): L.append(A[left + i]) for i in range(n2): R.append(A[mid + i]) L.append(INFTY) R.append(INFTY) i = 0 j = 0 for k in range(left, right): count = count + 1 if L[i] <= R[j]: A[k] = L[i] i = i + 1 else: A[k] = R[j] j = j + 1 def mergeSort(A, left, right): if left+1 < right: mid = (left + right)/2; mergeSort(A, left, mid) mergeSort(A, mid, right) merge(A, left, mid, right) import sys n = raw_input() for line in sys.stdin: items = line.strip().split() items = map(int, items) mergeSort(items, 0, len(items)) print " ".join(map(str, items)) print count
ABC = input().split() list_ABC= list(ABC) if list_ABC[0] == list_ABC[1] and list_ABC[0] == list_ABC[2]: print('Yes') else: print('No')
# A, Can'tWait for Holiday # 今日の曜日を表す文字列Sが与えられます。 # Sは'SUN','MON','TUE','WED','THU','FRI','SAT'のいずれかであり、それぞれ日曜日、月曜日、火曜日。水曜日、木曜日、金曜日、土曜日を表します。 # 月の日曜日(あす以降)が何日後か求めてください。 # Sは'SUN','MON','TUE','WED','THU','FRI','SAT'のいずれか。 S = input() if S == 'MON': print(6) elif S == 'TUE': print(5) elif S == 'WED': print(4) elif S == 'THU': print(3) elif S == 'FRI': print(2) elif S == 'SAT': print(1) else:print(7)
import math import sys import collections import bisect def main(): h, w = map(int, input().split()) hw = [["."] * (w + 2)] + [0] * h + [["."] * (w + 2)] for i in range(h): hw[i + 1] = ["."] + list(input()) + ["."] for i in range(1, h + 1): for j in range(1, w + 1): if hw[i][j] == "#": if hw[i - 1][j] == "#" or hw[i + 1][j] == "#" or hw[i][j - 1] == "#" or hw[i][j + 1] == "#": continue else: print("No") return print("Yes") if __name__ == '__main__': main()
def main(): H, W = (int(_) for _ in input().split()) board = [input() for _ in range(H)] num = 0 for i in range(H): for j in range(W): if board[i][j] == '#': num += 1 def dfs(x, y, n): if x == H-1 and y == W-1: return n == num nx = x + 1 if 0 <= nx < H and board[nx][y] == '#': if dfs(nx, y, n+1): return True ny = y + 1 if 0 <= ny < W and board[x][ny] == '#': if dfs(x, ny, n+1): return True return False print('Possible' if dfs(0, 0, 1) else 'Impossible') return if __name__ == '__main__': main()
def gcd(x, y): if x > y: return gcd(y, x) if y % x == 0: return x else: return gcd(y % x, x) def main(): x, y = map(int, input().split()) print(gcd(x,y)) if __name__ == "__main__": main()
r=int(input()) if r <1200: ans="ABC" elif 1200<=r<2800: ans="ARC" else: ans="AGC" print(ans)
from sys import stdin input = stdin.readline def main(): A, B = input().split() A = int(A) # B = int(100*float(B)) B = int(B[0]+B[2:]) # print((A*B)//100) if A*B < 100: print(0) else: print(str(A*B)[:-2]) if(__name__ == '__main__'): main()
#!/usr/bin/env python S = input() MOD = 10**9+7 a, b, c , d = 0, 0, 0, 1 for s in S: if s == 'A': a += d a %= MOD elif s == 'B': b += a b %= MOD elif s == 'C': c += b c %= MOD else: a, b, c, d = 3*a+d, 3*b+a, 3*c+b, 3*d a %= MOD b %= MOD c %= MOD d %= MOD ans = c print(ans)
n = int(input()) dict = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} for _ in range(n): dict[input()] += 1 for i in dict: print(i, 'x', dict[i])
a=list(map(int,input().split())) if a[1]//a[0]<a[2]: print(a[1]//a[0]) else:print(a[2])
x=int(input()) a=(x//11)*2 print(a if x%11==0 else a+1 if x%11<7 else a+2)
import sys def gcd(a,b): if b== 0:return a return gcd(b,a%b) def return_lcm(a,b): prime = gcd(a,b) return prime*(a/prime)*(b/prime) def solve(): a = [] for line in sys.stdin: digit_list = line.split(' ') new_list = [] for j in digit_list: new_list.append(int(j)) a.append(new_list) for data in a: print str(gcd(data[0],data[1])) + ' ' + str(return_lcm(data[0],data[1])) if __name__ == "__main__": solve()
vals = [int(i) for i in input().split()] a = vals[0] b = vals[1] c = vals[2] d = vals[3] res2 = a//d + (1 if(a % d > 0) else 0) res1 = c//b + (1 if(c % b > 0) else 0) res = "Yes" if(res1 <= res2) else "No" print(res)
#!/usr/bin python3 # -*- coding: utf-8 -*- def main(): N, A, B, C, D = map(int, input().split()) S = input() ret = 'No' if C<D: pathBtoD=S[B-1:D] pathAtoC=S[A-1:C] if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1: ret = 'Yes' else: pathBtoD=S[B-1:D] pathAtoC=S[A-1:C] pathBtoD2 = S[B-2:D+1] if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1: if pathBtoD2.find('...')!=-1: ret = 'Yes' print(ret) if __name__ == '__main__': main()
W = input().lower() ans = 0 while 1: T = input() if T == "END_OF_TEXT": break ans += T.lower().split().count(W) print(ans)
import collections s = input() c = collections.Counter(s) if all(x == 1 for x in c.values()): print('yes') else: print('no')
def is_prime(n): if n == 1: return False return all(n % i != 0 for i in range(2, int(n**0.5) + 1)) x = int(input()) print(min(i for i in range(x, 100004) if is_prime(i)))
a,b = input().split(" ") if int(a)<int(b): print(0) else: print(10)
n=int(input()) l=[int(input()) for i in range(n)] max_num=max(l) max_index=l.index(max(l)) for i in range(n): if i!=max_index: print(max_num) else: l.remove(max_num) print(max(l))
n = str(input()) ans = '' for i in n: if i == '1': ans += '9' elif i == '9': ans += "1" print(ans)
def gcd(a, b): return b if a % b == 0 else gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * b n = int(input()) a = [] for i in range(n): a.append(int(input())) ans = a[0] for x in range(1, n): ans = lcm(ans, a[x]) print(ans)
lst = input().split(' ') m = lst[0] n = lst[1] if n==m: print('Yes') else: print('No')
S = input() k = 'keyence' if S[:7] == k or S[-7:] == k: print('YES') exit() for i in range(len(S)): if S[:i] != k[:i]: if S[-7+i-1:] == k[-7+i-1:]: print('YES') exit() else: print('NO') exit() print('NO')
# D - Five, Five Everywhere def sieve_of_eratosthenes(n): primes = [] is_prime = [True] * (n+1) is_prime[0] = False is_prime[1] = False for i in range(2, n+1): if is_prime[i]: primes.append(i) for j in range(i*2, n+1, i): is_prime[j] = False return primes n = int(input()) A = sieve_of_eratosthenes(55555) ans = [] for a in A: if a%5 == 1: ans.append(a) if len(ans) == n: break print(' '.join(map(str, ans)))
num = int(input()) even_count = num // 2 if num % 2 == 0: odd_count = even_count else: odd_count = even_count + 1 print(odd_count * even_count)
A, B = input().split() order = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '1'] if A == B: print('Draw') elif order.index(A) > order.index(B): print('Alice') else: print('Bob')
#B - Power Socket A,B = input().split() A = int(A) B = int(B) count = 0 total_plug = 1 for i in range(1,B): count += 1 total_plug += (A - 1) if B <= total_plug: break print(count)
S = dict() S['a'] = list(input())[::-1] S['b'] = list(input())[::-1] S['c'] = list(input())[::-1] p = 'a' while S[p]: p = S[p].pop() print(p.upper())
# -*- coding: utf-8 -*- memo = ['' for i in xrange(45)] dp = [0 for i in xrange(45)] # ?????°?????¨?¨??????????O(2^n)????????? def recursion(n): if n == 0 or n == 1: return 1 return recursion(n - 1) + recursion(n - 2) # ?????¢??????????????°?¨??????????O(n)?????§????????§?????? def memo_search(n): if memo[n] != '': return memo[n] else: if n == 0 or n == 1: memo[n] = 1 return 1 memo[n] = memo_search(n - 1) + memo_search(n - 2) return memo[n] # ???????¨?????????§????¨??????????O(n)??¨?????? def dynamic_programming(n): for i in xrange(n + 1): if i == 0 or i == 1: dp[i] = 1 else: dp[i] = dp[i - 1] + dp[i - 2] return dp[n] if __name__ == '__main__': n = input() # print recursion(n) # print memo_search(n) print dynamic_programming(n)
A, B = map(int, input().split()) C = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1] if C.index(A) > C.index(B): print('Alice') elif C.index(A) < C.index(B): print('Bob') else: print('Draw')
string = input() news = "NEWS" flg = [False for _ in range(4)] for s in string: for i in range(4): if s == news[i]: flg[i] = True break if flg[0] != flg[3] or flg[1] != flg[2]: print("No") else: print("Yes")
S=input() T=["KIHBR","KIHBRA","KIHBAR","KIHBARA", "KIHABR","KIHABRA","KIHABAR","KIHABARA", "AKIHBR","AKIHBRA","AKIHBAR","AKIHABRA", "AKIHABR","AKIHABRA","AKIHABAR","AKIHABARA"] ans=0 for i in range(16): if(S==T[i]): ans=1 if(ans): print("YES") else: print("NO")
import sys def input(): return sys.stdin.readline().rstrip() def main(): T = input() len_t = len(T) S = "" for t in T: if t == "?": S += "D" else: S += t print(S) if __name__=='__main__': main()
for val in range(input()): x = map(int,raw_input().split(' ')) x.sort() if x[0]**2+x[1]**2==x[2]**2: print 'YES' else: print 'NO'
a, b, h = (int(input()) for _ in range(3)) s = (a + b) * h // 2 print(s)
#入力例は合うがWAになる A = input() B = input() if A[0]==B[2] and A[1]==B[1] and A[2]==B[0]: print("YES") else: print("NO") #YESとNOにしないといけないところをYes、Noになっていた
N=int(input()) a=list(map(int,input().split())) import numpy as np def getNearestValue(list, num): """ 概要: リストからある値に最も近い値を返却する関数 @param list: データ配列 @param num: 対象値 @return 対象値に最も近い値 """ # リスト要素と対象値の差分を計算し最小値のインデックスを取得 idx = np.abs(np.asarray(list) - num).argmin() return idx avg=sum(a)/N print(getNearestValue(a,avg))
import math def solution(N, K): if (math.floor((N + 1) / 2) >= K): return "YES" else: return "NO" n, k = [int(s) for s in input().split(' ')] print(solution(n, k))
import os, sys, re, math N = (int(input())) S = input() T = S.replace('ABC', '') print((len(S) - len(T)) // 3)
N = input() s1 = set(list(N[1:])) s2 = set(list(N[:-1])) if len(s1) == 1 or len(s2) == 1: print('Yes') else: print('No')
from collections import deque s = deque(input()) n = int(input()) now: bool = True for i in range(n): q = list(input().split()) if q[0] == '1': now = not now else: if (q[1] == '1' and now == True) or (q[1] == '2' and now == False): s.appendleft(q[2]) elif (q[1] == '1' and now == False) or (q[1] == '2' and now == True): s.append(q[2]) if now == True: print(''.join(s)) else: print(''.join(reversed(s)))
S = list(map(str, input().split())) # 単語の先頭の文字をつなげ、大文字にした略語を出力してください s1 = S[0][0].upper() s2 = S[1][0].upper() s3 = S[2][0].upper() print(s1 + s2 + s3)
N = list(input()) if N[len(N) - 1] == "2" or N[len(N) - 1] == "4" or N[len(N) - 1] == "5" or N[len(N) - 1] == "7" or N[len(N) - 1] == "9": print("hon") elif N[len(N) - 1] == "0" or N[len(N) - 1] == "1" or N[len(N) - 1] == "6" or N[len(N) - 1] == "8": print("pon") elif N[len(N) - 1] == "3": print("bon")
x = int(input()) double, rest = divmod(x, 11) if rest == 0: add = 0 elif 1<= rest <= 6: add = 1 else: add = 2 ans = double * 2 + add print(ans)
import math a,b,x = map(int,input().split()) y = (a**2)*b h = x/(a**2) def get_angle_from_sides(a, b, c): return math.acos((a ** 2 + b ** 2 - c ** 2) / (2 * a * b)) def checkio(a, b, c): try: angles = [get_angle_from_sides(*abc) for abc in ((a, b, c), (b, c, a), (c, a, b))] result = sorted((math.degrees(a)) for a in angles) return [0, 0, 0] if 0 in result else result except ValueError: return [0, 0, 0] count = 0 if y == x: pass elif y/2 <=x: if a>=2*(b-h): m = checkio(a,2*(b-h),math.sqrt(a**2+(2*(b-h))**2)) count = m[0] elif a<2*(b-h): m = checkio(a,2*(b-h),math.sqrt(a**2+(2*(b-h))**2)) count = m[1] elif y/2>x: z = 2*x/(a*b) if b>=z: m = checkio(b,z,math.sqrt(b**2+(z)**2)) count = m[1] elif b<z: m = checkio(b,z,math.sqrt(b**2+(z)**2)) count = m[0] #print(a,2*(b-h),math.sqrt(a**2+2*(b-h)**2),m) print(count)
str = input() while int(str[0]): sum = 0 for char in str: sum += int(char) print(sum) str = input()
def iroha(): letter = input() vols = ["a", "i", "u", "e", "o"] for elm in vols: if elm == letter: print("vowel") return print("consonant") if __name__ == "__main__": iroha()
def input_int(): return(int(input())) def input_int_list(): return(list(map(int,input().split()))) def input_int_map(): return(map(int,input().split())) def run(): S = list(input()) S = S[:len(S) - 1] for target_len in range(len(S) - 1, 1, -1): if target_len % 2 == 0: mid = target_len // 2 first = S[:mid] second = S[mid:mid + mid] if first == second: print(target_len) return run()
a = int(input()) if a >= 30 : print("Yes") else:print("No")
dic = {} N = int(input()) pre = input() dic[pre] = 0 flag = True for i in range(N-1): s = input() if list(pre)[len(pre)-1]!=list(s)[0]: flag=False if s in dic: flag=False else: dic[s]=0 pre = s print("Yes" if flag else "No")
MAX_ARRAY_SIZE = 100000 class Queue: array = [None] * MAX_ARRAY_SIZE start = end = 0 def enqueue(self, a): assert not self.isFull(), "オーバーフローが発生しました。" self.array[self.end] = a if self.end + 1 == MAX_ARRAY_SIZE: self.end = 0 else: self.end += 1 def dequeue(self): assert not self.isEmpty(), "アンダーフローが発生しました。" if (self.start + 1) == MAX_ARRAY_SIZE: self.start = 0 return self.array[MAX_ARRAY_SIZE - 1] else: self.start += 1 return self.array[self.start - 1] def isEmpty(self): return self.start == self.end def isFull(self): return self.start == (self.end + 1) % MAX_ARRAY_SIZE n, q = list(map(lambda x: int(x), input().strip().split())) queue = Queue() for i in range(n): queue.enqueue(input().strip().split()) sum_time = 0 while not queue.isEmpty(): name, time = queue.dequeue() if int(time) <= q: sum_time += int(time) print(name + ' ' + str(sum_time)) else: queue.enqueue([name, str(int(time) - q)]) sum_time += q
A = input() A = A[::-1] divide = [i[::-1] for i in ["dream", "dreamer", "erase", "eraser"]] flag = 1 while flag and A: flag = 0 for word in divide: if A.startswith(word): A = A[len(word):] flag = 1 if len(A) == 0: print('YES') else: print('NO')
x, y = map(int, input().split()) a = [1, 3, 5, 7, 8, 10, 12] b = [4, 6, 9, 11] if (x == 2 or y == 2) or (x in a and y not in a) or (x in b and y not in b): print('No') else: print('Yes')
import math def resolve(): k = int(input()) ans = 0 for a in range(1,k+1): for b in range(1, k+1): for c in range(1, k+1): ans += math.gcd(math.gcd(a,b),c) print(ans) resolve()
X, Y = [int(i) for i in input().split()] fare = X + (Y // 2) print(fare)
import itertools n = int(input()) list_3_5_7 = ["3", "5", "7"] res = 0 for i in range(3, 10): tmp_product_list = list(itertools.product(list_3_5_7, repeat = i)) for tmp_list in tmp_product_list: tmp_str = "".join(tmp_list) if len(set(tmp_str)) == 3 and int(tmp_str) <= n: res += 1 print(res)
s=input() s=sorted(s) if s[0]=='a' and s[1]=='b' and s[2]=='c': print('Yes') else: print('No')
n = int(input()) w = input() double_set = set() double_set.add(w) finish_str = w[-1] for i in range(1, n): w = input() if w not in double_set and w[0] == finish_str: double_set.add(w) finish_str = w[-1] else: print("No") break else: print("Yes")
def replace(str): for i, c in enumerate(command[3], command[1]): str[i] = c return str def reverse(str): for i, c in enumerate(reversed(str[command[1]: command[2]+1]), command[1]): str[i] = c return str def str_print(str): str = ''.join(str) print(str[command[1]: command[2]+1]) str = list(str) return str str = list(input()) q = int(input()) for i in range(q): command = input().split() command[1], command[2] = int(command[1]), int(command[2]) if command[0] == 'replace': str = replace(str) elif command[0] == 'reverse': str = reverse(str) else: str = str_print(str)