problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03038
s796360202
Wrong Answer
import sys input = sys.stdin.readline N,M = list(map(int,input().split())) A = list(map(int,input().split())) tmp = [] for _ in range(M): tmp.append( list(map(int,input().split()))) cnt = 0 t = [] for i in range(M): t=t+[tmp[i][1]]*tmp[i][0] cnt+= tmp[i][0] if cnt >=N: break A = sorted(A+t,reverse = 1) print(sum(A[:N]))
p02835
s405923664
Accepted
def main(): A1, A2, A3 = map(int, input().split()) if A1 + A2 + A3 >= 22: ans = "bust" else: ans = "win" print(ans) if __name__ == "__main__": main()
p03544
s988496606
Accepted
N = int(input()) S = [0]*87 S[0] = 2; S[1] = 1; for i in range(2, 86+1): S[i] = S[i-1] + S[i-2] print(S[N])
p02661
s030336761
Accepted
def read_int(): return int(input()) def read_ints(): return map(int, input().split(' ')) n = read_int() a = [] b = [] for i in range(n): ai, bi = read_ints() a.append(ai) b.append(bi) a.sort() b.sort() if n % 2 == 0: ma = a[n // 2 - 1] + a[n // 2] mb = b[n // 2 - 1] + b[n // 2] print(mb - ma + 1) else: ma = a[n // 2] mb = b[n // 2] print(mb - ma + 1)
p02952
s486380689
Wrong Answer
import sys def main(): N = int(input()) cnt = 0 for i in range(1, N): if 1 <= i < 10: cnt += 1 elif 100 <= i < 1000: cnt += 1 elif 10000 <= i < 100000: cnt += 1 print(cnt) main()
p02838
s949151543
Wrong Answer
import numpy as np N=int(input()) M=10**9+7 A=[int(x) for x in input().split()] A=np.array(A) ans=0 for i in range(60): #one=sum([a>>i&1 for a in A]) one=np.sum(A>>i&1) zero=N-one ans+=(one*zero)*pow(2,i,M) ans%=M #print(one,zero) print(ans)
p02994
s122010112
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n,l = inpl() mi = INF a = [i+l for i in range(n)] no = -1 for i in range(n): if abs(a[i]) < mi: no = i mi = abs(a[i]) # print(no) print(sum(x for i,x in enumerate(a) if i != no))
p02608
s918974088
Accepted
def calc(x, y, z): return x**2 + y**2 + z**2 + x*y + y*z + z*x n = int(input()) ans = [0]*n for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): a = calc(x, y, z) if a <= n: ans[a-1] += 1 b = [str(i) for i in ans] print('\n'.join(b))
p02831
s750473401
Wrong Answer
import math A,B = map(int,input().split()) print(math.gcd(A,B)*A*B)
p03262
s402085345
Wrong Answer
import numpy as np import fractions from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) N, X = map(int, input().split()) x = np.array(list(map(int, input().split()))) if N == 1: print(np.abs(x[0] - X)) else: x = np.abs(x - X) print(min(gcd(x)))
p03338
s244635697
Wrong Answer
n = int(input()) s = list(input()) max = 0 for i in range(1, n-1): a = set(s[:i]) b = set(s[i:]) print(a & b) if max < len(a & b): max = len(a & b) print(max)
p03067
s442918738
Accepted
a, b, c = [int(i) for i in input().split()] if a < c < b or a > c > b: print("Yes") else: print("No")
p03705
s937669484
Accepted
n, a, b = map(int, input().split()) if a > b or ( n == 1 and a != b ): print(0) else: print((a+b*(n-1))-(a*(n-1)+b)+1)
p02897
s373128447
Accepted
n=int(input()) if n%2==0: print(0.5) else: print(((n-1)/2+1)/n)
p03951
s450553804
Accepted
n = int(input()) s = input() t = input() ok = False for i in range(n): if s[i:n] == t[:n-i]: ok = True break print(n + i if ok else n*2)
p03103
s334745256
Accepted
n, m = map(int, input().split()) lst = [list(map(int, input().split())) for i in range(n)] lst.sort() lst = lst[::-1] ans = 0 while m > 0: if lst[-1][1] <= m: ans += lst[-1][0] * lst[-1][1] m -= lst[-1][1] else: break lst.pop() if m > 0: ans += lst[-1][0] * m print(ans)
p02719
s339345055
Wrong Answer
N,K = map(int,input().split()) i = 0 if K == 1: print(0) else: results = [N] while i < K: N = N - K if N < 0: results.append(-N) N = -N else: results.append(N) i += 1 print(min(results))
p02642
s586956344
Accepted
import numpy as np from collections import Counter length=int(input()) list=list(map(int,input().split())) list.sort() max=list[-1] dp=[0]*(max+1) dp=np.array(dp,int) for num in list: dp[num]=1 for num in list: if dp[num]==1: dp[2*num::num]=0 count=Counter(list) for num,cnt in count.items(): if cnt>1: dp[num]=0 print(dp.sum())
p03127
s175917561
Wrong Answer
from math import gcd n = int(input()) a = list(map(int,input().split())) g = a[0] for i in a: g = gcd(g,i) print(i)
p02789
s197200296
Wrong Answer
n, m = map(int, input().split()) if n == m: print('AC') elif n > m: print('WA')
p02681
s050080136
Accepted
S = input() T = input() if T[:-1] == S: print("Yes") else: print("No")
p02820
s036991409
Accepted
import numpy as np N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = input() dic = {"r":P, "s":R, "p":S}#key:筐体が出した手、val:それに勝ったら貰える点 points = 0 for st in range(K): series = T[st::K] prev = "x" for now in series: if now != prev: points += dic[now] prev = now else: prev = "x" print(points)
p02786
s635785270
Accepted
def resolve(): H = int(input()) cnt = 0 mons = 1 while H != 1: H = H//2 cnt += mons mons *= 2 print(cnt+mons) if '__main__' == __name__: resolve()
p03623
s343940348
Accepted
x,a,b= map(int,input().split()) print("A" if abs(x-a)<abs(x-b) else 'B')
p02996
s959602053
Accepted
n = int(input()) t = 0 task = [] for i in range(n): a,b = map(int,input().split()) task.append([b,a]) task.sort() ans = "Yes" for i in range(n): t += task[i][1] if task[i][0] < t: ans = "No" break print(ans)
p03557
s660350278
Accepted
# ABC077C import bisect N=int(input()) A=sorted(list(map(int,input().split()))) B=sorted(list(map(int,input().split()))) C=sorted(list(map(int,input().split()))) bC=[0 for i in range(N)] for i in range(N): bC[i]=N-bisect.bisect(C,B[i]) bCS=[0]*(N+1) for i in range(N): bCS[i+1] = bCS[i]+bC[i] ans=0 for i in range(N): x=bisect.bisect(B,A[i]) ans+=bCS[N]-bCS[x] print(ans)
p03944
s243979866
Accepted
w,h,n=map(int,input().split()) mix=0 mx=w miy=0 my=h for i in range(n): x,y,a=map(int,input().split()) if a==1: mix=max(mix,x) elif a==2: mx=min(mx,x) elif a==3: miy=max(miy,y) else: my=min(my,y) if mix>=mx or miy>=my: print(0) else: print((mx-mix)*(my-miy))
p02995
s460720639
Wrong Answer
import fractions a,b,c,d = map(int,input().split()) num = b-a+1 ac = int((a-1)/c) ad = int((a-1)/d) bc = int(b/c) bd = int(b/d) e = c*d//(fractions.gcd(c,d)) a = int(a/e) b = int(b/e) c = bc-ac d = bd-ad e = b-a print(num-(c+d-e))
p03548
s981788926
Wrong Answer
A,B,C = map(int,input().split()) print((A+C)//B)
p03719
s004674156
Accepted
a, b, c = list(map(int, input().split())) if a <= c <= b: print("Yes") else: print("No")
p03778
s500827138
Wrong Answer
w,a,b=map(int,input().split()) if a+w<b: print(b-a-w) else: print(0)
p02576
s395978669
Accepted
n,x,t=map(int,input().split()) count=0 a=0 a=x if(n<=x): print(t,end='\n') elif(x==1): print((n)*t) else: while(x<n): count=count+1 x=x+a print((count+1)*t)
p02811
s316907434
Accepted
k, x = map(int, input().split()) if (k*500) >= x: print('Yes') else: print('No')
p02963
s176724854
Wrong Answer
s = int(input()) a = s ** 2 % 10 ** 9 b = s ** 2 // 10 ** 9 print(0, 0, 10 ** 9, 1, a, b)
p03062
s994429769
Accepted
n = int(input()) aa = list(map(int,input().split())) minus_count = sum([1 for v in aa if v<0]) a = [abs(v) for v in aa] if minus_count % 2 == 0: print(sum(a)) else: print(sum(sorted(a)[1:]) - min(a))
p03076
s633234569
Accepted
meals=[] for i in range(5): meals.append([i,int(input())]) for g in range(5): if meals[g][1]%10!=0: meals[g][0]=meals[g][1]%10 else: meals[g][0]=10 meals.sort(reverse=True) ans=0 for i in range(4): ans+=meals[i][1]+10-meals[i][0] ans+=meals[-1][1] print(ans)
p02676
s626218548
Accepted
k = int(input()) s = input() if len(s) <= k: print(s) else: print(s[:k] + "...")
p03565
s908366377
Accepted
S = input() T = input() res = [] ok = -1 for i in range(len(S) - len(T) + 1): if S[i] == T[0] or S[i] == "?": for j in range(len(T)): if S[i + j] not in ("?", T[j]): break else: s = S[:i] + T + S[i + len(T):] res.append(s.replace("?", "a")) if res: print(min(res)) else: print("UNRESTORABLE")
p04012
s043465188
Accepted
from collections import Counter s = input() s = Counter(s) for i in s.values(): if i%2!=0: print("No") break else:print("Yes")
p03730
s124388778
Wrong Answer
A,B,C=map(int,input().split()) if A%B==0 : if C==0: print('YES') else: print('NO') elif (A%B)%2==1: if C%2==1: print('YES') else: print('NO') elif (A%B)%2==0: print('YES')
p03796
s984267627
Accepted
N = int(input()) a = 1 for i in range(1,N+1): a *= i a %= 10**9 + 7 print(a)
p02547
s314549772
Accepted
n = int(input()) c = 0 for i in range(n): d1, d2 = map(int, input().split()) if(d1 == d2): c += 1 else: c = 0 if(c >= 3): print("Yes") exit() print("No")
p03327
s068765799
Accepted
if int(input()) >= 1000: print("ABD") else: print("ABC")
p03795
s525317183
Wrong Answer
n = int(input()) b = int(n/15) print(n*800-n*200)
p02777
s764533741
Wrong Answer
y = input() x = [int(x) for x in input().split()] y = input() if (y == 'red'): print(x[0]-1,x[1]) else: print(x[0], x[1]-1)
p02873
s934488923
Wrong Answer
S = input() s_Count = 0 b_Count = 0 ans = 0 for i in range(len(S)): if S[i] == "<" and i != len(S)-1: s_Count += 1 else: b_Count += 1 if i == len(S)-1 or S[i+1] == "<": max_sb = max(s_Count,b_Count) min_sb = min(s_Count,b_Count) - 1 ans += max_sb * (max_sb+1) / 2 + min_sb * (min_sb+1) / 2 s_Count = 0 b_Count = 0 print(int(ans))
p03317
s015383508
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) print((N-1-1)//(K-1)+1)
p02910
s574726602
Accepted
S=input() if S[0::2].count("L")==0 and S[1::2].count("R")==0: print("Yes") else: print("No")
p03469
s152295864
Accepted
d = input().split("/") d[0] = "2018" print("/".join(d))
p02833
s072878097
Accepted
def main(): n = int(input()) if n%2==1: print(0) else: ans = 0 waru = 10 while n>=waru: ans += n//waru waru = waru*5 print(ans) if __name__ == "__main__": main()
p03408
s034080960
Accepted
N = int(input()) from collections import defaultdict d_blue = defaultdict(int) strs = set() for i in range(N): s = input() d_blue[s] += 1 strs.add(s) M = int(input()) d_red = defaultdict(int) for j in range(M): t = input() d_red[t] += 1 strs.add(t) ans = 0 for s in strs: b = d_blue[s] t = d_red[s] ans = max(ans,b-t) print(ans)
p02820
s903233653
Wrong Answer
n, k = map(int, input().split()) r, s, p = map(int, input().split()) S = input() pt = [] for i in range(n): if S[i]=='r': t = p elif S[i]=='s': t = r else: t=s pt.append(t) for i in range(n-k): if pt[i]==pt[i+k]: pt[i+k]=0 print(sum(pt))
p03001
s116383922
Accepted
W, H, x, y = [int(i) for i in input().strip().split()] S = (W*H) / 2 if (W % 2 == 0) and (H % 2 == 0) and (W // 2 == x) and (H // 2 == y): print(str(S) + " " + str(1)) else: print(str(S) + " " + str(0))
p02713
s936499369
Wrong Answer
import math k = int(input()) num = 0 for a in range(0, k + 1): for b in range(0, k + 1): c = math.gcd(a, b) for d in range(0, k + 1): num += math.gcd(c, d) print(num)
p02594
s433580612
Wrong Answer
X = int(input()) if X>30: print("Yes") else: print("No")
p02640
s524692417
Wrong Answer
x,y=map(int,input().split()) ans='No' for i in range(x+1): j=x-i if 2*x+4*j==y: ans='Yes' print(ans)
p03293
s785271449
Accepted
s=input() t=input() print("Yes" if t in s*2 else "No")
p03037
s909713837
Wrong Answer
N, M = map(int, input().split()) l = 0 r = N for i in range(M): L, R = map(int, input().split()) if M == 1: print(R-L+1) break else: if L > l: l = L if R < r: r = R ans = r - l + 1 else: print(ans)
p02624
s439614300
Accepted
n = int(input()) s = 0 for i in range(1, n+1): x = n // i s += i * (x * (x+1)) / 2 print(int(s))
p02899
s950604934
Accepted
N = int(input()) A = list(map(int, input().split())) rev = [0] * N for i in range(N): rev[A[i]-1] = i+1 print(*rev)
p03329
s764451181
Accepted
import math n = int(input()) target_ls = [1] target_6 = 6 while target_6 <= n: target_ls.append(target_6) target_6 *= 6 target_9 = 9 while target_9 <= n: target_ls.append(target_9) target_9 *= 9 dp = [float('inf')] * (n+1) dp[0] = 0 for i in range(n): for j in target_ls: if i+j <= n: dp[i+j] = min(dp[i+j],dp[i] + 1) print(dp[n])
p03352
s553915248
Wrong Answer
X = int(input()) x = 0 for i in range(2,int(X ** 0.5) + 1): n = 1 a = i while n < X : n *= a if n // a > x: x = (n // a) print(x)
p02659
s355484208
Accepted
a,b = input().split() a = int(a) b = b.replace('.','') b = int(b) answer = str(a*b) if (len(answer) <=2): print(0) else: print(answer[:-2])
p03693
s818864753
Accepted
r, g, b = map(int, input().split()) rgb=int(str(r) + str(g) + str(b)) if rgb % 4 == 0: print("YES") else: print("NO")
p02554
s442642844
Wrong Answer
def func(a, n): p = 10 ** 9 + 7 bi = str(format(n, "b")) res = 1 for i in range(len(bi)): res = (res * res) % p if bi[i] == "1": res = (res * a) % p return res N = int(input()) n = func(10, N) no_0 = func(9, N) no_9 = func(9, N) no_09 = func(8, N) ans = (n - no_0 - no_9 + no_09) if ans < 0: ans += 10 ** 9 + 7 print(ans)
p03062
s284869790
Accepted
n = int(input()) A = list(map(int, input().split())) absA = [abs(a) for a in A] if sum(True if a < 0 else False for a in A) % 2 == 0: ans = sum(absA) else: ans = sum(absA) - 2 * min(absA) print(ans)
p03910
s762378334
Accepted
N=int(input()) def is_ok(n): if n*(n+1)//2>=N: return True else: return False ng=0 ok=N+1 while abs(ng-ok)>1: mid=(ok+ng)//2 if is_ok(mid): ok=mid else: ng=mid diff=ok*(ok+1)//2-N for i in range(1,ok+1): if i!=diff: print(i)
p03328
s407563939
Wrong Answer
a,b=map(int,input().split()) A=[] for i in range(1,1000): A.append((i*(i+1))//2) for j in range(10**6): if ((a+j) in A) and ((b+j) in A): print(j) exit()
p02787
s381969094
Wrong Answer
import time h, n = map(int, input().split()) INF = 10 ** 20 dp = [INF] * (h + 10 ** 4) dp[0] = 0 magic = [] for i in range(n): magic.append(list(map(int, input().split()))) magic.sort(key=lambda x: x[0]) for a, b in magic: for i in range(h - a + 1): if dp[i] == INF: continue dam = i + a if dp[dam] > dp[i] + b: dp[dam] = dp[i] + b ans = min(dp[h:]) print(ans)
p02953
s098440470
Accepted
n = int(input()) hoge_list = list(map(int,input().split())) h_list = hoge_list[::-1] mae = h_list[0] s = 0 for h in h_list: if h <= mae: mae = h elif h-1 == mae: mae = h-1 else: print('No') s += 1 break if s == 0: print('Yes')
p03327
s445200420
Wrong Answer
N=int(input()) if N < 1000: print('ABC') elif 1000 <= N < 1998: print('ABD')
p02553
s821392816
Accepted
a,b,c,d=map(int,input().split()) print(max(a*c,a*d,b*c,b*d))
p03086
s657814523
Accepted
S="x"+input() T=[0]*(len(S)+1) U={"A","C","G","T"} for i in range(len(S)): if S[i] in U: T[i]=T[i-1]+1 else: T[i]=0 print(max(T))
p03679
s827790457
Accepted
x, a, b = map(int, input().split()) d = -1*a + b if(d <= 0): print("delicious") elif(abs(d) <= x): print("safe") else: print("dangerous")
p02647
s931621279
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) B = A.copy() k = 0 while k < K and sum(B) < N**2: tmp = [0]*N i = 0 while i < N: a = B[i] tmp[max(0, i-a)] += 1 if i+a+1 < N: tmp[i+a+1] -= 1 i += 1 s = 0 i = 0 while i < N: B[i] = tmp[i]+s s = B[i] i += 1 k += 1 print(" ".join([str(b) for b in B]))
p02642
s471096859
Wrong Answer
n = int(input()) A = sorted(list(map(int, input().split()))) if len(set(A)) == 1: print(0) exit() from collections import Counter c = Counter(A) NMAX = 10 ** 6 + 1000 dp = [True] * (NMAX + 1) for k, v in c.items(): if dp[k]: for i in range(k * 2, NMAX + 1, k): dp[i] = False if v > 1: dp[k] = False count = 0 for k, v in c.items(): if v > 1: continue if dp[k]: count += 1 print(count)
p03069
s995804260
Accepted
N = int(input()) S = input() b, w = 0, 0 for i in range(N): if S[i] == '#': b += 1 else: w += 1 ans = [0 for _ in range(N+1)] ans[0], ans[-1] = w, b for i in range(1, N): if S[i-1] == '#': ans[i] = ans[i-1] + 1 else: ans[i] = ans[i-1] - 1 print(min(ans))
p02694
s663859523
Wrong Answer
X = int(input()) ans = 0 money = 100 while money < X: money += int(money * 0.01) ans += 1 print(ans)
p03795
s577415131
Wrong Answer
N = int(input()) # Nは食事数 x = 800*N # xは払った金額の合計 y = N // 15*200 # yはもらった金額の合計 # /:商、小数点以下まで表示される # //:切り捨て、小数点以下が切り捨てられる answer = x-y
p02548
s052327330
Accepted
N = int(input()) counter = 0 for A in range(1,N): for B in range(1,N//A+1): if 0 < A*B < N: counter += 1 print(counter)
p03494
s903990120
Accepted
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] #a = [list(input()) for _ in range(n)] #a = [int(input()) for _ in range(n)] n = int(input()) a = list(map(int, input().split())) def func(a): rtn = 0 while a % 2 == 0: a //= 2 rtn+=1 return rtn for i in range(n): a[i] = func(a[i]) print(min(a))
p02717
s936314194
Accepted
X,Y,Z = map(int,input().split()) print(Z,X,Y)
p03160
s981711262
Accepted
# A Frog 1 n = int(input()) h_list = [int(x) for x in input().split()] dp = [float('Inf')]*(n) dp[0] = 0 dp[1] = abs(h_list[1] - h_list[0]) for i in range(2,n,1): dp[i] = min(dp[i-2]+abs(h_list[i]-h_list[i-2]), dp[i-1]+abs(h_list[i]-h_list[i-1])) print(dp[n-1])
p02842
s975677878
Accepted
#B(別解) import math n=int(input()) x=math.ceil(n/1.08) if math.floor(x*1.08)==n: print(x) else: print(":(")
p03723
s086908301
Wrong Answer
A,B,C = map(int,input().split()) ans = 0 if A == B and B == C: print(-1) exit() while A % 2 == 0 and B % 2 == 0 and C % 2 == 0: A,B,C = (B+C)//2,(C+A)//2,(A+B)//2 ans += 1 if A == B and B == C: print(-1) exit() print(ans)
p02658
s177265718
Accepted
n = int(input()) li = list(map(int, input().split())) ans = 1 flg = 0 for i in range(n): if flg==1 and li[i]!=0: continue elif li[i]==0: ans = 0 break else: ans *= li[i] if(ans>1000000000000000000): flg = 1 if flg==1 and ans==0: print(ans) elif flg==1: print(-1) else: print(ans)
p03131
s586433284
Accepted
k,a,b = map(int,input().split()) if a >= b or a + 2 >= b: print(k+1) else: if k+1 <= a: print(k+1) else: k = k-a+1 c = k%2 d = k//2 print(a+(b-a)*d+c)
p03136
s213670407
Accepted
N = int(input()) widths = list(map(int, input().split())) Notmax_widths = sum(widths) - max(widths) result = 'Yes' if Notmax_widths > max(widths) else 'No' print(result)
p03327
s147458485
Accepted
n = int(input()) if n < 1000: print('ABC') else: print('ABD')
p03951
s237233312
Accepted
n = int(input()) s = input() t = input() for i in range(n+1): for j in range(n+1): tmp = s[:i] + t[:j] if tmp[:n] == s and tmp[-n:] == t: print(len(tmp)) exit()
p02720
s286071076
Accepted
import queue K = int( input() ) q = queue.Queue() ret = K number_of_operations = 9 for i in range( 1, number_of_operations + 1 ): q.put( i ) while number_of_operations < K: i = q.get() k = i % 10 if k != 0: ret = 10 * i + k - 1 q.put( ret ) number_of_operations += 1 if number_of_operations == K: break ret = 10 * i + k q.put( ret ) number_of_operations += 1 if number_of_operations == K: break if k != 9: ret = 10 * i + k + 1 q.put( ret ) number_of_operations += 1 print( ret )
p03711
s806392898
Wrong Answer
x,y=map(int,input().split()) a=[1,3,5,7,8,12] b=[4,6,9,11] if (x in a and y in a) or (x in b and y in b):print("Yes") else:print("No")
p03339
s668333396
Accepted
n=int(input()) s=input() rw=s.count("W") re=s.count("E") lw=0 le=0 now="" m=10000000000000000000 for i in range(n): if now=="W":lw+=1 if now=="E":le+=1 if s[i]=="W":rw-=1 if s[i]=="E":re-=1 m=min(m,lw+re) now=s[i] print(m)
p03073
s263107119
Accepted
S = input() l = len(S) s1 = ''.join(['0' if i % 2 == 0 else '1' for i in range(l)]) s2 = ''.join(['1' if i % 2 == 0 else '0' for i in range(l)]) t1 = 0 t2 = 0 for i, j, s in zip(s1, s2, S): if i != s: t1 += 1 if j != s: t2 += 1 print(min(t1, t2))
p03611
s524594750
Accepted
from collections import defaultdict N=int(input()) alist=list(map(int,input().split())) dic_a=defaultdict(int) for a in alist: dic_a[a]+=1 #print(dic_a) max_answer=0 for v in list(dic_a): answer=dic_a[v-2]+dic_a[v-1]+dic_a[v] max_answer=max(answer,max_answer) answer=dic_a[v-1]+dic_a[v]+dic_a[v+1] max_answer=max(answer,max_answer) answer=dic_a[v]+dic_a[v+1]+dic_a[v+2] max_answer=max(answer,max_answer) print(max_answer)
p03073
s891813378
Accepted
s=list(input()) a=["0","1"] cnt=0 for i in range(len(s)): if s[i]!=a[i%2]: cnt+=1 print(min(cnt,len(s)-cnt))
p03379
s761056506
Accepted
n = int(input()) x = list(enumerate(map(int, input().split()))) x.sort(key=lambda x:x[1]) ans = [""]*n for i in range(n): if (n+1)//2 >= i+1: ans[x[i][0]] = x[(n+1)//2][1] else: ans[x[i][0]] = x[(n+1)//2-1][1] print("\n".join(map(str, ans)))
p02633
s921970160
Wrong Answer
X = int(input()) ans = 360 / X print(int(ans))
p02702
s111149527
Accepted
import copy s = list(input()) s.reverse() n = len(s) MOD = 2019 m = [0] * n msum = [0] * (n+1) cnt = [0] * (MOD) cnt[0] = 1 t = 1 for i in range(n): m[i] = int(s[i]) * t % MOD msum[i+1] = (msum[i] + m[i]) % MOD cnt[msum[i+1]] += 1 t = t * 10 % MOD ans = 0 for i in range(MOD): ans += cnt[i] * (cnt[i] - 1) // 2 print(ans)
p03625
s016729872
Accepted
n = int(input()) a = list(map(int,input().split())) a.sort() tmp = [] i =n-1 while i >0: if a[i] == a[i-1]: tmp.append(a[i]) i -=2 else: i -=1 if len(tmp)>=2: print(tmp[0]*tmp[1]) else: print(0)