problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02595
s671131087
Accepted
import math n, d = map(int, input().split()) xy = [list(map(int, input().split())) for i in range(n)] ans = 0 for i in range(n): if math.sqrt(xy[i][0] ** 2 + xy[i][1] ** 2) <= d: ans += 1 print(ans)
p03262
s187421279
Accepted
from fractions import gcd from functools import reduce n,x=map(int,input().split()) num=[abs(int(i)-x) for i in input().split() if abs(int(i)-x)!=0] print(reduce(gcd,num))
p03435
s700320278
Accepted
c = [list(map(int,input().split())) for i in range(3)] for i in range(2): if (c[i+1][0]-c[i][0]) == (c[i+1][1]-c[i][1]) == (c[i+1][2]-c[i][2]): continue else: print('No') exit(0) for j in range(2): if (c[0][j+1]-c[0][j]) == (c[1][j+1]-c[1][j]) == (c[2][j+1]-c[2][j]): continue else: print('No') exit(0) print('Yes')
p03617
s471903702
Wrong Answer
Q, H, S, D = map(int, input().split()) N = int(input()) if N%2: if D/2 < min(Q*4, H*2, S): print(N//2*D+(N-2*(N//2))*min(Q*4, H*2, S)) else: print(N*min(Q*4, H*2, S)) else: print(int(N*min(Q*4, H*2, S, D/2)))
p03386
s630131376
Accepted
A,B,K=map(int,input().split()) if B-A>200: k=range(A,A+K) l=range(B-K+1,B+1) for i in k: print(i) for i in l: print(i) else: s=range(A,B+1) t=[x for x in s if A<=x<=A+K-1 or B-K+1<=x<=B] t.sort() for i in t: print(i)
p03472
s866965809
Accepted
import bisect from collections import deque N, H = map(int, input().split()) furi = deque() nage = deque() for _ in range(N): a, b = map(int, input().split()) furi.append(a) nage.append(b) furu = sorted(furi)[-1] nage = sorted(nage) nage = deque(nage[bisect.bisect(nage, furu):]) ans = 0 while H > 0 and nage: ans += 1 n = nage.pop() H -= n if H > 0: ans += H//furu+(0 if H%furu==0 else 1) print(ans)
p03086
s042354839
Accepted
def is_acgt(s): for c in s: if c not in ["A", "C", "G", "T"]: return False return True S = input() ml = 0 for l in range(len(S)+1): for r in reversed(range(len(S)+1)): if l <= r and is_acgt(S[l:r]): ml = max(ml, r-l) print(ml)
p03665
s979024504
Accepted
n,p=map(int,input().split()) a=list(map(int,input().split())) if all(i%2==0for i in a):print(0 if p%2else 2**n) else:print(2**(n-1))
p02726
s097476417
Accepted
import sys import math import numpy n , x , y = map(int,input().split()) k = [0] * (n-1) for i in range(n): for j in range(i+1,n): cost = min( j-i , abs( (x-1) - i ) + 1 + abs( j-(y-1) ) ) k[cost - 1 ] += 1 [print(p) for p in k]
p02916
s233682720
Wrong Answer
N = int(input()) A = [_ for _ in map(int,input().split())] B = [_ for _ in map(int,input().split())] C = [_ for _ in map(int,input().split())] Happy = 0 temp = -1 for i in range(N): Happy += B[A[i]-1] if A[i]-1 == (temp+1): Happy += C[temp] temp = A[i] - 1 print(Happy)
p03427
s744361814
Accepted
str_n = input() digits = [int(c) for c in str_n] if sum(digits[1:]) == 9 * (len(digits) - 1): print(sum(digits)) else: print(digits[0] + 9 * (len(digits) - 1) - 1)
p02761
s770799300
Wrong Answer
N,M = map(int,input().split()) source = [] goal = '' for i in range(M): keta,number = map(int,input().split()) source.append((keta,number)) source.sort() for i in range(N): if i < len(source): keta,number = source[i] if i == keta-1: goal += str(number) else: goal += '0' else: goal += '0' k = int(goal) if len(str(k)) == len(goal): print(goal) else: print('-1')
p03087
s865566616
Wrong Answer
N,Q=map(int,input().split()) S=input() s_cnt=[] for i in range(N): s_cnt.append(S[:i+2].count("AC")) for i in range(Q): l,r=map(int,input().split()) print(s_cnt[r-1] - s_cnt[l-1])
p02917
s333758489
Accepted
#!/usr/bin/env python3 def main(): n = int(input()) b = list(map(int, input().split())) a = [] for i in range(n): if i == 0: a.append(b[0]) elif i == n - 1: a.append(b[-1]) else: a.append(min(b[i - 1], b[i])) print(sum(a)) if __name__ == "__main__": main()
p02572
s170105249
Wrong Answer
n = int(input()) a = list(map(int,input().split())) sum = 0 for i in a: sum += i sum = sum * sum % 1000000007 for j in a: sum = (sum - j*j) % 1000000007 print(int(sum/2))
p02823
s047988547
Accepted
N,A,B=map(int,input().split()) if (A-B)%2==0: print(abs(A-B)//2) else: if (A+B)>N: print((abs(A-B)-1)//2+(min(N-A,N-B)+1)) else: print((abs(A-B)-1)//2+(min(A-1,B-1)+1))
p03645
s135407104
Accepted
#068_C n,m=map(int,input().split()) s1=set() sn=set() for _ in range(m): a,b=map(int,input().split()) if a==1: s1.add(b) if b==n: sn.add(a) print('POSSIBLE' if len(s1&sn) else 'IMPOSSIBLE')
p02935
s421181209
Wrong Answer
n = int(input()) v = list(map(int, input().split())) ans = 0 for i in range(n-1): for j in range(i+1, n): p = (v[i] + v[j]) / 2 for k in range(n): if k == i or k == j: continue p = (p + v[k]) / 2 ans = max(ans, p) print(ans)
p03317
s933335258
Wrong Answer
n, k = map(int, input().split()) a = list(map(int, input().split())) if n == k: print(1) elif k == 2: print(n-1) else: print(n // (k-1))
p02660
s866848068
Accepted
from math import sqrt, ceil, floor def factorize(x): result = [] for p in range(2, floor(sqrt(x))): exp = 0 while x % p == 0: exp += 1 x = x // p if exp > 0: result.append((p, exp)) if x > 1: result.append((x, 1)) return result N = int(input()) factors = factorize(N) ans = sum([floor((sqrt(exp * 8 + 1) - 1) / 2) for p, exp in factors]) print(ans)
p02693
s016329758
Accepted
K = int(input()) A,B = (int(x) for x in input().split()) Flag = 0 for T in range(0,B-A+1): if (A+T)%K==0: Flag = 1 break if Flag: print('OK') else: print('NG')
p02836
s099114007
Accepted
S = input() S_rev = S[::-1] total = 0 for i in range(len(S)): if S[i] != S_rev[i]: total += 1 if total % 2 == 0: total = int(total / 2) else: total = int(total / 2) + 1 print(total)
p03062
s985620311
Accepted
N=int(input()) L=list(map(int,input().split())) count=0 sum=0 A=float("inf") for i in L: sum+=abs(i) A=min(A,abs(i)) if i<0: count+=1 if count%2==0: print(sum) else: print(sum-A*2)
p03605
s194262973
Accepted
N = input() if '9' in N: print('Yes') else: print('No')
p03759
s135390459
Wrong Answer
def main(): t = list(map(int, input().split())) if t[1] - t[0] == t[2] - t[1]: print('Yes') else: print('No') if __name__ == '__main__': main()
p03327
s890910156
Accepted
if int(input())<=999: print("ABC") else: print("ABD")
p03479
s209518425
Accepted
# one example of valid A is {X, (2 * X), (2 * 2 * X), ...} X, Y = list(map(int, input().split())) answer = 0 while X <= Y: answer += 1 X *= 2 print(answer)
p03261
s162758522
Wrong Answer
N = int(input()) W = [input() for _ in range(N)] a = [] pre = W[0] flag = False for wi in W[1:]: if wi in a or pre[-1] != wi[0]: flag = True break a.append(wi) if flag: print('No') else: print('Yes')
p02690
s372802768
Accepted
x = int(input()) for a in range(-118, 120): for b in range(-119, 119): if a**5 - b**5 == x: print(a, b) exit()
p03555
s685945791
Accepted
C1 = list(input()) C2 = list(input()) print("YES" if C1 == C2[::-1] else "NO")
p03449
s686526852
Accepted
N = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) temp = [] for i in range(N): ans = sum(a[0:i+1]) + sum(b[i:]) temp.append(ans) print(max(temp))
p03206
s993365548
Wrong Answer
D = int(input()) print("christmas" + " Eve" * (25-D))
p02584
s147636280
Wrong Answer
X, K, D = map( int, input().split()) Y = X // D if K > Y: A = Y if A % 2 != 0: if X > 0: X += D else: X -= D else: A = K print( abs( X ) - abs( A * D ) )
p03208
s761910997
Accepted
N, K = map(int, input().split()) h = [int(input()) for i in range(N)] dif = [] h.sort() for i in range(N-K+1): dif.append(h[i+K-1] - h[i]) print(min(dif))
p03799
s675754320
Wrong Answer
s,c = map(int,input().split()) res = 0 if c == 1: print(0) exit() if s*2 <= c: res += s c -= s*2 else: res += c//2 c //= 2 print(res+c//4)
p02598
s941639013
Wrong Answer
from heapq import heappush, heappop, heapify import math def solve(): n , k= map(int, input().strip().split()) if k >= 10*7: return 1 a= [(-int(x),1,int(x)) for x in input().strip().split()] heapify(a) for i in range(k): x,cnt,orig = heappop(a) x = -x if x <= 1: return 1 heappush(a,(-((orig+cnt)//(cnt+1)),cnt+1,orig)) return -(heappop(a)[0]) print(solve())
p03557
s084310739
Accepted
import bisect n = (int)(input()) a = sorted(list(map(int, input().split(" ")))) b = list(map(int, input().split(" "))) c = sorted(list(map(int, input().split(" ")))) count = 0 for i in b: #print((a[:bisect.bisect_right(a, i - 1)]), i, c[bisect.bisect_left(c, i + 1):]) #print(bisect.bisect_right(a, i - 1), i, (n - bisect.bisect_left(c, i + 1)) ) count += bisect.bisect_right(a, i - 1) * (n - bisect.bisect_left(c, i + 1)) print(count)
p03077
s903784509
Accepted
List = [] for _ in range(6): List.append(int(input())) Count = 5 MIN = min(List[1],List[2],List[3],List[4],List[5],) Count += List[0]//MIN if List[0]%MIN != 0 else (List[0]//MIN)-1 print(Count)
p02993
s702448334
Accepted
s = input() if (s[0] == s[1]) or (s[1] == s[2]) or (s[2] == s[3]): print("Bad") else: print("Good")
p02555
s983615738
Accepted
S = int(input()) arr = [0]*(S+1) MOD = 10**9 + 7 arr[0] = 1 for i in range(3,S+1): for j in range(i-3+1): arr[i] += arr[j] arr[i] = arr[i]%MOD print(arr[S])
p02982
s893718263
Accepted
import math N,D = map(int,input().split()) Xs = [list(map(int,input().split()))for i in range(N)] c = 0 for i in range(N-1): X1 = Xs[i] for j in range(i+1,N): X2 = Xs[j] su = 0 for k in range(D): su += abs(X1[k]-X2[k]) **2 distance = math.sqrt(su) if distance.is_integer(): c+=1 print(c)
p03457
s971141128
Accepted
n=int(input()) x=0 y=0 t=0 f=0 for i in range(n): T,a,b=map(int,input().split()) if not(abs(a-x)+abs(b-y)<=T-t and (abs(a-x)+abs(b-y)-(T-t))%2==0): f=1 x=a y=b t=T print("Yes" if f==0 else "No")
p03624
s062797648
Accepted
s = input() s = sorted(s) s = set(s) alpha = 'a' flg = 0 for i in range(1,27): if (alpha not in s): flg = 1 break else : alpha = chr(ord(alpha)+1) if (flg): print(alpha) else: print("None")
p03627
s985923714
Accepted
from collections import Counter n = int(input()) a = list(map(int,input().split())) a_count = sorted(Counter(a).items(),reverse=True) f = False for k,v in a_count: if (4 <= v) and (not f): print (k**2) exit () elif 2 <= v: if f: print (x*k) exit () else: x = k f = True else: pass print (0)
p02639
s520731882
Accepted
l = list(map(int, input().split())) print(l.index(0)+1)
p02554
s718080507
Wrong Answer
N = int(input()) mod = 10 ** 9 + 7 e = pow(8, N, mod) f = pow(9, N, mod) g = pow(10, N, mod) # 全体 - (0を含まない + 9を含まない) + 0と9どちらも含まない ans = g - 2 * f + e print(ans)
p03971
s116788720
Accepted
N,A,B= map(int,input().split()) S=input() f=[] d=0 e=1 for i in range(N): if S[i]=='a': if d < A+B: f.append('Yes') d+=1 else: f.append('No') if S[i]=='b': if d <A+B and e<=B: f.append('Yes') d+=1 e+=1 else: f.append('No') if S[i]=='c': f.append('No') for F in f: print(F)
p02744
s406153959
Accepted
n=int(input()) l=[["a"]]+[[] for i in range(9)] for i in range(9): for j in l[i]: k=len(set(list(j))) for h in range(k+1): l[i+1].append(j+chr(97+h)) for i in l[n-1]:print(i)
p02796
s049894253
Accepted
M,a=-float("inf"),0 for X,L in sorted(zip(*[iter(map(int,open(0).read().split()[1:]))]*2),key=sum): l,r=X-L,X+L if M<=l:a+=1;M=r print(a)
p02641
s535660722
Accepted
x, n = map(int, input().split()) p = list(map(int, input().split())) ans1, ans2 = x, x cnt1, cnt2 = 0, 0 while ans1 in p: ans1 += 1 cnt1 += 1 while ans2 in p: ans2 -= 1 cnt2 += 1 if cnt1 >= cnt2: print(ans2) else: print(ans1)
p03627
s309344553
Wrong Answer
import collections n=int(input()) A=list(map(int,input().split())) a=collections.Counter(A) firstnum=0 secondnum=0 firstl=0 secondl=0 for i,j in a.items(): if i>=firstl and j>=2: secondnum=firstnum firstnum=j secondl=firstl firstl=i elif secondl<=i<firstl and j>=2: secondnum=j secondl=i print(firstl*secondl)
p02720
s807657337
Accepted
k = int(input()) num = [1,2,3,4,5,6,7,8,9] def lunlun(m): for i in range(10): if(abs((m%10) - i ) <=1): if(m*10+i > 3234566667): return num.append(m*10+i) lunlun(m*10+i) for j in range(1,10): lunlun(j) num = sorted(num) print(num[k-1])
p02598
s364420675
Wrong Answer
N,K = map(int, input().split()) A = [int(a) for a in input().split()] def f(X): cnt = 0 for a in A: cnt += int(a/X) return max(1, cnt) l = 1 r = max(A) while r-l > 0.1: m = (r+l)/2 if f(m) <= K: r = m else: l = m if K == 0: print(max(A)) elif f(r) >= K and int(r) < r: print(int(r)+1) elif int(l) < l: print(int(l)+1) else: print(int(l))
p03455
s399214409
Wrong Answer
import sys input = sys.stdin.readline a,b=map(int,input().split()) print("Odd" if a*b%2==0 else "Even")
p02684
s602869243
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) if K<=N: next_city=0 for i in range(K): next_city=A[next_city]-1 else: next_city=0 visited=[-1]*N visited[0]=0 for num in range(1,N): next_city=A[next_city]-1 if visited[next_city]!=-1: break visited[next_city]=num K=(K-num)%(num-visited[next_city]) for i in range(K): next_city=A[next_city]-1 print(next_city+1)
p03803
s229479666
Wrong Answer
A,B=input().split() A=int(A) B=int(B) if A==B: print("Draw") if A>B: print("Alice") if B==1: print("Bob") if B>A: print("Bob") if A==1: print("Alice")
p04019
s052721918
Wrong Answer
sl = list(input()) x, y = 0, 0 for s in sl: if s == 'N' or 'S': y += 1 else: x += 1 if x%2 == 0 and y%2 == 0: print('Yes') else: print('No')
p02676
s791533602
Wrong Answer
k=int(input()) s=input() n=len(s) if k>n: print(s[:k+1]+"...") else: print(s)
p02608
s042250206
Wrong Answer
n=int(input()) ls=[0]*n x=1 y=1 z=1 p=6 m=int(n**0.5) for x in range(1,m+3): for y in range(1,x+1): for z in range(1,y+1): k=6 if x==y: k=3 if x==z: k=1 j=x*x+y*y+z*z+x*y+y*z+x*z if j<=n: ls[j-1]+=k else: break for i in ls: print(i)
p02629
s727575949
Wrong Answer
n=int(input()) a=[] while n: a+=n%26, n//=26 a=a[::-1] for i in range(len(a)-1,0,-1): if not a[i]: a[i]=26 a[i-1]-=1 i=0 while not a[i]:i+=1 print(''.join(chr(c+96)for c in a[i:]))
p02546
s641255675
Accepted
s=input() print(s+'es' if s[-1]=='s' else s+'s')
p02787
s759485989
Wrong Answer
# input H, N = map(int, input().split()) A = [] B = [] for _ in range(N): a, b = map(int, input().split()) A.append(a) B.append(b) # process max_a = max(A) dp = [10**9]*(H+max_a) dp[0] = 0 for i in range(len(dp)): if dp[i] == 10**4: continue for j in range(N): idx = i+A[j] if idx < len(dp) and dp[i]+B[j] < dp[idx]: dp[i+A[j]] = dp[i]+B[j] print(dp) # output print(min(dp[H:]))
p02663
s890401782
Wrong Answer
time = list(map(int, input().split())) h1,m1 = time[0],time[1] h2,m2 = time[2],time[3] k = time[4] ans = 0 full = (h2*60+m2) - (h1*60+m1) while full - k > 0: full-=k ans+=k print(ans)
p02963
s834390115
Accepted
s = int(input()) v = 10 ** 9 x = (v - s%v) % v y = (s + x) // v print(0, 0, 10 ** 9, 1, x, y)
p02957
s291184434
Wrong Answer
a,b= map(int,input().split()) if (b+a)%2==0: print((a+b)/2) else: print("IMPOSSIBLE")
p02660
s230579938
Accepted
N=int(input()) p=[] r=0 if N%2==0: c=0 while N%2==0: N=N//2 c+=1 p.append(c) for i in range(3,int(N**0.5)+1,2): if N%i==0: c=0 while N%i==0: N=N//i c+=1 p.append(c) if N!=1: p.append(1) while p: r+=int(((8*p.pop()+1)**0.5-1)/2) print(r)
p02784
s952120346
Accepted
import math h, n = map(int, input().split()) a = list(map(int, input().split())) if sum(a) >= h: print("Yes") else: print("No")
p03433
s032550462
Accepted
def main(): N = int(input()) A = int(input()) if N % 500 <= A: print("Yes") else: print("No") if __name__ == "__main__": main()
p03487
s409594532
Accepted
from collections import Counter n=int(input()) num=list(map(int,input().split())) dic=Counter(num) ans=0 for k,v in dic.items(): if k<v: ans+=v-k elif v<k: ans+=v print(ans)
p03324
s528394714
Accepted
def solve(): d,n = map(int,input().split()) if n!=100: print(n*(100**d)) else: print(101*(100**d)) if __name__=='__main__': solve()
p02768
s934519135
Accepted
from functools import reduce MOD = 10**9 + 7 def cmb(N, A): num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1)) den = reduce(lambda x, y: x * y % MOD, range(1, A + 1)) return num * pow(den, MOD - 2, MOD) % MOD n, a, b = map(int, input().split()) a %= MOD b %= MOD print((pow(2, n, MOD) - 1 - cmb(n, a) - cmb(n, b)) % MOD)
p03324
s325238524
Accepted
D, N = map(int, input().split()) ans = 0 df = 0 if D == 0: df = 1 elif D == 1: df = 100**1 else: df = 100**2 if N < 100: ans = df * N else: ans = df * (N+1) print(ans)
p02860
s515411553
Accepted
n = int(input()) s = input() for i in range(n): if s[:i] == s[i:]: print('Yes') exit() print('No')
p03241
s067106544
Wrong Answer
import sys from math import sqrt, floor from bisect import bisect_right as bi_r n, m = map(int, sys.stdin.readline().split()) def factorize(n): res = [1] for i in range(2, floor(sqrt(n)) + 1): if not n % i: res.append(i) if n >= 2: res.append(n) return res def main(): res = factorize(m) ans = res[bi_r(res, m / n) - 1] return ans if __name__ == '__main__': ans = main() print(ans)
p03605
s471944894
Accepted
N = input() ARU = False for i in range(len(N)): if N[i] == "9": ARU= True if ARU: print("Yes") else: print("No")
p02556
s592568511
Accepted
#!/usr/bin/env python3 (n,), *d = [[*map(int, o.split())] for o in open(0)] M = [[x - y for x, y in d], [x + y for x, y in d]] print(max(max(M[d]) - min(M[d]) for d in [0, 1]))
p02732
s247222597
Wrong Answer
import collections N = int(input()) A = list(map(int, input().split())) ctr_A = collections.Counter(A).most_common() less_A = collections.Counter(A) total = 0 for i in range(len(ctr_A)): n = ctr_A[i][1] total += n * (n - 1) // 2 for i in range(N): summ = total num = A[i] n = less_A[num] if (n <= 2): summ -= 1 else: new = (n - 1) * (n - 2) // 2 old = n * (n - 1) // 2 summ += new - old ans = max(0, summ) print(ans)
p02597
s353283152
Wrong Answer
n=int(input()) c=list(str(input())) count=0 w_count=0 r_count=0 w_count2=0 r_count2=0 flag=False for i in range(n//2): if c[i]=="W": w_count+=1 else: r_count+=1 for i in range(n//2,n): if c[i]=="W": w_count2+=1 else: r_count2+=1 if r_count2>=w_count: print(w_count) else: print(r_count+r_count2)
p02693
s989986099
Wrong Answer
k = int(input()) a, b = [int(i) for i in input().split()] ans = 'OK' if - a + b >= k else 'NG' print(ans)
p03011
s362593218
Accepted
from sys import stdin P,Q,R = map(int,input().split()) print(min(P+Q,Q+R,P+R))
p03250
s430524354
Accepted
n = list(map(int,input().split())) m=sorted(n) print(int((m[2]*10+m[1])+m[0]))
p03548
s842626950
Accepted
X, Y, Z = (int(x) for x in input().split()) ans = (X-Z)//(Y+Z) print(ans)
p02909
s654361122
Accepted
s = input() if s == 'Sunny': print('Cloudy') if s == 'Cloudy': print('Rainy') if s == 'Rainy': print('Sunny')
p03699
s597817922
Accepted
n = int(input()) s = [int(input()) for i in range(n)] ans=0 m = sum(s) if m%10==0: f = True s.sort() for si in s: if si%10!=0: print(m-si) f = False break if f: print(0) else: print(m)
p03951
s871888567
Wrong Answer
N=int(input()) S=input() T=input() s=[str(c) for c in (S)] t=[str(c) for c in (T)] flag=0 score=N for i in range (N,2*N): for j in range(N+N-i): flag=0 if s[i-N+j]!=t[j]: flag=1 if flag==0: score=i flag=2 if flag==2: break if flag==1: score=2*N print(score)
p02802
s154676055
Accepted
n, m = map(int, input().split()) mapAC = [False]*(n+1) countWA = [0]*(n+1) for i in range(m): p, s = input().split() p = int(p) if s == 'AC': mapAC[p] = True else: countWA[p] += 1*(not mapAC[p]) countWA = map(lambda x, y: x*y, countWA, mapAC) print(mapAC.count(True), sum(countWA))
p02630
s492999274
Wrong Answer
from collections import Counter n = int(input()) a_L = list(map(int,input().split())) q = int(input()) L = dict(Counter(a_L)) all_sum = sum(a_L) ans_L = [] for i in range(q): b,c = map(int,input().split()) try: diff = (c-b) * L[b] all_sum = all_sum+diff L[c] += L[b] except: pass ans_L.append(all_sum) for i in ans_L: print(i)
p02780
s820654849
Accepted
n,k=map(int,input().split()) pl=list(map(int,input().split())) cuml=[] cum=0 for i in range(n): cum+=(pl[i]+1)/2 cuml.append(cum) mx=0 for i in range(n-(k-1)): if i==0: mx=max(cuml[i+k-1],mx) else: mx=max(cuml[i+k-1]-cuml[i-1],mx) print('{:.9f}'.format(mx))
p02918
s885371774
Accepted
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, K = map(int, readline().split()) S = readline().strip() ans = 0 for i in range(N-1): if S[i] == S[i+1]: ans += 1 ans += 2 * K if ans > N - 1: ans = N - 1 print(ans) return if __name__ == '__main__': main()
p03556
s266576863
Wrong Answer
n=int(input()) for i in range(n+1): if i*i>n: print((i-1)*(i-1)) break
p02952
s052249278
Accepted
N = int(input()) print(len([0 for n in range(1, N + 1) if len(str(n)) % 2 == 1]))
p03038
s632055528
Accepted
from collections import deque N,M = map(int,input().split()) A = list(map(int,input().split())) bc = [tuple(map(int,input().split())) for _ in range(M)] for x in A: bc.append((1,x)) bc.sort(key=lambda x:x[1], reverse=True) A = [] for b,c in bc: while len(A) < N and b > 0: b -= 1 A.append(c) if len(A) == N: break A.sort(reverse=True) print(sum(A))
p03827
s043616782
Wrong Answer
s = input().rstrip() ans = 0 val = 0 for ch in s: if ch == "I": val += 1 ans = max(ans, val) elif ch == "D": val -= 1 print(ans)
p03435
s952537727
Accepted
from itertools import combinations c = [list(map(int, input().split())) for _ in range(3)] row = [[0] * 3 for _ in range(2)] for i in range(2): for j in range(3): row[i][j] = c[i+1][j] - c[i][j] ans = "Yes" for i in row: if any(x != y for x, y in combinations(i, 2)): ans = "No" print(ans)
p02848
s146629124
Wrong Answer
n=int(input()) s=input() l=[] for a in s: moji=ord(a) moji+=n print(moji) if int(moji)>90: moji-=26 l.append(chr(moji)) print(''.join(l))
p03162
s373433666
Accepted
n = int(input()) s = [list(map(int, input().split())) for i in range(n)] dp = [[0, 0, 0] for _ in range(n)] dp[0][:] = s[0][:] for i in range(1, n): for j in range(3): # dasu te for k in range(3): # maeno te if j != k: try: dp[i][j] = max(dp[i][j], dp[i-1][k] + s[i][j]) except: pass print(max(dp[-1][:]))
p02707
s676637216
Accepted
n = int(input()) al = map(lambda x: int(x) - 1, input().split()) a = [] count = 0 for _ in [0] * n: a.append(0) for x in al: a[x] += 1 count += 1 for x in a: print(x)
p03095
s039641312
Accepted
N = int(input()) S = input() from collections import Counter c = Counter(S) ans = 1 for v in c.values(): ans = ans*(v+1)%(10**9+7) print(ans-1)
p02766
s564854233
Accepted
n,k = map(int,input().split()) tempk = k ans = 1 while 1: if tempk<=n: ans+=1 tempk*=k else: break print(ans)
p02742
s536896079
Accepted
H,W = map(int,input().split()) if H ==1 or W ==1: print(1) else: a = H*W if a%2 == 0: print(int(a/2)) else: print(int(a/2)+1)