text
stringlengths 37
1.41M
|
---|
text = "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51"
tx = text.split(",")
index = int(input())
print(tx[index-1]) |
class dice:
def __init__(self,label):
self.top,self.front,self.right,self.left,self.rear,self.bottom\
= label
def roll(self, order):
if order== "N":
self.top, self.front, self.bottom, self.rear \
= self.front, self.bottom, self.rear, self.top
elif order=="E":
self.top, self.left, self.bottom, self.right\
= self.left, self.bottom, self.right, self.top
elif order=="W":
self.top, self.right, self.bottom, self.left\
= self.right, self.bottom, self.left, self.top
elif order=="S":
self.top, self.rear, self.bottom, self.front\
= self.rear,self.bottom,self.front,self.top
def print_top(self): print(self.top)
label = list(input().split())
order_list = list(input())
d = dice(label)
for order in order_list:
d.roll(order)
d.print_top() |
s=input()
if len(s)%2!=0:
print("No")
exit()
for i,c in enumerate(s):
if (i%2==0 and c=="h") or (i%2==1 and c=="i"):
continue
else:
print("No")
exit()
print("Yes") |
while True:
h, w = map(int,input().split())
if h == 0 and w ==0:
break
else:
print('#'*w)
h2 = h-2
w2 = w-2
for i in range(0, h2):
print('#' + '.'*w2 + '#')
print('#'*w)
print('') |
def main():
for a in range(1,10):
for b in range(1,10):
print("{}x{}={}".format(a,b,a*b))
return None
if __name__ == '__main__':
main() |
s = input()
result = ''
for i in range(0, len(s)):
if(s[i] == '0'):
result = result + '0'
elif(s[i] == '1'):
result = result + '1'
elif(s[i] == 'B'):
if(len(result) > 0):
result = result[ 0 : len(result)-1 ]
print(result) |
n_num = int(input())
plan_list = [[0, (0, 0)]]
def movable(p1, p2):
time = p2[0] - p1[0]
distance = 0
distance += abs(p1[1][0] - p2[1][0])
distance += abs(p1[1][1] - p2[1][1])
if distance > time:
return 0
else:
if (time - distance) % 2 != 0:
return 0
else:
return 1
for _ in range(n_num):
line = [int(i) for i in input().split()]
plan_list.append([line[0], (line[1], line[2])])
vector = (0, 0)
flag = 0
for n in range(1, n_num+1):
if movable(plan_list[n-1], plan_list[n]) == 0:
flag = 1
if flag == 1:
print('No')
else:
print('Yes') |
# B - 3人でカードゲームイージー
def main():
sa = list(input())
sb = list(input())
sc = list(input())
t = sa.pop(0)
for _ in range(301):
if t == 'a':
if len(sa) == 0:
print('A')
break
t = sa.pop(0)
elif t == 'b':
if len(sb) == 0:
print('B')
break
t = sb.pop(0)
elif t == 'c':
if len(sc) == 0:
print('C')
break
t = sc.pop(0)
if __name__ == "__main__":
main() |
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 3 14:11:35 2020
@author: NEC-PCuser
"""
def gcd(a, b):
if (a % b == 0):
return b
return gcd(b, a % b)
def factorize(num):
i = 2
factorize_list = []
num_tmp = num
while i * i <= num_tmp:
count = 0
if num % i == 0:
while num % i == 0:
count += 1
num //= i
factorize_list.append([i, count])
i += 1
if num != 1:
factorize_list.append([num, 1])
return factorize_list
if __name__ == "__main__":
A, B = map(int, input().split())
big_num = max(A, B)
short_num = min(A, B)
gcd_num = gcd(big_num, short_num)
print(len(factorize(gcd_num)) + 1)
|
A=list(map(int,input().split()))
if A[0]==A[1] and not A[0]==A[2]:
print(2)
elif not A[0]==A[1] and not A[1]==A[2] and not A[0]==A[2]:
print(3)
elif A[0]==A[2] and not A[0]==A[1]:
print(2)
elif A[1]==A[2] and not A[1]==A[0]:
print(2)
else:
print(1)
|
r = float(input())
p = 3.141592653589
print('%.6f %.6f'%(r*r*p, 2*r*p))
|
score = {"taro":0, "hanako":0}
n = int(input())
for i in range(n):
words = input().split()
if words[0] > words[1]:
score["taro"] += 3
elif words[0] < words[1]:
score["hanako"] += 3
else:
score["taro"] += 1
score["hanako"] += 1
print(score["taro"], score["hanako"]) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
for x in range(1, 10):
for y in range(1, 10):
s = '%dx%d=%d' % (x, y, x*y)
print(s) |
n = int(input())
if n == 1:
print(1)
else:
x = [2, 1]
for i in range(2, n+1):
x.append(x[i-2] + x[i-1])
print(x[n]) |
s = input()
s = s.replace('BC','D')
A_count = 0
ans = 0
for i in s:
if i == 'A':
A_count += 1
elif i == 'B' or i == 'C':
A_count = 0
else:
ans += A_count
print(ans) |
list = []
while True:
line = raw_input().split(" ")
if line[0] == "0" and line[1] == "0":
break
line = map(int, line)
#print line
if line[0] > line[1]:
temp = line[0]
line[0] = line[1]
line[1] = temp
print " ".join(map(str, line)) |
#サンプルが罠ってパターンもあるんだぜ
def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError("n is int-type.")
if n < 2:
raise ValueError("n is more than 2")
data = [i for i in range(2, n + 1)]
for d in data:
data = [x for x in data if (x == d or x % d != 0)]
return data
N = int(input())
primes = get_sieve_of_eratosthenes(5000)
ans=[]
inde=0
while len(ans)<N:
if primes[inde]%5 == 1:
ans.append(primes[inde])
inde+=1
print(" ".join(list(map(str,ans))))
|
n = int(input())
listA = list(input())
listB = list(input())
listC = list(input())
counter=0
index=0
while index < n:
if listA[index] == listB[index] and listB[index] == listC[index]:
pass
elif listA[index] != listB[index] and listB[index] != listC[index] and listC[index]!=listA[index]:
counter+=2
else:
counter+=1
index+=1
print(counter) |
def solve(n):
ans = 0
for i in range(1, n+1):
if (i % 3 == 0 and i % 5 == 0) or (i % 3 == 0) or (i % 5 == 0):
continue
else:
ans += i
print(ans)
if __name__ == "__main__":
n = int(input())
solve(n) |
x=list(input())
for i in range(10):
if x.count(str(i))>=3 and x[1]==x[2]:
print("Yes")
break
else:
print("No")
|
def dfs(A):
x ="".join(A)
if 3 <=len(A) :
if int(x) <=N :
if x.count("3") >=1 and x.count("5") >=1 and x.count("7") >=1:
c.append(int(x))
if len(x) ==len(str(N)): #終了条件
return
for i in ["3","5","7"] :
A.append(i)
dfs(A)
A.pop()
N = int(input())
c =[]
a =dfs([])
print(len(c)) |
n=int(input())
l=list(input())
m=int(input())
for i in range(len(l)):
if l[i]!=l[m-1]:
l[i]="*"
print("".join(l)) |
a,b,x=list(map(int,input().split()))
import math
x=x/a
if a*b/2<x:
print(math.degrees(math.atan(2*(a*b-x)/a**2)))
else:
print(math.degrees(math.atan(b**2/(2*x)))) |
from sys import stdin
a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())
if a > b:
print("GREATER")
elif a == b:
print("EQUAL")
else:
print("LESS") |
s=input()
res=""
for t in s:
if t.islower()==True:
res+=t.upper()
else:
res+=t.lower()
print(res)
|
n = map(int, raw_input().split())
if (n[0] < n[1] and n[1] < n[2]):
print "Yes"
else:
print "No" |
N = int(input())
S = input()
if N % 2 > 0 or S != S[:int(N/2)] + S[:int(N/2)]:
print("No")
else:
print("Yes")
|
a = int(input())
for i in range(1,a+1):
x = i
if i % 3 == 0 or i % 10 == 3:
print(" {}".format(i), end = "")
else:
while int(x) > 0:
x /= 10
if int(x) % 10 == 3:
print(" {}".format(i), end = "")
break
print()
|
while True:
a = list(map(int, input().split()))
if a[0] == 0 and a[1] == 0:
break
a.sort()
print("{} {}".format(a[0], a[1])) |
from sys import stdin
a, b = [int(x) for x in stdin.readline().rstrip().split()]
if a < b:
op = "<"
elif a > b:
op = ">"
else:
op = "=="
print("a", op, "b")
|
def bubblesort(n, a):
r = a[:]
for i in range(n):
for j in range(n-1, i, -1):
if int(r[j][1]) < int(r[j-1][1]):
r[j], r[j-1] = r[j-1], r[j]
print(*r)
print("Stable")
def selectionsort(n, a):
r = a[:]
ret = "Stable"
for i in range(n):
tmp = i
for j in range(i, n):
if int(r[j][1]) < int(r[tmp][1]):
tmp = j
r[i], r[tmp] = r[tmp], r[i]
for i in range(n):
for j in range(i+1, n):
for k in range(n):
for l in range(k+1, n):
if int(a[i][1]) == int(a[j][1]) and a[i] == r[l] and a[j] == r[k]:
ret = "Not stable"
print(*r)
print(ret)
def main():
n = int(input())
a = list(input().split())
bubblesort(n, a)
selectionsort(n, a)
if __name__ == '__main__':
main()
|
import math
a, b = input().split()
ab = int(a + b)
result = math.sqrt(ab)
value = result % 1
if result * result == ab and value == 0:
print('Yes')
else:
print('No') |
dic = {}
dic.setdefault('a',str(input())+'A')
dic.setdefault('b',str(input())+'B')
dic.setdefault('c',str(input())+'C')
dare = dic['a'][0]
dic['a'] = dic['a'][1:]
while len(dic['a'])>0 and len(dic['b'])>0 and len(dic['c'])>0:
tmp = dic[dare][0]
dic[dare] = dic[dare][1:]
dare = tmp
print(dare)
|
s = input().split(',')
for a in s:
print(a, end=' ')
|
def solve():
gx,gy = False, False
if W/2 == x:
gx = True
if H/2 == y:
gy = True
ans = W*H/2
# print(gx,gy)
if gx and gy:
print(ans, 1)
else:
print(ans, 0)
if __name__ == "__main__":
W,H,x,y = list(map(float, input().split()))
solve()
|
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
1 2
/2 = 1.5
1 2 3 4
/4 = 2.5
1 2 3 4 5
/5 = 3
"""
N, K = read_ints()
expectations = [(p+1)/2 for p in read_ints()]
max_e = current = sum(expectations[:K])
for i in range(1, N-K+1):
# remove i-1 add i+K
current = current-expectations[i-1]+expectations[i+K-1]
max_e = max(max_e, current)
return max_e
if __name__ == '__main__':
print(solve())
|
# 素数生成器
def generate_primes():
from collections import defaultdict
from itertools import count
D = defaultdict(list)
q = 2
for q in count(2):
if q in D:
for p in D[q]:
D[p+q].append(p)
del D[q]
else:
yield q
D[q*q].append(q)
N = int(input())
res = []
cnt = 0
for p in generate_primes():
if p % 5 == 1:
cnt += 1
res.append(p)
if cnt >= N:
break
print(*res) |
n = int(input())
dictionary = set()
for _ in range(n):
cmd, arg = input().split()
if cmd == "insert":
dictionary.add(arg)
elif cmd == "find":
if arg in dictionary:
print("yes")
else:
print("no") |
"""
まず、答えは必ずAの総和以下になる。なぜなら、A同士の差の最大値がAの総和だからである。
移動回数が足りるのであれば、一つだけAの総和になるような項を作って、他を全部0にするのがよい。
ここからわかるのは、数を移動させ終わった後の各Aは全て0以上になるということである。
また答えはからなずAの総和の約数になる。
理由:
答えをXとすると、各AはbXと表すことができる。
したがって、Aの総和=(bの総和*X)となる。
ゆえに、答えXはAの総和の約数である。
解法としては、Aの総和の約数を列挙して、大きい順に実現可能かどうかを試していく。
実現可能かどうかを試すには、各Aを総和の約数dで割ったときの余りをもとめて、小さい順にソートする。
そのうえで、左からL番目までを「数を与える側」、L+1番目以降を「数をもらう側」として余りが0になるように調整できないかを確かめる。
これは累積和を活用することですくない計算量で実行可能である。
最後に、移動した数がK以下かどうかを確認する。
"""
from itertools import accumulate
N,K = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)
yakusu = []
d = 1
while d*d < sumA:
if sumA%d == 0:
yakusu.append(d)
yakusu.append(sumA//d)
d += 1
if d*d == sumA:
yakusu.append(d)
yakusu.sort(reverse=True)
for d in yakusu:
#約数の大きい順に、実現可能かどうかを試していく。
rest = [a%d for a in A]
rest.sort()
rest = [a%d for a in A]
rest.sort()
Rrest = [d-r for r in rest]
Rrest = Rrest[::-1]
rest = [0]+list(accumulate(rest))
Rrest = [0]+list(accumulate(Rrest))
for i in range(N+1):
if rest[i] == Rrest[N-i]:
if rest[i] <= K:
print(d)
exit()
break |
import math
# s=int(input())
# b=input()
# c=[]
# for i in range(b):
# c.append(a[i])
a = list(map(int,input().split()))
#b = list(map(int,input().split()))
if a[0]+a[1]<a[2]+a[3]:
print("Right")
elif a[0]+a[1]==a[2]+a[3]:
print("Balanced")
elif a[0]+a[1]>a[2]+a[3]:
print("Left") |
x =[str(input()) for i in range(2)]
if x[0][0]==x[1][2] and x[0][1]==x[1][1] and x[0][2]==x[1][0]:
print("YES")
else:
print("NO") |
x=input()
y=x.split(" ")
a=int(y[0])
b=int(y[1])
c=int(y[2])
if(a<b and b<c):
str="Yes"
else:
str="No"
print(str) |
r = float(input())
#円の面積 = πr^2
#円周の長さ=直径*π=2πr
#print(c,d,"{:.5f}".format(e))
m = 3.141592653589 * r * r
l = 3.141592653589 * r * 2
print("{:.6f}".format(m),"{:.6f}".format(l))
|
a = int(input())
b = int(input())
d = {}
d[a] = True
d[b] = True
for i in range(1, 4):
if i not in d:
print(i) |
a, b = input().split()
ab = a*int(b)
ba = b*int(a)
if ab <= ba:
print(ab)
else:
print(ba) |
import math
a, b = map(int,input().split())
ab = int(str(a) + str(b))
if int(math.sqrt(ab))**2 == ab :
print('Yes')
else :
print('No') |
A=int(input())
B=int(input())
for i in range(3):
if i+1 !=A and i+1 != B:
print(i+1) |
A = input()
print('A') if A.isupper() else print('a') |
string = input()
s = []
total = 0
s2 = []
for i in range(len(string)):
if string[i] == '\\':
s.append(i)
elif string[i] == '/' and len(s) > 0:
j = s.pop() # j: 対応する '\' の位置
area = i - j # 面積
total += area
while len(s2) > 0 and s2[-1][0] > j: # s2[-1][0] == s2.pop()[0]
area += s2[-1][1]
s2.pop()
s2.append([j, area]) # j: 水たまりの左端 / tmp: その水たまりの面積
ans = []
for i in range(len(s2)):
ans.append(str(s2[i][1]))
print(total)
if len(ans) == 0:
print(len(ans))
else:
print(len(ans), end = ' ')
print(' '.join(ans))
|
class MyQueue(object):
"""
My Queue class
Attributes:
queue: queue
head
tail
"""
def __init__(self):
"""Constructor
"""
self.length = 100010
self.queue = []
counter = 0
while counter < self.length:
self.queue.append(Process())
counter += 1
self.head = 0
self.tail = 0
def enqueue(self, name, time):
"""enqueue method
Args:
name: enqueued process name
time: enqueued process time
Returns:
None
"""
if self.is_full():
print("[ERROR] Queue Overflow")
else:
self.queue[self.tail % self.length].name = name
self.queue[self.tail % self.length].time = time
self.tail += 1
def dequeue(self):
"""dequeue method
Returns:
None
"""
if self.is_empty():
print("[ERROR] Queue Underflow")
else:
self.queue[self.head % self.length].name = ""
self.queue[self.head % self.length].time = 0
self.head += 1
def is_empty(self):
"""check queue is empty or not
Returns:
Bool
"""
if self.head == self.tail:
return True
else:
return False
def is_full(self):
"""chech whether queue is full or not"""
if self.tail - self.head >= len(self.queue):
return True
else:
return False
class Process(object):
"""process class
"""
def __init__(self, name="", time=0):
"""constructor
Args:
name: name
time: time
"""
self.name = name
self.time = time
def forward_time(self, time):
"""time forward method
Args:
time: forward time interval
Returns:
remain time
"""
self.time -= time
return self.time
def time_forward(my_queue, interval, current_time):
"""
Args:
my_queue: queue
interval: time step interval
current_time: current time
"""
value = my_queue.queue[my_queue.head % my_queue.length].forward_time(interval)
if value < 0:
current_time += (interval + value)
print my_queue.queue[my_queue.head % my_queue.length].name, current_time
my_queue.dequeue()
return current_time
elif value == 0:
current_time += interval
print my_queue.queue[my_queue.head % my_queue.length].name, current_time
my_queue.dequeue()
return current_time
elif value > 0:
current_time += interval
copied_process = my_queue.queue[my_queue.head % my_queue.length]
name, time = copied_process.name, copied_process.time
my_queue.dequeue()
my_queue.enqueue(name, time)
return current_time
my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
name, time = raw_input().split()
my_queue.enqueue(name, int(time))
counter += 1
current_time = 0
while not my_queue.is_empty():
current_time = time_forward(my_queue, q, current_time) |
import collections
n = int(input())
def prime_factorize(n):
a = []
while n % 2 == 0:
a.append(2)
n //= 2
f = 3
while f * f <= n:
if n % f == 0:
a.append(f)
n //= f
else:
f += 2
if n != 1:
a.append(n)
return a
def make_divisors(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]
ns = make_divisors(n)
ans = 0
for i in ns:
if i == 1:
continue
p = n
while p % i == 0:
p //= i
if p % i == 1:
ans += 1
ns = make_divisors(n - 1)
ans += len(ns) - 1
print(ans)
|
integer1, integer2 = map(int, input().split())
if integer1 + integer2 >= 10:
print("error")
else:
print(integer1 + integer2) |
S = input()
T = input()
S_len = len(S)
s = S
for i in range(S_len):
s_list = list(s)
s_end = s_list.pop()
b = s_end + ''.join(s_list)
if b == T:
print('Yes')
exit(0)
s = b
print('No')
|
import sys
n = int(raw_input())
#n = 30
for i in range(1, n+1):
if i % 3 == 0:
sys.stdout.write(" {:}".format(i))
elif str(i).find('3') > -1:
sys.stdout.write(" {:}".format(i))
print("") |
def prime_list(num):
list = [0]*2 + [1]*(num - 1)
prime_list = []
for i in range(2,num + 1):
if list[i] == 1:
for j in range(2, num//i + 1):
list[i*j] = 0
for i in range(num + 1):
if list[i] == 1:
prime_list.append(i)
return prime_list
x = int(input())
prime = prime_list(100003)
while x not in prime:
x += 1
print(x) |
import math
n = float(input())
area = "%.6f" % float(n **2 * math.pi)
circ = "%.6f" % float(n * 2 * math.pi)
print(area, circ) |
x, a = input().split()
a = int(a)
x = int(x)
if x < a:
print(0)
else:
print(10) |
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)
return divisors
N = int(input())
count = 0
for i in range(1,N+1,2):
if len(make_divisors(i)) == 8:
count += 1
print(count)
|
num = list(map(int, input().split()))
sound = num[1] // num[0]
if sound > num[2]:
sound = num[2]
print(sound) |
def main():
a, b = map(int, input().split())
if a < 0 and b > 0:
print('Zero')
elif a > 0 and b > 0:
print('Positive')
elif a == 0 or b == 0:
print('Zero')
else:
if (abs(a) - abs(b) + 1) % 2 == 1:
print('Negative')
else:
print('Positive')
if __name__ == "__main__":
main()
|
# coding: utf-8
num = input().rstrip().split(" ")
ishow = int(num[0]) // int(num[1])
amari = int(num[0]) % int(num[1])
fshow = float(int(num[0])) / int(num[1])
print(str(ishow) + " " + str(amari) + " " + str("{0:.5f}".format(fshow))) |
a,b = map(int, input().split())
if 0 < a and 0 < b:
print('Positive')
elif a <= 0 <= b:
print('Zero')
else:
if (b-a+1)%2 == 1:
print('Negative')
else:
print('Positive') |
S = list(str(input()))
T = list(str(input()))
if S == T[:len(T)-1]:
print('Yes')
else:
print('No') |
from itertools import *
s = input()
n = len(s) - 1 # 隙間の数
plus_list = list(product(["+", ""], repeat=n))
ans = 0
for bit in range(1 << n):
formula = s[0]
for j, k in zip(plus_list[bit], s[1:]):
formula += (j + k)
ans += eval(formula)
print(ans)
|
a,b,c=input().split()
if a[-1]==b[0] and b[-1]==c[0]:print('YES')
else:print('NO') |
n = int(input())
print(0)
L = R = input()
if L == "Vacant":
exit()
l = 0
r = n
while True:
m = (l + r) // 2
print(m)
M = input()
if M == "Vacant":
exit()
if (M == L) ^ ((m - l) % 2 == 1):
l = m
L = M
else:
r = m
R = M
|
x = input()
ls_x = x.split()
# 文字配列を整数化
# for i in range(len(ls_x)):
# ls_x[i] = int(ls_x[i])
# 別の方法 lint_xという箱を作って,intしたものをappendしていく
lint_x = []
for i in ls_x:
lint_x.append(int(i))
lint_x = sorted(lint_x)
if (lint_x[0] + lint_x[1] == lint_x[2]):
print("Yes")
else:
print("No")
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
answer = 0
for coin1 in range(a+1):
for coin2 in range(b+1):
for coin3 in range(c+1):
if x == 500 * coin1 + 100 * coin2 + 50 * coin3:
answer += 1
print(answer) |
num_ate_food = int(input())
total_cost = num_ate_food * 800
cash_back = 0
if num_ate_food >= 15:
cash_back = (num_ate_food // 15) * 200
total_paid = total_cost - cash_back
print(total_paid) |
def bubble_sort(A):
count = 0
for i in reversed(range(len(A))):
for j in range(i):
if A[j] > A[j+1]:
temp = A[j]
A[j] = A[j+1]
A[j+1] = temp
count += 1
return count
N = int(input())
A = list(map(int,input().split()))
count = bubble_sort(A)
print(" ".join(map(str,A)))
print(count) |
a=int(input())
b=list(map(str,input().split()))
if len(set(b))==3:
print('Three')
else:
print('Four') |
def f(a):
if a%2==0:
return a//2
else:
return 3*a+1
s=int(input())
cnt=1
while s!=4 and s!=2 and s!=1:
cnt+=1
s=f(s)
print(cnt+3) |
list = input().split()
list.sort()
if ''.join(list) == '557':
print('YES')
else:
print('NO') |
S = list(input())
S.sort()
#print(S)
if S[0] == S[1]:
if S[2] == S[3]:
if S[0] != S[2]:
print("Yes")
else:
print("No")
else:
print("No")
else:
print("No")
|
arr = list(map(int, input().split()))
a = arr[0]
b = arr[1]
if 1 <= a <= 13 and 1 <= b <= 13:
if a == b:
print('Draw')
elif a == 1:
print('Alice')
elif b == 1:
print('Bob')
elif a > b:
print('Alice')
elif b > a:
print('Bob') |
lst = []
for i in range(int(input())):
S,P = input().split()
lst.append([S,int(P),i])
sorted_point = sorted(lst,key = lambda x: x[1], reverse = True)
sorted_name = sorted(sorted_point,key = lambda x: x[0], reverse = False)
for i in sorted_name:
print(i[2] + 1) |
x=int(input())
if x%2 == 0 or x == 9 or x ==1:
print("NO")
else:
print("YES") |
s,t = [input() for i in range(2)]
s_2 = sorted(s)
t_2 = sorted(t,reverse=True)
if s_2 < t_2:
print("Yes")
else:
print("No") |
s = input().replace('hi', '')
if not len(s):
print('Yes')
else:
print('No') |
from copy import deepcopy
n = int(input())
A = [int(input()) for i in range(n)]
A2 = deepcopy(A)
A2.sort()
for i in range(n):
#print (A[i], A2[-1])
if A[i] == A2[-1]:
print (A2[-2])
else:
print (A2[-1]) |
n=int(input())
m=n
wa=0
while m:
wa+=m%10
m//=10
if n%wa==0:print("Yes")
else:print("No") |
A="abcdefghijklmnopqrstuvwxyz"
S=input()
S=sorted(set(S))
for i in range(len(S)):
if S[i]!=A[i]:
print(A[i])
exit()
if len(S)<len(A):
print(A[len(S)])
exit()
print("None") |
dice = list(map(int, input().split()))
directions = input()
for direction in directions:
if direction == 'N':
dice = [dice[1], dice[5], dice[2], dice[3], dice[0], dice[4]]
elif direction == 'S':
dice = [dice[4], dice[0], dice[2], dice[3], dice[5], dice[1]]
elif direction == 'W':
dice = [dice[2], dice[1], dice[5], dice[0], dice[4], dice[3]]
else:
dice = [dice[3], dice[1], dice[0], dice[5], dice[4], dice[2]]
print(dice[0])
|
def sh(num):
for n in num:
out(n)
def out(n):
number = []
# print(n[0])
# print(n[1])
for i in range(n[1]):
number.append("#")
for i in range(1,n[0]+1):
if i in range(2,n[0]):
print('#' + '.' * (n[1]-2) + '#')
else:
print(''.join(number))
print('')
num = []
while True:
n = list(map(int, input().split()))
if n[0] == 0 and n[1] == 0:
break
else:
num.append(n)
sh(num) |
ch = input()
v = "aeiou"
if ch in v:
print("vowel")
else:
print("consonant") |
a, b, c = input().split()
LIST = [a, b, c]
five = LIST.count("5")
seven = LIST.count("7")
if five == 2 and seven == 1:
print("YES")
else:
print("NO") |
W = input().lower()
T = []
while True:
S = input()
if S == "END_OF_TEXT":
break
T.extend([words.lower() for words in S.split()])
print(T.count(W)) |
S=input()
S = S.replace("dream","w")
S = S.replace("erase","x")
S = S.replace("wer","y")
S = S.replace("xr","z")
if len(S) == S.count("w")+S.count("x")+S.count("y")+S.count("z"):
print("YES")
else:
print("NO")
|
S=input()
set1=set(S)
for i in range(97,123):
if chr(i) not in set1:
print(chr(i))
exit()
print('None') |
a, b = [int(i) for i in input("").split(" ")]
if a < 2*b:
print(0)
else:
print(a - 2*b) |
S = input()
if S[0] == "A" and S.count("A") == 1 and S.count("C") == 1:
p = S.find("C")
b = S.replace("A","").replace("C","")
if p > 1 and p < len(S) - 1 and b.islower():
print("AC")
else:
print("WA")
else:
print("WA")
|
user_input = list(map(int, input().split()))
# print(user_input)
# to find the index where zero is located
indexOfZero = [x for x in range(0, 5) if user_input[x] == 0]
print(indexOfZero[0] + 1) |
import math
x1,y1,x2,y2 = map(float, input().split())
a1 = (x2-x1)**2
a2 = (x1-x2)**2
b1 = (y2-y1)**2
b2 = (y1-y2)**2
if x1<x2:
if y1<y2:
print(math.sqrt(a1+b1))
else:
print(math.sqrt(a1+b2))
else:
if y1<y2:
print(math.sqrt(a2+b1))
else:
print(math.sqrt(a2+b2))
|
n = int(input())
a = [int(input()) for i in range(n)]
amax1 = max(a)
amax_i1 = a.index(amax1)
a.pop(amax_i1)
amax2 = max(a)
amax_i2 = a.index(amax2)
for i in range(n):
if i == amax_i1:
print(amax2)
else:
print(amax1) |
num = raw_input()
num = num.split()
result = True
w, h, x, y, r = int(num[0]), int(num[1]), int(num[2]), int(num[3]), int(num[4])
if x < r or (w - r) < x:
result = False
if y < r or (h - r) < y:
result = False
if result:
print "Yes"
else:
print "No" |
x,a,b =map(int,input().split())
if b-a<=0:
print("delicious")
elif (b-a)>0 and (b-a)<=x:
print("safe")
else:
print("dangerous") |
N=int(input())
if 10<=N and N<=99:
n=str(N)
if (int(n[0])==9 or int(n[1])==9) or (int(n[0])==9 and int(n[1])==9):
print('Yes')
else:
print('No') |
n = input().split()
print('YES' if ('1' in n) and ('9' in n) and ('7' in n) and ('4' in n) else 'NO')
|
import string
al = string.ascii_lowercase
S = set(input())
for i in al:
if i not in S:
print(i)
exit()
print("None") |
list01 = list(input())
list02 = list(set(list01))
if len(list02) == 3:
print('Yes')
else:
print('No') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.