problem_id
stringclasses 428
values | submission_id
stringlengths 10
10
| status
stringclasses 2
values | code
stringlengths 5
816
|
|---|---|---|---|
p02833
|
s844556830
|
Accepted
|
n = int(input())
if n % 2 == 1:
print(0)
exit()
ans = 0
while n != 0:
n //= 5
ans += n//2
print(ans)
|
p02958
|
s503074015
|
Accepted
|
n = int(input())
p = list(map(int, input().split()))
p_sort = sorted(p)
count = 0
for a, b in zip(p, p_sort):
if a == b:
count += 1
if len(p) - count <= 2:
print("YES")
else:
print("NO")
|
p02678
|
s339891251
|
Wrong Answer
|
n, m = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(m)]
next_node = [[] for _ in range(n)]
for a, b in edge:
next_node[a-1].append(b)
next_node[b-1].append(a)
q = [1]
visit = [1] + [0] * (n-1)
prev = [0]*n
while q:
now = q.pop()
for i in next_node[now-1]:
if visit[i-1] == 0:
q.append(i)
visit[i-1] = 1
prev[i-1] = now
print('Yes')
print(prev[1:])
|
p03657
|
s509513015
|
Accepted
|
a,b=list(map(int,input().split()))
if a%3==0 or b%3==0 or (a+b)%3==0:
print("Possible")
else:
print("Impossible")
|
p03145
|
s877021101
|
Accepted
|
A, B, C = map(int, input().split())
print(A * B // 2)
|
p03997
|
s147221376
|
Wrong Answer
|
a=int(input())
b=int(input())
h=int(input())
print(int(a+b)*h/2)
|
p03211
|
s554651932
|
Accepted
|
L = []
S = input()
for i in range(len(S)-2):
n = int(S[i] + S[i+1] + S[i+2])
L.append(abs(753-n))
L.sort()
print(L[0])
|
p02699
|
s217030357
|
Accepted
|
s, w = map(int, input().split())
print('unsafe' if w >= s else 'safe')
|
p02817
|
s223128742
|
Accepted
|
S, T = input().split()
print(T+S)
|
p04012
|
s881823294
|
Accepted
|
w=list(input())
for x in w:
key=w.count(x)
if key%2!=0:
print('No')
exit()
print('Yes')
|
p03252
|
s969523740
|
Wrong Answer
|
s = input()
t = input()
memo = {}
ans = 'Yes'
for i in range(len(s)):
if s[i] in memo:
if t[i] != memo[s[i]]:
ans = 'No'
break
else:
memo[s[i]] = t[i]
a = memo.values()
if set(a) != len(a):
ans = 'No'
print(ans)
|
p02629
|
s755724746
|
Accepted
|
N = int(input())
d = "abcdefghijklmnopqrstuvwxyz"
ans = ""
N -= 1
while(N >= 0):
ans += d[N % 26]
N //= 26
N -= 1
print(ans[::-1])
|
p03103
|
s200376876
|
Accepted
|
N,M = map(int,input().split())
AB = []
for _ in range(N):
AB.append([int(i) for i in input().split()])
AB_sort = sorted(AB,key=lambda x : x[0])
money = 0
for ab in AB_sort:
if M >= ab[1]:
money += ab[0] * ab[1]
M -= ab[1]
else:
money += M * ab[0]
break
print(money)
|
p03416
|
s913754670
|
Accepted
|
A,B = map(int,input().split())
count = 0
for i in range(A,B+1):
if str(i) == str(i)[::-1]:
count += 1
print(count)
|
p03456
|
s628977874
|
Accepted
|
import math
a,b=input().split()
if math.sqrt(int(a+b))%1==0:print("Yes")
else:print("No")
|
p03456
|
s378861105
|
Accepted
|
import math
a, b = map(str,input().split())
c = int(a+ b)
if math.sqrt(c).is_integer() == True:
print('Yes')
else:
print('No')
|
p02972
|
s591231796
|
Wrong Answer
|
n = int(input())
nums = [int(i) for i in input().split()]
box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
ball = nums[i - 1]
box[i] = ball
t = i
while t <= n + 1:
ball ^= box[i]
t += i
box[i] = ball
ans = box.count(1)
index = []
for i in range(len(box)):
if box[i]:
index.append(i)
print(ans)
print(*index)
|
p03408
|
s766723769
|
Wrong Answer
|
from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
d[input()] += 1
for _ in range(int(input())):
d[input()] -= 1
print(max(d.values()))
|
p03481
|
s663558897
|
Accepted
|
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
x, y = inm()
ans = 0
while x <= y:
ans += 1
x *= 2
print(ans)
|
p03069
|
s440678403
|
Accepted
|
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)
A = list(S)
x = 0
y = S.count('.')
ans = min(n-y, y)
for i in range(n):
if S[i] == '#':
x += 1
else:
y -= 1
ans = min(ans, x + y)
print(ans)
|
p02697
|
s002545930
|
Wrong Answer
|
n, m = map(int, input().split())
ans = []
for i in range(m):
ans.append((i + 1, n - i - 1))
for i in ans:
print(*i)
|
p03803
|
s608164940
|
Accepted
|
a,b = map(int,input().split())
if a==b:
print('Draw')
elif a==1 or b!=1 and a>b:
print('Alice')
else:
print('Bob')
|
p04044
|
s752615207
|
Wrong Answer
|
str = input()
|
p03131
|
s763586797
|
Accepted
|
K, A, B = map(int,input().split())
if B - A <= 2 or K < A + 1:
print(K+1)
else:
cnt = A - 1
bisket = 1 + cnt + (B - A) * ((K - cnt)//2)
bisket += (K - cnt) % 2
print(bisket)
|
p03000
|
s627088393
|
Wrong Answer
|
# 初期入力
import sys
input = sys.stdin.readline
N,X = (int(x) for x in input().split())
L = list(map(int, input().split()))
d =[0]*(N+1)
count =1
for i in range(N):
d[i+1] =d[i] +L[i]
if d[i+1] < X:
count +=1
else:
break
print(count)
|
p03264
|
s951032058
|
Accepted
|
n = int(input())
print(n//2 * (n//2+1) if n % 2 else (n//2)**2)
|
p03760
|
s874929587
|
Wrong Answer
|
o = [input()]
e = [input()]
for x, y in zip(o, e): print(x+y, end="")
|
p03328
|
s004664067
|
Accepted
|
a, b = map(int, input().split())
d = b - a
h = (d*(d + 1)) // 2
print(h - b)
|
p03012
|
s631318490
|
Wrong Answer
|
N = int(input())
W = [int(e) for e in range(N)]
_ = sum(W)
ans = 0
Y = 100 ** 100
for i in range(N - 1):
ans += W[i]
_ -= W[i]
X = abs(ans - _)
if Y > X:
Y = X
print(Y)
|
p02970
|
s954044567
|
Wrong Answer
|
N,D = map(int,input().split())
print(N//(D*2+1)+1)
|
p03455
|
s341311826
|
Wrong Answer
|
a, b = map(int, input().split())
if a * b % 2 == 1:
print("odd")
else:
print("even")
|
p03360
|
s804174282
|
Accepted
|
A, B, C = map(int, input().split())
K = int(input())
max_num = max([A, B, C])
print((max_num) * pow(2, K) + sum([A, B, C]) - max_num)
|
p03815
|
s925307325
|
Accepted
|
x = int(input())
if x % 11 == 0:
print((x//11)*2)
elif x % 11 <= 6:
print((x//11)*2+1)
else:
print((x//11)*2+2)
|
p02973
|
s633744546
|
Wrong Answer
|
import bisect
N = int(input())
A = [-int(input()) for _ in range(N)]
dp = [float("inf")] * (N+1)
dp[0] = -1
dp[1] = A[0]
for i in range(1,N):
dp[bisect.bisect_right(dp, A[i])] = A[i]
for i in reversed(range(N+1)):
if dp[i] < float("inf"):
print(i)
break
|
p03264
|
s207255943
|
Wrong Answer
|
K = input()
def myfunc(K):
count = 0
for i in range(1, K+1):
if i%2==0:
# print(i)
for i in range(1, K+1):
if i%2==1:
# print(" ", i)
count +=1
print(count)
|
p02700
|
s092638972
|
Accepted
|
a,b,c,d=map(int,input().split())
ans="No"
for i in range(100):
c=c-b
if c<=0:
ans="Yes"
break
a=a-d
if a<=0:
break
print(ans)
|
p02760
|
s071557305
|
Accepted
|
import sys
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
d = [int(input()) for f in range(n)]
for k in range(3):
if a[k][0] in d and a[k][1] in d and a[k][2] in d:
print("Yes")
sys.exit()
elif a[0][k] in d and a[1][k] in d and a[2][k] in d:
print("Yes")
sys.exit()
if a[0][0] in d and a[1][1] in d and a[2][2] in d:
print("Yes")
sys.exit()
elif a[0][2] in d and a[1][1] in d and a[2][0] in d:
print("Yes")
sys.exit()
else:
print("No")
|
p03150
|
s904931849
|
Accepted
|
def check(s):
t = 'keyence'
if s == t:
return 'YES'
for i in range(len(s)):
for j in range(i + 1, len(s)):
if t == s[:i] + s[j:]:
return 'YES'
return 'NO'
s = input()
print(check(s))
|
p03672
|
s581878015
|
Wrong Answer
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
S = input()
print(len(S)-2)
|
p04012
|
s628156928
|
Accepted
|
word = input()
result = "Yes"
abc = (set(word))
abc = "".join(abc)
for i in abc:
if word.count(i) %2 ==1:
result = "No"
break
print(result)
|
p02854
|
s323375737
|
Accepted
|
import sys
n = int(input())
a = list(map(int, input().split()))
cnt = 0
ave = sum(a)/2
for i in range(n):
cnt += a[i]
if cnt == ave:
print(0)
sys.exit()
elif cnt > ave:
x = ave -cnt +a[i]
if x >= cnt -ave:
x = cnt -ave
break
print(int(x*2))
|
p02631
|
s839633809
|
Wrong Answer
|
n = int(input())
l = list(map(int, input().split()))
ans = "0"
for i in range(1, n):
a = l[i] ^ l[0]
ans += " {}".format(a)
print(ans)
|
p03136
|
s423098620
|
Wrong Answer
|
n = int(input())
L = list(map(int, input().split()))
idx = L.index(max(L))
print(idx)
sum_L = 0
for i in range(len(L)):
if i == idx:
pass
else:
sum_L += L[i]
if L[idx] < sum_L:
print('Yes')
else:
print('No')
|
p02848
|
s316020425
|
Accepted
|
e = [chr(ord('A') + i) for i in range(26)]
a=int(input())
s=input()
res = []
for i in s:
res.append(e[(e.index(i)+a)%26])
print(''.join(res))
|
p03011
|
s582207833
|
Accepted
|
P,Q,R = sorted(map(int,input().split()))
print(P+Q)
|
p03854
|
s090153094
|
Accepted
|
import re
S = input()
'''
メタ文字:
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
print('YES')
else:
print('NO')
|
p03160
|
s826473577
|
Accepted
|
n=int(input())
cst=list(map(int,input().split()))
arr=[0]*10**5
arr[0]=0
arr[1]=abs(cst[1]-cst[0])
if n==2:
print(arr[1])
else:
for i in range(2, n):
arr[i] = min(abs(cst[i - 1] - cst[i]) + arr[i - 1], abs(cst[i - 2] - cst[i]) + arr[i - 2])
print(arr[i])
|
p03632
|
s710772494
|
Accepted
|
#abc070 b
a,b,c,d=map(int,input().split())
if d<a or b<c:
print(0)
else:
print(min(b,d)-max(a,c))
|
p03086
|
s780035780
|
Wrong Answer
|
s=input()
tmp = 0
ans = -1
flg= 1
for i in range(len(s) -1):
if s[i] in ["A","G","C","T"]:
tmp += 1
else:
if ans <= tmp:
ans = tmp
flg = 0
tmp = 0
if s[-1] in ["A","G","C","T"]:
ans = max(ans, tmp +1)
print(ans if flg==0 else tmp)
|
p03071
|
s151679957
|
Accepted
|
a, b = map(int, input().split())
if a > b:
ans = a + a - 1
elif a < b:
ans = b + b - 1
else:
ans = a + b
print(ans)
|
p03013
|
s164875599
|
Accepted
|
N,M = map(int,input().split())
steps = [1,1,2]
for i in range(3,N+1):
steps.append(steps[i-1]+steps[i-2])
ans = 1
a = 0
mod = 10**9+7
for i in range(M):
b = int(input())
b -=1
if(b<a):
print(0)
exit()
else:
ans = ans*steps[b-a]%mod
a = b+2
ans = ans*steps[N-a]%mod
print(ans)
|
p02743
|
s621478615
|
Accepted
|
a, b, c = map(int, input().split())
if (c - a - b) ** 2 > 4 * a * b and c - a - b > 0:
print('Yes')
else:
print('No')
|
p03699
|
s125887675
|
Accepted
|
N=int(input())
s = [int(input()) for i in range(N)]
if sum(x%10!=0 for x in s) == 0:
print(0)
elif sum(s)%10!=0:
print(sum(s))
else:
l = [i for i in s if i % 10 != 0 ]
l.sort()
ans=sum(s)-l[0]
print(ans)
|
p03061
|
s586430583
|
Accepted
|
from functools import reduce
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
L = [reduce(gcd, A[1:])]
l = A[0]
for i in range(N-1):
l = gcd(l, A[i])
L.append(l)
R = [reduce(gcd, A[:N-1])]
r = A[-1]
for i in range(N-1, 0, -1):
r = gcd(r, A[i])
R.append(r)
ans = 1
for i in range(N):
ans = max(ans, gcd(L[i], R[-(i+1)]))
print(ans)
|
p03331
|
s540214975
|
Accepted
|
N = int(input())
ans = 2 * 10**5
for n in range(1,N//2 + 1):
a = n
b = N - n
sum_a = sum(list(map(int,list(str(a)))))
sum_b = sum(list(map(int,list(str(b)))))
ans = min(ans,sum_a+sum_b)
print(ans)
|
p03351
|
s750932968
|
Accepted
|
a, b, c, d = map(int, input().split())
if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
print("Yes")
else:
print("No")
|
p03471
|
s461708616
|
Accepted
|
N,Y = map(int,input().split())
for i in range(N+1):
A = i
for j in range(N+1):
B = j
C = N - A - B
if C < 0:
break
s = 10000*A+5000*B+1000*C
if s == Y:
a = str(A)
b = str(B)
c = str(C)
print(a+" "+b+" "+c)
exit()
print("-1"+" "+"-1"+" "+"-1")
|
p03639
|
s262687339
|
Wrong Answer
|
N = int(input())
a = list(map(int,input().split()))
count = 0
count2 = 0
for i in range(N):
if a[i]%4 == 0:
count += 1
elif a[i]%2 == 0:
count2 += 1
if count+(count2//2) >= N//2:
print("Yes")
else:
print("NO")
|
p03435
|
s647705712
|
Accepted
|
[(a,b,c),(d,e,f),(g,h,i)] = [map(int,input().split()) for i in range(3)]
if a-b==d-e==g-h and b-c==e-f==h-i:
print("Yes")
else:
print("No")
|
p03243
|
s091563711
|
Wrong Answer
|
N = input()
print(''.join(max(N)*3))
|
p02817
|
s935893336
|
Wrong Answer
|
S, T = input().split()
print(S + T)
|
p03723
|
s914819827
|
Accepted
|
a,b,c=map(int,input().split())
ans = 0
while a%2 == b%2 == c%2 == 0:
ans += 1
newa=b//2+c//2
newb=a//2+c//2
newc=a//2+b//2
a=newa
b=newb
c=newc
if a == b == c:
print("-1")
break
else:
print(ans)
|
p03951
|
s661233068
|
Accepted
|
n = int(input())
s = input()
t = input()
for i in range(n):
if s[i:] == t[:n-i]:
print(n*2 - (n-i))
exit(0)
print(2*n)
|
p02786
|
s025339563
|
Accepted
|
c= int(input())
ans =0
s = 0
while c >1:
c = c//2
ans += 1
for i in range(1,ans+1):
s += 2**i
print(s+1)
|
p03962
|
s619939146
|
Wrong Answer
|
color=input()
iro=color.split(" ")
i=0
if int(iro[0])==int(iro[1]):
i=i+0
else:
i=i+1
if int(iro[0])==int(iro[2]):
i=i+0
else:
i=i+1
if int(iro[1])==int(iro[2]):
i=i+0
else:
i=i+1
print(str(i))
|
p02556
|
s096523931
|
Accepted
|
n = int(input())
z = []
w = []
for i in range(n):
x,y = map(int,input().split())
z.append(x+y)
w.append(x-y)
zmax = max(z)-min(z)
wmax = max(w)-min(w)
print(max(zmax,wmax))
|
p03371
|
s020625115
|
Wrong Answer
|
a, b, c, x, y = map(int, input().split())
n = a*x + b*y
sx, rx = divmod(x, 2)
sy, ry = divmod(y, 2)
s = 2*min(sx, sy)
m = 2*c*s + a*(2*sx-s+rx) + b*(2*sy-s+ry)
print(min(n, m))
|
p02795
|
s073545205
|
Accepted
|
import math
h = int(input())
w = int(input())
n = int(input())
l = max(h, w)
print(math.ceil(n/l))
|
p02843
|
s414178796
|
Accepted
|
X = int(input())
q = X // 100
if X%100<=q*5:
print('1')
else:
print('0')
|
p03041
|
s030672329
|
Accepted
|
N, K = map(int, input().split())
S = input()
ans = ''
for i in range(N):
ans += S[i] if i != (K - 1) else str(S[i]).lower()
print(ans)
|
p03386
|
s642468586
|
Accepted
|
a, b, k = map(int, input().split())
for i in range(a, min(b, a + k - 1) + 1):
print(i)
for i in range(max(b - k + 1, a + k), b + 1):
print(i)
|
p03557
|
s086570059
|
Wrong Answer
|
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
a = bisect.bisect_left(A, b)
c = bisect.bisect_right(C, b)
ans += (a + 1)*c
print(ans)
|
p02922
|
s864325743
|
Accepted
|
import numpy as np
import functools
import math
import collections
import scipy
import fractions
import itertools
def solve():
a, b = map(int, input().split())
if b <= 1:
print(0)
elif a >= b:
print(1)
else:
print(math.ceil((b-a)/(a-1))+1)
return 0
if __name__ == "__main__":
solve()
|
p03860
|
s595106673
|
Accepted
|
a,s,c = input().split()
print(a[0]+s[0]+c[0])
|
p03721
|
s210933709
|
Accepted
|
N,K = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(N)]
#print(lst)
#print(lst.sort())
lst.sort(key=lambda l:l[0])
#print(lst)
sm = 0
for x in lst:
sm += x[1]
#print(lst[i][1])
if sm >= K:
print(x[0])
break
|
p03556
|
s101726336
|
Accepted
|
a = int(input())
for i in range(1, int(a ** .5)+2):
if i ** 2 > a:
print((i-1)**2)
|
p03206
|
s256656331
|
Accepted
|
d=int(input())
if d==25:
print("Christmas")
elif d==24:
print("Christmas Eve")
elif d==23:
print("Christmas Eve Eve")
else:
print("Christmas Eve Eve Eve")
|
p02701
|
s581847407
|
Accepted
|
#!/usr/bin/env python3
import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
n = I()
s = [input() for _ in range(n)]
cnt = Counter(s)
print(len(cnt))
|
p03605
|
s631105767
|
Accepted
|
import itertools
def main():
n = input()
print("Yes" if n.count('9') else "No")
if __name__ == '__main__':
main()
|
p03672
|
s751272719
|
Wrong Answer
|
# -*- coding: utf-8 -*-
S = list(str(input()))
while len(S) > 1:
S.pop()
if S[0 : len(S) // 2] == S[len(S) // 2 :]:
print(len(S))
|
p02718
|
s159150351
|
Accepted
|
nm = input('')
n = int(nm.split(' ')[0])
m = int(nm.split(' ')[1])
alist = input('').split(' ')
t = 0
for i in range(n):
t += int(alist[i])
s = 0
for i in range(n):
a = int(alist[i])
if a*4*m >= t:
s+=1
if s >= m:
print('Yes')
else:
print('No')
|
p03730
|
s766328396
|
Accepted
|
A,B,C = map(int,input().split())
ans =[]
flag =False
for i in range(1,A*B):
temp = (A*i)%B
ans.append(temp)
for j in ans:
if j == C:
flag = True
break
else:
flag = False
if flag ==True:
print("YES")
else:
print("NO")
|
p02988
|
s045052817
|
Wrong Answer
|
a=int(input())
b=list(map(int,input().split()))
i=0
c=0
for i in range(a-1):
if b[i-1]<b[i]<b[i+1]:
c+=1
i+=1
print(c)
|
p02847
|
s838835134
|
Accepted
|
s = input()
days = ['SUN','MON','TUE','WED','THU','FRI','SAT' ]
day = int(days.index(s))
#print(day)
print(7-day)
|
p03605
|
s857952647
|
Wrong Answer
|
# coding: utf-8
# Your code here!
n=input()
if n[0]==9 or n[1]==9:
print('Yes')
else:
print('No')
|
p02631
|
s794577114
|
Wrong Answer
|
n = int(input())
a = list(map(int, input().split()))
xor=0
for i in range(n):
xor ^= a[i]
print(xor)
ans=[]
for i in range(n):
ans.append(xor ^ a[i])
print(*ans,sep=" ")
|
p02982
|
s292164917
|
Wrong Answer
|
import math
n,d = map(int,input().split())
try:
a = [list(map(int,input().split())) for j in range(0,n)]
except EOFError:
pass
c = 0
r = 0
for i in range(0,n):
for j in range(i+1,n):
for k in range(0,d):
c+=(a[i][k]-a[j][k])**2
if math.sqrt(c)==int(math.sqrt(c)):
r += 1
print(r)
|
p02935
|
s272707311
|
Wrong Answer
|
n=int(input())
v=list(map(int ,input().split()))
l=[]
draw_list=[]
second_draw=[]
for i in range(0,len(v)-1):
first_combination=float((v[i]+v[i+1])/2)
draw_list.append(first_combination)
# print(draw_list)
for j in range(0,len(v)-1):
second_combination=float((draw_list[j]+v[j])/2)
second_draw.append(second_combination)
# print(second_draw)
draw_list.extend(second_draw)
print(int(max(draw_list)))
|
p03419
|
s813074864
|
Accepted
|
h,w = map(int,input().split())
if h== 1 and w == 1:
ans = 0
elif h == 1 or w == 1:
ans = 2
else:
ans = 2*(h-2)+2*(w-2)+4
ans = (h*w) - ans
print(ans)
|
p02995
|
s970904201
|
Accepted
|
a, b, c, d = map(int, input().split())
import fractions
lcm = c * d // fractions.gcd(c, d)
a_count = (a-1)//c + (a-1)//d - (a-1)//lcm
b_count = b//c + b//d - b//lcm
answer = b_count - a_count
print(b - a + 1 - answer)
|
p03103
|
s180644106
|
Accepted
|
n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort()
cnt = 0
mon = 0
i = 0
if n >= 2:
while cnt < m:
if lis[i][1] + cnt < m:
cnt += lis[i][1]
mon += lis[i][0]*lis[i][1]
i += 1
else:
break
print(mon + (m-cnt) * lis[i][0])
else:
print(m*lis[0][0])
|
p02555
|
s736916531
|
Accepted
|
# 動的計画法による解法
s = int(input())
mod = pow(10, 9) + 7
A = [0] * (s + 1)
if s >= 3:
A[3] = 1
for i in range(4, s + 1):
A[i] = (A[i - 3] + A[i - 1]) % mod
print(A[s])
|
p02791
|
s633299349
|
Accepted
|
n=int(input())
l=list(map(int, input().split()))
# n=5
# l=[4,2,5,1,3]
count=0
import heapq
tmp=l[0]
for i in range(1,len(l)+1):
if tmp>=l[i-1]:
count+=1
tmp=l[i-1]
print(count)
|
p02922
|
s075278391
|
Wrong Answer
|
A,B=map(int,input().split())
if A>=B:
print(1)
else:
print(B//A+1)
|
p03556
|
s208050531
|
Accepted
|
import math
print(math.floor(math.sqrt(int(input())))**2)
|
p02790
|
s888078180
|
Wrong Answer
|
a, b=list(map(int, input().split()))
big = 0
small =0
if a > b:
big = a
small = b
else:
big = b
small = a
s = ""
for i in range(b):
s += str(small)
print(s)
|
p02707
|
s642112475
|
Accepted
|
n = int(input())
input_line = list(map(int, input().split()))
data = [0 for i in range(n)]
for i in range(len(input_line)):
data[input_line[i]-1] += 1
for i in data:
print(i)
|
p03723
|
s487079370
|
Accepted
|
a,b,c = map(int,input().split())
ans = 0
for i in range(10000001):
if a%2 == 1 or b%2 == 1 or c%2 == 1:
break
if i == 1000000:
print(-1)
exit()
m = a
n = b
l = c
a = (b+c)//2
b = (c+m)//2
c = (m+n)//2
ans += 1
print(ans)
|
p03035
|
s238005125
|
Accepted
|
A,B=map(int,input().split())
if A>12:
print(B)
elif A>5:
print(B//2)
else:
print(B*0)
|
p03284
|
s422393839
|
Accepted
|
n,k=map(int,input().split())
if n%k==0:
print(0)
else:
print(1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.