s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s576009833 | p03703 | u619819312 | 1570400192 | Python | PyPy3 (2.4.0) | py | Runtime Error | 943 | 87088 | 393 | n,k=map(int,input().split())
b=[0]*(n+1)
for i in range(n):
b[i+1]=b[i]+int(input())-k
a=sorted(set(b))
s={a[i-1]:i for i in range(1,len(a)+1)}
c=[]
for i in b:
c.append(s[i])
b=[0]*(n+1)
def f(x):
c=0
while x>0:
c+=b[x]
x-=x&-x
return c
def g(x):
while x<n+1:
b[x]+=1
... |
s268992252 | p03703 | u340781749 | 1568002377 | Python | Python (3.4.3) | py | Runtime Error | 1350 | 48104 | 692 | import sys
import numpy as np
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
... |
s991679301 | p03703 | u969190727 | 1567736279 | Python | PyPy3 (2.4.0) | py | Runtime Error | 885 | 88792 | 724 | n,k=map(int,input().split())
A=[]
for i in range(n):
A.append(int(input())-k)
AA,BB=[0]*(n+1),[0]*(n+1)
AA[-2]=A[-1]
BB[-2]=A[-1]
for i in reversed(range(n-1)):
AA[i]=AA[i+1]+A[i]
BB[i]=BB[i+1]+A[i]
BB.sort()
cur=1
D=dict()
D[BB[0]]=cur
for i in range(1,n+1):
if BB[i]==BB[i-1]:
continue
else:
cur+=1
... |
s175756958 | p03703 | u375616706 | 1560104443 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1355 | import bisect
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def brute():
N, K = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
for j in range(i, N):
if su... |
s918146135 | p03703 | u375616706 | 1560104167 | Python | Python (3.4.3) | py | Runtime Error | 1054 | 35108 | 1174 | import bisect
from itertools import accumulate
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def brute():
N, K = map(int, input().split())
L = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
for j in range(i, N):
if su... |
s912916115 | p03703 | u497625442 | 1533696279 | Python | Python (3.4.3) | py | Runtime Error | 416 | 12584 | 223 | N, K = map(int,input().split())
z = [0 for i in range(N+1)]
s = 0
for i in range(N):
s += int(input())
z[i+1] = s
cnt = 0
for (i,j) in itertools.combinations(range(N+1),2):
if z[j]-z[i] >= K*(j-i):
cnt += 1
print(cnt)
|
s404948532 | p03703 | u839537730 | 1502509596 | Python | Python (3.4.3) | py | Runtime Error | 1321 | 41676 | 460 | N, K = map(int, input().split())
a = []
for _ in range(N):
a.append(int(input())-K)
su = 0
v = [(0, 0)]
for i in range(N):
su += a[i]
v.append((su, i+1))
v = sorted(v)
data = [0]*(N+1)
def sumation(i):
s = 0
while i > 0:
s += data[i]
i -= i & -i
return s
def add(i, x)... |
s434103189 | p03703 | u839537730 | 1502509319 | Python | Python (3.4.3) | py | Runtime Error | 1497 | 42276 | 462 | N, K = map(int, input().split())
a = []
for _ in range(N):
a.append(int(input())-K)
su = 0
v = [(0, 0)]
for i in range(N):
su += a[i]
v.append((su, i+1))
v = sorted(v)
data = [0]*(N+2)
def sumation(i):
s = 0
while i > 0:
s += data[i]
i -= i & -i
return s
def add(i, x)... |
s929558789 | p03703 | u582577761 | 1501861002 | Python | PyPy3 (2.4.0) | py | Runtime Error | 949 | 93272 | 397 | n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
if b[i]!=b[i-1]:
c+=1
d[b[i]]=c
bit=[0]*(n+1)
def sum(i):
res=0
while i>0:
res+=bit[i]
i-=i&-i
return res
def add(i):
while i<=c:
bit[i]+=1
i... |
s176454350 | p03703 | u582577761 | 1501860950 | Python | PyPy3 (2.4.0) | py | Runtime Error | 958 | 93272 | 393 | n,k=map(int,input().split())
a=[0]+[int(input())-k for i in range(n)]
for i in range(1,n+1):
a[i]+=a[i-1]
b=sorted(a)+[-2e9-1]
c,d=0,dict()
for i in range(n+1):
if b[i]!=b[i-1]:
c+=1
d[b[i]]=c
bit=[0]*n
def sum(i):
res=0
while i>0:
res+=bit[i]
i-=i&-i
return res
def add(i):
while i<=c:
bit[i]+=1
i+=i&... |
s600228076 | p03703 | u177481830 | 1498227628 | Python | Python (3.4.3) | py | Runtime Error | 529 | 24504 | 410 | import numpy as np
buf=input().split(' ')
N=int(buf[0])
K=int(buf[1])
arr=np.zeros(N,dtype=np.int8)
for i in range(N):
arr[i]=int(input())
arr=arr-K
mat=-np.ones((N,N))
for i in range(N):
mat[i][i]=arr[i]
for j in range(1,N):
mat[0][j]=mat[0][j-1]+mat[j][j]
for i in range(1,N):
mat[i][:]=mat[i-1... |
s721507861 | p03703 | u177481830 | 1498227097 | Python | Python (3.4.3) | py | Runtime Error | 707 | 24508 | 388 | import numpy as np
buf=input().split(' ')
N=int(buf[0])
K=int(buf[1])
arr=np.zeros(N,dtype=np.int8)
for i in range(N):
arr[i]=int(input())
arr=arr-K
mat=-np.ones((N,N))
for i in range(N):
mat[i][i]=arr[i]
for j in range(1,N):
mat[0][j]=mat[0][j-1]+mat[j][j]
for i in range(1, N):
for j in range(i+1,N)... |
s189276916 | p03703 | u327466606 | 1496954568 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 659 | class BinaryIndexedTree:
def __init__(self, size):
self.data = [0] * (size+1)
self.size = size
def add(self, i, w):
while i <= self.size:
self.data[i] += w
i += i & -i
def sum(self, i):
result = 0
while i > 0:
result += self.data[i]
i -= i & -i
return result
fr... |
s539523173 | p03703 | u226155577 | 1496545157 | Python | Python (2.7.6) | py | Runtime Error | 1064 | 39624 | 675 | n, k = map(int, raw_input().split())
A = [int(raw_input())-k for i in xrange(n)]
su = 0
v = [(0, 0)]
for i in xrange(n):
su += A[i]
v.append((su, i+1))
v.sort()
class BIT:
def __init__(self, n):
self.n = n
self.data = [0]*n
self.el = [0]*n
def sum(self, i):
s = 0
... |
s762627070 | p03703 | u226155577 | 1496543584 | Python | Python (2.7.6) | py | Runtime Error | 1016 | 36096 | 433 | n, k = map(int, raw_input().split())
A = [int(raw_input())-k for i in xrange(n)]
su = 0
v = [(0, 0)]
for i in xrange(n):
su += A[i]
v.append((su, i+1))
v.sort()
data = [0]*(n+2)
def sum(i):
s = 0
while i > 0:
s += data[i]
i -= i & -i
return s
def add(i, x):
while i <= n+2:
... |
s808938973 | p03703 | u226155577 | 1496543487 | Python | Python (2.7.6) | py | Runtime Error | 936 | 38008 | 433 | n, k = map(int, raw_input().split())
A = [int(raw_input())-k for i in xrange(n)]
su = 0
v = [(0, 0)]
for i in xrange(n):
su += A[i]
v.append((su, i+1))
v.sort()
data = [0]*(n+2)
def sum(i):
s = 0
while i > 0:
s += data[i]
i -= i & -i
return s
def add(i, x):
while i <= n+2:
... |
s143352812 | p03704 | u997521090 | 1561749573 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 190 | def f(d,x,y):n=int("9"*x+"0"*y);return d==0if x<1else sum(f(d+i*n,x-2,y+1)*(10-abs(i)-(y<1))for i in range(-9,10)if abs(d+i*n)<n)
D=input();print sum(f(D,i,0)*(10-i%2*9)for i in range(1,21)) |
s675518128 | p03704 | u327466606 | 1497220620 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3700 | 1485 |
# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways: (10-x,0)-(9,x-1) -> (10-x, -10 + x)
def solve(D):
leading_zeros = 0
while D[-1] == 0:
D.pop()
leading_zeros += 1
r = 1
if len(D) >= 2:
h,t = D.popleft(), D.pop()
c = h + t
if not D:
r = t - (leading_zeros == 0) if c == 9 else... |
s008700445 | p03704 | u327466606 | 1497218304 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 1253 |
# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways: (10-x,0)-(9,x-1) -> (10-x, -10 + x)
def solve(D):
leading_zeros = 0
while D[-1] == 0:
D.pop()
leading_zeros += 1
if len(D) >= 2:
h,t = D.popleft(), D.pop()
c = h + t
if not D:
r = t - (leading_zeros == 0) if c == 9 else 0
el... |
s451807870 | p03704 | u327466606 | 1497217151 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 1102 |
# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways: (10-x,0)-(9,x-1) -> (10-x, -10 + x)
def solve(D):
leading_zeros = 0
while D[-1] == 0:
D.pop()
leading_zeros += 1
if len(D) >= 2:
h,t = D.popleft(), D.pop()
c = h + t
if not D:
r = t - (leading_zeros == 0) if c == 9 else 0
el... |
s204818810 | p03704 | u327466606 | 1497185175 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3444 | 1067 | from collections import deque
D = deque(map(int,input()))
leading_zeros = 0
while D[-1] == 0:
D.pop()
leading_zeros += 1
# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways: (10-x,0)-(9,x-1) -> (10-x, -10 + x)
def solve(D):
r = 1
while len(D) > 1:
h,t = D.popleft(), D.pop()
c = h + t
if -1 <=... |
s017672503 | p03704 | u327466606 | 1497183884 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 1035 | from collections import deque
D = deque(map(int,input()))
leading_zeros = 0
while D[-1] == 0:
D.pop()
leading_zeros += 1
# (10-x) ways: (0,x)-(9-x,9) -> (-x, x)
# (x) ways: (10-x,0)-(9,x-1) -> (10-x, -10 + x)
def solve(D):
r = 1
while len(D) > 1:
h,t = D.popleft(), D.pop()
c = h + t
if -1 <=... |
s336618125 | p03704 | u327466606 | 1497167199 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 869 |
def rec(d, outer = False):
head, tail = d[-1], d[0]
if len(d) == 0:
return 1
if len(d) == 1:
return 10-outer if tail == 0 else 0
# (10-tail) ways: (0,tail)-(9-tail,9) -> (-tail, tail)
# (tail) ways: (10-tail,0)-(9,tail-1) -> (10-tail, -10 + tail)
t = head + tail
if len(d) == 2:
if t == 0... |
s755217646 | p03704 | u327466606 | 1497166206 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3064 | 841 |
def rec(d, outer = False):
head, tail = d[-1], d[0]
if len(d) == 0:
return 1
if len(d) == 1:
return 10-outer if tail == 0 else 0
# (10-tail) ways: (0,tail)-(9-tail,9) -> (-tail, tail)
# (tail) ways: (10-tail,0)-(9,tail-1) -> (10-tail, -10 + tail)
t = head + tail
if len(d) == 2:
if t == 0... |
s766480721 | p03704 | u053547321 | 1496570515 | Python | Python (3.4.3) | py | Runtime Error | 655 | 3064 | 818 | def recursion(length, ll, string, cc):
if ll * 2 < length:
for i in range(10):
string1 = string + str(i)
recursion(length, ll+1, string1, cc)
else:
number = str(int(string) + int(cc[-ll:]))
ds = ""
for i in range(length // 2):
ds += number[-i-1... |
s594746050 | p03704 | u458556900 | 1496544590 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 681 | #include <bits/stdc++.h>
#define LL long long
using namespace std;
LL sum = 0;
LL Pow[20];
int main(){
LL d;
Pow[1] = 1;
for(int i = 2; i <= 19; i++) Pow[i] = Pow[i - 1] * 10;
scanf("%lld", &d);
LL s = d;
for(int i = 2; i <= 19; i++){
s = d;
LL tmp = 1;
int k = (i + 1) / 2;
for(int j = i; j > k; j--){
... |
s173573572 | p03705 | u864785784 | 1600917360 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9004 | 847 | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstri... |
s071721924 | p03705 | u703823201 | 1599180354 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9124 | 203 | N, A, B = map(int, input().split())
if A > B:
print(0)
sys.exit(0)
if N == 1:
if A == B:
print(1)
else:
print(0)
sys.exit(0)
x = B*(N-1)+A
n = A*(N-1)+B
print(x-n+1) |
s366910264 | p03705 | u655048024 | 1598389855 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8904 | 171 | n,a,b = map(int,input().split())
if(a>b):
print(0)
else:
if(n = 1):
if(a!=b):
print(0)
else:
print(1)
else:
print(b*(n-1)+a-(a*(n-1)+b)+1)
|
s721772736 | p03705 | u357289011 | 1598113488 | Python | PyPy3 (7.3.0) | py | Runtime Error | 106 | 74576 | 200 | n, a, b = map(int, input().split())
fst = (n - 1) * b + a
sec = (n - 1) * a + b
if a > b:
print(0)
elif n == 1 and a != b:
print(0)
else:
print(fst - sec + 1) |
s344483828 | p03705 | u075303794 | 1597102508 | Python | Python (3.8.2) | py | Runtime Error | 2299 | 3433948 | 371 | import itertools
import sys
N,A,B=map(int,input().split())
ans=set()
if A>B:
print(0)
sys.exit()
elif N==1:
if A==B:
print(1)
sys.exit()
else:
print(0)
sys.exit()
elif N==2:
print(1)
sys.exit()
else:
for x in itertools.combinations_with_replacement(range(A,B+1),N-2):
if x in ans:
... |
s238043388 | p03705 | u075303794 | 1597102403 | Python | Python (3.8.2) | py | Runtime Error | 2296 | 3380256 | 301 | import itertools
N,A,B=map(int,input().split())
ans=set()
if A>B:
print(0)
elif N==1:
if A==B:
print(1)
else:
print(0)
elif N==2:
print(1)
else:
for x in itertools.combinations_with_replacement(range(A,B+1),N-2):
if x in ans:
continue
ans.add(sum(x))
print(len(ans)) |
s775857138 | p03705 | u829416877 | 1596806851 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9172 | 131 | N, A, B = map(int, input().split())
if A > B:
print(0)
elif A == B:
print(1)
elif B-A >=N:
print(0)
else:
print((B-A)*X+1) |
s501586149 | p03705 | u024782094 | 1595381688 | Python | PyPy3 (7.3.0) | py | Runtime Error | 99 | 77272 | 357 | import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))
n... |
s063802482 | p03705 | u030820165 | 1595128351 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9104 | 163 | n, a, b = map(int, input().split())
if (n == 1 and a == b):
ans = 1
elif (n == 1):
ans = 0
elif A > B:
ans = 0
else:
ans = (b - a) * (n - 2) + 1
print(ans) |
s307843704 | p03705 | u545644875 | 1592639944 | Python | Python (3.8.2) | py | Runtime Error | 20 | 9032 | 361 | N,A,B = map(int,input().split())
check = B - A + 1
loop = N - 2
if check < loop:
loop = check
if B < A or (N == 1 and A != B):
print(0)
exit(0)
elif N == 1 or N ==2:
print(1)
exit(0)
if loop % 2 == 0:
ans = (check + check - loop +1)*(loop/2)
elif loop % 2 == 1:
ans = (check + check - loop+1)*((loop-1)/2)... |
s897393439 | p03705 | u835283937 | 1591589142 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 275 | def main():
N = input()
S = str(N)
S = S[::-1]
odd = 0
even = 0
for i in range(len(S)):
if (i + 1) % 2 == 0:
even += int(S[i])
else:
odd += int(S[i])
print(even, odd)
if __name__ == "__main__":
main() |
s010086821 | p03705 | u895408010 | 1590353231 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 709 | def findleftmost(A,B):
shift = 0
while (A>>shift) != (B>>shift):
shift += 1
return shift-1
def findleftmostbit(B,n):
for m in range(n-1,-1,-1):
if (B>>m)%2==1:
return m
return -1
def solve(A,B):
if A==B:
return 1
n = findleftmost(A,B)
m = findleftmostb... |
s246678892 | p03705 | u731322489 | 1590335910 | Python | Python (3.4.3) | py | Runtime Error | 2243 | 3444 | 321 | from itertools import combinations_with_replacement
n, a, b = map(int, input().split())
ans = 0
if n >= 2 and a <= b:
cmbs = combinations_with_replacement([i for i in range(a, b + 1)], n - 2)
D = [sum([a] + list(c) + [b]) for c in cmbs]
ans = len(set(D))
elif n == 1 and a == b:
ans = 1
print(ans... |
s205048396 | p03705 | u987164499 | 1590236279 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 71 | n,a,b = map(int,input().split())
print(max(b*(n-1)+a-(a*(n-1)+b)+1),0) |
s668599502 | p03705 | u542190960 | 1590235879 | Python | Python (3.4.3) | py | Runtime Error | 2282 | 5340 | 324 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
if a == b:
print(1)
else:
print(0)
elif n == 2:
print(1)
elif n >= 3:
if a > b:
print(0)
else:
smin = a * n + (b-a)
smax = b * n - (b-a)
print(smax-smi... |
s512237362 | p03705 | u542190960 | 1590235784 | Python | Python (3.4.3) | py | Runtime Error | 2301 | 4184 | 271 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
if a == b:
print(1)
else:
print(0)
elif n == 2:
print(1)
elif n >= 3:
smin = a * n + (b-a)
smax = b * n - (b-a)
print(smax-smin+1) |
s498326706 | p03705 | u542190960 | 1590235718 | Python | Python (3.4.3) | py | Runtime Error | 2287 | 3444 | 306 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
if a == b:
print(1)
else:
print(0)
elif n == 2:
print(1)
elif n >= 3:
smin = a * n + (b-a)
smax = b * n - (b-a)
sl = list(range(smin, smax+1, 1))
print(len(sl)) |
s763361083 | p03705 | u542190960 | 1590235417 | Python | Python (3.4.3) | py | Runtime Error | 2291 | 157812 | 382 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
if a == b:
print(1)
else:
print(0)
elif n == 2:
print(a)
elif n >= 3:
c = list(itertools.combinations_with_replacement(candidate, n-2))
suml = []
for i in c:
suml.append(s... |
s657915792 | p03705 | u542190960 | 1590235293 | Python | Python (3.4.3) | py | Runtime Error | 2379 | 157812 | 382 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
if a == b:
print(a)
else:
print(0)
elif n == 2:
print(a)
elif n >= 3:
c = list(itertools.combinations_with_replacement(candidate, n-2))
suml = []
for i in c:
suml.append(s... |
s042989992 | p03705 | u542190960 | 1590235231 | Python | Python (3.4.3) | py | Runtime Error | 2313 | 157812 | 336 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
if n == 1:
print(0)
elif n == 2:
print(a)
elif n >= 3:
c = list(itertools.combinations_with_replacement(candidate, n-2))
suml = []
for i in c:
suml.append(sum(i) + 4 + 6)
sum_set = set(suml)
pri... |
s177104041 | p03705 | u542190960 | 1590234724 | Python | Python (3.4.3) | py | Runtime Error | 2473 | 157812 | 279 | import itertools
n, a, b = map(int, input().split())
candidate = list(range(a, b+1, 1))
c = list(itertools.combinations_with_replacement(candidate, n))
suml = []
for i in c:
if min(i) == a and max(i) == b:
suml.append(sum(i))
sum_set = set(suml)
print(len(sum_set)) |
s377530070 | p03705 | u057964173 | 1590118697 | Python | Python (3.4.3) | py | Runtime Error | 2300 | 4308 | 515 | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
import itertools
n,a,b=map(int, input().split())
if n==1 and a==b:
print(1)
elif n==1 and a!=b:
print(0)
elif b<a:
print(0)
else:
l=list(range(a,b+1))
c=itertools.combinations_with... |
s041215727 | p03705 | u057964173 | 1590118623 | Python | Python (3.4.3) | py | Runtime Error | 2415 | 4308 | 519 | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
n,a,b=map(int, input().split())
if n==1 and a==b:
print(1)
elif n==1 and a!=b:
print(0)
elif b<a:
print(0)
else:
import itertools
l=list(range(a,b+1))
c=itertools.combinations_... |
s051603658 | p03705 | u967106822 | 1589685359 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 309 | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
int N, A, B;
cin >> N >> A >> B;
if (N == 1) {
cout << (A == B ? 1 : 0) << endl;
return 0;
}
int Min = A * (N - 2);
int Max = B * (N - 2);
cout << max(0, Max - Min + 1) << endl;
}
|
s357713762 | p03705 | u026788530 | 1589669968 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 119 | n,a,b=[int(_) for_ in input().split()]
if n==1:
if a==b:
print(1)
else:
print(0)
print(max(0,(n-2)*(b-a)+1) |
s669833655 | p03705 | u486251525 | 1589559243 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2150 | 38660 | 321 | import itertools
N, A, B = map(int, input().split())
if (N == 1 and A != B) or (B < A):
print(0)
exit()
combi = list(itertools.combinations_with_replacement(
range(A, B + 1, 1), N - (B - A)))
sum_array = []
for x in combi:
sumX = A + sum(x) + B
sum_array.append(sumX)
print(len(set(sum_array)))... |
s887350377 | p03705 | u486251525 | 1589559143 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2157 | 38744 | 308 | import itertools
N, A, B = map(int, input().split())
if N == 1 and A != B:
print(0)
exit()
combi = list(itertools.combinations_with_replacement(
range(A, B + 1, 1), N - (B - A)))
sum_array = []
for x in combi:
sumX = A + sum(x) + B
sum_array.append(sumX)
print(len(set(sum_array)))
|
s991661223 | p03705 | u980205854 | 1589419146 | Python | Python (3.4.3) | py | Runtime Error | 16 | 2940 | 134 | # A - A+...+B Problem
N, A, B = map(int, input())
if A>B or (N==1 and A!=B):
print(0)
else:
print((N-1)*B+A - (N-1)*A+B + 1) |
s267001500 | p03705 | u685983477 | 1589062306 | Python | PyPy2 (5.6.0) | py | Runtime Error | 38 | 28396 | 302 | n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
print(0)
exit()
if n==0:
print(0)
elif n==1:
if a==b:
print(1)
else:print(0)
elif n==2:
if a==b:print(1)
print(1)
else:
k = n-2
ans=0
for i in range(k):
ans+=pot
pot-=1
print(ans)
|
s362285762 | p03705 | u977642052 | 1588713348 | Python | Python (3.4.3) | py | Runtime Error | 2401 | 7648 | 461 | from itertools import combinations
def main(n: int, a: int, b: int):
if a > b:
print(0)
return
elif a == b:
print(1)
return
if n < 3:
if n == 1:
print(0)
elif n == 2:
print(2)
return
ans = 2
ans += sum(1 for _ in c... |
s414896823 | p03705 | u443569380 | 1588099454 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 66 | n, a, b = map(int, input().split())A
print((b - a) * (n - 2) + 1)
|
s707289905 | p03705 | u241159583 | 1587829727 | Python | Python (3.4.3) | py | Runtime Error | 2274 | 157812 | 350 | import itertools
n, a, b = map(int, input().split())
if n < b-a:
print(0)
exit()
N = list(range(a, b+1))
su = []
if n > 2:
for v in itertools.combinations_with_replacement(N, n-2):
if not sum(v) in su: su.append(sum(v))
ans = len(su)
else:
A = b-a+1
if n == 1: ans = A
else: ans = A *... |
s087676494 | p03705 | u940139461 | 1587742586 | Python | PyPy3 (2.4.0) | py | Runtime Error | 2111 | 92892 | 279 | # https://atcoder.jp/contests/agc015/tasks/agc015_a
import math
n, a, b = map(int, input().split())
if b < a:
print(0)
elif a != b and n == 1:
print(0)
else:
t = b - a + 1 - 2
ans = math.factorial(t + n) // (math.factorial(t) * math.factorial(n))
print(ans) |
s226123355 | p03705 | u253681061 | 1587321622 | Python | Python (3.4.3) | py | Runtime Error | 3610 | 157812 | 310 | import itertools
n,a,b = [int(x) for x in input().split()]
r = range(a,b+1)
tmp = []
ans = 0
if a == b:
print(1)
elif n == 1:
print(0)
else:
for v in itertools.combinations_with_replacement(r, n-2):
if not sum(v) in tmp:
ans += 1
tmp.append(sum(v))
print(ans) |
s450418125 | p03705 | u297651868 | 1587067282 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 197 | n,a,b= list(map(int, input().split()))
if a>b:
print("0")
exit(0)
else n==1:
if a!=b:
print("0")
else:
print("1")
exit(0)
n-=2;b-=a;a=0
if n>=b:
print(b*n+1) |
s288661291 | p03705 | u024340351 | 1586303871 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 135 | N, A, B = map(int, input().split())
if B< A:
print(0)
elif B = A:
print(1)
elif B-A+1 > N:
print(0)
else:
print((N-2)*B-(N-2)*A+1) |
s526361685 | p03705 | u047102107 | 1584495795 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38640 | 153 | n, A, B = map(int, input().split())
if A > B:
print(0)
elif n == 1:
if A != B:
print(0)
else:
print(1)
else:
print((B - A) * (N - 2) + 1) |
s947690087 | p03705 | u489762173 | 1583532656 | Python | Python (3.4.3) | py | Runtime Error | 2728 | 157812 | 306 | import itertools
N, A, B = list(map(int,input().split()))
if N==1:
if A==B:
print(1)
exit()
else:
print(0)
exit()
comb = list(itertools.combinations_with_replacement(range(A,B+1),N-2))
lis=[]
for x in comb:
lis.append(sum(x))
lis = set(lis)
print(len(lis)) |
s249478237 | p03705 | u904943473 | 1581819188 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38256 | 176 | N, A, B = map(int, input().split())
if(A > B):
print(0)
elif (A == B):
print(1)
else:
print(0)
else:
if (N == 1):
print(0)
else:
print((B-A)*(N-2) + 1) |
s592438666 | p03705 | u672475305 | 1580573698 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 176 | n,a,b = map(int,input().split())
if n==1:
if a==b:
print(1)
else:
print(0)
else:
if b-a < 0:
print(0)
elif k==1:
print(1)
else:
print(b*k - a*k+1) |
s846253981 | p03705 | u263933075 | 1579286169 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 47 | N=input()
A=input()
B=input()
print((2-N)(A-B)) |
s340869800 | p03705 | u430223993 | 1579281871 | Python | Python (3.4.3) | py | Runtime Error | 2310 | 7520 | 471 | import sys
import itertools
n, a, b = map(int, input().split())
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
if a > b:
print(0)
sys.exit()
if a > 1000000007 or b > 1000000007:
a = a%... |
s025003796 | p03705 | u430223993 | 1579281378 | Python | Python (3.4.3) | py | Runtime Error | 2086 | 7520 | 461 | import sys
import itertools
n, a, b = map(int, input().split())
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
if a > b:
print(0)
sys.exit()
if a > 1000000007 and b > 1000000007:
a = a... |
s088025337 | p03705 | u430223993 | 1579280856 | Python | Python (3.4.3) | py | Runtime Error | 2180 | 7520 | 389 | import sys
import itertools
n, a, b = map(int, input().split())
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
if a > b:
print(0)
sys.exit()
total = set([sum(i)+a+b for i in itertools... |
s922505751 | p03705 | u430223993 | 1579280537 | Python | Python (3.4.3) | py | Runtime Error | 2437 | 7648 | 488 | import sys
import itertools
n, a, b = map(int, input().split())
total = set()
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
if a > b:
print(0)
sys.exit()
for i in itertools.combinati... |
s401574013 | p03705 | u430223993 | 1579280467 | Python | Python (3.4.3) | py | Runtime Error | 61 | 157812 | 488 | import sys
import itertools
n, a, b = map(int, input().split())
total = set()
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
if a < b:
print(0)
sys.exit()
for i in itertools.combinati... |
s340804787 | p03705 | u430223993 | 1579280253 | Python | Python (3.4.3) | py | Runtime Error | 2238 | 157812 | 445 | import sys
import itertools
n, a, b = map(int, input().split())
total = set()
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
for i in itertools.combinations_with_replacement(range(a,b+1), n-2):
... |
s658942856 | p03705 | u430223993 | 1579279896 | Python | Python (3.4.3) | py | Runtime Error | 2239 | 157812 | 461 | import sys
import itertools
n, a, b = map(int, input().split())
total = set()
count = 0
if n == 1:
if a != b:
print(0)
else:
print(1)
sys.exit()
if n == 2:
if a > b:
print(0)
else:
print(1)
sys.exit()
for i in itertools.combinations_with_replacement(range(a,b+1)... |
s133523964 | p03705 | u905582793 | 1578385858 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 467 | a=int(input())
b=int(input())
if a==b:
print(1)
exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
while abin[0]==bbin[0]:
abin=abin[1:]
bbin=bbin[1:]
while len(abin)>1 and abin[0]=="0":
abin=abin[1:]
cbin=bbin[1:]
while cbin and cbin[0]=="0":
cbin=cbin[1:]
c=2**(len(cbin)... |
s085770870 | p03705 | u723721005 | 1576873408 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 79 | n = int(input())
a = int(input())
b = int(input())
print((b - a) * (n - 2) + 1) |
s726069169 | p03705 | u254871849 | 1574459615 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 442 | # 2019-11-22 16:25:33(JST)
import sys
def main():
n, a, b = [int(x) for x in sys.stdin.readline().split()]
if a > b:
ans = 0
elif a == b:
ans = 1
elif b < a:
if n == 1:
ans = 0
else:
min_possible = a * (n - 1) + b
max_possible = b *... |
s849605636 | p03705 | u276115223 | 1574365862 | Python | Python (3.4.3) | py | Runtime Error | 2493 | 7520 | 466 | # AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement
n, a, b = [int(s) for s in input().split()]
if a == b:
print(1)
elif a > b or n <= 2:
print(0)
else:
candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
sum_variations = []
for candidate in ca... |
s700905627 | p03705 | u276115223 | 1574365773 | Python | Python (3.4.3) | py | Runtime Error | 2494 | 7392 | 466 | # AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement
n, a, b = [int(s) for s in input().split()]
if a == b:
print(1)
elif a > b or n == 1:
print(0)
else:
candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
sum_variations = []
for candidate in ca... |
s303617195 | p03705 | u276115223 | 1574365662 | Python | Python (3.4.3) | py | Runtime Error | 2244 | 6616 | 465 | # AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement
n, a, b = [int(s) for s in input().split()]
if a > b or n == 1:
print(0)
elif a == b:
print(1)
else:
candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
sum_variations = []
for candidate in can... |
s013350785 | p03705 | u276115223 | 1574365566 | Python | Python (3.4.3) | py | Runtime Error | 2975 | 7520 | 455 | # AGC 015: A – A+...+B Problem
from itertools import combinations_with_replacement
n, a, b = [int(s) for s in input().split()]
if a > b:
print(0)
elif a == b:
print(1)
else:
candidates = list(combinations_with_replacement(range(a, b + 1), n - 2))
sum_variations = []
for candidate in candidates:
... |
s285775530 | p03705 | u747602774 | 1571379354 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 152 | N,A,B=map(int,input().split())
if A==B:
print(1)
else:
if N==1:
ptint(0)
else:
if A<B:
print((N-2)*(B-A)+1)
else:
print(0) |
s708361648 | p03705 | u476418095 | 1570976922 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 203 | #include<bits/stdc++.h>
using namespace std;
int main()
{
long long n,a,b;
cin>>n>>a>>b;
if(n>1 && b>=a || n==1 && a==b
cout<<(n-2)*(b-a)+1<<endl;
else
cout<<0<<endl;
} |
s904780802 | p03705 | u042802884 | 1570675993 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 169 | N,A,B=map(int,input().split())
if N==1:
if A==B:
ans=1
else:
ans=0
elif:
if A>B:
ans=0
else:
ans=(B-A)*(N-2)+1
print(ans) |
s556396597 | p03705 | u723721005 | 1570214066 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 193 | #include<iostream>
using namespace std;
int main()
{
long long n,a,b;
cin>>n>>a>>b;
if(n>1&&b>=a||n==1&&a==b)
cout<<(n-2)*(b-a)+1<<endl;
else
cout<<0<<endl;
} |
s967703105 | p03705 | u247366051 | 1570213354 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 154 | #include<cstdio>
#include<iostream>
using namespace std;
int main()
{
unsigned long long a,b,c,d,e,n;
cin>>n>>a>>b;
e=(a+b)*n/2;
cout<<e;
return 0;
} |
s285645150 | p03705 | u263933075 | 1568772654 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 115 | n,a,b=map(int,input().split())
if n>1 and b>=a or n==1 and a==b:
print ((n-2)*(b-a)+1);
else:
print ("0"); |
s869414683 | p03705 | u247366051 | 1568772462 | Python | PyPy2 (5.6.0) | py | Runtime Error | 39 | 28012 | 115 | n,a,b=map(int,input().split())
if n>1 and b>=a or n==1 and a==b:
print ((n-2)*(b-a)+1);
else:
print ("0"); |
s080255197 | p03705 | u821744287 | 1568255277 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 79 | a=int(input())
b=int(input())
c=0
for i in range(a,b+1):
c+=i
print(c)
|
s032790012 | p03705 | u324549724 | 1565154291 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 90 | n, a, b = map(int, input().split())
if (a < b) print(0)
else print(b*(n-1)+a-a*(n-1)-b+1)
|
s249620163 | p03705 | u921773161 | 1565103761 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 219 | N, A, B = map(int, input().split())
if N == 1 :
if A != B :
ans = 0
elif :
ans = 1
elif A > B :
ans = 0
elif A == B :
ans = 1
else:
ans = (B*(N-1)+A) - (A*(N-1)+B) + 1
print(ans) |
s682041314 | p03705 | u077291787 | 1564159225 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 444 | # AGC015A - A+...+B Problem
import sys
sys.setrecursionlimit(10 ** 9)
from itertools import product
def main():
n, a, b = tuple(map(int, input().rstrip().split()))
if a > b or (n == 1 and abs(a - b) > 1):
print(0)
return
if (n == 1 and a == b) or n == 2:
print(1)
return
... |
s103678078 | p03705 | u077291787 | 1564159174 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 401 | # AGC015A - A+...+B Problem
from itertools import product
def main():
n, a, b = tuple(map(int, input().rstrip().split()))
if a > b or (n == 1 and abs(a - b) > 1):
print(0)
return
if (n == 1 and a == b) or n == 2:
print(1)
return
ans = {sum(i) for i in product(range(a, b... |
s170524310 | p03705 | u649326276 | 1560310401 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 168 | s = input().split(" ");
n = s[0];
a = s[1];
b = s[2];
if a > b :
print(0);
else
if n = 1 or n = 2:
print(1);
else
ans = (b - a)*(n - 2)+1;
print(ans); |
s887440645 | p03705 | u572144347 | 1559367383 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 195 | n,a,b = map(int, input().split())
if n == 1 and a == b:
print(1)
elif n == 1:
print(0)
elif a > b:
print(0)
elif n == 2:
print(1)
elif n > 2:
print( (B-A+1) * (n-2) )
else:
print(0) |
s455036098 | p03705 | u572144347 | 1559367332 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 177 | n,a,b = map(int, input().split())
if n == 1 and a == b:
print(1)
elif n == 1:
print(0)
elif a > b:
print(0)
elif n == 2:
print(1)
elif n > 2:
print( (B-A+1) * (n-2) ) |
s947033478 | p03705 | u077019541 | 1558245330 | Python | Python (3.4.3) | py | Runtime Error | 2237 | 157812 | 294 | import itertools
N,A,B = map(int,input().split())
num = [i for i in range(A,B+1)]
counts = []
for nums in list(itertools.combinations_with_replacement(num,N)):
if num[0] not in nums or num[-1] not in nums:
continue
else:
counts.append(sum(nums))
print(len(set(counts))) |
s140572839 | p03705 | u518064858 | 1557016784 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 127 | n,a,b=map(int,input().split())
if a>b:
print(0)
exit()
elif n=1 and a!=b:
print(0)
exit()
print((b-a)*(n-2)+1)
|
s966769320 | p03705 | u363610900 | 1554107674 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 116 | N, A, B = map(int, input().split())
if A > B:
print(0)
elif N == 1:
print(0)
else:
print((B-A)(N-2)+1) |
s530570421 | p03705 | u363610900 | 1554107602 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 170 | N, A, B = map(int, input().split())
cnt = 0
if A > B:
print(0)
elif N == 1:
if A == B:
print(1)
else:
print(0)
else:
print((B-A)(N-2)+1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.