problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p02621
|
s312738897
|
Accepted
|
def main():
N = int(input())
print(N + N * N + N * N * N)
if __name__ == '__main__':
main()
# import sys
# input = sys.stdin.readline
#
# sys.setrecursionlimit(10 ** 7)
#
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
# while abs(ok - ng) > 1:
# mid = (ok + ng) // 2
# if func(mid):
# ok = mid
# else:
# ng = mid
# return ok
|
p03351
|
s478704625
|
Accepted
|
a,b,c,d=map(int,input().split())
s='Yes'
if abs(a-c)>d:
if abs(a-b)>d or abs(b-c)>d:
s='No'
print(s)
|
p03785
|
s756363763
|
Accepted
|
n,c,k = map(int,input().split())
t = [int(input()) for i in range(n)]
t.sort()
key = t[0]+k
len_t = 0
ans1 = 0
for i in range(n):
if t[i] <= key and len_t < c:
len_t += 1
else:
ans1 += 1
key = t[i]+k
len_t = 1
ans1 += 1
print(ans1)
|
p03067
|
s218673250
|
Accepted
|
a,b,c=map(int,input().split())
if (c<=b and a<=c) or c<=a and b<=c:
print("Yes")
else:
print("No")
|
p02996
|
s099203250
|
Accepted
|
N =int(input())
List = []
for _ in range(N):
A, B = map(int, input().split())
List.append([A,B])
List = sorted(List,key=lambda x: x[1],reverse = True)
Limit = List[0][1]
for item in List:
Limit = min(item[1],Limit) - item[0]
if Limit < 0:
print('No')
exit()
print('Yes')
|
p02958
|
s391169879
|
Wrong Answer
|
N=int(input())
P=list(map(int,input().split()))
count=0
for i in range(N):
if P[i]!=i+1:
count+=1
print("Yes" if count<=2 else "No")
|
p02744
|
s585267599
|
Accepted
|
N = int(input())
def f(n, lst):
if n == N:
print(''.join(map(str, [chr(s + 97) for s in lst])))
else:
for i in range(max(lst) + 2):
f(n + 1, lst + [i])
f(1, [0])
|
p02657
|
s214939445
|
Accepted
|
a,b = map(int,input().split())
print(a*b)
|
p03665
|
s103058597
|
Accepted
|
N, P = map(int, input().split())
A = [int(x) for x in input().split()]
odd = False
for i in range(N):
if A[i] % 2 == 1:
odd = True
break
if odd:
print(2**(N-1))
else:
if P == 0:
print(2**N)
else:
print(0)
|
p02642
|
s203401115
|
Accepted
|
import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit('(i4[::1],)', cache=True)
def solve(A):
count = np.zeros(10**6 + 10, np.int32)
for x in A:
if count[x] > 1:
continue
count[::x] += 1
ret = 0
for x in A:
ret += count[x] == 1
return ret
A = np.array(read().split(), np.int32)[1:]
print(solve(A))
|
p02838
|
s055926322
|
Accepted
|
def powmod(x, y, mod):
if y == 0:
return 1
return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod
n = int(input())
a = tuple(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * 60
for i in range(n):
r = a[i]
for j in range(60):
if r & 1:
cnt[j] += 1
r >>= 1
ans = 0
for i in range(60):
ans += powmod(2, i, mod) * cnt[i] * (n-cnt[i])
ans %= mod
print(ans)
|
p02602
|
s083534767
|
Wrong Answer
|
#MSOL C
import numpy as np
N,K = map(int,input().split())
A = list(map(int,input().split()))
def checker(i):
l = A[i-K:i:]
return np.prod(l)
bscore = checker(K)
for i in range(K+1,N+1):
ascore = checker(i)
if (bscore < ascore):
print("Yes")
else:
print("No")
bscore = ascore
|
p02993
|
s321550054
|
Accepted
|
s=input()
for i in range(3):
if s[i]==s[i+1]:
print("Bad")
exit()
print("Good")
|
p02646
|
s562694094
|
Accepted
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a > b:
aa = a - t * v
bb = b - t * w
if aa > bb:
print('NO')
else:
print('YES')
elif a < b:
aa = a + t * v
bb = b + t * w
if aa < bb:
print('NO')
else:
print('YES')
else:
print('YES')
|
p02854
|
s004648220
|
Wrong Answer
|
n=int(input())
a=list(map(int, input().split()))
m=sum(a)
if m%2==1:
ans=1
m-=1
else:
ans=0
a.insert(0,0)
b=[0]
c=[]
for l in range(n):
b.append(b[l]+a[l+1])
for l in range(n):
c.append(abs(m/2-b[l+1]))
print(int(min(c)+ans))
|
p03041
|
s285795172
|
Accepted
|
inputted = list(map(int, input().split()))
N = inputted[0]
K = inputted[1]
S = input()
S = list(S)
S[K - 1] = S[K - 1].lower()
S = ''.join(S)
print(S)
|
p03605
|
s098146883
|
Accepted
|
n=list(input())
if '9' in n:
print("Yes")
else:
print("No")
|
p03331
|
s499619565
|
Wrong Answer
|
ans=999999999
n = int(input())
for i in range(1,n//2):
x=str(i)
y=str(n-i)
ans=min(ans, sum(map(int, x))+sum(map(int, y)))
print(ans)
|
p03427
|
s331391806
|
Wrong Answer
|
s=input()
k=10**(len(s)-1)
#print(s,str(int(s)//k*k-1))
print(sum(map(int,str(int(s)//k*k-1))) if len(s)!=1 else s)
|
p02761
|
s240035616
|
Accepted
|
N, M = map(int, input().split())
S = []
C = []
for i in range(M):
s, c = map(int, input().split())
S.append(s-1)
C.append(str(c))
ans = []
for i in range(10 ** N):
a = list(str(i))
if len(a) != N:
continue
ansFlag = True
for i in range(M):
if a[S[i]] != C[i]:
ansFlag = False
if ansFlag:
ans = a
break
if ans == []:
print(-1)
else:
print("".join(ans))
|
p02608
|
s721816692
|
Wrong Answer
|
n=int(input())
from math import floor,sqrt
sqset=set()
for i in range(1,200):
sqset.add(i**2)
print(sqset)
def func(m):
r=0
for x in range(1,floor(sqrt(m))+1):
for y in range(1,floor(sqrt(m))+1):
a=x+y
b=x**2+y**2+x*y-m
d=a**2-4*b
if d in sqset:
if (sqrt(d)-a)>0 and (sqrt(d)-a)%2==0:
r+=1
return r
for i in range(1,n+1):
print(func(i))
|
p02946
|
s132986100
|
Accepted
|
k,x=map(int,input().split(' '))
range1=(x-k)+1
range2=(x+k)-1
for i in range(range1,range2+1):
print(i,end=' ')
|
p03387
|
s483127037
|
Wrong Answer
|
a,b,c = map(int,input().split())
x = abs(a-b)
y = abs(b-c)
if (x%2 == 0 and y%2 == 0): # 差が ぐぐ
ans = x//2 + y//2
elif (x%2 == 1 and y%2 == 1): #差が きき
ans = x//2 + y//2 + 1
else: # 差が ぐき or きぐ
ans = x//2 + y//2 + 2
print (ans)
|
p03659
|
s708542669
|
Accepted
|
N = int(input())
a = tuple(map(int, input().split()))
x = a[0]
y = sum(a[1:])
mn = abs(x-y)
for i in range(1, N-1):
x += a[i]
y -= a[i]
mn = ab if (ab := abs(x-y)) < mn else mn
print(mn)
|
p03469
|
s499570795
|
Wrong Answer
|
S = input()
print('2018' + S[:4])
|
p02708
|
s821876705
|
Accepted
|
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
MOD = 10 ** 9 + 7
min_lis = [0] * (N + 2)
max_lis = [0] * (N + 2)
for i in range(1, N + 2):
min_lis[i] = min_lis[i - 1] + (i - 1)
max_lis[i] = max_lis[i - 1] + (N - i + 1)
answer = 0
for k in range(K, N + 2):
answer += max_lis[k] - min_lis[k] + 1
print(answer % MOD)
|
p02767
|
s506471054
|
Accepted
|
n = int(input())
x_list = list(map(int, input().split()))
min_count = 1e10
for i in range(101):
count = 0
for x in x_list:
count += (x - i) * (x - i)
if count < min_count:
min_count = count
print(min_count)
|
p02629
|
s728903108
|
Accepted
|
def f(n):
if n == 0: return ""
n -= 1
return (f(n // 26) + chr(ord("a") + n % 26))
def main():
from builtins import int, map, list, print
import sys
sys.setrecursionlimit(10 ** 6)
input = (lambda: (sys.stdin.readline()).rstrip())
input_list = (lambda: input().split())
input_number = (lambda: int(input()))
input_number_list = (lambda: list(map(int, input_list())))
n = input_number()
ans = f(n)
print(ans)
if __name__ == '__main__':
main()
|
p02642
|
s154899374
|
Accepted
|
import sys
from collections import Counter
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
A_counters = Counter(A)
A.sort()
A_set = set(A)
ans = 0
for a in A:
if a in A_set:
if A_counters[a] == 1:
ans += 1
for i in range(1, A[-1] // a + 1):
if a * i in A_set:
A_set.remove(a * i)
print(ans)
|
p02958
|
s330600793
|
Accepted
|
N = int(input())
p = list(map(int,input().split()))
p_sort = sorted(p)
count = 0
for i,j in zip(p,p_sort):
if i != j:
count += 1
if count == 0 or count == 2:
print("YES")
else:
print("NO")
|
p03067
|
s220733346
|
Accepted
|
A,B,C=map(int,input().split())
if((A<C and C<B) or (B<C and C<A)):
print("Yes")
else:
print("No")
|
p02708
|
s565071973
|
Wrong Answer
|
# n, k = 0
n, k = map(int, input().split())
# 0,1,2,3,,,,,,n
# k個選んだ時の最小値と最大値の差をk,k+1,k+2,,,,nと積算する
iResult = 0 # 答え
for i in range(k, n + 2):
# print(i)
# min = 0
# max = 0
# for j in range(0, i):
# print(' ' + str(j))
# min = min + j
# max = max + n - j
iResult = iResult + i * (n - i + 1) + 1
print(iResult)
|
p02820
|
s912110849
|
Wrong Answer
|
N, K = map(int, input().split())
R, S, P = list(map(int, input().split()))
T = list(input())
result = [0] * N
for i,t in enumerate(T):
if t == "r":
result[i] = P
elif t == "s":
result[i] = R
else:
result[i] = S
for i in range(K, N):
if result[i] == result[i-K]:
result[i] = 0
print(sum(result))
|
p03449
|
s765941965
|
Accepted
|
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
s = []
for i in range(N):
a = sum(A1[0:i+1])+sum(A2[i:])
s.append(a)
print(max(s))
|
p02983
|
s071778370
|
Accepted
|
l,r = map(int,input().split())
m = r-l
if m >= 2019:
print(0)
else:
cnt = []
for i in range(l,r):
for j in range(l+1,r+1):
cnt.append(i*j%2019)
print(min(cnt))
|
p02918
|
s172519298
|
Accepted
|
N, K = map(int, input().split())
S=input()
ch=0
for i in range(N-1):
if S[i]!=S[i+1]:
ch+=1
print(min(N-1,N-ch-1+2*K))
|
p03035
|
s212940836
|
Wrong Answer
|
a, b = map(int, input().split())
if a >= 13:
print(b)
elif 6 <= a <= 12:
b /= 2
print(b)
else:
b = 0
print(b)
|
p02899
|
s788007287
|
Wrong Answer
|
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
ans[a[i]-1] = i+1
print(ans)
|
p02811
|
s745273791
|
Wrong Answer
|
K,X=map(int,input().split())
ans='YES'
if 500*K<X:
ans='NO'
print(ans)
|
p02711
|
s920873613
|
Accepted
|
import sys
N = str(input())
if '7' in N:
print('Yes')
sys.exit()
print('No')
|
p02765
|
s081298967
|
Accepted
|
n, dr = list(map(int, input().split()))
if n >= 10:
print(dr)
else:
print(dr+(100*(10-n)))
|
p03210
|
s116250379
|
Accepted
|
x=int(input())
if x==3 or x==5 or x==7:
print("YES")
else :
print("NO")
|
p02688
|
s149483588
|
Accepted
|
N , K = map(int,input().split())
dA = [list(map(int,input().split()))for k in range(2*K)]
L = list(sum(dA[1::2],[]))
print(N-len(set(L)))
|
p02767
|
s301203120
|
Accepted
|
n = int(input())
x = [int(i) for i in input().split()]
hp = []
for p in range(min(x), max(x)+1):
sum = 0
for i in x:
sum = sum + (i-p)**2
hp.append(sum)
print(min(hp))
|
p03379
|
s188099340
|
Accepted
|
n = int(input())
num_list = list(map(int,input().split()))
tmp = num_list.copy()
tmp.sort()
mid = tmp[n//2-1]
midu = tmp[n//2]
for i in num_list:
if i <= mid:
print(midu)
else:
print(mid)
|
p03986
|
s710945872
|
Accepted
|
X = input()
val = len(X)
sum = 0
for i in X:
if i == "S":
sum += 1
else:
if sum > 0:
val -= 2
sum -= 1
print(val)
|
p03625
|
s823253584
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
now = A[0]
tateyoko = [0, 0]
count = 0
nowflag = False
for i in range(1, N):
if (A[i] == now) and (not nowflag):
tateyoko[count] = now
count += 1
nowflag = True
else:
nowflag = False
if count == 2:
break
now = A[i]
print(tateyoko[0] * tateyoko[1])
|
p03639
|
s453322943
|
Accepted
|
N = int(input())
a = list(map(int,input().split()))
s,t = 0, 0
for e in a:
if e%4 == 0:
s += 1
elif e%2 == 0:
t += 1
if t == 0:
if N//2 <= s:
print("Yes")
else:
print("No")
else:
if (1+N-t)//2 <= s:
print("Yes")
else:
print("No")
|
p03042
|
s338863472
|
Wrong Answer
|
s = input()
a = int(s[:2])
b = int(s[2:])
if 0 < a and a <= 12 and 0 < b and b <= 12:
print("AMBIGUOUS")
elif a > 12 and 0 < b and b <= 12:
print("YYMM")
elif 0 < a and a <= 12 and b > 12:
print("MMYY")
else:
print("NA")
|
p02678
|
s100760939
|
Accepted
|
n,m=map(int,input().split())
g=[[] for x in range(n)]
for c in range(m):
a,b= map(int,input().split())
g[a-1].append(b-1)
g[b-1].append(a-1)
ans_list=[-1]*n
queue=[0]
while queue:
qi=queue.pop(0)
for gi in g[qi]:
if ans_list[gi]==-1:
queue.append(gi)
ans_list[gi]=qi
print("Yes")
for ans in ans_list[1:]:
print(ans+1)
|
p02663
|
s411781031
|
Accepted
|
h1, m1, h2, m2, k = map(int, input().split())
hd = h2 - h1
if m1 > m2:
hd -= 1
m2 += 60
md = m2 - m1
m = hd * 60 + md
print(m-k)
|
p03286
|
s927218240
|
Accepted
|
N=int(input())
s=''
if(N==0):
print(0)
exit()
while(N!=0):
m=N%2
s+=str(m)
N=(N-m)//-2
print(s[::-1])
|
p03160
|
s509866570
|
Accepted
|
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(1,N-1):
DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
print(DP[N-1])
|
p03160
|
s043254393
|
Wrong Answer
|
#DP カエルの奴 A 配るDP
N=int(input())
S=list(map(int,input().split()))
S.append(100010)
S.append(100010)
DP=[100000000]*100010
DP[0]=0
for i in range(N):
if DP[i]+abs(S[i]-S[i+1])<DP[i+1]:
DP[i+1]=DP[i]+abs(S[i]-S[i+1])
if DP[i]+abs(S[i]-S[i+2])<DP[i+2]:
DP[i+2]=DP[i]+abs(S[i]-S[i+2])
print(DP[N-1])
print(DP)
|
p03838
|
s564647652
|
Accepted
|
x, y = map(int, input().split())
if x <= y:
if 0 <= x * y:
print(y - x)
else:
print(abs(x + y) + 1)
else:
if 0 < x * y:
print(x - y + 2)
elif x * y <= 0:
print(abs(y + x) + 1)
|
p02970
|
s877203358
|
Accepted
|
n, d = map(int, input().split())
if(n % (2*d+1)):
print(n // (2*d+1) + 1)
else:
print(n // (2*d+1))
|
p03086
|
s425081735
|
Accepted
|
s = input()
cnt = 0
ans = 0
for c in s:
if c in "ACGT":
cnt += 1
ans = max(ans, cnt)
else:
cnt = 0
print(ans)
|
p02595
|
s084448019
|
Accepted
|
N, D = map(int, input().rstrip().rsplit())
ans = 0
for i in range(N):
xi, yi = map(int, input().rstrip().rsplit())
if D**2 >= xi**2 + yi**2:
ans += 1
print(ans)
|
p03696
|
s247095654
|
Wrong Answer
|
N = int(input())
S = input()
l = S.count("(")
r = S.count(")")
S
cnt = 0
for i in range(N):
if S[i] == "(":
break
cnt += 1
l += cnt
S = "(" * cnt + S
cnt = 0
for i in range(r+l)[::-1]:
if S[i] == ")":
break
cnt += 1
r += cnt
S = S + ")" * cnt
if l >= r:
S = S + ")" * (l - r)
else:
S = "(" * (r - l) + S
print(S)
|
p02917
|
s261774395
|
Wrong Answer
|
def main():
n = int(input())
blis = list(map(int, input().split()))
alis = [blis[0], blis[0]]
for i in range(2, n):
alis.append(min(blis[i-2], blis[i-1]))
if n > 2:
alis.append(blis[n-2])
print(sum(alis))
if __name__ == "__main__":
main()
|
p03485
|
s419917754
|
Accepted
|
a,b = map(int, input().split())
import math
print(math.ceil((a + b) / 2))
|
p03264
|
s858532130
|
Accepted
|
a = int(input())
print((a//2)*((a+1)//2))
|
p03126
|
s643439818
|
Wrong Answer
|
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [0]*m
for i in range(n):
for j in range(ab[i][0]):
k = ab[i][j+1]
dp[k-1] +=1
print(dp.count(m))
|
p03761
|
s618510453
|
Accepted
|
from collections import *
N = int(input())
C = Counter(input())
for n in range(N-1):
C&=Counter(input())
print(*sorted(C.elements()),sep="")
|
p03327
|
s506563630
|
Wrong Answer
|
N = int(input())
if N < 1000:
tmp = str(N)
print("ABC"+tmp.zfill(3))
else:
tmp = str(N%1000+1)
print("ABD"+tmp.zfill(3))
|
p02556
|
s742791854
|
Accepted
|
import sys
N=int(sys.stdin.readline().strip())
XY=[ map(int, sys.stdin.readline().split()) for _ in range(N) ]
X=[]
Y=[]
for x,y in XY:
X.append(x-y)
Y.append(x+y)
X.sort()
Y.sort()
print max(abs(X[0]-X[-1]),abs(Y[0]-Y[-1]))
|
p04005
|
s596125918
|
Accepted
|
a, b, c = map(int, input().split())
if any(x % 2 == 0 for x in (a, b, c)):
print(0)
else:
print(min(a*b, b*c, c*a))
|
p03860
|
s828689261
|
Accepted
|
a,b,c=input().split();print(a[0]+b[0]+c[0])
|
p03854
|
s776565477
|
Accepted
|
import re
S = input()
'''
メタ文字:
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
print('YES')
else:
print('NO')
|
p03951
|
s230057135
|
Wrong Answer
|
n = int(input())
s = input()
t = input()
l = 0
for i in range(n):
for j in range(n):
if s[i] == t[j]:
l += 1
print(2 * n - l)
|
p04044
|
s824563112
|
Accepted
|
from sys import stdin, stdout
from time import perf_counter
import sys
sys.setrecursionlimit(10**9)
mod = 10**9+7
# import sys
# sys.stdout = open("e:/cp/output.txt","w")
# sys.stdin = open("e:/cp/input.txt","r")
n,l = map(int,input().split())
a = [input() for item in range(n)]
b = sorted(a)
print(''.join(b))
|
p02720
|
s953881378
|
Accepted
|
k = int(input())
lunlun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for li in lunlun:
if 10**10 < li:
break
lunlun.append(li * 10 + li % 10)
if 0 <= li % 10 < 9:
lunlun.append(li * 10 + li % 10 + 1)
if 0 < li % 10 <= 9:
lunlun.append(li * 10 + li % 10 - 1)
lunlun.sort()
print(lunlun[k - 1])
|
p03472
|
s206481167
|
Accepted
|
def main():
from math import ceil
from itertools import accumulate
from bisect import bisect_left
n, h, *ab = map(int, open(0).read().split())
x = max(ab[::2])
*y, = filter(lambda i: i >= x, ab[1::2])
y = sorted(y, reverse=True)
*z, = accumulate(y)
if z[-1] <= h:
print(len(y) + ceil((h - z[-1]) / x))
else:
print(bisect_left(z, h) + 1)
if __name__ == '__main__':
main()
|
p03760
|
s277370563
|
Accepted
|
def main():
O = input()
E = input()
ans = ''
for i in range(len(O)):
if len(O) == len(E):
ans += O[i] + E[i]
elif i < len(O)-1:
ans += O[i] + E[i]
else:
ans += O[i]
print(ans)
if __name__ == "__main__":
main()
|
p03767
|
s976447112
|
Accepted
|
N = int(input())
a = [0] + list(map(int, input().split()))
a = sorted(a)
# print(f"N:{N} a:{a}", file=sys.stderr)
max_power = 0
for i in range(N):
max_power += a[(N + 1) + 2 * i]
print(max_power)
|
p02761
|
s834168371
|
Accepted
|
n,m = map(int, input().split())
scl = []
for _ in range(m):
s,c = map(int, input().split())
scl.append((s,c))
for i in range(0, 1000):
si = str(i)
if len(si) != n: continue
for sc in scl:
s,c = sc
if si[s-1] != str(c):
break
else:
print(i)
exit()
else:
print(-1)
|
p02838
|
s713506468
|
Accepted
|
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
cnt = [0] * 61
for a in A:
for i in range(61):
cnt[i] += 1 if (a >> i) & 1 else 0
answer = 0
for i in range(61):
answer = (answer + (2 ** i * cnt[i] * (N - cnt[i]))) % MOD
print(answer)
|
p02836
|
s427670963
|
Wrong Answer
|
S = input()
k = len(S)//2
res = 0
for i in range(k):
if S[i]==S[len(S)-1-i]:
res += 1
print(res)
|
p03449
|
s284019861
|
Wrong Answer
|
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
ans = max(ans,sum(a[:5-i])+sum(b[4-i:]))
print(ans)
|
p03611
|
s641092301
|
Wrong Answer
|
import numpy as np
n = int(input())
a = list(map(int,input().split()))
base = np.zeros(100000)
for i in range(n):
base[a[i]-1] += 1
base[a[i]] += 1
base[a[i]-2] += 1
print(int(max(base)))
|
p03862
|
s886721656
|
Wrong Answer
|
n, x = map(int, input().split())
a = [ int(x) for x in input().split() ]
ans = 0
for i in range(n-1):
# greedy
if a[i] + a[i+1] > x:
cost = ((a[i] + a[i+1]) - x)
a[i+1] -= cost
ans += cost
print(ans)
|
p03252
|
s448885452
|
Accepted
|
S=input()
T=input()
dict1={}
a=0
for i in range(len(S)):
if S[i] in dict1:
if dict1[S[i]]!=T[i]:
a=1
else:
dict1[S[i]]=T[i]
dict2={}
for i in range(len(T)):
if T[i] in dict2:
if dict2[T[i]]!=S[i]:
a=1
else:
dict2[T[i]]=S[i]
if a==0:
print("Yes")
else:
print("No")
|
p03062
|
s079197364
|
Accepted
|
import numpy as np
n = int(input())
nums = list(map(int, input().split()))
minus = 0
zero = 0
for num in nums:
if num == 0:
zero += 1
break
elif num < 0:
minus += 1
nums = np.abs(nums)
nums.sort()
if minus % 2 and not zero:
ans = sum(nums) - 2 * nums[0]
else:
ans = sum(nums)
print(ans)
|
p02682
|
s113180041
|
Accepted
|
a, b, c, k = map( int, input().split())
if k <= a:
print(k)
elif k <= a+b:
print(a)
else:
print(a-(k-a-b))
|
p02859
|
s592365999
|
Accepted
|
r = int(input())
print(r**2)
|
p02730
|
s563093000
|
Wrong Answer
|
s = str(input())
n = len(s)
s1 = s[:int((n-1)/2)]
s2 = s[int((n+3)/2)-1:]
i = 1
while i < len(s):
if not s[i-1] == s[-i]:
print("No")
exit()
i += 1
while i < len(s1):
if not s1[i-1] == s1[-i]:
print("No")
exit()
i += 1
while i < len(s2):
if not s2[i+2] == s2[-i]:
print("No")
exit()
i += 1
print("Yes")
|
p03612
|
s721691888
|
Accepted
|
n = int(input())
p = [int(x) for x in input().split()]
ans = 0
for i in range(n):
if p[i] == i+1:
if i+1 < n:
p[i],p[i+1] = p[i+1],p[i]
ans += 1
print(ans)
|
p03289
|
s981548412
|
Wrong Answer
|
import sys
S=input()
first=S[0]
second=S[1]
last=S[len(S)-1]
cnt=0
moji=[i for i in "abcdefghijklmnopqrstuvwxyz"]
# print(len(moji))
if first=="A":
for i in range(2,len(S)-1):
print(i)
if S[i]=="C":
cnt+=1
else:
if (S[i] in moji)==False:
print("WA")
sys.exit()
if cnt==1 and ((last in moji)==True) and ((second in moji)==True):
print("AC")
else:
print("WA")
else:
print("WA")
|
p04043
|
s590285399
|
Wrong Answer
|
inp = (input().split())
if inp[0] == inp[1]:
print("YES")
else:
print("NO")
|
p03475
|
s354259953
|
Accepted
|
N = int(input())
C = [0]*(N-1)
S = [0]*(N-1)
F = [0]*(N-1)
for TN in range(0,N-1):
C[TN],S[TN],F[TN] = (int(T) for T in input().split())
for TN in range(0,N):
Time = 0
for TS in range(TN,N-1):
if Time>=S[TS]:
Time += C[TS]+(F[TS]-(Time%F[TS]))%F[TS]
else:
Time += C[TS]+(S[TS]-Time)
print(Time)
|
p02842
|
s696726958
|
Accepted
|
N = int(input())
if int(N//1.08 * 1.08) == N:
print(int(N//1.08))
elif int(-(-N//1.08) * 1.08) == N:
print(int(-(-N//1.08)))
else:
print(':(')
|
p04005
|
s318719003
|
Accepted
|
import sys
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
def solve():
A, B, C = inl()
if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
return 0
x = sorted([A, B, C])
return x[0] * x[1]
print(solve())
|
p02754
|
s343382507
|
Wrong Answer
|
N,A,B=map(int,input().split())
sum=0
if A==0:
print(0)
else:
a=N//(A+B)
b=N%(A+B)
# print(a)
# print(b)
sum=A*a+b
print(sum)
|
p03109
|
s853403979
|
Accepted
|
y,m,d=map(int,input().split("/"))
print('TBD' if (y>2019 or (y==2019 and m>4)) else 'Heisei')
|
p02995
|
s886946686
|
Accepted
|
from fractions import gcd
a, b, c, d = map(int, input().split())
lcm = lambda x, y: x * y // gcd(x, y)
a -= 1
ans = b - (b // c + b // d - b // lcm(c, d)) - a + (a // c + a // d - a // lcm(c, d))
print(ans)
|
p03472
|
s181548223
|
Accepted
|
import sys
N,H=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
a,b=map(int,input().split())
A[i],B[i]=a,b
max_A=max(A)
B.sort(reverse=True)
K=0
for b in B:
if H>0 and b>=max_A:
K+=1
H-=b
if H>0:
K+=(H+max_A-1)//max_A
print(K)
|
p02814
|
s180128694
|
Wrong Answer
|
import functools
import fractions
def lcm(a, b):
return a * b // fractions.gcd(a, b)
N,M=map(int,input().split())
A=list(map(int,input().split()))
LCM=functools.reduce(lcm,A)
HLCM=LCM//2
Y=M//HLCM
if Y%2==0:
print(Y//2)
else:
print((Y+1)//2)
|
p02747
|
s115373723
|
Accepted
|
S = input()
if S.count("hi") > 0:
num = S.count("hi")
S = S.replace("hi", "", num)
if len(S) == 0:
print("Yes")
else:
print("No")
else:
print("No")
|
p03286
|
s743188631
|
Accepted
|
n = int(input())
ans = []
while n != 0:
if n % 2 != 0:
n -= 1
ans.append("1")
else:
ans.append("0")
n //= -2
if len(ans) == 0:
ans.append("0")
print("".join(reversed(ans)))
|
p03075
|
s740268202
|
Accepted
|
ans = 0
position = []
for i in range(5):
x = int(input())
position.append(x)
k = int(input())
distance_list = []
for i in range(5):
for j in range(5):
if i != j:
distance = abs(position[i] - position[j])
distance_list.append(distance)
y = max(distance_list)
if y <= k:
print('Yay!')
else:
print(':(')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.