problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02730
s290520750
Accepted
S = input() N = len(S) S1 = S[:(N-1)//2] S2 = S[(N+3)//2-1:] print("Yes" if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1] else "No")
p03627
s299522872
Accepted
from collections import Counter N = int(input()) A = list(map(int,input().split())) C = Counter(A) T = [] F = [] for e in C: if C[e] >= 4: F.append(e) if C[e] >= 2: T.append(e) ans = 0 for e in F: ans = max(ans,e**2) T = sorted(T) if len(T) >= 2: ans = max(ans,T[-1]*T[-2]) print(ans)
p03041
s627464915
Accepted
n, k = map(int, input().split()) s = list(input()) if s[k-1] == 'A': s[k-1] = 'a' elif s[k-1] == 'B': s[k-1] = 'b' else: s[k-1] = 'c' print(''.join(s))
p03293
s921043540
Accepted
S=input() T=input() ans = "No" for i in range(len(S)): if S[i:] + S[0:i] == T: ans = "Yes" print(ans)
p03721
s598472344
Accepted
# https://atcoder.jp/contests/abc061/tasks/abc061_c from collections import defaultdict n, k = [int(i) for i in input().split()] d = defaultdict(int) for _ in range(n): a, b = [int(i) for i in input().split()] d[a] += b array = sorted(d.items(), key=lambda x: x[0]) for num, count in array: if k > count: k -= count else: print(num) quit()
p03785
s824359035
Accepted
N, C, K = map(int, input().split()) T = [] for i in range(N): T += [int(input())] sortT = sorted(T) pre_ti = sortT[0] ans = 1 c = 0 for ti in sortT: c += 1 if ti - pre_ti <= K and c <= C: continue c = 1 ans += 1 pre_ti = ti print(ans)
p02712
s725051964
Accepted
n=int(input()) ans = 0 loop = n//15 ans += loop * 60 + 120*(loop-1)*loop//2 res = n % 15 for i in range(1,res+1): if i%3 != 0 and i%5 != 0: ans += 15*loop + i print(ans)
p02725
s139690017
Wrong Answer
k,n = map(int,input().split()) a = list(map(int,input().split())) ans = 0 a.reverse() for i in range(n-1): a[i]-=a[i+1]-a[n-1] a.append(k-max(a)) ans = max(a) print(ans)
p03971
s727693994
Accepted
n,a,b = map(int,input().split()) sl = list(input()) naka = 0 soto = 0 for s in sl: if s == "c": print("No") if s == "a": if naka + soto < a + b: print("Yes") naka += 1 else: print("No") if s == "b": if naka + soto < a + b and soto < b: print("Yes") soto += 1 else: print("No")
p03274
s592379452
Accepted
n, k = map(int, input().split()) x = list(map(int, input().split())) ans = 10**10 for i in range(n - k + 1): ans = min(ans, max(0, -x[i]) + max(0, 2 * x[i + k - 1]), max(0, -2 * x[i]) + max(0, x[i + k - 1])) print(ans)
p02647
s657893669
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) for _ in range(k): b = [0] * (n + 1) for i in range(n): b[max(0, i - a[i])] += 1 b[min(n, i + a[i] + 1)] -= 1 for i in range(n): b[i + 1] += b[i] a = b[:-1].copy() for x in a: if x < n: break else: print(*a) exit(0) print(*a)
p03814
s948553409
Accepted
s = input() ans=0 j=1 for i in range(len(s)): if s[i]=="A": while s[-j] != "Z": j += 1 ans = len(s)-j-i+1 break else: continue print(ans)
p02836
s662119501
Accepted
s = input() ans = 0 n = len(s) for i in range(n//2): if s[i] != s[n-1-i]: ans+=1 print(ans)
p02730
s359175836
Accepted
S = input() N = len(S) A = S[:int((N-1)/2)] B = S[int((N+3)/2)-1:] # print(S,A,B) # def palindrome(string): return # string.find(string[::-1]) def palindrome(string): return 1 if string==string[::-1] else 0 # print(palindrome(S),palindrome(A),palindrome(B)) if palindrome(S) and palindrome(A) and palindrome(B): print('Yes') else: print('No')
p03556
s928213974
Accepted
n = int(input()) s = 0 for i in range(10**5): if i**2 > n: break print((i-1)**2)
p02720
s586529989
Accepted
import queue q = queue.Queue() k = int(input()) for i in range(1,10): q.put(i) while(k > 0): x = q.get() if x % 10 != 0: q.put(x*10 + (x%10 - 1)) q.put(x*10 + x%10) if x % 10 != 9: q.put(x*10 + (x%10 + 1)) k -= 1 print(x)
p03835
s902887420
Wrong Answer
k,s = map(int,input().split()) ans = 0 for i in range(k): for j in range(k): if 0 <= s - i - j <= k: ans += 1 #elif s - i - j > k: break print(ans)
p02628
s016252661
Accepted
N, K = map(int, input().split()) P = list(map(int, input().split())) print(sum(sorted(P)[:K]))
p03695
s680933264
Accepted
import sys input=sys.stdin.readline n = int(input()) A = list(map(int, input().split())) l = [0] * 9 mn = 0 for i in A: t = min(i // 400, 8) l[t] += 1 for i in range(8): if l[i] != 0: mn += 1 if mn == 0: mn = 1 mx = l[8] else: mx = mn + l[8] print(mn, mx)
p03038
s099446399
Accepted
n, m = map(int, input().split()) PAIRS = [(a, 1) for a in map(int, input().split())] for _ in range(m): b, c = map(int, input().split()) PAIRS.append((c, b)) PAIRS.sort(reverse = True) answer, count = 0, 0 for pair in PAIRS: answer += pair[0] * pair[1] count += pair[1] if count > n: answer -= pair[0] * (count - n) break print(answer)
p03109
s440848060
Accepted
s = input() print("Heisei" if s <= "2019/04/30" else "TBD")
p02972
s713517031
Accepted
n = int(input()) a = [0] + list(map(int, input().split())) ans = [] for i in range(n, 0, -1): j = 2 * i while j <= n: a[i] ^= a[j] j += i if a[i] == 1: ans.append(i) print(len(ans)) if ans: print(' '.join(list(map(str, ans))))
p02817
s510706783
Accepted
str_l = list(map(str, input().split())) print(''.join(list(reversed(str_l))))
p02767
s888287456
Accepted
if __name__ == '__main__': N = int(input()) X = [int(x) for x in input().split()] ans = 10000000 for i in range(1,101): s = 0 for x in X: s += (x-i)**2 if ans > s: ans = s print(ans)
p02695
s393343512
Wrong Answer
import itertools N,M,Q = map(int,input().split()) A = [[ int(n) for n in input().split()] for _ in range(Q) ] n = [i for i in range(1,M+1)] numbers = list(itertools.combinations_with_replacement(n, N)) ans = [0 for _ in range(len(numbers))] q = Q while q> 0: q -= 1 a, b, c, d = A[q][0], A[q][1], A[q][2], A[q][3] print(a,b,c,d) for i in range(len(numbers)): if numbers[i][b-1] - numbers[i][a-1] == c: ans[i] += d print(max(ans))
p02706
s813834269
Accepted
n,m=map(int,input().split()) a=list(map(int,input().split())) if sum(a)>n: print(-1) else: print(n-sum(a))
p02880
s940335608
Accepted
import math N = int(input()) rootN = math.ceil(math.sqrt(N)) yakusuu = [] for i in range(1,rootN+1): if N % i == 0: yakusuu.append(i) hitoketaFLG = 0 for j in yakusuu: if len(str(int(N / j))) == 1: hitoketaFLG = 1 print('Yes' if hitoketaFLG == 1 else 'No')
p03632
s838272324
Accepted
a, b, c, d = map(int, input().split()) aa = [0 for i in range(101)] bb = [0 for i in range(101)] ans = 0 for i in range(a, b): aa[i] = 1 for i in range(c, d): bb[i] = 1 for i in range(101): if aa[i] == 1 and bb[i] == 1: ans += 1 print(ans)
p03075
s699295282
Accepted
# -*- coding: utf-8 -*- a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if abs(a - e) > k: print(':(') else: print('Yay!')
p02702
s144643684
Accepted
S = input() N = len(str(S)) P = 2019 list_a = [0] * P list_a[0] += 1 counter = 0 temp = 0 power = 1 for i in range(N): temp += pow(10, i, P) * int(S[N - i - 1]) temp %= P counter += list_a[temp] list_a[temp] += 1 print(counter)
p03345
s682091188
Wrong Answer
def resolve(): A, B, C, K = list(map(int, input().split())) MX = 10 ** 18 if K == 0: print(A-B) return AK = (K-1) * A + K * (B+C) BK = (K-1) * B + K * (C+A) CK = (K-1) * C + K * (A+B) if (abs(AK-BK)>=MX): print('Unfair') return print(AK - BK) return resolve()
p02607
s463640816
Accepted
def main(): n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(n): if i%2 == 0 and a[i]%2 == 1: ans += 1 print(ans) if __name__ == "__main__": main()
p02713
s850118033
Accepted
import math def main(): k = int(input()) k1 = k + 1 sum = 0 for i in range(1, k1): for j in range(1, k1): for m in range(1, k1): sum += math.gcd(math.gcd(i, j), m) print(sum) main()
p03160
s259849479
Wrong Answer
n = int(input()) h_L = list(map(int,input().split())) #dp = [float("inf")] * (10**4 + 1) dp = [10**8] * n dp[0] = 0 dp[1] = abs(h_L[0]-h_L[1]) for i in range(2,n): #dp[i] # 1 tmp1 = dp[i-1] + abs(h_L[i-1] - h_L[i]) dp[i] = min(dp[i],tmp1) # 2 tmp2 = dp[i-2] + abs(h_L[i-2] - h_L[i]) dp[i] = min(dp[i],tmp2) #print(dp) print(dp[len(h_L)-1])
p02720
s820632767
Wrong Answer
_input = input ''' allinputs = iter(input().splitlines()) input = lambda : next(allinputs) #''' #ここに書きたいコードを書く #データ読み込み K=int(input()) bansu=10 n=9 while bansu <= K: n += 1 n_str = str(n) l=len(n_str) lun_flag = True for i in range(l-1): if abs(int(n_str[i]) - int(n_str[i+1])) > 1: lun_flag = False #print(n,bansu,lun_flag) if lun_flag == True: bansu += 1 print(n) input = _input
p02819
s859477401
Accepted
X = int(input()) while True: isDivisible = False divider = 2 while not isDivisible or divider < X: isDivisible = (X % divider == 0) if isDivisible: break else: divider += 1 if divider == X: break else: X += 1 print(X)
p02854
s511743224
Wrong Answer
def main(): N = int(input()) A = [int(a) for a in input().split()] l = r = ans = 0 if N % 2 == 0: l = sum(A[:len(A)//2]) r = sum(A[len(A)//2:]) ans = abs(l - r) else: l = sum(A[:len(A)//2]) r = sum(A[len(A)//2+1:]) m = A[len(A)//2] ans = m + min(l, r) - max(l, r) print(ans) if __name__ == "__main__": main()
p03274
s574317033
Accepted
N,K = map(int,input().split()) x = list(map(int,input().split())) ans = 1e12 for i in range(N-K+1): a = abs(x[i])+abs(x[i]-x[i+K-1]) b = abs(x[i+K-1]) + abs(x[i]-x[i+K-1]) ans = min(ans,min(a,b)) print(ans)
p03339
s238763355
Accepted
import numpy as np import sys buf = sys.stdin.buffer N = int(buf.readline()) L = list(input()) tE = L.count("E") tW = N-tE ce,cw = 0,0 ans = 3*(10**5) for i in range(N): if L[i] == "E": ce +=1 elif L[i] == "W": cw +=1 if L[i] == "E": ans = min(ans,cw+(tE-ce)) elif L[i] == "W": ans = min(ans,cw-1+(tE-ce)) print(ans)
p02952
s640910506
Accepted
n = int(input()) a = [9,900,90000] order = len(str(n)) if order == 1: print(n) elif order == 2: print(9) elif order == 3: print(n-100+1 + 9) elif order == 4: print(909) elif order == 5: print(n-10000+1 + 909) else: print(90909)
p02995
s154945644
Wrong Answer
A, B, C, D = map(int, input().split()) def abc131_c(a,b,c,d): count = 0 for i in range(a,b-1): if i % c == 0 or i % d == 0: continue count += 1 return count print(abc131_c(A,B,C,D))
p02731
s507339186
Wrong Answer
l=int(input()) ans=0 for a in range(1,l+1): b=(l-a)/2 c=(l-a)/2 ans=max(ans,a*b*c) print(ans)
p03471
s778841238
Accepted
N, Y = map(int, input().split()) ans = [-1, -1, -1] for i in range(Y//1000+1): for j in range(Y//5000+1): k = (Y - 10000*i - 5000*j)//1000 if k < 0: break if i + j + k == N: ans = i, j, k # print(10000*ans[0] + 5000*ans[1] + 1000*ans[2]) print(*ans)
p03150
s493628167
Accepted
S = input() import sys for i in range(0,len(S)): for j in range(i,len(S)): if S[:i] + S[j:] == 'keyence': print('YES') sys.exit() print('NO')
p02696
s695250577
Accepted
a, b, n = map(int, input().split()) tmp = min(b-1, n) print(int(a*tmp/b)-a*int(tmp/b))
p03077
s010424587
Accepted
N, A, B, C, D, E = [int(input()) for _ in range(6)] s = min(A, B, C, D, E) print((N // s + (N % s != 0) - 1) + 5)
p03557
s780744760
Accepted
import sys import bisect def main(): input = sys.stdin.buffer.readline N = int(input()) A = list(map(int, input().split())) A.sort() B = list(map(int, input().split())) B.sort() C = list(map(int, input().split())) C.sort() ans = 0 for i in B: a = bisect.bisect_left(A, i) c = bisect.bisect_right(C, i) ans += a*(N-c) print(ans) if __name__ == '__main__': main()
p02779
s771587120
Accepted
n=int(input()) a=list(map(int,input().split())) aa = sorted(a) flag=True for i in range(n-1): if aa[i]==aa[i+1]: flag=False if flag: print('YES') else: print('NO')
p02767
s934893413
Accepted
N = int(input()) X = list(map(int,input().split())) tmp = 0 mi =100000000000 for i in range(1,101): for k in range(N): tmp += (X[k] - i)**2 if tmp < mi: mi = tmp tmp = 0 print(mi)
p02786
s445366793
Wrong Answer
import numpy as np import math def resolve(): n = input() m = math.ceil(np.log2(int(n))) ans = 0 for i in range(m + 1): ans += np.power(2, i) print(ans) resolve()
p03285
s262705555
Accepted
n = int(input()) ans = 'No' for i in range(n//4 + 1): for j in range(n//7 + 1): if 4*i + 7*j == n: ans = 'Yes' print(ans)
p02963
s752566064
Accepted
S = int(input()) l = [0,0] if S <= 10 ** 9: a = [S, 0, 0, 1] else: u = S // 10 ** 9 if S % 10 ** 9 != 0: u += 1 d = u * (10 ** 9) - S a = [u, d, 1, 10 ** 9] l.extend(a) print(" ".join(map(str, l)))
p02879
s851415070
Wrong Answer
A,B=map(int,input().split()) print(A*B if 1<=A<=9 and 1<=B<=9 else "–1")
p03627
s990560509
Accepted
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) tmp = 0 tate = 0 yoko = 0 cnt = 0 for i in A: if tmp == i and cnt == 0: tate = i cnt += 1 tmp = 0 continue if tmp == i and cnt == 1: yoko = i cnt += 1 break tmp = i print(tate*yoko)
p03262
s738570429
Accepted
import math [N,X] = list(map(int,input().split())) x = list(map(int,input().split())) #x = sorted(x, reverse=True) out=x[0] - X for i in range(N): out = math.gcd(abs(x[i]-X), out) print(out)
p02598
s564187441
Wrong Answer
#E - Logs import math # 入力 N,K = map(int,input().split()) A = list(map(int,input().split())) Amax = int(max(A)) high = Amax Cancut = Amax low = 0 while ( abs(high - low) > 0.1 ) : Cut = 0 X = (high + low) / 2.0 for i in range(N): Cut = Cut + math.ceil(A[i]/X) - 1 if Cut <= K: high = X Cancut = X else: low = X # 出力 print(math.ceil(Cancut))
p02628
s370723043
Wrong Answer
n, k = map(int, input().split()) plist = list(map(int, input().split())) plist.sort() ans = sum(plist, k) print(ans)
p03493
s225905069
Wrong Answer
s = "101" print(s.count("1"))
p03252
s479379420
Wrong Answer
s=input() t=input() swich=[] stay=[] for x,y in zip(s,t): if x!=y: swich.append([x,y]) else: stay.append(x) #print(swich,stay,sep=('\n')) for i in swich: if i[0] in stay or i[1] in stay: print('No') exit() for j in swich: if i[0]==j[0] and i[1]!=j[1]: print('No') exit() print('Yes')
p03435
s116676776
Accepted
l1=list(map(int,input().split())) l2=list(map(int,input().split())) l3=list(map(int,input().split())) l=[l1,l2,l3] c=l[0][0] for i in range(3): for j in range(3): l[i][j] -=c if (l[1][1]==l[0][1]+l[1][0]) and (l[2][1]==l[0][1]+l[2][0]) and (l[1][2]==l[0][2]+l[1][0])and (l[2][2]==l[2][0]+l[0][2]): print('Yes') else: print("No")
p04033
s014454026
Accepted
#!/usr/bin/env python # coding: utf-8 # In[18]: a,b = map(int, input().split()) # In[19]: if a*b <= 0: print("Zero") elif a > 0 and b > 0: print("Positive") else: if (b-a)%2 == 1: print("Positive") else: print("Negative") # In[ ]:
p03359
s952726140
Accepted
# A - Day of Takahashi a, b = map(int ,input().split()) ans = 0 for i in range(1, 13): if i < a: ans += 1 elif i == a and i <= b: ans += 1 print(ans)
p03380
s209256216
Accepted
import sys N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) n = max(A) mid = n / 2 r = float("inf") for a in A: if a == n: continue if abs(mid - r) > abs(mid - a): r = a print(n, r)
p02784
s218511971
Accepted
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): h, n = map(int, input().split()) A = list(map(int, input().split())) print("Yes" if h <= sum(A) else "No") if __name__ == '__main__': resolve()
p02663
s985630154
Accepted
h1,m1,h2,m2,k=map(int,input().split()) if h1==h2: print(m2-m1-k) else: print((60-m1)+(h2-h1-1)*60-k+m2)
p03448
s927581669
Accepted
A, B, C, X = [int(input()) for i in range(4)] ans = 0 for i in range(0, A+1): for j in range(0, B+1): for k in range(0, C+1): if (i*500 + j*100 + k*50)==X: ans+=1 print(ans)
p02847
s308092457
Accepted
s = input() if s=="SUN": print(7) if s=="MON": print(6) if s=="TUE": print(5) if s=="WED": print(4) if s=="THU": print(3) if s=="FRI": print(2) if s=="SAT": print(1)
p02659
s240872834
Wrong Answer
A,B=input().split() A=int(A) B=int(B.replace('.','')) C=int(A*B/100) print(C)
p03210
s149255056
Accepted
x = int(input()) print('YES' if x == 3 or x == 5 or x == 7 else 'NO')
p03317
s018982954
Accepted
import math def main(): N, K = map(int, input().split()) input() print(math.ceil((N-K)/(K-1) + 1.0)) main()
p03951
s172599330
Wrong Answer
N = int(input()) s = input() t = input() ans = 2 * N for tail, head in zip(reversed(s), t): if s == t: print(N) break if tail == head: ans -= 1 else: print(ans) break
p03161
s013717487
Accepted
def main(): n,k = map(int,input().split()) h = [int(i) for i in input().split()] INF = float('inf') dp = [INF for i in range(n)] dp[0] = 0 dp[1] = abs(h[0]-h[1]) for i in range(2,n): dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]) for j in range(1,min(i,k)+1)) print(dp[n-1]) main()
p02744
s757372842
Accepted
N = int(input()) w = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] def dfs(s, i): # s:文字列 i:最大のアルファベットのindex if len(s) == N: print(s) else: for k in range(i+2): if k == i+1: dfs(s+w[k], i+1) else: dfs(s+w[k], i) x = dfs('a', 0)
p02583
s178513135
Wrong Answer
n = int(input()) s = map(int,input().split()) cnt = 0 t = sorted(s) for i in range(n): a = t[i] for j in range(i, n): b = t[j] for k in range(j, n): c = a + b if t[k] != c and a != b and b != t[k] and a != t[k]: cnt += 1 print(cnt)
p03145
s501560686
Wrong Answer
a,b,c=input().split() a=int(a) b=int(b) c=int(c) ls=[a,b,c] ls.sort() print(ls[0]*ls[1]/2)
p02658
s158069089
Wrong Answer
n = int(input()) a_nums = list(map(int, input().split())) if 0 in a_nums: print(0) ans = 1 for num in a_nums: ans *= num if ans > 10 **18: print(-1) else: print(ans)
p02645
s364536801
Accepted
S = input() print(S[:3])
p03448
s968352359
Wrong Answer
A, B, C, X = [int(input()) for i in range(4)] ans = 0 for i in range(0, A): for j in range(0, B): for k in range(0, C): if (i*500 + j*100 + k*50)==X: ans+=1 print(ans)
p04019
s542643484
Wrong Answer
s=input() if s.count('N')==s.count('S')==0 or (s.count('N')!=0 and s.count('S')!=0): if s.count('E')==s.count('W')==0 or (s.count('E')!=0 and s.count('W')!=0): print('Yes') else: print('No')
p02571
s883315126
Wrong Answer
s_long = input() s_shor = input() ans = len(s_shor) strr_1 = s_shor strr_2 = s_shor if (strr_1 in s_long): print(0) exit() else: for i in range(1, len(s_shor)): strr_1 = s_shor[: - i] strr_2 = s_shor[i:] if (strr_1 in s_long or strr_2 in s_long): ans = min(ans, i) print(ans)
p03419
s385316036
Accepted
n, m = map(int, input().split()) ans = n * m if n > 1 or m > 1: if n >= 2 and m >= 2: ans -= 4 else: ans -= 2 if n > 1: ans -= max((m - 2) * 2, 0) if m > 1: ans -= max((n - 2) * 2, 0) print(ans)
p02621
s472419443
Wrong Answer
for i in range(10): a=i+1 print(a+a^2+a^3)
p02743
s601804938
Accepted
def main(): import math a, b, c = map(int, input().split()) # a = math.sqrt(a) # b = math.sqrt(b) # c = math.sqrt(c) # n = math.sqrt(a*b) if 4 * a*b < (c-a-b)**2 and c-a-b > 0: print('Yes') else: print('No') if __name__ == '__main__': main()
p03639
s544296437
Accepted
N = int(input()) A = list(map(int,input().split())) Lo = 0 L2 = 0 L4 = 0 for i in range(N): if A[i]%2==1: Lo+=1 elif A[i]%4==0: L4+=1 else: L2+=1 if Lo<=L4: print("Yes") else: if Lo==L4+1 and L2==0: print("Yes") else: print("No")
p03804
s431314997
Accepted
n, m = map(int, input().split()) a = [input() for _ in range(n)] b = [input() for _ in range(m)] from itertools import product for i,j in product(range(n-m+1), repeat=2): t = [] for k in range(m): t.append(a[i+k][j:j+m]) if t == b: print("Yes") break else: print("No")
p03495
s707299140
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) import collections c=collections.Counter(A) lst=c.most_common()[::-1] val_lst=[el[1] for el in lst] #print(val_lst) print(sum(val_lst[:(len(lst)-K)]))
p03495
s181152092
Wrong Answer
N,K = map(int,input().split()) A = list(map(int,input().split())) tmp = [0]*N tmp_2 = [0]*N Cnt=0 result = 0 for i in range(N): tmp[A[i]-1]+= 1 tmp_2[A[i]-1] = 1 m = sum(tmp_2)-K tmp = sorted(tmp) for i in range(N): if tmp[i]!=0: result += tmp[i] Cnt +=1 if Cnt == m: break print(result)
p02916
s645027230
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) satisfaction = 0 for i in range(N): satisfaction += B[A[i] - 1] if (i != 0) and (A[i - 1] + 1 == A[i]): satisfaction += C[A[i - 1] - 1] print(satisfaction)
p03126
s012102984
Accepted
def f11(): N, M=map(int, input().split()) item=[0 for i in range(M)] for i in range(N): A = [int(j) for j in input().split()] for j in range(A[0]): item[A[j+1]-1] += 1 print(sum([1 if item[i]==N else 0 for i in range(M)])) def main(): f11() main()
p03087
s038703503
Accepted
import bisect n, q = map(int, input().split()) S = list(input()) X = [] for i in range(n-1): if S[i] == 'A' and S[i+1] == 'C': X.append(i) for j in range(q): l, r = map(int, input().split()) a = bisect.bisect_left(X, l-1) b = bisect.bisect_left(X, r-1) print(b-a)
p02554
s395674941
Accepted
N=int(input()) x=(10**N-2*(9**N)+8**N)%(10**9+7) print(x)
p02909
s211163129
Accepted
a=["Rainy","Cloudy","Sunny"] s=input() for i in range(3): if a[i]==s: print(a[i-1])
p03219
s431305854
Wrong Answer
x, y = map(int, input().split()) print(x + y/2)
p02699
s740705449
Accepted
#!/usr/bin/python3 # -*- coding: utf-8 -*- s, w = map(int, input().split()) if s > w: print("safe") else: print("unsafe")
p03285
s808048830
Accepted
n=int(input()) for i in range(100//4): for j in range(100//7+1): if 4*i+7*j==n: print("Yes") exit() print("No")
p02918
s370002724
Accepted
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n, k = map(int, input().split()) s = input() cnt = 0 score = 0 for i in range(1, n): if s[i - 1] != s[i]: cnt += 1 else: score += 1 res = min(n - 1, score + min(k, cnt) * 2) print(res) if __name__ == '__main__': resolve()
p02732
s339277698
Accepted
from collections import defaultdict, deque import sys import heapq import bisect import itertools import queue import copy import time sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) N = inp() lis = inpl() counts = [0]*(N+10) for i in lis: counts[i] += 1 S = 0 for i in lis: S += counts[i] - 1 S //= 2 for i in lis: print(S - counts[i] + 1)
p03592
s643391725
Accepted
n,m,k = map(int,input().split()) for a in range(n+1): for b in range(m+1): if k == a*m+b*n-2*a*b: print('Yes') exit() print('No')
p02924
s829060088
Wrong Answer
n=int(input()) print(int((n*(n+1))/2))
p03327
s369384973
Wrong Answer
N = input() if N <= str(999): print('ABC') elif N <= str(1998): print('ABD')