problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02647 | s656714840 | Accepted | n,k=map(int,input().split())
a=list(map(int,input().split()))
from itertools import accumulate
for i in range(min(k,100)):
l=[0]*(n+2)
for j in range(n):
left=max(0,j-a[j])
right=min(n,j+a[j])
l[left]+=1
l[right+1]-=1
s=list(accumulate(l))
# print(s)
a=s[:n]
print(*a) |
p03471 | s164984126 | Accepted | a,sums= list(map(int,input().split()))
yuki = sums//10000
taishi = (sums%10000) //5000
noguchi = (sums%5000) //1000
while a>yuki+taishi+noguchi:
if ((a-(yuki+taishi+noguchi))%4==0)&(taishi>0):
taishi-=1
noguchi+=5
elif yuki>0:
yuki-=1
taishi+=2
else:
break
if a==yuki+taishi+noguchi:
print(yuki,taishi,noguchi)
else:
print("-1 -1 -1") |
p03611 | s807903152 | Wrong Answer | N, *A = map(int, open(0).read().split())
C = {}
for a in A:
if a in C.keys():
C[a] += 1
else:
C[a] = 1
B = list(C.items())
B.sort(key=lambda x: x[0])
ans = max(B[0][1], B[-1][1])
for i in range(1, len(B)-1):
count = B[i][1]
if B[i-1][0] == B[i][0]-1:
count += B[i-1][1]
if B[i+1][0] == B[i][0]+1:
count += B[i+1][1]
ans = max(ans, count)
print(ans) |
p02640 | s384718001 | Wrong Answer | import sys
x, y = map(int, input().split()) # x:頭数 y:足
for i in range(x):
if i * 4 + (x - i) * 2 == y:
print('Yes')
sys.exit()
print('No')
|
p03481 | s785859482 | Wrong Answer | import math
x,y = map(int,input().split())
n = math.log2(y/x)
if n - int(n) == 0:
n = int(n)
else:
n = int(n)+1
print(n) |
p02612 | s419111215 | Accepted | #!/usr/bin/python3
n = int(input())
if(n%1000==0):
print("0")
else:
ans = n%1000
print(1000-ans) |
p02552 | s346376669 | Accepted | print(1 if input().strip() == "0" else 0) |
p02695 | s530906943 | Wrong Answer | N,M,Q = map(int,input().split())
num_list = []
for i in range(Q):
num_list.append(list(map(int,input().split())))
A_list = [1]*N |
p03219 | s579295739 | Wrong Answer | print(eval((input()+"*0.5").replace(" ","+"))) |
p03087 | s725683436 | Accepted | N,Q = map(int, input().split())
S = str(input())
before = ''
i = 0
num = 0
data_list = {}
for s in S:
if before == 'A' and s == 'C':
num += 1
before = s
data_list[i] = num
i += 1
ans = ''
for q in range(Q):
r,l = map(int, input().split())
ans += str(data_list[l-1]-data_list[r-1])+'\n'
print(ans.rstrip()) |
p03105 | s048896998 | Wrong Answer | A, B, C = map(int, input().split(' '))
print(max(C, B // A))
|
p02861 | s198125362 | Accepted | n = int(input())
dis = [list(map(int,input().split())) for _ in range(n)]
ans = 0
num = 0
from itertools import permutations
for path in list(permutations(range(n))):
num += 1
path = list(path)
distance = 0
for i in range(1,n):
xi = dis[path[i-1]][0]
xj = dis[path[i]][0]
yi = dis[path[i-1]][1]
yj = dis[path[i]][1]
distance += (pow(xi-xj,2)+pow(yi-yj,2))**0.5
ans = ans + distance
ans = ans/num
print(ans) |
p02779 | s465199865 | Accepted | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
N = int(readline())
A = list(map(int, readline().split()))
S = set(A)
if len(S) == N:
print("YES")
else:
print("NO")
if __name__ == '__main__':
main()
|
p02948 | s112844619 | Wrong Answer | N, M = map(int,input().split())
A_B = [list(map(int, input().split())) for i in range(N)]
day = 0
ans = 0
A_B = sorted(A_B, key=lambda x:(-x[1], -x[0]))
#print(A_B)
for i in range(N):
#print(day)
if day + A_B[i][0] <= M:
ans += A_B[i][1]
day += 1
print(ans) |
p02860 | s613642049 | Wrong Answer | i=input()
print(int(i)**2) |
p03633 | s047452467 | Accepted | import fractions
from functools import reduce
def lcm_base(x, y):
return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
N = int(input())
a = [int(input()) for i in range(N)]
print(lcm_list(a)) |
p03617 | s932681243 | Accepted | def main():
q, h, s, d = map(int, input().split())
n = int(input())
min_1 = min(q*4, h*2, q*2+h, s)
min_2 = min(min_1*2, d)
print((n % 2)*min_1 + (n // 2)*min_2)
if __name__ == '__main__':
main()
|
p02952 | s229301128 | Wrong Answer | N = int(input())
result = 0
if len(str(N)) % 2 == 0:
loop = ((len(str(N)) - 1) -1) //2 + 1
print(loop)
for i in range(loop):
result += 9 * pow(10,2*i)
else:
for i in range(len(str(N)) - 2):
result += 9 * pow(10,i)
result += N - pow(10,len(str(N)) - 1) + 1
print(result)
|
p03471 | s456719686 | Wrong Answer | N, Y = map(int, input().split())
res = False
a = 0
b = 0
c = 0
for i in range(N + 1):
for q in range(N + 1):
c = N - (i + q)
total = 10000*i + 5000*q + 1000*c
if total == Y:
res = True
a = i
b = q
d = c
if res:
print('{} {} {}'.format(a, b, d))
else:
print('-1 -1 -1') |
p02861 | s136945565 | Accepted | import math
n = int(input())
ten = [list(map(int,input().split())) for i in range(n)]
a = 0
for i, j in ten:
for k, u in ten:
a += math.sqrt((i - k)**2 + (j - u)**2)
print(a/n)
|
p03817 | s936607994 | Accepted | n=int(input())
ans=(n//11)*2
n%=11
if n>=7:ans+=2
elif n:ans+=1
print(ans) |
p03012 | s244167457 | Accepted | icase=0
if icase==0:
n=int(input())
w=list(map(int,input().split()))
ws=[0]*n
ws[0]=w[0]
for i in range(1,n):
ws[i]=ws[i-1]+w[i]
wdmin=100000
for i in range(n):
wd=abs(ws[-1]-2*ws[i])
wdmin=min(wdmin,wd)
print(wdmin)
|
p03494 | s785377646 | Accepted | n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
a = [i/2 for i in a ]
ans += 1
print(ans)
|
p02783 | s099655964 | Wrong Answer | H,A=map(int,input().split())
print(H//A+1) |
p03607 | s473291103 | Wrong Answer | N = int(input())
A = [int(input()) for i in range(N)]
sorted_A = sorted(A)
pre = sorted_A[0]
ans = 0
if len(sorted_A) == 1:
print(1)
else:
count = 1
for i in range(1, len(sorted_A)):
if sorted_A[i] == pre:
count += 1
else:
if count % 2 == 1:
ans += 1
pre = sorted_A[i]
count = 1
print(ans) |
p03623 | s817247910 | Accepted | x,a,b = map(int,input().split())
if abs(x-a) < abs(x-b):
print("A")
else:
print("B") |
p03059 | s927765464 | Wrong Answer | a,b,t = map(int, input().split())
if a > t:
print(0)
else:
total = int(t/a + 0.5)
print(total * b) |
p02792 | s470084621 | Accepted | n=int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(1,n+1):
d[str(i)[0]+str(i)[-1]]+=1
sm=0
for i in range(1,10):
for j in range(1,10):
sm+=d[str(i)+str(j)]*d[str(j)+str(i)]
print(sm) |
p03150 | s550565429 | Accepted | s = input()
cond = False
key = "keyence"
for i in range(len(s)+1):
for j in range(i, len(s)+1):
mod_s = s[:i]+s[j:]
if mod_s == key:
cond = True
print("YES" if cond else "NO")
|
p02661 | s960193698 | Accepted | import statistics
N = int(input())
A = []
B = []
for i in range(N):
a, b = map(int, input().split())
A.append(a)
B.append(b)
A_med = statistics.median(A)
B_med = statistics.median(B)
if N % 2 == 0:
ans = int((B_med - A_med) * 2 + 1)
else:
ans = int((B_med - A_med) + 1)
print(ans)
|
p03001 | s605326287 | Wrong Answer | w, h, x, y = map(int, input().split())
h_y = abs(y - h/2)
w_x = abs(x - w/2)
yoko = h_y*w
tate = w_x*h
ans = w*h/2 - min(tate, yoko)
flag = 0
if tate == yoko:
flag = 1
print(ans, flag)
|
p03815 | s634995078 | Accepted | x = int(input())
num = (x - 1) // 11 * 2 + 1
if x % 11 > 6 or x % 11 == 0:
num += 1
print(num) |
p03286 | s511611255 | Accepted | n = int(input())
s = ''
while n != 0:
r = n % 2
if r < 0:
r += 2
n = (n - r) // (-2)
s += str(0 + r)
if s == '':
print(0)
else:
print(s[::-1])
|
p03623 | s657233781 | Wrong Answer | x,a,b=map(int,input().split())
print(min([abs(x-a),abs(x-b)])) |
p02628 | s181648389 | Accepted | #!/usr/bin/env python3
def main():
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:K]))
if __name__ == '__main__':
main() |
p03075 | s601058748 | Wrong Answer | L=[int(input()) for _ in range(5)]
k=int(input())
if sum(L)<k*5:
print("Yay!")
else:
print(":(") |
p04034 | s257923384 | Accepted | n,m = map(int,input().split())
x = [0]*m
y = [0]*m
for i in range(m):
x[i],y[i] = map(int,input().split())
x[i] -= 1
y[i] -= 1
cnt = [1]*n
flag = [False]*n
flag[0] = True
for i in range(m):
if flag[x[i]]:
flag[y[i]] = True
if cnt[x[i]] == 1:
flag[x[i]] = False
cnt[x[i]] -= 1
cnt[y[i]] += 1
print(flag.count(True)) |
p02584 | s721185880 | Accepted | X, K, D = map(int,input().split())
XX = abs(X)
if K > XX // D:
if (K - (XX // D)) % 2 == 0:
ans = XX - (XX // D) * D
print(abs(ans))
else:
ans = (XX - (XX // D) * D) - D
print(abs(ans))
else:
ans = XX - D * K
print(abs(ans)) |
p03623 | s612343925 | Accepted | x,a,b = map(int,input().split())
print('A' if abs(x-a) < abs(x-b) else 'B') |
p02607 | s663191368 | Accepted | import sys
input = sys.stdin.readline
def main():
ans = 0
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
if (i+1)%2==1 and a[i]%2==1:
ans += 1
print(ans)
if __name__ == '__main__':
main() |
p03645 | s395267207 | Wrong Answer | n, m = [int(i) for i in input().split()]
a, b = [], []
c = 0
for i in range(m):
ship1, ship2 = [int(i) for i in input().split()]
if ship1 == 1:
c = max(c, ship2)
a.append(ship1)
b.append(ship2)
d = 0
for i in range(m):
ship1, ship2 = a[i], b[i]
if ship1 == c and ship2 == n:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
p02946 | s349250924 | Wrong Answer | k,n=map(int,input().split())
ans=""
for i in range(n-k+1,n+k-1):
ans+=str(i)+" "
print(ans) |
p03645 | s597428703 | Accepted | n,m = map(int,input().split())
start = [0]*200001
goal = [0]*200001
for i in range(m):
a,b = map(int,input().split())
if a == 1:
if goal[b] == 1:
print("POSSIBLE")
exit()
start[b] = 1
a
elif b == n:
if start[a] == 1:
print("POSSIBLE")
exit()
goal[a] = 1
print("IMPOSSIBLE") |
p03309 | s506433486 | Accepted | from numpy import *
N = int(input())
A = list(map(int,input().split()))
B = array(sorted([A[n]-(n+1) for n in range(N)]))
print(sum(abs(B-int(median(B))))) |
p03243 | s456708851 | Accepted | n = int(input())
for i in range(n, 1000):
nstr = str(i)
if nstr[0] == nstr[1] and nstr[1] == nstr[2]:
print(i)
break |
p02779 | s021813356 | Accepted | n = int(input())
a = list(map(int, input().split()))
a.sort()
for i in range(n-1):
if a[i] == a[i+1]:
print('NO')
exit(0)
print('YES') |
p03329 | s037229986 | Wrong Answer | import math
dp = [float('inf') for _ in range(200000)]
withdraw = []
N = int(input())
#引き出し可能な金額の配列にする
withdraw.append(1)
for i in range( math.floor(math.log(N,6)) + 1):
withdraw.append(6**i)
for i in range( math.floor(math.log(N,9)) + 1):
withdraw.append(9**i)
withdraw = sorted(list(set(withdraw)))
dp[0] = 0
for i in range(N+1):
for j in withdraw:
dp[i+j] = min(dp[i+j],dp[i]+1)
print(dp[N])
|
p02862 | s832770936 | Wrong Answer | import math
mod=10**9+7
def framod(n, mod, a=1):
for i in range(1,n+1):
a=a * i % mod
return a
def comb(n, r, mod = 10**9 + 7):
return ( framod(n,mod) * pow(framod(n-r,mod),mod-2,mod ) * pow(framod(r,mod),mod-2,mod))
X,Y=map(int,input().split())
if X % 3 == 0 and Y % 3 ==0:
s,t= ( 2*X - Y ) // 3 , (2*Y - X) // 3
print(comb(s+t,s) % mod)
else:
print(0)
|
p02642 | s253404114 | Accepted | from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
A_sort = sorted(set(A))
bool_list = [True] * (10 ** 6 + 1)
duplicate_dic = defaultdict(int)
for a in A:
duplicate_dic[a] += 1
if duplicate_dic[a] > 1:
bool_list[a] = False
for a in A_sort:
for i in range(2*a, 10 ** 6 + 1, a):
bool_list[i] = False
print(sum([1 for a in A_sort if bool_list[a]]))
|
p02712 | s681772161 | Accepted | # 入力
n = int(input())
# 出力
answer = 0
for i in range(1, n + 1):
if not i % 3 == 0 and not i % 5 == 0:
answer += i
print(answer)
|
p03241 | s073534814 | Wrong Answer | n,m=map(int,input().split())
num=m//n
while num!=0:
if m%num==0:print(num);break
else:
num **=0.5
num=int(num) |
p03994 | s441071768 | Accepted | s = input()
k = int(input())
n = len(s)
le = [""]*n
ne = []
for i in range(n):
le[i] = s[i]
if s[i] == "a":
ne.append(0)
else:
ne.append(123-ord(s[i]))
rem = k
for i in range(n):
if rem >= ne[i]:
rem -= ne[i]
le[i] = 'a'
saigo = ord(le[n-1]) - 97
ssm = (rem+saigo) % 26
le[n-1] = chr(97+ssm)
print(*le,sep = "") |
p03352 | s686474697 | Accepted | x=int(input())
ans=0
for i in range(2,10):
for j in range(1,1001):
tmp=j**i
if tmp<=x:
ans=max(tmp,ans)
print(ans) |
p02582 | s902424278 | Accepted | S=input()
ans=0
kouho=0
for i in range(len(S)):
if S[i]=="R":
kouho+=1
ans=max(ans,kouho)
else:
kouho=0
print(ans)
|
p03017 | s452177721 | Accepted | import sys
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a+1, c-1):
if s[i-1]==s[i]=='#':
print('No')
sys.exit()
for i in range(b+1, d-1):
if s[i-1]==s[i]=='#':
print('No')
sys.exit()
if c<d:
print('Yes')
else:
for i in range(b-1, d):
if s[i-1]==s[i]==s[i+1]=='.':
print('Yes')
sys.exit()
print('No') |
p02606 | s742371636 | Accepted | L, R, d = map(int, input().split())
count = 0
for i in range(L, R + 1):
if i % d == 0:
count += 1
print(count)
|
p02681 | s603163455 | Wrong Answer | s = input()
t = input()
a_1 = len(s)
a_2 = len(t)
if a_1+1 == a_2:
for i in range(a_1):
if s[i] != t[i]:
ans = "No"
else:
ans = "Yes"
else :
ans = "No"
print(ans) |
p03693 | s538204262 | Accepted | r, g, b = map(int, input().split())
number = 100*r + 10*g + b
if number%4 == 0:
ans = 'YES'
else:
ans = 'NO'
print(ans) |
p02697 | s363525050 | Accepted | N,M = [int(i) for i in input().split()]
if N%2 == 1:
for i in range(1,M+1):
print(i, end=" ")
print(N+1-i)
exit()
L = min(M,N//4)
for i in range(1,L+1):
print(i,end=" ")
print(N+1-i)
if L < M:
for i in range(L+1,M+1):
print(i,end=" ")
print(N-i) |
p02873 | s868302597 | Accepted | s = input()
partition = s.replace('><','>|<').split('|')
ans=0
for sub in partition:
left = sub.count('<')
right = sub.count('>')
ans += sum(range(1, max(left, right)+1))+sum(range(1, min(left, right)))
print(ans) |
p02742 | s979635996 | Wrong Answer | H,W=map(int,input().split())
P=H*W
if P % 2==0:
print(int(P/2))
else:
print(int(P/2+1)) |
p02676 | s037435248 | Accepted | K = int(input())
S = input()
if len(S) <= K:
print(S)
else:
print(S[:K] + '...') |
p03407 | s454217939 | Wrong Answer | a,b,c = map(int, input().split())
coins = [1,5,10,50,100,500]
if a in coins and b in coins:
if a+b >= c:
print("Yes")
else: print("No")
else: print("No") |
p02555 | s805207073 | Accepted | import math
def main():
s = int(input())
quo = int(s/3)
count = 0
for i in range(1, quo+1):
a = math.factorial((s-3*i)+(i-1))
b = math.factorial(s-3*i)
c = math.factorial(i-1)
add = a//(b*c)
count += add
return count % (10**9+7)
if __name__ == "__main__":
print(main())
|
p02951 | s248001244 | Accepted | a, b, c = map(int, input().split())
a -= b
if a > c:
print(0)
else:
print(c-a) |
p03861 | s808041905 | Wrong Answer | a, b, x = [int(x) for x in input().split()]
cnt_a = a // x
cnt_b = b // x
print(cnt_b-cnt_a) |
p02755 | s993989669 | Wrong Answer | import math
a=input().split()
A,B=int(a[0]),int(a[1])
p=int(A/0.08)
if(math.floor(p*0.1)==B):
print(p)
else:
print(-1) |
p02659 | s418795725 | Wrong Answer | import math
A, B = list(input().split())
A = int(A)
B = '{:.2f}'.format(float(B)).replace('.', '')
B = int(B)
# A *= 100
# B = int(B * 100)
AB = A * B / 100
floored = int(math.floor(AB))
print(floored)
# AB = A * B
# AB = str(AB)
# AB = AB[0:-2]
# AB = 0 if AB == '' else AB
# print(AB)
|
p03639 | s807194972 | Accepted | n=int(input())
lst=map(int,input().split())
od=0
fo=0
for a in lst:
if (a%4)%2==1:
od+=1
elif a%4==0:
fo+=1
if fo>=od:
print("Yes")
elif 2*fo+1==n:
print("Yes")
else:
print("No") |
p02628 | s974203752 | Accepted |
def main():
kinds = list(map(int,input().split()))
prices = list(map(int,input().split()))
minPrice = 0
for item in range(kinds[1]):
minPrice += min(prices)
prices.remove(min(prices))
print(minPrice)
if __name__ == "__main__":
main() |
p02659 | s040750532 | Accepted | A, B = input().split()
print(int(A) * round(float(B) * 100) // 100) |
p02705 | s327455416 | Accepted | import math
n = int(input())
ans = math.pi * 2 * n
print(ans)
|
p02747 | s432965350 | Accepted | S=input()
def No():
print("No")
exit()
def Yes():
print("Yes")
exit()
if len(S)%2!=0:
No()
if len(S)==0:
No()
if all([S[2*i:2*i+2]=="hi" for i in range(int(len(S)/2))]):
Yes()
else:
No() |
p03387 | s974922559 | Accepted | a,b,c=map(int,input().split())
l=[a,b,c]
l.sort(reverse=True)
x_max=l[0]
x_mid=l[1]
x_min=l[2]
count=0
count+=l[0]-l[1]
dif=l[0]-(l[2]+count)
if dif%2==0:
count+=dif//2
else:
count+=dif//2+2
print(count) |
p02706 | s579579212 | Accepted | # coding: utf-8
# Your code here!
N, M = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) <= N:
print(N - sum(A))
else:
print(-1) |
p03815 | s372952008 | Accepted | x=int(input())
large_approach=x//11
short_approach=x%11
if short_approach==0:
print(large_approach*2)
elif short_approach<=6:
print(large_approach*2+1)
else:
print(large_approach*2+2) |
p03860 | s881755489 | Accepted | icase=48
if icase==48:
a,b,c=input().split()
print("A"+b[0]+"C")
|
p04031 | s606740243 | Accepted | n=int(input())
a = list(map(int,input().split()))
_sum =sum(a) / n
s = round(_sum)
ans = 0
#print(s)
for i in range(n):
v =(a[i]-s)**2
ans += v
print(ans) |
p02747 | s556828195 | Accepted | s = input()
data = len(s)
s = list(s)
j = 0
for i in s:
if j%2 == 0:
if i != "h":
break
if j%2 == 1:
if i != "i":
break
j += 1
if j == data and data%2 == 0:
print("Yes")
else:
print("No") |
p02973 | s406019292 | Accepted | import bisect
N = int(input())
A = []
for i in range(N):
A.append(int(input()))
A = A[::-1]
S = [A[0]]
c = 1
for i in range(1, N):
t = A[i]
if t >= S[-1]:
S.append(t)
c += 1
else:
p = bisect.bisect_right(S, t)
S[p] = t
print(c) |
p02813 | s422226241 | Wrong Answer | import itertools
import math
N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
l=[ i+1 for i in range(N) ]
Per=itertools.permutations(l,N)
Per=list(Per)
num=[-1,-1]
for i in range(math.factorial(N)):
if Per[i]==P:
num[0]=i
elif Per[i]==Q:
num[1]=i
print(abs(num[0]-num[1])) |
p02695 | s524783514 | Wrong Answer | import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(Q)]
answer = 0
nums=[]
for i in range(1, M+1):
nums.append(i)
for balls in itertools.combinations_with_replacement(nums, N):
score = 0
for i in range(Q):
test = list(balls)
print(test)
if test[abcd[i][0]-1] + abcd[i][2] == test[abcd[i][1]-1]:
score += abcd[i][3]
if score > answer:
answer = score
print(answer)
|
p03759 | s494528669 | Accepted | a,b,c = map(int, input().split())
A = b - a
B = c - b
if A==B:
print("YES")
else :
print("NO") |
p04031 | s709350377 | Accepted | N =int(input())
a = list(map(int,input().split()))
ans = (10**9)
for av in range(min(a),max(a)+1):
Sum = 0
for i in range(N):
Sum += (a[i]-av)**2
if Sum < ans:
ans = Sum
print(ans) |
p02753 | s023814401 | Accepted | arr = input()
cnt = 0
for a in arr:
if a == 'A':
cnt += 1
if cnt == 0 or cnt == len(arr):
print("No")
else:
print("Yes") |
p04011 | s541921841 | Accepted | N = int(input())
K = int(input())
X = int(input())
Y = int(input())
print((min(N,K)*X) + (max(0,(N-K))*Y)) |
p02759 | s465655119 | Accepted | from math import ceil
n = int(input())
print(ceil(n/2)) |
p03127 | s259866042 | Accepted | n = int(input())
import fractions
A = list(map(int,input().split()))
g = 0
for i in range(n):
g = fractions.gcd(g,A[i])
print(g)
|
p03632 | s262914370 | Wrong Answer | #import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
r_ = n / m
if (r_ - (n // m)) > 0:
return (n//m) + 1
else:
return (n//m)"""
# Written by NoKnowledgeGG @YlePhan
#import math
#mod = 10**9+7
def main():
a,b,c,d = map(int,input().split())
if b >= c:
l = max(a,c)
r = min(b,d)
print(r-l)
exit()
else:
print(0)
exit()
if __name__ == '__main__':
main() |
p02713 | s708932641 | Accepted | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd,numbers)
K=int(input())
count=0
for a in range(1,K+1):
for b in range(1,K+1):
for c in range(1,K+1):
count+=gcd(a,b,c)
print(count) |
p04045 | s416999636 | Accepted | # 24
import sys
def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()
INF = float('inf')
n, k = LI()
d = set(LI())
# 最小金額から条件を満たすまで増やしていく
while True:
if all([int(j) not in d for j in str(n)]): # 全ての桁の数字が d に属さない
print(n)
exit()
n += 1
|
p03282 | s601265095 | Accepted | s = input()
k = int(input())
if k <= len(s) :
for i in range(k):
if s[i] != "1":
print(s[i])
exit()
print("1")
exit()
for i in range(len(s)):
if s[i] != "1":
print(s[i])
exit()
|
p02917 | s014813764 | Wrong Answer | N=int(input())
B=list(map(int,input().split()))
A=[0]*N
for i in range(1,N-1):
A[i]=min(B[i-1],B[i])
A[0]=A[1]
a=sum(A)+B[N-2]
print(a) |
p02819 | s967648445 | Accepted | import math
array=[2]
for i in range(3,100004,2):
prime=True
for n in range(len(array)):
if array[n] > math.sqrt(i):
break
if i % array[n] == 0:
prime = False
break
if prime:
array.append(i)
l=int(input())
for m in range(len(array)):
if l>array[m]:
pass
else:
print(array[m])
break |
p03997 | s741447110 | Wrong Answer | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2) |
p03327 | s244776595 | Accepted | n=int(input())
if n<1000:
print("ABC")
else:
print("ABD") |
p03417 | s278776488 | Accepted | n,m = map(int, input().split())
if n==1 and m==1:
print(1)
elif n==1:
print(m-2)
elif m==1:
print(n-2)
else:
print((n-2)*(m-2)) |
p03821 | s865078158 | Accepted | n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ans=0
for i in range(n):
#print(ab[-i-1][0]+ans,ab[-i-1][1])
if (ab[-i-1][0]+ans)%ab[-i-1][1]!=0:
ans+=ab[-i-1][1]-(ab[-i-1][0]+ans)%ab[-i-1][1]
#print(ans)
print(ans) |
p02664 | s454175312 | Accepted | t=list(input())
for i in range(len(t)):
if t[i]=='?':
t[i]='D'
print(''.join(t)) |
p02713 | s332117222 | Accepted | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
N = int(input())
sum1 = 0
sum2 = 0
sum3 = 0
for a in range(1,N+1):
for b in range(a+1, N+1):
for c in range(b+1, N+1):
sum1 += gcd(a,b,c)
for a in range(1,N+1):
for b in range(a+1, N+1):
sum2 += gcd(a,b)
sum3 = N*(N+1)/2
print(int(sum1*6+sum2*6+sum3)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.