problem_id stringclasses 428
values | submission_id stringlengths 10 10 | status stringclasses 2
values | code stringlengths 5 816 |
|---|---|---|---|
p02607 | s413405793 | Accepted | N = int(input())
li = []
for i in input().split():
li.append(int(i))
a = 1
count = 0
for i in li:
if a % 2 == 1 and i % 2 == 1:
count += 1
a += 1
print(count)
|
p02695 | s776811070 | Accepted | from itertools import *
n, m, q = map(int, input().split())
abcd = []
for i in range(q):
abcd.append(list(map(int, input().split())))
abcd[i][0] -= 1
abcd[i][1] -= 1
numbers = []
for i in range(1, m + 1):
numbers.append(i)
cwr = list(combinations_with_replacement(numbers, n))
ans = 0
for c in cwr:
cnt = 0
for i in range(q):
if c[abcd[i][1]] - c[abcd[i][0]] == abcd[i][2]:
cnt += abcd[i][3]
ans = max(ans, cnt)
print(ans) |
p03773 | s559864490 | Wrong Answer | A, B = map(int, input().split())
time = A + B
if time > 24:
time = time - 24
print(time) |
p03210 | s096775578 | Accepted | #!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
x = I()
if x == 3 or x == 5 or x == 7:
print('YES')
else:
print('NO') |
p02700 | s209597818 | Wrong Answer | a,b,c,d=map(int,input().split())
print("Yes" if (c//b+c%b>0)<=(a//d+a%d>0) else "No") |
p02658 | s685919301 | Accepted | N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
print(0)
else:
for i in range(N):
ans *= A[i]
if 10 ** 18 < ans:
ans = -1
break
print(ans)
|
p02702 | s003936513 | Wrong Answer | import sys
import math
s=str(input())
s1=len(s)
k=0
a=0
p=list()
if s1<4:
print(0)
sys.exit()
for i in range(s1):
b=(int(s[s1-i-1])*10**i)%2019
a=a+b
p.append(a%2019)
for i in range(1,2019):
l=p.count(i)
if l>=2:
k=k+l-1
print(k+math.factorial(p.count(0))) |
p03556 | s434062216 | Accepted | import math
N = int(input())
A = int(math.sqrt(N))
print(A * A)
|
p02576 | s688587761 | Wrong Answer | N ,X, T = map(int,input().split())
if N %X ==0:
a = N // X + 1
else:
a = N//X
total = a *T
print(total)
|
p02730 | s421965734 | Wrong Answer | s = input()
s = list(s)
ans = True
fs = 0
sl = -1
fl = (len(s) - 1) // 2
ss = (len(s) + 3) // 2
for i in range(fl // 2):
if s[fs+i] == s[fl-i] and s[fl-i] == s[ss+i] and s[ss+i] == s[sl-i]:
pass
else:
ans = False
break
if ans:
print("Yes")
else:
print("No")
|
p02717 | s112507920 | Wrong Answer | N, M, *A = map(int, open(0).read().split())
vote = sum(A) / (4*M)
num = list(filter(lambda x: x > vote, A))
num = len(num)
if num >= M:
print("Yes")
else:
print("No") |
p03076 | s799140272 | Accepted | from itertools import permutations
def f(a,g):
return ((a+(g-1))//g)*g
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
P=[A,B,C,D,E]
Q=permutations(P)
M=10**100
for (v,w,x,y,z) in Q:
M=min(M,f(v,10)+f(w,10)+f(x,10)+f(y,10)+z)
print(M)
|
p02595 | s640451775 | Wrong Answer | import sys
import math
a = []
for l in sys.stdin:
a.append(l)
N,D = a[0].split(' ')
N = int(N)
D = float(D)
x = []
y = []
count = 0
dist = 0.0
for i in range(1,N):
x, y = a[i].split(' ')
x = int(x)
y = int(y)
dist = math.sqrt(x*x+y*y)
if dist <= D:
count = count + 1
print(count) |
p02602 | s920902255 | Accepted | n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(0,n-k):
if a[i]<a[i+k]:
print("Yes")
else:
print("No")
|
p02571 | s016608174 | Accepted | s = input()
t = input()
s = ''.join(s)
t = ''.join(t)
count = 0
maxcount = 0
slen = len(s)
tlen = len(t)
j = 0
while j <= slen-tlen:
k = j
for i in range(tlen):
if t[i] == s[k]:
count += 1
k+= 1
j += 1
if count > maxcount :
maxcount = count
count = 0
print(len(t)-maxcount) |
p03997 | s801291246 | Accepted | a=int(input())
b=int(input())
h=int(input())
print(((a+b)*h)//2)
|
p03773 | s068016447 | Wrong Answer | a, b = map(int, input().split())
if a + b> 24:
print(str(a + b - 24))
else:
print(str(a + b)) |
p03131 | s124970257 | Accepted | K,A,B = map(int,input().split())
if B-A-2 <= 0:
print(K+1)
exit()
if K-1 < A:
print(K+1)
exit()
K -= (A-1)
num = K//2
nokori = K%2
#print(K,num,nokori)
ans = A+num*(B-A)+nokori
print(ans) |
p02772 | s262858355 | Accepted | n = int(input())
a = list(map(int, input().split()))
k = 0
for i in a:
if i % 2 == 0:
if i % 3 == 0 or i % 5 == 0:
pass
else:
k += 1
else:
pass
if k != 0:
print('DENIED')
else:
print('APPROVED') |
p02888 | s660471807 | Accepted | import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N):
for j in range(i+1, N):
query = L[i] + L[j]
res += bisect.bisect_left(L, query) - j - 1
print(res)
|
p03627 | s482599164 | Accepted | from collections import defaultdict
N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
ans = 0
for i in a:
d[i] += 1
ans1 = []
for v, c in d.items():
if c >= 2:
ans1.append(v)
ans1.sort(reverse=True)
if len(ans1) > 1:
ans = ans1[0] * ans1[1]
ans2 = []
for v, c in d.items():
if c >= 4:
ans2.append(v)
ans2.sort(reverse=True)
if len(ans2) > 0:
ans = max(ans, ans2[0] * ans2[0])
print(ans) |
p03986 | s216833165 | Accepted | s=t=0
for i in input():
if i=="S":
s+=1
elif s>0:s-=1
else:t+=1
print(s+t) |
p04043 | s266962230 | Accepted | A, B, C = map(int, input().split())
if A + B + C == 17 and max(A, B, C) == 7 and min(A, B, C) == 5:
print('YES')
else:
print('NO') |
p02613 | s746056103 | Wrong Answer | N=int(input())
a=0
w=0
t=0
r=0
for i in range(N):
s=input()
if s=="AC":
a+=1
elif s=="WA":
w+=1
elif s=="TLE":
t+=1
elif s=="RE":
r+=1
print("AC ×",a)
print("WA ×",w)
print("TLE ×",t)
print("RE ×",r) |
p03286 | s253696032 | Accepted | n = int(input())
if n == 0:
print(0)
exit()
ans = []
while abs(n) > 0:
ans.append(n%2)
n = (n - (n % 2)) // -2
print(''.join(map(str, ans[::-1])))
|
p03067 | s726988402 | Accepted | A, B, C = map(int,input().split())
print('Yes' if A<C<B or A>C>B else 'No') |
p03778 | s841163161 | Wrong Answer | w,a,b = map(int,input().split())
print(max(b-(a+w),w-b)) |
p03379 | s758960185 | Accepted | #!/usr/bin/env python3
import numpy as np
n = int(input())
x = list(map(int, input().split()))
median = np.median(x)
x_sorted = sorted(x)
index = len(x)//2-1
for i in x:
if i == median:
print(i)
elif i < median:
print(x_sorted[index+1])
else:
print(x_sorted[index])
|
p03625 | s344336736 | Accepted | from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
c = defaultdict(int)
for x in a:
c[x] += 1
sq = False
top, sec = 0,0
for k,v in c.items():
if v < 2:
continue
if k > top:
sq = v >= 4
sec = top
top = k
elif k > sec:
sec = k
if sq:
print(top * top)
else:
print(top * sec) |
p02608 | s133968835 | Accepted | n = int(input())
a = [0 for i in range(n)]
for z in range(1, int(n**0.5+1)):
for y in range(1, int(n**0.5+1)):
for x in range(1, int(n**0.5+1)):
i = x*x + y*y + z*z + x*y + y*z + x*z
if i <= n: a[i-1] += 1
for i in range(n):
print(a[i])
|
p03371 | s844517507 | Accepted | a,b,c,x,y=map(int,input().split())
minpr=10e+10
memo=None
if x>=y:
for i in range(x+1):
price= i*a+ 2*(x-i)*c+ max(0,y-(x-i))*b
minpr=min(price,minpr)
print(minpr)
else:
for i in range(y+1):
price= i*b+ 2*(y-i)*c+ max(0,x-(y-i))*a
minpr=min(price,minpr)
print(minpr) |
p03243 | s706001130 | Accepted | n=int(input())
while True:
if list(str(n))[0]==list(str(n))[1]==list(str(n))[2]:
break
n+=1
print(n) |
p03327 | s971345986 | Accepted | if int(input()) >=1000:
print("ABD")
else:
print("ABC") |
p03433 | s923229406 | Accepted | a,b = (int(input()) for _ in range(2))
print("Yes" if a%500<=b else "No") |
p02947 | s280137159 | Accepted | from collections import Counter
import math
n = int(input())
res = 0
all = []
for i in range(n):
s = input()
sor = sorted(s)
all.append("".join(sor))
counter = dict(Counter(all))
for i in counter.values():
if i > 1:
res += math.factorial(i)/(2*math.factorial(i-2))
print(int(res)) |
p03679 | s934393457 | Wrong Answer | x, a, b = map(int, input().split())
if a-b > 0:
print("delicious")
if a-b < 0:
if b-a < x:
print('safe')
if b > x+a:
print("dangerous")
|
p03479 | s928319528 | Wrong Answer | def Multiple_Gift(x , y):
ans = 1
while x < y:
if x * 2 < y:
ans += 1
x = x * 2
return ans
def main():
x , y = map(int , input().split())
print(Multiple_Gift(x , y))
if __name__ == '__main__':
main()
|
p03852 | s461765002 | Accepted | import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
def resolve():
c = input()
L = list("aiueo")
print("vowel" if c in L else "consonant")
if __name__ == '__main__':
resolve()
|
p02621 | s446538430 | Accepted | a = int(input())
ans = a + a ** 2 + a ** 3
print(ans) |
p02787 | s740695115 | Accepted | h,n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 18
dp = [10 ** 18] * (h+1)
dp[0] = 0
for i in range(h):
for a,b in ab:
c = min(h,i+a)
dp[c] = min(dp[c],dp[i]+b)
ans = dp[h]
print(ans) |
p02814 | s424687636 | Wrong Answer | import numpy as np
from fractions import gcd
from functools import reduce
from math import floor
N ,M = map(int, input().split())
A = list(set(list(map(int, input().split()))))
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
lcm = lcm_list(A)
least_lcm = lcm // 2
print(max(floor( (M - least_lcm) // lcm + 1), 0))
|
p04031 | s810346427 | Accepted | n=int(input())
a=[]
a=list(map(int,input().split()))
ave=sum(a)/n
if ave<int(ave)+0.5:
ave=int(ave)
else:
ave=int(ave)+1
ans=0
for i in range(n):
ans+=(a[i]-ave)**2
print(ans) |
p03698 | s032261920 | Accepted | import sys
input = sys.stdin.readline
def main():
ans = 'no'
s = input()
if len(s) == len(set(s)):
ans = 'yes'
print(ans)
if __name__ == '__main__':
main() |
p03067 | s568308822 | Accepted | a,b,c = map(int,input().split())
print("Yes") if a<c<b or a>c>b else print("No") |
p02866 | s532478854 | Accepted | def main():
import sys
n,*d=map(int,sys.stdin.buffer.read().split())
e=[0]*n
for i in d:e[i]+=1
a=1if d[0]<1else 0
for i in d[1:]:a=a*e[i-1]%998244353
print(a)
main() |
p03774 | s965151368 | Accepted | import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,M = LI()
ab = np.array([LI() for _ in range(N)])
cd = np.array([LI() for _ in range(M)])
for x in ab:
vector = np.sum(np.abs(cd-x),axis=1).tolist()
print(vector.index(min(vector))+1)
|
p03043 | s741282214 | Wrong Answer | from math import log2,ceil
def main():
N,K = map(int,input().split())
ans = 0
for i in range(1,N + 1):
digit = ceil(log2(K) - log2(i))
ans += (1/N)*0.5**digit
print(ans)
return
if __name__ == "__main__":
main() |
p02702 | s340973928 | Accepted | M=2019
a=i=0
d=[1]+[0]*M
p=1
for j in input()[::-1]:i=(i+int(j)*p)%M;a+=d[i];d[i]+=1;p=p*10%M
print(a) |
p02789 | s184287494 | Wrong Answer | a = input()
a.split(" ")
if a[0] == a[1]:
print("yes")
else:
print("no") |
p03126 | s263557196 | Wrong Answer | a, b = map(int, input().split())
if (b % a == 0):
print(b + a)
else:
print(b - a) |
p02584 | s472001888 | Accepted | x,k,d = map(int, input().split())
x = abs(x)
a= x//d
b = x%d
if a>=k:
print(x-k*d)
exit(0)
c = abs(b-d)
if (k-a)%2==0:
print(b)
else:
print(c) |
p03284 | s052803767 | Accepted | import math
n,k=map(int,input().split())
if n%k==0:
print(0)
else:
max=math.floor(7/3)
min=7%3
print(max-min) |
p02624 | s662832930 | Accepted | import sys
def input():
return sys.stdin.readline().rstrip('\n')
def calc(N):
ans = 0
for i in range(1, N + 1):
k = N // i
ans += i * k * (k + 1) // 2
return ans
N = int(input())
print(calc(N)) |
p03136 | s792229376 | Accepted | n =int(input())
l =list(map(int ,input().split()))
if sum(l)- max(l) >max(l):
print("Yes")
else:
print("No") |
p02777 | s665444826 | Accepted | S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()
if S==U: A -= 1
if T==U: B -= 1
print(str(A) + " " + str(B)) |
p02995 | s523986488 | Wrong Answer | import math
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])
c_count = (b//c)-((a-1)//c)
d_count = (b//d)-((a-1)//d)
print(c_count)
print(d_count) |
p03163 | s658666039 | Accepted | n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [0] * (w+1)
for wi, vi in wv:
for sum_w in reversed(range(wi, w+1)):
dp[sum_w] = max(dp[sum_w], dp[sum_w - wi] + vi)
print(dp[w])
|
p02971 | s570907134 | Accepted | n=int(input())
a=[]
for i in range(n):
a.append(int(input()))
m=max(a)
b=sorted(a)
m2=b[-2]
for i in range(n):
if a[i]==m:
print(m2)
else:
print(m)
|
p02697 | s745889601 | Wrong Answer | n,m=map(int, input().split())
num=0
l=[]
if n%2==0:
num=n//m
else:
num=(n//m)+1
for i in range(m):
l.append(num)
num=num-1
l.reverse()
for i in l:
print(i,end=" ")
print(n-i) |
p02684 | s904852496 | Wrong Answer | from math import log2
n, k = map(int, input().split())
To = []
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A))
To.append(A)
for i in range(int(log2(k))):
N = [0 for i in range(n)]
for j in range(n):
N[j] = To[i][To[i][j]]
To.append(N)
v = 0
for i in reversed(range(int(log2(k)) + 1)):
l = 1 << i
print(i)
if l <= k:
v = To[i][v]
k -= l
else:
pass
print(v + 1) |
p02546 | s443855965 | Accepted | n=input()
if n[len(n)-1] == "s":
print (n+"es")
else:
print (n+"s")
|
p03544 | s604087753 | Accepted | N = int(input())
memo = {}
def luca(N):
if N in memo:
return memo[N]
else:
memo[N] = 0
if N == 0:
memo[N] = 2
return 2
if N == 1:
memo[N] = 1
return 1
memo[N] = luca(N-1) + luca(N-2)
return memo[N]
print(luca(N)) |
p03705 | s489828481 | Wrong Answer | N, A, B = map(int, input().split())
if N==1 and A==B:
ans = 1
elif N==1:
ans = 0
elif A > B:
ans = 0
else:
ans = (B-A) * (N-2) + 1 |
p03059 | s249350484 | Accepted | a, b, t = map(int, input().split())
the_number_of_times = (t + 0.5) // a
the_number_of_biscuits = int(b * the_number_of_times)
print(the_number_of_biscuits) |
p02596 | s335599839 | Accepted | import sys
input = sys.stdin.readline
def main():
K = int(input())
if K%2==0 or K%5==0:
print(-1)
return
if K % 7:
L = 9*K
else:
L = 9*K//7
a = 1
for i in range(1,K+10):
a = (a * 10) % L
if a == 1:
print(i)
return
print(-1)
main()
|
p02765 | s886212504 | Accepted | n,r=map(int,input().split())
if n>=10:
print(r)
else:
print(r+(100*(10-n)))
|
p03774 | s800298185 | Accepted | N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]
closest = {}
for s in student:
min_dist = 'INF'
ans = 1
for c in checkpoint:
dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
if min_dist == 'INF' or dist < min_dist:
min_dist = dist
closest[s] = ans
ans += 1
for s in student:
print(closest[s])
|
p03659 | s705090696 | 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()))
n=int(input())
a=lmp()
sa=0
sb=sum(a)
ans=float("inf")
for i in range(n-1):
sa+=a[i]
sb-=a[i]
ans=min(ans,abs(sa-sb))
print(ans) |
p02645 | s016958433 | Wrong Answer | S=input()
print("S"[0:2]) |
p02621 | s562302065 | Accepted | a=int(input())
print(a+(a*a)+(a*a*a)) |
p03943 | s718498273 | Accepted | a=list(map(int,input().split()))
a=sorted(a)
if a[0]+a[1]==a[2]:
print("Yes")
else:
print("No") |
p02972 | s992929394 | Accepted | import math
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
c = 0
s = [0]*(n+1)
for i in reversed(range(1,n+1)):
for k in range(1,math.floor(n/i)+1):
j = int(k*i)
s[i] += b[j-1]
if s[i]%2 != a[i-1]:
b[i-1] += 1
c += 1
print(c)
L = [i+1 for i in range(n) if b[i] == 1]
print(*L) |
p03281 | s316393587 | Accepted | def main():
N = int(input())
num = 0
for i in range(1, N + 1):
if i % 2 == 1:
count = 0
for j in range(1, N + 1):
if i % j == 0:
count += 1
if count == 8:
num += 1
print(num)
main() |
p02835 | s239113247 | Accepted | A=list(map(int,input().split()))
B=0
B=A[0]+A[1]+A[2]
if B>=22:
print("bust")
else:
print("win")
|
p03416 | s494632129 | Accepted | a, b = map(int, input().split())
cnt = 0
for i in range(a, b+1):
tmp = str(i)
if tmp == tmp[::-1]:
cnt += 1
print(cnt) |
p02771 | s033219445 | Accepted | number = input().split(" ")
ans = set(number)
if len(ans) == 2:
print("Yes")
else:
print("No") |
p02707 | s976620463 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
p = 0
for i in list(set(a)):
ans = a.count(i)
print(ans)
a = [s for s in a if s != i]
p = p + ans
if p == n-1:
break
for s in range (n-i):
print(0) |
p03261 | s470995982 | Accepted | n = int(input())
W = [input() for i in range(n)]
flg = 1
Word = [W[0]]
for i in range(1,n):
s = W[i-1]
t = W[i]
if(s[-1] != t[0] or t in Word):
flg = 0
break
Word.append(t)
if (flg): print("Yes")
else: print("No")
|
p02831 | s889632160 | Wrong Answer | a,b=sorted(map(int,input().split()))
#ユークリッドの互除法
def gcd(a,b):
if b==0:
return a
#余りが0になったら最後の割る数を出力=lcm
else:
return (gcd(b,a%b))
print(a*b/gcd(a,b))
#ユークリッドの互除法) |
p02755 | s916211700 | Accepted | import math
if __name__ == '__main__':
a, b = list(map(int, input().split(" ")))
for i in range(1, 1500):
# print(i)
if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
print(i)
exit()
print(-1) |
p03711 | s865845985 | Accepted | x,y = map(int,input().split())
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
if x in g1 and y in g1:
print('Yes')
elif x in g2 and y in g2:
print('Yes')
elif x in g3 and y in g3:
print('Yes')
else:
print('No') |
p03013 | s222274287 | Accepted | import sys
n,m=map(int,input().split())
if m != 0:
a=set(map(int,sys.stdin.read().split()))
else:
a=set()
modx=10**9+7
dp=[0]*(n+10)
dp[0]=1
for i in range(n+1):
if i+1 not in a:
dp[i+1]= (dp[i]+dp[i+1]) % modx
if i+2 not in a:
dp[i+2]= (dp[i]+dp[i+2]) % modx
print(dp[n]) |
p03633 | s174096978 | Wrong Answer | from fractions import gcd
def lcm(x,y):
return (x*y)//gcd(x,y)
n=int(input())
t=[int(input()) for i in range(n)]
ans=0
if n==1:
print(t[0])
exit()
for i in range(n-1):
tt=lcm(t[i],t[i+1])
ans=max(ans,tt)
print(ans)
|
p03860 | s331373553 | Accepted | a, b, c = list(input().split())
s = a[0] + b[0] + c[0]
ans = s.upper()
print(ans)
|
p02744 | s021527769 | Wrong Answer | import itertools
def resolve():
n = int(input())
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
init = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
print(''.join(init[0:n]))
for str in itertools.combinations_with_replacement(l[0:n], n):
if len(list(set(str))) != 1:
print(''.join(str))
resolve() |
p03657 | s046705099 | Accepted | a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print('Possible')
else:
print('Impossible') |
p02584 | s547862806 | Wrong Answer | # coding: utf-8
# Your code here!
X,K,D=map(int,input().split())
move=min(X//D,K)
ans=X-move*D
if move==K:
print(ans)
else:
if (K-move)%2==0:
print(ans)
else:
print(abs(ans-D)) |
p03637 | s937166697 | Accepted | import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in range(n):
if a[i]%4 == 0:
n4+=1
elif a[i]%2 == 0:
n2 +=1
else:
n1+=1
if n2 == 1:
n2 = 0
if n4*2 + n2 >= n or n4*2 + 1 == n:
print("Yes")
else:
print("No") |
p03475 | s611786714 | Accepted | N = int(input())
li = []
for i in range(N-1):
c, s, f = map(int, input().split())
li.append((c,s,f))
for i in range(N-1):
t = 0
for j in range(i, N-1):
t = max(li[j][1], t)
t += (li[j][2] - t)%li[j][2]
t += li[j][0]
print(t)
print(0) |
p02678 | s782384881 | Wrong Answer | print('No') |
p02795 | s177225581 | Accepted | h = int(input().rstrip())
w = int(input().rstrip())
n = int(input().rstrip())
if h > w:
div = h
else:
div = w
if n % div > 0:
ans = int(n / div) + 1
else:
ans = int(n / div)
print(ans) |
p02953 | s654011433 | Accepted | N = int(input())
H = [int(i) for i in input().split()]
is_true = True
before_tmp = 1
for i in range(N - 1):
# 差分を計算
tmp = H[i + 1] - H[i]
if tmp < 0 and (tmp <= -2 or before_tmp <= -1):
is_true = False
break
# 0の場合は飛ばす
if tmp != 0:
before_tmp = tmp
if is_true:
print('Yes')
else:
print('No')
|
p02548 | s643979826 | Accepted | from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18
n=int(input())
cnt=0
for i in range(1,n+1):
wk=n//i
if n%i==0:
wk-=1
cnt+=wk
print(cnt) |
p02995 | s526154712 | Accepted | from math import gcd
A, B, C, D = map(int, input().split())
if C == 1 or D == 1:
print(0)
exit()
def check(A, B, x):
return B//x - (A-1)//x
print((B - A + 1) - (check(A, B, C) + check(A, B, D) - check(A, B, C*D//gcd(C, D))) )
|
p02917 | s419100689 | Accepted | n = int(input())
b = list(map(int,input().split()))
a = []
a.append(b[0])
for i in range(n-1):
if i==n-2:
a.append(b[i])
else:
if b[i]<b[i+1]:
a.append(b[i])
else:
a.append(b[i+1])
print(sum(a)) |
p02658 | s604132598 | Wrong Answer | N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
ans *= a
if ans > 10**18:
print(-1)
break
else:
print(ans) |
p03317 | s956371915 | Accepted | def main():
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for x in range(1, N+1):
if (K-1)*x + 1 >= N:
ans = x
break
print(ans)
main() |
p03612 | s772160490 | Wrong Answer | N = int(input())
P = list(map(int, input().split()))
ans = 0
cnt = 0
f = 0
for i, v in enumerate(P):
if not f:
if i+1 == v:
f = 1
else:
cnt += 1
if i+1 == v:
ans += cnt
f = 0
cnt = 0
# print(f"i{i} v{v} ans{ans} cnt{cnt} f{f}")
print(ans + f) |
p02785 | s103314526 | Accepted | import math
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))
H = sorted(H,reverse=True)
print(sum(H[K:])) |
p03730 | s584701484 | Accepted | import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from fractions import gcd
def main():
mod=10**9+7
a,b,c=MI()
d=gcd(a,b)
if c%d==0:
print("YES")
else:
print("NO")
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.