problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03038 | s385365447 | Accepted | from collections import Counter
import heapq
N,M = map(int,input().split())
A = Counter(list(map(int,input().split())))
cards = []
for x,y in A.items():
heapq.heappush(cards, (-x,y))
for _ in range(M):
b,c = map(int,input().split())
heapq.heappush(cards, (-c,b))
cnt = N
res = 0
while cnt <= N:
v,c = heapq.heappop(cards)
v *= -1
if cnt-c < 0:
res += v*cnt
break
else:
res += v*c
cnt -= c
print(res) |
p03131 | s967438019 | Accepted | k, a, b = map(int, input().split())
ans = k + 1
if a < b:
k -= a - 1
ans = max(ans, a + (b-a)*(k//2) + k%2)
print(ans) |
p02705 | s197214996 | Accepted | import sys
from math import pi
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007
def main():
R = int(readline())
print(2 * R * pi)
return
if __name__ == '__main__':
main()
|
p03705 | s056747512 | Accepted | N, A, B = map(int, input().split())
diff = B - A
if N == 1:
if diff != 0:
print(0)
else:
print(1)
else:
if diff < 0:
print(0)
elif diff == 0:
print(1)
else:
max_val = B * (N-1) + A
min_val = A * (N-1) + B
print(max_val - min_val + 1)
|
p03487 | s330504523 | Accepted | from collections import defaultdict
def main():
N = int(input())
a = [int(i) for i in input().split()]
dd = defaultdict(int)
res=0
for i in a:
dd[i]+=1
for i in dd.keys():
if dd[i]<i:
res += dd[i]
elif dd[i]>i:
res += dd[i]-i
dd[i] = i
print(res)
if __name__ == "__main__":
main()
|
p02754 | s291653941 | Accepted | n,a,b=map(int,input().split())
print(a*(n//(a+b))+min(a,n%(a+b))) |
p02658 | s853861374 | Accepted | n = int(input())
A = list(map(int,input().split()))
for i in range(n):
if A[i]==0:
print(0)
exit()
ans = 1
for i in range(n):
ans *= A[i]
if ans > 1e18:
print(-1)
exit()
print(ans) |
p03493 | s454313552 | Accepted | s = input()
print(s.count('1'))
# 全探索 |
p04045 | s387394987 | Wrong Answer | nk = input().split()
n = int(nk[0])
k = int(nk[1])
d = input().split()
for i in range(n,10000):
for j in range(k):
for l in range(len(str(n))):
if str(n)[l] == str(d)[j]:
break
else:
continue
break
else:
print(i)
break
n += 1 |
p02917 | s226407273 | Accepted | n=int(input())
b=list(map(int,input().split()))
ans=b[0]+b[-1]
for i in range(n-2):
if b[i]<=b[i+1]:
ans+=b[i]
else:
ans+=b[i+1]
print(ans) |
p03252 | s501057698 | Wrong Answer | from collections import defaultdict
s=input()
t=input()
lis=defaultdict(lambda:-1)
lis2=defaultdict(lambda:-1)
for i,val in enumerate(s):
if lis[i]==-1:
lis[i]=val
else:
if lis[i]!=val:
print("No")
exit()
for i,val in enumerate(t):
if lis2[i]==-1:
lis2[i]=val
else:
if lis2[i]!=val:
print("No")
exit()
print("Yes") |
p03434 | s377045933 | Accepted | def main():
n = int(input())
a = list(map(int, input().split()))
m = 0
y = 0
sort_a = sorted(a, reverse=True)
for i in range(n):
if i % 2 == 0:
m += sort_a[i]
else:
y += sort_a[i]
print(m - y)
main()
|
p02720 | s861010762 | Accepted | from collections import deque
k = int(input())
l = [int(x) for x in range(1,10)]
lnln = deque(l)
Lnln = []
# print(lnln)
n = 10**5
for i in range(n):
x = lnln.popleft()
Lnln.append(x)
a = x % 10
if a!=0:
lnln.append(x*10 + (a-1))
lnln.append(x*10 + a)
if a!=9:
lnln.append(x*10 + (a+1))
print(Lnln[k-1]) |
p03624 | s619664171 | Accepted | Sset=set(input())
Sset=sorted(Sset)
ans = "None"
flg = True
last = "None"
for i,c in enumerate(Sset):
if i+97 !=ord(c):
flg=False
ans = chr(i+97)
break
last = c
if flg and last != 'z' :
ans = chr(ord(last)+1)
print(ans)
|
p04012 | s496316008 | Wrong Answer | w = list(input())
ans = 'Yes'
for i in range(ord('a'),ord('z')):
if int(w.count("chr(i)"))%2 == 1:
ans = 'No'
break
if int(w.count("chr(i)"))%2 == 0:
continue
print(ans) |
p04029 | s432494898 | Accepted | N = int(input())
print(int(N*(N+1)*0.5)) |
p03035 | s897625394 | Wrong Answer | a,b = map(int,input().split())
if(a <= 5):
print(0)
elif(a < 12):
print(b//2)
else:
print(b)
|
p03799 | s041251162 | Accepted | n,m=map(int,input().split())
if m<=2*n:
print(int(m/2))
else:
print(int((2*n+m)/4))
|
p02732 | s154767794 | Wrong Answer | N=int(input())
s=0
A=list(map(int,input().split()))
li=[0]*(2*(10**5))
for i in range(N):
li[A[i]]+=1
for j in range(N):
s+=li[j]*(li[j]-1)//2
for k in range(N):
print(s-(li[A[k]]*(li[A[k]]-1))//2+((li[A[k]]-1)*(li[A[k]]-2))//2)
|
p03011 | s314020699 | Accepted | p, q, r = map(int, input().split())
list01 = [p, q, r]
print(p + q + r - (max(list01)))
|
p04019 | s244560618 | Accepted | s = list(set(list(input())))
if (len(s)%2==1):
print("No")
else:
if ("N" in s) and ("S" in s):
print("Yes")
elif ("E" in s) and ("W" in s):
print("Yes")
else:
print("No")
|
p03137 | s881424846 | Accepted | N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >= M:
print(0)
else:
X.sort()
X_div = [0] * (M-1)
for i in range(1,M):
X_div[i-1] = X[i] - X[i-1]
X_div.sort(reverse=True)
m = 0
for i in range(N-1):
m += X_div[i]
print(X[-1]-X[0]-m)
|
p02600 | s961986083 | Wrong Answer | x=int(input())
if 400 <= x <= 599:print(8)
elif 700 <= x <= 799:print(7)
elif 800 <= x <= 999:print(6)
elif 1000 <= x <= 1199:print(5)
elif 1200 <= x <= 1399:print(4)
elif 1400 <= x <= 1599:print(3)
elif 1600 <= x <= 1799:print(2)
else:print(7)
|
p03221 | s696799229 | Wrong Answer | import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]
a = defaultdict(list)
for x,y in sorted(p):
a[x].append(y)
for x,y in p:
z=bisect.bisect(a[x],y)
print("{0:06d}{0:06d}".format(x,z)) |
p03419 | s769456478 | Accepted | N,M=map(int,input().split())
print(abs(N-2)*abs(M-2)) |
p03827 | s815899367 | Accepted | n = int(input())
s = input()
x = 0
point = [0] * (n + 1)
for i in range(n) :
if s[i] == "I" :
point[i+1] = point[i] + 1
if s[i] == "D" :
point[i+1] = point[i] - 1
print(max(point))
|
p02819 | s265940766 | Accepted | import math
X = int(input())
if X == 2:
print(2)
else:
is_find = False
while not is_find:
for i in range(2, X//2):
is_find = True
if math.gcd(X, i) != 1:
is_find = False
X += 1
break
rst = X
print(rst) |
p03854 | s102172959 | Wrong Answer | s = input()
a = 'dream'
b = 'dreamer'
c = 'erase'
d = 'eraser'
for i in range(len(s)):
if not s[i] == a[i//4] or s[i] == b[i//5] or s[i] == c[i//4] or s[i] == d[i//5]:
print('NO')
exit()
print('YES') |
p02711 | s727283116 | Accepted | n = int(input())
x = n % 10
y = (n // 10) % 10
z = n // 100
if x == 7 or y == 7 or z == 7:
print("Yes")
else:
print("No")
|
p02713 | s073718118 | Accepted | # C - Sum of gcd of Tuples (Easy)
from math import gcd
def main():
K = int(input())
gcd_three = lambda x, y, z: gcd(gcd(x, y), z)
ans = sum(
gcd_three(i, j, k)
for i in range(1, K + 1)
for j in range(1, K + 1)
for k in range(1, K + 1)
)
print(ans)
if __name__ == "__main__":
main()
|
p02687 | s645747562 | Accepted | comp = input()
if comp == "ABC":
print("ARC")
else:
print("ABC") |
p02953 | s691805159 | Accepted | n = int(input())
h = list(map(int, input().split()))
N=h[0]
for i in range(n):
if N-1 > h[i]:
print("No")
break
elif h[i] > N:
N = h[i]
else:
print("Yes") |
p03803 | s638512740 | Accepted | A, B = map(int, input().split())
if A == B:
print('Draw')
elif A == 1:
print('Alice')
elif B == 1:
print('Bob')
elif A > B:
print('Alice')
else:
print('Bob')
|
p03721 | s758604098 | Accepted | N, K = map(int, input().split())
cnt = [0]*100001
S = set()
for i in range(N):
a, b = map(int, input().split())
cnt[a-1] += b
S.add(a)
acc = 0
for s in sorted(S):
acc += cnt[s-1]
if acc >= K:
print(s)
break
|
p02935 | s473950364 | Accepted | N = int( input() )
V = list( map( int, input().split() ) )
V.sort()
ret = V[0]
for i in range( 1, len( V ) ):
ret = ( ret + V[i] ) / 2
print( ret ) |
p02848 | s822900340 | Accepted | N = int(input())
S = input()
C = list(S)
cA = ord('A') # 65
n = ord('Z') - ord('A') + 1 # 26
ans = map(lambda c : chr(cA + (ord(c) + N - cA) % n), C)
print(''.join(ans)) |
p03612 | s362237067 | Accepted | n=int(input())
p=list(map(int,input().split()))
i=0
ans=0
while i<n:
if p[i]==i+1:
i+=1
ans+=1
i+=1
print(ans) |
p04019 | s874216841 | Accepted | s=input()
a=s.count("N")
b=s.count("W")
c=s.count("S")
d=s.count("E")
ans=False
if a!=0 and c!=0:
if (b!=0 and d!=0) or (b==0 and d==0):
ans=True
if a==0 and c==0:
if (b!=0 and d!=0) or (b==0 and d==0):
ans=True
if ans==True:
print("Yes")
else:
print("No") |
p03407 | s185068963 | Accepted | a, b, c = map(int, input().split())
print("Yes" if a + b >= c else "No") |
p03971 | s423658667 | Wrong Answer | N,A,B=map(int,input().split())
S=input()
t_count=0
b_count=0
flag=None
for i in S:
if i=="c":
print("No")
else:
if i=="a":
t_count+=1
if t_count<=A+B:
print("Yes")
else:
print("No")
else:
b_count+=1
if b_count<=B:
t_count+=1
print("Yes")
else:
print("No") |
p03644 | s576200897 | Accepted | n = int(input())
a = 0
while n > 1:
n = n//2
a = a+1
print(2**a) |
p03778 | s571237419 | Wrong Answer | w, a, b = map(int, input().split())
if a < b < a + w:
print(0)
elif a + w < b:
print(b - (a + w))
elif b + w < a:
print(a - (b + w)) |
p03162 | s937746744 | Accepted | # C Vacation
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
#print(N,A)
dp = [[0] * 3 for _ in range(N)]
dp[0][0] = A[0][0]
dp[0][1] = A[0][1]
dp[0][2] = A[0][2]
#print(dp)
for i in range(1,N):
for j in range(3):
for k in range(3):
if j != k:
dp[i][j] = max(dp[i][j],dp[i-1][k]+A[i][j])
print(max(dp[N-1])) |
p02973 | s816170490 | Accepted | import sys
from bisect import bisect_right as bi_r, bisect_left as bi_l
inf = float('inf')
n, *a = map(int, sys.stdin.read().split())
def main():
res = [inf] * n
for x in a[::-1]:
res[bi_r(res, x)] = x
print(bi_l(res, inf))
if __name__ == '__main__':
main() |
p02706 | s443680951 | Wrong Answer | N,M = map(int,input().split())
A = list(map(int,input().split()))
print(N - sum(A)) |
p02922 | s289471839 | Accepted | import math
a,b=map(int,input().split())
print(math.ceil((b-1)/(a-1))) |
p02743 | s160656162 | Accepted | a,b,c = list(map(int, input().split()))
"""
a ** 0.5 + b ** 0.5 < c ** 0.5
a + 2(a*b) ** 0.5 + b < c
2(a*b) ** 0.5 < (c - a -b)
#c-a-b>0のとき
4(a*b) < (c - a -b)**2
a*b < (c-a-b)**2/4
"""
if 4*(a*b) < (c-a-b)**2 and c-a-b>0:
print("Yes")
else:
print("No") |
p02765 | s675131625 | Accepted | N, R = map(int, input().split())
if N >= 10:
answer = R
else:
answer = R + 100*(10 - N)
print(answer) |
p02823 | s817783924 | Accepted | N, A, B = map(int, input().split())
if (B - A) % 2 == 0:
print((B - A) // 2)
else:
print(min(A + (B - A - 1) // 2, N - B + 1 + (B - A - 1) // 2))
|
p03854 | s135519212 | Accepted | s = input()[::-1]
while True:
if len(s) == 0:
break
if s[:7] == "remaerd":
s = s[7:]
elif s[:6] == "resare":
s = s[6:]
elif s[:5] == "maerd" or s[:5] == "esare":
s = s[5:]
else:
print("NO")
exit()
print("YES") |
p03438 | s719167722 | Wrong Answer | n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=sum(b)-sum(a)
p=0
for i in range(n):
if a[i]>=b[i]:
p+=a[i]-b[i]
else:
p+=a[i]-b[i]//2*-1
print('Yes' if k>=p else 'No')
#print(k) |
p02832 | s393392569 | Accepted | import math
import statistics
a=int(input())
#b=int(input())
# c=[]
# for i in b:
# c.append(i)
# e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
# h = []
# for i in range(e1):
# h.append(list(map(int,input().split())))
ans=0
count=0
for i in range(a):
if ans+1 == f[i]:
ans=f[i]
count+=1
if count>0:
print(len(f)-count)
else:
print(-1) |
p03328 | s329635768 | Accepted | a, b = map(int, input().split())
h = 0
hs = []
for i in range(1, 1000):
h += i
hs.append(h)
for i in range(998):
if (hs[i] - a) == (hs[i + 1] - b):
print(hs[i] - a)
exit()
|
p02720 | s545229271 | Accepted | K = int(input())
ans = [i + 1 for i in range(9)]
i = 0
while len(ans) <= K:
s = str(ans[i])
t = int(s[-1])
d = [-1, 0, 1]
if t == 0:
d = [0, 1]
elif t == 9:
d = [-1, 0]
for x in d:
ans.append(s + str(t + x))
i += 1
print(ans[K-1]) |
p02854 | s700904331 | Accepted | n=int(input())
a=list(map(int,input().split()))
sm=sum(a)
x=[a[0]]
y=[sm-a[0]]
for i in range(1,n):
x.append(x[i-1]+a[i])
y.append(sm-x[i])
min=9999999999
for (p,q) in zip(x,y):
sa=abs(p-q)
if sa<min:
min=sa
print(min) |
p02897 | s333488525 | Accepted | n=int(input())
kisu=0
for i in range(1,n+1):
if i%2==1:
kisu+=1
print(kisu/n) |
p02658 | s047100955 | 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 > 10**18:
print(-1)
break
else :
print(prod) |
p03289 | s900808861 | Accepted | s = input()
ans = "AC"
c = 0
for i in range(len(s)):
if i==0 and s[i]!="A":
ans = "WA"
if i>=2 and i<len(s)-1:
if s[i]=="C":
c += 1
elif ord(s[i])>=65 and ord(s[i])<=90:
ans = "WA"
if i==1 or i==len(s)-1:
if ord(s[i])>=65 and ord(s[i])<=90:
ans = "WA"
if c!=1:
ans = "WA"
print(ans) |
p02765 | s267161970 | Accepted | N, R = map(int, input().split())
if N < 10:
print(R+(10-N)*100)
else:
print(R) |
p03328 | s339110519 | Wrong Answer | a,b=map(int,input().split())
n=999
l=[1]*n
for i in range(1,n):
l[i]=l[i-1]+(i+1)
if l[i-1]<=a<l[i]:
print(l[i]-a)
break |
p02664 | s317685480 | Accepted | T = list(input())
tlen = len(T)
for i in range(0, tlen):
if T[i] == '?':
T[i] = 'D'
print(*T,sep='') |
p02555 | s165774244 | Accepted | mod = 1000000007
N = int(input())
memo = [0]*(N+1)
for i in range(3,N+1):
tmp = 1
for j in range(i-3):
tmp += memo[j+1]
memo[i] = tmp%mod
print(memo[-1]) |
p02744 | s036577173 | Accepted | n = int(input())
def chrinc(s,n):
return chr(ord(s)+1)
def dfs(s,mx):
if len(s) == n:
print(s)
else:
c = 'a'
while c <= mx:
dfs(s+c, chrinc(mx,1) if c==mx else mx)
c = chrinc(c,1)
dfs('','a') |
p03137 | s964881422 | Accepted | N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N>=M: print(0);exit()
if N==1: print(X[-1]-X[0]);exit()
L = []
for i in range(len(X)-1):
L.append(X[i+1]-X[i])
L.sort()
L = L[:-(N-1)]
print(sum(L)) |
p02629 | s713542376 | Accepted | N = int(input())
def num2alpha(num):
if num<=26:
return chr(64+num)
elif num%26==0:
return num2alpha(num//26-1)+chr(90)
else:
return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(N).lower()) |
p03814 | s661832714 | Wrong Answer | s = input()
sa = 0
sz = 0
for i in range(len(s)):
if sa == 0 and s[i] == "A":
sa = i
if s[i] == "Z":
sz = i
print(sz-sa+1) |
p02664 | s991195791 | Accepted | t=input()
print(t.replace("?","D")) |
p02663 | s818434586 | Accepted | n = 0
H1,M1,H2,M2,K = map(int,input().rstrip().split(" "))
n = (H2 - H1) * 60 + (M2 - M1)
print(n - K) |
p03745 | s812448606 | Accepted | n = int(input())
a = list(map(int, input().split()))
flg = None
cur = a[0]
cnt = 1
for v in a[1:]:
if v > cur:
if flg is None:
flg = True
if not flg:
flg = None
cnt += 1
if v < cur:
if flg is None:
flg = False
if flg:
cnt += 1
flg = None
cur = v
print(cnt) |
p02948 | s730946286 | Wrong Answer | from collections import deque
n,m=map(int,input().split())
lmoney=[]
for _ in range(n):
a,b=map(int,input().split())
if a<=m:
lmoney.append([b,a])
lmoney=sorted(lmoney,reverse=True)
q=deque()
for i in lmoney:
q.append(i)
day=0
money=0
while day<=m and q:
job=q.popleft()
if job[1]<=m-day:
money+=job[0]
day+=1
print(money) |
p03107 | s249254333 | Accepted | s = list(input())
red = s.count("0")
blue = len(s) - red
print(min(red, blue)*2) |
p02681 | s935417182 | Accepted | S = input()
T = input()
if S == T[:-1]:
print('Yes')
else:
print('No') |
p02621 | s169320474 | Accepted | def main():
a=int(input())
print(a*(1+a+a*a))
main() |
p03695 | s074085419 | Accepted | n = int(input())
a = list(map(int, input().split()))
col1 = []
col2 = []
for i in a:
if i//400<8:
col1.append(i//400)
else:
col2.append(i//400)
min = len(set(col1))
if min == 0:
min = 1
max = len(set(col1))+len(col2)
print(min, max)
|
p03456 | s592759182 | Accepted | a, b = map(str,input().split())
c = int(a+b)
d = c ** (1/2)
if d.is_integer():
print("Yes")
else:
print("No") |
p03371 | s015283681 | Accepted | A,B,C,X,Y = map(int,(input().split()))
#ABピザの最大枚数
limit = max(X,Y)*2
Min = 10**10
for i in range(limit+1):
a=0
b=0
c=0
if i/2 < X:
a = (X-int(i/2)) *A
if i/2 < Y:
b= (Y-int(i/2))*B
c = i*C
Min = min(Min,a+b+c)
print(Min)
|
p02547 | s112789857 | Accepted | n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]:
print('Yes')
exit()
print('No')
|
p02989 | s632110102 | Wrong Answer | N = int(input())
D = sorted(map(int, input().split()))
print(D)
if D[N//2 - 1] == D[N//2]:
print(0)
else:
print(D[N//2] - D[N//2 - 1]) |
p03416 | s168609713 | Accepted | A,B=map(int,input().split())
cnt=0
for i in range(A,B+1):
S=str(i)
if S[0]==S[4] and S[1]==S[3]:
cnt+=1
print(cnt) |
p02675 | s761148573 | Accepted | N= input()
a= int(N[-1])
if(a== 3):
print("bon")
elif(a== 0 or a== 1 or a== 6 or a== 8):
print("pon")
else:
print("hon") |
p03796 | s917476612 | Wrong Answer | N = int(input())
power = 1
for i in range(1, N+1):
power *= i
power %= 1e9 + 7
print(power)
|
p02747 | s782040635 | Accepted | S= input()
if len(S) %2 != 0:
print('No')
exit()
number = len(S)//2
if 'hi'*number == S:
print('Yes')
exit()
print('No') |
p03971 | s130188305 | Accepted | N,A,B =list(map(int, input().split()))
S = input()
C = A+B
a_number = 0
b_number= 0
for i in S:
if i == "a" and a_number< C:
print("Yes")
a_number = a_number+1
elif i == "b" and a_number<C and b_number<B:
print("Yes")
a_number = a_number + 1
b_number = b_number +1
else:
print("No") |
p02641 | s726709624 | Accepted | x, n = map(int, input().split())
s = list(map(int, input().split()))
for j in range(n):
s[j] = s[j] - x
i = 0
while True:
if -i not in s:
print(x-i)
exit()
if i not in s:
print(x+i)
exit()
i += 1
|
p02861 | s323255524 | Accepted | from itertools import permutations
from math import factorial
n=int(input())
XY=[list(map(int,input().split())) for _ in range(n)]
ans=0
for A in permutations(XY,n):
cnt=0
for j in range(n-1):
cnt +=((A[j][0]-A[j+1][0])**2+(A[j][1]-A[j+1][1])**2)**0.5
ans +=cnt
print(ans/factorial(n)) |
p03377 | s740374897 | Accepted | a, b, x = map(int,input().split())
if a > x:
print("NO")
elif (a + b) >= x:
print("YES")
else:
print("NO")
|
p03433 | s719589682 | Accepted | n=int(input())
a=int(input())
amari=int(n%500)
if amari<=a:
print('Yes')
else:
print('No') |
p03435 | s958550652 | Accepted | c = [list(map(int, input().split())) for _ in [0]*3]
a = [0]*3
b = [0]*3
for i in range(3):
b[i] = c[0][i] - a[0]
for i in range(3):
a[i] = c[i][0] - b[0]
for i in range(3):
for j in range(3):
if a[i] + b[j] != c[i][j]:
print('No')
exit()
print('Yes') |
p03438 | s858599909 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
max_count = sum(b) - sum(a)
count = 0
for i in range(n):
if a[i] > b[i]:
count += (a[i] - b[i])
elif a[i] < b[i]:
if (b[i] - a[i]) % 2 == 0:
count += (b[i] - a[i]) // 2
else:
count += (b[i] - a[i]) // 2 + 1
else: continue
if count <= max_count:
print('YES')
else:
print('NO')
|
p02613 | s161741987 | Accepted | results = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
N = int(input())
for _ in range(N):
S = input()
results[S] = results[S] + 1
for k, v in results.items():
print(k, 'x', v) |
p02939 | s072573181 | Accepted | ans=0
S=T=''
for i in input():
S+=i
if S!=T:
ans+=1
S,T='',S
print(ans) |
p02661 | s511038996 | Accepted | n = int(input())
A = []
B = []
for i in range(n):
a,b = map(int,input().split())
A.append(a)
B.append(b)
A.sort()
B.sort()
if n%2 == 1:
print(B[(n-1)//2] - A[(n-1)//2] + 1)
else:
M = B[n//2 - 1] + B[n//2]
m = A[n//2 - 1] + A[n//2]
ans = M-m+1
print(ans) |
p02918 | s323564330 | Accepted | N, K = map(int, input().split())
S = input()
x, y = 0, 0
if S[0] == "L":
y += 1
if S[-1] == "R":
y += 1
x = S.count("RL")
if x:
if x > K:
x -= K
K = 0
else:
K -= x
x = 0
if K > 0:
y = max(1, y - K)
print(N - 2 * x - y) |
p02696 | s304172061 | Accepted | A, B, N = map(int, input().split())
m = B - 1 if N >= B else N
print(A * m // B)
|
p03206 | s562301450 | Wrong Answer |
D = int(input())
print("christmas" + "Eve" * (25-D))
|
p03971 | s018809661 | Accepted | N, A, B = map(int, input().split())
S = list(input())
f_cnt = 0
s_cnt = 0
for s in S:
if s == 'a' and s_cnt < A + B:
print('Yes')
s_cnt += 1
elif s == 'b' and s_cnt < A + B and f_cnt < B:
print('Yes')
s_cnt += 1
f_cnt += 1
else:
print('No')
|
p03623 | s827360587 | Accepted | x, a, b = map(int, input().split())
if (x - a) ** 2 < (x - b) ** 2:
print('A')
else:
print('B') |
p03380 | s218741126 | Wrong Answer | n = int(input())
a = sorted(map(int, input().split()))
print(a)
from operator import mul
from functools import reduce
def comb(n, r):
r = min(r, n-r)
numer = reduce(mul, range(n, n-r, -1), 1)
denom = reduce(mul, range(1, r+1), 1)
return numer // denom
from bisect import bisect_left
n = a[-1]
p = bisect_left(a, n//2) - 1
ans_r = -1
comb_max = 0
for i in range(p, n):
c = comb(n, a[i])
if c > comb_max:
comb_max = c
ans_r = a[i]
else:
break
print(n, ans_r) |
p03386 | s039818828 | Accepted | a,b,k = map(int, input().split())
ans=[]
for i in range(a,min(a+k,b)):
ans.append(i)
for j in range(max(a,b-k+1),b+1):
ans.append(j)
ans=list(set(ans))
ans.sort()
l=len(ans)
for i in range(l):
print(ans[i]) |
p02695 | s357117102 | Wrong Answer | import itertools
n, m, q = map(int, input().split())
abcd = []
a_pre = []
for i in range(q):
abcd.append(list(map(int, input().split())))
lis = [i for i in range(1,m+1)]
for pair in itertools.combinations(lis, n):
a_pre.append(list(pair))
sum = 0
for i in range(len(a_pre)):
sum_pre = 0
for j in range(len(abcd)):
if a_pre[i][abcd[j][1] - 1] - a_pre[i][abcd[j][0] - 1] == abcd[j][2]:
sum_pre = sum_pre + abcd[j][3]
if sum_pre > sum:
sum = sum_pre
print(sum) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.