text stringlengths 37 1.41M |
|---|
# coding: utf-8
def main():
S = list(input())
b = 0
ans = 0
for s in S:
if s == 'B':
b += 1
else:
ans += b
print(ans)
if __name__ == "__main__":
main()
|
import math
a,b,x=map(int,input().split())
if x>=(1/2)*a*a*b:
y=2*(b-x/(a*a))
print(math.degrees(math.atan2(y,a)))
else:
y=2*x/(a*b)
print(math.degrees(math.atan2(b,y))) |
L = int(input(""))
a = L / 3.0
print(pow(a,3)) |
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
while True:
try:
a, b = map(int, raw_input().strip().split(' '))
print "%d %d" % (gcd(a, b), a*b/gcd(a, b))
except EOFError:
break |
a,b,c = map(int,input().split())
if a+b+c == 17 and a*b*c == 175:
print('YES')
else:
print('NO') |
while True:
string = input()
if string == '-':
break
n = int(input())
for i in range(n):
x = int(input())
tmp = string[0:x]
string = string[x:]
string+=tmp
print(string) |
class Dice:
def __init__(self, usr_input, command):
self.eyes = list(map(int, usr_input.split()))
self.pos = {label:eye for label, eye in zip(range(1, 7), self.eyes)}
self.com = list(command)
def roll(self):
for c in self.com:
self.eyes = [n for n in self.pos.values(... |
n = int(input())
a_list = list(map(int, input().split()))
num_of_odd = 0
for a in a_list:
if a % 2 == 1:
num_of_odd += 1
if num_of_odd % 2 == 0:
print("YES")
else:
print("NO")
|
arr = list([input() for _ in range(10)])
arr.sort(reverse=True)
for i in range(3):
print arr[i]
|
def main():
s = input()
lst = ["AKIHABARA",
"KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR",
"KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR",
"KIHBRA", "KIHBAR", "KIHABR", "AKIHBR",
"KIHBR"]
if s in lst:
print("YES")
else:
prin... |
m, s, mps = [int(x) for x in input().split()]
time = m / mps
if s >= time:
print('Yes')
else:
print('No') |
import math
r = input()
pi = math.pi
c = 2 * float(r) * pi
print(f'{c:.20f}')
|
S = input()
S1 = []
for i in S:
if i not in S1:
S1.append(i)
if len(S1) == 2:
print('Yes')
else:
print('No') |
N = int(input())
ans = 0
for a in range(1,N):
ans += (N-1)//a
print("{}".format(ans)) |
h, w = map(int, input().split())
a = [input() for _ in range(h)]
vrows = {r: False for r in range(h)}
vcols = {c: False for c in range(w)}
for r in range(h):
for c in range(w):
if a[r][c] == '#':
vrows[r] = True
vcols[c] = True
for r in range(h):
if vrows[r]:
row = ''
... |
n=int(input())
print(0)
zero=input()
if zero=="Vacant":exit()
left,right=0,n
while left<right:
mid=(left+right)//2
print(mid)
ans=input()
if ans=="Vacant":exit()
if (ans==zero and mid%2==1) or (ans!=zero and mid%2==0):right=mid+1
else:left=mid |
from collections import deque
A = list(input())
B = list(input())
C = list(input())
CARDS = [deque(A),deque(B),deque(C)]
s_to_i = {"a":0,"b":1,"c":2}
turn = 0
while CARDS[turn]:
nxt = CARDS[turn].popleft()
turn = s_to_i[nxt]
if turn == 0:
print("A")
elif turn == 1:
print("B")
elif turn == 2:
print("C")
... |
T = input()
T_list = list(T)
i = 0
while i < len(T):
if T_list[i] == "?":
T_list[i] = "D"
i += 1
T_new = "".join(T_list)
print(T_new) |
X = int(input())
i = 0
now = 0
while i < X:
now += 1
i +=now
ans = now
print(ans) |
c=False
f=False
s=input()
for i in s:
if i=="C":
c=True
if i=="F" and c==True:
f=True
if c and f:
print("Yes")
else:
print("No") |
def sum_value(n):
n = str(n)
sum = 0
for i in range(len(n)):
sum+=int(n[i])
return sum
N = int(input())
A = int(N/2)
B = int(N/2) if N%2 == 0 else int(N/2)+1
menor = -1
for i in range(int(N/2)):
menor = sum_value(A+i)+sum_value(B-i) if menor < 0 else min(sum_value(A+i)+sum_value(B-i), menor... |
#B - Break Number
N = int(input())
result = 0
for i in range(7):
if 2**i <= N:
result = i
else:
break
print(2**result) |
if __name__ == '__main__':
s=input()
count=0
for i in s:
if i=="o":
count+=1
if 15- len(s) >=8-count:
print("YES")
else:
print("NO") |
s = input()
for i in range(len(s)):
if s[i]=="A":
for j in reversed(range(i,len(s))):
if s[j] == "C":
if j==i+1:
print("Yes")
exit()
print("No")
|
class Dice:
__x = 1
__y = 0
def __init__(self,dice):
self.dice = dice
def output(self):
print(self.dice[0])
def move(self,str):
if str == 'N':
temp = self.dice[0]
self.dice[0] = self.dice[1]
self.dice[1] = self.dice[5]
self.dice[5] = self.dice[4]
self.dice[4... |
from fractions import gcd
#最小公倍数
def lcm(a, b):
return a*b // gcd(a, b)
import sys
input = sys.stdin.readline
N = int(input())
print(lcm(2, N)) |
def main():
n = int(input())
a_lst = [int(input()) for i in range(n)]
a_lst_descend = sorted(a_lst, reverse=True)
max_value = a_lst_descend[0]
second_value = a_lst_descend[1]
for a in a_lst:
if a == max_value:
print(second_value)
else:
print(max_value)
... |
#!/usr/bin/env python3
import collections as cl
import sys
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def main():
_a, _b = input().split()
a = _a * int(_b)
b = _b * int(... |
# Dice I
class Dice:
def __init__(self, a1, a2, a3, a4, a5, a6):
# サイコロを縦横にたどると書いてある数字(index1は真上、index3は真下の数字)
self.v = [a5, a1, a2, a6] # 縦方向
self.h = [a4, a1, a3, a6] # 横方向
# print(self.v, self.h)
# サイコロの上面の数字を表示
def top(self):
return self.v[1]
# サイコロを北方向に倒す
... |
N=input()
ok=True
for i,c in enumerate(N):
if c!=N[len(N)-i-1]:
ok=False
if ok:
print("Yes")
else:
print("No") |
name=input()
len_n=len(name)
name2=input()
len_n2=len(name2)
if name==name2[:-1] and len_n+1==len_n2:
print("Yes")
else:
print("No") |
N = int(input())
ans = 'Yes'
a = set()
pre = ''
for i in range(N):
word = input()
if not word in a and (pre == word[0] or pre == '') and ans == 'Yes':
ans = 'Yes'
a.add(word)
pre = word[-1]
else:
ans = 'No'
print(ans)
|
#!/usr/bin/env python
# coding: utf-8
# In[11]:
N = int(input())
A = list(map(int, input().split()))
# In[12]:
even_list = [x for x in A if x%2 == 0]
ans = 3**len(A) - 2**(len(even_list))
print(ans)
# In[ ]:
|
def main():
h,w=map(int,input().split())
a=[]
for _ in range(h):
a.append(input())
now = (0, 0)
end = (h-1, w-1)
visited = set([now])
while True:
nxt = None
#print(now)
if now[0]+1 < len(a) and a[now[0]+1][now[1]] == "#":
nxt = (now[0]+1, now[1])
... |
import sys
input = sys.stdin.readline
A, B, C, D = [int(x) for x in input().split()]
if (A + B) > (C + D):
print("Left")
elif (A + B) < (C + D):
print("Right")
else:
print("Balanced") |
while 1:
x = raw_input().split()
a,op,b = int(x[0]),x[1],int(x[2])
if op == "+":
print a+b
elif op == "-":
print a-b
elif op == "/":
print a/b
elif op == "*":
print a*b
else:
break |
N=int(input())
import math
X=math.ceil(N/1.08)
if int(X*1.08)==N:
print(X)
else:
print(':(') |
def abc144c_walk_on_multiplication_table():
def divisor(n):
""" nの約数列挙 """
ret = []
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
ret.append(i)
if i ** 2 == n:
continue
ret.append(n // i)
return re... |
import sys
line = sys.stdin.readline()
inp = []
for i in line.split(" "):
inp.append(int(i))
a = inp[0]
b = inp[1]
if a<b:
print("a < b")
elif a==b:
print("a == b")
elif a>b:
print("a > b") |
a,b,c = input()
a = int(a)
b = int(b)
c = int(c)
if a == 7 or b == 7 or c == 7:
print("Yes")
else:
print("No") |
def run(S):
if len(S) == 2:
return S
else:
return S[::-1]
def main():
S = input()
print(run(S))
if __name__ == '__main__':
main()
|
#連想配列(Dictを使った配列操作)
N = int(input())
li = []
dict1 = {}
for _ in range(N):
li.append(int(input()))
for i in range(N):
if str(li[i]) in dict1:
#print("delete",li[i])
del dict1[str(li[i])]
else:
#print("add",li[i])
dict1[str(li[i])] = '0'
print(len(dict1)) |
if __name__ == '__main__':
n = int(input())
list =[111,222,333,444,555,666,777,888,999]
for i in list:
if i>= n:
print(i)
break |
from enum import IntEnum
class Face(IntEnum):
One=1
Two=2
Three=3
Four=4
Five=5
Six=6
class Dice:
def __init__(self):
self.top=Face.One
self.bottom=Face.Six
self.back=Face.Two
self.front=Face.Five
self.left=Face.Four
self.right=Face.Three
... |
comparison = 0
def merge(A,left,mid,right):
global comparison
n1 = mid - left
n2 = right - mid
L = [0]*(n1+1)
R = [0]*(n2+1)
for i in range(n1):
L[i] = A[left+i]
for i in range(n2):
R[i] = A[mid+i]
L[n1] = 1e12
R[n2] = 1e12
i = 0
j = 0
for k in ra... |
s=input()
ans='No'
if s.count('AC')!=0:
ans='Yes'
print(ans)
|
# # もし修行により消化コストが全て0になる場合
# if sum(a_list) <= k:
# print(0)
# exit()
# # 更新メソッド
# def update_cost(max_idx, result_cost, a_list, f_list):
# result_cost[max_idx] = a_list[max_idx] * f_list[max_idx]
# if max_idx == 0:
# pass
# else:
# result_cost[max_idx-1] = a_list[max_idx-1] * f_li... |
# -*- config: utf-8 -*-
if __name__ == '__main__':
for i in range(int(raw_input())):
nums = map(lambda x:x**2,map(int,raw_input().split()))
nums.sort()
if nums[0]+nums[1] == nums[2]:
print "YES"
else :
print "NO" |
def main():
S = input()
w = int(input())
answer = ""
for i in range(0, len(S), w):
answer += S[i]
print(answer)
if __name__ == '__main__':
main()
|
s = list(map(str, input().rstrip()))
t = list(map(str, input().rstrip()))
s.sort()
t.sort(reverse=True)
s = "".join(s)
t = "".join(t)
print("Yes" if s < t else "No") |
import string
s = set(sorted(input()))
for i in string.ascii_lowercase:
if i not in s:
print(i)
exit()
print("None") |
mount = []
for i in range(0, 10):
n = input()
mount.append(n)
mount.sort(reverse = True)
for i in range(0, 3):
print mount[i] |
n = int(input())
a, b = divmod(n, 3)
if n < 3:
print(0)
else:
print(a) |
import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
N = int(input())
primes = []
mod = 1
count = 0
for i in range(2,55555+1):
if i%5 == mod and is_prime(i):
primes.append(i)
count ... |
c=input()
if c=='A':print('T')
elif c=='T':print('A')
elif c=='G':print('C')
else:print('G') |
class Sieve:
"""区間[2,n]の値を素因数分解する"""
def __init__(self, n=1):
primes = []
f = [0] * (n + 1)
f[0] = f[1] = -1
for i in range(2, n + 1): # 素数を探す
if f[i]: continue
primes.append(i)
f[i] = i # 素数には自身を代入
for j in range(i * i, n + 1, i... |
X = int(input())
c = X // 100
if c * 100 <= X <= c * 105:
print(1)
else:
print(0)
|
N = int(input())
A = N // 1000
B = (N % 1000) // 100
C = (N % 100) // 10
D = N % 10
if A==B and B==C:
print('Yes')
elif B==C and C==D:
print('Yes')
else:
print('No')
|
import math
def is_prime(n):
if n in [2, 3, 5, 7]:
return True
elif 0 in [n%2, n%3, n%5, n%7]:
return False
else:
check_max = math.ceil(math.sqrt(n))
for i in range(2, check_max + 1):
if n % i == 0:
return False
else:
return True
def main():
primes = set([])
length =... |
a = input()
b = 0
c = ""
for i in a:
c += i
b += 1
if b==3:
break
print(c)
|
S=input()
res=0
cnt=0
if S[0]!='A':
print('WA')
exit()
for i in range(2,len(S)-1):
if S[i]=='C' and cnt==0:
cnt+=1
res=1
elif S[i]=='C' and cnt==1:
res=0
for i in range(len(S)):
if S[i]!='A' and S[i]!='C' and S[i].isupper() == True:
print('WA')
exit()
if res==... |
N = int(input())
import math
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
num = prime_fac... |
n = int(input())
if n % 2 == 0:
print(int(n/2) - 1)
elif n % 2 == 1:
print(n // 2) |
while True:
h, w = map(int, raw_input().split())
if (h == 0) & (w == 0):
break
line = ""
for j in range(w):
line += "#"
for i in range(h):
print line
print "" |
word = input()
if word[0] == word[1] and word[1] == word[2] and word[0] == word[2]:
print("No")
else:
print("Yes")
|
url = "https://atcoder.jp//contests/abc142/tasks/abc142_d"
import math
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:
... |
from collections import Counter
N = int(input())
S_list = []
for i in range(N):
str = input()
S_list.append(str)
print(len(list(Counter(S_list))))
|
s=input()
t=True
for i in s:
if s.count(i) != 1:
t=False
print("yes" if t else "no") |
#!/usr/local/env python3
import sys
def main():
while True:
count = 0
n, r = map(int, sys.stdin.readline().split())
if n == r == 0:
break
for n1 in range(1, n-1):
for n2 in range(n1+1, n):
for n3 in range(n2+1, n+1):
if n... |
s=str(input())
a="Y"
b="Y"
if 0<int(s[0:2])<13:
a="MY"
if 0<int(s[2:5])<13:
b="MY"
if a==b=="Y":
ans="NA"
elif a=="Y" and b=="MY":
ans="YYMM"
elif a=="MY" and b=="Y":
ans="MMYY"
else:
ans="AMBIGUOUS"
print(ans) |
S = input()
flag = False
tmp = ''
for s in S:
if tmp == s:
flag = True
tmp = s
if flag == True:
print('Bad')
else:
print('Good') |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
''' ?????? '''
class Dictionary(object):
""" Dictionary """
def __init__(self):
self.dict = {}
def insert(self, x):
self.dict[x] = 0
def find(self, x):
if x in self.dict.keys():
print('yes')
else:
... |
while True:
k=map(int,raw_input().split())
H=k[0]
W=k[1]
if H+W==0:
break
#
if W%2==0:
pattern="even"
else:
pattern="odd"
#
if pattern=="even":
f_line="#."*(W/2)
s_line=".#"*(W/... |
n = 0
list = []
while n < 10:
x = int(input())
list.append(x)
n += 1
list.sort()
print(list[9])
print(list[8])
print(list[7]) |
import copy as cp
n = int(input())
A = list()
for i in range(n):
A.append(int(input()))
count = 0
#print(A)
def insertionsort(A,n,g):
global count
for i in range(g,n):
v = A[i]
j = i-g
while (j >= 0 and A[j] > v):
A[j+g] = A[j]
A[j] = v
j = j - g... |
S=str(input())
X="abc"
Y=[]
for i in range(3):
if S[i] in X:
if S[i] not in Y:
Y.append(S[i])
if len(Y)==3:
ans="Yes"
else:
ans="No"
print(ans) |
S = input()
cnt=0
for i in S:
if i == '2':
cnt+=1
print(cnt) |
N = int(input())
if N == 0:
print(2)
if N == 1:
print(1)
else:
li = [2,1]
for i in range(2,N+1):
li.append(li[i-2]+li[i-1])
if i == N:
print(li[i]) |
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n): #各単語の出現回数を数える
if arr[i] not in dic:
dic[arr[i]]=1
else:
dic[arr[i]]+=1
largest=max(dic.values()) #最大の出現回数を求める
ans=[]
for keys in dic.keys():
if dic[keys]==largest: #出現回数が最も多い単語を集計する
ans.append(keys)
ans=sorted(ans) #単語を辞書順に並べ替えて出力する
fo... |
p = input() * 2
s = input()
print('Yes' if s in p else 'No') |
import math
H = int(input())
def f(x):
if x == 1:
return 1
else:
return 2 * f(x // 2) + 1
print(f(H)) |
def insertion_sort(A, g):
cnt = 0
for i in range(g, len(A)):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j+g] = A[j]
j -= g
cnt += 1
A[j+g] = v
return cnt
def shell_sort(A):
cnt = 0
h = 1
G = []
while h <= len(A)/2:
... |
a = int(input())
A = str(a)
b = int(A[len(A)-1])
if b == 3:
print('bon')
elif b == 0 or b == 1 or b == 6 or b == 8:
print('pon')
else:
print('hon') |
if __name__ == "__main__":
N = input()
n_list = []
for n in N:
n_list.append(int(n))
n_sum = sum(n_list)
ans = 'Yes' if n_sum % 9 == 0 else 'No'
print(ans) |
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())
class UnionFind:
def __init__(self, n):
self.parents = [-1] * (n + 1)
self.rank = [0] * (n + 1)
def root(se... |
import math
r = float(input())
print('%.6f %.6f'%(math.pi*r*r,2.0*math.pi*r))
|
K = int(input())
num = 0
for i in range(0,K+1):
num = (num*10+7)%K
if num==0:
print(i+1,'\n')
break
if num:
print("-1\n") |
import fractions
from functools import reduce
def gcd(l):
return reduce(fractions.gcd, l)
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = gcd(a)
if k%x == 0 and k <= max(a):
print("POSSIBLE")
else:
print("IMPOSSIBLE") |
from decimal import Decimal
def main():
n = int(input())
xu = [input().split() for _ in range(n)]
c = Decimal("0")
for x,u in xu:
if u == "JPY":
c += Decimal(x)
else:
c += Decimal(x)*Decimal("380000.0")
print(c)
if __name__ == "__main__":
main() |
s = input()
lc = s.lower()
uc = s.upper()
ans = ""
for i in range(len(s)):
if s[i] == lc[i]:
ans += uc[i]
else:
ans += lc[i]
print(ans)
|
x, y = [int(x) for x in input().split()]
def gcd(a, b):
m = a%b
return gcd(b, m) if m else b
print(gcd(x, y))
|
s = int(input())
b = s%100
a = (s - b)//100
if (0 < a <= 12 and 0 < b <= 12):
print("AMBIGUOUS")
elif (0 < a <= 12):
print("MMYY")
elif (0 < b <= 12):
print("YYMM")
else:
print("NA")
|
x = int(input())
min_x = -int(pow(x,0.2))-1
for a in range(x):
for b in range(min_x,x):
test = pow(a,5) - pow(b,5)
if b > 0 and test < x:
break
if test == x:
print(a,b)
exit() |
str = input()
q = int(input())
for i in range(q):
order = list(input().split())
if order[0] == "print":
print(str[int(order[1]):int(order[2])+1])
elif order[0] == "reverse":
str = str[:int(order[1])] + str[int(order[1]):int(order[2])+1][::-1] + str[int(order[2])+1:]
elif order[0] == "re... |
import sys
def main():
n = int(input())
print("0")
sys.stdout.flush()
x = input().rstrip()
if x == "Vacant":
sys.exit()
print(n//2)
sys.stdout.flush()
y = input().rstrip()
if y == "Vacant":
sys.exit()
l, r= 0, 0
z = ""
if x == y:
if n//2%2 == 1:
... |
x=int(input())
x=x+x*x+x*x*x
print(x) |
import math
S = list(input())
a =0
b = 0
n=len(S)
for i in range(0,n,2):
if(S[i]=="R" or S[i]=="U" or S[i]=="D"):
a +=1
for j in range(1,n,2):
if(S[j]=="L" or S[j]=="U" or S[j]=="D"):
b+=1
if(a==math.ceil(n/2) and b ==math.floor(n/2)):
print("Yes")
else:
print("No") |
lst = input().split()
for i in range(len(lst)):
lst[i] = int(lst[i])
area1 = lst[0] * lst[1]
area2 = lst[2] * lst[3]
areas = [area1, area2]
areas.sort()
print(areas[1])
|
n = int(raw_input())
out = ""
for i in range(1, n + 1):
if (i % 3 == 0) or (i % 10 == 3):
out += " " + str(i)
continue
if "3" in str(i):
out += " " + str(i)
print out |
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
n = int(input())
increasing = []
decreasing = []
dec_special = []
for _ in range(n):
s = input().rstrip()
minima = 0
fin = 0
for ch in s:
if ch == ")":
fin -= 1
if fin < minima:
minima = fin
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.