problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03127
s317545679
Accepted
import fractions n = int(input()) a = list(map(int,input().split())) ans = fractions.gcd(a[0],a[1]) for i in range(2,n): ans = fractions.gcd(ans,a[i]) print(ans)
p03624
s320022668
Accepted
s = input() alps = 'abcdefghijklmnopqrstuvwxyz' for alp in alps: if alp not in s: print(alp) break else: print('None')
p03730
s443149211
Accepted
import fractions a,b,c = map(int, input().split()) gab = fractions.gcd(a, b) gbc = fractions.gcd(gab,c) if gab ==1: print("YES") exit() if c ==0: print("YES") exit() if gbc == gab: print("YES") exit() print("NO")
p02780
s391851428
Accepted
n,k=map(int,input().split()) p=list(map(int,input().split())) a=[] b=[0]*n q=0 for i in range(n): a.append((1/2)*(p[i]+1)) for j in range(k): q+=a[j] b[0]=q for l in range(1,n-k+1): b[l]=b[l-1]-a[l-1]+a[k+l-1] print(max(b))
p03998
s706488620
Wrong Answer
A = input() B = input() C = input() i = "a" player = {"a":A,"b":B,"c":C} while True: l = player[i][0] player[i] = player[i][1:] if len(player[i])==0: print(i.upper()) break i = l
p03137
s385887265
Accepted
N, M = map(int, input().split()) X = list(map(int, input().split())) X.sort() diff_X = [] for i in range(M-1): tmp = X[i+1] - X[i] diff_X.append(tmp) diff_X.sort(reverse=True) ans = sum(diff_X[N-1:]) print(ans)
p02801
s479118472
Accepted
c=str(input()) a='abcdefghijklmnopqrstuvwxyz' b=a.find(c) print(a[b+1])
p02577
s083037118
Accepted
N=input() i=0 for n in N: i+=int(n) if i%9==0: print("Yes") else: print("No")
p02993
s933741857
Accepted
s = list(input()) if s[0] == s[1] or s[1] == s[2] or s[2] ==s[3]: print("Bad") else: print("Good")
p02939
s834582012
Accepted
S = input() count = 0 passFlag = False for x in range(len(S)): if x == 0: count = 1 prev = S[0] else: if passFlag: passFlag = False count += 1 else: if S[x] == prev: prev = S[x:x + 2] passFlag = True else: prev = S[x] count += 1 print(count)
p02819
s591744441
Accepted
from math import sqrt X=int(input()) def checkprime(x): for i in range(1,int(sqrt(x))+1,2): #print(i) if i == 1: continue if X%i==0: return False return True if X<=2: print(X) exit() if X%2==0: X+=1 while(1): if checkprime(X): print(X) break else: X+=2
p03262
s521988888
Accepted
from math import gcd n,x = map(int,input().split()) l = list(map(int,input().split())) for i in range(n): l[i] = abs(l[i] - x) d = l[0] for i in range(1,n): d = gcd(d,l[i]) print(d)
p03286
s487164460
Accepted
N=int(input()) if N >= 0: n = N i = 0 while 1: b = bin(n)[2:] if i >= len(b): break if i % 2 == 1 and b[-i-1]=='1': n += 2**(i+1) i += 1 print(bin(n)[2:]) else: n = -N i = 0 while 1: b = bin(n)[2:] if i >= len(b): break if i % 2 == 0 and b[-i-1]=='1': n += 2**(i+1) i += 1 print(bin(n)[2:])
p04019
s938411546
Accepted
S = input() if ('W' not in S and 'E' not in S or 'W' in S and 'E' in S) and\ ('N' not in S and 'S' not in S or 'N' in S and 'S' in S): print('Yes') else: print('No')
p02780
s311515630
Accepted
def main(): N,K=map(int, input().split()) A = list(map(int, input().split())) S = (sum(A[0:K])+K)/2 S_max=S for i in range(K,N): S += A[i]/2 S -= A[i-K]/2 if S_max<S: S_max=S print(S_max) main()
p02818
s387159008
Accepted
A, B, K = map(int, input().split()) if A >= K: print(str(A - K) + ' ' + str(B)) else: print(str(0) + ' ' + str(max((B - (K - A)), 0)))
p02759
s630206360
Accepted
N=int(input()) if N%2==0: print(N//2) else: print(N//2+1)
p02790
s205941954
Accepted
a,b = map(int,input().split()) if a < b: print(str(a)*b) else: print(str(b)*a)
p03323
s650842085
Accepted
line = input() num_a, num_b = [int(n) for n in line.split()] is_it_possible = "Yay!" if num_a > 8 or num_b > 8: is_it_possible = ":(" print(is_it_possible)
p02882
s075766207
Accepted
import math A, B, X = map(int, input().split()) h = X / (A*A) r = 0 deg = 0 if (2 * X) - (B * A * A) > 0: r = math.atan(2 * (B-h) / A) elif (2 * X) - (B * A * A) == 0: r = math.atan(B / A) else: h = (2 * X) / (A * B) r = math.atan(B / h) deg = math.degrees(r) print(deg)
p03862
s218003140
Accepted
n,x,*a=map(int,open(0).read().split());t=r=0 for i in a:t=min(i,x-t);r+=i-t print(r)
p03565
s898875356
Accepted
def is_word(i): # T文字の長さを切り取り sub_S = S[i:i+len(T)] for s, t in zip(sub_S, T): if s == "?": continue if s != t: return False return True S = input() rep_S = S.replace("?", "a") T = input() word_L = [] for i in range(len(S)-len(T)+1): if is_word(i): s = rep_S[:i] + T + rep_S[i+len(T):] word_L.append(s) ans = "UNRESTORABLE" if word_L: ans = sorted(word_L)[0] print(ans)
p03803
s701919785
Accepted
a,b = map(int, input().split()) if a==1 and b!=1: print("Alice") elif a!=1 and b==1: print("Bob") elif a==1 and b==1: print("Draw") elif a>b: print("Alice") elif a<b: print("Bob") else: print("Draw")
p03264
s501910348
Accepted
K = int(input()) numO = K//2 numE = (K+1)//2 print(numO*numE)
p02916
s906032231
Accepted
def main(): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) ans = sum(b) for i in range(n-1): if a[i] + 1 == a[i+1]: ans += c[a[i] - 1] print(ans) main()
p02695
s106703338
Wrong Answer
A,B,N = map(int, input().split()) if B > N: res = (A*N//B)-A*(N//B) else: N = N - N%B - 1 res = (A*N//B)-A*(N//B) print(res)
p03150
s716726936
Accepted
s=input() for i in range(len(s)): for j in range(i, len(s)+1): if s[:i]+s[j:]=='keyence': print('YES') exit() print('NO')
p02723
s822016316
Wrong Answer
S = input() if S[2] == S[3] and S[4] == S[4]: print("Yes") else: print("No")
p03380
s759582927
Wrong Answer
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) def binary(l,i): r=N-1 while l<=r: m=(l+r)//2 if A[m]==i: return A[m] elif A[m]>i: r=m-1 else: l=m+1 x=abs(A[m]-i) for j in range(max(0,m-2),min(m+3,N)): if x >= abs(A[j]-i): res = A[j] x=abs(A[j]-i) return res print(A[0],binary(1,A[0]/2))
p03282
s573771480
Accepted
S = input() K = int(input()) output = '' if len(S) <= K: for letter in S: if letter != '1': output = letter break else : for i in range(K): if S[i] != '1': output = S[i] break if output: print(output) else : print('1')
p03087
s346707475
Accepted
N, Q = map(int, input().split()) S = input().rstrip() cnt = 0 tmp = 0 res = [0]*N for i, s in enumerate(S): if s == "A": tmp = 1 elif s=="C" and tmp == 1: tmp = 0 cnt += 1 else: tmp = 0 res[i] = cnt for _ in range(Q): l, r = map(int, input().split()) l -= 1 r -= 1 print(res[r] - res[l])
p02831
s030865413
Accepted
import math a, b = map(int, input().split()) print((a*b)//math.gcd(a, b))
p02695
s198070215
Accepted
import itertools n, m, q = map(int, input().split()) alist = [list(map(int,input().split())) for i in range(q)] comb = list(set(itertools.combinations_with_replacement(range(1, m + 1), n))) # print(comb) res = 0 for c in comb: tmp_score = 0 for a in alist: if c[a[1]-1] - c[a[0]-1] == a[2]: tmp_score += a[3] res = max(res, tmp_score) print(res)
p04011
s651024209
Wrong Answer
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) print(int(K*X+max((N-K),0)*Y))
p02880
s271019283
Accepted
n = int(input()) ans = {i*j for i in range(1,10) for j in range(1,10)} if n in ans:print("Yes") else:print("No")
p03761
s703821842
Wrong Answer
import collections n = int(input()) s = list(input() for _ in range(n)) sl = [] s1 = set(list(s[0])) for i in range(1, n-1): tmp = set(list(s[i])) sl = s1 & tmp sl = list(sl) sl.sort() d = [51] * len(sl) for i in range(len(sl)): for j in s: d[i] = min(j.count(sl[i]), d[i]) ans = str() for i, a in enumerate(sl): ans += a * d[i] print(ans)
p03359
s361911793
Accepted
a,b=map(int,input().split());print(a-1 if a>b else a)
p03331
s892255123
Accepted
N = int(input()) ans = float('inf') for i in range(1, N): j = N-i i_str = str(i) j_str = str(j) i_sum, j_sum = 0, 0 for p in range(len(i_str)): i_sum += int(i_str[p]) for q in range(len(j_str)): j_sum += int(j_str[q]) ans = min(ans, i_sum+j_sum) print(ans)
p03069
s645547028
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N = int(input()) S = input().rstrip() lb = [0] * (N+1) for i, c in enumerate(S, 1): lb[i] = lb[i-1] + (1 if c=='#' else 0) ans = N + 100 bl = lb[-1] for i in range(N+1): j = i+1 left = lb[i] right = N - i - (bl - lb[i]) ans = min(ans, left+right) print(ans)
p02835
s406713294
Accepted
A = map(int, input().split()) print('win' if sum(A)<22 else 'bust')
p02730
s171484106
Accepted
S = input() H = len(S)//2 if S[:H] == S[-H:] == S[-H:][::-1]: print("Yes") else: print("No")
p02577
s865193976
Accepted
n = input() ans = 0 for i in n: ans += int(i) if ans % 9 == 0: print('Yes') else: print('No')
p03612
s861474049
Accepted
N = int(input()) P = list(map(int,input().split())) cnt = 0 is_continue = False for i in range(N): if (i + 1) == P[i]: cnt += 1 if is_continue: cnt -= 1 is_continue = False else: is_continue = True else: is_continue = False print(cnt)
p03838
s663732100
Accepted
x,y = map(int,input().split()) ch = max(abs(x),abs(y)) - min(abs(x),abs(y)) if x <= 0 and y == 0 or x == y or x == 0 and y > 0: print(ch) elif x*y <= 0: print(ch+1) elif x*y >= 0 and x >= y: print(ch+2) else: print(ch)
p02939
s453746871
Accepted
S = input() N = len(S) a = [0]*(N+1) b = ['']*(N+1) s = '' for i in range(1, N+1): s += S[i-1] b[i] = s if s != b[i-1]: a[i] = a[i-1]+1 s = '' else: a[i] = a[i-1] print(a[N])
p03472
s607866744
Wrong Answer
n,h=map(int,input().split()) A,B=[0]*n,[0]*n for i in range(n): A[i],B[i]=map(int,input().split()) A_max=max(A) B.sort(reverse=True) ans=0 for i in B: if i > A_max: h-=i ans+=1 else:break if h<0: h=0 q = h / A_max p = q % 1 ans += int(q) if p>0: print(ans+1) else: print(ans)
p03387
s636421130
Accepted
A, B, C = map(int, input().split()) A, B, C = sorted([A, B, C]) if (A + B + C) % 2 == (C * 3) % 2: ans = (C - A + C - B) // 2 else: ans = (C + 1 - A + C - B) // 2 + 1 print(ans)
p03774
s107545960
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n, m = map(int, readline().split()) ab = [list(map(int, readline().split())) for _ in range(n)] cd = [list(map(int, readline().split())) for _ in range(m)] for i in ab: l = [] for j in cd: distance = abs(i[0]-j[0])+abs(i[1]-j[1]) l.append(distance) print(l.index(min(l)) + 1)
p03038
s674154206
Accepted
from bisect import bisect_left N, M = map(int, input().split()) d = dict() A = list(map(int, input().split())) for i in range(N): d[A[i]] = d.get(A[i], 0) + 1 for i in range(M): B, C = map(int, input().split()) d[C] = d.get(C, 0) + B ans = 0 keys = sorted(list(d.keys()), reverse = True) for k in keys: kosuu = min(N, d.get(k)) ans += k * kosuu N -= kosuu if N == 0: break print(ans)
p02714
s445780722
Accepted
N=int(input()) s=input() rcnt=s.count("R") gcnt=s.count("G") bcnt=s.count("B") sum=rcnt*gcnt*bcnt#条件1を満たす組み合わせの数 for i in range(N): for d in range(N): j=i+d k=j+d if k>=N: break if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:#等間隔の組み合わせを除く sum-=1 print(sum)
p02900
s399386721
Accepted
import math A,B = map(int,input().split()) Anum=[] Bnum=[] for i in range(2,int(math.sqrt(A)+1)): while A % i ==0: A //= i if i not in Anum: Anum.append(i) if A!=1: Anum.append(A) for i in range(2,int(math.sqrt(B)+1)): while B % i ==0: B //= i if i not in Bnum: Bnum.append(i) if B!=1: Bnum.append(B) ABnum=set(Anum) & set(Bnum) print(len(ABnum)+1)
p02829
s925939794
Accepted
a=int(input()) b=int(input()) print(6-a-b)
p03109
s356916050
Wrong Answer
s = input() if s == "2019/04/30": print("Heisei") else: print("TBD")
p02835
s243585006
Accepted
a1, a2, a3 = map(int, input().split()) if a1 + a2 + a3 >= 22: print('bust') else: print('win')
p02694
s191046503
Accepted
x=int(input()) a=100 ans=0 while a<x: a*=101/100 a=int(a) ans+=1 print(ans)
p03437
s663517187
Accepted
X, Y = map(int, input().split()) if X % Y == 0: print(-1) else: print(X)
p02724
s918298962
Wrong Answer
x = int(input()) num_500 = int(x / 500) amari = x - num_500 num_5 = int(amari / 5) print(1000 * num_500 + 5 * num_5)
p04019
s597839091
Accepted
def solve(s): for dirs in ('NS', 'SN', 'EW', 'WE'): d, o = dirs[0], dirs[1] if d in s and o not in s: return False return True s = input() print('Yes' if solve(s) else 'No')
p03371
s777227041
Wrong Answer
A, B, C, X, Y = map(int, input().split()) ans = 0 for i in range(X): for j in range(Y): for k in range(X+Y, 2): if i+k/2==X and j+k/2==Y: ans = min(ans, A*i+B*j+C*k) print(ans)
p02701
s368814113
Accepted
s = set() for _ in range(int(input())): a = input() s.add(a) print(len(s))
p02712
s430587065
Wrong Answer
n = int(input()) n3 = n/3 n5 = n/5 n15 = n/15 def sum(k): return k*(k+1)/2 ans = sum(n)+15*sum(n15)-3*sum(n3)-5*sum(n5) print(int(ans))
p02786
s193740986
Accepted
H = int(input()) res = 0 cnt = 1 while H > 0: H = H // 2 if res == 0: res = 1 else: cnt *= 2 res += cnt print(res)
p02641
s269125033
Wrong Answer
def solve(x, ls): y = 0 m = x for i in range(1, 102): if i in ls: continue if abs(x - i) < m: y = i m = abs(x - i) return y def main(istr, ostr): x, n = list(map(int, istr.readline().strip().split())) ls = list(map(int, istr.readline().strip().split())) result = solve(x, ls) print(result, file=ostr)
p03761
s131548259
Wrong Answer
def main(): n = int(input()) ans = "" dics = [] az = "abcdefghijklmnopqrstuwvxyz" for i in range(n): dic = {} s = input() for c in az: dic[c] = s.count(c) dics.append(dic) for c in az: can_use = True m = 50 for dic in dics: if dic[c] == 0: can_use = False break m = min(m, dic[c]) if(can_use): ans += c * m print(ans) if __name__ == "__main__": main()
p02786
s422654704
Accepted
import math H=int(input()) a=H ans=1 while a>1: a=math.floor(a/2) ans+=1 Ans=2**(ans) print(Ans-1)
p02729
s651372661
Accepted
n, m = map(int, input().split()) #nC2 #mC2 ans = 0 if n >= 2: ans += n*(n-1)//2 if m >= 2: ans += m*(m-1)//2 print(ans)
p03760
s303511271
Wrong Answer
o = input() e = input() for s, t in zip(o, e): print(s, t, sep='', end='')
p03730
s306849645
Wrong Answer
A,B,C = map(int,input().split()) if A % B == C - 1: print("NO") else: print("YES")
p03681
s419493312
Wrong Answer
hoge = 10 ** 9 + 7 def test(): n, m = map(int, input().split()) if abs(n-m) > 1: print(0) exit() i_n = n i_m = m np = 1 mp = 1 while True: np = np * i_n mp = mp * i_m i_n -= 1 i_m -= 1 if i_n < 1: i_n = 1 if i_m < 1: i_m = 1 if i_n == 1 and i_m == 1: break s = 1 r = (mp % hoge) * (np % hoge) * (s % hoge) print(r) if __name__ == '__main__': test()
p03994
s922204942
Accepted
S=list(input()) K=int(input()) N=len(S) for i in range(N): if S[i]=="a": continue sa=ord("z")-ord(S[i])+1 if sa<=K: K-=sa S[i]="a" if K!=0: K%=26 S[i]=chr(ord(S[i])+K) print("".join(S))
p03817
s202809791
Accepted
x = int(input()) tmp1 = x//11 tmp2 = x%11 ans = 2*tmp1 if tmp2 > 6: ans += 2 elif tmp2 > 0: ans += 1 print(ans)
p02629
s640892828
Wrong Answer
n=int(input()) ans='' while n>0: ans+=chr(ord('a')+n%26-1) n=n//26 print(ans[::-1])
p02615
s668851778
Accepted
def main(): N=int(input()) A=sorted([int(_) for _ in input().split()])[::-1] ans = A[0] if N==2: print(ans) else: for i in range(1, N//2): ans += A[i]*2 if N%2: ans += A[N//2] print(ans) main()
p02701
s391951350
Accepted
import collections n=int(input()) l=[input() for i in range(n)] c=collections.Counter(l) print(len(c))
p03162
s099428381
Accepted
N = int(input()) a,b,c = [],[],[] for n in range(N): a_,b_,c_ = map(int, input().split()) a.append(a_) b.append(b_) c.append(c_) do_a = [a[0]] #do a in n-th day do_b = [b[0]] #same do_c = [c[0]] for day in range(1,N): do_a.append(a[day] + max(do_b[day-1], do_c[day-1])) do_b.append(b[day] + max(do_a[day-1], do_c[day-1])) do_c.append(c[day] + max(do_a[day-1], do_b[day-1])) print(max(do_a[N-1],do_b[N-1], do_c[N-1]))
p02753
s486552064
Accepted
s = input() if s[0] == s[1] and s[1] == s[2]: print("No") else: print("Yes")
p03408
s456356976
Accepted
N=int(input()) s=[input() for i in range(N)] M=int(input()) t=[input() for i in range(M)] def ans091(N:int, s:list, M:int, t:list): test_count=0 own=list(set(s)) for i in range(len(own)): if test_count<=s.count(own[i])-t.count(own[i]): test_count=s.count(own[i])-t.count(own[i]) if test_count>0: return test_count else: return 0 print(ans091(N,s,M,t))
p03309
s493483208
Accepted
N = int(input()) A = list(map(int, input().split())) ai = [] for i in range(N): ai.append(A[i] - (i + 1)) # print(ai) ai.sort() # Nの偶奇に依らず、中央値はこのように表せることが知られている med = ai[N // 2] ans = 0 for i in range(N): tmp = abs(ai[i] - med) ans += tmp print(ans)
p03013
s040807313
Accepted
n,m=map(int,input().split()) a=[int(input()) for i in range(m)] d=[1]*(n+1) for i in range(m): d[a[i]]=0 for i in range(2,n+1): if d[i]!=0: d[i]=d[i-1]+d[i-2] print(d[n]%(10**9+7))
p02910
s425522177
Accepted
S=input() if all(a!="L" for a in S[::2]) and all(a!="R" for a in S[1::2]): print("Yes") else: print("No")
p03699
s986062652
Accepted
n = int(input()) s = [] for _ in range(n): i = int(input()) s.append(i) s.sort() ans = sum(s) if ans % 10 == 0: for i in s: if i % 10 != 0: ans -= i print(ans) break else: print(0) else: print(ans)
p03087
s764138454
Accepted
N, Q = map(int, input().split()) S = input() t = [0 for i in range(N)] for i in range(N-1): if S[i] == 'A' and S[i+1] == 'C': t[i+1] = t[i] + 1 else: t[i+1] += t[i] for i in range(Q): l, r = map(int, input().split()) print(t[r-1] - t[l-1])
p02911
s890707345
Accepted
import sys input = sys.stdin.readline n,k,q=map(int,input().split()) point=[0]*n for a in range(q): a=int(input()) point[a-1]+=1 #print(point) for i in point: if i>q-k: print("Yes") else: print("No")
p03071
s222358540
Accepted
x=list(map(int,input().split())) if x[0]==x[1]: print(sum(x)) else: print(sum(list(range(min(x),max(x)+1))[-2:]))
p03962
s861517258
Accepted
abc = list(map(int, input().split())) ans = len(set(abc)) print(ans)
p03285
s535993556
Accepted
n = int(input()) a = 'No' for i in range(100): for j in range(100): if n == 4*i + 7*j : a = 'Yes' print(a)
p03250
s398783207
Accepted
l = sorted(list(map(int, input().split())), reverse = True) print(l[0] * 10 + l[1] + l[2])
p03827
s727698993
Accepted
N = int(input()) s = input() length = len(s) tmp = 0 ans = 0 for i in range(length): if s[i] == 'I': tmp += 1 if tmp > ans: ans = tmp else: tmp -= 1 print(ans)
p03254
s664437682
Wrong Answer
num_children, num_snacks = list(map(int, input().split(' '))) children = list(map(int, input().split(' '))) children.sort() print(children) count = 0 for i in range(num_children+1): if num_snacks >= sum(children[:i+1]): count += 1 else: break print(count)
p02958
s456083419
Accepted
a=int(input()) l=list(map(int,input().split())) t=[] b=[] for x in range(1,a+1): t.append(x) for x in range(a): b.append( l[x]==t[x]) if b.count(True)==a:print("YES") elif b.count(False)!=2:print("NO") else: fi=b.index(False) li=b.index(False,fi+1) tmp=l[fi] l[fi]=l[li] l[li]=tmp b.clear() for x in range(a): b.append( l[x]==t[x]) if b.count(True)==a:print("YES") else:print("NO")
p02552
s799059125
Wrong Answer
data = int(input()) print(data)
p02778
s155374119
Wrong Answer
s = [input()] for i in s: s = i S = "".join(s) print(S)
p03163
s506826382
Wrong Answer
n, w = map(int ,input().split()) items = [] for i in range(n): array = list(map(int, input().split())) items.append(array) dp = [[0 for _ in range(w+1)] for _ in range(n+1)] for i in range(1, n+1): weight = items[i-1][0] for j in range(weight, w+1): dp[i][j] = max((dp[i - 1][j - weight] + items[i - 1][1]), dp[i - 1][j]) print(dp[-1][-1])
p02624
s801871096
Wrong Answer
import sys def _sum_ob_divisors(n): def f(n, x): y = n // x return y * (y + 1) * x / 2 return sum(f(n, i) for i in range(1, n + 1)) def sum_ob_divisors(f): n = int(f.read()) return _sum_ob_divisors(n) def main(): ans = sum_ob_divisors(sys.stdin.buffer) print(ans) if __name__ == '__main__': main()
p03854
s929548346
Wrong Answer
s=input().strip() s=s.replace("eraser","") s=s.replace("erase","") s=s.replace("dreamer","") s=s.replace("dream","") print("YES" if s else "NO")
p04019
s926155160
Accepted
s = input() if 'E' in s: if 'W' not in s: print('No') exit() if 'E' not in s: if 'W' in s: print('No') exit() if 'N' not in s: if 'S' in s: print('No') exit() if 'N' in s: if 'S' not in s: print('No') exit() print('Yes')
p03471
s827344380
Wrong Answer
N, Y = map(int, input().split()) # 合計値 y = 0 # 正解組み合わせがあった場合 exist_answer = False for i in range(N + 1): for j in range((N + 1) - i): k = N - (i + j) y = i * 10000 + j * 5000 + k * 1000 if y == Y: exist_answer = True print(i, j, k) if exist_answer is False: print(-1, -1, -1)
p02833
s752285474
Accepted
n=int(input()) if n%2: print(0) exit() ans=0 n//=2 while n>0: ans+=n//5 n//=5 print(ans)
p04031
s817450399
Accepted
N=int(input()) A_s =list(map(int,input().split())) from statistics import mean c_n =mean(A_s) c_n = round(c_n) cost = 0 for i in range(N): cost+=(A_s[i]-c_n)**2 print(cost)
p02766
s935498843
Accepted
n,k = map(int, input().split()) y = [] while n>=1: y.append(n%k) n = int(n/k) y.reverse() print(len(y))