problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02732
s974316077
Accepted
N = int(input()) A = list(map(int, input().split())) cnt = [0] * (N+1) ans = 0 for i in range(N): cnt[A[i]] +=1 for i in range(N+1): ans += cnt[i] * (cnt[i] - 1) // 2 for i in range(N): print(ans - cnt[A[i]] + 1)
p03774
s652984067
Accepted
N,M=map(int,input().split()) s = [tuple(map(int,input().split())) for _ in range(N)] c = [tuple(map(int,input().split())) for _ in range(M)] def calc_dict(p1,p2): return abs(p1[0]-p2[0])+abs(p1[1]-p2[1]) for i in range(N): dist = list(map(lambda x:calc_dict(s[i],x),c)) print(dist.index(min(dist))+1)
p02773
s812281443
Accepted
from itertools import groupby N =int(input()) d = [input() for i in range(N)] d.sort() #print(d) p=-1 b=[] for key, value in groupby(d): a = len(list(value)) if p<a: #print(p,len(list(value))) b=[] b.append(key) p=a elif p==a: #print(222) b.append(key) for i in b: print(i)
p02880
s515885014
Wrong Answer
n=int(input()) k=0 for i in range(9,1,-1): if n%i==0: n=n//i if n>9: k+=1 break if k>0: print('No') else: print('Yes')
p02720
s308009201
Accepted
from collections import deque k=int(input()) queue=deque(range(1,10)) x=0 for _ in range(k): x=queue.popleft() if not x%10==0: queue.append(10*x+(x%10)-1) queue.append(10*x+(x%10)) if not x%10==9: queue.append(10*x+(x%10)+1) print(x)
p03705
s169906447
Wrong Answer
# https://atcoder.jp/contests/agc015/tasks/agc015_a import math n, a, b = map(int, input().split()) if b < a: print(0) else: t = b - a + 1 ans = math.factorial(t + n - 1) // (math.factorial(t) * math.factorial(n)) print(ans)
p03486
s300348426
Accepted
def calculate(s, t): a = sorted(s) b = sorted(t,reverse=True) m = "".join(a) k = "".join(b) if m < k: print("Yes") else: print("No") # s = 'yx' # t = 'axy' # # s = 'ratcode' # t = 'atlas' # # s = 'cd' # t = 'abc' # # s = 'w' # t = 'ww' s = input() t = input() calculate(s, t)
p02687
s859734701
Accepted
S = input() if S == 'ABC': print('ARC') else: print('ABC')
p03131
s091741394
Accepted
K, A, B = map(int, input().split()) x = (K - (A - 1)) // 2 * (B - A) + A if (K - (A - 1)) % 2 != 0: x += 1 print(max(x, K + 1))
p02571
s590609502
Accepted
S = input() T = input() minCount = len(T) for i in range(len(S)-len(T)+1): count = 0 for j in range(len(T)): if S[i+j] != T[j]: count += 1 minCount = min(minCount, count) print(minCount)
p02783
s433114678
Accepted
H, A = map(int,input().split()) print( H//A if H%A == 0 else H//A+1)
p03998
s887081205
Accepted
import sys from collections import deque def main(sa,sb,sc): sa=deque(sa) sb=deque(sb) sc=deque(sc) ms={'a':sa, 'b':sb, 'c':sc} ct='a' while True: cc=ms[ct].popleft() ct=cc if not ms[ct]: return ct.upper() sa=sys.stdin.readline().strip() sb=sys.stdin.readline().strip() sc=sys.stdin.readline().strip() print(main(sa,sb,sc))
p03821
s684069688
Accepted
n = int(input()) A = [0] * n B = [0] * n ans = 0 mod = 0 for i in range(n): A[i], B[i] = map(int, input().split()) for i in range(n-1, -1, -1): ans += 0 if (A[i]+ans)%B[i]==0 else B[i] - (A[i]+ans)%B[i] print(ans)
p03239
s828050692
Wrong Answer
n, T = map(int, input().split()) c = [0 for _ in range(n)] t = [0 for _ in range(n)] for i in range(n): c[i], t[i] = map(int, input().split()) ans = 1000 for i in range(n): if t[i] <= T: ans = min(ans, c[i]) print(ans)
p03161
s317280323
Accepted
#Educational DP Contest #B-Frog2 import sys input = sys.stdin.readline #n = int(input()) n,k = map(int,input().split()) lst1 = list(map(int,input().split())) #dp table dp = [float("inf")]*n dp[0] = 0 #process1 for i in range(1,n): for j in range(max(0,i-k),i): #kの許容しうる範囲だけ回す b = abs(lst1[i]-lst1[j]) + dp[j] #(j迄の最小コスト)+(jからiまでのコスト) dp[i] = min(dp[i],b) #output process print(dp[-1])
p03435
s604724469
Wrong Answer
su=0 for i in range(3): l=list(map(int,input().split())) s=sum(l) su+=s print('Yes' if su%3==0 else 'No')
p02795
s792988556
Accepted
h = int(input()) w = int(input()) n = int(input()) if h > w: print(-(-n//h)) else: print(-(-n//w))
p02645
s145440466
Wrong Answer
import random s=list(input()) print(''.join(random.sample(s, 3)))
p03623
s003617238
Wrong Answer
x,a,b=map(int,input().split()) print(min(abs(x-a),abs(x-b)))
p03076
s072836328
Wrong Answer
import math list=[int(input()) for x in range(5)] ans=[] for l in list: ans.append(math.ceil(l/10)*10) print(sum(ans))
p03796
s963441020
Wrong Answer
number = int(input()) result = 1 for index in range(1, number): result = result * index dividor = 10 ** 9 + 7 print (result % dividor)
p03721
s620722977
Accepted
#!/usr/bin.env python3 N,K = map(int,input().split()) queries = [list(map(int,input().split())) for _ in range(N)] queries = sorted(queries,key=lambda x: x[0]) arrayLength = 0 for i in range(N): arrayLength += queries[i][1] if arrayLength >= K: print(queries[i][0]) exit() print(-1)
p02608
s512471793
Accepted
import sys input = lambda: sys.stdin.readline().rstrip("\r\n") n = int(input()) ans = [0]*10**5 for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): ans[i**2 + j**2 + k**2 + i*j + j*k + k*i] += 1 print(*ans[1:n + 1], sep='\n')
p02665
s803548194
Accepted
def main(): input() in_a = list(map(int, input().split())) leaves = [0] * len(in_a) leaves[-1] = in_a[-1] if in_a[0] > 1: print(-1) return for i in range(len(in_a)-2, -1, -1): leaves[i] = leaves[i+1] + in_a[i] node = 1 total = 1 for i in range(1, len(in_a)): n = (node - in_a[i-1]) * 2 if n < in_a[i]: print(-1) return node = min(n, leaves[i]) total += node print(total) if __name__ == '__main__': main()
p02957
s949346594
Wrong Answer
a,b = map(int,input().split()) if (a+b) % 2 == 0: print(int((a+b)/2)) else: print("impossible")
p02702
s157908922
Accepted
from collections import defaultdict s = input() cnt = defaultdict(int) cnt[0] += 1 tmp = 0 for i, c in enumerate(s[::-1]): c = int(c) tmp = (tmp + c * pow(10, i, 2019)) % 2019 cnt[tmp] += 1 # print(cnt) print(sum(c * (c - 1) // 2 for c in cnt.values()))
p02948
s728242162
Accepted
from heapq import heappush, heappop N, M = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] pq = [] for a, b in X: heappush(pq, (a, b)) cand = [] ans = 0 for t in range(1, M + 1): while pq: a, b = heappop(pq) if a <= t: heappush(cand, -b) else: heappush(pq, (a, b)) break if cand: v = heappop(cand) ans += -v print(ans)
p02987
s294887893
Wrong Answer
S=input() if S[0]!=S[2] or S[0]!=S[3]: if S[0]==S[1] and S[2]==S[3]: print('YES') elif S[0]==S[3] and S[2]==S[1]: print('YES') elif S[0]==S[2] and S[3]==S[1]: print('YES') else: print('NO') else: print('NO')
p03478
s052586564
Wrong Answer
N, A, B = map(int, input().split()) count = 0 num1 = 0 num2 = 0 for i in range(1, N + 1): if i < 10: if i >= A and i <= B: count = count + i else: num1 = str(i)[0] num2 = str(i)[1] num = int(num1) + int(num2) if num >= A and num <= B: count = count + 1 print(count)
p03162
s043440384
Accepted
n = int(input()) dp = [[0]*3 for i in range(n)] li = [list(map(int, input().split())) for i in range(n)] dp[0] = li[0] for i in range(1,n): dp[i][0] = max(dp[i-1][1]+li[i][0], dp[i-1][2]+li[i][0]) dp[i][1] = max(dp[i-1][0]+li[i][1], dp[i-1][2]+li[i][1]) dp[i][2] = max(dp[i-1][0]+li[i][2], dp[i-1][1]+li[i][2]) print(max(dp[-1][0], dp[-1][1], dp[-1][2]))
p02713
s778401993
Accepted
from math import gcd K = int(input()) total = 0 for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): total += gcd(gcd(a,b),c) print(total)
p02888
s844732630
Accepted
from bisect import bisect_left n = int(input()) arr = list(map(int, input().split())) arr.sort() ans = 0 for small in range(n - 2): for mid in range(small + 1, n - 1): div = bisect_left(arr, arr[small] + arr[mid], 0, n) if div > mid + 1: ans += div - mid - 1 print(ans)
p03785
s729991318
Accepted
n, c, k = list(map(int, input().split())) t = [] for i in range(n): t.append(int(input())) t = sorted(t) cnt = 1 cap = 1 first = t[0] for i in range(1, n): if t[i] > first + k: cnt += 1 cap = 1 first = t[i] elif cap == c: cnt += 1 cap = 1 first = t[i] else: cap += 1 print(cnt)
p02603
s843350742
Wrong Answer
N=int(input()) A=list(map(int,input().split())) G=1000 K=0 for i in range(N-1): if A[i+1]>A[i]: K=int(G/A[i]) G=G % A[i] if A[i+1]<A[i]: G=G+A[i]*K K=0 G=G+A[N-1]*K print(G)
p02959
s949109857
Accepted
f=lambda:list(map(int,input().split())) n=f()[0];l=f();c,t=0,l[0] for a,b in zip(l[1:],f()): s=min(t+a,b);t=min(max(t+a-s,0),a);c+=s print(c)
p02912
s522791713
Wrong Answer
N, M = map(int, input().split()) prices = list(map(int, input().split())) prices.sort() discounts = prices[:M] proper = prices[M:] for i in range(M): max_idx = discounts.index(max(discounts)) discounts[max_idx] = discounts[max_idx] // 2 print(sum(discounts)+sum(proper))
p02553
s851725957
Accepted
#!/usr/bin/env python3 def main(): a, b, c, d = map(int, input().split()) ans = -10 ** 20 for x in [a, b]: for y in [c, d]: ans = max(ans, x * y) print(ans) if __name__ == '__main__': main()
p03417
s451393857
Wrong Answer
N,M = map(int,input().split()) if(min(N,M)==1): print(max(N,M)-2) else: print(max(N-2,0)*max(M-2,0))
p03862
s575814766
Wrong Answer
import collections N, x = map(int, input().split()) A_lis = list(map(int, input().split())) A_q = collections.deque(A_lis) con = 0 tmp1 = A_q.popleft() for i in range(N-1): tmp2 = A_q.popleft() if tmp1 + tmp2 > x: con += (tmp1 + tmp2) - x tmp1 = max(0, tmp1 - x) else: tmp1 = tmp2 print(con)
p02554
s284343126
Accepted
#import #=input() n=int(input()) #=map(int,input().split()) #=list(map(int,input().split())) #=[list(map(int,input().split())) for _ in range()] print((10 ** n - 2 * (9 ** n) + 8 ** n) % (10 ** 9 + 7))
p03293
s472631584
Wrong Answer
def resolve(): s = input() t = input() if sorted(s) == sorted(t): print('Yes') else: print('No') resolve()
p02817
s601956632
Accepted
s,t = map(str,input().split()) print(t,s,sep="")
p02600
s063612172
Wrong Answer
N = int(input().strip()) if N<599:print(8) elif N<799:print(7) elif N<999:print(6) elif N<1199:print(5) elif N<1399:print(4) elif N<1599:print(3) elif N<1799:print(2) else: print(1)
p02888
s029510209
Accepted
inf = 1001001001 n = int(input()) lis = list(map(int, input().split())) lis.sort() lis.append(inf) ans = 0 for i in range(n-2): a = lis[i] for j in range(i + 1, n-1): b = lis[j] l = j r = n while r > l+1: mid = (l+r) // 2 if lis[mid] < a + b: l = mid else: r = mid ans += l - j print(ans)
p03693
s524377364
Wrong Answer
a,b,c = map(str,input().split()) print("YES" if int(a + b +c) % 4 == 0 else "No")
p03324
s126884185
Wrong Answer
d,n = map(int,input().split()) print(100**d*n)
p02725
s652745588
Accepted
K, N = list(map(int, input().split())) A = list(map(int, input().split())) a = K + A[0] A = A + [a] #print(A) B = [] for i in range(N): B.append(A[i+1] - A[i]) B = sorted(B,reverse = False) print(sum(B) - max(B))
p03163
s374676730
Accepted
from numpy import* f=lambda:map(int,input().split()) N,W=f() T=zeros(W+1,int) exec('w,v=f();T[w:]=maximum(T[w:],T[:-w]+v);'*N) print(T[-1])
p02983
s904690783
Accepted
l, r = map(int,input().split()) if r - l >= 2019: print(0) else: ans = 2019 for i in range(l,r+1): for j in range(i+1,r+1): ans = min(ans, (i*j)%2019) print(ans)
p02714
s393531475
Accepted
import sys from collections import Counter def input(): return sys.stdin.readline().rstrip() def main(): n=int(input()) s=input() c_s=Counter(s) sum_a=0 for diff in range(1,(n-1)//2+1): for i in range(n-2*diff): if s[i]!=s[i+diff] and s[i+diff]!=s[i+2*diff] and s[i]!=s[i+2*diff]: sum_a+=1 print(c_s['R']*c_s['G']*c_s['B']-sum_a) if __name__=='__main__': main()
p03038
s489692796
Accepted
#abc127d n,m=map(int,input().split()) a=list(map(int,input().split())) l=[] for i in range(m): bi,ci=map(int,input().split()) l.append((ci,bi)) for i in range(n): l.append((a[i],1)) l=sorted(l,reverse=True) r=n res=0 for x in l: q=min(r,x[1]) res+=q*x[0] r-=q if r==0: break print(res)
p03778
s361916489
Accepted
w,a,b = map(int, input().split()) if (a <= b <= a+w) or (a <= b+w <= a+w): print(0) elif a+w < b: print(b-a-w) elif b+w < a: print(a-b-w)
p02658
s742094936
Accepted
n = int(input()) a = list(map(int, input().split())) ans = 1 if min(a) == 0: print(0) else: for i in range(n): ans *= a[i] if ans > 10**18: ans = 0 print(ans if ans != 0 else -1)
p03803
s506241630
Accepted
a,b=map(int,input().split()) list=[2,3,4,5,6,7,8,9,10,11,12,13,1] # print(list.index()) a_val=list.index(a) b_val=list.index(b) if a_val>b_val:print('Alice') elif a_val<b_val:print('Bob') else:print('Draw')
p02659
s614797903
Accepted
A, B = input().split() a = int(A) if '.' in B: b, c = B.split('.') p = len(c) b = int(b) * 10 ** p + int(c) else: b = int(B) p = 0 print(a * b // 10 ** p)
p03543
s547339914
Accepted
S=str(input()) if (str(S[0])==str(S[1]) and str(S[0])==str(S[2])) or (str(S[1])==str(S[2]) and str(S[1])==str(S[3])): print("Yes") else: print("No")
p02606
s344003699
Wrong Answer
lst = input().split() L = int(lst[0]) R = int(lst[1]) d = int(lst[2]) if L % d != 0: L = L + d - (L % d) if R % d != 0: R = R - d + (R % d) result = int(((R - L) / d) + 1) print(result)
p02742
s696131609
Wrong Answer
h,w = map(int,input().split()) ans = (h*w)//2 if h%2 == 1 and w%2 == 1: ans += 1 print(ans)
p03951
s387144759
Accepted
import sys def input(): return sys.stdin.readline().rstrip() N=int(input()) s=input() t=input() def func(): for i in range(N): if s[i:]==t[0:N-i]: return i+N return N*2 print(func())
p02778
s274227220
Accepted
S = input() x = len(S) i = 1 while i <= x: print("x", end="") i += 1
p03136
s058513155
Wrong Answer
n = int(input()) l = list(map(int, input().split())) if sum(l)-max(l) > max(l): print('yes') else: print('no')
p02742
s721812548
Accepted
h, w = map(int, input().split()) if h == 1 or w == 1: print(1) else: import math h_odds = math.ceil(h / 2) h_evens = h // 2 w_odds = math.ceil(w / 2) w_evens = w // 2 print(h_odds * w_odds + h_evens * w_evens)
p02546
s053405140
Wrong Answer
S = input() if(S[-1]=='s'): S=S[:-1]+'es' else: S=S+'s' print(S)
p03711
s706915413
Accepted
x, y = map(int, input().split()) groups = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]] for group in groups: if x in group and y in group: print('Yes') break else: print('No')
p02658
s797134329
Accepted
n = int(input()) a =list(map(int, input().split())) if 0 in a: print(0) else : prod = 1 for x in a: prod *= x if prod: if prod > 10**18: print(-1) break else : print(0) break else : print(prod)
p02683
s804842353
Wrong Answer
n,m,x = map(int, input().split()) matrix = [list(map(int, input().split())) for i in range(n)] collum = [[x[i] for x in matrix] for i in range(m + 1)] row_sum = [] flag = True for i in range(len(collum)): sum = 0 for j in range(len(collum[i])): sum += collum[i][j] row_sum.append(sum) for a, i in enumerate(row_sum): if a == 0: continue if x > i: flag = False break if flag == True: print(row_sum[0]) else: print(-1)
p02923
s974353244
Accepted
N = int(input()) H = list(map(int, input().split())) old = H[0] ans = 0 a = 0 for i in range(1,N): if H[i] <= old: a += 1 else: if a > ans: ans = a a = 0 old = H[i] if a > ans: ans = a print(ans)
p03086
s933322479
Accepted
s = input() n = len(s) l = ['A','C','G','T'] ans = 0 a = 0 for i in range(n): if s[i] in l: a += 1 else: a = 0 ans = max(ans,a) print(ans)
p02909
s787631244
Accepted
import sys def S(): return sys.stdin.readline().rstrip() d = {'Sunny':'Cloudy','Cloudy':'Rainy','Rainy':'Sunny'} print(d[S()])
p02946
s331258930
Wrong Answer
k,x=[int(s) for s in input().split()] r=[] for i in range(k-1): r.append(x-k+i+1) for j in range(k): r.append(x+j) print(r)
p02713
s729872918
Accepted
import math K = int(input()) ans=0 for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): t=math.gcd(a,b) t=math.gcd(t,c) ans+=t print(ans)
p02554
s258705276
Accepted
n = int(input()) mod = 10**9+7 total = 10**n % mod rest = (((9**(n) % mod) * 2 % mod) - (8**n % mod)) % mod print((total - rest) % mod)
p02880
s756709785
Accepted
import sys N = int(input()) for i in range(1, 10): if N % i == 0: if 1 <= N/i <= 9: print('Yes') sys.exit(0) else: continue print('No')
p02970
s086579557
Wrong Answer
N,D=map(int,input().split()) print(N//(2*D+1)+1)
p02923
s822398411
Accepted
N = int(input()) H = list(map(int,input().split())) dp = {N-1:0} def f(n): if n in dp: return dp[n] if H[n] >= H[n+1]: dp[n] = 1+dp[n+1] return dp[n] else: dp[n] = 0 return 0 maxc = 0 for i in range(N-1,-1,-1): maxc = max(maxc, f(i)) print(maxc)
p02641
s982248919
Accepted
x, n = map(int, input().split()) P = set(list(map(int, input().split()))) notP = set(list(range(-1, 102))) - P #print(notP) min_dif = 10000 ans = 10000 for num in list(notP): dif = abs(x - num) if dif < min_dif: min_dif = dif ans = num elif dif == min_dif and num < ans: min_dif = dif ans = num print(ans)
p02881
s956527182
Accepted
N = int(input()) from math import sqrt def get_divs(n): divs = [] for i in range(1, int(sqrt(n)) + 1): if n % i == 0: divs.append((i, n // i)) return divs divs = get_divs(N) ans = float('inf') for x, y in divs: ans = min(ans, (x + y - 2)) print(ans)
p02897
s070880117
Accepted
import os, sys, re, math N = int(input()) print(((N + 1) // 2) / N)
p04029
s635521740
Accepted
N = int(input()) print(N * (N + 1) // 2)
p02953
s476380294
Wrong Answer
n = int(input()) stair = input().split(' ') flag = 0 for i in range(0, n - 1): if (int(stair[i]) < int(stair[i+1])): stair[i+1] = int(stair[i+1]) - 1 if (int(stair[i]) > int(stair[i+1])): print("No") exit; print("Yes")
p03035
s602809505
Accepted
a, b = map(int, input().split()) if a >= 13: print(b) elif a <= 5: print(0) else: print(b//2)
p02768
s653251600
Accepted
def cmb(n,r,mod=10**9+7): if r<0 or r>n:return 0 return g1[r]*g2[r]%mod mod=10**9+7 n,a,b=map(int,input().split()) k=max(a,b) g1=[1,n] g2=[1,1] inverse=[0,1] for i,j in enumerate(range(n-1,((n-k+1)-1),-1)): i=i+2 g1.append((g1[-1]*j)%mod) inverse.append((-inverse[mod%i]*(mod//i))%mod) g2.append((g2[-1]*inverse[-1]%mod)) print((2**n-1-cmb(n,a)-cmb(n,b))%mod)
p03211
s822081458
Accepted
S = input() A = [] for n in range(len(S)-2): A.append(abs(int(S[n:n+3])-753)) print(min(A))
p02548
s800081464
Wrong Answer
N = int(input()) if N == 2: print(0) import sys sys.exit() if N == 3: print(3) import sys sys.exit() s = 0 m = N//2 if N%2 == 0 else N//2 + 1 for n in range(1, m): s += (N//n if N%n != 0 else N//n - 1) print(s+N//2)
p02910
s057744655
Wrong Answer
s = list(input()) for i in s[::2]: if i=='L': print('No') exit() for i in s[1::2]: if i=='R': print('No') exit print('Yes')
p02842
s184266703
Wrong Answer
N=int(input()) ans=round(N/1.08) if int(ans*1.08)==N: print(ans) else: print(":(")
p02598
s386072803
Wrong Answer
import math N,K = map(int,input().split()) A = list(map(int,input().split())) m = 0 M = max(A) while(M-m>0.0001): mm = 0 mid = (M+m)/2 for i in range(N): mm += math.ceil(A[i]/mid)-1 if mm>K: m = mid else: M = mid print(math.ceil(mid))
p03086
s606777747
Wrong Answer
def s0():return input() def s1():return input().split() def s2(n):return [input() for x in range(n)] def s3(n):return [[input().split()] for _ in range(n)] def n0():return int(input()) def n1():return [int(x) for x in input().split()] def n2(n):return [int(input()) for _ in range(n)] def n3(n):return [[int(x) for x in input().split()] for _ in range(n)] s=s0() ans=0 c=0 for x in s: if x in "ACGT": c+=1 else: ans=max(ans,c) c=0 print(ans)
p02790
s156343460
Wrong Answer
a, b = map(str, input().split()) num1 = int(a * int(b)) num2 = int(b * int(a)) if num1 >num2: print(num2) if num1 <num2: print(num1) else: print(num1)
p02657
s452807783
Wrong Answer
X=list(map(int,input().split())) for i in range(len(X)): if X[i]==0: print(i+1)
p03380
s494628923
Wrong Answer
def main(): from bisect import bisect_right n, *a = map(int, open(0).read().split()) a.sort() x = max(a) i = bisect_right(a, x / 2) p, q = a[i], a[i - 1] if p == x: print(x, q) elif (x / 2 - p) < (x / 2 - q): print(x, p) else: print(x, q) if __name__ == '__main__': main()
p03487
s667213793
Wrong Answer
from collections import defaultdict N = int(input()) A = list(map(int,input().split())) hashmap = defaultdict(int) for a in A: hashmap[a]+=1 ans = 0 for k, v in hashmap.items(): if k < v: ans+=v-k elif k > v: ans+=1 print(ans)
p02813
s069230502
Wrong Answer
N = int(input()) P = list(map(int, input().split())) Q = list(map(int, input().split())) import itertools s = [] for j in range(N): s.append(j + 1) n_P = 0 n_Q = 0 list_seed = list(itertools.permutations(s, N)) list_seed = [list(list_seed[i]) for i in range(len(list_seed))] for i in range(len(list_seed)): if list_seed[i] == P: n_P = i + 1 elif list_seed[i] == Q: n_Q = i + 1 print(abs(n_P - n_Q))
p03986
s604135967
Accepted
printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10**9 + 7 def ddprint(x): if DBG: print(x) x = ins() s = [] for c in x: s.append(c) while len(s)>1 and s[-2]=='S' and s[-1]=='T': s.pop() s.pop() print(len(s))
p02597
s573288057
Accepted
import sys input = sys.stdin.readline N=int(input().rstrip('\n')) S=list(input().rstrip('\n')) score = [S.count('R'),S.count('W')] sta = 'R' ws = 0 rs = S.count('R') sto = 0 for i in range(N): if S[i] != sta: if sta=='W': ws += sto sto = 1 score.append(max(rs,ws)) sta ='R' else: rs -= sto sto = 1 score.append(max(rs,ws)) sta ='W' else: sto += 1 print(min(score))
p03359
s085212010
Accepted
a,b = map(int,input().rstrip().split()) if a>b: print(a-1) else: print(a)
p02582
s969149314
Accepted
s = input().strip() if (s[0] == "R") and (s[1] =="R") and (s[2] =="R"): print(3) elif (s[0] == "R" and s[1] == "R" and s[2] == "S")or(s[0] == "S" and s[1] == "R" and s[2] == "R"): print(2) elif s[0] == "S" and s[1] == "S" and s[2] == "S": print(0) else: print(1)
p03206
s410100719
Wrong Answer
print("Chiristmas"+" Eve"*(25-int(input())))
p03986
s532013564
Accepted
s=input() stack=0 x=0#消したペア数 for c in s: if c=='S': stack+=1 else: if stack>0: stack-=1 x+=1 print(len(s)-x*2)
p03944
s343253388
Wrong Answer
W,H,N = map(int, input().split(' ')) ls = [] for i in range(N): ls.append(input()) WA,WZ,HA,HZ = 0,W,0,H for str_ in ls: x,y,a = map(int,str_.split(' ')) if a == 1 and WA < x: WA = x elif a == 2 and WZ > x: WZ = x elif a == 3 and HA < y: HA = y elif a == 4 and HZ > y: HZ = y if (s := (WZ-WA)*(HZ-HA)) > 0: print(int(s)) else: print(0)