problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p03352 | s375310738 | Wrong Answer | from bisect import bisect_right
a = int(input())
dp = [1]
t = 1
while t**2<=10000:
dp.append(t**2)
t+=1
if dp[-1]>=a:
print(dp[-2])
exit()
print(dp[bisect_right(dp,a)-1])
|
p02909 | s938793540 | Accepted | # -*- coding: utf-8 -*-
# A
import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline
# εθ΅·εζ°δΈιε€ζ΄
# sys.setrecursionlimit(1000000)
s = input()[:-1]
if s == 'Sunny':
print('Cloudy')
elif s == 'Cloudy':
print('Rainy')
else:
print('Sunny')
|
p03012 | s459366659 | Wrong Answer | n=int(input())
w=[int(i) for i in input().split()]
s=sum(w)
#print(s)
s2=0
for i in range(n):
s2+=w[i]
if s2>=s//2:
break
print(abs((s-s2)-s2))
|
p02996 | s376277065 | Accepted | from sys import stdin
from collections import deque
N=list(map(int,stdin.readline().strip().split()))[0]
t=0
data = [list(map(int,stdin.readline().rstrip().split())) for _ in range(N)]
data=sorted(data,key=lambda x:(x[1]))
d=deque(data)
while(len(d)!=0):
A,B=d.popleft()
if B>=t+A:
t+=A
else:
print("No")
exit()
print("Yes")
|
p03545 | s354857404 | Accepted | ABCD = input()
res = 0
for i in range(1 << 3):
l = []
for j in range(3):
if i >> j & 1 == 1:
l.append(ABCD[j])
l.append("+")
else:
l.append(ABCD[j])
l.append("-")
l.append(ABCD[-1])
l = ''.join(l)
res = eval(l)
if res == 7:
print(l + "=7")
exit() |
p02909 | s071782962 | Accepted | S = input()
l = ['Sunny', 'Cloudy', 'Rainy']
index = l.index(S)
print(l[(index + 1) % 3])
|
p02814 | s278776273 | Wrong Answer | import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = 1
flag = 0
for i in range(N):
gcd = fractions.gcd(A[i] // 2, lcm_half)
lcm_half = (lcm_half * (A[i]) // 2) // gcd
if lcm_half > M:
flag = 1
break
if flag == 1:
ans = 0
else:
M -= lcm_half
ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)
|
p03351 | s180971177 | Wrong Answer | def main():
a, b, c, d = map(int, input().split())
if abs(a-b) <= d:
print("Yes")
elif abs(a-c) <= d or abs(b-c) <= d:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
|
p02548 | s978020680 | Accepted | import math
N = int(input())
def num_divisors_table(n):
table = [0] * (n + 1)
for i in range(1, n + 1):
for j in range(i, n + 1, i):
table[j] += 1
return table
print(sum(num_divisors_table(N-1))) |
p02621 | s296029729 | Wrong Answer | num = int(input())
ans = 0
def divisor(n):
i = 1
table = []
while i * i <= n:
if n%i == 0:
table.append(i)
table.append(n//i)
i += 1
table = list(set(table))
return table
yaku_list = [len(divisor(i)) for i in range(1,num+1)]
for i,j in enumerate(yaku_list):
ans += int(i+1) * int(j)
print(ans) |
p02859 | s749096329 | Accepted | print(int(input())**2) |
p02607 | s568764390 | Accepted | n=int(input())
c=list(map(int, input().split()))
c = [0] + c
ans = 0
for i in range(1,n+1):
if i%2 == 1 and c[i]%2 ==1:
ans += 1
print(ans)
|
p03359 | s572669978 | Accepted | a,b=map(int,input().split())
if b>=a:
print(a)
else:
print(a-1) |
p03637 | s739390660 | Wrong Answer | N = int(input())
l = list(map(int,input().split()))
num_odd = 0
num_even = 0
num_four = 0
for i in l:
if i % 4 == 0:
num_four += 1
elif i % 2 == 0:
num_even += 1
else:
num_odd += 1
if num_four <= 2 * num_odd:
ans = "No"
else:
ans = "Yes"
print(ans)
|
p03760 | s552432505 | Accepted | o=list(input())
e=list(input())+[""]
for x,y in zip(o,e):print(x+y,end="")
|
p02802 | s279980873 | Accepted | N, M = map(int, input().split())
ac_chk = [0]*(N+1)
wa_chk = [0]*(N+1)
wa = 0
ac = 0
for i in range(M):
p, S = input().split()
p = int(p)
if ac_chk[p] == 0:
if S == "AC":
ac_chk[p] = 1
ac += 1
wa += wa_chk[p]
continue
if S == "WA":
wa_chk[p] += 1
continue
else:
continue
print(ac, wa) |
p03804 | s673582642 | Accepted | N, M = map(int, input().split())
A = []
B = []
for i in range(N):
A.append(input())
for i in range(M):
B.append(input())
f = 0
for i in range(N - M + 1):
for j in range(N - M + 1):
g = 0
for k in range(M):
for l in range(M):
if A[i+k][j+l] != B[k][l]:
g = 1
break
if g == 1:
break
if g == 0:
print("Yes")
f = 1
break
if f == 1:
break
if f == 0:
print("No") |
p02578 | s957687434 | Accepted | N = int(input())
people = [int(i) for i in input().split()]
step = 0
front = people[0]
for i in range(N):
if front > people[i]:
step += front - people[i]
else:
front = people[i]
print(step) |
p03145 | s388105722 | Accepted | a,b,c = map(int,input().split())
print(int(a*b/2)) |
p03210 | s663549072 | Wrong Answer | n = int(input())
if n == 7 or n == 5 or n == 3:
print('Yes')
else:
print('No')
|
p02713 | s347928605 | Accepted | import math
import fractions
K = int(input())
sum = 0
def gcd2(x,y,z):
return math.gcd(math.gcd(x,y),z)
for i in range(1,K+1):
for j in range(i,K+1):
for k in range(j,K+1):
if (i == j == k):
sum += gcd2(i,j,k)
elif i != j and j != k:
sum += gcd2(i,j,k)*6
else:
sum += gcd2(i,j,k)*3
print(sum)
|
p02882 | s597898494 | Accepted | import math
a, b, x = [int(_) for _ in input().split()]
h = x / a / a
if a * b / 2 < a * h:
theta = math.atan(2 * (b - h) / a)
else:
theta = math.atan(b * b / a / h / 2)
ans = math.degrees(theta)
print(ans)
|
p02747 | s178637565 | Accepted | s = list(input())
if s[::2].count('h') == len(s[::2]) and s[1::2].count('i') == len(s[1::2]) and len(s)%2 == 0:
print('Yes')
else:
print('No') |
p02848 | s218555967 | Accepted | n,s=int(input()),input()
ans=""
for ss in s:
if ord(ss)+n > 90:
ans+=chr(ord(ss)+n-26)
else:
ans+=chr(ord(ss)+n)
print(ans) |
p03817 | s234202535 | Wrong Answer | import sys
read_=sys.stdin.buffer.readline
x=int(read_())
print(int(-(-x/11*2//1))) |
p02622 | s136177400 | Wrong Answer | S=input()
T=input()
if S==T:
print('0')
elif S!=T:
STand = set(S) & set(T)
STlist = list(STand )
print(len(STlist)) |
p03645 | s595068764 | Accepted | N, M = [int(x) for x in input().split(" ")]
next_to_1 = []
next_to_last = []
for i in range(M):
tmp = input().split(" ")
if int(tmp[0]) == 1:
next_to_1.append(int(tmp[1]))
if int(tmp[1]) == N:
next_to_last.append(int(tmp[0]))
if len(list(set(next_to_1) & set(next_to_last))) > 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
p02952 | s855229495 | Wrong Answer | n = int(input())
s = len(str(n))
if s == 1:
print(n)
elif s == 2:
print(9)
elif s == 3:
print(n-90)
elif s == 4:
print(9+900)
elif s == 5:
print(9+900+n-1000+1)
else:
print(90909)
|
p03324 | s647965998 | Accepted | def read_ints():
return[int(i) for i in input().split()]
def main():
d, n = read_ints()
print(101 * (100**d) if n == 100 else (100**d)*n)
if __name__ == '__main__':
main() |
p02862 | s851175577 | Wrong Answer | def gho1(x):
g=1
for i in range(1,x+1):
g*=i
return g
def gho2(x):
g=1
for i in range(1,x+1):
g*=i;g=g%(10**9+7)
return g
q,w=map(int,input().split())
e,d=divmod((2*w-q),3)
r,f=divmod((2*q-w),3)
if d!=0 or f!=0:print(0)
else:
print((gho2(e+r)//(gho2(e)*gho2(r)))%(10**9+7))
|
p03693 | s011572449 | Wrong Answer | print("YENOS"[int(input()[::2])%4>0::2]) |
p02881 | s735552747 | Wrong Answer | N = int(input())
ans = []
for i in range(1,10**6):
if N%i == 0:
j = N//i
ans.append(i+j-2)
else:
continue
print(min(ans)) |
p03371 | s148100657 | Accepted | a,b,c,x,y = map(int, input().split())
ab = min(a+b,2*c)
a = min(a,2*c)
b = min(b,2*c)
print((x-y)*a+y*ab if x>y else (y-x)*b+x*ab) |
p03077 | s476905594 | Accepted | n=int(input())
a=[int(input()) for i in range(5)]
m=min(a)
k=(n+m-1)//m
print(5+k-1) |
p02772 | s216407402 | Accepted | _=int(input())
a=list(map(int,input().split()))
bool=True
for i in a:
if i%2==0:
if i%3==0 or i%5==0:
pass
else:
bool=False
if bool:
print("APPROVED")
else:
print("DENIED")
|
p02747 | s928543464 | Accepted | # -*- coding: utf-8 -*-
import math
import itertools
import sys
import copy
#import numpy as np
# ε
₯ε
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
S = str(input())
if len(S)%2 == 1 :
print ("No")
exit()
else :
c = len(S)//2
st = ""
for _ in range(c) :
st += "hi"
if S == st :
print ("Yes")
else :
print ("No")
|
p02861 | s568406665 | Accepted | N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
print(2/N*sum([sum([(l-m)**2for l,m in zip(X[i],X[j])])**0.5for j in range(N) for i in range(N) if i<j ])) |
p02947 | s035168549 | Accepted | import sys
from collections import Counter
M = {}
N = int(input())
ans = 0
for _ in range(N):
S = input()
S = ''.join(sorted(S))
if S not in M:
M[S] = 1
else:
ans += M[S]
M[S] += 1
print(ans) |
p03592 | s118393547 | Wrong Answer | import sys
def solve():
input = sys.stdin.readline
N, M, K = map(int, input().split())
possible = False
for i in range(N + 1):
for j in range(M + 1):
black = (N - i) * M + N * (M - j)
if black == K:
print("Yes")
possible = True
break
if possible: break
else: print("No")
return 0
if __name__ == "__main__":
solve() |
p02640 | s520231825 | Accepted | x, y = list(map(int, input().split(" ")))
tmp = False
for i in range(0, x+1):
if i * 2 + (x-i) * 4 == y:
tmp = True
break
if tmp:
print("Yes")
else:
print("No") |
p02717 | s470310802 | Accepted | x, y, z = input().split()
lis = [z, x, y]
print(" ".join(lis)) |
p02811 | s663275130 | Accepted | K,X=list(map(int,input().split()))
if 500*K>=X:
print('Yes')
else:
print('No') |
p03699 | s091741320 | Accepted | import sys
N = int(input())
S = []
for _ in range(N):
S.append(int(input()))
S.sort()
ans = sum(S)
if ans % 10 != 0:
print(ans)
sys.exit()
for i in S:
if i % 10 != 0:
ans -= i
print(ans)
sys.exit()
print(0) |
p02777 | s233367481 | Wrong Answer | s,t = (i for i in input().split())
a,b = (int(i) for i in input().split())
u = input()
set = {s:a, t:b}
if u == s: set[s] -= 1
else: set[t] -= 1
for i in set.values(): print(i,end=" ")
print() |
p03042 | s222371214 | Wrong Answer | s = input()
#s = list(s)
mae = int(s[:2])
usi = int(s[2:])
#print(mae,usi)
if(mae >= 0 and mae <= 99 or usi >= 1 and usi <= 12):
print("AMBIGUOUS")
elif(usi >= 0 and usi <= 99 or mae >= 1 and mae <= 12):
print("AMBIGUOUS")
elif(mae == 0 and usi == 0):
print("NA")
elif(mae == 0 and usi >= 12):
print("NA")
elif(mae >= 12 and usi == 0):
print("NA")
elif(mae >= 0 and mae <= 99 and usi >= 1 and usi <= 12):
print("YYMM")
elif(usi >= 0 and usi <= 99 and mae >= 1 and mae <= 12):
print("MMYY")
else:
print("AMBIGUOUS") |
p02777 | s215582694 | Accepted | s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())
if u == s:
a -= 1
else :
b -= 1
print (a, b) |
p03796 | s922530159 | Accepted | #B - Training Camp
N = int(input())
power = 1
for i in range(1,N+1):
power = (power*i)%(10**9+7)
print(power) |
p03475 | s067749845 | Wrong Answer | n = int(input())
L = [list(map(int, input().split())) for _ in range(n-1)]
for i in range(n-1):
t = 0
for j in range(i, n-1):
if t <= L[j][1]:
s = L[j][1]
else:
if t % L[j][1]:
s = t + L[j][2] - (t % L[j][1])
else:
s = t
t = s + L[j][0]
print(t)
print(0)
|
p03434 | s244075746 | Wrong Answer | # coding: UTF-8
N = int(input())
a = list(map(int, input().split()))
sum_a, sum_b = 0, 0
for i in reversed(range(1, N)):
for j in reversed(range(1, i+1)):
if a[j-1] < a[j]:
s = a[j-1]
a[j-1] = a[j]
a[j] = s
for i in range(0, N, 2):
sum_a += a[i]
for i in range(1, N, 2):
sum_b += a[i]
print(sum_a - sum_b) |
p02987 | s573910939 | Wrong Answer | S=str(input())
if S[0]==S[1] and S[2]==S[3]:
print('Yes')
elif S[0]==S[2] and S[1]==S[3]:
print('Yes')
elif S[0]==S[3] and S[1]==S[2]:
print('Yes')
else:
print('No') |
p03076 | s304149881 | Accepted | import itertools
t = []
for i in range(5):
t.append(int(input()))
candidates = []
for check in itertools.permutations(t):
t = 0
for i in range(4):
t+= -((-check[i])//10)*10
t+=check[-1]
candidates.append(t)
print(min(candidates)) |
p03761 | s712817610 | Accepted | import collections
n = int(input())
c = collections.Counter(input())
for _ in range(n-1):
sc = set(c.keys())
nc = collections.Counter(input())
snc = set(nc.keys())
inter = sc & snc
r = dict()
for i in inter:
r[i] = min(c[i], nc[i])
c = r
if len(c) == 0:
print('')
else:
l = []
for i in sorted(c.items(), key=lambda x: x[0]):
l.append(i[0]*i[1])
print(''.join(l)) |
p02690 | s993012325 | Accepted | X = int(input())
A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
for b in B:
ans = a**5 - b**5
if ans == X:
print("{} {}".format(a,b))
flag=1
break
if flag:
break |
p03385 | s234885697 | Accepted | S = str(input())
# S γ abc γδΈ¦γ³ζΏγγ¦δ½γγγ¨γγ§γγγͺγ Yes γγγγγ§γͺγγͺγ No γεΊεγγγ
abc = [S[0], S[1], S[2]]
if "a" in abc and "b" in abc and "c" in abc:
print("Yes")
else:
print("No") |
p03030 | s297572025 | Wrong Answer | from operator import itemgetter
n = int(input())
sp = []
for i in range(n):
s,p = input().split()
tmp = [s,100-int(p),i]
sp.append(tmp)
print(sp)
sp = sorted(sp,key = itemgetter(0,1))
print(sp)
for i in range(n):
print(sp[i][2]+1)
|
p02970 | s837953859 | Accepted | n,d = map(int,input().split())
i = 1+2*d
count = 1
while n>i:
i = i + 2*d + 1
count += 1
print(count) |
p02571 | s139346928 | Accepted | a = list(input())
b = list(input())
min_k = len(b)
for i in range(len(a)-len(b)+1):
c = a[i:i+len(b)]
count=0
for k,j in enumerate(c):
if b[k]==j:
count+=1
min_k = min(min_k,len(b)-count)
print(min_k) |
p02802 | s911926571 | Accepted | from collections import defaultdict
n, m = map(int, input().split())
ac_set = set()
wa_dic = defaultdict(int)
wa_cnt = 0
for i in range(m):
p, s = input().split()
if s == 'AC':
ac_set.add(p)
else:
if p not in ac_set:
wa_dic[p] += 1
print(len(ac_set), sum(value for key, value in wa_dic.items() if key in ac_set)) |
p03086 | s365943292 | Accepted | s = input()
max = 0
tmp = 0
for c in s:
if c in ['A', 'C', 'G', 'T']:
tmp += 1
if tmp > max:
max = tmp
else:
tmp = 0
print(max)
|
p02725 | s326519229 | Wrong Answer | k, n = map(int, input().split())
a = list(map(int, input().split()))
ans1 = a[n - 1] - a[0]
ans2 = 0
flag = 0
for i in range(n):
if a[i] <= (k / 2):
continue
else:
if flag == 0:
ans2 += a[i - 1]
flag = 1
ans2 += (k - a[i])
print(min(ans1, ans2)) |
p02612 | s484393189 | Accepted | print((1000-int(input())%1000)%1000) |
p03071 | s899946851 | Accepted | A,B = (int(X) for X in input().split())
print(max(2*A-1,2*B-1,A+B)) |
p02682 | s054460462 | Accepted | a,b,c,k = map(int,input().split())
print(min(a,k)-min(max(k-a-b,0),c)) |
p02836 | s962932372 | Accepted | a = input()
A = len(a)
b = a[::-1]
b = b[:len(a)//2]
a = a[:len(a)//2]
res = 0
for i in range(A//2):
if a[i] != b[i]:res+=1
print(res) |
p03475 | s041353126 | Wrong Answer | N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
c, s, f = map(int, input().split())
for j in range(i+1):
if A[j] < s:
A[j] = s + c
else:
d = - (s - A[j]) // f + 1
A[j] = s + f * d + c
for i in range(N):
print(A[i]) |
p03457 | s041546401 | Accepted | n = int(input())
lst = [(0,0,0)]
for i in range(n):
t,x,y = map(int, input().split())
lst.append((t,x,y))
for i in range(n):
T,X,Y = lst[i+1][0]-lst[i][0],abs(lst[i][1]-lst[i+1][1]),abs(lst[i][2]-lst[i+1][2])
if X+Y>T or (X+Y-T)%2!=0:
print("No")
exit()
print("Yes")
|
p03486 | s921685183 | Accepted | s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
s = ''.join(s)
t = ''.join(t)
if s < t:
print('Yes')
else:
print('No')
|
p02983 | s243389757 | Wrong Answer | L, R = [int(i) for i in input().split()]
diff = R - L
ans = 2019
if diff == 1:
x = (L * (L + 1)) % 2019
print(min(x, ans))
else:
for i in range(diff):
for j in range(i + 1, diff):
x = ((L + i) * (L + j)) % 2019
ans = min(x, ans)
if x == 0:
break
print(ans)
|
p03427 | s010391508 | Accepted | N = list(map(str, input().rstrip()))
print(max(sum([int(i) for i in N]), 9*(len(N)-1)+int(N[0])-1))
|
p02700 | s991148910 | Wrong Answer | A, B, C, D = map(int, input().split())
print('Yes' if C / B < A / D else 'No') |
p03796 | s772501520 | Accepted | x,y=1,10**9+7
for i in range(1,int(input())+1):x=x*i%y
print(x) |
p02924 | s608210191 | Accepted | import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def main():
N = int(input())
ans = 0
if N==1:
ans = 0
else:
ans = (N-1) * N//2
print(ans)
if __name__ == '__main__':
main() |
p02660 | s217701957 | Accepted | import math
N = int(input())
if N == 1:
print(0)
exit()
div = {}
for i in range(2, int(math.sqrt(N))+1):
while N % i == 0:
N = N // i
if i in div:
div[i] += 1
else:
div[i] = 1
if N == 1:
break
if N != 1:
div[N] = 1
ans = 0
for v in div.values():
i = 1
while v >= i:
v -= i
i += 1
ans += 1
print(ans)
|
p03419 | s530793426 | Accepted | n, m = (map(int, input().split()))
print(abs((n-2) * (m-2)))
|
p03069 | s662802962 | Accepted | ans=n=int(input())
s=input()
a=[0]
for i in s:
if i==".":
a+=[a[-1]+1]
else:
a+=[a[-1]]
w=s.count(".")
for i in range(n+1):
ans=min(ans,i-a[i]+w-a[i])
print(ans) |
p02553 | s833800670 | Accepted | a,b,c,d = map(int,input().split())
if(a > 0 and b > 0):
if(c <= 0 and d <= 0):
print(a * d)
exit()
if(c > 0 and d > 0):
if(a <= 0 and b <= 0):
print(c * b)
exit()
print(max(a * c, b * d)) |
p03696 | s901187219 | Wrong Answer | # coding: utf-8
N=int(input())
S=list(input())
c=0
L=[0]*N
L[0]=1 if S[0]=='(' else -1
for i in range(1,N):
if S[i]=='(':
L[i]=L[i-1]+1
else:
L[i]=L[i-1]-1
if L[N-1]<0:
S.insert(0,'('*abs(L[N-1]))
elif L[N-1]>0:
S.append(')'*L[N-1])
print(''.join(S)) |
p02727 | s822107751 | Wrong Answer | X, Y, A, B, C = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
Z = 0
while Z < C:
if min(p[X - 1], q[Y - 1]) < r[Z]:
if p[X - 1] < q[Y - 1]:
X -= 1
Z += 1
else:
Y -= 1
Z += 1
continue
break
print(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z])) |
p02548 | s949871110 | Wrong Answer | from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
########################################################
F=[1]*(10**6+1)
for i in range(2,10**6+1):
for j in range(i,10**6+1,i):
F[j]+=1
ans=0
n=1000000
for c in range(1,n):
ans+=F[n-c]
print(ans)
|
p03250 | s899569741 | Wrong Answer | A, B, C = list(map(int, input().split(" ")))
print(int(str(B)+str(C)) + A) |
p02748 | s624597673 | Accepted | a,b,m = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
can = [min(x)+min(y)]
for _ in range(m):
i,j,c = map(int,input().split())
i -= 1
j -= 1
can.append(x[i]+y[j]-c)
print(min(can)) |
p03796 | s340240489 | Wrong Answer |
def main():
N = int(input())
res = 1
for i in range(1, N+1):
res = res * i
print(res%100000007)
if __name__ == "__main__":
main() |
p03012 | s482284975 | Wrong Answer | mn=0
n=int(input())
li=list(map(int,input().split()))
for i in range(n):
res=abs(sum(li[:i])-sum(li[i:]))
if res<mn:
mn=res
print(mn) |
p03556 | s941975006 | Accepted | n = int(input())
print(int(n**0.5)**2) |
p02661 | s432752692 | Accepted | N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
a,b = map(int,input().split())
A[i] = a
B[i] = b
A.sort()
B.sort()
if N%2:
print(B[N//2]-A[N//2]+1)
else:
print(B[N//2]+B[(N-1)//2]-A[N//2]-A[(N-1)//2]+1)
|
p02665 | s932921803 | Wrong Answer | N = int(input())
A_leaf = list(map(int, input().split()))
if N == 0 and A_leaf[0] == 0:
print(-1)
exit()
s = [0]*(N+2)
for i in range(1, N+2):
s[i] = s[i-1] + A_leaf[i-1]
node = [1]*(N+1)
for i in range(1, N+1):
node[i] = min((node[i-1] - A_leaf[i-1])*2, s[N+1]-s[i])
if node[i] <= 0:
print(-1)
exit()
else:
print(sum(node)) |
p04020 | s262303066 | Accepted | #!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
def main():
N, *A = map(int, open(0))
ans = 0
i = 0
prev = 0
while i < N:
if A[i] == 0:
prev = 0
else:
ans += (A[i]+prev)//2
prev = (A[i]+prev)%2
# print(A[i],prev,ans)
i += 1
print(ans)
if __name__ == "__main__":
main()
|
p03437 | s689735057 | Wrong Answer | from functools import reduce
from fractions import gcd
def lcm_base(x, y):
return (x * y) // gcd(x, y)
def lcm(*numbers):
return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
X,Y = map(int,input().split())
if lcm(X,Y)//X > 10**18 or X == Y:
print(-1)
else:
print(lcm(X,Y)//X) |
p02660 | s672787458 | Accepted | n = int(input())
mp = {}
for f in range(2, 1000000):
while n % f == 0:
mp[f] = 1 if f not in mp else mp[f] + 1
n //= f
if n > 1:
mp[n] = 1
def fn(x):
for i in range(2, 100):
sm = i*(i+1)//2
if x < sm:
return i - 1
#print(mp)
#print({p:fn(mp[p]) for p in mp})
print(sum(fn(mp[p]) for p in mp))
|
p02987 | s708545468 | Accepted | S=input()
s=list(set(S))
print("Yes" if len(s)==2 and S.count(s[0])==S.count(s[1])==2 else "No") |
p02993 | s817324752 | Wrong Answer | S = [str(x) for x in input()]
cnt = 0
for i in range(0,2):
if S[i] == S[i+1]:
cnt += 1
if cnt >= 1:
print("Bad")
else:
print("Good") |
p02832 | s460943278 | Accepted | n = int(input())
li_a = list(map(int, input().split()))
flg = False
nextval = 1
br = 0
for idx, a in enumerate(li_a):
if a == nextval:
nextval += 1
flg = True
else:
br += 1
if flg:
print(br)
else:
print('-1')
|
p03814 | s950274330 | Accepted | s= list(input())
a=min([i for i, x in enumerate(s) if x == 'A'])
z =max([i for i, x in enumerate(s) if x == 'Z'])
print(z+1-a) |
p03146 | s882873629 | Accepted | s = int(input())
c = set([s])
i = 1
while 1:
if s % 2 == 0:
s //= 2
else:
s = s*3+1
i += 1
if s in c:
break
else:
c.add(s)
print(i) |
p02793 | s581780916 | Accepted | from fractions import gcd
Mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
lm = A[0]
for a in A[1:]:
lm = lm*a//gcd(lm,a)
ans = 0
for i in range(N):
ans += lm//A[i]
ans %= Mod
print(ans)
|
p03030 | s287152841 | Accepted | n = int(input())
l = []
for i in range(n):
s, p = input().split()
p = int(p)
l.append([s, p])
l_s = sorted(l, key = lambda l:(l[0], -l[1]))
for i in l_s:
print(l.index(i) + 1)
|
p03657 | s165345687 | Accepted | a, b = list(map(int, input().split()))
if a % 3 == 0 or b % 3 == 0 or (a + b ) % 3 == 0:
print('Possible')
else:
print('Impossible')
|
p03037 | s513914508 | Accepted | def resolve():
N, M = list(map(int, input().split()))
interval = []
l, r = 0, 10**5
for i in range(M):
L, R = list(map(int, input().split()))
l = max(l, L)
r = min(r, R)
interval = set(list(range(l, r + 1)))
interval = interval & set(range(1, N + 1))
print(len(interval))
return
resolve() |
p03836 | s023032429 | Accepted | sx,sy,tx,ty = map(int,input().split())
y_diff = ty-sy
x_diff = tx-sx
ans = ""
for i in range(y_diff):
ans += "U"
for j in range(x_diff):
ans += "R"
for k in range(y_diff):
ans += "D"
for l in range(x_diff):
ans += "L"
ans += "L"
for s in range(y_diff+1):
ans += "U"
for t in range(x_diff+1):
ans += "R"
ans += "DR"
for p in range(y_diff+1):
ans += "D"
for q in range(x_diff+1):
ans += "L"
ans+="U"
print(ans) |
p03069 | s668310027 | Accepted | n = int(input())
s = input()
b = 0
w = s.count(".")
l = [w]
for i in range(1, n + 1):
if s[i - 1] == "#":
b += 1
if s[i - 1] == ".":
w -= 1
l.append(b + w)
# print(l)
print(min(l))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.