problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02843 | s538338553 | Accepted | X = int(input())
# とりあえず 100 で構成しようとして、余剰分を 100 を置換することで構成できないか調べる
q, r = X//100, X%100
if r <= 5 * q:
print(1)
else:
print(0)
|
p03624 | s936737600 | Wrong Answer | s=input()
ans=1
all="abcdefghijklmnopqrstuvwxyz"
for i in all:
if i not in s:
print(i)
ans=0
if ans==1:
print("None") |
p02996 | s500593200 | Accepted | import numpy as np
N = int(input())
AB = ['']*N
for i in range(N):
AB[i] = list(map(int, input().split()))
#AB = np.array(AB)
AB = sorted(AB, key=lambda x: x[1])
#print(AB)
total = 0
flag = 1
for i in range(N):
total += AB[i][0]
if total > AB[i][1]:
flag = 0
break
if flag == 1:
print('Yes')
else:
print('No') |
p03211 | s559403436 | Wrong Answer | s=input()
ans=1000
for i in range(len(s)-3):
ans=min(ans,abs(753-int(s[i:i+3])))
print(ans) |
p02963 | s537747683 | Accepted | S = int(raw_input())
X1 = 0
Y1 = 0
X2 = 10**9
Y2 = 1
mod = 10**9
if S%mod == 0:
X3 = 0
Y3 = S/mod
else:
Y3 = S/mod + 1
X3 = mod - S%mod
print X1, Y1, X2, Y2, X3, Y3
|
p03592 | s650185518 | Wrong Answer | n,m,k = [int(x) for x in input().split()]
ans = "No"
for i in range(n):
for j in range(m):
if i * (m-j) + j * (m-i) == k:
ans = "Yes"
break
print(ans) |
p03359 | s731453150 | Accepted | #!/usr/bin/env python3
def main():
a, b = map(int, input().split())
if b < a:
print(a - 1)
else:
print(a)
if __name__ == "__main__":
main()
|
p03548 | s537964725 | Wrong Answer | def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
x,y,z = iim()
print(x//(z+y))
|
p02726 | s772768976 | Wrong Answer | N,X,Y = map(int,input().split())
length = [0]*(N+1)
for i in range(1,N+1):
for j in range(i,N+1):
ans = min(abs(j-i),abs(X-i)+1+abs(Y-j),abs(X-j)+1+abs(Y-i))
length[ans] += 1
for i in range(1,N+1):
print(length[i]) |
p03013 | s092057288 | Accepted | ### 動的計画法
#ABC129C - Typical Stairs
#https://atcoder.jp/contests/abc129/tasks/abc129_c
mod = 10**9+7
n, m = list(map(int,input().split()))
a = [int(input()) for _ in range(m)]
dp = [float("Inf")]*(n+1)
for i in range(m):
dp[a[i]] = 0
dp[0] = 1
if dp[1] == float("Inf"):
dp[1] = 1
for i in range(2,n+1):
if dp[i] == float("Inf"):
dp[i] = dp[i-1] + dp[i-2]
print(dp[n]%mod) |
p03239 | s614371348 | Accepted | n,t=map(int,input().split())
ans=1000000
for i in range(n):
x,y=map(int,input().split())
if y<=t:
ans=min(ans,x)
if ans<=100000:
print(ans)
else:
print("TLE") |
p03544 | s183710873 | Accepted | n = int(input())
l = [2,1]
if n==1:
print(l[1])
else:
c = 2
while(c<=n):
l.append(sum(l[-2:]))
c+=1
print(l[-1]) |
p03106 | s502804980 | Accepted | a, b, k = map(int, input().split())
num = min(a, b)
cnt = 0
while cnt < k:
if a%num == 0 and b%num == 0:
cnt += 1
num -= 1
else:
num -= 1
print(num + 1) |
p03479 | s389096727 | Accepted | X,Y = map(int,input().split())
ans = []
ans.append(X)
while max(ans)*2 <= Y:
ans.append(max(ans)*2)
print(len(ans))
|
p02801 | s568456831 | Wrong Answer | print(chr(ord(input()))) |
p02606 | s844175064 | Accepted | import math
L, R, d = map(int, input().split())
l = math.ceil(L / d)
r = math.floor(R / d)
print(r - l + 1) |
p02548 | s460780360 | Accepted | import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
N = int(input())
def solve():
cnt = 0
for i in range(1, N):
cnt += (N-1)//i
print(cnt)
return 0
if __name__ == "__main__":
solve()
|
p03474 | s590660231 | Accepted | a,b=map(int,input().split())
s=input()
flag=True
for i in range(0,a+b+1):
if i<a and not s[i].isdecimal():
flag=False
break
elif i==a and not s[i]=="-":
flag=False
break
elif a<i and not s[i].isdecimal():
flag=False
break
if flag:
print("Yes")
else:
print("No")
|
p03417 | s297423853 | Accepted | a,b=map(int,input().split())
if min(a,b)==1:
if a==1 and b==1:
print(1)
else:
print(max(a,b)-2)
else:
print((a-2)*(b-2)) |
p03795 | s194456332 | Wrong Answer | i=int(input())
x=20*i
y=(i//15)*200
print(x-y) |
p02719 | s568531628 | Wrong Answer | n,k = map(int,input().split())
def gcd(a,b):
b,a = sorted([a,b])
while(b!=0):
save = b
b = a%b
a = save
return a
if(n%k==0):
print(0)
else:
print(gcd(n,k))
|
p02642 | s743954675 | Wrong Answer | n=int(input())
a=list(map(int,input().split()))
from collections import Counter
seta=set(a)
ca=dict(Counter(a))
a=[k for k,v in ca.items() if v==1]
if len(a)==0:
print(0)
exit()
a.sort()
maxa=a[-1]
for ai in a:
i=2
while maxa>=i*ai:
seta.discard(i*ai)
i+=1
print(len(seta))
|
p02639 | s842367274 | Wrong Answer | X=list(map(int,input().split()))
for x in enumerate(X):
if x[1]==0:
print(x[0])
break |
p03645 | s028331984 | Wrong Answer |
def main():
n,m = map(int,input().split())
ab = [[0] * n for i in range(n)]
for _ in range(m):
a,b = map(int,input().split())
ab[a-1][b-1] = 1
for mid in range(1,n):
if ab[0][mid] == 1 and ab[mid][n-1] == 1:
return
print('IMPOSSIBLE')
if __name__ == '__main__':
main()
|
p03419 | s383242332 | Wrong Answer | n,m=map(int,input().split())
if n==1 or m==1:
print(max(0,max(n,m)-2))
else:
print((n-2)*(m-2)) |
p02623 | s581520167 | Accepted | N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
t = sum(B)
j = M
for i in range(N+1):
while j > 0 and t > K:
j -= 1
t -= B[j]
if t > K:
break
ans = max(ans, i+j)
if i == N:
break
t += A[i]
print(ans) |
p02761 | s330068910 | Wrong Answer | n,m=[int(i) for i in input().split()]
s=['*']*n
flag=0
for i in range(m):
a,b=[int(i) for i in input().split()]
if(s[a-1]=='*'):
s[a-1]=str(b)
else:
if(s[a-1]!=str(b)):
flag=1
for i in range(0,len(s)):
if(s[i]=='*'):
s[i]='0'
e=''
for i in range(0,len(s)):
e=e+s[i]
e=int(e)
if(len(str(e))!=n or flag==1):
print(-1)
else:
print(e) |
p04012 | s181519112 | Wrong Answer | w = list(map(str,input()))
w_ord = []
for i in range(len(w)):
w_ord.append(ord(w[i]))
w_ord.sort()
j = 1
if len(w) % 2 == 1:
print("NO")
else:
for i in range((len(w)+1)//2):
if not w_ord[2*i] == w_ord[2*i + 1]:
print("NO")
break
else:
if i == (len(w)+1)//2 -1:
print("YES")
|
p02707 | s961071090 | Accepted | import numpy as np
def calculate_num_boss(num_person, boss):
boss_count = np.zeros([num_person])
result, num = np.unique(boss, return_counts=True)
for idx in range(result.shape[0]):
ids = result[idx]
boss_count[ids-1] = num[idx]
return boss_count
if __name__ == "__main__":
num_person = int(input().split()[0])
bosses = np.array([int(i) for i in input().split()])
count = calculate_num_boss(num_person, bosses)
for i in count:
print(int(i)) |
p03339 | s610889173 | Accepted | from itertools import accumulate
n = int(input())
s = list(input())
l = [1 if s[i] == "E" else 0 for i in range(n)]
l = list(accumulate(l))
ans = l[-1]-l[0]
for i in range(1, n):
ans = min(ans, i-l[i-1] + l[-1]-l[i])
print(ans) |
p03633 | s937672718 | Accepted | import fractions
n = int(input())
t = [int(input()) for _ in range(n)]
ans = t[0]
for i in range(1,n):
ans = ans * t[i] // fractions.gcd(ans, t[i])
print(ans) |
p03639 | s940175603 | Wrong Answer | n = int(input())
a = list(map(int, input().split()))
cnt4,cnt2=0,0
for i in a:
if i % 4 == 0:
cnt4 += 1
elif i % 2 == 0:
cnt2 += 1
cnt2 = max(1,cnt2)
print('Yes' if 2 * cnt4 + cnt2 == n else 'No') |
p02600 | s770776993 | Accepted | X = int(input())
if 400 <= X < 600:
print(8)
elif 600 <= X < 800:
print(7)
elif 800 <= X < 1000:
print(6)
elif 1000 <= X < 1200:
print(5)
elif 1200 <= X < 1400:
print(4)
elif 1400 <= X < 1600:
print(3)
elif 1600 <= X < 1800:
print(2)
elif 1800 <= X < 2000:
print(1) |
p02659 | s709649504 | Accepted | from math import floor
from decimal import Decimal
A,B=input().split()
A=int(A)
B=Decimal(B)
print(int(A*B)) |
p02819 | s022862723 | Accepted | x = int(input())
isPrime = False
def isP(num):
for i in range(2, num):
if num % i == 0:
return False
return True
isPrime = isP(x)
if isPrime:
print(x)
else:
while isPrime == False:
x += 1
isPrime = isP(x)
print(x)
|
p02720 | s283450191 | Accepted | from collections import deque
K = int(input())
lunlun = deque()
for i in range(1, 10):
lunlun.append(i)
for i in range(K - 1):
x = lunlun[0]
lunlun.popleft()
if x % 10 != 0:
res = 10 * x + x % 10 - 1
lunlun.append(res)
res = 10 * x + x % 10
lunlun.append(res)
if x % 10 != 9:
res = 10 * x + x % 10 + 1
lunlun.append(res)
print(lunlun[0]) |
p03543 | s524729881 | Wrong Answer | n = list(input())
n = set(n)
if len(n) <= 2:
print('Yes')
else:
print('No')
|
p02861 | s739416826 | Accepted | import itertools
import math
N = int(input())
ls = []
ans = 0
for i in range(N):
x,y = map(int,input().split())
ls.append([x,y])
ls2 = []
for i in itertools.permutations(ls,N):
ls2.append(list(i))
for i in range(math.factorial(N)):
ls3 = ls2[i]
now_x = ls3[0][0]
now_y = ls3[0][1]
for j in range(1,N):
ans += ((now_x - ls3[j][0])**2 + (now_y - ls3[j][1]) ** 2)**0.5
now_x = ls3[j][0]
now_y = ls3[j][1]
print(ans/math.factorial(N)) |
p02935 | s232450480 | Accepted | N = int(input())
V = list(map(int, input().split()))
V = sorted(V)
ans = (V[0]+V[1])/2
for i in range(2,N):
ans = (ans + V[i])/2
print(ans)
|
p04031 | s094805594 | Wrong Answer | N = int(input())
l = [int(x) for x in input().split()]
cost = 1000000000000
for i in range(0,7):
co = 0
for j in range(N):
co += (i - l[j]) ** 2
if cost > co:
cost = co
print(cost) |
p03107 | s941643704 | Accepted |
S = input()
num_0 = S.count("0")
num_1 = S.count("1")
print(2 * min(num_0, num_1))
|
p03657 | s758239516 | Accepted | # -*- coding: utf-8 -*-
"""
Created on Thu May 14 12:29:30 2020
@author: shinba
"""
a,b = map(int,input().split())
if a % 3 == 0:
print("Possible")
elif b % 3 == 0:
print("Possible")
elif (a+b) % 3 == 0:
print("Possible")
else:
print("Impossible")
|
p02622 | s633323788 | Accepted | S=input()
T=input()
N=len(S)
s=list(S)
t=list(T)
count=0
for i in range(N):
if s[i]!=t[i]:
count+=1
print(count) |
p03681 | s450435551 | Accepted | N,M=map(int,input().split())
MOD=10**9+7
if abs(N-M)>1:
print(0)
exit()
fn=1
for n in range(2,min(N,M)+1):
fn=fn*n%MOD
fx=fn
ans=1
if N==M:
ans*=2
else:
fx=fx*max(N,M)%MOD
print(ans*fn*fx%MOD)
|
p02659 | s711764114 | Accepted | a = input().split()
for i in range(2):
a[i] = int(a[i]) if i == 0 else round(float(a[i])*100)
print(int(a[0] * a[1] // 100))
|
p02818 | s900974990 | Accepted | A, B, K = map(int, input().split())
if A >= K:
A = A - K
elif A < K:
B = B - (K - A)
A = 0
print('{} {}'.format(A, max(0, B))) |
p02687 | s975857831 | Accepted | S = input()
print('ABC' if S == 'ARC' else 'ARC')
|
p03474 | s709781149 | Accepted | a,b=map(int,input().split())
s=input()
tmp1=s[:a]
tmp2=s[a]
tmp3=s[a+1:]
if all([tmp1[i]!='-' for i in range(len(tmp1))])==True and tmp2=='-' and all([tmp3[i]!='-' for i in range(len(tmp3))])==True:
print('Yes')
else:
print('No') |
p02702 | s132139886 | Accepted | S = input()
MOD =2019
count = [0]*MOD
r = 0
t = 1
for i in reversed(S):
r += int(i) * t
r %= MOD
t *= 10
t %= MOD
count[r] += 1
count[0] += 1
print(int(sum(i*(i-1)/2 for i in count))) |
p03241 | s947555972 | Accepted | def divisors(n):
res = []
for i in range(1, int(n ** 0.5) + 1):
if n % i == 0:
res.append(i)
if i != n // i:
res.append(n // i)
return res
n, m = map(int, input().split())
ans = 0
nums = divisors(m)
nums.sort()
num = nums.pop(0)
while num * n <= m:
if (m - num * n) % num == 0:
ans = num
if nums == []:
break
num = nums.pop(0)
print(ans) |
p02570 | s106626319 | Accepted | a, b, c = map(int, input().split())
if a <= b * c:
print("Yes")
else:
print("No") |
p03043 | s217126047 | Accepted | N, K = map(int, input().split())
ans = 0
for i in range(1, N + 1):
tmp = 1 / N
now = i
while now < K:
tmp *= 0.5
now *= 2
ans += tmp
print(ans)
|
p03075 | s700350016 | Accepted | import sys
INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
sys.setrecursionlimit(10 ** 9)
def main():
L = [INT() for _ in range(5)]
k = INT()
print("Yay!" if L[4] - L[0] <= k else ":(")
if __name__ == '__main__':
main() |
p02973 | s503062847 | Wrong Answer | N = int(input())
A = [0] * N
for i in range(N):
A[i] = int(input())
ans = 1
cur_min = A[0]
for i in range(1, N):
if A[i] > A[i-1]:
continue
else:
if A[i] <= cur_min:
ans += 1
cur_min = A[i]
print(ans) |
p02621 | s332787597 | Accepted | a = int(input())
x = a + a**2 + a**3
print(int(x)) |
p03107 | s878127279 | Wrong Answer | s = input()
ans = 0
while ('01'or'10') in s:
ans += s.count('01')*2
s = s.replace("01", "")
ans += s.count('10')*2
s = s.replace("10", "")
print(ans) |
p03284 | s843162238 | Accepted | import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
N, K = map(int, input().split())
print(0 if N % K == 0 else 1) |
p03107 | s025529722 | Accepted | s=input()
print(min(s.count("0"),s.count("1"))*2) |
p03377 | s039117210 | Wrong Answer | a,b,x = map(int,input().split())
print("Yes" if a+b >= x >= a else "No") |
p02621 | s875317275 | Accepted | a = int(input())
print(a+a*a+a*a*a) |
p03360 | s181141047 | Accepted | a,b,c = sorted(list(map(int,input().split())))
k = int(input())
for i in range(k):
c *= 2
print(a+b+c) |
p02796 | s995285109 | Accepted | N = int(input())
robot = {}
for i in range(N):
x, l = map(int, input().split())
robot[x] = l
s_robot = sorted(robot.items(), key=lambda x:x[0])
pre_arm = -10**10
cnt = 0
for key, val in s_robot:
l_arm = key - val
r_arm = key + val
if pre_arm > l_arm:
cnt += 1
if pre_arm > r_arm:
pre_arm = r_arm
else:
pre_arm = r_arm
print(N-cnt) |
p03371 | s421382961 | Wrong Answer | A,B,C,X,Y=map(int,input().split())
if A+B<=C*2:
print(A*X+B*Y)
elif max(A,B)<=2*C:
if X>=Y:
print(Y*2*C+(X-Y)*A)
else:
print(X*2*C+(Y-X)*B)
else:
print(2*max(X,Y)*C) |
p03408 | s341804163 | Accepted | n = int(input())
s = {}
for _ in range(n):
x = input()
if x in s: s[x] += 1
else: s[x] = 1
m = int(input())
t = {}
for _ in range(m):
x = input()
if x in t: t[x] += 1
else: t[x] = 1
ans = 0
for k,v in s.items():
ans = max(ans, v - (t[k] if k in t else 0))
print(ans)
|
p03351 | s423035434 | Accepted | a,b,c,d = map(int,input().split())
ab = abs(a-b)
bc = abs(b-c)
ca = abs(c-a)
if ca <= d or ab<=d and bc<=d:
print("Yes")
else:
print("No") |
p02708 | s650142008 | Wrong Answer | import math
import itertools
def mathFactorial(a,b):
return math.factorial(a) // (math.factorial(b) * math.factorial(a-b))
N,K = map(int, input().split())
print(N,K)
myListA =[]
myList =[]
for i in range(0,N+1):
myListA.append(i)
i = 0
l = 0
while K < N+2:
for x in itertools.combinations(myListA,K):
myList.append(sum(x))
K = K + 1
i = i + 1
l = l + len(set(myList))
myList =[]
print(l % (10^9 +7))
|
p02811 | s979982533 | Accepted | K, X = list(map(int, input().split()))
if K * 500 >= X:
print("Yes")
else:
print("No") |
p02933 | s288356770 | Accepted | a = int(input())
s = input()
if a >= 3200:
print(s)
else:
print('red') |
p02947 | s275344124 | Accepted | n = int(input())
d = dict()
for i in range(n):
s = list(input())
s.sort()
s = "".join(s)
if s not in d.keys():
d[s] = 1
else:
d[s] += 1
count = 0
for i in d.values():
count += i * (i-1) // 2
print(count) |
p02922 | s341898921 | Wrong Answer | x, y = map(int, input().split())
if y <= x:
print(1)
else:
cnt = 1
total = x
while True:
total += (x - 1)
cnt += 1
if total >= y:
break
print(cnt)
|
p02866 | s845356442 | Accepted | from collections import Counter
import sys
MOD = 998244353
def main():
n, *d = map(int, sys.stdin.buffer.read().split())
D = Counter(d)
if D[0] != 1:
print(0)
else:
ans = 1
for i in d[1:]:
ans = ans*D[i-1]%MOD
print(ans % MOD)
if __name__ == '__main__':
main()
|
p03042 | s837286424 | Accepted | s = input()
a = int(s[:2])
b = int(s[2:])
if a <= 12 and b <= 12:
if a==0 and b!=0:
print("YYMM")
elif b==0 and a!=0:
print("MMYY")
elif a==0 and b==0:
print("NA")
else:
print("AMBIGUOUS")
elif a<=12 and b>12:
if a==0:
print("NA")
else:
print("MMYY")
elif a>12 and b<=12:
if b==0:
print("NA")
else:
print("YYMM")
else:
print("NA") |
p03854 | s388531635 | Accepted | import sys
from itertools import combinations
import math
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
S = S()
while 1:
for flag in ("erase", "eraser", "dream", "dreamer"):
if S.endswith(flag):
S = S[:-len(flag)]
break
else:
print('NO')
break
if not S:
print('YES')
break
|
p03719 | s391634883 | Wrong Answer | S_list = list(map(int,input().split()))
if S_list[1] - S_list[0] >= 0 and S_list[2]- S_list[0] >=0 and S_list[2] - S_list[2] >=0:
result = "Yes"
else:
result = "No"
print(result)
|
p03471 | s070955528 | Accepted | N, Y = map(int, input().split())
for i in range(0, N+1, 1):
isFinish = False
for j in range(0, N+1-i, 1):
sen = 1000 * i
gosen = 5000 * j
man = 10000 * (N - i - j)
if sen + gosen + man == Y:
print(N - i - j, j, i)
isFinish = True
break
if isFinish:
break
else:
print(-1, -1, -1) |
p03838 | s517183215 | Wrong Answer | x, y = map(int, input().split())
if x >= 0:
if y >= 0:
if x <= y:
ans = y - x
else:
ans = x - y + 2
else:
ans = abs(x + y) + 1
else:
if y < 0:
if x <= y:
ans = y - x
else:
ans = x - y + 2
else:
ans = abs(x + y) + 1
print(ans) |
p03962 | s681711805 | Accepted | # coding: utf-8
lst = set(map(int, input().split()))
print(len(lst)) |
p04034 | s417213394 | Wrong Answer | n, m = map(int, input().split())
N = [1]*n
P = [True] + [False]*(n-1)
for i in range(m):
x, y = list(map(lambda tmp: tmp-1, map(int, input().split())))
P[y] = True if P[x]==True else False
N[x] -= 1; N[y] += 1
P[x] = False if N[x]==0 else P[x]
print(sum(P)) |
p03673 | s164600735 | Accepted | n = int(input())
a_list = [int(x) for x in input().split()]
print(*(a_list[::-2] + a_list[n&1::2])) |
p02910 | s176032014 | Accepted | s = input()
odd = ["R", "U", "D"]
even = ["L", "U", "D"]
for i in list(s[::2]):
if i not in odd:
print("No")
exit()
for i in list(s[1::2]):
if i not in even:
print("No")
exit()
print("Yes")
|
p04034 | s848462894 | Accepted | N, M = map(int, input().split())
s = {1}
cnt = [1] * (N + 1)
for i in range(M):
x, y = map(int, input().split())
cnt[x] -= 1
cnt[y] += 1
if x in s:
s.add(y)
if cnt[x] == 0:
s.discard(x)
print(len(s)) |
p04005 | s204236378 | Accepted | a,b,c = map(int,input().split())
ans = 0
if a%2 == 0 or b%2==0 or c%2==0:
pass
else:
ans += min(a*b,a*c,b*c)
print(ans) |
p03472 | s384795978 | Accepted | n,h=map(int,input().split())
a=[]
b=[]
for _ in range(n):
a_i,b_i=map(int,input().split())
a.append(a_i)
b.append(b_i)
import bisect,math
b=sorted(b)
index = bisect.bisect_left(b,max(a))
cnt=0
for i in range(n-1,-1,-1):
if i>=index:
h-=b[i]
cnt+=1
else:
break
if h<=0:
h=0
break
ans=math.ceil(h/max(a))+cnt
print(ans)
|
p03838 | s094638913 | Accepted | x,y=map(int, input().split())
ans=0
if x!=0 and x==-y:
ans+=1
elif x*y<0:
ans+=abs(x+y)+1
else:
if x>y:
ans+=1+(x!=0 and y!=0)
x,y=-x,-y
ans+=y-x
print(ans) |
p02958 | s400618955 | Accepted | N=int(input())
P=list(map(int, input().split()))
ido=[]
for i in range(N):
if P[i]!=i+1:
ido.append(P[i])
if len(ido)==2 or len(ido)==0:
print("YES")
else:
print("NO") |
p02747 | s997652536 | Accepted | S = input()
ok = True
for i in range(0, len(S), 2):
try:
if not (S[i] == "h" and S[i + 1] == "i"):
ok = False
break
except IndexError:
ok = False
break
print("Yes" if ok else "No")
|
p03796 | s070777401 | Accepted | import math
N=int(input())
print(math.factorial(N)%(10**9+7)) |
p03774 | s518453116 | Wrong Answer | n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]
targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
def md(s, t):
d = abs(s[0] - t[0]) + abs(s[1] - t[1])
return d
for i in range(n):
x = 2 * 10 ** 8
for j in range(m):
if x > md(students[i], targets[j]):
x = md(students[i], targets[j])
snumber[i] = (j+1, md(students[i], targets[j]))
for i in range(n):
print(snumber[i][0]) |
p02623 | s881077578 | Accepted | from bisect import bisect_left, bisect_right
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n-1): a[i+1] = a[i] + a[i+1]
for i in range(m-1): b[i+1] = b[i] + b[i+1]
a = [0] + a; b = [0] + b
c = bisect_right(a, k)-1
ans = 0
for i in range(c+1)[::-1]:
r = k-a[i]
j = bisect_right(b, r)-1
ans = max(ans, i+j)
print(ans)
|
p03285 | s183771143 | Accepted | n = int(input())
while n >= 0:
if n % 4 == 0:
print("Yes")
exit()
else:
n -= 7
print("No") |
p03544 | s746608738 | Accepted | n = int(input())
l_list = [2, 1]
if n < 2 :
print(l_list[n])
else :
for i in range(2,n+1) :
new = l_list[i-1] + l_list[i-2]
l_list.append(new)
print(l_list[n])
|
p02681 | s760864477 | Accepted | S = input()
T = input()
print('Yes' if T.startswith(S) else 'No')
|
p02646 | s631472630 | Wrong Answer | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
# if (b - a) <= (v-w)*t:
# print("YES")
# else:
# print("NO")
if b+w*t > a+v*t:
print("NO")
else:
print("YES")
|
p02947 | s161456446 | Wrong Answer |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
N = int(input())
S = [''.join(map(str,(sorted(str(input()))))) for i in range(N)]
print(S)
counter = Counter(S)
print(counter)
answer = sum(x*(x-1)//2 for x in counter.values())
print(answer) |
p03254 | s140473512 | Accepted | N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
happy=0
for i in range(N-1):
if a[i]<=x:
x-=a[i]
happy+=1
else:
break
if a[N-1]==x:
happy+=1
print(happy) |
p02848 | s348297121 | Accepted | n = int(input())
st = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
s = input()
for i in range(len(s)):
a = (st.index(s[i]) + n) % 26
print(st[a],end="") |
p02597 | s150844950 | Accepted | n=int(input())
c=input()
a=[]
for i in range(n):
if(c[i]=='R'):
a.append(0)
else:
a.append(1)
zero=0
one=0
for i in range(n):
if(a[i]==0):
zero+=1
ans=[zero]
for i in range(n):
if(a[i]==0):
zero-=1
else:
one+=1
#print(zero,one)
ans.append(max(zero,one))
print(min(ans)) |
p03852 | s563432504 | Accepted | c = str(input())
if c == 'a':
print('vowel')
elif c == 'i':
print('vowel')
elif c == 'u':
print('vowel')
elif c == 'e' :
print('vowel')
elif c == 'o':
print('vowel')
else:
print('consonant')
|
p03659 | s491655794 | Accepted | import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
res = float("inf")
for i in range(1, N):
res = min(res, abs(cs[i] - (cs[-1] - cs[i])))
print(res) |
p02612 | s764578240 | Accepted | n=int(input())
print(1000-((n-1)%1000)-1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.