text
stringlengths 37
1.41M
|
---|
x=int(input())
if x<=6:
print(1)
elif x<=11:
print(2)
elif x%11==0:
print(2*(x//11))
elif x%11<=6:
print(2*(x//11)+1)
else:
print(2*(x//11)+2) |
S = input()
K = len(S)
N = S.count("o")
if N + 15 - K >= 8:
print("YES")
else:
print("NO") |
N = int(input())
from math import sqrt, floor
for i in range(1,floor(sqrt(N))+2):
if i**2 > N:
print((i-1)**2) |
n = int(input())
def divGame(N=n):
if N == 1:
return 0
if N == 2:
return 1
factors = []
for i in range(2, int(N**0.5 + 1)):
count = 0
while N % i == 0:
N /= i
count += 1
if count != 0:
factors.append(count)
if N != 1:
factors.append(1)
factors.sort()
answer = 0
accum = 1
count = 1
for i in range(len(factors)):
while factors[i] >= accum:
count += 1
accum += count
answer += count - 1
return answer
print(divGame()) |
a = list(input())
b = list(input())
c = b
c.pop()
if(a == c):
print("Yes")
else:
print("No") |
from fractions import Fraction as frac
input()
a = list(map(int,input().split()))
sm = frac("1/" + str(a[0]))
for i in range(1,len(a)):
sm += frac("1/" + str(a[i]))
print(sm.denominator / sm.numerator) |
from math import *
lst = input().split()
if (sqrt(int(lst[0] + lst[1])) % 1) == 0:
print('Yes')
else:
print('No') |
a, b, c, d = map(int, input().split())
e = a + b
f = c + d
if(e > f):
print("Left")
elif(e < f):
print("Right")
else:
print("Balanced") |
def ap_in_time(distance, time_for_ap, speed) -> str:
return 'Yes' if distance <= time_for_ap * speed else 'No'
if __name__ == '__main__':
a, b, c = map(int, input().split())
print(ap_in_time(a, b, c)) |
#coding:UTF-8
W,H,x,y,r = map(int,raw_input().split())
if x - r < 0 or x + r > H or y - r < 0 or y + r > H:
print "No"
else:
print "Yes" |
def gcd(a,b):
a,b=max(a,b),min(a,b)
return a if b==0 else gcd(b,a%b)
x=int(input())
g=gcd(360,x)
print(360//g) |
def main():
str =input().split()
if str[1] =='+' :
print(int(str[0])+int(str[2]))
else :
print(int(str[0])-int(str[2]))
main() |
def resolve():
x, y = input().split()
nx = ord(x)
ny = ord(y)
if nx < ny:
print("<")
elif nx > ny:
print(">")
else:
print("=")
resolve() |
n = int(input())
f = 100000
if n == 0:
print(int(f))
else:
for i in range(n):
f *= 1.05
#print(f)
#F = f - f%1000 + 1000
if f%1000 != 0:
f = (f//1000)*1000 + 1000
#print(i,f)
print(int(f))
|
n = int(input())
s, t = input().split()
answer_list = []
for i in range(n):
answer_list.append(s[i])
answer_list.append(t[i])
joint = ''.join(answer_list)
print(joint) |
import string
while True:
L = string.split(raw_input())
x = int(L[0])
y = int(L[1])
if x == 0 and y == 0: break
if x < y:
print x,y
else:
print y,x |
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
# 各要素の親要素の番号を格納するリスト
# 要素が根(ルート)の場合は-(そのグループの要素数)を格納する
def __init__(self, n):
self.n = n
self.parents = [-1] * n
# 要素xが属するグループの根を返す
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
# 要素xが属するグループと要素yが属するグループとを併合する
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
# 要素x, yが同じグループに属するかどうかを返す
def same(self, x, y):
return self.find(x) == self.find(y)
def main():
from sys import stdin
def input():
return stdin.readline().strip()
n, m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
i, j = map(int, input().split())
uf.union(i-1, j-1)
ans = 0
for i in range(n):
if uf.same(i, p[i]-1):
ans += 1
print(ans)
main() |
x = int(input())
for a in range(-10**3, 10**3+1):
for b in range(-10**3, 10**3+1):
if a**5-b**5 == x:
print(a, b)
exit()
|
N = input()
lastWord = int(N[-1])
if lastWord == 3:
print('bon')
elif lastWord == 0 or lastWord == 1 or lastWord == 6 or lastWord == 8:
print('pon')
else:
print('hon')
|
def mult(n):
res = 0
for i in n:
res += int(i)
if res%9 != 0:
return "No"
return "Yes"
n = input()
print(mult(n)) |
x=input()
ans='AC' in x
if ans==True:
print("Yes")
else:print("No") |
S = input()
if S[0] == S[1] == S[2] == "R":
print(3)
elif (S[0] == S[1] == "R" and S[2] == "S") or (S[1] == S[2] == "R" and S[0] == "S"):
print(2)
elif "R" in S:
print(1)
else:
print(0) |
s = input()
if len(s) < 7:
print("NO")
else:
if s[:7] == "keyence" or s[-7:] == "keyence":
print("YES")
else:
flag = True
for i in range(1, 7):
if s[:i]+s[i-7:] == "keyence":
flag = False
print("YES")
break
if flag:
print("NO") |
def main():
inps = list(input().split(" "))
# print(inps)
stack = []
for inp in inps:
if inp == "+":
a = int(stack.pop(-2))
b = int(stack.pop(-1))
stack.append(a+b)
elif inp == "-":
a = int(stack.pop(-2))
b = int(stack.pop(-1))
stack.append(a-b)
elif inp == "*":
a = int(stack.pop(-2))
b = int(stack.pop(-1))
stack.append(a*b)
else:
stack.append(inp)
# print(inp, type(inp), stack)
print(int(stack[0]))
main()
|
# coding: utf-8
# Your code here!
def LI():
return list(map(int,input().split()))
from decimal import Decimal
a,b,c=map(Decimal,input().split())
if a.sqrt()+b.sqrt()<c.sqrt():
print("Yes")
else:
print("No") |
n = int(input())
s = "abcdefghij"
def func(a):
if len(a) == n:
print(a)
else:
for i in range(len(set(a))+1):
func(a+s[i])
func("a") |
s=input()
for i in range(int(input())):
l=list(input().split())
l[1]=int(l[1])
l[2]=int(l[2])+1
if l[0]=="print":
print(s[l[1]:l[2]])
elif l[0]=="reverse":
s=s[:l[1]]+s[l[1]:l[2]][::-1]+s[l[2]:]
elif l[0]=="replace":
s=s[:l[1]]+l[3]+s[l[2]:] |
s = input()
while "0B" in s or "1B" in s:
s = s.replace("0B", "")
s = s.replace("1B", "")
while "B" in s:
s = s.replace("B", "")
print(s) |
def main():
from collections import deque
N = int(input())
A = input().split()
ret = deque()
head_is_0 = 1
for x in A:
if head_is_0:
ret.append(x)
else:
ret.appendleft(x)
head_is_0 ^= 1
if head_is_0 == 0:
ret.reverse()
print(*ret)
if __name__ == '__main__':
main()
|
N = int(input())
for n in range(25):
for m in range(25):
if n*4+m*7==N:
print("Yes")
exit()
print("No") |
import collections as cl
# 全街のつながりは保証されていて、橋は3本固定なので、枝分かれしてなければたどり着けるはず
def main() :
bridges = []
for i in range(3) :
in_list = [int(i) for i in input().split()]
bridges.extend(in_list)
c = cl.Counter(bridges)
com = c.most_common()
if (com[0][1] == 2 and com[1][1] == 2 and com[2][1] == 1 and com[3][1] == 1) :
print("YES")
else :
print("NO")
main() |
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def warshall_floyd(N: int, graph: list) -> list:
""" ワーシャルフロイド(頂点数, 隣接行列(0-indexed)) """
from copy import deepcopy
res = deepcopy(graph)
for i in range(N):
# 始点 = 終点、は予め距離0にしておく
res[i][i] = 0
# 全頂点の最短距離
for k in range(N):
for i in range(N):
for j in range(N):
res[i][j] = min(res[i][j], res[i][k] + res[k][j])
# 負の閉路(いくらでもコストを減らせてしまう場所)がないかチェックする
for i in range(N):
if res[i][i] < 0:
return []
return res
def build_grid(H, W, intv, _type, space=True, padding=False):
# 入力がスペース区切りかどうか
if space:
_input = lambda: input().split()
else:
_input = lambda: input()
_list = lambda: list(map(_type, _input()))
# 余白の有無
if padding:
offset = 1
else:
offset = 0
grid = list2d(H+offset*2, W+offset*2, intv)
for i in range(offset, H+offset):
row = _list()
for j in range(offset, W+offset):
grid[i][j] = row[j-offset]
return grid
def check1(A, B):
for i in range(N):
for j in range(N):
# 1つでも最短経路が更新されていればNG
if A[i][j] != B[i][j]:
return False
return True
def check2(G):
res = 0
S = set()
for k in range(N):
for i in range(N):
for j in range(N):
# 3頂点が異なってかつ、経由のが近い場合は直接の辺は不要
if i != j and j != k and k != i \
and G[i][k] + G[k][j] == G[i][j]:
if (i, j) not in S:
S.add((i, j))
res += G[i][j]
return res
N = INT()
G = build_grid(N, N, 0, int)
# 妥当性の確認
wf = warshall_floyd(N, G)
if not check1(G, wf):
print(-1)
exit()
# 全体から不要な辺のコストを引く
total = 0
for i in range(N):
for j in range(N):
total += wf[i][j]
ans = (total - check2(wf)) // 2
print(ans)
|
S = str(input())
ans = ["abc", "acb", "bac", "bca", "cab", "cba"]
if S in ans:
print("Yes")
else:
print("No")
|
N = int(input())
for _ in range(3):
if N%10==7:
print("Yes")
break
N //=10
else:
print("No") |
N = int(input())
a = [(s[0], int(s[1])) for s in input().split()]
def bubble(a):
n = len(a)
for i in range(n):
for j in range(n-1, i, -1):
if a[j][1] < a[j-1][1]:
a[j], a[j-1] = a[j-1], a[j]
return a
def selection(a):
n = len(a)
for i in range(n):
minj = i
for j in range(i+1, n):
if a[j][1] < a[minj][1]:
minj = j
a[i], a[minj] = a[minj], a[i]
return a
b_a = bubble(a[:])
s_a = selection(a[:])
print(" ".join([p[0]+str(p[1]) for p in b_a]))
print("Stable")
print(" ".join([p[0]+str(p[1]) for p in s_a]))
print("Stable" if b_a==s_a else "Not stable") |
s = list(input())
if s[0] != 'A':
print('WA')
elif s[2:-1].count('C') != 1:
print('WA')
else:
i = s.index('C')
s.pop(i)
s.pop(0)
s = ''.join(s)
if s.islower():
print('AC')
else:
print('WA') |
x = int(input())
max_val = 1
for i in range(1, x):
for j in range(2, x):
val = i ** j
if val > x:
break
elif val > max_val:
max_val = val
print(max_val) |
import datetime as d
def main():
s = d.datetime.strptime(input(), "%Y/%m/%d")
s = d.date(s.year, s.month, s.day)
if s <= d.date(2019,4,30):
print("Heisei")
else:
print("TBD")
if __name__ == "__main__":
main() |
word = input()
list_word = list(word)
if list_word.count(list_word[0]) == 2 and list_word.count(list_word[1]) == 2 and list_word.count(list_word[2]) == 2:
print('Yes')
else:
print('No')
|
# Take both input K & S, then compare the length of S with K and assign it to length
# If the length is <= K print all
# And if length is >K print some of the character
K = int(input())
S = input()
x = 0
length = len(S)
if length <= K:
print(S)
else:
while x < K:
print(S[x], end=(""))
x += 1
print("...") |
import math
A, B =map(int,input().split())
if A >=13 :
print(B)
elif A >= 6 and 12 >=A :
print(math.floor(B/2))
else :
print(0) |
# -*- coding: utf-8 -*-
nontastyDetox, tastyDedox, tastyToxic = map(int, input().split())
if nontastyDetox + tastyDedox + 1 >= tastyToxic:
print(tastyDedox + tastyToxic)
else:
print(nontastyDetox + 2 * tastyDedox + 1)
|
import sys
readline = sys.stdin.readline
def insertionSort(n, A):
print(*A)
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A)
n = int(readline())
A = [int(j) for j in readline().split(" ")]
insertionSort(n, A) |
def multiply(a,b):
return a * b if a < 10 and b < 10 else -1
print(multiply(*map(int, input().split()))) |
import math
N = int(input())
if (N%2 == 0):
print(math.floor(N/2)-1)
else:
print(math.floor(N/2)) |
x,a,b=(int(x) for x in input().split())
if b<=a:
print("delicious")
elif b-a<=x:
print("safe")
else:
print("dangerous")
|
n=str(input())
for i in n:
if i==",":
n=n.replace(","," ")
print(n) |
n=int(input())
x=0
if n==1:
print(1)
else:
a1=1
a0=2
for i in range(n-1):
x=a1+a0
a0=a1
a1=x
print(x) |
from collections import deque
N = int(input())
L = deque()
for i in range(N):
C= input().split()
if C[0] == "insert":
L.appendleft(C[1])
elif C[0] == "delete":
try:
L.remove(C[1])
except ValueError:
pass
elif C[0] == "deleteFirst":
L.popleft()
elif C[0] == "deleteLast":
L.pop()
print(" ".join(L))
|
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())
num = 0
num += len(make_divisors(n-1))-1
k = make_divisors(n)
k.pop(0)
for item in k:
tn = n
while tn % item == 0:
tn /= item
if tn % item == 1:
num += 1
print(num)
|
s1, s2, s3 = input().split()
print('YES' if s1[-1] == s2[0] and s2[-1] == s3[0] else 'NO') |
#!/usr/bin/env python3
c = input()
d = input()
if c == d[::-1] and d == c[::-1]:
print("YES")
else:
print("NO") |
if __name__ == "__main__":
S = input()
word_arr = ["A","T","G","C"]
max_count,count = 0,0
for c in S:
if c in word_arr:
count += 1
else:
max_count = max(count,max_count)
count = 0
max_count = max(count,max_count)
print(max_count) |
a = input().split()
if -1000 > int(a[0]):
print('')
elif 1000 < int(a[0]):
print('')
elif -1000 > int(a[1]):
print('')
elif 1000 < int(a[1]):
print('')
elif int(a[0]) < int(a[1]):
print('a < b')
elif int(a[0]) > int(a[1]):
print('a > b')
elif int(a[0]) == int(a[1]):
print('a == b')
|
def main():
s = input()
nagasa = len(s)
for i in range(nagasa):
if i % 2 == 0 and s[i] == "L":
print("No")
exit()
elif i % 2 != 0 and s[i] == "R":
print("No")
exit()
print("Yes")
if __name__ == "__main__":
main()
|
N = input()
ans = 'ABC' if N == 'ARC' else 'ARC'
print(ans) |
n=list(input())
for i in range(3):
if n[i]=="1":
n[i]="9"
else:
n[i]="1"
S=""
for j in range(3):
S+=n[j]
print(S) |
n=int(input())
num=[1,1]
for i in range(43):
b=(num[-2])+(num[-1])
num.append(b)
print(num[(n)])
|
import math
N = int(input())
ans = -1
for i in range(N+1):
if math.floor(i*1.08) == N:
ans = i
if ans == -1:
print(':(')
else:
print(ans) |
def insertion_sort(array, element_number):
for i in range(element_number):
v = array[i]
j = i - 1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j = j - 1
array[j+1] = v
for k in range(element_number):
if k < element_number-1:
print(str(array[k]) + ' ', end='')
else:
print(str(array[k]), end='')
print('\n', end='')
def test():
element_number = int(input())
input_array = list(map(int, input().split()))
insertion_sort(input_array, element_number)
if __name__ == '__main__':
test() |
def main():
number = int(raw_input())
list = map(int, raw_input().split())
sort(number, list)
def sort(number, list):
output(list)
for i in range(1, number):
key = list[i]
j = i - 1
while j >= 0 and list[j] > key:
list[j+1] = list[j]
j -= 1
list[j+1] = key
output(list)
def output(list):
print(" ".join(map(str, list)))
main() |
def main():
num_list = list(map(int,input().split()))
good_list = [1,4,7,9]
num_list.sort()
if num_list == good_list:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()
|
# -*- coding: utf-8 -*-
n = int(raw_input())
num = map(int, raw_input().split())
for e in num[::-1]:
if e == num[0]:
print e
break
print e, |
# -*- coding: utf-8 -*-
#----------
X,A,B = [int(input().strip()) for _ in range(3)]
#----------
num_B = (X-A) // B
ans = X - (A + num_B * B)
print(ans)
|
a = list(input())
b = list(input())
a = a[::-1]
if a == b:
print('YES')
else:
print('NO') |
for i in range(int(input())):
a = [int(i) for i in input().split(' ')]
a.sort()
if a[0]**2 + a[1]**2 == a[2]**2:
print('YES')
else:
print('NO') |
s = list(input())
t = list(input())
if s == t[:-1]:
print("Yes")
else:
print("No") |
S = list(input())
q = int(input())
for i in range(q):
cmd, a, b, *c = input().split()
a = int(a)
b = int(b)
if cmd == "replace":
S[a:b+1] = c[0]
elif cmd == "reverse":
S[a:b+1] = reversed(S[a:b+1])
else:
print(*S[a:b+1], sep='')
|
from math import floor, sqrt
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())
div = make_divisors(N)
max_div = sqrt(N)
ans = 0
if N == 2:
print(0)
exit()
if N == 6:
print(5)
exit()
if N == 12:
print(16)
exit()
if N == 20:
print(28)
exit()
if N == 30:
print(52)
exit()
if N == 42:
print(74)
exit()
if N == 56:
print(95)
exit()
if N == 72:
print(157)
exit()
if N == 90:
print(193)
exit()
for d in div:
if d < max_div:
ans += (N-d)//d
# print(d, (N-d)//d, ans)
print(ans)
|
n = int(input())
if n//100*5 >= n%100:
print(1)
else:
print(0) |
n=input()
print "",
for i in xrange(1,n+1):
if i%3==0 or str(i).count('3'):
print i, |
string = input()
q = int(input())
for c in range(0,q):
instruction = input().split(' ')
if instruction[0] == 'print':
print(string[int(instruction[1]):int(instruction[2]) + 1])
elif instruction[0] == 'reverse':
string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)
elif instruction[0] == 'replace':
string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:] |
N = input()
money = 100000
for i in range(N):
money = int(money *1.05)
if money % 1000 != 0:
money = (money // 1000 + 1) * 1000
print money |
import sys
import math
import bisect
def main():
ans = 0
for c in input():
if c == '+':
ans += 1
elif c == '-':
ans -= 1
print(ans)
if __name__ == "__main__":
main()
|
#!/usr/bin/env python3
# from typing import *
YES = 'Yes'
NO = 'No'
# def solve(D: int, T: int, S: int) -> str:
def solve(D, T, S):
return S * T >= D
# generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
D, T, S = map(int, input().split())
a = solve(D, T, S)
print(YES if a else NO)
if __name__ == '__main__':
main()
|
a, b, c = list(map(int, input().split()))
ans = 'Yes' if a <= c <= b else 'No'
print(ans)
|
import collections
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
n = int(input())
a = []
for i in range(2,n+1):
a += prime_factorize(i)
b = set(a)
c = collections.Counter(a)
ans = 1
for i in b:
ans *= c[i]+1
ans %= 10**9+7
print(ans)
|
i1 = input().split(' ')
a=int(i1[0])*int(i1[1])
b=int(i1[2])
if a>b:
print(b)
else:
print(a) |
a, b, c, d = (int(x) for x in input().split())
dis1 = abs(a-b)
dis2 = abs(b-c)
dis3 = abs(a-c)
if dis3 <= d or (dis1 <= d and dis2 <= d):
print('Yes')
else:
print('No') |
def ABC_132_A():
S = input()
if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
print('No')
else:
print('Yes')
if __name__ == '__main__':
ABC_132_A() |
a = list(map(str,input().split()))
A = a[0]
B = a[1]
C = a[2]
if A[-1] == B[0] and B[-1] == C[0]:
print('YES')
else:
print('NO')
|
n=int(input())
nums=list(map(int,input().split()))
count=0
def merge(nums,left,mid,right):
global count
inf=10**9
L=nums[left:mid]+[inf]
R=nums[mid:right]+[inf]
i=0
j=0
for k in range(left,right):
count+=1
if R[j]>=L[i]:
nums[k]=L[i]
i+=1
else:
nums[k]=R[j]
j+=1
def merge_sort(nums,left,right):
if left+1<right:
mid=(right+left)//2
merge_sort(nums,left,mid)
merge_sort(nums,mid,right)
merge(nums,left,mid,right)
merge_sort(nums,0,n)
def show(nums):
l=len(nums)
for i in range(l):
if i!=l-1:
print(nums[i],end=" ")
else:
print(nums[i])
show(nums)
print(count)
|
def resolve():
import math
n = int(input())
for i in range(1, n+1):
if math.floor(i * 1.08) == n:
print(i)
quit()
print(":(")
resolve() |
s = input()
if s == "AAA" or s == "BBB" :
print ("No")
else : print ("Yes") |
S=input()
if 'keyence'==S[:7] or 'keyence'==S[-7:]:
print('YES')
exit()
if 'k'==S[:1] and 'eyence'==S[-6:]:
print('YES')
exit()
if 'ke'==S[:2] and 'yence'==S[-5:]:
print('YES')
exit()
if 'key'==S[:3] and 'ence'==S[-4:]:
print('YES')
exit()
if 'keye'==S[:4] and 'nce'==S[-3:]:
print('YES')
exit()
if 'keyen'==S[:5] and 'ce'==S[-2:]:
print('YES')
exit()
if 'keyenc'==S[:6] and 'e'==S[-1:]:
print('YES')
exit()
print('NO') |
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 8 20:25:36 2020
@author: liang
"""
def Eratosthenes(x):
lis = [int(i) for i in range(2,x+1)]
#print(lis)
res = list()
while lis:
a = lis.pop(0)
res.append(a)
lis = [i for i in lis if i%a != 0]
#print(lis)
return res
import math
X = int(input())
N = int(math.sqrt(X))
lis = Eratosthenes(N)
#print(N)
#print(lis)
ans = X
while True:
if all(ans%i != 0 for i in lis):
print(ans)
break
ans += 1 |
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
def main():
S = input()
search_string=['A','Z']
position=[]
#Aを探す
for i,s in enumerate(S):
if s==search_string[0]:
position.append(i)
break
#Zを探す
for r_i,r_s in enumerate(reversed(S)):
if r_s==search_string[1]:
position.append(len(S)-r_i)
break
print(position[1]-position[0])
if __name__=="__main__":
main() |
n = 0
while n != 1:
m = raw_input().split()
if m[1] == "?":
break
if m[1] == "+":
print int(m[0])+int(m[2])
if m[1] == "-":
print int(m[0])-int(m[2])
if m[1] == "*":
print int(m[0])*int(m[2])
if m[1] == "/":
print int(m[0])/int(m[2]) |
#!/usr/bin/env python3
wd = "SUN MON TUE WED THU FRI SAT".split()
wd = list(reversed(wd))
def solve(S: str):
idx = wd.index(S)
return idx+1
def main():
S = input().strip()
answer = solve(S)
print(answer)
if __name__ == '__main__':
main()
|
n = int(input())
from collections import defaultdict
d = {0:2,1:1}
def calc(n):
if n not in d:
d[n] = calc(n-1) + calc(n-2)
return d[n]
for i in range(n):
calc(i)
print(calc(n)) |
line = input()
a, b, x = [int(n) for n in line.split()]
if x>(a+b) or x<a:
print("NO")
else:
print("YES") |
def gcd(a, b):
if b == 0: return a
else: return gcd(b, a % b)
def lcm(a, m):
return a * b / gcd(a, b);
while True:
try:
a, b = map(int, raw_input().split())
print gcd(a, b), lcm(a, b)
except (EOFError):
break |
a,b,c = (int(i) for i in input().split())
ans = False
if a == b and b==c:
ans = True
if ans:
print("Yes")
else:
print("No") |
while(True):
f = input()
s = f.split()
if(s[1] == '?'):
break
if(s[1] == '/'):
print((int)(s[0]) // (int)(s[2]))
else:
print(eval(f))
|
A, B, C = input().split()
if A[len(A)-1:len(A)] == B[0:1] and B[len(B)-1:len(B)] == C[0:1]:
print('YES')
else:
print('NO')
|
A = int(input())
B = int(input())
C = int(input())
D = int(input())
if A <= B :
answer1 = A
else :
answer1 = B
if C <= D :
answer2 = C
else:
answer2 = D
print(answer1 + answer2) |
n = input().split()
n.sort()
print('YES') if ''.join(n) == '1479' else print('NO') |
word = input()
word += "s" if word[-1] != "s" else "es"
print(word) |
import re
s = input()
answer=re.sub(r'[a-z]','x',s)
print(answer) |
a,op,b=input().split() #文字列
if op=='+':print(int(a)+int(b))
else:print(int(a)-int(b))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.