text
stringlengths
37
1.41M
input() A = list(input()) B = list(input()) C = list(input()) ans = 0 for a, b, c in zip(A, B, C): if a == b == c: ans += 0 elif a == b or b == c or c == a: ans += 1 else: ans += 2 print(ans)
(a,b,c) = map(int,raw_input().split()) if a < b and b < c : print "Yes" else : print "No"
def euclid(a, b): if b == 0: return a else: return euclid(b, a%b) def multiple(a, b): return a*b // euclid(a, b) N = int(input()) print(multiple(N,2))
n = list(str(i) for i in input()) print(sum(1 for i in n if i=='2'))
def actual(s): N = len(s) count_operation = 0 for i in range(N): head = s[i] tail = s[N - 1 - i] if head != tail: count_operation += 1 return int(count_operation / 2) s = input() print(actual(s))
N = int(input()) for i in range(N,N*2+1,N): if i % 2 == 0 and i % N == 0: print(i) break
x = list(map(int,input().split())) y = sorted(x) if y[0]+y[1]==y[2]: print("Yes") else: print("No")
a = [1,3,5,7,8,10,12] b = [4,6,9,11] c = [2] x,y=map(int,input().split()) if x in a and y in a: print("Yes") elif x in b and y in b: print("Yes") else: print("No")
lin = input() l = lin.split(" ") a = int(l[0]) b = int(l[1]) c = int(l[2]) if a < b < c: print('Yes') else: print('No')
S = str(input()) if (S[0]==S[1] and S[2]==S[3]) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]): if S[0]==S[1] and S[1]==S[2] and S[2]==S[3]: print("No") else: print("Yes") else: print("No")
l = list(input()) l=set(l) if len(l)==4: print('Yes') elif len(l)==2 and 'N' in l and 'S' in l: print('Yes') elif len(l)==2 and 'E' in l and 'W' in l: print('Yes') else: print('No')
N = int(input()) if N ==1: print("Hello World") else: A = int(input()) B = int(input()) ans =A+B print(ans)
def fib(n): global F if n not in F: F[n] = fib(n-1)+fib(n-2) return F[n] F = {0:1,1:1} print(fib(int(input())))
s=input().split() a=int(s[0]) b=int(s[1]) c=int(s[2]) num=[a,b,c] num.sort() print(str(num[0])+" "+str(num[1])+" "+str(num[2]))
if __name__ == '__main__': H = int(input()) cnt = 0 while H!=1: H //= 2 cnt += 1 ans = 0 for c in range(cnt+1): ans += pow(2, c) print(ans)
a = int(input()) a2 = pow(a, 2) a3 = pow(a, 3) print(a + a2 + a3)
from math import gcd K = int(input()) sum = 0 for i in range(1,K+1): for j in range(1,K+1): A = gcd(i,j) for k in range(1,K+1): sum += gcd(A,k) print(sum)
for i in range(int(raw_input())): sides = map(int, raw_input().split()) if sides[0]**2 == sides[1]**2 + sides[2]**2 or\ sides[1]**2 == sides[2]**2 + sides[0]**2 or\ sides[2]**2 == sides[0]**2 + sides[1]**2: print "YES" else: print "NO"
a,b,h = [int(input()) for _ in range(3)] print(round(((a + b)*h)/2))
def factorial(a,n): # n*(n-1)*,,,,,*(n-a+1) ans=1 for i in range(n,n-a,-1): ans=(ans*i)%M return ans def pow(x, n): ans=1 while n: if n % 2 == 1: ans = (ans*x)%M x = (x*x)%M n >>= 1 return ans def main(): ans=pow(2,N) - 1 ans-=(factorial(A,N)*pow(factorial(A,A),M-2))%M ans+...
r = int(input()) standard_area = 1 ans_area = r ** 2 ans = ans_area // standard_area print(ans)
a=input() if a[0]!=a[1] and a[1]!=a[2] and a[2]!=a[0]: print("Yes") else: print("No")
nums = input() num1 = int(nums.split()[0]) num2 = int(nums.split()[1]) print(num1 * num2)
S = input() ans = 0 if S == "RSS" or S == "RSR" or S == "SRS" or S == "SSR": ans = 1 if S == "RRS" or S == "SRR": ans = 2 if S == "RRR": ans = 3 print(ans)
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() sys.setrecursionlimit(10**6) class UnionFind(): """ https://note.nkmk.me/python-union-find/ DFSの上位互換と考えて良い 2要素x, yがpath-connectedかどうかをlogオーダーで判定する(螺旋本の14.1節参照) さらに連結成分の要素数がO(1)で取得可能なように改造してある """ de...
n = 10 ** 2 for i in range(int(input())) : n = float(n) * 1.05 if n - int(n) > 0 : n = int(n) + 1 else : n = int(n) print(n * (10 ** 3))
L = raw_input().split() a = int(L[0]) b = int(L[1]) d = int(0) r = int(0) f = float(0) d = a / b r = a % b f = float(a) / float(b) print "{0} {1} {2:f}".format(d,r,f)
#A S=input() T=input() ans='No' if S != T: if S==T[:(len(S))]: if T[-1].islower(): ans='Yes' print(ans)
def rotate(dice,d): if d == "N": temp = dice[0] dice[0] = dice[1] dice[1] = dice[5] dice[5] = dice[4] dice[4] = temp elif d == "E": temp = dice[0] dice[0] = dice[3] dice[3] = dice[5] dice[5] = dice[2] dice[2] = temp elif d == "W...
#!/usr/bin/env python3 H, W = map(int, input().split()) M = [list(input()) for _ in range(H)] # yoko for i in range(H): for j in range(W-1): if (M[i][j] == '#' or M[i][j] == 'M') and (M[i][j+1] == '#' or M[i][j+1] == 'M'): M[i][j] = 'M' M[i][j+1] = 'M' #tate for j in range(W): ...
a = input() N = int(a) if N == 10**5: print(90909) elif N >= 10**4: print(N-(9000+90)) elif N >= 10**3: print(909) elif N >= 10**2: print(N-90) elif N >= 10: print(9) else: print(N)
if __name__ == '__main__': # ??????????????\??? num = int(input()) triangles = [] for i in range(num): triangles.append([int(x) for x in input().split(' ')]) # ??´?§?????§???¢????????????????????? results = [] for t in triangles: t.sort() if t[0]**2 + t[1]**2 == t[2]...
n = int(input()) if n%2==1: print(0) else: ans = 0 div = 10 pt = 1 while div<=n: ans += n//div div *=5 print(ans)
X,Y = (int(X,16) for X in input().split()) print((X<Y)*'<'+(X==Y)*'='+(X>Y)*'>')
N = int(input()) res = '' while True: amari = N % 26 if amari == 0: amari = 26 res += chr(96 + amari) N -= amari if N == 0: break N //= 26 print(res[::-1])
import math x = int(input().replace(' ','')) y = int(math.sqrt(x)) if y * y == x: print("Yes") else: print("No")
X = input() X = int(X) if X < -40 or X > 40: print("invalid number 'X'") elif X >= 30: print("Yes") else: print("No")
#!/usr/bin/env python3 #import import math #import numpy as np #= int(input()) #= input() a, b, x= map(int, input().split()) #= list(map(int, input().split())) #= [input(), input()] #= [list(map(int, input().split())) for _ in range(N)] #= [int(input()) for _ in range(N)] #= {i:[] for i in range(N)} d = a * a * b # ...
a=int(input()) if a%10==9 or a>=90: print("Yes") else: print("No")
n=int(input()) def isprime(n): if n==1:return False for i in range(2,int(n**0.5)+1): if n%i==0:return False return True while 1: if isprime(n): print(n) exit() else: n+=1
X,A,B = list(map(int,input().split())) if B <= A: print("delicious") elif B-A <= X: print("safe") else: print("dangerous")
print("".join([x.upper() if x.islower() else x.lower() for x in raw_input()]))
#! /usr/bin/env python # -*- coding: utf-8 -*- def main(): #print ("x???%d??§???" % x) for left in range(1, 10): for right in range(1, 10): print("{0}x{1}={2}".format(left, right, left * right)) if __name__ == '__main__': main()
data = input().split() for n in range(len(data)): data[n] = int(data[n]) W, H, x, y, r = data if (r <= x <= W - r) and (r <= y <= H - r): print("Yes") else: print("No")
data=list(map(int,input().split())) if data[0]/data[1]<=data[2]: print('Yes') else: print('No')
# Grading end = 0 while end == 0: test = [int(i) for i in input().rstrip().split()] midterm = test[0] final = test[1] makeup = test[2] if midterm == -1 and final == -1 and makeup == -1: end += 1 elif midterm == -1 or final == -1: print('F') else: if midterm + final >...
n = int(input()) for i in range(1,10): if n // i == n/i and n//i in range(1,10): print('Yes') break else: print('No')
a, b, c = map(int, input().split()) r = 'No' if c >= a and c <= b: r = 'Yes' print(r)
import sys def print_arr(arr): for i in range(len(arr)): sys.stdout.write(str(arr[i])) if i != len(arr) - 1: sys.stdout.write(' ') print() def insertion_sort(arr, n, g): cnt = 0 for i in range(g, n): v = arr[i] j = i - g while j >= 0 and arr[j] > v: arr[j + g] = arr[j] j = j - g cnt += 1 a...
s=list(input().split()) if int(s[0])<int(s[2])<int(s[1]): c='Yes' elif int(s[1])<int(s[2])<int(s[0]): c='Yes' else: c='No' print(c)
a, b = map(int,input().split()) num = int(str(a) + str(b)) if (num**(1/2)).is_integer(): print('Yes') else: print('No')
import sys def input(): return sys.stdin.readline().strip() def resolve(): s=input() num=0 for i in s: #'C'がまだ見つかっていない状態:num=0 #'C'が見つかって'F'がまだ見つかっていない状態:num=1 #'C'が見つかってから'F'が見つかった状態:num=2 #num==0のときに'C'が見つかったらnumを1にする #num==1のときに'F'が見つかったらnumを2にする if i=='C'...
x,a,b=map(int,input().split()) plan1=x*a plan2=b if plan1<plan2: print(plan1) elif plan1==plan2: print(plan1) else: print(plan2)
#ABC-112-A N = int(input()) if N == 1: print("Hello World") else: ans = 0 for _ in range(2): AB = int(input()) ans += AB print(ans)
array1 = [1,3,5,7,8,10,12] array2 = [4,6,9,11] array3 = [2] x,y = map(int,input().split()) if (x in array1 and y in array1) or (x in array2 and y in array2) or (x in array3 and y in array3): print("Yes") else: print("No")
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp #?????\????????????????£? #?¨?????????????????????????????????±????????? def insertion_sort(target_list, n_list): for focus_index in range(1, n_list): print(*target_list) target = target_list[focus_index] if tar...
num1,num2 = map(int,input().split(" ")) men = num1*num2 leng = (num1+num2)*2 print(men,leng)
r = float(input()) s = r * r * 3.14159265358979 l = 2 * r * 3.14159265358979 print(s, end = " ") print(l)
a = input() b = input() a = a.zfill(101) b = b.zfill(101) if a<b: print('LESS') elif a>b: print('GREATER') else: print('EQUAL')
def func(S): if S[-1] == "s": return S+"es" else: return S+"s" if __name__ == "__main__": S = input() print(func(S))
N = int(input()) M = N X = 0 while M: X += M % 10 M //= 10 if N % X == 0: print("Yes") else: print("No")
print('Yes' if '9' in list(input()) else 'No')
h={} for _ in range(input()): a,b=raw_input().split() if a[0]=="f": print "yes" if b in h else "no" else: h[b]=1
# -*- coding: utf-8 -*- class dice_class: def __init__(self, list): self.num = list def sut(self, top): #set_up_top while True: if self.num[0] == top: break else: self.roll('E') if self.num[0] == top: break ...
s = input() t = input() ans = 'No' if t==s: ans = "Yes" for i in range(len(s)): s = "".join([s[-1],s[:len(s)-1]]) if t==s: ans = "Yes" print(ans)
n = int(input()) def is_prime(n): for i in range(2, int(n ** 0.5) + 1): if n % i == 0: return False return True num = 11 tmp = 0 while 1: if is_prime(num): print(num, end = " ") tmp += 1 num += 10 if n == tmp: exit()
from collections import namedtuple Task = namedtuple('Task', 'name time') class Queue: def __init__(self, n): self.n = n self._l = [None for _ in range(self.n + 1)] self._head = 0 self._tail = 0 def enqueue(self, x): self._l[self._tail] = x self._tail += 1 ...
S = list(input()) f = False c = 0 for i in range(len(S) - 1): # if i == len(S) - 2: # break if S[i] != S[i + 1]: continue else: if S[i] == "0": S[i+1] = "1" c += 1 else: S[i+1] = "0" c += 1 print(c)
# -*- coding: utf-8 -*- s = input() c = s.find('C') f = s.rfind('F') print('Yes' if c != -1 and f != -1 and c < f else 'No')
x = int(input()) y = x **3 print(y, end = "\n")
G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])] def check(x, y): for g in G: if x in g and y in g: return True return False x, y = map(int, input().split()) print("Yes" if check(x, y) else "No")
def resolve(): matrix = [] for i in range(3): line = input() matrix.append(line) ans = "" for i in range(3): ans += matrix[i][i] print(ans) resolve()
a=input() if ('a' in a) and ('b' in a) and ('c' in a): print("Yes") else: print("No")
a,b= list(map(int,input().split())) if a==0 or b==0: print("Zero") elif a>0 and b>0: print("Positive") elif a<0 and b>0: print("Zero") else: c = abs(b-a) if c%2 == 0: print("Negative") else: print("Positive")
while(1): H,W=map(int,input().split()); if H==0 and W==0 : break else: print(('#'*W+'\n')*H)
while 1: a,b,c = list(map(str,input().split())) num_a=int(a) num_c=int(c) if b=="+": print(num_a+num_c) elif b=="-": print(num_a-num_c) elif b=="*": print(num_a*num_c) elif b=="/": print(num_a//num_c) elif b=="?": break
N=int(input()) if N==1: print("Hello World") else: A,B=(input().split() for i in range(2));print(int(A[0])+int(B[0]))
n = int(input()) ret = '' for i in range(1,n+1): str = repr(i) if (i % 3 == 0): ret += ' ' + repr(i) elif ('3' in str): ret += ' ' + repr(i) print(ret)
N = int(input()) def digitSum(n): s = str(n) array = list(map(int, s)) return sum(array) if digitSum(N) % 9 == 0: print("Yes") else: print("No")
z = input() a= z.split() if int(a[0]) < int(a[1]) < int(a[2]): print('Yes') else: print('No')
a,b=map(int,input().split()) if a>=10 or b>=10: print(str(-1)+"\n") else: print(str(a*b)+"\n")
def main(N): ans = 0 for n in str(N): ans += int(n) if ans%9==0: return 'Yes' else: return 'No' if __name__ == '__main__': N = int(input()) ans = main(N) print(ans)
N = int(input()) S = sum(i for i in range(1, N + 1) if not (i % 3 == 0 or i % 5 == 0)) print(S)
s = input() ans = "" for _ in range(len(s)): if s[0] == "0": ans += "0" s = s[1:] elif s[0] == "1": ans += "1" s = s[1:] else: s = s[1:] ans = ans[:-1] print(ans)
n = int(input()) a_ = 2 a = 1 for i in range(n-1): a, a_ = a + a_, a print(a)
S = {} for i in 'ABC': S[i] = [w for w in input()] ans = '' judge = True turn = S['A'].pop(0).upper() while judge: if S[turn] == []: ans = turn judge = False else: turn = S[turn].pop(0).upper() print(ans)
def check(A,B,C): if A==0 or B==0 or C==0: return False if A%2!=0 or B%2!=0 or C%2!=0: return False return True A,B,C=map(int,input().split()) ans=0 if A%2==B%2==C%2==0 and A==B==C: print(-1) exit() while check(A,B,C)==True: a=B//2+C//2 b=A//2+C//2 c=A//2+B//2 A,B,C=a,b,c ans+=1 if 10**9<...
N = int(input()) if N == 1: print(1) elif N%2 == 0: print(0.5) else: print((N+1)/2/N)
import math def prime(num): array=[] tmp=int(math.sqrt(n))+1 for i in range(2,tmp): while num % i == 0: num/=i array.append(i) # リストが空なら入力(num)は素数 if array==[]: return [num] else: if num>1: array.append(int(num)) return array n=int(input()) P=prime(n) P=sorted(P) num=n if 1 in P: print(0) el...
import sys import os def file_input(): f = open('CODE_FESTIVAL_2017Final/input.txt', 'r') sys.stdin = f def main(): #file_input() S=input() a=b=c=0 for s in S: if s=='a': a+=1 elif s=='b': b+=1 else: c+=1 if max(a,b,c)-min(a,b,...
STABLE = 'Stable' UNSTABLE = 'Not stable' def main(): card_num = int(input()) cards = input().split() bubble_sorted = bubble_sort(cards, card_num) select_sorted = select_sort(cards, card_num) stability = True for i, c in enumerate(select_sorted): if c != bubble_sorted[i]: stability = False ...
import math N=int(input()) x=math.ceil(N/1.08) if math.floor(x*1.08) == N: print(x) else: print(":(")
n = int(input()) alphabet = list("abcdefghij"[:n]) # DFS def print_string(string="", depth=1): if len(string) == n: print(string) else: for i in range(depth): if i+1 == depth: print_string(string+alphabet[i], depth=depth+1) else: print_str...
from copy import deepcopy def bubble_sort(lst): size=len(lst) for i in xrange(size): for j in reversed(range(i+1,size)): if lst[j].num<lst[j-1].num: tmp=lst[j] lst[j]=lst[j-1] lst[j-1]=tmp def selection_sort(lst): size=len(lst) for i i...
def main(): s = input() t = input() lis = [] for i in range(len(s)-len(t)+1): f=True for j in range(len(t)): if(s[i+j]==t[j] or s[i+j]=="?"): continue else: f=False break if(f): tmp = s[0:i]+t+s[i...
def main(): n = int(input()) if n%2==1: print(0) else: ans = 0 waru = 10 while n>=waru: ans += n//waru waru = waru*5 print(ans) if __name__ == "__main__": main()
# coding:utf-8 # Doubly Linked List from collections import deque def main(): n = int(input()) dll = deque() for _ in range(n): operation = input().split(' ') if operation[0] in ["insert", "delete"]: key = operation[1] if operation[0] == "insert": ...
a,b=map(int,input().split()) f=a%3==0 or b%3==0 or (a+b)%3==0 print("Possible" if f==True else "Impossible")
N = input() S = list(map(str,input().split())) if "P" in S and "W" in S and "G" in S and "Y" in S : print("Four") else : print("Three")
k = int(input()) sum = 0 def gcd(a, b): if b == 0: return a return gcd(b, a % b) for a in range(1, k + 1): for b in range(1, k + 1): ab_gcd = gcd(a, b) for c in range(1, k + 1): abc_gcd = gcd(c, ab_gcd) sum += abc_gcd print(sum)