problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p03485
|
s045526093
|
Wrong Answer
|
A,B = map(int,input().split())
print((A+B)//2)
|
p02684
|
s187030296
|
Wrong Answer
|
N, K = map(int, input().split())
A = list(map(int, input().split()))
roop_num = 1
city = 0
first_city = 0
while True:
next_city = A[city] - 1
if next_city == first_city:
break
if roop_num == K:
print(city + 1)
exit()
city = next_city
roop_num += 1
rem_num = K % roop_num
city = 0
num = 0
while True:
next_city = A[city] - 1
if num == rem_num:
print(city + 1)
exit()
city = next_city
num += 1
|
p04029
|
s715259121
|
Wrong Answer
|
# 等差数列の和 Sn=n(a+1)/2
N = int(input())
# 定義
# 1 <= N <= 100
total = N * ( N + 1)/ 2
print(total)
|
p02959
|
s713239254
|
Accepted
|
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
res = 0
for i in range(N):
if A[i] < B[i]:
res += min(A[i+1]+A[i],B[i])
A[i+1] = max(A[i+1]+A[i]-B[i],0)
else:
res += B[i]
print(res)
|
p02618
|
s898744127
|
Accepted
|
from collections import defaultdict
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
s.append(list(map(int,input().split())))
dic = defaultdict(int)
for i in range(1,d+1):
maxscore = 0
maxcontest = -1
for k in range(26):
score = 0
score += s[i-1][k-1]
score += c[k]*(i-dic[k])
if score > maxscore:
maxscore = score
maxcontest = k
print(maxcontest+1)
dic[maxcontest] = i
|
p03698
|
s752911450
|
Wrong Answer
|
a = list(input())
count = 0
for i in range(0, len(a)):
if a[i] == a[i - 1]:
count += 1
if count > 0:
print("no")
elif count == 0:
print("yes")
|
p03696
|
s877713264
|
Accepted
|
N = int(input())
S = input()
stk = []
for s in S:
if len(stk) == 0 or stk[-1] == ')' or s == '(':
stk.append(s)
else:
stk.pop()
print('(' * stk.count(')') + S + ')' * stk.count('('))
|
p03435
|
s447808580
|
Wrong Answer
|
grid = []
for i in range(3):
grid.append(list(map(int, input().split())))
flag = True
for i in range(1, 3):
if grid[i][0] - grid[0][0] == grid[i][1] - grid[0][1] == grid[i][2] - grid[0][2]:
continue
else:
flag = False
print('No')
if flag:
print('Yes')
|
p03998
|
s150177845
|
Accepted
|
S = {alpha:list(input()) for alpha in 'abc'}
s = 'a'
while S[s]:
s = S[s].pop(0)
print(s.upper())
|
p02660
|
s225067910
|
Accepted
|
n = int(input())
i = 2
ans = 0
while True:
if i * i > n:
break
if n % i == 0:
cnt = 0
while n % i == 0:
n /= i
cnt += 1
k = 1
while cnt >= k:
cnt -= k
k += 1
ans += k - 1
i += 1
if n > 1:
ans += 1
print(ans)
|
p02711
|
s842753284
|
Accepted
|
N = input()
if "7" in N:
print("Yes")
else:
print("No")
|
p02718
|
s164823523
|
Accepted
|
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if a[m-1] * 4 * m >= sum(a):
print('Yes')
else:
print('No')
|
p02642
|
s134411242
|
Accepted
|
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ma = 2 * 10 ** 6
tab = [False] * (ma)
mapp = {}
for i in a:
if i in mapp:
mapp[i] += 1
else:
mapp[i] = 1
ans = 0
for i in a:
if not tab[i]:
if mapp[i] == 1:
ans += 1
for j in range(i, ma, i):
tab[j] = True
print(ans)
|
p02630
|
s418709236
|
Accepted
|
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = sum(a)
a = Counter(a)
for _ in range(q):
b, c = map(int, input().split())
if b in a:
a[c] += a[b]
s += (c-b) * a[b]
a[b] = 0
print(s)
|
p03971
|
s078352461
|
Accepted
|
_N,A,B=map(int,input().split())
S=input()
a,b=0,0
for s in S:
if a+b < A+B:
if s=='a':
a+=1
print('Yes')
elif s=='b' and b < B:
b+=1
print('Yes')
else:
print('No')
else:
print('No')
|
p03997
|
s360204090
|
Accepted
|
a = int(input())
b = int(input())
h = int(input())
print( int((a + b) * h / 2) )
|
p03371
|
s205581494
|
Wrong Answer
|
a, b, c, x, y = A = list(map(int, input().split()))
l = a * x + b * y
m = c * max(x, y) * 2
if x >= y :
n = c * y * 2 + a * (x - y)
else:
n = c * x * 2 + a * (y - x)
ans = min(l, m, n)
print(ans)
|
p03759
|
s244781266
|
Accepted
|
a,b,c=map(int,input().split())
print('YNEOS'[b-a!=c-b::2])
|
p03814
|
s584262753
|
Wrong Answer
|
S = input()
#Aの探索
for i in range(len(S)):
if S[i] == "A":
S = S[i:]
break
#Zの探索
for i in range(1, len(S)+1):
if S[-i] == "Z":
S = S[:-i+1]
break
print(len(S))
|
p03524
|
s088216715
|
Accepted
|
S = input()
c_a = 0
c_b = 0
c_c = 0
for i in range(len(S)):
if S[i] == 'a':
c_a += 1
elif S[i] == 'b':
c_b += 1
else:
c_c += 1
if abs(c_a -c_b) < 2 and abs(c_b - c_c) < 2 and abs(c_c - c_a) < 2:
print('YES')
else:
print('NO')
|
p03282
|
s015898455
|
Accepted
|
S = input()
K = int(input())
lc1 = -1
while lc1 + 1 < len(S) and S[lc1 + 1] == '1':
lc1 += 1
print("1" if lc1 + 1 >= K else S[lc1 + 1])
|
p02600
|
s241978660
|
Wrong Answer
|
x = int(input())
print(8 - (1800 - 400) // 200)
|
p02996
|
s337777277
|
Accepted
|
import heapq
n = int(raw_input())
heap = [map(int, raw_input().split(' '))[::-1] for _ in range(n)]
heapq.heapify(heap)
def f(heap):
t = 0
while(heap):
nd,d = heapq.heappop(heap)
gap = nd - t - d
if gap < 0:
return False
t += d
return True
print 'Yes' if f(heap) else 'No'
|
p02646
|
s518186565
|
Accepted
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a == b:
print("YES")
exit()
if v <= w:
print("NO")
exit()
if (v - w) * t >= abs(a - b):
print("YES")
else:
print("NO")
|
p02756
|
s337872984
|
Accepted
|
from collections import deque
S = input()
Q = int(input())
ans = deque()
ans.append(S)
reverse = False
for i in range(Q):
x = list(input().split())
if int(x[0]) == 1:
reverse = not reverse
continue
if int(x[1]) == 1 and not reverse:
ans.appendleft(x[2])
elif int(x[1]) == 2 and reverse:
ans.appendleft(x[2])
else:
ans.append(x[2])
ans = ''.join(ans)
if reverse:
print(ans[::-1])
else:
print(ans)
|
p03962
|
s396168326
|
Accepted
|
se = set(list(map(int, input().split())))
n = len(se)
print(str(n))
|
p02832
|
s738778130
|
Accepted
|
N=int(input())
A=list(map(int,input().split()))
number=1
B=[]
for i in range(N):
if A[i]==number:
number+=1
B.append(A[i])
#print(B,number)
if len(B)==0:
print(-1)
else:
print(N-len(B))
|
p02820
|
s275505431
|
Accepted
|
n, k = map(int, input().split())
s, p, r = map(int, input().split())
dic = {"p":p, "r":r, "s":s}
t = input()
ans = 0
for i in range(k):
bef = "a"
for j in range(i, n, k):
if bef == t[j]:
bef = "a"
else:
ans += dic[t[j]]
bef = t[j]
print(ans)
|
p02727
|
s187959296
|
Accepted
|
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)
P = P[:X]
Q = Q[:Y]
print(sum(sorted(P + Q + R, reverse=True)[:X+Y]))
|
p02657
|
s992181869
|
Accepted
|
a, b = map(int, input().split())
print(a * b)
|
p03210
|
s019113748
|
Accepted
|
x=int(input())
if x==7 or x==5 or x==3:
print('YES')
else:
print('NO')
|
p03797
|
s614177218
|
Accepted
|
n, m = list(map(int, input().split()))
if n * 2 < m:
print(n + (m - n * 2) // 4)
else:
print(m // 2)
|
p02854
|
s377509439
|
Accepted
|
n = int(input())
a = list(map(int,input().split()))
a_cumsum = [0]*(n+1)
for i in range(n):
a_cumsum[i+1] = a_cumsum[i] + a[i]
ans = 10**18
for i in range(n):
ans = min(ans, abs(a_cumsum[-1] - a_cumsum[i]*2))
print(ans)
|
p02760
|
s723958506
|
Wrong Answer
|
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))
a3 = list(map(int,input().split()))
a4 = set()
a5 = set()
a4.update({a1[0],a2[1],a3[2]})
a5.update({a1[2],a2[1],a3[0]})
n = int(input())
B =set()
for i in range(n):
b = int(input())
B.add(b)
if set(a1) <= B or set(a2) <= B or set(a3) <= B or a4 <= B or a5 <= B:
print('Yes')
else:
print('No')
|
p03380
|
s935288733
|
Accepted
|
import sys
input = sys.stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
amax = a.pop()
ans = a[0]
for i in a :
if abs(amax/2 - ans) > abs(amax/2 - i) :
ans = i
print(amax, ans)
|
p02595
|
s821737430
|
Accepted
|
N,D = map(int,input().split())
Ref = D ** 2
cnt = 0
for _ in range(N):
p,q = map(int,input().split())
if p ** 2 + q ** 2 <= Ref:
cnt += 1
print(cnt)
|
p03475
|
s907438310
|
Accepted
|
N = int(input())
CSF = [list(map(int,input().split())) for i in range(N-1)]
for j in range(0,N,1):
t = 0
for i in range(j,N-1,1):
C,S,F = CSF[i]
if t < S:#まだ1ポンも出てないなら待つしかない
t = S
if t%F != 0:
t += F-t%F
t += C
print(t)
|
p03163
|
s514968004
|
Accepted
|
n,W=map(int,input().split())
dp=[0]*(W+1)
for i in range(n):
w,v=map(int,input().split())
for j in range(W,-1,-1):
cw=j+w
cv=dp[j]+v
if cw <=W and dp[cw]<cv:
dp[cw]=cv
print(dp[W])
|
p03067
|
s572522216
|
Wrong Answer
|
a,b,c = map(int,input().split())
if a < c < b:
print('Yes')
else:
print('No')
|
p02916
|
s865303932
|
Accepted
|
def main():
n = int(input())
a_lst = list(map(int, input().split()))
b_lst = list(map(int, input().split()))
c_lst = list(map(int, input().split()))
ans = 0
for a in a_lst:
ans += b_lst[a - 1]
for i in range(n - 1):
if a_lst[i] + 1 == a_lst[i + 1]:
ans += c_lst[a_lst[i] - 1]
print(ans)
if __name__ == "__main__":
main()
|
p03861
|
s264600348
|
Accepted
|
a, b, x = [int(i) for i in input().split()]
print((b//x+1) - ((a-1)//x+1 if a >= 0 else 0))
|
p02854
|
s659214788
|
Accepted
|
import sys, itertools
N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
S = list(itertools.accumulate(A))
mini = 10 ** 18
for i in range(N):
mini = min(mini, abs(S[N - 1] - 2 * S[i]))
print(mini)
|
p02601
|
s497900119
|
Wrong Answer
|
a,b,c = map(int,input().split())
k = int(input())
if not a < b:
b *=2
k -=1
if not b < c:
c *=2
k -=1
if k <= 0:
print('No')
exit()
elif not a<b<c:
print('No')
exit()
print('Yes')
|
p02691
|
s671880368
|
Wrong Answer
|
N=int(input())
A=list(map(int, input().split()))
D={}
E={}
for i in range(N):
a=i+1+A[i]
b=i+1-A[i]
D.setdefault(a-1,0)
E.setdefault(b-1,0)
D[a-1]+=1
E[b-1]+=1
print(D,E)
ans=0
for i in D:
if i in E:
ans+=D[i]*E[i]
print(ans)
|
p02831
|
s366391382
|
Accepted
|
from fractions import gcd
A, B = map(int,input().split())
print((A * B) // gcd(A, B))
|
p03252
|
s580307847
|
Wrong Answer
|
def main():
from string import ascii_lowercase
S = input()
T = input()
dic = {a: set() for a in ascii_lowercase}
for s, t in zip(S, T):
dic[t].add(s)
if all(len(s) <= 1 for s in dic.values()):
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
p02790
|
s743681649
|
Accepted
|
a,b=input().split()
li=[a*int(b),b*int(a)]
li.sort()
print(li[0])
|
p03862
|
s652457021
|
Accepted
|
N,x = list(map(int,input().split()))
a = list(map(int,input().split()))
counter = 0
for i in range(N-1):
sum_a = a[i] + a[i+1]
if sum_a > x:
if sum_a - x > a[i+1]:
counter += sum_a -x
a[i] = a[i] -(sum_a-x-a[i+1]) #この行はなくてもいい
a[i+1] = 0
else:
counter += sum_a-x
a[i+1] = a[i+1] - (sum_a -x)
print(counter)
|
p03944
|
s655247006
|
Wrong Answer
|
w,h,n = map(int,input().split())
x_min = 0
y_min = 0
x_max = w
y_max = h
for i in range(n):
x,y,a = map(int,input().split())
if a == 1:
x_min = x
elif a == 2:
x_max = x
elif a == 3:
y_min = y
elif a == 4:
y_max = y
S = (x_max-x_min)*(y_max-y_min)
if S < 0:
print(0)
else:
print(S)
|
p04020
|
s573343810
|
Wrong Answer
|
N = int(input())
A = []
cnt = 0
for _ in range(N):
a = int(input())
cnt += a//2
A.append(a%2)
cur = 0
for i in range(N):
if A[i]==1:
cur += 1
else:
cnt += cur//2
cur = 0
cnt += cur//2
print(cnt)
|
p03836
|
s543543409
|
Accepted
|
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
def main():
sx, sy, tx, ty = MII()
x1 = tx-sx
y1 = ty-sy
go1 = 'U'*y1 + 'R'*x1
bk1 = 'D'*y1 + 'L'*x1
go2 = 'L'+'U'+go1+'R'+'D'
bk2 = 'R'+'D'+bk1+'L'+'U'
print(go1+bk1+go2+bk2)
if __name__ == '__main__':
main()
|
p02623
|
s845795697
|
Wrong Answer
|
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
a[i] += a[i-1]
for i in range(1,m):
b[i] += b[i-1]
ans = -100
for i in range(n):
if(a[i]>k):
break
for j in range(1,m):
if(a[i]+b[(-1)*j]>k):
break
ans = max(ans,i+j+1)
print(ans)
|
p02600
|
s115669941
|
Wrong Answer
|
print(8-int(int(input())-400)/200)
|
p03644
|
s831327779
|
Accepted
|
N = int(input())
ans = 1
judg = 0
for i in range(N):
x = i+1
counter = 0
while True:
if x%2==0:
x = x / 2
counter += 1
else:
break
if judg<counter:
ans = i+1
judg = counter
print(ans)
|
p03861
|
s312770070
|
Accepted
|
a,b,x=map(int,input().split())
shita=a//x
ue=b//x
if a%x==0:
print(ue-shita+1)
else:
print(ue-shita)
|
p03062
|
s874758164
|
Accepted
|
n = int(input())
A = list(map(int,input().split()))
cnt = 0
A_ = []
for i in A:
if i < 0:
cnt += 1
A_.append(-i)
else:
A_.append(i)
if cnt%2 == 0:
print(sum(A_))
else:
print(sum(A_) - 2*min(A_))
|
p02963
|
s427759278
|
Wrong Answer
|
#!/usr/bin python3
# -*- coding: utf-8 -*-
def main():
S = int(input())
y = (S+10**9-1)//(10**9)
x = y*(10**9)-S
print(' '.join(map(str,[0,0,1,10**9,x,y])))
if __name__ == '__main__':
main()
|
p02795
|
s462740236
|
Accepted
|
h = int(raw_input())
w = int(raw_input())
n = int(raw_input())
if h > w:
h, w = w, h
print (n + w - 1) / w
|
p02700
|
s928601227
|
Accepted
|
A,B,C,D = map(int,input().split())
Flag = False
while Flag == False:
C = C - B
if C <= 0 :
Flag = True
break
A = A - D
if A <= 0 :
break
if Flag == True :
print('Yes')
else :
print('No')
|
p02946
|
s229128413
|
Wrong Answer
|
X, K = map(int, input().split())
if X == 1:
print(K)
else:
for i in range(K - X +1,K + X -1):
print(i,end=" " )
|
p03711
|
s101841808
|
Accepted
|
m = dict()
a0 = [1,3,5,7,8,10,12]
a1 = [4,6,9,11]
a2 = [2]
for i,j in enumerate([a0,a1,a2]):
for k in j:
m[k] = i
a, b = map(int, input().split())
if m[a] == m[b]:
print("Yes")
else:
print("No")
|
p03951
|
s584799929
|
Accepted
|
N = int(input())
S = input()
T = input()
if S==T:
print(N)
exit()
for i in range(N):
if S[i:] == T[:-i]:
print(N+i)
exit()
print(N+N)
|
p04043
|
s175514380
|
Accepted
|
A = sorted(list(map(int, input().split())))
print('YES' if A[0] == 5 and A[1] == 5 and A[2] == 7 else 'NO')
|
p02847
|
s256395271
|
Wrong Answer
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
S = input()
W = {'SUN': 1,
'MON': 2,
'TUE': 3,
'WED': 4,
'THU': 5,
'FRI': 6,
'SAT': 7}
print(W[S])
if __name__ == "__main__":
main()
|
p02918
|
s040265980
|
Wrong Answer
|
N,K = (int(x) for x in input().split())
S = list(input())
i = 0
ans = N
while i < len(S)-1:
if S[i] == 'R' and S[i+1] == 'L':
if K == 0:
ans -= 2
else:
K -= 1
i += 1
if S[0] == 'L':
if K > 0:
K -= 1
else:
ans -= 1
if S[N-1] == 'R':
if K > 0:
K -= 1
else:
ans -= 1
print(ans)
|
p02713
|
s411852850
|
Wrong Answer
|
from math import gcd
n = int(input())
ans = 0
for i in range(1, n + 1):
for j in range(1, n + 1):
for k in range(1, n + 1):
ans += gcd(gcd(i, j), k)
|
p02900
|
s035902652
|
Accepted
|
from fractions import *
a,b=map(int,input().split())
g=gcd(a,b)
l=[g]
for i in range(2,int(g**.5)+1):
if g%i<1: l+=[i,g//i]
c=1
for i in sorted(l):
if g<2: break
if g%i<1: c+=1
while g%i<1: g//=i
print(c)
|
p02760
|
s122782720
|
Wrong Answer
|
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
print(A)
for i in range(3):
for j in range(3):
if A[i][j] in b:
A[i][j] = 0
for i in range(3):
if A[i][0] + A[i][1] + A[i][2] == 0 or A[0][i] + A[1][i] + A[2][i] == 0 or A[0][0]+A[1][1]+A[2][2] ==0 or A[2][0]+A[1][1]+A[0][2] ==0:
print('Yes')
break
else:
print('No')
break
|
p03457
|
s222154747
|
Accepted
|
n = int(input())
t0, x0, y0 = 0, 0, 0
cnt = 0
for _ in range(n):
t, x, y = map(int, input().split())
diff_t = t-t0
distance = abs(x0-x)+abs(y0-y)
if diff_t >= distance and (diff_t - distance == 0 or (diff_t - distance) % 2 == 0):
cnt += 1
t0, x0, y0 = t, x, y
print('Yes' if cnt == n else 'No')
|
p02689
|
s334474020
|
Accepted
|
N, M = list(map(int, input().split()))
TENBOUDAI = list(map(int, input().split()))
# linked_list = { i: set() for i in range(N)}
_list = {i:1 for i in range(1,N+1)}
for m in range(M):
i,j= list(map(int, input().split()))
# if i in _list and j in _list:
if TENBOUDAI[i-1] <= TENBOUDAI[j-1]:
# _list.remove(i)
_list[i] =0
if TENBOUDAI[j-1] <= TENBOUDAI[i-1]:
# _list.remove(j)
_list[j] =0
# print(_list)
print(sum(_list.values()))
|
p03329
|
s229863063
|
Accepted
|
N=int(input())
def money(n):
dp=[n]*(n+1)
dp[0]=0
for i in range(1,n+1):
power=1
while power<=i:
dp[i]=min(dp[i],dp[i-power]+1)
power*=6
power=1
while power<=i:
dp[i]=min(dp[i],dp[i-power]+1)
power*=9
return dp[n]
print(money(N))
|
p02640
|
s656674440
|
Accepted
|
import math
X,Y=map(int, input().split())
if math.isclose(-Y/2+2*X, math.ceil(-Y/2+2*X)) and math.isclose(Y/2-X, math.ceil(Y/2-X)):
if Y//2-X>0 and -Y/2+2*X>0:
print("Yes")
elif Y/2-X==0 and -Y/2+2*X>0:
print("Yes")
elif Y/2-X>0 and -Y/2+2*X==0:
print("Yes")
else:
print("No")
else:
print("No")
|
p02973
|
s551415798
|
Wrong Answer
|
import heapq
N = int(input())
A = list(int(input()) for _ in range(N))
S = [A[0]]
for i in range(1, N):
if A[i] <= S[0]:
S.insert(0, A[i])
continue
for j in range(len(S)):
if A[i] < S[j]:
S[j-1] = A[i]
break
else:
S[-1] = A[i]
print(len(S))
|
p03352
|
s905691142
|
Accepted
|
X = int(input())
ans = 1
for i in range(2, X + 1):
tmp = i ** 2
while tmp <= X:
ans = max(ans, tmp)
tmp *= i
print (ans)
|
p02678
|
s401541694
|
Accepted
|
from collections import deque
n,m=map(int,input().split())
tree=[[] for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
a-=1
b-=1
tree[a].append(b)
tree[b].append(a)
dist=[-1 for i in range(n)]
dist[0]=0
ans=[-1 for i in range(n)]
ans[0]=0
dq=deque()
dq.append(0)
while dq:
x=dq.popleft()
for i in tree[x]:
if ans[i]==-1:
ans[i]=x
dq.append(i)
if -1 in ans:
print('No')
exit()
print('Yes')
for i in ans[1:]:
print(i+1)
|
p03680
|
s355345765
|
Wrong Answer
|
n = int(input())
a = list(int(input()) for _ in range(n))
i= 1
cnt=0
for _ in range(n):
i = a[i-1]
cnt += 1
if(a[i-1] == 2):
print(cnt+1)
quit()
else:
continue
print(-1)
|
p02761
|
s914396613
|
Accepted
|
N, M = map(int, input().split())
ans = ['-1'] * N
if N == 1 and M == 0:
print(0)
exit()
for i in range(M):
s, c = map(int, input().split())
if ans[s-1] == str(c):
continue
elif ans[s-1] == '-1':
ans[s-1] = str(c)
else:
print(-1)
exit()
if N >= 2 and ans[0] == '0':
print(-1)
exit()
elif ans[0] == '-1':
ans[0] = '1'
ans = ''.join(ans).replace('-1', '0')
print(ans)
|
p02554
|
s824464632
|
Accepted
|
n=int(input())
#0を一回も使わない
no_0 = 9**n
#9を一回も使わない
no_9 = 9**n
#0と9を一回も使わない
no_09 = 8**n
#全体-上記集合
yes_09 = 10**n - (no_0+no_9-no_09)
print(yes_09%(10**9+7))
|
p03485
|
s377410534
|
Accepted
|
from math import ceil
a,b = map(int,input().split())
print(ceil((a+b)/2))
|
p03679
|
s324053964
|
Wrong Answer
|
x,a,b = map(int,input().split())
print('delicious') if b <= a else print('safe') if b < a+b else print('dangerous')
|
p02601
|
s682272328
|
Wrong Answer
|
A,B,C=map(int,input().split())
K=int(input())
list=[A,B,C]
for i in range(K):
mini=min(list)
for n in range(3):
if mini==list[n]:
list[n]=2*list[n]
A=list[0]
B=list[1]
C=list[2]
if A<B<C:
print("Yes")
else:
print("No")
|
p02838
|
s522866774
|
Accepted
|
MOD = (10**9) + 7
n = int(input())
a = list(map(int,input().split()))
cnt = [0] * 60
for num in a:
for j in range(60):
cnt[j] += (num >> j) % 2
ans = 0
for b in range(60):
ans += cnt[b] * (n-cnt[b]) << b
ans %= MOD
print(ans)
|
p02556
|
s080906393
|
Accepted
|
n=int(input())
xy=[list(map(int,input().split()))for _ in range(n)]
xy1ma=-10**10
xy1mi=10**10
xy2ma=-10**10
xy2mi=10**10
for x,y in xy:
xy1ma=max(xy1ma,x-y)
xy1mi=min(xy1mi,x-y)
xy2ma=max(xy2ma,x+y)
xy2mi=min(xy2mi,x+y)
print(max(xy1ma-xy1mi,xy2ma-xy2mi))
|
p02742
|
s974711471
|
Wrong Answer
|
H, W = map(int, input().split())
if W % 2 == 1:
w = W // 2 + 1
ans = w * (H // 2) + (w - 1) * (H // 2)
if H % 2 == 1:
ans += w
print(ans)
else:
w = W // 2
ans = w * H
print(ans)
|
p03605
|
s960712666
|
Accepted
|
n=input()
print('Yes' if n[0]==str(9) or n[1]==str(9) else 'No')
|
p02582
|
s033877971
|
Wrong Answer
|
s = input()
ans = 0
for i in range(1,4):
p = "R"*i
if p in s:
ans = i
print(i+1)
|
p02639
|
s710438413
|
Accepted
|
X = map(int,input().split())
for i,x in enumerate(X):
if x == 0:
print(i+1)
|
p02705
|
s338708559
|
Accepted
|
r=int(input())
print(2*3.14*r)
|
p03285
|
s012086719
|
Accepted
|
n = int (input())
ans=0
for i in range (15):
for j in range (15):
if 4*i+7*j==n:
ans+=1
else:
ans+=0
if ans == 0:
print("No")
else:
print("Yes")
|
p02948
|
s290139923
|
Wrong Answer
|
def main():
from operator import itemgetter
n,m=map(int,input().split())
W=[list(map(int,input().split())) for _ in range(n)]
W.sort(key=itemgetter(1,0),reverse=True)
i,j,income=0,0,0
while i<m and j<n:
if W[i][0]+i<=m:
income+=W[i][1]
i+=1
j+=1
else:
j+=1
print(income)
if __name__=='__main__':
main()
|
p02687
|
s238700296
|
Wrong Answer
|
print('A%sC'%'BR'[id(id)%9%2])
|
p03239
|
s640230857
|
Accepted
|
N, T = map(int, input().split())
ans = 10000
for _ in range(N):
c, t = map(int, input().split())
if t <= T:
ans = min(ans, c)
print('TLE' if ans == 10000 else ans)
|
p02917
|
s905960165
|
Accepted
|
N = int(input())
B = list(map(int, input().split()))
ans = [0] * N
ans[0] = B[0]
ans[-1] = B[-1]
for i in range(1, N-1):
ans[i] = min(B[i], B[i-1])
print(sum(ans))
|
p02866
|
s557694426
|
Accepted
|
n=int(input())
d=list(map(int,input().split()))
mod=998244353
from collections import Counter
c=Counter(d)
if not(d[0]==0 and sorted(d)[1]!=0):
print(0)
exit()
d.sort()
ans=1
for i in range(1,d[-1]+1):
if c[i]==0:
ans*=0
else:
ans*=c[i-1]**c[i]
ans%=mod
print(ans)
|
p02717
|
s917119955
|
Accepted
|
a = list(map(int,input().split()))
print(a[2],a[0],a[1])
|
p02784
|
s963012994
|
Wrong Answer
|
# import itertools
# import math
def solve(H, N, A):
if (sum(A) > H):
return 'Yes'
return 'No'
# N = int(input())
# S = input()
H, N = map(int, input().split())
A = list(map(int, input().split()))
# P = []
# S = []
# for i in range(N):
# pp, ss = map(int, input().split())
# P.append(pp)
# S.append(ss)
print(solve(H, N, A))
|
p02753
|
s498569527
|
Accepted
|
s = list(input())
if s[0] == s[1] and s[1] == s[2]:
print('No')
else:
print('Yes')
|
p02756
|
s735227800
|
Accepted
|
from collections import deque
s = input()
q = int(input())
query = [input().split() for i in range(q)]
a = deque([s])
flag = True
for i in range(q):
if query[i][0] == "1":
flag = not(flag)
else:
if (query[i][1] == "1" and flag) or (query[i][1] != "1" and not(flag)):
a.appendleft(query[i][2])
else:
a.append(query[i][2])
b = "".join(a)
if not(flag):
b = b[::-1]
print(b)
|
p03360
|
s171002522
|
Accepted
|
a, b, c = map(int, input().split())
k = int(input())
print(a + b + c + (2**k - 1) * max(a, b, c))
|
p03723
|
s401406443
|
Accepted
|
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
def solve(a,b,c,counter=0):
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
return counter
elif a == b == c:
return -1
else:
return solve((b+c)//2,(c+a)//2,(a+b)//2,counter+1)
def main():
A, B, C = map(int,input().split())
print(solve(A,B,C))
if __name__ == '__main__':
main()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.