text
stringlengths 37
1.41M
|
---|
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,x = map(int,input().split())
print("YES" if a <= x <= a+b else "NO") |
x=int(input())
while 1:
for i in range(2,x):
if x%i==0:
x+=1
break
else:
break
print(x) |
N = int(input())
for i in range(N):
if int(input())%2 != 0:
print("first")
exit()
print('second') |
n=int(raw_input())
i=1
print "",
while i<=n:
x=i
if x%3==0:
print i,
else:
while x:
if x%10==3:
print i,
break
x/=10
i+=1 |
s = input()
ans = 'None'
for i in range(26):
c = chr(ord('a') + i)
if c not in s:
ans = c
break
print(ans)
|
data = int(input())
for i in range(1, data+1):
if (i % 3 == 0) or ("3" in str(i)):
print("", i, end="")
print() |
X, A, B = map(int, input().split())
mypoint = 0
if mypoint-A+B<=mypoint:
print("delicious")
elif mypoint-A+B<=X:
print("safe")
else:
print("dangerous") |
x = int(input())
eratostenes = [True] * 10**6
for i in range(2, len(eratostenes)):
if eratostenes[i]:
for j in range(i * 2, len(eratostenes), i):
eratostenes[j] = False
for i in range(x, len(eratostenes)):
if eratostenes[i]:
print(i)
exit() |
n = int(input())
for _ in range(n):
if int(input()) % 2 == 1:
print("first")
break
else:
print("second") |
import re
s = input()
s1 = re.fullmatch(r"A([a-z]+)C([a-z]+)", s)
if s1 == None:
print("WA")
else:
print("AC")
|
x = int(input())
sum = 0
for i in range(x + 1):
sum = sum + i
print(sum)
|
def BubbleSort(C,N):
for i in range(N):
for j in range(i+1, N)[::-1]:
if int(C[j][1]) < int(C[j - 1][1]):
C[j],C[j-1] = C[j-1],C[j]
def SelectionSort(C,N):
for i in range(N):
minj = i
for j in range(i,N):
if int(C[j][1]) < int(C[minj][1]):
minj = j
C[i],C[minj] = C[minj],C[i]
N = int(input())
C = (input()).split()
ORG = C[:]
BubbleSort(C,N)
print (" ".join(C))
print ("Stable")
C2=ORG
SelectionSort(C2,N)
print(" ".join(C2))
if C == C2:
print ("Stable")
else:
print ("Not stable") |
N = int(input())
sum=0
for i in range(1,N+1):
if (i%3!=0 and i%5!=0):
sum += i
print(sum)
|
s = input()
if len(s)>=4 and s[:4]=="YAKI": print("Yes")
else: print("No") |
N = int(input())
if N < 3:
print(0)
elif N//3 == 0:
print(3)
else:
print(N//3) |
n = int(input())
m = n%10
l = n // 10
if m==9 or l==9:
print("Yes")
else:
print("No") |
N = int(input())
result = 0
for x in range(N):
if (x+1)%3 == 0:
result+=1
print(result)
|
def print_list(A):
print(*A, sep=" ")
def swap(a, b):
return b, a
def find_minj(A, i, n):
minj = i
for j in range(i, n):
if A[j] < A[minj]:
minj = j
return minj
def selection_sort(A, n):
replace_num = 0
for i in range(0, n):
minj = find_minj(A, i, n)
if A[i] > A[minj]:
A[i], A[minj] = swap(A[i], A[minj])
replace_num += 1
print_list(A)
print(replace_num)
n = int(input())
A = list(map(int,input().split()))
selection_sort(A, n)
|
N=int(input())
S=input().split()
if len(set(S))==3:print('Three')
else:print('Four') |
N = int(input())
if N%2:
ans = 0
else:
ans = 0
d = 10
while d <= N:
ans += N//d
d *= 5
print(ans)
|
import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
def gcd_list(numbers):
return reduce(math.gcd, numbers)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
d = set()
for i in range(n):
d.add(a[i + 1] - a[i])
d = list(d)
ans = gcd_list(d)
print(ans) |
a, b = map(int, input().split())
if a == b:
ans = "Draw"
elif a == 1 or (b != 1 and a > b):
ans = "Alice"
elif b == 1 or (a != 1 and a < b):
ans = "Bob"
print(ans) |
s = input()
if s.find('RRR') != -1:
print(3)
elif s.find('RR') != -1:
print(2)
elif s.find('R') != -1:
print(1)
else:
print(0) |
def ex_euclid(a, b):
x0, x1 = 1, 0
y0, y1 = 0, 1
z0, z1 = a, b
while z1 != 0:
q = z0 // z1
z0, z1 = z1, z0 % z1
x0, x1 = x1, x0 - q * x1
y0, y1 = y1, y0 - q * y1
return z0, x0, y0
def mod_inv(a, n):
g, x, _ = ex_euclid(a, n)
if g != 1:
print("modular inverse does not exist")
else:
return x % n
def mod_factorial(x, modulo):
ans = 1
for i in range(1, x+1):
ans *= i
ans %= modulo
return ans
X, Y = map(int, input().split())
M = 10 ** 9 + 7
a, b = (2*X-Y)/3, (2*Y-X)/3
if a < 0 or b < 0:
print(0)
elif a == 0 and b == 0:
print(0)
elif a%1 != 0 or b%1!= 0:
print(0)
else:
a, b = int(a), int(b)
answer = 1
answer *= mod_factorial(a+b, M)
answer *= mod_inv(mod_factorial(a, M), M)
answer %= M
answer *= mod_inv(mod_factorial(b, M), M)
answer %= M
print(answer) |
from collections import deque
sa=list(input())
sb=list(input())
sc=list(input())
a=deque(sa)
b=deque(sb)
c=deque(sc)
k=a.popleft()
while True:
if k=="a":
if not a:
print("A")
exit()
else:
k=a.popleft()
if k=="b":
if not b:
print("B")
exit()
else:
k=b.popleft()
if k=="c":
if not c:
print("C")
exit()
else:
k=c.popleft() |
class Dice(object):
def __init__(self,List):
self.face=List
def n_spin(self,List):
temp=List[0]
List[0]=List[1]
List[1]=List[5]
List[5]=List[4]
List[4]=temp
def s_spin(self,List):
temp=List[0]
List[0]=List[4]
List[4]=List[5]
List[5]=List[1]
List[1]=temp
def e_spin(self,List):
temp=List[0]
List[0]=List[3]
List[3]=List[5]
List[5]=List[2]
List[2]=temp
def w_spin(self,List):
temp=List[0]
List[0]=List[2]
List[2]=List[5]
List[5]=List[3]
List[3]=temp
dice = Dice(map(int,raw_input().split()))
command = list(raw_input())
for k in command:
if k=='N':
dice.n_spin(dice.face)
elif k=='S':
dice.s_spin(dice.face)
elif k=='E':
dice.e_spin(dice.face)
else:
dice.w_spin(dice.face)
print dice.face[0] |
s = input()
f = 0
for i in s:
if i == "C" and f == 0:
f += 1
if i == "F" and f == 1:
print("Yes")
exit()
print("No") |
n = int(input())
s = input()
ans = 0
for i in range(1000):
# 確認するpinの数字の組み合わせと桁の初期化
current_digit = 0
pin = f'{i:0>3}'
# pin = list(str(i).zfill(3))
k = pin[current_digit]
for num in s:
# 見つけると桁を右に一つずらす
if num == k:
current_digit += 1
# indexが3(桁が3→2→1→0)になったときはそのPINは作れる
if current_digit <= 2:
k = pin[current_digit]
elif current_digit == 3:
ans += 1
break
print(ans) |
N = input()
good_ints = (str(i) * 3 for i in range(9 + 1))
answer = ''
for good_int in good_ints:
if good_int in N:
answer = 'Yes'
break
print(answer if answer else 'No') |
K=int(input())
S=input()
if len(S)<K or len(S)==K:
print (S)
elif len(S)>K:
print(S[0:K]+"...") |
N = int(input())
total = 0
for n in range(1, N+1):
if (n % 3 > 0) and (n % 5 > 0):
# print(n)
total += n
print(total) |
st=input()
count=0
while(True):
s=input()
if s=="END_OF_TEXT":
break
t=s.split()
for k in t:
if k.lower()==st:
count+=1
print(count) |
S = input()
A = sorted(S)
hantei = "".join(A)
#print(hantei)
if hantei == "abc" :
result = "Yes"
else:
result ="No"
print(result) |
d = int(input())
print('Christmas', end='')
for i in range(25, d, -1):
print(' Eve', end='')
print()
|
N = input()
if int(N)%sum(int(i) for i in N) == 0:
print("Yes")
else:
print("No") |
t = input()
ans = []
for i in range(len(t)):
if t[i] == '?':
ans.append('D')
else:
ans.append(t[i])
print(''.join(ans)) |
import sys
s = input()
for x, y in zip(s, s[1:]):
if x == 'A' and y == 'C':
print('Yes')
sys.exit()
print('No') |
a=int(input())
if a<10:
print(a)
if 10<=a<100:
print(9)
if 100<=a<1000:
print(9+a-99)
if 1000<=a<10000:
print(909)
if 10000<=a<100000:
print(909+a-9999)
if a==100000:
print(90909) |
N=input()
s=set(input().split())
if len(set(s))==3:
print("Three")
else:
print("Four") |
N = int(input())
isPrime = [True]*(N+1)
isPrime[0] = False
isPrime[1] = False
for i in range(2, N + 1):
if isPrime[i]:
for j in range(2*i, N + 1, i):
isPrime[j] = False
factors = []
for p in range(2, N+1):
if not isPrime[p]:
continue
f = 0
base = p
while base <= N:
f += N // base
base *= p
if f > 0:
factors.append(f)
ans = 1
m = 10**9 + 7
for f in factors:
ans *= (f+1)
if ans >= m:
ans %= m
print(ans)
|
N = int(input())
def divisor(n):
res = []
i = 1
while i*i <= n:
if n % i == 0:
res.append(i)
if i != n//i:
res.append(n // i)
i += 1
return res
ans = 0
for i in range(1, N+1, 2):
res = len(divisor(i))
ans += 1 if res == 8 else 0
print(ans)
|
def main(S):
while len(S) > 0:
if S[-1] == "m":
if S[-5:] == "dream":
S = S[:-5]
else:
print("NO")
return 0
elif S[-1] == "e":
if S[-5:] == "erase":
S = S[:-5]
else:
print("NO")
return 0
elif S[-1] == "r":
if S[-6:] == "eraser":
S = S[:-6]
elif S[-7:] == "dreamer":
S = S[:-7]
else:
print("NO")
return 0
else:
print("NO")
return 0
else:
print("YES")
main(input()) |
x, y = (int(s) for s in input().split())
while y > 0:
x, y = y, x % y
print(x) |
N = int(input())
if N % 2 ==1:
n = int((N+1)/2)
else:
n = int(N/2)
res = n/N
print(res) |
S= {char:list(input()) for char in 'abc'}
turn = 'a'
while S[turn]:
turn = S[turn].pop(0)
print(turn.upper()) |
def xor_sum(a):
if a == 0 or a == 1:
return a
elif a == 2:
return 3
elif a == 3:
return 0
else:
b = bin(a)[2:]
if a % 2 == 0:
return 2**(len(b)-1) + xor_sum(a % 2**(len(b)-1))
else:
return xor_sum(a % 2**(len(b)-1))
def main():
A,B = map(int,input().split())
a,b = xor_sum(max(0,A-1)),xor_sum(B)
print(a ^ b)
if __name__ == "__main__":
main()
|
def is_ok1(a,b,c):
return L[b] < L[c] + L[a]
def is_ok2(a,b,c):
return L[c] < L[a] + L[b]
def meguru_bisect(ng, ok, is_ok, a, b):
'''
初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
まずis_okを定義すべし
ng ok は とり得る最小の値-1 とり得る最大の値+1
最大最小が逆の場合はよしなにひっくり返す
'''
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if is_ok(a, b, mid):
ok = mid
else:
ng = mid
return ok
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N):
for b in range(a+1, N):
ans += max(0, meguru_bisect(N, b, is_ok2, a, b)-meguru_bisect(b, N, is_ok1, a, b)+1)
print(ans)
|
A, B, C = input().split()
Answer = 'NO'
if A[-1] == B[0] and B[-1] == C[0]:
Answer = 'YES'
print(Answer) |
def main():
string = input()
print(string if len(string) == 2 else string[::-1])
if __name__ == '__main__':
main()
|
# https://atcoder.jp/contests/tenka1-2018-beginner/submissions/6799589
# combinationを使うところ
def main():
from itertools import combinations
N = int(input())
# {1,...,N}*2を分割
# k個の集合があって
# 各集合は他のk-1個の集合に対し共通要素を1個ずつ合わせてk-1個の要素をもつ
k = 1
while (k - 1) * k < N * 2:
k += 1
cond = (k - 1) * k == N * 2
if not cond:
print('No')
return
sets = tuple(set() for _ in range(k))
for common_component, (set_idx_1, set_idx_2) in enumerate(combinations(range(k), r=2), start=1):
sets[set_idx_1].add(common_component)
sets[set_idx_2].add(common_component)
print('Yes')
print(k)
for set_ in sets:
print(len(set_), *set_)
if __name__ == '__main__':
main()
|
def main():
from collections import deque
from operator import itemgetter
s = input()
tot = 0
areas = []
dq = deque()
for i, c in enumerate(s):
# print(c, end='')
if c == '\\':
dq.append(i)
elif c == '/':
if dq:
j = dq.pop()
a = i - j
tot += a
while areas and areas[-1][0] > j:
a += areas.pop()[1]
areas.append((i, a))
print(tot)
print(len(areas), *map(itemgetter(1), areas))
if __name__ == '__main__':
main()
|
S = input()
ans = "No"
for i in range(len(S)-1):
if S[i:i+2] == "AC":
ans = "Yes"
print(ans) |
W, H, x, y = map(int, input().split())
area = W * H / 2
multi = x * 2 == W and y * 2 == H
print(area, 1 if multi else 0) |
while True:
l = input().split()
a = int(l[0])
o = l[1]
b = int(l[2])
if o =='?':
break
if o == '+':
print( '%d'%(a+b))
elif o == '-':
print('%d'%(a-b))
elif o =='*':
print('%d'%(a*b))
else:
o =='/'
print('%d'%(a//b))
|
import math
a,b,x = map(int,input().split())
if x <= a*a*b/2:
print(math.atan((a*b*b/2/x))*180/math.pi)
else:
print(math.atan((a*a*b-x)/(a**3)*2)*180/math.pi) |
s = input()
t = input()
s_len = len(s)
is_yes = False
rotate_s = s
for i in range(s_len):
if(rotate_s == t):
is_yes = True
break
rotate_s = rotate_s[-1] + rotate_s[:s_len - 1]
if(is_yes):
print("Yes")
else:
print("No") |
n = int(input())
s = set(map(str, input().split()))
print("Three" if len(s) == 3 else "Four") |
s = input()
flag = 0
for i in range(len(s)):
if flag == 0 and s[i] == "C":
flag += 1
if flag == 1 and s[i] == "F":
flag += 1
if flag == 2:
print("Yes")
else:
print("No") |
s = input()
print('YES') if (s.count('o')+15-len(s) >= 8) else print('NO') |
input_line = raw_input().split()
a = int(input_line[0])
b = int(input_line[1])
print a/b,
print a%b,
print ('%.5f' % (float(a)/float(b))) |
n=input()
k=0
for m in n:
k += int(m) % 9
print("Yes" if k % 9 == 0 else "No")
|
# coding=utf-8
class Dice(object):
def __init__(self, label):
self.label = label
def _rotateS(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s5, s1, s3, s4, s6, s2]
def _rotateN(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s2, s6, s3, s4, s1, s5]
def _rotateE(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s4, s2, s1, s6, s5, s3]
def _rotateW(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s3, s2, s6, s1, s5, s4]
def rotate(self, r):
if r == 'S':
self._rotateS()
elif r == 'N':
self._rotateN()
elif r == 'E':
self._rotateE()
elif r == 'W':
self._rotateW()
else:
print 'Cannot rotate into ' + r + 'direction.'
def _spinPos(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s1, s4, s2, s5, s3, s6]
def _spinNeg(self):
s1, s2, s3, s4, s5, s6 = self.label
self.label = [s1, s3, s5, s2, s4, s6]
def getTopLabel(self):
return self.label[0]
def match(self, top, front):
iTop = self.label.index(top) + 1
if iTop == 1:
pass
elif iTop == 2:
self._rotateN()
elif iTop == 3:
self._rotateW()
elif iTop == 4:
self._rotateE()
elif iTop == 5:
self._rotateS()
else:
self._rotateS()
self._rotateS()
iFront = self.label.index(front) + 1
if iFront == 2:
pass
elif iFront == 3:
self._spinNeg()
elif iFront == 4:
self._spinPos()
elif iFront == 5:
self._spinPos()
self._spinPos()
if __name__ == '__main__':
d = Dice(map(int, raw_input().split()))
n = input()
for _ in xrange(n):
top, front = map(int, raw_input().split())
d.match(top, front)
print d.label[2] |
from collections import deque
a = deque(reversed(input()))
b = deque(reversed(input()))
c = deque(reversed(input()))
ne = a.pop()
while(True):
if ne == 'a':
if not a: break
ne = a.pop()
elif ne == 'b':
if not b: break
ne = b.pop()
else:
if not c: break
ne = c.pop()
print(ne.upper()) |
def bubble_sort(A, n):
flag = 1
i = 0
count = 0
while flag:
flag = 0
for j in range(n-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = 1
count += 1
i += 1
print(' '.join(map(str, A)))
print(count)
if __name__ == '__main__':
n = int(input())
A = list(map(int, input().split()))
bubble_sort(A, n) |
List = [input() for _ in range(3)]
for i in range(3):
print(List[i][i],end="")
print("\n",end="") |
from math import floor
n = int(input())
def debt(week):
debt = 100000
for i in range(1,n+1):
debt *= 1.05
amari = debt % 1000
if amari:
debt += 1000 - amari
return int(debt)
print(debt(n)) |
N = int(input())
s = list(input())
R_count = s.count("R")
if R_count > N // 2:
print("Yes")
else:
print("No") |
c_1 = list(input())
c_2 = list(input())
if (c_1[0] == c_2[2] and c_1[1] == c_2[1] and c_1[2] == c_2[0]):
print('YES')
else:
print('NO') |
from math import gcd
k = int(input())
ans = 0
for x in range(1,k+1):
for y in range(1,k+1):
for z in range(1,k+1):
ans += gcd(gcd(x,y),z)
print(ans)
|
s =input()
ans = []
for i in range(len(s)):
if (s[i] == '0') or (s[i] == '1'):
ans.append(s[i])
elif ans ==[]:
continue
else:
ans.pop()
print(''.join(ans)) |
s=input()
for i,j in zip(s[:-1],s[1:]):
if i+j=="AC":
print("Yes")
exit()
print("No") |
N = int(input())
for i in range(1, 9 + 1):
if N % i == 0 and N / i <= 9:
result = "Yes"
break
else:
result = "No"
print(result) |
num=list(map(int,input().split()))
num.sort()
print('Yes' if num[2]==(num[0]+num[1]) else 'No') |
#塩基を入力
base = input()
"AとTのペアで出力、CとGのペアで出力"
if base == "A":
print("T")
elif base == "T":
print("A")
elif base == "C":
print("G")
#AでもTでもCでもなければGなのでCを出力
else:
print("C") |
y1_list = list(map(int,input().split()))
y2_list = list(map(int,input().split()))
y3_list = list(map(int,input().split()))
L = [y1_list,y2_list,y3_list]
a1 = list()
a2 = list()
b1 = list()
b2 = list()
for i in range(3):
a1.append(y1_list[i] - y2_list[i])
a2.append(y2_list[i] - y3_list[i])
if (a1[0] == a1[1] and a1[2] == a1[0]):
if (a2[0] == a2[1] and a2[2] == a2[0]):
print("Yes")
else:
print("No")
else:
print("No") |
n = int(input())
for i in range(n):
a = int(input())
if a %2 != 0:
print('first')
exit()
print('second') |
l = [2, 1]
for i in range(2, int(input()) + 1):
l.append(l[len(l) - 1] + l[len(l) - 2])
print(l[len(l) - 1]) |
N = int(input())
X = 1
while(True):
if X * 2 > N:
print(X)
exit()
X *= 2 |
import sys
arr = []
for i in sys.stdin:
arr.append(int(i))
arr.sort()
arr.reverse()
for i in range(3):
print(arr[i]) |
s=input()
t=input()
d=dict()
flag=True
ds=set()
for i in range(len(s)):
if not(t[i] in d):
if s[i] in ds:
flag=False
break
d[t[i]]=s[i]
ds.add(s[i])
else:
if d[t[i]]!=s[i]:
flag=False
break
if flag:
print("Yes")
else:
print("No") |
# B - KEYENCE String
def is_keyence_string():
for i in range(1, len(key)):
left = key[:i]
right = key[i-len(key):]
if S.startswith(left) and S.endswith(right):
return True
return False
S = input().strip()
key = 'keyence'
if S.startswith(key):
print('YES')
elif S.endswith(key):
print('YES')
elif is_keyence_string():
print('YES')
else:
print('NO') |
X = int(input())
num_500 = X // 500
amari = X % 500
num_5 = amari // 5
print(1000 * num_500 + 5 * num_5)
|
def gcd(x, y):
if x < y:
tmp = x
x = y
y = tmp
while y > 0:
r = x % y
x = y
y = r
return print(x)
x_y = input()
tmp = list(map(int, x_y.split()))
x = tmp[0]
y = tmp[1]
gcd(x, y)
|
n=int(input())
x=int(n/1.08)
if int(x*1.08)==n:
print(x)
elif int((x+1)*1.08)==n:
print(x+1)
else:
print(':(') |
W=input()
T=[]
while 1:
a=input()
if'END_OF_TEXT'==a:break
T+=[s.lower() for s in a.split()]
print(T.count(W)) |
n = input()
l = list(map(int, input().split()))
odd = list(filter(lambda x: (x % 2 != 0), l))
if len(odd)%2==0:
print("YES")
else:
print("NO") |
x=int(input())
X=x%100
Y=x//100
if X>5*Y:
print('0')
else:
print('1') |
# https://atcoder.jp/contests/abc043/tasks/abc043_b
"""
双方向キューをつかって実装する
このどれかの操作ができる
* 0 をキューに入れる
* 1 をキューに入れる
* キューの最後のものを出す
注意: キューが空の場合にバックスペースをしても何も起きないようにする
"""
from collections import deque
q = deque()
s = input()
for operation in s:
if operation == "0":
# 右端に0を追加
q.append("0")
elif operation == "1":
# 右端に1を追加
q.append("1")
elif operation == "B":
# バックスペース
# 右端を一つ削除
# q の中身が空でもエラーにならないように例外処理
try:
q.pop()
except IndexError:
pass # 何もしない
# キューの中身を順番に取り出して文字列に変換
answer = ""
for i in q:
answer = answer + i
print(answer)
|
from math import *
def solve(x,y,ans=1):
if x*2 > y:
return ans
else:
return solve(x*2,y,ans+1)
X,Y = map(int,input().split())
print(solve(X,Y)) |
def g(a,b):
if a*b:
if a>b:
return g(a-b,b)
elif(a<b):
return g(a,b-a)
else:
return a
else:
if(a*b):
return max(a,b)
else:
return 1
n=int(input())
print(360//g(n,360)) |
def get_caps(a):
dic = dict()
for ai in a:
dic.setdefault(ai, 0)
dic[ai] += 1
return dic
def is_match(caps):
global N
if 0 in caps.keys():
if caps[0] == N:
return True
if N % 3 == 0:
if 0 in caps.keys() and len(caps) == 2:
if caps[0] == N//3:
return True
elif len(caps) == 3:
x, y, z = caps.keys()
if x ^ y ^ z == 0:
if caps[x] == caps[y] == caps[z] == N//3:
return True
# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))
# 帽子の情報をdictに入れる
caps = get_caps(a)
if is_match(caps):
print('Yes')
else:
print('No') |
from collections import deque
que = deque([])
n = int(input())
for i in range(0, n):
a = input()
if a == 'deleteFirst':
que.popleft()
# print(a)
# print(que)
elif a == 'deleteLast':
que.pop()
# print(a)
# print(que)
else:
a, b = a.split()
b = int(b)
if a == 'insert':
que.appendleft(b)
# print('{0} {1}'.format(a,b))
# print(que)
elif a == 'delete':
if que.count(b) != 0:
que.remove(b)
# print('{0} {1}'.format(a, b))
print(*que)
#while not len(que) == 0:
# if len(que) == 1:
# print(que.pop())
# else:
# print(que.pop(), end=' ')
|
# N回目のコンテストの名前の最初の3文字を出力
N = int ( input ( ) )
if 1 <= N <= 999:
print("ABC")
elif 1000 <= N <= 1998:
print("ABD")
else:
print("入力ミス") |
cnt = 0
zorome = 0
num = int(input())
while cnt < num:
mass = input().split()
if(mass[0] == mass[1]):
zorome += 1
if(zorome >= 3):
break
else:
zorome = 0
cnt += 1
print("Yes" if zorome >= 3 else "No")
|
def main():
cost_list = [int(input()) for _ in range(5)]
amari_list = [cost % 10 for cost in cost_list]
last_order = 0
min_amari = 10
for index, amari in enumerate(amari_list):
if amari == 0:
continue
if amari < min_amari:
min_amari = amari
last_order = index
ans = 0
for index, cost in enumerate(cost_list):
if index == last_order:
ans += cost_list[index]
else:
if cost % 10 == 0:
ans += cost
else:
cost = (cost // 10 + 1) * 10
ans += cost
print(ans)
if __name__ == "__main__":
main()
|
S=input()
count=0
s=list(S)
for i in range(len(S)):
if (i+1)%2!=0:
if s[i]=='R' or s[i]=='U' or s[i]=='D':
count+=1
else:
if s[i]=='L' or s[i]=='U' or s[i]=='D':
count+=1
if count==len(S):
print('Yes')
else:
print('No') |
s = list(input())
for i in s:
if s.count(i) > 1:
print('no')
break
else:
print('yes')
|
s = str(input())
if len(s) == 2: print(s)
else: print(s[::-1]) |
def euclid(m,n):
while m%n>0:
m,n=n , m%n
else:
return n
x,y = map(int,raw_input().split())
if x < y:
x,y = y,x
print euclid(x,y) |
n = int(input())
for i in range(1, n + 1):
x = i
if x % 3 == 0:
print(" ", i, sep="", end="")
else:
while x > 0:
if x % 10 == 3:
print(" ", i, sep="", end="")
break
x //= 10
print() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.