problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02759
s035580852
Accepted
import math n = int(input()) print(math.ceil(n/2))
p03086
s218701101
Wrong Answer
s = input() c = [] x = ["A","G","C","T"] for i in range(0,len(s)-1): if(s[i] in x): t = 1 for j in range(i+1,len(s)): if(s[j] in x): t = t + 1 elif(s[j] not in x or j == len(s)): c.append(t) if(len(c)==0): c.append(0) print(max(c))
p03109
s912191334
Wrong Answer
s = list(map(int, input().split('/'))) if s[1] > 5: print('TBD') elif s[1] <= 4: print('Heisei')
p03407
s537207827
Wrong Answer
a, b, c = map(int, input().split()) if a+2*b>=c: print('Yes') else: print('No')
p02994
s457795986
Wrong Answer
N, L = map(int, input().split()) ans = 0 for i in range(1, N): ans += L + i print(ans)
p03427
s358134186
Accepted
import sys sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inm = lambda: map(int, sys.stdin.readline().split()) inl = lambda: list(inm()) ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) X = ins() def solve(): ans = sum([int(d) for d in X]) ans = max(ans, int(X[0]) - 1 + 9 * (len(X) - 1)) return ans print(solve())
p03962
s036624540
Accepted
colors = list(map(int, input().split())) ans = [] for i in colors: if not i in ans: ans.append(i) print(len(ans))
p02572
s732449162
Accepted
N = int(input()) A = list(map(int,input().split())) ans = 0 num = sum(A) for i in range(N - 1): num -= A[i] ans += A[i] * num print(ans % (10 ** 9 + 7))
p03095
s399625851
Accepted
from collections import defaultdict N = int(input()) S = input() mod = 10 ** 9 + 7 d = defaultdict(int) char = [chr(ord("a") + i) for i in range(26)] ans = 1 for s in S: d[s] += 1 for v in d.values(): ans *= v + 1 ans %= mod print(ans - 1)
p03345
s553440866
Wrong Answer
A, B, C, K = map(int, input().split()) print(A - B if K % 2 == 1 else B - A)
p02678
s831845210
Accepted
from collections import defaultdict, deque N, M = map(int, input().split()) edges = defaultdict(list) for _ in range(M): a, b = map(lambda x:int(x)-1, input().split()) edges[a].append(b) edges[b].append(a) go_to = [None] * N q = deque() q.append((0, -1)) is_visited = set() while q: node, prev = q.popleft() if node in is_visited: continue is_visited.add(node) go_to[node] = prev + 1 for dest in edges[node]: q.append((dest, node)) print('Yes') for i in range(1, N): print(go_to[i])
p02606
s278714357
Wrong Answer
import collections import sys a,b,c= map(int,input().split()) if c!=1: print(b//c-a//c) else: print(b-c+1)
p03644
s551910986
Accepted
def main(): n = int(input()) nums = [0] for i in range(1, n + 1): d = i count = 0 while d != 0: d, amari = divmod(d, 2) if amari != 0: break count += 1 nums.append(count) if n == 1: print(1) else: print(nums.index(max(nums))) if __name__ == '__main__': main()
p03720
s617695067
Wrong Answer
from collections import defaultdict n, m = map(int, input().split()) ans = defaultdict(int) for _ in range(m): a, b = map(int, input().split()) ans[a - 1] += 1 ans[b - 1] += 1 for _, v in sorted(ans.items()): print(v)
p02612
s378595043
Accepted
n = int(input()) ans = 1000-n%1000 if ans == 1000: ans = 0 print(ans)
p02676
s756453423
Accepted
#!/usr/bin/env python3 import sys import collections sys.setrecursionlimit(10 ** 7) # 1 ✕ 1 (int) K = int(input().rstrip()) # 1 ✕ 1 (str) S = input().rstrip() if len(S) > K: print(S[:K] + "...") else: print(S)
p02795
s496507051
Wrong Answer
input_list = [] for i in range(0, 3): input_list.append(int(input())) h = input_list[0] w = input_list[1] n = input_list[2] temp_num = 0 if w <= h: temp_num = h else: temp_num = w answer = 0 if n % temp_num == 0: answer = n / temp_num else: answer = (n // temp_num) + 1
p03043
s747345258
Accepted
n, k=map(int, input().split()) ans=0 for i in range(1, n+1): cnt=0 p=i while p<k: p*=2 cnt+=1 ans+=(1/2)**cnt print(ans*(1/n))
p02819
s547009524
Accepted
primes = [2] X = int(input()) def is_prime(n): for p in primes: if n < p * p: break if n % p == 0: return False return True for i in range(3, X, 2): if is_prime(i): primes.append(i) while True: if is_prime(X): print(X) break X += 1
p02708
s766143177
Wrong Answer
line=input() n,k=map(int,line.split()) sums=0 while k!=(n+2): if k==1: mini=1 if k>=2: mini=(((k)*(k-1))/2)%((10**9)+7) maxi=( (((n+1)*(n)) - ((n+1-k)*(n-k)) )/2 )%((10**9)+7) sums+=(maxi-mini+1) sums=sums%((10**9)+7) k+=1 print(int(sums))
p03475
s368229633
Wrong Answer
N = int(input()) C = [0]*N S = [0]*N F = [0]*N T = [0]*N for i in range(N-1): C[i], S[i], F[i] = map(int, input().split()) for j in range(N-1): T[j] = C[j] + S[j] for i in range(j, N-1): if T[j] >= S[i+1] or S[i+1] == 0: T[j] = T[j] + C[i+1] elif T[j] < S[i+1]: T[j] = S[i+1] T[N-1] = 0 for i in range(N): print(T[i])
p02627
s757122489
Wrong Answer
str = input() if str.isupper()=="TRUE": print("A") else: print("a")
p02696
s510493268
Accepted
A, B, N = map(int, input().split()) if N < B: print((A * N)//B) else: x = (N // B) * B - 1 print((A*x)//B - A*(x//B))
p03127
s213254295
Accepted
n,*a=map(int,open(0).read().split()) from fractions import gcd from functools import reduce print(reduce(gcd,a))
p03241
s157808587
Accepted
#!/usr/bin/env python3 n, m = map(int, input().split()) for i in reversed(range(1,m//n+1)): if m%i<1: print(i) exit()
p03657
s041579292
Wrong Answer
a,b = map(int,input().split()) if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0: print("possible") else: print("impossible")
p02675
s767313179
Accepted
import sys input = sys.stdin.readline def main(): m = N % 10 if m in [2, 4, 5, 7, 9]: print("hon") elif m in [0, 1, 6, 8]: print("pon") else: print("bon") if __name__ == "__main__": N = int(input()) main()
p02702
s307722606
Accepted
n = input() remainder = [0]*2019 remainder[0] += 1 x = 1 rem = 0 for i in range(1, len(n)+1): rem = (rem + int(n[-i])*x)%2019 remainder[rem] += 1 x *= 10 x %= 2019 res = 0 for e in remainder: res += e*(e-1)//2 print(res)
p03481
s164318989
Accepted
X,Y = map(int,input().split()) n = 0 ans = 0 while True: tmp = X * (2**n) if(tmp > Y): break else: ans += 1 n += 1 print(str(ans))
p03377
s841279233
Accepted
a,b,x = map(int,input().split()) if a <= x <= a+b: print("YES") else: print("NO")
p02642
s836860749
Wrong Answer
def divisor(n): d = [] for i in range(1, int(n ** 0.5) + 1): if n % i == 0: d.append(i) if i ** 2 == n: continue d.append(n // i) return d n = int(input()) A = list(map(int, input().split())) dup = [x for x in set(A) if A.count(x) > 1] A_dif = set(A) - set(dup) cnt = 0 for a in A_dif: tmp = set(divisor(a)) & set(A_dif) if len(tmp) == 1: cnt += 1 print(cnt)
p03251
s749141249
Accepted
N,M,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) x.append(X) y.append(Y) x.sort() y.sort() if x[-1]<y[0]: print('No War') else: print('War')
p02675
s502562195
Wrong Answer
A=input() x=A[-1] if x==3: print('bon') elif x==0 or 1 or 6 or 8: print('pon') else: print('hon')
p02596
s060905617
Accepted
K = int(input()) a = 0 for i in range(K): a = (10 * a + 7) % K if a % K == 0: print(i+1) exit() else: a %= K print(-1)
p02785
s661156768
Wrong Answer
n,k = map(int, input().split()) L = list(map(int,input().split())) ans = 0 S = sorted(L) print(S) for i in range(n): if k > 0: del S[-1] k = k-1 print(S) print(sum(S))
p04043
s291702572
Wrong Answer
A=list(map(int,input().split())) A.sort #print(A) if A==[5,5,7]: print('YES') else: print('NO')
p03457
s615584451
Wrong Answer
# 2020/03/14 # AtCoder Beginner Contest 086 - C # Input n = int(input()) nx = 0 ny = 0 nt = 0 # Check ans = "Yes" for i in range(n): t, x, y = map(int,input().split()) dist = abs(nx - x) + abs(ny - y) if dist > (t - nt) or (dist <= (t - nt) and dist % 2 == 0): ans = "No" break nx = x ny = y nt = t # Output print(ans)
p02696
s479618331
Accepted
import math a, b, n = list(map(int, input().split(" "))) k = min(b - 1, n) print(int(math.floor(a * k / b) - a * math.floor(k / b)))
p02708
s091478219
Wrong Answer
N,K=map(int,input().split()) cnt=0 for k in range(K,N+2): MIN=k*(k-1)//2 MAX=(2*N-k+1)*k//2 cnt+=MAX-MIN+1 print(cnt)
p02917
s427871626
Wrong Answer
def main(): _ = int(input()) B = list(map(int, input().split())) A = [] A.append(min(B[0:2])) A.append(min(B[0:2])) for i in range(1, len(B[:-1])): A.append(min(B[i], B[i+1])) if len(B) > 1: A.append(B[-1]) print(sum(A)) if __name__ == '__main__': main()
p02761
s575067619
Accepted
n, m = map(int, input().split()) T = [] A = [str(0) for _ in range(n)] for i in range(m): s, t = map(int, input().split()) T.append([s, t]) f = True for i in range(m): for j in range(i, m): if (T[i][0] == T[j][0] and T[i][1] != T[j][1]) or (T[i][0] == 1 and T[i][1] == 0 and n > 1): f = False break A[T[i][0]-1] = str(T[i][1]) if n == 1 and m == 0: print(0) exit() elif A[0] == "0" and len(A) > 1: A[0] = "1" if f: print("".join(A)) else: print(-1)
p02811
s493782950
Wrong Answer
K,X=input().split() if(int(K)*500>int(X)): print("Yes") else: print("No")
p03250
s760842153
Accepted
a, b, c = map(int, input().split()) print(max(a, b, c) * 10 + a + b + c - max(a, b, c))
p03657
s729301426
Wrong Answer
a,b=map(int,input().split()) print("Possible" if (a+b)%3==0 else "Impossible")
p02577
s009103951
Accepted
n = int(input()) if n % 9 == 0: print('Yes') else: print('No')
p02783
s479274761
Accepted
h, a=map(int,input().split()) if h%a == 0: count=h//a else: count = h//a+1 print(count)
p03042
s801183140
Accepted
S = input() if 1 <= int(S[:2]) <= 12 and 1 <= int(S[2:]) <= 12: print("AMBIGUOUS") elif 1 <= int(S[2:]) <= 12: print("YYMM") elif 1 <= int(S[:2]) <= 12: print("MMYY") else: print("NA")
p02796
s220437154
Accepted
N = int(input()) A = [list(map(int,input().split())) for _ in range(N)] B = sorted([[A[i][0]-A[i][1],A[i][0]+A[i][1]] for i in range(N)],key=lambda x:x[1]) cur = 1 C = [B[0]] while cur<N: if B[cur][0]>=C[-1][1]: C.append(B[cur]) cur += 1 print(len(C))
p02572
s295301209
Accepted
n = int(input()) a = list(map(int, input().split())) mod = 10**9 + 7 all_item = sum(a) ans = 0 for i in range(n): all_item = (all_item - a[i])%mod ans = (ans + all_item*a[i])%mod print(ans)
p04043
s353057814
Accepted
n=input().split() print("YES" if n.count("5")==2 and n.count("7")==1 else "NO")
p03711
s333971984
Wrong Answer
l = list(input().split()) a = ["1","3","5","7","8","10","12"] b = ["4","6","9","11"] c = ["2"] if a >= l or b >= l: print("Yes") else: print("No")
p03495
s130176158
Wrong Answer
import heapq n,k = map(int,input().split()) a = list(map(int,input().split())) r = [0 for _ in range(max(a)+1)] if len(set(a)) <= k: print(0) exit() for i in range(n): r[a[i]] += 1 t = [] for i in range(len(r)): if r[i]: t.append(r[i]) t = list(map(lambda x:-x,t)) heapq.heapify(t) print(n+sum(t[:k]))
p03286
s378970484
Accepted
n = int(input()) x = '' while n != 0: if n % (-2) == 0: n //= (-2) x = '0' + x else: n = (n - 1) // (-2) x = '1' + x print(x if x else 0)
p02933
s963293125
Accepted
a = int(input()) s = input() if a>=3200: print(s) else: print('red')
p03206
s425655319
Accepted
D = int(input()) if D==25: print('Christmas') if D==24: print('Christmas Eve') if D==23: print('Christmas Eve Eve') if D==22: print('Christmas Eve Eve Eve')
p02947
s290173839
Accepted
N = int(input()) s = {} for _ in range(N): input_s = list(input()) input_s = sorted(input_s) input_s = "".join(input_s) if input_s not in s.keys(): s[input_s] = 0 s[input_s] += 1 ans = 0 for key, value in s.items(): if value >= 2: ans += value * (value - 1) // 2 print(ans)
p03103
s883142370
Wrong Answer
n,m=map(int,input().split()) dic={} doll=0 for i in range(n): a,b=map(int,input().split()) dic[a]=b con=sorted(dic.items()) for k,v in con: if v<m: doll+=k*v m-=v else: doll+=k*m print(doll) exit()
p03544
s235131873
Accepted
from functools import lru_cache @lru_cache(maxsize=None) def luca(x): if x==0: return 2 if x==1: return 1 return luca(x-1)+luca(x-2) print(luca(int(input())))
p02659
s541894229
Wrong Answer
a,b = map(float, input().split()) print(int(a*b))
p02972
s842713531
Wrong Answer
N = int(input()) a = list(map(int, input().split())) box = [0 for _ in range(N)] for i in reversed(range(N)): if a[i] == 1: box[i] = 1 temp = sum(box) if temp % 2 != a[0]: print(-1) exit() for i in range(1, N): temp = sum(box[i:i+1]) if temp % 2 == a[i]: continue else: print(-1) exit() print(sum(box)) for n, i in enumerate(box): if i == 1: print(n+1, end="") else: print(end="")
p03062
s715670885
Accepted
import numpy as np n = int(input()) A = list(map(int,input().split())) cnt = np.sum(np.where(np.array(A) < 0, True, False)) #print(cnt) A = list(map(lambda x:abs(x), A)) if cnt%2 == 0: print(sum(A)) else: print(sum(A)-2*min(A))
p02658
s225491375
Accepted
def main(): n = int(input()) a = list(map(int, input().split())) if 0 in a: print(0) return res = 1 for e in a: res *= e if res > 10**18: print(-1) return print(res) main()
p02633
s129596182
Wrong Answer
x = int(input()) print((360 -1) // x + 1)
p03150
s131353456
Wrong Answer
s=input() k="keyence" t="" for i in range(7): if k[i]!=s[i]: t+=k[:i] break else: print("YES") exit() for j in range(7-i): if k[-j-1]!=s[-j-1]: t+=k[7-j:] break print("YES" if t==k else "NO")
p03625
s216639485
Wrong Answer
N = int(input()) A = list(input().split()) edge_list = [] selection = sorted(list(set(A)))[::-1] for i in selection: edge_list += i * (A.count(i) // 2) if len(edge_list) >= 2: break edge_list.sort() if len(edge_list) < 2: print(0) else: print(int(edge_list[-1]) * int(edge_list[-2]))
p02719
s906536267
Accepted
N,K = map(int,input().split()) print(min(N%K,K-N%K))
p03041
s239322959
Wrong Answer
# A n, k = map(int, input().split()) s = list(input()) s[n-1] = s[n-1].lower() for i in s: print(i, end ="")
p02818
s258868456
Wrong Answer
x = input().split() a = int(x[0]) b = int(x[1]) c = int(x[2]) if c % 2 == 0: c1 = c / 2 a = a - c1 b = a - c1 if (a < 0): a = 0 if (b < 0): b = 0 else: c = c - 1 c1 = c / 2 c1 = c1 + 1 a = a - c1 b = b - c1 b = b + 1 if a < 0: a = 0 if b < 0: b = 0 print("{} {}".format(int(a), int(b)))
p02910
s876819760
Accepted
import sys from bisect import * from heapq import * from collections import * from itertools import * from functools import * sys.setrecursionlimit(100000000) input = lambda: sys.stdin.readline().rstrip() S = input() if all(c != 'R' for c in S[1::2]) and all(c != 'L' for c in S[::2]): print('Yes') else: print('No')
p02767
s707295702
Accepted
N = int(input()) X = list(map(int,input().split())) import numpy as np arr = np.array(X) ans = np.inf for i in range(1,101): ans = min(ans, sum(map(lambda x:x**2,arr-i))) print(ans)
p02612
s644270038
Accepted
n = int(input()) if n%1000 == 0: change = 0 else: change = (1000*(n//1000 + 1)) - n print(change)
p02910
s314558691
Accepted
S=input() n=0 for i in S: if (n%2==0 and i=="L") or (n%2==1 and i=="R"): print('No') exit() n+=1 print('Yes')
p02873
s971349992
Wrong Answer
S = input() ans = [0] * (len(S) + 1) for i in range(len(S)): if S[i] == '<': ans[i + 1] = ans[i] + 1 print(ans) for i in range(len(S)-1, -1, -1): if S[i] == '>': ans[i] = max(ans[i + 1] + 1, ans[i]) print(ans) print(sum(ans))
p02711
s308604120
Accepted
n = input() if "7" in n: print("Yes") else: print("No")
p02789
s665936356
Accepted
l = [int(x) for x in input().split()] if l[0]==l[1]: print('Yes') else: print('No')
p03910
s385047121
Wrong Answer
import math n=int(input()) num=int(math.sqrt(n*2)) num2=(num*(num+1))//2 num3=n-num2 if num3>num: num+=1 num3-=num ans=list(range(1,num+1)) for i in range(num-num3,num): ans[i]+=1 for i in ans: print(i)
p03435
s531826286
Accepted
c = [] for _ in range(3): c.append(list(map(int, input().split()))) if c[0][1]-c[0][0] == c[1][1]-c[1][0] and c[2][1]-c[2][0] == c[1][1]-c[1][0] and c[0][2]-c[0][1] == c[1][2]-c[1][1] and c[2][2]-c[2][1] == c[1][2]-c[1][1]: print("Yes") else: print("No")
p03377
s977039250
Wrong Answer
A,B,X = map(int,input().split()) if X>A+B or A>X: print('No') else: print('Yes')
p03544
s099947118
Wrong Answer
n = int(input()) l0 = 2 l1 = 1 l2 = 0 for i in range(n-1): l2 = l0 + l1 l0, l1 = l1, l2 print(l2)
p02946
s677546206
Accepted
# -*- coding: utf-8 -*- import math import itertools import sys import copy #import numpy as np # 入力 #A, B, C, D = map(int, input().split()) #L = list(map(int, input().split())) #S = list(str(input())) #N = int(input()) #S = str(input()) K, X = map(int, input().split()) rmin = -1* (10 ** 6) rmax = (10 ** 6) lmin = max(rmin, X-K+1) lmax = min(rmax, X+K-1) ans = str(lmin) for i in range(lmin+1, lmax+1) : ans += " " + str(i) print (ans)
p03329
s369127307
Wrong Answer
n = int(input()) MAXN = 110000 f_inf = float('inf') dp = [f_inf] * (MAXN+n) dp[0] = 0 for i in range(1, n+2): for j in range(5): dp[i] = min(dp[i], dp[i-pow(6, j)]+1) for k in range(5): dp[i] = min(dp[i], dp[i-pow(9, k)]+1) print(dp[n])
p03293
s937567691
Accepted
S = input() T = input() S = S + S for i in range(0, len(S) - len(T)+1): if S[i: i + len(T)] == T: print("Yes") exit() print("No")
p03632
s136478856
Wrong Answer
a,b,c,d=map(int, input().split()) if b<c or d<a: print(0) elif b>=c: print(b-c) else: print(d-a)
p03543
s740972458
Accepted
a = input() print("Yes" if a[0]==a[1]==a[2] or a[1]==a[2]==a[3] else "No")
p03351
s742447929
Wrong Answer
a,b,c,d=map(int,input().split()) if abs(b-a)<=d and abs(c-b) <=d: print('Yes') else: print('No')
p02959
s165337070
Accepted
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) ans,ov = 0,0 for i in range(N): tmp = min(A[i],ov) ans += tmp A[i] -= tmp if B[i]>A[i]: ans+=A[i] ov = B[i]-A[i] else: ans+=B[i] ov = 0 tmp = min(A[N],ov) ans+=tmp print(ans)
p04012
s566631672
Accepted
w=input() ans="Yes" w_len=len(w) if w_len%2==1: ans="No" else: for i in range(w_len): w_i=w[i] w_count=w.count(w_i) if w_count%2==1: ans="No" print(ans)
p03434
s143217900
Accepted
N = int(input()) A = list(map(int, input().split())) Alice = 0 Bob = 0 A.sort(reverse=True) for i in range(len(A)): if i%2 == 0: Alice += A[i] else: Bob += A[i] print(Alice-Bob)
p03069
s458145830
Accepted
from collections import Counter, deque, defaultdict from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort from itertools import accumulate, product, permutations, combinations, combinations_with_replacement from collections import Counter, deque, defaultdict N = int(input()) S = input() mi = 10000000 c = Counter(S) A = N - c["#"] B = N - c["."] l = 0 r = c["."] for i in range(0, N): if S[i] == "#": l += 1 else: r -= 1 a = l + r if mi > a: mi = a print(min(mi, A, B))
p03261
s596032906
Accepted
N = int(input()) W = [] for i in range(N): w = input() if len(W) == 0 or (W.count(w) == 0 and l == w[0]): W.append(w) l = w[-1] else: print("No") exit() print("Yes")
p02820
s277922325
Accepted
N, K = [int(i) for i in input().split()] R, S, P = [int(i) for i in input().split()] d = {'r': P, 's': R, 'p': S} T = input() checked = [False for i in range(N)] # 勝てるだけ勝てばいい for i in range(N-K): if T[i] == T[i+K]: if checked[i] == False: checked[i+K] = True result = 0 for i in range(N): if checked[i] == False: result += d[T[i]] print(result)
p03206
s711616527
Wrong Answer
d=int(input()) result='Christamas' n=25 while n>=22: if n>d: result+=' Eve' n-=1 print(result)
p03639
s956129439
Wrong Answer
N = int(input()) L = list(map(int,input().split())) b2 = 0 b4 = 0 for i in range(N): if L[i] % 4 == 0: b4 += 1 elif L[i] % 2 == 0: b2 += 1 other = N-b4-b2 if other//2 > b4: print('No') else: rb4 = b4-(other//2) if b2 % 2 == 1: if rb4 == 0: print('No') else: print('Yes') else: print('Yes')
p03086
s181745994
Accepted
import re print(max(map(len, re.findall("[ACGT]*", input()))))
p03472
s130741034
Wrong Answer
from math import ceil N,H=map(int,input().split()) AB=[list(map(int,input().split())) for i in range(N)] sw=max(AB[i][0] for i in range(N)) cnt=0 for i in range(N): if AB[i][1]>=sw: cnt+=1 H-=AB[i][1] if(H<=0): print(cnt) exit() cnt+=ceil(H/sw) print(cnt)
p02813
s544525114
Wrong Answer
N = int(raw_input()) S = raw_input() state = 0 count = 0 #print S #print len(S) for i in range(len(S)): if S[i] == 'A': state = 1 elif state == 1 and S[i] == 'B': state = 2 elif state == 2 and S[i] == 'C': count += 1; state = 0 else: state = 0 print count
p02725
s725275597
Wrong Answer
# スペース区切りの文字列の入力 KN = input().split() A = input().split() i = ans = 0 max = 0 for i in range(int(KN[1])): if(i == int(KN[1]) - 1): A2 = int(KN[0]) else: A2 = int(A[i+1]) # 距離が最大のもの以外をansに加算 if(max < abs(A2 - int(A[i]))): ans += max max = abs(A2 - int(A[i])) else: ans += abs(A2 - int(A[i])) print(ans)
p02866
s496717403
Wrong Answer
import sys from collections import Counter input = sys.stdin.readline N = int(input()) ans = 1 mod = 998244353 D = sorted(Counter(list(map(int, input().split()))).items()) tmp = D[0][1] stream = 0 for n, i in D: if stream != n: exit() if n == 0: stream += 1 continue ans *= pow(tmp, i) ans %= mod tmp = i stream += 1 print(ans)
p03543
s853076518
Accepted
n = input() if (n[0]==n[1] and n[1]==n[2]) or (n[2]==n[3] and n[1]==n[2]): print("Yes") else: print("No")
p03161
s543698171
Accepted
INF = 2**31-1 n,k = map(int,input().split()) h = list(map(int,input().split())) dp = [INF for _ in range(n)] dp[0] = 0 for i in range(0,n): for j in range(1,k+1): if i+j < n: dp[i+j] = min(dp[i+j], abs(h[i+j] - h[i]) + dp[i]) else: break print(dp[n-1])