problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02663 | s548345371 | Wrong Answer | H1,M1,H2,M2,K = map(int,input().split())
tmp = K
if (M1 < M2):
H = H2 - H1 - 1
M = M1 - M2
if M < 0:
M = 60 - M
else:
H = H2 - H1
M = M2 - M1
T = H * 60 + M
ans = 0
while T > tmp:
T = T - K
ans += K
print(ans) |
p03821 | s039024011 | Wrong Answer | n=int(input())
a=[]
b=[]
for _ in range(n):
a_i ,b_i = map(int,input().split())
a.append(a_i)
b.append(b_i)
cnt=0
a=list(reversed(a))
b=list(reversed(b))
for i in range(n):
fr = a[i]+cnt
target =b[i]
if fr ==0 or target==1:
continue
num = abs(target -fr) // target
if fr>target:
target += target*(num+1)
cnt += (target-fr)
print(int(cnt))
|
p02958 | s477676353 | Accepted | n = int(input())
P = list(map(int, input().split()))
sorted_P = sorted(P)
cnt = 0
for i in range(n):
if sorted_P[i] != P[i]:
cnt += 1
if cnt <= 2:
print("YES")
else:
print("NO") |
p03645 | s646685073 | Accepted | from sys import stdin
nii=lambda:map(int,stdin.readline().split())
def main():
n,m=nii()
tree=[[] for i in range(n)]
for i in range(m):
a,b=nii()
a-=1
b-=1
tree[a].append(b)
tree[b].append(a)
for i in tree[0]:
for j in tree[i]:
if j==n-1:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
if __name__=="__main__":
main() |
p03317 | s361099705 | Wrong Answer | import math
n, k, *nums = map(int, open(0).read().split())
print(math.ceil((n-k)/2)+1) |
p02595 | s321417377 | Wrong Answer | N,D=map(int,input().split())
ans=0
for i in range(N):
x,y=map(int,input().split())
if x^2 + y^2<=D^2:
ans+=1
print(ans)
|
p03328 | s266664217 | Wrong Answer | A,B=map(int,input().split())
H=[0]*1000
i=1
while i<=999:
H[i]=i+H[i-1]
i+=1
ans=0
while True:
if (A+ans in H)and(B+ans in H):
break
else:
ans+=1
print(ans) |
p03162 | s134884090 | Accepted | N = int(input())
dp = [[0 for _ in range(3)] for _ in range(N + 1)]
a, b, c = map(int, input().split())
dp[1][0] = a
dp[1][1] = b
dp[1][2] = c
for i in range(2, N + 1):
a, b, c = map(int, input().split())
dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
print(max(dp[N])) |
p02607 | s031618758 | Wrong Answer | import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)):
if i % 2 == 1 and A[i] % 2 == 1:
ans += 1
print(ans) |
p03262 | s343869264 | Accepted | n, x = map(int,input().split())
tmp = list(map(int,input().split()))
tmp.append(x)
se = list(sorted(set(tmp)))
lis = []
for si,s in enumerate(se):
lis.append(se[si]-se[si-1])
import fractions
a = lis
ans = a[0]
for i in range(1, len(a)):
ans = fractions.gcd(ans, a[i])
print(ans) |
p02622 | s903799708 | Accepted | s,t=input(),input()
slen=len(s)
j=0
count=0
for i in range(slen):
if s[j]!=t[j]:
count+=1
j+=1
print(count) |
p03416 | s931363157 | Accepted | a,b=map(int,input().split())
def is_pali(s):
if s==s[::-1]: return True
else: return False
cnt=0
for i in range(a,b+1):
if is_pali(str(i))==True: cnt+=1
print(cnt) |
p02848 | s776904451 | Accepted | n=int(input())
for c in input():
print(chr(65+(ord(c)-65+n)%26),end='') |
p02771 | s826705523 | Wrong Answer | a, b, c = map(int, input().split())
if a == b:
if a == c:
print('No')
else:
print('Yes')
else:
if b == c:
print('Yes')
else:
print('No') |
p02888 | s005948129 | Wrong Answer | import itertools, bisect
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for a, b in itertools.combinations(L, 2):
ans += bisect.bisect_left(L, a + b) - bisect.bisect_right(L, b)
print(ans)
|
p03219 | s234929815 | Accepted | import sys
input=sys.stdin.readline
a,c=map(int,input().split())
ans=a+c/2
print(int(ans)) |
p03241 | s730477696 | Wrong Answer | from math import sqrt,floor
N,M =map(int,input().split())
ans = 1
n = N
for g in range(1,floor(sqrt(M)+1)):
if M%g == 0:
x = M//g
if x > floor(sqrt(N)) and g >= N:
ans = x
if x >= N:
ans = g
print(ans) |
p02835 | s483438685 | Accepted | if sum(map(int, input().split())) >= 22:
ans = 'bust'
else:
ans = 'win'
print(ans)
|
p02641 | s243933613 | Accepted | X, N = list(map(int, input().split()))
if N == 0: print(X)
else:
p = list(map(int, input().split()))
if not X in p:
print(X)
else:
q = [X-1, X+1]
while True:
if not q[0] in p:
print(q[0])
break
elif not q[1] in p:
print(q[1])
break
q = [q[0]-1, q[1]+1] |
p03127 | s925183673 | Accepted | # coding: utf-8
n = int(input().rstrip())
monster = [int(i) for i in input().rstrip().split(" ")]
def get_dev(num1:int, num2:int):
if num1 % num2 == 0:
return num2
return get_dev(num2, num1 % num2)
cur = monster[0]
for i in range(1,n):
cur = get_dev(cur, monster[i])
print(cur)
|
p02706 | s097049313 | Wrong Answer | n,m = map(int,input().split())
ls = list(map(int,input().split()))
if sum(ls) < n:
print(n-sum(ls))
else:
print("-1") |
p02675 | s315557549 | Accepted | n = int(input())
n = n%10
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
print("hon")
elif n == 3:
print("bon")
else:
print("pon") |
p03759 | s112673099 | Accepted | a, b, c = map(int, input().split())
print('YES' if b - a == c - b else 'NO') |
p02555 | s954996356 | Accepted | s=int(input())
m=10**9+7
dp=[0]*(s+1)
dp[0]=1
for i in range(1,s+1):
for j in range(0,(i-3)+1):
dp[i]+=dp[j]
dp[i]%=m
print(dp[s]) |
p03105 | s006193858 | Wrong Answer | import sys
stdin = sys.stdin
mod = 1000000007
inf = 1 << 60
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()
a, b, c = na()
if a * c <= b:
print(a * c)
else:
print(b // a) |
p02712 | s304359019 | Accepted | n=int(input())
l=[]
for i in range(1,n+1):
if i%3==0:l.append(0)
elif i%5==0:l.append(0)
else:l.append(i)
print(sum(l)) |
p03417 | s885362255 | Accepted | n,m = map(int,input().split())
if n>=2 and m>=2:
n-=2
m-=2
print(n*m)
elif n==1 and m==1:
print(1)
else:
print(max(n,m)-2) |
p03633 | s475039335 | Accepted | n=int(input())
A=[]
for i in range(n):
A.append(int(input()))
import numpy as np
print(np.lcm.reduce(A)) |
p02730 | s404822236 | Wrong Answer | s = list(input())
n = len(s)
if (
s[: (n - 1) // 2] == s[: (n - 1) // 2][::-1]
and s[(n + 1) // 2 :] == s[(n + 1) // 2 :][::-1]
):
print("Yes")
else:
print("No")
|
p03281 | s236449347 | Accepted | N=int(input())
ans=0
for i in range(1,N+1,2):
count=0
for j in range(1,i+1):
if i%j==0:
count+=1
if count==8:
ans+=1
print(ans)
|
p02790 | s870053461 | Accepted | a,b=input().split()
print( b*int(a) if a>b else a*int(b))
|
p02951 | s578196281 | Accepted | a, b, c = map(int, input().split())
print(max(0, c - (a - b))) |
p02596 | s009573242 | Wrong Answer | k = int(input())
count = 0
temp = ''
remainder = 0
reminder_list = []
while True:
count += 1
temp += '7' # 7, 77, 777,,,
reminder = int(temp) % k
print(reminder)
if reminder in reminder_list:
count = -1
break
if reminder == 0:
break
else:
temp = str(reminder % k)
reminder_list.append(reminder)
print(count) |
p02582 | s545179899 | Accepted | s=input()
c=0
m=0
flg=False
for x in s:
if x=="R" and flg:c+=1;m=max(m,c)
if x=="R" and not flg:
flg=True
c=1
m=max(m,c)
if x=="S":
flg=False
c=0
print(m) |
p03254 | s834460105 | Wrong Answer | import sys
input = sys.stdin.readline
def main():
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
for i, a in enumerate(sorted(a_list), start=1):
x -= a
if x < 0:
break
if x >= 0:
print(i)
else:
print(i-1)
if __name__ == '__main__':
main() |
p02843 | s895190220 | Accepted | X = int(input())
dp = [0 for _ in range(X + 110)]
dp[0] = 1
for i in range(X + 1):
if dp[i] == 0:
continue
dp[i + 100] = 1
dp[i + 101] = 1
dp[i + 102] = 1
dp[i + 103] = 1
dp[i + 104] = 1
dp[i + 105] = 1
print(dp[X]) |
p03062 | s181378270 | Accepted | n=int(input())
a=list(map(int,input().split()))
ans=0
mn=0
mi=abs(a[0])
for i in range(n):
if a[i]<=0:
mn += 1
s=abs(a[i])
ans += s
mi=min(s,mi)
if mn%2==1:
ans -= mi*2
print(ans) |
p03437 | s471940828 | Accepted | x, y = map(int, input().split())
if x%y == 0:
ans = -1
else:
ans = 0
cnt = 2
while True:
if (x*cnt)%y != 0:
ans = x*cnt
break
else:
cnt += 1
print(ans) |
p02829 | s753573538 | Accepted | a=int(input())
b=int(input())
print(6-a-b) |
p02615 | s754630223 | Accepted | def INT():
return int(input())
def MI():
return map(int, input().split())
def LI():
return list(map(int, input().split()))
N = INT()
A = LI()
A = A + sorted(A, reverse = True)[1 : ]
A.sort(reverse = True)
ans = 0
for i in range(N - 1):
ans += A[i]
print(ans) |
p03817 | s072889510 | Accepted | x=int(input())
ans=2*(x//11)
if 1<=x%11<=6:
ans+=1
elif 7<=x%11<=10:
ans+=2
print(ans)
|
p02555 | s456517606 | Wrong Answer | S = int(input())
if S<2:
print(0)
else:
ma = int(S/3)
if S/9<0:
mi = 1
elif S%9==0:
mi =int(S/9)
else:
mi = int(S/9)+1
ans=0
from scipy.special import comb
for i in range(mi,ma+1):
if i==1:
ans=1
continue;
x = S-i*3
ans+=comb(x+i-1, x, exact=True, repetition=True)
#ans+=math.factorial(x+i-1)/(math.factorial(i-1)*math.factorial(x))
print(int(ans%(10**9+7)))
|
p03487 | s941395524 | Wrong Answer | # coding: utf-8
import collections
N = int(input())
A= list(map(int,input().split()))
A.sort()
c = collections.Counter(A)
A_ = list(set(A))
ans = 0
for a in A_:
ans += min(a-c[a],c[a])
print(ans) |
p02583 | s546019941 | Accepted | N=int(input())
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
a,b,c = L[i],L[j],L[k]
if a!=b and a!=c and b!=c and a+b>c:
ans+=1
print(ans) |
p04033 | s570740311 | Accepted | a, b = map(int, input().split())
if a<0 and b<0:
if (b-a)%2 == 0:
print("Negative")
else:
print("Positive")
elif a <= 0 and b >= 0:
print("Zero")
else:
print("Positive") |
p02584 | s820056505 | Accepted | x,k,d=map(int,input().split())
x=abs(x)
if x>k*d:
ans=x-k*d
else:
n=x//d
if (k-n)%2==0:
ans=x-n*d
else:
ans=abs(x-(n+1)*d)
print(ans) |
p02689 | s588321182 | Wrong Answer | N,M = map(int,input().split(' '))
H = [int(i) for i in input().split(' ')]
AB = []
for i in range(M):
A,B = map(int,input().split(' '))
AB.append(max(H[A-1],H[B-1]))
print(len(set(AB))) |
p03555 | s302997390 | Accepted | import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))
c=[input() for i in range(2)]
ans="YES"
if c[0][0]!=c[1][2]:
ans="NO"
if c[0][1]!=c[1][1]:
ans="NO"
if c[0][2]!=c[1][0]:
ans="NO"
print(ans) |
p02835 | s456002818 | Wrong Answer | a, b, c = map(int, input().split())
if a + b + c < 22:
print('win')
else:
print('burst')
|
p02577 | s427864318 | Accepted | N = int(input())
if N % 9 == 0:
print("Yes")
else:
print("No") |
p03438 | s911789101 | Accepted | def check():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff = sum(B)-sum(A)
if diff < 0:
return 'No'
cnt = 0
for i in range(N):
cnt += max((B[i]-A[i]+1)//2,0)
if diff < cnt:
return 'No'
return 'Yes'
print(check()) |
p03109 | s481530281 | Wrong Answer | s = input()
if int(s[:4]) <= 2019:
if int(s[5:7]) <= 4:
if int(s[8:10]) < 30:
print('Heisei')
else:
print('TBO')
else:
print('TBO')
else:
print('TBO') |
p02814 | s939286716 | Accepted | def gcd(x, y):
if x == 0: return y
return gcd(y%x, x)
lcm = lambda x, y: x*y//gcd(x, y)
n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]
cm = arr[0]
for e in arr[1:]:
cm = lcm(cm, e)
if any([cm//e % 2 == 0 for e in arr]):
print(0)
exit()
print((m//cm+1)//2)
|
p03264 | s232658348 | Wrong Answer | import math
n = int(input())
print(math.ceil(n/2)*n//2) |
p03623 | s842663259 | Accepted | x,a,b = map(int,input().split())
if abs(x-a)<abs(x-b):
print('A')
else:
print('B') |
p02700 | s069648600 | Accepted | a,b,c,d = map(int, input().split())
def solve(a,b,c,d):
while True:
c -= b
if c <= 0:
return "Yes"
a -= d
if a <= 0:
return "No"
print(solve(a,b,c,d)) |
p02621 | s238176058 | Accepted | a=int(input())
print(a+a**2+a**3) |
p03087 | s732399237 | Accepted | N, Q = map(int, input().split())
S = input()
cnt = [None] * N
cnt[0] = 0
for i in range(1, N):
if S[i-1:i+1] == 'AC':
cnt[i] = cnt[i-1] + 1
else:
cnt[i] = cnt[i-1]
ans = []
for _ in range(Q):
l, r = map(int, input().split())
ans.append(cnt[r-1] - cnt[l-1])
print('\n'.join(list(map(str, ans)))) |
p03836 | s360399954 | Accepted | sx, sy, tx, ty = list(map(int, input().split()))
x = tx-sx
y = ty-sy
print('D', 'R'*(x+1), 'U'*(y+1), 'L', sep='', end='')
print('D'*y, 'L'*x, sep='', end='')
print('L', 'U'*(y+1), 'R'*(x+1), 'D', sep='', end='')
print('L'*x, 'D'*y, sep='') |
p03659 | s808307616 | Accepted | N = int(input())
a = list(map(int,input().split()))
ans = 10**10
deck = sum(a)
su = 0
for i in range(0,N-1):
su = su + a[i]
ar = deck - su
ans = min(ans, abs(su-ar))
print(ans) |
p03720 | s345879096 | Accepted | N, M = map(int, input().split())
l=[]
for i in range(M):
a, b = map(int, input().split())
l.append(a)
l.append(b)
for i in range(1, N+1):
print(l.count(i)) |
p03767 | s049040098 | Wrong Answer | n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
print(sum(a[n:2*n]))
|
p03557 | s407715752 | Accepted | import bisect
def snuke_festival(N,arr):
n_pair = 0
for item in arr[1]:
up_pair = bisect.bisect_left(arr[0],item)
down_pair = bisect.bisect_right(arr[2],item)
n_pair += up_pair*(N-down_pair)
return n_pair
if __name__ == "__main__":
N =int(input())
arr = []
for i in range(3):
arr.append(list(map(int,input().split())))
arr_sorted = []
for j in range(3):
arr_sorted.append(arr[j].sort())
print(snuke_festival(N,arr)) |
p02578 | s897549325 | Accepted | N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(1,N):
if A[i-1]>A[i]:
ans+=A[i-1]-A[i]
A[i]=A[i-1]
print(ans)
|
p02712 | s669587709 | Wrong Answer | num = int(input())
ans = 0
for i in range(num):
if(i%3!=0 and i%5!=0):
ans += i
print(ans)
|
p03042 | s610121220 | Accepted | S = input()
def is_yymm(s):
if 1<=int(s)<=12:
return "both"
else:
return "YY"
left = is_yymm(S[:2])
right = is_yymm(S[2:])
ans = left + right
if ans=="YYboth":
print("YYMM")
elif ans=="bothYY":
print("MMYY")
elif ans=="bothboth":
print("AMBIGUOUS")
else:
print("NA") |
p03380 | s415346758 | Accepted | n = int(input())
a = list(map(int, input().split()))
m = max(a)
a = sorted(a)
ans = 0
for i in a:
if abs(m/2-i) < abs(m/2-ans):
ans = i
print(m, ans) |
p03455 | s342810566 | Accepted | a, b = map(int, input().split())
print('Even' if a*b%2==0 else 'Odd') |
p02712 | s340857382 | Accepted | def S(M):
return M * (M + 1) // 2
N = int(input())
print(S(N) - 3 * S(N // 3) - 5 * S(N // 5) + 15 * S(N // 15))
|
p02923 | s625340460 | Accepted | n = int(input())
h = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(1, n):
if h[i] <= h[i - 1]:
cnt += 1
ans = max(ans, cnt)
else:
cnt = 0
print(ans)
|
p03607 | s219046575 | Wrong Answer | n = int(input())
nums = [int(input()) for _ in range(n)]
cnt = {}
for x in nums:
if x in cnt:
cnt[x] = 0
else:
cnt[x] = 1
print(sum(cnt.values())) |
p02916 | s035248970 | Accepted | n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
(*c,) = map(int, input().split())
ans = sum(c[a[i] - 1] for i in range(n - 1) if a[i + 1] - a[i] == 1)
print(ans + sum(b)) |
p02675 | s147966935 | Accepted | n = input()
hon =[2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]
if int(n[-1]) in hon:
print("hon")
elif int(n[-1]) in pon:
print("pon")
else:
print("bon") |
p02714 | s613230112 | Wrong Answer | from collections import Counter
n = int(input())
s = input()
c = Counter(s)
total = 1
for v in c.values():
total *= v
ct = 0
for i in range(n):
for j in range(i + 1, n):
k = j + j - i
if k >= n:
break
if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
ct += 1
print(total-ct if total - ct > 0 else 0) |
p03679 | s522730653 | Accepted | X, A, B = map(int, input().split())
if B - A <= 0:
print('delicious')
elif B - A <= X:
print('safe')
else:
print('dangerous') |
p03261 | s644869325 | Wrong Answer | N, *W = open(0).read().split()
is_ok = True
if len(W) != len(set(W)):
is_ok = False
else:
for i, w in enumerate(W):
if i > 1:
if before_w != w[0]:
is_ok = False
break
before_w = w[-1]
if is_ok:
print("Yes")
else:
print("No") |
p03252 | s237164062 | Accepted | import collections
A = input()
B = input()
A_c = collections.Counter(A)
B_c = collections.Counter(B)
A_c = A_c.values()
B_c = B_c.values()
A_c = list(A_c)
B_c = list(B_c)
A_c.sort()
B_c.sort()
if A_c == B_c:
print("Yes")
else:
print("No")
|
p02577 | s455609161 | Accepted | x=list(input())
a=0
for i in x:
a+=int(i)
if a%9==0:
print("Yes")
else:
print("No") |
p02918 | s592809980 | Accepted | #!/usr/bin/env python
# coding: utf-8
# In[1]:
N,K = map(int, input().split())
S = input()
# In[2]:
cnt = 1
for i in range(N-1):
if S[i] != S[i+1]:
cnt += 1
cnt = max(1,cnt-K*2)
print(N-cnt)
# In[ ]:
|
p03106 | s173683859 | Wrong Answer | A,B,K=map(int,input().split())
l=[]
for i in range(max(A,B)):
if A%(i+1)==0 and B%(i+1)==0: l.append(i+1)
l.sort(key=int)
print(l[K-1]) |
p03286 | s713472222 | Accepted | N = int(input())
if N == 0:
print('0')
exit()
ans = ''
while abs(N) > 0:
if abs(N) % 2 == 0:
ans += '0'
N //= 2
else:
N -= 1
N //= 2
ans += '1'
N *= -1
print(ans[::-1])
|
p02939 | s961476742 | Accepted | import sys
input = sys.stdin.readline
s = input().rstrip()
l = [0]*len(s)
k=0
for i in range(1,len(s)-1):
if s[i] == s[i-1] and l[i-1] == 0:
l[i]=1
l[i+1]=1
if len(s) >1 and s[-1] == s[-2] and l[-2] == 0:
l[-2] = 1
l[-1]=1
print(len(s)-sum(l)//2)
|
p03695 | s817944503 | Accepted | n = int(input())
a = list(map(int, input().split()))
d = {}
e = 0
for ai in a:
s = ai // 400
if s > 7:
e += 1
else:
if s in d:
d[s] += 1
else:
d[s] = 1
print(max(1, len(d)), len(d) + e)
|
p03042 | s713102134 | Wrong Answer | s = input()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
print("AMBIGUOUS")
elif (a > 12 and b > 12) or a == 0 or b == 0:
print("NA")
elif a > 12:
print("YYMM")
else:
print("MMYY") |
p02699 | s901284531 | Accepted | s, w = map(int, input().strip().split())
if w>=s:
print("unsafe")
else:
print("safe") |
p02700 | s318850871 | Wrong Answer | A,B,C,D = map(int,input().split())
while True:
C = C - B
if C <= 0:
print('C:',C)
break
A = A - D
if A <= 0:
print('A:',A)
break
print('Yes' if A >= C else 'no') |
p02623 | s506792816 | Accepted | N,M,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
import itertools
A = list(itertools.accumulate(A))
B = list(itertools.accumulate(B))
ans=0
b=M
for a in range(N+1):
if A[a]>K:
break
while A[a]+B[b]>K:
b-=1
ans=max(ans,a+b)
print(ans) |
p02729 | s295829887 | Accepted | import math
num_of_even, num_of_odd = map(int, input().split())
def combinations_count(n, r):
if n < 2:
return 0
else:
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if num_of_even == 1 and num_of_odd == 1:
print('0')
else:
print(combinations_count(num_of_odd, 2) + combinations_count(num_of_even, 2))
|
p03319 | s945970472 | Accepted | n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
ans += -(-(n-k)//(k-1))
print(ans) |
p03632 | s679413888 | Accepted | a, b, c, d = map(int, input().split())
if a > c:
a, c = c, a
if b > d:
b, d = d, b
ans = b - c
if ans < 0:
ans = 0
print(ans) |
p02595 | s994284355 | Accepted | N, D = map(int, input().split())
ans = 0
for i in range(N):
x, y = map(int, input().split())
if x**2 + y**2 <= D**2:
ans += 1
print(ans) |
p03479 | s489312571 | Accepted | x,y=map(int,input().split())
cnt=1
a=x
while a<=y:
if 2*a<=y:
cnt+=1
a=a*2
print(cnt) |
p03673 | s843216844 | Accepted | N = int(input())
A = [int(x) for x in input().split()]
A = [0] + A
B = []
i = N
if N%2==1:
for i in range(N, 0, -2):
B.append(A[i])
for i in range(2, N, 2):
B.append(A[i])
else:
for i in range(N, 1, -2):
B.append(A[i])
for i in range(1, N, 2):
B.append(A[i])
print(*B)
|
p03043 | s894655931 | Accepted | N, K = map(int, input().split())
prob = 0
for i in range(1, N+1):
x = 0
num = i * 2 ** x
while (K > num):
x += 1
num = i * 2 ** x
prob += 1 / N * (1 / 2) ** x
print(prob) |
p02706 | s868472122 | Accepted | n,m=map(int, input().split())
s=0
for i in input().split():
s=s+int(i)
if s>n:
print("-1")
else:
print(n-s) |
p03852 | s672034341 | Accepted | c = input()
print('vowel' if 'aeiou'.count(c) == 1 else 'consonant')
|
p02994 | s714791638 | Wrong Answer | n,a = map(int,input().split())
print(a*(n-1)+n/2*(n-1)-1-n) |
p03998 | s313576637 | Accepted | #abc045 b
from collections import deque
sa=deque(list(input()))
sb=deque(list(input()))
sc=deque(list(input()))
tefuda=sa
win=""
while tefuda:
c=tefuda.popleft()
if c=="a":
tefuda=sa
win="A"
if c=="b":
tefuda=sb
win="B"
if c=="c":
tefuda=sc
win="C"
print(win)
|
p03339 | s334585038 | Accepted | n=int(input())
s=input()
l=0
r=s[1:].count("E")
ans=r
MIN=r
for i in range(1,n):
if s[i-1]=="W":
ans+=1
if s[i]=="E":
ans-=1
MIN=min(ans,MIN)
print(MIN)
|
p02820 | s266139783 | Accepted | n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
u = [[] for i in range(k)]
R=0
S=0
P=0
for i in range(n):
u[i%k]+=t[i]
for i in range(k):
l=len(u[i])
for j in range(1,l):
if u[i][j]==u[i][j-1]:
u[i][j]='o'
R+=u[i].count('s')
S+=u[i].count('p')
P+=u[i].count('r')
print(r*R+s*S+p*P) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.