problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02866 | s403881394 | Wrong Answer | from collections import Counter
N = int(input())
D = list(map(int, input().split()))
c = Counter(D)
# 根は0である必要がある。
if not(0 in c):
print(0)
exit(0)
# N = 1の時は1
if N == 1:
print(1)
exit(0)
# 親の数*子の数を求める
parent = c[0]
ans = c[0]
for i in range(1, max(D)+1):
ans = (parent**c[i])*ans
parent = c[i]
print(ans % 998244353)
|
p02832 | s611649178 | Accepted | n = int(input())
a = list(map(int, input().split()))
num_looking_for = 1
cnt = 0
for i in range(n):
if a[i] == num_looking_for:
num_looking_for += 1
else:
cnt += 1
print("-1" if cnt == n else cnt) |
p03331 | s831732719 | Accepted | #!/usr/bin/env python3
def main():
N = int(input())
print(
min(
[
sum(list(map(int, str(i)))) + sum(list(map(int, str(N - i))))
for i in range(1, N)
]
)
)
main()
|
p02753 | s410158874 | Accepted | S = input()
if S[0] == 'A' and S[1] == 'A' and S[2] == 'A':
print('No')
elif S[0] == 'B' and S[1] == 'B' and S[2] == 'B':
print('No')
else:
print('Yes') |
p02755 | s458624106 | Accepted | a, b = map(int, input().split())
if a * 100 % 8 == 0:
low = max(a * 100 // 8, b * 10)
else:
low = max(a * 100 // 8 + 1, b * 10)
if 100 * (a + 1) % 8 == 0:
a_ = 100 * (a + 1) // 8 - 1
else:
a_ = 100 * (a + 1) // 8
high = min(a_, 10 * (b+1) -1)
if low <= high:
print(low)
else:
print(-1)
|
p02658 | s418798436 | Accepted | N=int(input())
a_list = list(map(int, input().split()))
if 0 in a_list:
print(0)
exit()
res = 1
for a in a_list:
res *= a
if res > 10**18:
print(-1)
exit()
print(res) |
p02618 | s263875897 | Wrong Answer | d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
last = [0] * 26
for di in range(d):
tmpl = [c[i] * (di + 1 - last[i]) for i in range(26)]
ti = tmpl.index(max(tmpl))
last[ti] = di + 1
print(ti)
|
p03437 | s693186454 | Accepted | x,y=map(int,input().split())
if x%y == 0:
print(-1)
else:
print(x) |
p03086 | s491888376 | Accepted | import sys
import re
S = input()
if not ( 1 <= len(S) <= 10 ): sys.exit()
if not S.isupper: sys.exit()
result = 0
max = max(re.findall('[A|T|G|C]+', S),key=len) if re.findall('[A|T|G|C]+', S) else ''
if len(max) > 0:result = len(max)
print(result) |
p02784 | s281030020 | Wrong Answer | H, N = map(int, input().split())
A = list(map(int, input().split()))
print(sum(A))
if sum(A) >= H:
print("Yes")
else:
print("No") |
p03637 | s330727002 | Wrong Answer | N = int(input())
A = list(map(int,input().split()))
four = 0
two = 0
for e in A:
if e%4 == 0:
four += 1
elif e %2 == 0:
two += 1
value = four * 3 + (two//2)*2
if value >= N:
print('Yes')
else:
print('No')
|
p04012 | s668269407 | Accepted | import sys
w = input()
d = {}
for c in range(97,97+26):
d[chr(c)]=0
for c in w:
d[c]+=1
for c in d.values():
if c%2 == 1:
print("No")
sys.exit()
print("Yes") |
p02766 | s740592324 | Accepted | n,k = map(int, input().split())
ans = 0
while n >= k**ans:
ans += 1
print(ans) |
p03219 | s239076586 | Wrong Answer | X, Y = map(int, input().split())
print(X+(Y/2)) |
p03555 | s517676116 | Wrong Answer | C1 = list(input())
C2 = list(input())
if C1[0] == C2[2] and C1[2] == C2[0] and C1[2] == C2[2]:
print("YES")
else:
print("NO") |
p02553 | s277850702 | Accepted | from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math
mod = 10**9+7
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
a = na()
ans = []
ans.append(a[0]*a[2])
ans.append(a[0]*a[3])
ans.append(a[1]*a[2])
ans.append(a[1]*a[3])
print(max(ans)) |
p02971 | s744481570 | Accepted | _,*a=map(int, open(0))
b=sorted(a)
for i in a:print(b[(i<b[-1])-2]) |
p02683 | s318445153 | Accepted | import numpy as np
n,m,x = map(int,input().split())
seen = []
ans = 10**7
for i in range(n):
seen.append(list(map(int,input().split())))
for i in range(2**n):
temp = 0
base = np.zeros(m)
for j in range(n):
if (i>>j)&1:
for k in range(m):
base[k] += seen[j][k+1]
temp += seen[j][0]
if (np.min(np.where(base >= x,1,0)) == 1) and (ans > temp):
ans = temp
if ans == 10**7:
ans = -1
print(ans) |
p03103 | s010617595 | Accepted | N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
sAB = sorted(AB, key=lambda x: x[0])
ans = 0
cnt = 0
last_cnt = 0
for a, b in sAB:
cnt += b
if cnt < M:
ans += a*b
last_cnt = cnt
else:
ans += a*(M-last_cnt)
break
print(ans)
|
p03286 | s570203625 | Wrong Answer | n = int(input())
ans = ""
while n != 0:
rest = n % 2
if rest == 1:
ans += "1"
else:
ans += "0"
n = (n - rest) // -2
if ans == "":
ans += "0"
print(ans) |
p03699 | s845453769 | Wrong Answer | n = int(input())
s = [int(input()) for _ in range(n)]
d = sum(s)
result = 0
if d % 10 == 0:
for i in s:
if (d-i) % 10 != 0:
result = d-i
break
else:
d = d-i
else:
result = d
print(result) |
p02631 | s005190780 | Accepted | def main():
n=int(input())
a = list(map(int, input().split()))
ans = [0] * n
base = xor(a)
for i in range(len(a)):
ans[i] = base ^ a[i]
print(*ans)
def xor(x):
r = 0
for i in x:
r ^= i
return r
if __name__ == '__main__':
main() |
p03759 | s754838203 | Wrong Answer | # 入力
a, b, c = map(int, input().split())
# 処理&出力
if b-a == c-b:
print('Yes')
else:
print('No') |
p02780 | s930248016 | Accepted | from itertools import accumulate
N, K, *P = map(int, open(0).read().split())
E = [(p + 1) for p in P]
A = [0] + list(accumulate(E))
print("{:.8f}".format(max(A[i + K] - A[i] for i in range(N - K + 1)) / 2))
|
p02724 | s627807435 | Accepted | def resolve():
x=int(input())
ans=0
while x>=500:
x-=500
ans+=1000
while x>=5:
x-=5
ans+=5
print(ans)
resolve() |
p02787 | s948267971 | Accepted | H,N = [int(i) for i in input().split()]
AB = [[int(i) for i in input().split()] for j in range(N)]
DP = [10000000000]*(H+1)#DP[h] = 体力をh削るのに必要な魔力のmin
DP[0] = 0
for h,curmp in enumerate(DP):
for a,b in AB:
goal = min(h+a,H)
DP[goal] = min(DP[goal],curmp+b)
print(DP[-1]) |
p03327 | s953535512 | Wrong Answer | n=int(input())
if n<1000:
n_s=str(n).zfill(3)
print("ABC"+n_s)
else:
n=n%1000+1
n_s=str(n).zfill(3)
print("ABD"+n_s) |
p03745 | s597432737 | Wrong Answer | p = -1
xp = -1
ans = 1
input()
for i in input().split(" "):
i = int(i)
if i == p: continue
if p != -1:
x = p < i
if xp != -1:
ans += x != xp
if xp != -1 and x != xp:
xp = -1
else:
xp = x
print(x)
p = i
print(ans)
|
p02784 | s367720067 | Accepted | h, n = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) >= h:
print('Yes')
else:
print('No') |
p03612 | s008014365 | Wrong Answer | N=int(input())
P=list(map(int,input().split()))
#S="".join("x" if P[i]==i+1 else "o" for i in range(N))
S=["x" if P[i]==i+1 else "o" for i in range(N)]
count=0
for j in range(N-1):
if S[j]=="x":
S[j]="o"
if S[j+1]=="x":
S[j+1]="o"
count+=1
print(count) |
p03109 | s286974616 | Accepted | #copy
y, m, d = map(int, input().split("/"))
print("Heisei" if m <= 4 else "TBD") |
p04030 | s434229636 | Wrong Answer | y=""
a=str(input())
print(len(a))
for i in range (len(a)):
if a[i]=="B":
y=y[:-1]
else:
y=y+a[i]
print(y) |
p04005 | s218347648 | Wrong Answer | A, B, C = map(int,input().split())
tmp1 = A * B
tmp2 = C // 2
tmp3 = C - tmp2
ans = tmp1 * tmp3 - tmp1 * tmp2
print(ans) |
p03323 | s907319889 | Accepted | a, b = map(int, input().split())
if a < 9 and b < 9:
print("Yay!")
else:
print(":(") |
p03012 | s650553560 | Accepted | N = int(input())
Ws = list(map(int, input().split()))
ans = sum(Ws)
for i in range(1, N):
sum1 = sum(Ws[:i])
sum2 = sum(Ws[i:])
diff = abs(sum1-sum2)
ans = min(ans, diff)
print(ans)
|
p02797 | s015842135 | Accepted | N,K,S = map(int,input().split())
if S!=10**9:
for i in range(K):
print(S)
for i in range(N-K):
print(S+1)
else:
for i in range(K):
print(S)
for i in range(N-K):
print(3)
|
p02661 | s656423704 | Accepted | n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
a, b = map(list, zip(*ab))
a.sort()
b.sort()
if n % 2:
i = (n + 1) // 2 - 1
mn = a[i]
mx = b[i]
else:
i1, i2 = n // 2 - 1, n // 2
mn = a[i1] + a[i2]
mx = b[i1] + b[i2]
ans = mx - mn + 1
print(ans)
|
p02657 | s046025340 | Accepted | # 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)
# 受け取った入力値を使い、適切に処理(計算)する
answer = a * b
# 計算した結果を出力する
print(answer) |
p02923 | s341600692 | Accepted |
def main():
n = int(input())
h = list(map(int, input().split()))
ans = 0
count = 0
for i in range(0, n-1):
if h[i] >= h[i+1]:
count += 1
# print(count, h[i], h[i+1])
else:
count = 0
if count > ans:
ans = count
print(ans)
if __name__ == '__main__':
main()
|
p02923 | s834469579 | Accepted | n = int(input())
hl = list(map(int, input().split()))
move = 0
tmp = 0
for i in range(n-1):
if hl[i] >= hl[i+1]:
tmp += 1
else:
tmp = 0
if move < tmp:
move = tmp
print(move)
|
p03471 | s054316931 | Accepted | N, Y = map(int, input().split())
for x in range(N+1):
for y in range(N+1):
if 10000*x + 5000*y + 1000*(N-(x+y)) == Y and N-(x+y) >= 0:
print(x, y, N-(x+y))
exit()
print(-1,-1,-1) |
p03416 | s716384499 | Accepted | #
# import sys
# input=sys.stdin.readline
def main():
A,B=map(int,input().split())
cnt=0
for i in range(A,B+1):
s=str(i)
if s==s[::-1]:
cnt+=1
print(cnt)
if __name__=="__main__":
main()
|
p02683 | s075162403 | Accepted | n,m,x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]
prices = []
for i in range(2**n):
buy = [[] for _ in range(m+1)]
for j in range(n):
if ((i >> j) & 1):
for k in range(m+1):
buy[k].append(c[j][k])
for k in range(1,m+1):
if sum(buy[k]) < x:
break
else:
prices.append(sum(buy[0]))
if len(prices) == 0:
print(-1)
else:
print(min(prices)) |
p02823 | s134907295 | Accepted | n, a, b = map(int,input().split())
if a % 2 == b % 2:
print((b-a)//2)
else:
ans = min(n-b, a-1) + 1 + (b-a-1)//2
print(ans) |
p02720 | s256082633 | Wrong Answer | def isLun(n):
n = list(map(int, list(str(n))))
l = [abs(n[i+1]-n[i]) for i in range(len(n)-1)]
if set(l) == set([1]) or set(l) == set([0]) or len(n)==1:
return True
else:
return False
n = int(input())
lun, ctr, i = 1, 1, 1
while ctr<=n:
if isLun(i):
lun=i
ctr+=1
i+=1
print(lun)
|
p02572 | s626171161 | Accepted | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
K = int(1e9)+7
acum = [0]
for i in range(N):
acum.append(acum[i]+A[i])
ans = 0
for i in range(N):
ans += A[i]*(acum[N]-acum[i+1])
ans %= K
print(ans)
if __name__ == '__main__':
main()
|
p03042 | s380698975 | Accepted | S = input()
A, B = int(S[:2]), int(S[2:])
x = 0 <= A <= 99 and 1 <= B <= 12
y = 1 <= A <= 12 and 0 <= B <= 99
if x and y:
print('AMBIGUOUS')
elif x:
print('YYMM')
elif y:
print('MMYY')
else:
print('NA')
|
p02982 | s184086548 | Accepted | import math
N, D = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]
seisu_count = 0
for l in range(N):
for r in range(l+1, N):
total = 0
for z in range(D):
y_z = abs(X[l][z] - X[r][z])
y_z_2 = y_z * y_z
total += y_z_2
sqr_total = math.sqrt(total)
if sqr_total.is_integer():
seisu_count += 1
print(seisu_count) |
p02730 | s161980347 | Accepted | s = input()
n = len(s)
ans = 0
s1 = s[:int((n - 1) / 2)]
s2 = s[int((n + 3) / 2) - 1:]
s5 = s[::-1]
s3 = s1[::-1]
s4 = s2[::-1]
#print(s5, s3, s4)
if s1 == s3:
ans += 1
if s2 == s4:
ans += 1
if s == s5:
ans += 1
if ans == 3:
print('Yes')
else:
print('No')
|
p04031 | s406984053 | Accepted | n = int(input())
arr = list(map(int, input().split()))
mini = min(arr)
maxi = max(arr)
cost = 10000000000
for i in range(-100, 101+1):
add = 0
for j in range(n):
add = add + (arr[j] - i)**2
cost = min(cost, add)
print(cost) |
p02744 | s586609774 | Wrong Answer | n = int(input())
candidate = ['a']
def dfs(s, c):
if len(s) == n:
return
candidate.append(s + c)
candidate.append(s + chr(ord(c) + 1))
dfs(s + c, c)
dfs(s + chr(ord(c) + 1), chr(ord(c) + 1))
dfs('a', 'a')
for c in candidate:
if len(c) == n:
print(c)
|
p03680 | s313291278 | Wrong Answer | lst = [int(input()) for i in range(int(input()))]
index = 0
count = 0
a = -1
while True:
index = lst[index] - 1
if index == 0:
break
elif index == 1:
a = count
else:
count += 1
print(a) |
p03779 | s656663518 | Accepted | x = int(input())
for t in range(1000000000):
if 2 * x <= t * (t + 1):
print(t)
break |
p03998 | s402507951 | Wrong Answer | A = list(input())
B = list(input())
C = list(input())
A.append("0")
B.append("0")
C.append("0")
x = A[0]
del A[0]
while x != "0":
if x == "a":
x = A[0]
del A[0]
elif x == "b":
x = B[0]
del B[0]
else:
x = C[0]
del C[0]
print(A,B,C,x)
if "0" not in A:
print("A")
elif "0" not in B:
print("B")
else:
print("C") |
p02743 | s626585723 | Wrong Answer | from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
a,b,c = inpl()
x = 4 * a * b
y = a**2 + b**2 + c**2 - (a*c-a*b+b*c)*2
if x-y < 0:
print('Yes')
else:
print('No')
|
p03673 | s966171707 | Wrong Answer | from collections import deque
n = int(input())
arr = list(map(int, input().split()))
d = deque()
for i, v in enumerate(arr):
i += 1
if n % 2:
if i % 2:
d.append(v)
else:
d.appendleft(v)
else:
if i % 2:
d.append(v)
else:
d.appendleft(v)
print(*d) |
p02972 | s705776757 | Accepted | n=int(input())
A=list(map(int,input().split()))
choice=[0]*n
ans=[]
cnt=0
for i in range(n-1,-1,-1):
a=i+1
c=0
a+=i+1
while a<=n:
c+=choice[a-1]
a+=i+1
if c%2!=A[i]:
choice[i]+=1
ans.append(i+1)
cnt+=1
if cnt==0:
print(0)
else:
print(cnt)
ans.sort()
print(*ans, sep=' ') |
p02646 | s507339540 | Wrong Answer | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
cnt = 0
for tt in range(1, t + 1):
res = (w - v) * tt + (b - a)
if res == 0:
cnt = 1
if a >= b and w >= v:
cnt = 0
if cnt == 1:
print('YES')
else:
print('NO')
|
p03407 | s204448052 | Accepted | a, b, c = map(int, input().split())
if a + b >= c:
print('Yes')
else:
print('No') |
p02596 | s622572697 | Wrong Answer | # coding: utf-8
import numpy as np
k = int(input())
s = 0
cnt = 0
flg = False
while (cnt < 1e7):
cnt += 1
print(cnt)
s = s * 10 + 7
# print(s)
if s % k == 0:
flg = True
break
if k < 7:
flg = False
break
if k % 2 == 0:
flg = False
break
if flg == True:
print(cnt)
else:
print(-1) |
p03796 | s865997958 | Accepted | import math
a = int(input())
print(math.factorial(a)%(10**9+7)) |
p02641 | s911449843 | Wrong Answer | import sys
x, n = map(int, input().split())
if n == 0:
print(x)
sys.exit()
if n == 1:
print(abs(x - int(input())))
sys.exit()
p = list(map(int, input().split()))
p.sort()
min = [100, 100]
for i in range(100):
if i in p:
continue
hoge = abs(x - i)
if min[0] > hoge:
min[0] = hoge
min[1] = i
print(min[1])
|
p02664 | s447387479 | Accepted | T = input()
N = len(T)
res = []
for t in T:
if t == "P":
res.append("P")
else:
res.append("D")
print("".join(map(str, res)))
|
p02612 | s653535346 | Accepted | n = int(input())
if n % 1000 == 0:
print(0)
else:
print(((n // 1000 + 1) * 1000) - n)
|
p02696 | s673501845 | Accepted | def f(x):
return (A*x)//B-A*(x//B)
A, B, N = map(int, input().split())
print(f(min(B-1, N))) |
p03472 | s479616219 | Wrong Answer | N, H = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ans = 0
attack = []
for a, b in ab:
attack += [[a, 0]]
attack += [[b, 1]]
attack = sorted(attack, key=lambda x:(-x[0], -x[1]))
for a, i in attack:
if i == 1:
H -= a
ans += 1
else:
if H <= 0:
break
cnt = (H-1)//a + 1
ans += cnt
break
print(ans) |
p04011 | s477374722 | Wrong Answer | n = int(input())
k = int(input())
x = int(input())
y = int(input())
a = 0
b = 0
c = 0
e = 0
if n <= k:
a = n * x
else:
c = n - k
b = c * y
e = a + b
print(e) |
p03481 | s319185666 | Wrong Answer | X,Y = map(int,input().split())
y_end = Y - Y%X
count = 0
while X <= y_end:
print(X)
count += 1
X *= 2
print(count) |
p02947 | s846187492 | Wrong Answer | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int( input() )
dict_all = {}
for nn in range(N):
text = ''.join( sorted( str( input() ) ) )
if( text in dict_all ):
dict_all[text] += dict_all[text] + 1
else:
dict_all[text] = 0
count = 0
for key in dict_all:
count += dict_all[key]
print(count)
|
p02615 | s098901771 | Accepted | n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
ans=0+a[0]
cnt=1
for i in range(1,n):
if cnt<n-2:
ans+=2*a[i]
cnt+=2
elif cnt==n-2:
ans+=a[i]
break
elif cnt==n-1:
break
print(ans) |
p02663 | s553314617 | Accepted | h1,m1,h2,m2,k=map(int,input().split())
print((h2-h1)*60+m2-m1-k) |
p03284 | s845978696 | Accepted | n,k=map(int,input().split())
if n%k==0:
print(0)
else:
print(1) |
p03239 | s571635215 | Accepted | n,T=map(int,input().split())
C=[]
for i in range(n):
c,t=map(int,input().split())
if t<=T:
C.append(c)
if len(C)>0:
print(min(C))
else:
print("TLE") |
p02995 | s559053010 | Accepted | a, b, c, d = map(int, input().split())
import math
g = math.gcd(c, d)
l = int(c * d / g)
less_b = b - (b // c + b // d - b // l)
less_a = (a-1) - ((a-1)//c + (a-1) // d - (a-1)//l)
print(less_b-less_a) |
p03699 | s538386214 | Accepted | N = int(input())
S = []
for _ in range(N):
S.append(int(input()))
s = sum(S)
if s % 10 != 0:
print(s)
else:
S.sort()
for i in S:
if i % 10 != 0:
s -= i
break
if s % 10 == 0:
print(0)
else:
print(s) |
p03495 | s801974728 | Wrong Answer | N, K = map(int, input().split())
*A, = map(int, input().split())
d = [0]*(N+1)
for a in A:
d[a] += 1
d.sort()
d.reverse()
print(sum(d[K:]))
|
p03319 | s158093138 | Accepted | n, k = map(int, open(0).readline().split())
print((n - 2) // (k - 1) + 1) |
p02693 | s321722208 | Accepted | #!/usr/bin/python
# -*- coding: utf-8 -*-
K = int(input())
A, B = map(int,input().split())
if A%K == 0:
print('OK')
elif K*(A//K+1) <= B:
print('OK')
else:
print('NG')
|
p02744 | s384596712 | Wrong Answer | import sys
from string import ascii_lowercase
alphs = list(ascii_lowercase)
n = int(sys.stdin.readline().rstrip())
def main():
cur = ['a']
for _ in range(n-1):
nex = []
for c in cur:
i = ord(c[-1]) - 97
for al in alphs[:i+2]:
nex.append(c + al)
cur = nex
return sorted(cur)
if __name__ == "__main__":
ans = main()
print(*ans, sep='\n') |
p03252 | s062614597 | Wrong Answer | s = input()
t = input()
li_s = list(s)
li_t = list(t)
ma = {}
for i,j in zip(li_s,li_t):
if j not in ma:
ma[j] = i
elif ma[j] != i:
print('No')
exit()
print('Yes') |
p04034 | s500562618 | Wrong Answer | # AtCoder Grand Contest 002 B
N,M = map(int,input().split())
xn = [0] * M
yn = [0] * M
for i in range(M):
xn[i],yn[i] = map(int,input().split())
if 1 not in xn:
print(1)
exit()
a = [1]
count = 0
for i in range(M):
if xn[i] in a:
count +=1
a.append(yn[i])
print(count) |
p02708 | s574220457 | Accepted | N, K = map(int, input().split())
m = 1000000007
result = 0
for i in range(K, N + 2):
# max: N, N -1, ..., N - i + 1
a = (N + (N - i + 1)) * i // 2
# min: 0, 1, .., i - 1
b = (0 + (i - 1)) * i // 2
result += a - b + 1
result %= m
print(result)
|
p02951 | s836305486 | Accepted | A, B, C = map(int, input().split())
print(C-(A-B) if C-(A-B)>=0 else 0)
|
p02778 | s359971597 | Accepted | S = input()
for i in range(len(S)):
print('x', end='')
print() |
p03243 | s678772857 | Wrong Answer | N = int(input())
if N < 111:
print(111)
elif N < 222:
print(222)
elif N < 333:
print(333)
elif N < 444:
print(444)
elif N < 555:
print(555)
elif N < 666:
print(666)
elif N < 777:
print(777)
elif N < 888:
print(888)
else:
print(999) |
p03095 | s366766951 | Accepted | n=int(input())
s=input()
mod=10**9+7
from collections import Counter
c=list(Counter(s).values())
ans=1
for i in c:
ans*=(i+1)
print((ans-1)%mod)
|
p04029 | s454293816 | Accepted | N=int(input() )
print( int(N*(N+1)/2) ) |
p04019 | s502526798 | Accepted | s = input()
kita, minami = sorted([s.count('N'),s.count('S')])
nisi, higasi = sorted([s.count('W'),s.count('E')])
result = ['No','Yes']
r = 1
if kita==minami or kita*minami > 0:
r *= 1
else:
r = 0
if nisi==higasi or nisi*higasi > 0:
r *= 1
else:
r = 0
print(result[r]) |
p03105 | s534771410 | Wrong Answer | A, B, C = map(int, input().split())
print(C if A * C >= B else B // A) |
p03030 | s428438800 | Accepted | N=int(input())
S=[[] for i in range(N)]
for i in range(N):
s,p=map(str,input().split())
S[i]=[s,int(p)*(-1),i]
S.sort(key=lambda x:(x[0],x[1]))
for i in range(N):
print(S[i][2]+1) |
p03836 | s780205322 | Wrong Answer | SX, SY, TX, TY = map(int, input().split())
way1 = 'U' * (TX - SX) + 'R' * (TY - SY)
way2 = 'D' * (TX - SX) + 'L' * (TY - SY)
way3 = 'L' + 'U' * (TX - SX + 1) + 'R' * (TY - SY + 1) + 'D'
way4 = 'R' + 'D' * (TX - SX + 1) + 'L' * (TY - SY + 1) + 'U'
print(way1 + way2 + way3 + way4)
|
p03449 | s056753319 | Accepted | n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
ans = 0
for i in range(n):
x = 0
row = 0
for j in range(n):
x += a[row][j]
if i == j:
row += 1
x += a[row][j]
ans = max(ans, x)
print(ans)
|
p04045 | s804608082 | Wrong Answer | import itertools
N,K=map(int,input().split())
D=set(int(x) for x in input().split())
T=set(range(10))-D
answer=100000
for x in itertools.product(T,repeat=5):
p=0
for i in range(5):
p +=x[i]*10**i
if p>=N:
answer=min(p,answer)
print(answer) |
p03943 | s649932303 | Accepted | l = sorted(list(map(int, input().split())))
if l[0]+l[1] == l[2]:
print("Yes")
else:
print("No")
|
p02633 | s633991341 | Wrong Answer | from math import gcd
def resolver(X):
if 360 % X == 0:
return 360 // X
ans = 360 * X // gcd(360, X)
return ans
def main():
X = int(input())
ans = resolver(X)
print(ans)
if __name__ == '__main__':
main()
|
p02779 | s010120947 | Accepted | n = int(input())
alist = list(map(int,input().split()))
aset = set(alist)
if len(alist) == len(aset):
print("YES")
else:print("NO")
|
p03637 | s323412834 | Accepted | n = int(input().strip())
a = list(map(int, input().split()))
two = 0
four = 0
for e in a:
if e % 4 == 0:
four += 1
elif e % 2 == 0:
two += 1
if (n - two <= 2 * four) or (two == 0 and n <= (2 * four + 1)):
print("Yes")
else:
print("No")
|
p03555 | s660730358 | Accepted | def main():
s1 = input()
s2 = input()
s2 = s2[::-1]
print('YES' if s1 == s2 else 'NO')
if __name__ == '__main__':
main() |
p02957 | s112820496 | Wrong Answer | A, B = [int(x) for x in input().split(" ")]
if (A+B)%2 == 0:
print(int((A+B)/2))
else:
print("INPOSSIBLE")
|
p03803 | s900107490 | Wrong Answer | a,b = map(int,input().split())
if a==b:
print('Draw')
elif a==1 or a>b:
print('Alice')
elif b==1 or b>a:
print('Bob')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.