problem_id stringclasses 428 values | submission_id stringlengths 10 10 | status stringclasses 2 values | code stringlengths 5 816 |
|---|---|---|---|
p02951 | s863982085 | Wrong Answer | A,B,C=map(int,input().split())
ans=C-(A-B)
if (C>=0):
print(ans)
else:
print(0) |
p03672 | s518315176 | Accepted | S = input()
if len(S)%2:
S = S[:len(S)-1]
else:
S = S[:len(S)-2]
N = len(S)
while True:
now = S[:N]
L = len(now)
if now[:L//2] == now[L//2:]:
break
N -= 2
print(N)
|
p03943 | s373547851 | Accepted | a,b,c = map(int,input().split())
if (a+b == c) or (a+c == b) or (b+c == a):
print("Yes")
else:
print("No") |
p03062 | s864583451 | Wrong Answer | n, *a = map(int, open(0).read().split())
ans = 0
for i in range(n-2):
if a[i] < 0:
ans += -1 * a[i]
a[i+1] = -1 * a[i+1]
else:
ans += a[i]
if a[-2] * a[-1] < 0: # 最後2つが異符号のとき
ans += max(abs(a[-2]), abs(a[-1])) - min(abs(a[-2]), abs(a[-1]))
else:
ans += abs(a[-2]) + abs(a[-1])
print(ans) |
p02817 | s678946157 | Accepted | s,t = map(str,input().split())
print(t+s) |
p02622 | s551842520 | Accepted | s = input()
t = input()
cnt = 0
for a, b in zip(s, t):
if a != b:
cnt += 1
print(cnt) |
p02743 | s785981090 | Accepted | #!/usr/bin/env python3
from decimal import Decimal
a, b, c = list(map(int, input().split()))
# ans = "Yes" if (math.sqrt(a) + math.sqrt(b)) < math.sqrt(c) else "No"
root = Decimal("0.5")
ans = "Yes" if ((a ** root) + (b ** root)) < (c ** root) else "No"
print(ans)
|
p02582 | s044735288 | Accepted | s=input()
if s=='SSS':
print(0)
elif s=='SSR':
print(1)
elif s=='SRS':
print(1)
elif s=='SRR':
print(2)
elif s=='RSS':
print(1)
elif s=='RSR':
print(1)
elif s=='RRS':
print(2)
elif s=='RRR':
print(3) |
p02630 | s474149436 | Wrong Answer | N = int(input())
target_list = map(int, input().split())
trans_list = {}
for i in range(int(input())):
trans_list[i] = list(map(int, input().split()))
result = {}
for target in target_list:
print(result)
for key, trans in trans_list.items():
if target == trans[0]:
target = trans[1]
if key in result:
result[key] = result[key] + target
else:
result[key] = target
for r in result.values():
print(r)
|
p02548 | s942981868 | Accepted | n=int(input())
ans=0
for i in range(1,n):
ans+=((n-1)//i)
print(ans) |
p02546 | s273864737 | Wrong Answer | S = input()
if S[-1] != "s":
print(S+"s")
else:
print(S[:-1]+"es") |
p02608 | s807487461 | Accepted | # vim: fileencoding=utf-8
def main():
N = int(input())
ans = [0] * N
for x in range(1, 101):
for y in range(1, 101):
for z in range(1, 101):
t = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x - 1
if t >= len(ans):
break
ans[t] += 1
print(*ans)
if __name__ == "__main__":
main()
|
p03759 | s052379070 | Wrong Answer | a, b, c = map(int, input().split())
print("YNEOS"[b-a!=c-b]) |
p02639 | s299087133 | Accepted | x = [int(i) for i in input().split()]
for i in range(len(x)):
if x[i] == 0:
print(i+1)
|
p02761 | s672636708 | Wrong Answer | n,m=map(int, input().split())
r = []
flg = []
for i in range(n):
r.append(str(0))
flg.append(0)
for i in range(m):
s,c = map(int, input().split())
if flg == 1 and int(r[s-1]) < c:
r[s-1] = r[s-1]
else:
r[s-1] = str(c)
flg[s-1] = 1
if n == 1 and r[0] == '0':
print(0)
elif r[0] == '0':
print('-1')
else:
print(''.join(r))
|
p02615 | s597992363 | Wrong Answer | N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ANS = A[0]
for i in range(N-2):
index = i // 2
print(index)
ANS += A[index+1]
print(ANS) |
p03145 | s129440305 | Wrong Answer | def TriangleS(a,b,c):
return a*b//2
|
p03038 | s249039379 | Accepted | import sys
from bisect import bisect_right as br
input = sys.stdin.readline
N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
b = []
for _ in range(M):
k, x = map(int, input().split())
b.append((x, k))
b.sort()
l = 0
res = 0
while len(b):
x, k = b.pop()
i = br(a, x)
if l >= i: break
if i - l > k:
i = l + k
res += x * (i - l)
l = i
print(res + sum(a[l: ])) |
p03131 | s363391072 | Accepted | K,A,B = map(int,input().split())
ans = 1+K
rem = K-(A-1)
if rem <= 1:
print(ans)
else:
ans2 = A
d,m = divmod(rem,2)
ans2 += (B-A)*d
ans2 += m
print(max(ans, ans2)) |
p03137 | s875679626 | Wrong Answer | import itertools
a=0;b=0;m=0;l=0
N,M=map(int,input().split())
X=list(map(int,input().split()))
l=M-N; m=sum(X)
if N>=M:
print(0)
else:
for i in itertools.combinations(X,l):
L=sorted(list(map(int,i)))
print(L)
for j in range(1,l):
a=a+(L[j]-L[j-1])
print(a)
if a<m:
m=a
a=0
print(m) |
p02577 | s374760986 | Wrong Answer | N = input()
a = 0
for n in N:
a += int(n)
if a % 9 == 0:
ans = "Yse"
else:
ans = "No"
print(ans) |
p03221 | s447071675 | Accepted | #!/usr/bin/env python3
N, M = map(int, input().split())
C = {}
for i in range(N):
C[i+1] = 0
D = {}
for i in range(M):
P, Y = map(int, input().split())
D[Y] = [P, i]
ret = {}
for y, p in sorted(D.items(), key=lambda x: x[0]):
C[p[0]] += 1
ret[p[1]] = str(p[0]).zfill(6) + str(C[p[0]]).zfill(6)
for i, r in sorted(ret.items(), key=lambda x: x[0]):
print(r)
|
p03838 | s889310903 | Accepted | X, Y = map(int, input().split())
if X * Y > 0:
if X <= Y: print(Y-X)
else: print(X-Y+2)
elif X == 0:
print(Y if Y >= 0 else -Y+1)
elif Y == 0:
print(-X if X <= 0 else X+1)
else:
mi = abs(abs(Y)-abs(X))+1
if X <= Y:
mi = min(mi, Y-X)
print(mi) |
p02595 | s599698150 | Accepted | from math import sqrt
n, d = map(int, input().split())
pq = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for p, q in pq:
ans += (sqrt(p ** 2 + q ** 2) <= d)
print(ans)
|
p02888 | s142095195 | Wrong Answer | import itertools
n = int(input())
l = list(map(int, input().split()))
triangle = itertools.combinations(l, 3)
cnt = 0
for i in triangle:
if max(i)*2 > sum(i):
cnt += 1
print(cnt) |
p02647 | s098727830 | Accepted | a,b=map(int,input().split())
l=list(map(int,input().split()))
import itertools
b=min(b,50)
def ku(l):
y=[0]*a
for j,x in enumerate(l):
y[max(0,j-x)]+=1
r=min(j+x,a-1)
if r<a-1:
y[r+1]-=1
return itertools.accumulate(y)
for _ in range(b):
l=ku(l)
print(*l) |
p02695 | s527965253 | Accepted | from itertools import combinations_with_replacement
N,M,Q = map(int,input().split())
comb = list(combinations_with_replacement(range(1,M+1),N))
abcd = []
for i in range(Q):
a,b,c,d = map(int,input().split())
abcd.append([a-1,b-1,c,d])
ans = 0
for i in comb:
tmp = 0
for a,b,c,d in abcd:
if i[b] - i[a] == c:
tmp += d
ans = max(ans,tmp)
print(ans) |
p02820 | s104273765 | Accepted | N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
ans = 0
for i in range(K,N):
if T[i] == T[i-K]:
T[i] = 'n'
score = {'r':P,'s':R,'p':S,'n':0}
for i in range(N):
ans += score[T[i]]
print(ans) |
p03759 | s445934261 | Accepted | a,b,c = map(int,input().split())
if c-b == b-a:
print('YES')
else:
print('NO') |
p03645 | s020332619 | Wrong Answer | n,m=map(int,input().split())
a=[list(map(int, input().split())) for num in range(m)]
count=0
for num1 in range(m):
for num2 in range(m-num1):
if a[num1][1]==a[num1+num2][0]:
if a[num1][0]==1:
if a[num1+num2][1]==n:
count=1
if count==0:
print("IMPOSSIBLE")
else:
print("POSSIBLE")
|
p02971 | s071044029 | Accepted | N = int(input())
A = [int(input()) for _ in range(N)]
sortA = sorted(A)
ma = sortA[-1]
ma2 = sortA[-2]
for a in A:
if a == ma:
print(ma2)
else:
print(ma)
|
p03043 | s487648250 | Wrong Answer | from fractions import Fraction
N , K = list(map(int,input().split()))
denom_list = []
Z=0
def detame_keisan( N , K , i ):
kijun = 10
score = i
count = 0
while score < kijun:
count += 1
score = ( score * 2 )
print(count)
return N * (2 ** count)
for i in range( 1,N+1 ):
X = detame_keisan( N , K , i)
denom_list.append( X )
for item in denom_list:
#Z += 1/item
Z += Fraction(1, item)
print( Z.numerator / Z.denominator) |
p02717 | s364292319 | Wrong Answer | X, Y, Z = map(int, input().split())
print(Y, Z, X) |
p02778 | s709809789 | Wrong Answer | print('*'*len(input())) |
p03627 | s134318677 | Wrong Answer | from collections import Counter
N=int(input())
A=Counter(sorted(list(map(int,input().split()))))
A=[i for i in A if A[i]>=2]
A.sort(reverse=True)
try:
print(A[0]*A[1])
except:
print(0)
|
p03211 | s924846389 | Accepted | s = input()
n = len(s)-2
X = []
for i in range(n):
X.append(int(s[i:i+3]))
ans = 753
for i in range(n):
if abs(X[i]-753) < ans:
ans = abs(X[i]-753)
print(ans) |
p02677 | s230240340 | Accepted | import numpy as np
a,b,h,m=[int(i) for i in input().split()]
def get_angle(h,m):
long_angle=2*np.pi*m/60
short_angle=2*np.pi*h/12+(2*np.pi/12)*m/60
big_angle=max(long_angle,short_angle)
small_angle = min(long_angle, short_angle)
angle=min(big_angle-small_angle,2*np.pi-big_angle+small_angle)
return angle
def yogen(a,b,theta):
ans=a**2+b**2-2*a*b*np.cos(theta)
return ans**0.5
print(yogen(a,b,get_angle(h,m))) |
p02994 | s016897656 | Accepted | from sys import stdin
N,L=list(map(int,stdin.readline().strip().split()))
taste=L-1
apple_list=[]
min=3000
j=0
for i in range(1,N+1):
apple_list.append(taste+i)
if min>abs(taste+i):
min=abs(taste+i)
j=i-1
apple=sum(apple_list)
print(apple-(apple_list[j])) |
p02693 | s967408941 | Wrong Answer | K = int(input())
A, B = map(int, input().split())
min_num = A//K
max_num = B//K
for i in range(min_num, max_num+1):
if A <= i*K <= B:
print("OK")
exit(0)
print("NO") |
p03211 | s781435085 | Wrong Answer | import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
s = rr()
min_ = inf
for i in range(len(s)-3):
min_ = min(min_, abs(int(s[i:i+3])-753))
print(min_)
|
p02613 | s492897728 | Accepted | n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(n):
c = input()
if c == 'AC':
c0 += 1
elif c == 'WA':
c1 += 1
elif c == 'TLE':
c2 += 1
else:
c3 += 1
print(f'AC x {c0}')
print(f'WA x {c1}')
print(f'TLE x {c2}')
print(f'RE x {c3}')
|
p02835 | s584598244 | Wrong Answer | print('win' if sum(list(map(int,input().split())))<22 else 'burst') |
p03359 | s966741399 | Accepted | a, b = map(int, input().split())
print(a - 1 if a > b else a) |
p03699 | s398419669 | Accepted | n = int(input())
s = [int(input()) for _ in range(n)]
ans = sum(s)
x = []
for i in s:
if i % 10 != 0:
x.append(i)
x = sorted(x)
for i in x:
if ans % 10 == 0:
ans = ans - i
if ans % 10 == 0:
print(0)
else:
print(ans) |
p02935 | s429443428 | Accepted | from functools import reduce
input()
print(reduce(lambda a,b:(a+b)/2,sorted(map(int,input().split())))) |
p02731 | s962331633 | Accepted | l=int(input())
print(l/3*l/3*l/3) |
p02552 | s998794938 | Wrong Answer | i = int(input())
if i == 0:
print(1)
else:
print(1)
|
p02994 | s196796184 | Accepted | N, L = map(int, input().split())
# 味:L + i - 1
aji_list = [L+i-1 for i in range(1, N+1)]
basic = abs(sum(aji_list))
min_diff = 9999999
for i in aji_list:
diff = abs(basic - abs(basic - abs(i)))
min_diff = min(min_diff, diff)
for i in aji_list:
if abs(basic - abs(basic - abs(i))) == min_diff:
if basic == sum(aji_list):
print(basic - abs(i))
else:
print(-1*(basic - abs(i)))
break |
p02958 | s833044944 | Accepted | N=int(input())
p=list(map(int,input().split()))
miss=0
for i in range(N):
if p[i]!=i+1:
miss+=1
if miss==0 or miss==2:
print("YES")
else:
print("NO") |
p03487 | s164221198 | Accepted | from collections import Counter
N=int(input())
a=list(map(int,input().split()))
a=Counter(a)
ans=0
for key,count in a.most_common():
key=int(key)
if count>=key:
ans+=count-key
else:
ans+=count
print(ans) |
p02819 | s194282118 | Accepted | import math
def isPrime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
# 2ではない偶数は素数ではない
return False
# nの半分まで計算する範囲を絞る
m = math.floor(n / 2) + 1
for p in range(3, m, 2): # 奇数だけ計算する
if n % p == 0:
return False
return True
n=int(input())
while not isPrime(n):
n+=1
print(n) |
p02792 | s406960406 | Accepted | import sys
input = sys.stdin.readline
n=int(input())
dp=[[0]*10 for _ in range(10)]
for i in range(1,n+1):
dp[int(str(i)[0])][int(str(i)[-1])]+=1
#print(dp)
ans = 0
for i in range(10):
for j in range(10):
ans+=dp[i][j]*dp[j][i]
print(ans)
|
p02814 | s540910696 | Accepted | import sys
import fractions
n, m = map(int, input().split())
a = set(map(int, input().split()))
g = 0
mx_2 = 0
for i in a:
tmp = 0
while i % (2 ** tmp) == 0: tmp += 1
mx_2 = max(mx_2, tmp - 1)
g = fractions.gcd(g, i)
if g % (2 ** mx_2) != 0 or g % (2 ** (mx_2 + 1)) == 0:
print(0)
else:
prod = 1
lcm = 1
g = 0
for i in a:
lcm = lcm * i // 2 // fractions.gcd(lcm, i // 2)
print((m // lcm + 1) // 2)
|
p02923 | s249683310 | Accepted | N = int(input())
H = list(map(int,input().split()))
max = 0
count = 0
for x in range(N-1):
if H[x]>=H[x+1]:
count += 1
else:
if max < count:
max = count
count=0
if max < count:
max = count
print(max) |
p02693 | s361782848 | Wrong Answer | k = int(input())
a, b = map(int, input().split())
if b - a >= k or k == 1:
print('OK')
else:
print('NG') |
p03345 | s001856629 | Accepted |
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()
def resolve():
A,B,C,K=map(int,input().split())
if abs(B-A)>10**18:
print('Unfair')
else:
if K%2==0:
print(A-B)
else:
print(B-A)
resolve() |
p02790 | s609369081 | Accepted | a, b = map(int, input().split())
print (str(a)*b if a <= b else str(b)*a) |
p03994 | s751088999 | Wrong Answer | s = input()
K = int(input())
for i in range(len(s)):
if(ord("a") + 26 - ord(s[i]) <= K):
K -= ord("a") + 26 - ord(s[i])
s = s[:i] + "a" + s[i+1:]
if(i == len(s) - 1):
s = s[:-1] + chr(ord("a") + ((ord(s[-1]) + K % 26) - ord("a")) % 26)
print(s) |
p04034 | s829912357 | Accepted | N,M=map(int,input().split())
L=[1]*N
S=[-1]*N
S[0]=1
for i in range(M):
x,y=map(int,input().split())
if S[x-1]==1:
S[y-1]=1
L[x-1]-=1
L[y-1]+=1
if L[x-1]==0:
S[x-1]=-1
print(S.count(1)) |
p03861 | s745807617 | Accepted | # from pprint import pprint
# import math
# import collections
# n = int(input())
a, b, x = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
_a = a // x + 1
_b = b // x + 1
if a % x == 0:
_c = 1
else:
_c = 0
ans = _b - _a + _c
# print(_a, _b, _c, ans)
print(ans)
|
p02691 | s812448289 | Accepted | N = int(input())
A = [int(i) for i in input().split()]
# 線形で計算できる
# j > iとしてA[j]+A[i] = j-iよりA[i]+i=j-A[j]
# iとjを分離できたのでjを前に進めていって、計算結果を貯めていけばいい
#
counter = 0
dic = {}
for j in range(N):
if j-A[j] in dic:
counter += dic[j - A[j]]
if j + A[j] in dic:
dic[j+A[j]] += 1
else:
dic[j+A[j]] = 1
print(counter)
|
p03761 | s019590589 | Wrong Answer | n = int(input())
ans = ""
for i in range(n):
if i == 0:
ans = sorted(input())
else:
tmp = sorted(input())
ans = [v for v in ans if v in tmp]
print(''.join(map(str, ans)))
|
p02576 | s463219999 | Accepted | n, x, t = map(int,input().split())
cnt=0
while True:
n=n-x
cnt+=t
if n<=0:
break
print(cnt) |
p03448 | s784170733 | Wrong Answer | a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(1,a+1):
for j in range(1,b+1):
for k in range(1,c+1):
if i*500 + j*100 + k*50 == x:
count += 1
print(count) |
p02683 | s131986667 | Accepted | N, M, X = [int(i) for i in input().split()]
CA = []
for i in range(N):
CA.append([int(j) for j in input().split()])
min_money = 100000 ** N + 1
for i in range(2**N):
money = 0
result = [0] * M
for j in range(N):
if ((i >> j) & 1):
money += CA[j][0]
for n in range(1, M+1):
result[n-1] += CA[j][n]
if money < min_money and min(result) >= X:
min_money = money
print(min_money if min_money != 100000 ** N + 1 else -1) |
p03633 | s776064443 | Accepted | def gcd(a, b):
"""Compute the greatest common divisor of a and b"""
while b > 0:
a, b = b, a % b
return a
def lcm(a, b):
"""Compute the lowest common multiple of a and b"""
return a * b // gcd(a, b)
def resolve():
n = int(input())
t = [int(input()) for _ in range(n)]
ans = t[0]
for i in t[1:]:
ans = lcm(ans, i)
print(ans)
resolve() |
p03416 | s275016762 | Accepted | A, B = map(int, input().split())
ans = 0
for i in range(A, B + 1):
i = str(i)
flag = True
for j in range(len(i) // 2):
if i[j] != i[len(i) - 1 - j]:
flag = False
if flag == True:
ans += 1
print(ans)
|
p02597 | s113930493 | Accepted | n=int(input())
c=input()
d=c.count("R")
e=c[:d].count("R")
print(d-e) |
p03681 | s976102593 | Wrong Answer | from math import factorial
n,m=map(int,input().split())
mod=10**9+7
f=factorial(n)
if abs(n-m)>1:
print(0)
elif abs(n-m)==1:
print((f**2)%mod)
else:
print((2*(f**2))%mod)
|
p02570 | s172817190 | Wrong Answer | d, t, s = map(int, input().split())
if d // s <= t:
print('Yes')
else:
print('No') |
p03262 | s383653444 | Accepted | import fractions
from functools import reduce
N, X =list(map(int,input().split()))
listx = list(map(int,input().split()))
list1 = [abs(x-X) for x in listx]
for i in range(0,N-1):
ans = fractions.gcd(list1[i],list1[i+1])
print(reduce(lambda a,b:fractions.gcd(a,b),list1,list1[0]))
|
p02615 | s931334523 | Wrong Answer | N=int(input())
input1=list(map(int,input().split()))
max1=0
for i in input1:
if sum(input1)-i >=max1:
max1=i
print(max1) |
p03696 | s027713932 | Accepted | N = int(input())
S = list(input())
c = [0,0]
for s in S:
if s == '(':
c[0] += 1
else:
if c[0] > 0:
c[0] -= 1
else:
c[1] += 1
pre = ['('] * c[1]
rear = [')'] * c[0]
ans = pre+S+rear
print(''.join(ans))
|
p02862 | s075736759 | Accepted | X, Y = map(int, input().split())
MD = pow(10, 9) + 7
def choose(n, a):
x, y = 1, 1
for i in range(a):
x = x * (n - i) % MD
y = y * (i + 1) % MD
return x * pow(y, MD - 2, MD) % MD
a = (2*Y-X)//3
b = (Y-2*X)//-3
if a < 0 or b < 0 or (X+Y) % 3 != 0:
print(0)
exit()
print(choose(a+b, min(a,b))) |
p02796 | s445040865 | Wrong Answer | n = int(input())
xl = [[int(i) for i in input().split()] for j in range(n)]
xl.sort(key = lambda x:x[1])
xl.sort(key = lambda x:x[0])
now = xl[0][0] + xl[0][1]
count = 1
if(n == 1):
print(1)
else:
for i in range(1, n):
if(now <= xl[i][0] - xl[i][1]):
count += 1
now = xl[i][0] + xl[i][1]
print(count) |
p03698 | s389496658 | Accepted | s = input()
print("yes" if len(set(s)) == len(s) else "no") |
p02705 | s952261384 | Wrong Answer | print(int(input())*3.141592) |
p02665 | s148130952 | Wrong Answer | from itertools import accumulate
N = int(input())
a = tuple(map(int,input().split()))
s = list(accumulate(a))
b = [0]*(N+1)
if a[0] == 0:
b[0] = 1
ans = 1
flag = 0
for d in range(1,N+1):
b[d] = b[d-1]-a[d]
tmp = min(s[-1]-s[d],2*b[d-1]-a[d])
if b[d] > tmp or tmp < 0:
flag = 1
break
else:
b[d] = tmp
if flag:
print(-1)
else:
print(s[-1]+sum(b)) |
p02555 | s225545033 | Accepted | import math
def comb(n,r):
return math.factorial(n)//(math.factorial(n-r) * math.factorial(r))
s=int(input())
sm=1
if s<3:
print("0")
else:
for i in range(2,(s//3)+1):
a=s-(i*3)
#print(i,",",a)
sm+=comb(i+a-1,i-1)
#print(sm)
print(sm%((10**9)+7)) |
p03435 | s040512099 | Accepted | c=[list(map(int,input().split())) for _ in range(3)]
yoko=[c[0][1]-c[0][0],c[0][2]-c[0][1]]
tate=[c[1][0]-c[0][0],c[2][0]-c[1][0]]
flag=1
for i in range(1,3):
if not((c[i][1]-c[i][0]==yoko[0])and(c[i][2]-c[i][1]==yoko[1])):
flag=0
if not((c[1][i]-c[0][i]==tate[0])and(c[2][i]-c[1][i]==tate[1])):
flag=0
if flag==1:
print("Yes")
else:
print("No") |
p03282 | s232449474 | Accepted | n=str(input())
N = int(n)
m=int(input())
cnt = 0
for i in range(m):
if i >= N:
break
if n[i] == "1":
cnt +=1
else:
break
if cnt == m:
print(1)
elif cnt == 0:
print(n[0])
elif cnt < m:
print(n[cnt]) |
p02623 | s465966417 | Accepted | import bisect
N, M, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
WA = [0] * (N + 1)
WB = [0] * (M + 1)
for i in range(N):
WA[i + 1] = WA[i] + A[i]
for j in range(M):
WB[j + 1] = WB[j] + B[j]
ma = 0
last = False
for i in range(0, N + 1):
if WA[i] > K:
break
t = K - WA[i]
j = bisect.bisect(WB, t)
ma = max(ma, i + j - 1)
print(ma)
|
p03434 | s874071146 | Accepted | N = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
Alice = 0
Bob = 0
for i in range(1,N+1):
if i%2 !=0:
Alice+=li[i-1]
elif i%2 == 0:
Bob += li[i-1]
ans = Alice-Bob
print(ans) |
p03944 | s469601950 | Accepted | W, H, N = map(int, input().split())
x_min, x_max, y_min, y_max = 0, W, 0, H
for i in range(N):
x, y, a = map(int, input().split())
if a == 1 and x > x_min:
x_min = x
elif a == 2 and x < x_max:
x_max = x
elif a == 3 and y > y_min:
y_min = y
elif a == 4 and y < y_max:
y_max = y
if x_max > x_min and y_max > y_min:
S = (x_max - x_min) * (y_max - y_min)
else:
S = 0
print(S) |
p02973 | s387634020 | Accepted | from bisect import bisect, bisect_left
N = int(input())
dp = [1]*N
for _ in range(N):
a = -int(input())
n = bisect(dp, a)
dp[n] = a
print(sum( 1 for i in dp if i <= 0 )) |
p02547 | s706497773 | Accepted | num = int(input())
count = 0
for i in range(num):
ab = input().split(" ")
a = int(ab[0])
b = int(ab[1])
if a == b:
count += 1
if count >= 3:
break
else:
count = 0
if count >= 3:
print("Yes")
else:
print("No") |
p03437 | s438577281 | Accepted | X , Y = map(int, input().split())
if X%Y == 0:
print(-1)
else:
i = 2
while True:
if X*i > 10**18:
print(-1)
break
if X*i%Y != 0:
print(X*i)
break
i += 1 |
p02899 | s369885025 | Accepted | from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF = float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353
import numpy
N = int(input())
A = list(map(int, input().split()))
a = numpy.argsort(A)
b = []
for i in range(N):
b.append(str(a[i]+1))
print(" ".join(b)) |
p03778 | s807270053 | Accepted | w,a,b=map(int,input().split())
print(max(abs(a-b)-w,0)) |
p02712 | s604257205 | Accepted | n = int(input())
total = 0
for i in range(1, n+1):
if i % 15 == 0:
continue
elif i % 3 == 0:
continue
elif i % 5 == 0:
continue
else:
total += i
print(total) |
p02719 | s070386346 | Accepted | n, k = map(int,input().split())
n = n % k
if abs(n - k) < n:
print(abs(n - k))
else:
print(n) |
p02699 | s460432707 | Accepted | s,w=map(int,input().split())
if s>w:
print('safe')
else:
print('unsafe') |
p02555 | s604361078 | Wrong Answer | from itertools import combinations
S = int(input())
n = S // 3
ans = -1
for k in range(n + 1):
ans = ans + 1
print(ans) |
p03107 | s754095951 | Accepted | s = list(input())
c0 = s.count("0")
c1 = s.count("1")
if c0 >= c1:
print(2*c1)
else:
print(2*c0) |
p04011 | s495281923 | Accepted | N,K,X,Y=[int(input()) for i in range(4)]
print(X*K+Y*(N-K) if N-K > 0 else X*N) |
p03163 | s213978397 | Accepted | N, W = map(int, input().split())
items = [[0, 0]]
for _ in range(N):
items.append(list(map(int, input().split())))
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
for i in range(1, N + 1):
for j in range(W + 1):
if j - items[i][0] >= 0:
dp[i][j] = max(dp[i - 1][j - items[i][0]] + items[i][1], dp[i - 1][j])
else:
dp[i][j] = dp[i - 1][j]
print(max(dp[N])) |
p03380 | s475982012 | Accepted | n = int(input())
A = list(map(int, input().split()))
A.sort()
m = A[-1] / 2
diff = abs(A[0] - m)
r = A[0]
for a in A:
tmp = abs(a - m)
if tmp < diff:
diff = tmp
r = a
print(int(2 * m), r)
|
p02787 | s183764092 | Accepted | h,n=map(int,input().split())
c=[list(map(int,input().split()))for _ in range(n)]
d=[0]*20002
for i in range(h):d[i]=min(d[i-a]+b for a,b in c)
print(d[h-1]) |
p03785 | s164302546 | Wrong Answer | n,c,k = map(int,input().split())
t = []
for i in range(n):
t.append(int(input()))
t = sorted(t)
ans = 1
passenger = 0
#first = 0
for i in range(n):
# if first == 0:
# first = t[i]
if passenger < c and t[i] + k > t[i]:
passenger +=1
if i == n-1:
ans +=1
else:
passenger = 0
# first = 0
ans +=1
print(ans) |
p02713 | s348117561 | Wrong Answer | import math
from functools import reduce
def gcd(*numbers):
return reduce(math.gcd, numbers)
k = int(input())
count = 0
from itertools import product
for a in range(1, k+1):
for b in range(a, k+1):
for c in range(b, k+1):
count += gcd(a, b, c)
print(count) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.