problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p02695
|
s428142143
|
Accepted
|
n, m, q = map(int, input().split())
t = []
for _ in range(q):
a, b, c, d = map(int, input().split())
t.append([a-1, b-1, c, d])
#t = sorted(t, key=lambda x:x[1])
tmp = [i for i in range(1, m+1)]
from itertools import combinations_with_replacement
ans = 0
for v in combinations_with_replacement(tmp, n):
A = list(v)
score = 0
for i in range(q):
a, b, c, d = t[i]
if A[b] - A[a] == c:
score += d
ans = max(ans, score)
print(ans)
|
p02747
|
s208964232
|
Wrong Answer
|
if 'hi' in input():
print('Yes')
else:
print('No')
|
p02859
|
s459838643
|
Accepted
|
r = int(input())
print(r**2)
|
p03127
|
s425404416
|
Wrong Answer
|
n = int(input())
l = list(map(int,input().split()))
l.sort()
a = l[0]
for i in range(1,n):
if l[i]%a != 0:
a = l[i]%a
if a == 1:
print(1)
exit()
print(a)
|
p03162
|
s817810738
|
Accepted
|
import sys
sys.setrecursionlimit(10000000)
N = int(input())
H = list(list(map(int,input().split())) for _ in range(N))
#sub problem: max cost from 0 to ith day
memo = {}
def rec(i, choice):
if (i, choice) in memo:
return memo[(i, choice)]
if i == len(H):
return 0
m = max(H[i][j] + rec(i+1,j) for j in range(3) if j != choice)
memo[(i, choice)] = m
return m
print(max(rec(0, j) for j in range(3)))
|
p02612
|
s416545780
|
Accepted
|
int = int(input())
print((1000 - int % 1000) % 1000)
|
p02684
|
s687648533
|
Accepted
|
n, k = map(int,input().split())
A = list(map(int,input().split()))
A = [a-1 for a in A]
path = []
passed = set([])
p = 0
while 1:
if k ==0:
print(p+1)
exit()
if p not in passed:
path.append(p)
passed.add(p)
p = A[p]
k -= 1
else:
break
path = path[path.index(p):]
term = len(path)
k %= term
print(path[k]+1)
|
p02548
|
s960388668
|
Accepted
|
N=int(input())
answer=0
for i in range(1,N):
answer+=(N-1)//i
print(answer)
|
p02582
|
s856789211
|
Accepted
|
S = input()
cnt = 0
if S.count('R') == 0:
cnt = 0
elif S.count('R') == 1:
cnt = 1
elif S.count('R') == 3:
cnt = 3
else :
if S[1] == 'R':
cnt = 2
else :
cnt = 1
print(cnt)
|
p02682
|
s474830057
|
Accepted
|
a,b,c,k=map(int,input().split())
if k<=a:
ans=k
elif k>a and k<=a+b:
ans=a
else:
ans=a-(k-(a+b))
print(ans)
|
p02952
|
s611530855
|
Wrong Answer
|
import math
N = int(input())
keta = int(math.log10(N)+1)
count = 0
for i in range(1,keta+1):
if i % 2 == 1:
if i == 1:
count += 9
elif i != keta:
count += int('8'+'9'*(i-1)) + 1
else:
count += N - 10 ** (keta-1) + 1
print(count)
|
p02684
|
s154734461
|
Accepted
|
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
at = A[at]-1
if visited[at]:
loop = i+1-path.index(at)
break
else:
visited[at]=True
path.append(at)
if K < len(path):
print(path[K]+1)
else:
print(path[(K-path.index(at))%loop+path.index(at)]+1)
|
p03951
|
s165276215
|
Accepted
|
N = int(input())
A = input()
B = input()
for i in range(N):
if A[i:] == B[0:N-i]:
print(N+i)
exit(0)
print(N*2)
|
p03721
|
s812298616
|
Accepted
|
n,k=map(int,input().split())
s=sorted([[int(i) for i in input().split()] for l in range(n)])
c=0
for x in s:
c+=x[1]
if c>=k:
print(x[0])
break
|
p03408
|
s628502893
|
Accepted
|
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
l=list(set(s))
List=[s.count(l[i])-t.count(l[i]) for i in range(len(l))]
print(max(0,max(List)))
|
p03379
|
s854264394
|
Accepted
|
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
index = N//2
for i in range(N):
if X[i] < Y[index]:
print(Y[index])
else:
print(Y[index-1])
|
p03206
|
s444368093
|
Accepted
|
D = int(input())
if D == 25:
print('Christmas')
elif D == 24:
print('Christmas Eve')
elif D == 23:
print('Christmas Eve Eve')
elif D == 22:
print('Christmas Eve Eve Eve')
|
p02831
|
s704676153
|
Accepted
|
a,b = map(int,input().split())
import math
def lcm(x, y):
return (x * y) // math.gcd(x, y)
print(lcm(a, b))
|
p02866
|
s694194461
|
Accepted
|
import sys
MOD = 998244353
def main():
n, *d = map(int, sys.stdin.buffer.read().split())
e = [0]*n
for i in d:
e[i] += 1
ans = e[0]
for i in d[1:]:
ans = ans*e[i-1] % MOD
print(ans)
if __name__ == '__main__':
main()
|
p02787
|
s156051435
|
Accepted
|
#import time
#t1 = time.time()
h,n = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]
dp = [[10**18 for i in range(h+1)] for j in range(n)]
for i in range(n):
dp[i][0] = 0
for i in range(1,h+1):
dp[0][i] = ((i+ab[0][0]-1) // ab[0][0]) * ab[0][1]
for i in range(1,n):
for j in range(1,h+1):
dp[i][j] = min(dp[i-1][j],dp[i][max(0,j-ab[i][0])]+ab[i][1])
print(dp[n-1][h])
|
p04034
|
s120771563
|
Wrong Answer
|
n, m = map(int, input().split())
mizu = [1]*n
iro = [1] + [0]*(n-1)
for i in range(m):
x, y = list(map(lambda x: x-1, map(int, input().split())))
iro[y] += (iro[y]+iro[x])/(mizu[y]+1)
mizu[x]-=1; mizu[y]+=1
if mizu[x]==0:
iro[x] = 0
print(sum(map(lambda x: int(bool(x)), iro)))
|
p03479
|
s906188925
|
Accepted
|
X, Y = map(int, input().split())
ans = 0
ai = X
while ai <= Y:
ai = 2 * ai
ans += 1
print(ans)
|
p03761
|
s225253836
|
Accepted
|
from collections import Counter
n = int(input())
l = list(Counter(input()) for i in range(n))
k =[]
m = 50
for i in l[0]:
for t in l:
m = min(m,t[i])
k.append(i*m)
m = 50
k.sort()
print("".join(k))
|
p03327
|
s903853623
|
Accepted
|
N = int(input())
if N < 1000:
print('ABC')
else:
print('ABD')
|
p03163
|
s241329806
|
Accepted
|
N, W = map(int, input().split())
w, v = [0], [0]
for i in range(N):
w_i, v_i = map(int, input().split())
w.append(w_i)
v.append(v_i)
DP = [[0 for c in range(W+1)] for i in range(N+1)]
for i in range(1, N+1):
for c in range(1, W+1):
if c - w[i] < 0:
DP[i][c] = DP[i-1][c]
else:
DP[i][c] = max(DP[i-1][c], DP[i-1][c-w[i]] + v[i])
print(DP[N][W])
|
p02909
|
s954093277
|
Accepted
|
# A - Weather Prediction
w=['Sunny','Cloudy','Rainy']
s=input()
if s==w[0]:
print(w[1])
elif s==w[1]:
print(w[2])
else:
print(w[0])
|
p02572
|
s147282759
|
Wrong Answer
|
def solve():
N = int(input())
AA = list(map(int,input().split()))
ans = 0
for a in AA:
ans += a
ans = ans % (10**9+7)
ans = ans**2
for a in AA:
ans -= a**2
ans = ans % (10**9+7)
while ans<0:
ans += 10**9+7
print(int(ans/2))
solve()
|
p03339
|
s019334111
|
Wrong Answer
|
from collections import Counter
n = int(input())
s = input()
ans = float('inf')
e = int(s.count('E'))
for i in range(n):
a = (s[:i]).count('W')
b = e - (i-a)
ans = min(ans, a + b)
print(ans)
|
p02842
|
s218192324
|
Wrong Answer
|
N = int(input())
X = round(N / 1.08)
#再計算
if (X * 1.08) // 1 == N:
print(X)
else:
print(":(")
|
p04011
|
s968526228
|
Wrong Answer
|
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
print(x*k+y*(n-k))
else:
print(x*k)
|
p02700
|
s735247315
|
Wrong Answer
|
A, B, C, D = map(int, input().split())
if A-B <= 0:
print("No")
elif D-C <= 0:
print("No")
else:
print("Yes")
|
p02552
|
s874589796
|
Accepted
|
x = int(input())
if x:
print(0)
else:
print(1)
|
p03435
|
s686400017
|
Wrong Answer
|
# わからん記録
|
p02753
|
s152784555
|
Wrong Answer
|
S = input()
if S[0] == S[1] and S[1]== S[2]:
print("no")
else:
print("yes")
|
p02726
|
s976909883
|
Accepted
|
n, x, y = map(int, input().split())
count = {k:0 for k in range(1, n)}
for i in range(1, n+1):
for j in range(1, i):
k = min(abs(i-j), abs(x-i) + 1 + abs(j-y),abs(y-i) + 1 + abs(x-j))
count[k] += 1
for i in count.values():
print(i)
|
p03379
|
s284234238
|
Accepted
|
N = int(input())
X=list(map(int, input().split()))
sorted_X=sorted(X)
med1=sorted_X[N//2-1]
med2=sorted_X[N//2]
#print(med1, med2)
for i in range(N):
if X[i]<=med1:
print(med2)
elif X[i]>=med2:
print(med1)
|
p02888
|
s886593289
|
Accepted
|
# https://atcoder.jp/contests/abc143/tasks/abc143_d
from bisect import bisect_left, bisect_right
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ
# map(int, input().split()) # 入力が複数
L = [int(i) for i in input().split()]
L.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
a, b = L[i], L[j]
ans += bisect_left(L, a + b) - 1 - j
print(ans)
|
p02719
|
s114751823
|
Accepted
|
l = input()
m = l.split(" ")
n = int(m[0])
k = int(m[1])
if n > k:
n = n % k
if n < (k-n):
print(n)
else:
print(k-n)
|
p02772
|
s136818523
|
Accepted
|
import sys
import math
n = int(input())
a = list(map(int, input().split()))
flg = 0
b = []
for i in range(n):
if a[i] % 2 == 0:
b.append(a[i])
for i in range(len(b)):
if b[i] <= 2:
flg = 1
elif b[i] % 3 != 0 and b[i] % 5 != 0:
flg = 1
if flg == 0:
print("APPROVED")
else:
print("DENIED")
|
p02597
|
s450984411
|
Accepted
|
n=int(input())
c=input()
list=[0 for i in range(n+1)]
r=0
for i in range(n):
if c[i]=='R':
r+=1
w=0
list[0]=max(r,w)
#i corresponds to the right side boundary of c[i]
for i in range(n):
if c[i]=='W':
w+=1
if c[i]=='R':
r-=1
list[i+1]=max(r,w)
print(min(list))
|
p03555
|
s009043832
|
Accepted
|
a = list(input())
b = list(input())
print("YES" if a==b[::-1] else "NO")
|
p03633
|
s440363431
|
Accepted
|
n = int(input())
t = [int(input()) for _ in range(n)]
from fractions import gcd
def lcm(a,b):
return a*b//gcd(a,b)
ans = 1
for i in range(n):
ans = lcm(ans,t[i])
print(ans)
|
p03105
|
s451242515
|
Accepted
|
a,b,c = map(int,input().split())
if a*c <= b:
print(c)
elif a*c >b:
print(b//a)
|
p03329
|
s127789443
|
Wrong Answer
|
from bisect import bisect_right
N = int(input())
L = {1}
m = 6
n = 9
while m <= N:
L.add(m)
m *= 6
while n <= N:
L.add(n)
n *= 9
L = list(L)
L.sort()
# print(L)
dp = [N]*(N+1)
dp[0] = 0
for i in range(1, N+1):
x = bisect_right(L, i)
for j in range(x):
dp[i] = min(dp[i], dp[i % L[j]]+i//L[j])
# print(dp)
print(dp[N])
|
p03719
|
s574863277
|
Wrong Answer
|
a = list(map(int,input().split()))
# b = list(map(int,input().split()))
if a[0]<=a[2]<=a[1]:
print("yes")
else:
print("No")
|
p02702
|
s566780400
|
Wrong Answer
|
S = str(input())
cnt = 0
div_value = 2019
for i in range(0, len(S)-3):
#print(i, S[i:i+4])
for j in range(i+4, len(S)):
#print(i, "-", j, S[i:j])
if j-i >= 200000:
continue
if int(S[i:j]) >= div_value \
and int(S[i:j]) % div_value == 0:
#print(i, "-", j, int(S[i:j]))
cnt = cnt+1
print(cnt)
|
p02645
|
s690568745
|
Wrong Answer
|
s=input(" ")
s=s.lower()
print(s[0:3])
|
p02882
|
s811717304
|
Accepted
|
a,b,x=map(int,input().split())
import math
if a*a*b/2 >x:
print(math.degrees(math.atan(b*b*a/(2*x))))
else:
d=a*a*b-x
print(math.degrees(math.atan(2*d/a**3)))
|
p04043
|
s069139121
|
Accepted
|
# coding: utf-8
# Your code here!
l = input()
if l.count("5") == 2 and l.count("7") == 1:
print("YES")
else:
print("NO")
|
p02767
|
s762442160
|
Wrong Answer
|
import math
N = int(input())
A = list(map(int, input().split()))
X = sum(A)//N
ans = 0
for i in A:
ans += (i-X)**2
print(math.ceil(ans))
|
p03759
|
s487265490
|
Accepted
|
a,b,c = list(map(int,input().split()))
if b-a == c - b:
print("YES")
else:
print("NO")
|
p03095
|
s367024468
|
Accepted
|
from collections import*;input();i=1
for c in Counter(input()).values():i*=c+1
print(~-i%(10**9+7))
|
p03437
|
s848387915
|
Accepted
|
X,Y=map(int,input().split())
print([-1,X][X%Y>0])
|
p02818
|
s783983850
|
Wrong Answer
|
a,b,k=map(int,input().split())
if a+b<=k:
print(0,0)
elif a==0 and b>=k:
print(0,b-k)
elif a>=k and b==0:
print(a-k,b)
else:
print(0,0)
|
p02623
|
s936627732
|
Wrong Answer
|
import bisect
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 = 0
for i in range(n):
if a[i] < k:
ans = max(ans,i+1 + bisect.bisect_left(b,k-a[i]))
print(ans)
|
p03481
|
s672893845
|
Wrong Answer
|
import math
X, Y = map(int, input().split())
print(math.floor(math.log2(Y // X)) + 1)
|
p03797
|
s001894387
|
Accepted
|
N, M = map(int, input().split())
def Main(N, M):
if N+3 >= M:
return M//2
else:
c_remain = M-N*2
return N+c_remain//4
print(Main(N, M))
|
p02601
|
s817804241
|
Accepted
|
import math
aka, mi, ao = map(int, input().split(" "))
k = int(input())
for i in range(k):
if mi <= aka:
mi *= 2
continue
if ao <= mi:
ao *= 2
continue
ao *= 2
if ao > mi > aka:
print("Yes")
else:
print("No")
|
p02911
|
s513941905
|
Wrong Answer
|
n, k, q = map(int, input().split())
points = [k] * n
a = []
for i in range(q):
a.append(int(input())-1)
for cand in a:
points[cand] += 1
points = [i-q for i in points]
ans = ["YES" if i > 0 else "NO" for i in points]
print(*ans, sep="\n")
|
p03797
|
s312485832
|
Accepted
|
n,m = map(int,input().split())
# n + x : m - 2 * x = 1 : 2
# 2n+2x = m - 2x
# 4x = m-2n
if n * 2 <= m:
l = (m - 2 * n) // 4
ans1 = min(n+l, (m-l*2)//2)
ans2 = min(n+l+1, (m - (l+1)*2)//2)
print(max(ans1, ans2))
else:
print(m//2)
|
p03773
|
s860742227
|
Accepted
|
A,B = map(int, input().split())
Ans = A + B
if Ans <= 23:
print(Ans)
else:
print(Ans-24)
|
p02583
|
s198405225
|
Accepted
|
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(0, i):
for k in range(0, j):
if (l[k] != l[j]) and (l[i] != l[j]) and (l[k] + l[j] > l[i]):
ans += 1
print(ans)
|
p02705
|
s861003399
|
Wrong Answer
|
r = int(input())
import math
print(math.pi * r)
|
p02778
|
s682143200
|
Accepted
|
S = input()
N = len(S)
ans = ["x" for _ in range(N)]
print("".join(ans))
|
p03345
|
s315160147
|
Accepted
|
a,b,c,k = map(int,input().split())
i = 0
if k % 2 == 0:
print(a-b)
else :
print(b-a)
|
p02682
|
s695928953
|
Accepted
|
a, b, c, k = list(map(int, input().split()))
s = 0
if k <= a+b:
s = min(k, a)
else:
s = a - (k-a-b)
print(s)
|
p03860
|
s875076375
|
Accepted
|
A = list(input().rstrip().split(" "))
ans = []
for i in A:
ans.append(i[0])
print("".join(ans))
|
p03379
|
s783504427
|
Accepted
|
import numpy as np
N = int(input())
X = list(map(int, input().split()))
Xs = sorted(X)
c1 = np.median(Xs[1:]).astype(int)
c2 = np.median(Xs[:-1]).astype(int)
for i in range(N):
if X[i] < c1:
print(c1)
else:
print(c2)
|
p03672
|
s984849848
|
Accepted
|
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7
S = s()
N = len(S)
ans = 0
for i in range(1,N-1,2):
a = S[:i+1]
if a[:(i+1)//2] == a[(i+1)//2:]:
ans = i+1
print(ans)
|
p02838
|
s562822048
|
Accepted
|
N = int(input())
A = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 0
x = 1
for d in range(60):
odd = 0
even = 0
for a in A:
if a & (1 << d):
odd += 1
else:
even += 1
ans += odd * even * x
ans %= MOD
x <<= 1
print(ans)
|
p03339
|
s117509507
|
Accepted
|
n = int(input())
s = input()
wcnt = [0] * n
ecnt = [0] * (n)
enum = 0
wnum = 0
for i in range(n):
if s[i] == "W":
wnum += 1
wcnt[i] += wnum
if s[-i - 1] == "E":
enum += 1
ecnt[-i - 1] += enum
ans = 10 ** 10
for i in range(n):
temp = 0
if i - 1 >= 0:
temp += wcnt[i - 1]
if i + 1 < n:
temp += ecnt[i + 1]
ans = min(ans, temp)
print(ans)
|
p03434
|
s786035978
|
Accepted
|
n = int(input())
A = sorted(map(int, input().split()))[::-1]
# print(A)
loop = 0
scoreA = 0
scoreB = 0
for e in A:
if loop % 2 == 0:
scoreA += e
else:
scoreB += e
loop += 1
print(scoreA - scoreB)
|
p03073
|
s943531189
|
Accepted
|
S = input()
N = len(S)
O,E = 0,0
for i,s in enumerate(S):
O +=(i%2)^int(s)
E +=(i%2)^(not int(s))
print(min(O,E))
|
p02701
|
s003796861
|
Accepted
|
n = int(input())
s = set()
for i in range(n):
s |= {input()}
print(len(s))
|
p03705
|
s558455382
|
Accepted
|
N,A,B = map(int,input().split())
if A>B:
ans = 0
elif N==1 and A!=B:
ans = 0
elif N==1 and A==B:
ans = 1
else:
ans = (N-2)*(B-A)+1
print(ans)
|
p02958
|
s285457917
|
Accepted
|
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
count=0
for i in range(N):
if p[i]!=q[i]:
count+=1
if count<=2:
print('YES')
else:
print('NO')
|
p03699
|
s855573488
|
Accepted
|
import sys
n=int(input())
l=sorted([int(input()) for _ in range(n)])
sm=sum(l)
if sm%10!=0:
print(sm)
sys.exit()
else:
for i in range(n):
if l[i]%10!=0:
print(sm-l[i])
sys.exit()
print(0)
|
p03760
|
s041721666
|
Accepted
|
a,b=input(),input();
length = len(a)+len(b)
result = []
count1 = 0
count2 = 0
for i in range(length):
if i % 2 == 0:
try:
result.append(a[count1])
count1 += 1
except:
continue
else:
try:
result.append(b[count2])
count2 += 1
except:
continue
print(''.join(result))
|
p03644
|
s957462907
|
Accepted
|
n=int(input())
even=[2,4,8,16,32,64]
ans=1
for i in range(len(even)):
if even[i]<=n:
ans=even[i]
print(ans)
|
p02647
|
s689672318
|
Accepted
|
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(min(K,41)):
l=[0]*(N+1)
c=0
for j in range(N):
if j-A[j]>0:
l[j-A[j]]+=1
else:
c+=1
if A[j]+j<N:
l[A[j]+j+1]-=1
for j in range(N):
c+=l[j]
A[j]=c
print(*A)
|
p02773
|
s708897692
|
Wrong Answer
|
n = int(input())
si = []
for i in range(n):
si.append(input())
wkmax = wk = m = 0
c = []
b = list(set(si))
m = len(b)
for i in range(m):
wk = si.count(b[i])
if wkmax <= wk:
wkmax = wk
c.append([b[i],wk])
for i in range(len(c)):
if c[i][1] == wkmax:
print(c[i][0])
|
p03611
|
s540956716
|
Wrong Answer
|
N = int(input())
a = map(int, input().split())
x = [0]*(10**5 + 1)
for i in a:
x[i-1] += 1
x[i] += 1
x[i+1] += 1
res = max(x)
print(res)
|
p02910
|
s855499757
|
Accepted
|
S = input()
ok = True
for i in range(len(S)):
if (i + 1) % 2:
if S[i] not in ['R', 'U', 'D']:
ok = False
else:
if S[i] not in ['L', 'U', 'D']:
ok = False
if ok:
print("Yes")
else:
print("No")
|
p03416
|
s854786377
|
Accepted
|
a, b = map(int, input().split())
ans = 0
for i in range(a, b + 1):
s = str(i)
if s[0] == s[4] and s[1] == s[3]:
ans += 1
print(ans)
|
p02572
|
s142635224
|
Accepted
|
N = int(input())
A = list(map(int, input().split()))
reversed_cumsum = []
tmp = 0
for i in range(N):
tmp += A[N - 1 - i]
reversed_cumsum.append(tmp)
cumsum = reversed_cumsum[::-1]
ans = 0
for i in range(N - 1):
ans = (ans + A[i] * cumsum[i + 1]) % (10 ** 9 + 7)
print(ans)
|
p03126
|
s665283887
|
Accepted
|
ii=lambda:int(input())
miis=lambda:map(int,input().split())
lmiis=lambda:list(map(int,input().split()))
n,m=miis()
k=lmiis()
st=set(k[1:])
for i in range(n-1):
ki=lmiis()
st=st&set(ki[1:])
print(len(st))
|
p03835
|
s146675594
|
Wrong Answer
|
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))
tmp = LI()
k,s = [tmp.pop(0) for i in range(2)]
c=0
for i in range(k,-1,-1):
if i<=s:
for j in range(k,-1,-1):
if s-i-j<=k:
c += 1
print(c)
|
p03624
|
s102876253
|
Accepted
|
S = input()
L = "abcdefghijklmnopqrstuvwxyz"
for i in L:
if i not in S:
print(i)
exit()
print("None")
|
p03637
|
s906162368
|
Wrong Answer
|
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
n = int(input())
a = list(map(int,input().split()))
li = []
li2 = []
li4 = []
for i in range(n):
if a[i]%4 == 0:
li4.append(a[i])
elif a[i]%2 == 0:
li2.append(a[i])
else:
li.append(a[i])
if len(li) < len(li4)+1:
print("Yes")
else:
print("No")
|
p03627
|
s704499947
|
Accepted
|
from collections import Counter
N = int(input())
A = sorted(map(int, input().split()), reverse=True)
c = Counter(A)
check = 0
for i in range(N):
if (c[A[i]] > 1):
check += 1
if (check <= 1):
print(0)
exit()
L = []
for i, v in c.items():
if (v > 3):
L.append(i)
L.append(i)
elif (v > 1 and v <= 3):
L.append(i)
L.sort(reverse=True)
print(L[0] * L[1])
|
p02982
|
s596142075
|
Wrong Answer
|
n,d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(n-1):
for j in range(i+1,n):
sub = 0
for k in range(d) :
sub += (x[i][k]-x[j][k])**2
sub = sub**0.5
print(sub)
if sub.is_integer() :
ans += 1
print(ans)
|
p02552
|
s904369636
|
Accepted
|
y=input()
if y=='0':
print("1")
if y=='1':
print("0")
|
p02761
|
s918861624
|
Wrong Answer
|
def main():
n, m = map(int, input().split())
l = [ (input().split()) for i in range(m)]
l.sort(key=lambda x: x[1])
res = ["0"]*n
for s, c in l:
res[int(s)-1] = c
res = "".join(res)
res = int(res)
if len(str(res))==n:print(int(res))
else:print(-1)
if __name__ == "__main__":
main()
|
p04044
|
s040357449
|
Accepted
|
N, L = map(int, input().split())
lists = []
for n in range(N):
lists.append(input())
print(''.join(sorted(lists)))
|
p02768
|
s616519493
|
Wrong Answer
|
n, a, b = map(int, input().split(' '))
MOD = 10**9 + 7
ans = -1
def modpow(a, n, mod):
res = 1
while n > 0:
if n & 1:
res = res * a % mod
a = a * a % mod
n = n>>1
return res
ans += modpow(2, n, MOD)
def COM(n, k):
res = 1
for i in range(1, k+1):
res = int(res * (n-i+1) / i) % MOD
return res
ans -= COM(n, a)
ans -= COM(n, b)
print(ans)
|
p02595
|
s589734403
|
Accepted
|
N,D = map(int,input().split())
ct = 0
for i in range(N):
X,Y = map(int,input().split())
if X**2 + Y**2 <=D**2:
ct += 1
print(ct)
|
p02647
|
s958723314
|
Wrong Answer
|
n,k=map(int,input().split())
a=[0]*n
ans=[0]*n
a=list(map(int,input().split()))
if (k>15):
a=[n]*n
print(" ".join(map(str,a)))
else:
for _ in range(k):
ans=[0]*n
for i in range(n):
left=max(0,i-a[i])
right=min(n-1,i+a[i])
#print(left,right)
for j in range(left,right+1):
ans[j]+=1
a=ans
print(" ".join(map(str,a)))
|
p02702
|
s814797526
|
Accepted
|
def d_multiple_of_2019():
from collections import Counter
S = [int(ch) for ch in input()]
p = 2019 # ABC158-E のソースコードを流用するため
s = S[::-1]
u = [0] * len(S)
u[0] = s[0] % p
power = 1
for i in range(1, len(S)):
power *= 10
power %= p
u[i] = u[i - 1] + power * s[i]
u[i] %= p
count = Counter(u)
return sum(v * (v - 1) // 2 for v in count.values()) + count[0]
print(d_multiple_of_2019())
|
p03796
|
s807460016
|
Wrong Answer
|
N = int(input())
prod = 1
mod = int(1e9+7)
for j in range(1, N+1):
prod = j * (prod%mod)
print(prod)
|
p03345
|
s953202573
|
Accepted
|
a,b,c,k = map(int, input().split())
if k%2 == 0:
print(a-b)
else:
print(b-a)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.