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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s551977040 | p03838 | u867848444 | 1580346779 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 248 | #agc008-a
x,y=map(int,input().split())
if x<0:
if y<0:
ans=2+abs(y)-abs(x)
else:
if y<-x:
ans=y-x
else:
ans=1+y+x
else:
if y>x:
ans=y-x
elif y<0:
ans=-y-x+1
print(ans) |
s235285724 | p03838 | u867848444 | 1580346076 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 158 | #agc008-a
x,y=map(int,input().split())
y_con=-y
if x<0:
ans=2+abs(y)-abs(x)
else:
if y>x:
ans=y-x
elif y<0:
ans=-y-x+1
print(ans) |
s667676992 | p03838 | u183840468 | 1579470679 | Python | Python (3.4.3) | py | Runtime Error | 148 | 12468 | 397 | import numpy as np
x,y = [int(i) for i in input().split()]
ans_array = np.array([],dtype = np.int64)
if y - x >= 0:
ans_array = np.append(ans_array,y-x)
if y - abs(x) >= 0:
ans_array = np.append(ans_array,y-abs(x)+1)
if abs(y) - x >= 0:
ans_array = np.append(ans_array,abs(y)-x+1)
if abs(y) -abs(x) >= 0:
ans_array = np.append(ans_array,abs(y)-abs(x) + 2)
print(ans_array.min()) |
s318172193 | p03838 | u864197622 | 1578556739 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 130 | X, Y = map(int, input().split())
if X * Y >= 0:
if X <= Y: print(Y-X)
else: print(X-Y+2)
else: print(max(abs(Y)+abs(X))+1) |
s751858314 | p03838 | u709304134 | 1578251192 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 159 | #coding:utf-8
import math
x, y = map(int, input().split())
ls = [y-x,y+x+1,-y-x+1,-y+x+2]
ls = [math.inf if i<0 else i for i in ls]
#print (ls)
print (min(ls)) |
s328925391 | p03838 | u600935366 | 1578056313 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 180 | x,y = map(int, input().split())
ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
ans+=1a
print(ans)
|
s365668592 | p03838 | u305366205 | 1577830248 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 247 | if abs(x) == abs(y):
print(1)
exit()
if x * y < 0:
print(abs(abs(x) - abs(y)) + 1)
elif x == 0 or y == 0:
print(max(abs(x), abs(y)))
elif x < y:
print(y - x)
elif y > 0:
print(x + y + 2)
else:
print(abs(y) - abs(x) + 2) |
s683721923 | p03838 | u169138653 | 1577328690 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 174 | x,y=map(int,input().split())
if x<0 and y<0 or x>0 and y>0 and y<x:
print(abs(x-y)+2)
elif x=0 or y=0 and y<x:
print(abs(x-y)+1)
else:
print(min(abs(x-y),abs(-x-y)+1))
|
s039430072 | p03838 | u252828980 | 1577241310 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 229 | x,y = map(int,input().split())
if y<x<0 or 0<y<x:
print(abs(x-y)+2)
elif (y<x and x=0) or (y=0 and y<x):
print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
print(abs(x-y))
elif x<0<y or y<0<x:
print(abs(abs(x)-abs(y))+1) |
s143626560 | p03838 | u252828980 | 1577241224 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 213 | x,y = map(int,input().split())
if y<x<0 or 0<y<x:
print(abs(x-y)+2)
elif y<x=0 or 0=y<x:
print(abs(x-y)+1)
elif x<=y<=0 or 0<=x<=y:
print(abs(x-y))
elif x<0<y or y<0<x:
print(abs(abs(x)-abs(y))+1) |
s701367293 | p03838 | u295353795 | 1577211601 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 437 | x,y = map(int,input().split())
if 0 < x < y:
print(y-x)
elif x < 0 and y > 0 and abs(x) > abs(y):
print(abs(x)-y+1)
elif x < 0 and y > 0 and abs(x) < abs(y):
print(y-abs(x)+1)
elif x > y > 0:
print(x-y+2)
elif x > 0 and y < 0 and abs(x) > abs(y):
print(x-abs(y)+1)
elif x > 0 and y < 0 and abs(x) < abs(y):
print(abs(y)-x+1)
elif abs(x) == abs(y):
print(1)
elif x < y < 0:
print(y-x)
else:
print(x-y+2 |
s572835541 | p03838 | u295353795 | 1577211532 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38352 | 437 | x,y = map(int,input().split())
if 0 < x < y:
print(y-x)
elif x < 0 and y > 0 and abs(x) > abs(y):
print(abs(x)-y+1)
elif x < 0 and y > 0 and abs(x) < abs(y):
print(y-abs(x)+1)
elif x > y > 0:
print(x-y+2)
elif x > 0 and y < 0 and abs(x) > abs(y):
print(x-abs(y)+1)
elif x > 0 and y < 0 and abs(x) < abs(y):
print(abs(y)-x+1)
elif abs(x) == abs(y):
print(1)
elif x < y < 0:
print(y-x)
else:
print(x-y+2 |
s648229478 | p03838 | u377989038 | 1576190148 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 477 | x, y = map(int, input().split())
X, Y = x // abs(x), y // abs(y)
if abs(x) < abs(y):
if X == 1 and Y == 1:
print(abs(x - y))
elif X == -1 and Y == -1:
print(abs(x - y) + 2)
else:
print(abs(x - y) + 1)
elif abs(x) == abs(y):
if X == Y:
print(0)
else:
print(1)
else:
if X == 1 and Y == 1:
print(abs(x - y) + 2)
elif X == -1 and Y == -1:
print(abs(x - y))
else:
print(abs(x - y) + 1) |
s826507589 | p03838 | u774160580 | 1575002884 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3064 | 236 | x, y = list(map(int, input().split()))
if y - x >= 0:
ans = y - x
if y + x >= 0:
ans = min(ans, y + x + 1)
if -1 * y - x >= 0:
ans = min(ans, -1 * y - x + 1)
if -1 * y + x >= 0:
ans = min(ans, -1 * y + x + 2)
print(ans)
|
s641221987 | p03838 | u774160580 | 1575002818 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 220 | x, y = list(map(int, input().split()))
if y - x >= 0:
ans = y - x
if y + x >= 0:
ans = min(ans, y + x + 1)
if -y - x >= 0:
ans = min(ans, -y - x + 1)
if -y + x >= 0:
ans = min(ans, -y + x + 2)
print(ans)
|
s108793840 | p03838 | u094191970 | 1574898068 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 182 | x,y=map(int,input().split())
if 0<=x<=y or x<=0<=y<=-x or x<=y<=0:
print(y-x)
elif y<=-x<=0<=x:
print(-y-x+1)
elif y<=x<=0 or o<=y<=x:
print(x-y+2)
else:
print(y+x+1) |
s575485112 | p03838 | u852798899 | 1574784635 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38376 | 327 | x, y = map(int, input().split())
diff = abs(abs(x)-abs(y))
elif abs(x) < abs(y):
if x < 0 and y < 0:
diff += 2
elif x > 0 and y < 0:
diff += 1
elif x < 0 and y > 0:
diff += 1
else:
if x > 0 and y > 0:
diff += 2
elif x < 0 and y > 0:
diff += 1
elif x > 0 and y < 0:
diff += 1
print(diff) |
s752021694 | p03838 | u621935300 | 1574319087 | Python | PyPy2 (5.6.0) | py | Runtime Error | 34 | 27628 | 527 | x,y=map(int, raw_input().split())
if 0<=x and 0<=y:
if x<=y:
print abs(x-y)
else:
print min(2+abs(x-y),1+abs(x+y))
elif x<0 and y<0:
if x<=y:
print min(abs(x-y),1+abs(x-y*-1)
else:
print min(2+abs(x-y), 1+abs(x-y*-1))
elif x<0 and 0<=y:
if x*-1<=y:
print min(1+abs(y-x*-1),1+abs(x-y*-1))
else:
print min(abs(x-y),1+abs(x-y*-1))
elif y<0 and 0<=x:
if y*-1<x:
print min(abs(x-y),1+abs(x*-1-y))
else:
print min(abs(x-y),1+abs(x-y*-1))
|
s385600304 | p03838 | u621935300 | 1574318905 | Python | PyPy2 (5.6.0) | py | Runtime Error | 34 | 27884 | 489 | x,y=map(int, raw_input().split())
if 0<=x and 0<=y:
if x<=y:
print abs(x-y)
else:
print min(2+abs(x-y),1+abs(x+y))
elif x<0 and y<0:
if x<=y:
print abs(x-y)
else:
print min(2+abs(x-y), 1+abs(x-y*-1))
elif x<0 and 0<=y:
if x*-1<=y:
print min(1+abs(y-x*-1),1+abs(x-y*-1)
else:
print abs(x-y)
elif y<0 and 0<=x:
if y*-1<x:
print min(abs(x-y),1+abs(x*-1-y))
else:
print min(abs(x-y),1+abs(x-y*-1))
|
s446939588 | p03838 | u215743476 | 1573098524 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 151 | x, y = map(int, input().split())
b = abs(abs(x)-abs(y))
if x * y < 0:
print(b+1)
elif 0 =< y < x or y < x <= 0:
print(b+2)
else:
print(b) |
s879235433 | p03838 | u893063840 | 1572841460 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 322 | def main():
x, y = map(int, input().split())
if 0 <= x <= y or x <= y <= 0:
ans = abs(abs(x) - abs(y))
elif x < 0 < y or y < 0 < x:
ans = abs(abs(x) - abs(y)) + 1
elif y < x < 0 or 0 < y < x:
ans = abs(abs(x) - abs(y)) + 2
print(ans)
if __name__ == "__main__":
main()
|
s923764501 | p03838 | u075303794 | 1567195599 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 184 | x,y = map(int, input().split())
count = 0
if x < 0:
abs_x = abs(x)
count += 1
if y < 0:
abs_y = abs(y)
count += 1
count += abs_y - abs_x
if x == y:
count = 0
print(count) |
s304652826 | p03838 | u077291787 | 1564080090 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 719 | # AGC008A - Simple Calculator
def main():
x, y = tuple(map(int, input().rstrip().split()))
xs, ys = x >= 0, y >= 0
dif = abs(abs(x) - abs(y))
if x, y = 1000000000, 1:
print(1000000001)
return
if abs(x) == abs(y): # <-> x == y <-> y - x = 0
if x == y:
ans = 0
else:
ans = 1
elif 0 <= x < y:
ans = y - x
elif 0 <= y < x:
ans = 1 + dif
elif x < y < 0:
ans = y - x
elif y < x < 0:
ans = 1 + dif + 1 # -a -> a -> b -> -b
elif x < 0 <= y:
ans = dif + 1
ans -= 1 if y == 0 else 0
else: # y < 0 <= x
ans = dif + 1
print(ans)
if __name__ == "__main__":
main() |
s225174151 | p03838 | u227082700 | 1562525230 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 191 | x,y=map(int,input().split())
if x=0:print(abs(y)+(y<0))
elif y=0:print(abs(x)+(x>0))
elif 0<x<y or x<y<0:print(abs(y-x))
elif 0<y<x or y<x<0:print(2+abs(x-y))
else:print(abs(abs(x)-abs(y))+1) |
s412497826 | p03838 | u405256066 | 1560320132 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12408 | 199 | from sys import stdin
import numpy as np
x,y = [int(x) for x in stdin.readline().rstrip().split()]
ans = [(y-x),(y-(-x))+1, (y-x)+2, (x-(-y))+1]
ans = np.array(ans)
ans = ans[ans > 0]
print(min(ans)) |
s131309876 | p03838 | u983967747 | 1557964531 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 376 | a ,b= map(int,input().split())
ans ,x , y ,c= 0 ,int(math.sqrt(a * a)) ,int(math.sqrt(b * b)),0
if x == 0:
x = 1
c += 1
if b < 0:
c += 1
elif y == 0:
y = 1
c += 1
if (a < 0 and b < 0) and (a > b):
ans = abs(x - y)
c += 2
elif (a < 0 and b > 0) or (a > 0 and b < 0):
ans = abs(x - y)
c += 1
else:
ans = abs(x - y)
print(ans + c) |
s596369787 | p03838 | u820351940 | 1556110365 | Python | Python (3.4.3) | py | Runtime Error | 149 | 12504 | 412 | import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
a = np.array(a)
cs_plus = np.cumsum((a > 0) * a)
cs_plus = [0] + list(cs_plus)
plus = [v2 - v1 for v1, v2 in zip(cs_plus[:-k], cs_plus[k:])]
cs_minus = np.cumsum((a < 0) * a)
cs_minus = [0] + list(cs_minus)
minus = [v2 - v1 for v1, v2 in zip(cs_minus[:-k], cs_minus[k:])]
print(cs_plus[-1] - min(min(plus), -max(minus)))
|
s104133688 | p03838 | u450339194 | 1555157504 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 546 | x, y = map(int, input().split())
if abs(x) == abs(y):
print(1)
elif abs(x) < abs(y):
if y > 0:
if x >= 0:
print(abs(x - y))
else:
print(abs(x - y) + 1)
else:
if x >= 0:
print(abs(x - y) + 1)
else:
print(abs(x - y) + 2)
else:
if x < 0:
if y <= 0:
print(abs(x - y))
else:
print(abs(x - y) + 1)
else:
if y <= 0:
print(abs(x - y) + 1)
else y >= 0:
print(abs(x - y) + 2) |
s515220569 | p03838 | u394721319 | 1554751958 | Python | PyPy3 (2.4.0) | py | Runtime Error | 180 | 38640 | 531 | x,y = [int(i) for i in input().split()]
if x > 0:
x_f = 1
else:
x_f = 0
if y > 0:
y_f = 1
else:
y_f = 0
if x_f+y_f == 2:
p = abs(y)-abs(x)
if p > 0:
ans = p
else:
ans = p+2
elif x_f+y_f == 1:
p = abs(y)-abs(x)
ans = abs(p)+1
else:
p = abs(y)-abs(x)
if p < 0:
ans = p
else:
ans = p+2
if x == 0:
if y_f:
ans = y
else:
ans = abs(y)+1
if y == 0:
if x_f:
ans = x_f+1
else:
ans = bas(x_f)
print(ans)
|
s710548632 | p03838 | u151625340 | 1554662945 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 408 | x,y = map(int,input().split())
if x == 0 and y > 0:
print(y-x)
elif x == 0 and y < 0:
print(1+abs(x+y))
elif y == 0 and x > 0:
print(1+abs(x+y))
elif y == 0 and x < 0:
print(y-x)
elif 0 < x and x < y:
print(y-x)
elif 0 < x and x > y:
#print(abs(y+x)+1)
elif x < 0 and y > 0:
print(abs(y+x)+1)
elif y < 0 and x < y:
print(y-x)
elif x < 0 and y < x:
print(2+abs(x-y))
|
s533047876 | p03838 | u151625340 | 1554662765 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 407 | x,y = map(int,input().split())
if x == 0 and y > 0:
print(y-x)
elif x == 0 and y < 0:
print(1+abs(x+y))
elif y == 0 and x > 0:
print(1+abs(x+y))
elif y == 0 and x < 0:
print(y-x)
elif 0 < x and x < y:
print(y-x)
elif 0 < x and x > y:
print(abs(y+x)+1)
elif x < 0 and y > 0
print(abs(y+x)+1)
elif y < 0 and x < y:
print(y-x)
elif x < 0 and y < x:
print(2+abs(x-y))
|
s978541926 | p03838 | u118642796 | 1553869905 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 287 | x,y = map(int,input())
ans = 0
while True:
if x == y:
print(ans)
break
if x == -y:
x = -x
ans += 1
continue
if (abs(x)<abs(y) and x<0) or (abs(y)<abs(x) and 0<=x):
x = -x
ans += 1
continue
ans += abs(abs(x)-abs(y))
x += abs(abs(x)-abs(y)) |
s003369141 | p03838 | u407535999 | 1552575880 | Python | PyPy3 (2.4.0) | py | Runtime Error | 180 | 38640 | 351 | all=input().split()
I=int(all[0]);O=int(all[1]);J=int(all[3]);L=int(all[4])
count=0
while True:
if J>=1 and L>=1 and I>=1:
count+=6
J-=1;L-=1;I-=1
else:
break
while I>=2:
count+=4
I-=2
while O!=0:
count+=2
O-=1
while J>=2:
count+=3
J-=2
while L>=2:
count+=3
L-=2
print(str(int(count/2))) |
s259411663 | p03838 | u139629238 | 1551828488 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 244 | input_nums = [int(c) for c in input().split(" ")]
x = input_nums[0]
y = input_nums[1]
ad = 0
if x = y:
print(0)
return
if x > y:
ad = 2
if (x < 0 and y > 0) or (x >= 0 and y <= 0):
ad = 1
x, y = abs(x), abs(y)
print(abs(x-y)+ad)
|
s065095011 | p03838 | u367130284 | 1551336444 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 460 | a,b=map(int,input().split())
ans=0
if a==b:
print(0)
exit()
if b>0:
if abs(a)<abs(b):
if a<0:
ans+=1
ans+=b+a
else:
ans+=b-a
else:
if a<0:
raise "eerot"
ans+=abs(a)-b+1 #正
else:
ans+=a-b+1 #正
else:
if abs(a)<abs(b):
if a<0:
ans+=2
ans+=a-b
else:
ans+=abs(b)-a
ans+=1
else:
if a<0: #正
ans+=b-a
else:
ans+=a+b+1 #正
print(ans) |
s498852335 | p03838 | u367130284 | 1551336403 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 458 | a,b=map(int,input().split())
ans=0
if a==b:
print(0)
exit()
if b>0:
if abs(a)<abs(b):
if a<0:
ans+=1
ans+=b+a
else:
ans+=b-a
else:
raise "eerot"
if a<0:
ans+=abs(a)-b+1 #正
else:
ans+=a-b+1 #正
else:
if abs(a)<abs(b):
if a<0:
ans+=2
ans+=a-b
else:
ans+=abs(b)-a
ans+=1
else:
if a<0: #正
ans+=b-a
else:
ans+=a+b+1 #正
print(ans) |
s249849692 | p03838 | u367130284 | 1551336350 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 458 | a,b=map(int,input().split())
ans=0
if a==b:
print(0)
exit()
if b>0:
if abs(a)<abs(b):
raise "eerot"
if a<0:
ans+=1
ans+=b+a
else:
ans+=b-a
else:
if a<0:
ans+=abs(a)-b+1 #正
else:
ans+=a-b+1 #正
else:
if abs(a)<abs(b):
if a<0:
ans+=2
ans+=a-b
else:
ans+=abs(b)-a
ans+=1
else:
if a<0: #正
ans+=b-a
else:
ans+=a+b+1 #正
print(ans) |
s924976161 | p03838 | u367130284 | 1551336310 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 456 | a,b=map(int,input().split())
ans=0
if a==b:
print(0)
exit()
if b>0:
raise "eerot"
if abs(a)<abs(b):
if a<0:
ans+=1
ans+=b+a
else:
ans+=b-a
else:
if a<0:
ans+=abs(a)-b+1 #正
else:
ans+=a-b+1 #正
else:
if abs(a)<abs(b):
if a<0:
ans+=2
ans+=a-b
else:
ans+=abs(b)-a
ans+=1
else:
if a<0: #正
ans+=b-a
else:
ans+=a+b+1 #正
print(ans) |
s666610597 | p03838 | u391875425 | 1551332544 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 316 | x, y = map(int, input().split())
X = abs(x)
Y = abs(y)
if x * y < 0:
print(max(Y - X, X - Y) + 1)
else:
print(max(x - y, y - x) + 2 * (y < x))x, y = map(int, input().split())
X = abs(x)
Y = abs(y)
if x * y < 0:
print(max(Y - X, X - Y) + 1)
elif x * y > 0:
print(max(x - y, y - x) + (y < x) + (X > 0)) |
s455715492 | p03838 | u620480037 | 1550525642 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 432 | if B==0 and 0>A:
print(abs(A))
elif B>=A and A>=0:
print(B-A)
elif B>=0 and 0>=A:
if abs(B)>=abs(A):
print(abs(B)-abs(A)+1)
else:
print(abs(A)-abs(B)+1)
elif 0>=B and B>=A:
print(abs(A)-abs(B))
elif A>B and B>=0:
print(A-B+2)
elif A>=0 and 0>=B:
if abs(A)>=abs(B):
print(abs(A)-abs(B)+1)
else:
print(abs(B)-abs(A)+1)
elif 0>=A and A>=B:
print(abs(B)-abs(A)+2) |
s028419051 | p03838 | u375616706 | 1548863846 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 500 | x, y = map(int, input().split())
ans = 0
diff = y-x
abs_diff = abs(abs(y)-abs(x))
ans += abs_diff
if abs_diff == diff:
ans += 0
elif diff == -1*(abs_diff):
ans += 2
if x == 0 or y == 0:
ans -= 1
else:
ans += 1
print(ans)
x, y = map(int, input().split())
ans = 0
diff = y-x
abs_diff = abs(abs(y)-abs(x))
ans += abs_diff
if abs_diff == diff:
ans += 0
elif diff == -1*(abs_diff):
ans += 2
if x == 0 or y == 0:
ans -= 1
else:
ans += 1
print(ans)
|
s676037155 | p03838 | u371467115 | 1547426393 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 118 | x,y=map(int,input().split())
if abs(x)==abs(y):
print(1)
elif if x<y:
print(abs(x-y))
else:
print(abs(x-y)+2)
|
s569323241 | p03838 | u459233539 | 1546491702 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 201 | x, y = map(int, input().split())
if (0 =< x < y) or (x < y =< 0):
print(y - x)
elif (0 < y < x) or (y < x < 0):
ans = 2 + abs(x - y)
print(ans)
else:
ans = 1 + abs(abs(x) - abs(y))
print(ans) |
s341635071 | p03838 | u787562674 | 1546470551 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 396 | x, y = map(int, input().split())
if x >= 0 and y >= 0:
if x =< y:
print(y - x)
else:
if y == 0:
print(1 + x - y)
else:
print(x - y + 2)
elif x < 0 and y < 0:
if y >= x:
print(y - x)
else:
print(2 + x - y)
else:
if y == 0:
print(abs(abs(x) - abs(y)) + 1)
else:
print(abs(abs(x) - abs(y)) + 2) |
s960634412 | p03838 | u371467115 | 1546105862 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 185 | x,y=map(int,input(.split())
if x==y:
print(0)
elif (x<0)^(y<0):
print(abs(abs(x)-abs(y))+1)
elif x<0 and y<0:
print(abs(abs(x)-abs(y))+2)
else:
print(abs(abs(x)-abs(y))) |
s520653748 | p03838 | u371467115 | 1546104829 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 228 | x,y=map(int,input().split())
if x<0:
if y<0:
print(abs(abs(x)-abs(y))+2)
else:
print(abs(abs(x)-abs(y))+1)
else:
if y<0:
printabs((abs(x)-abs(y))+1)
else:
print(abs(abs(x)-abs(y))) |
s156588195 | p03838 | u983918956 | 1545803796 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 537 | x,y = map(int,input().split())
if x == y:
ans = 0
elif 0 <= x < y:
ans = y - x
elif 0 <= y < x:
if y == 0:
ans = 1 + x
else:
ans = 1 - y + x + 1
elif x < y <= 0:
ans = y - x
elif y < x <= 0:
if x == 0:
ans = - y + 1
else:
ans = 1 - y + x + 1
elif x < y:
if abs(x) < abs(y):
ans = 1 + y + x
elif abs(x) > abs(y):
ans = - y - x + 1
elif y < x:
if abs(x) < abs(y):
ans = - y - x + 1
elif abs(x) > abs(y):
ans = 1 + y + x
print(ans) |
s929767855 | p03838 | u136647933 | 1545007174 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 264 | x,y=map(int,input().split())
if x=y:
result=0
elif y>x:
if x<=0 and y>=0 and (x+y)/2>=0:
result=y-abs(x)+1
else:
result=y-x
elif x>=y:
if y>=0:
result=y+x+1
elif x<=0:
result=x-y+2
else:
result=abs(abs(x)-abs(y))+1
print(result) |
s073561937 | p03838 | u177040005 | 1542426783 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 588 | x,y = map(int, input().split())
ans = 0
if x == y:
ans = 0
elif abs(x) == abs(y):
ans = 1
elif x > 0 and y > 0:
if x < y:
ans = y - x
else:
ans = 2 + (x - y)
elif x < 0 and y < 0:
if abs(x) < abs(y):
ans = 2 + abs(abs(x) - abs(y))
else:
ans = 2 + abs(abs(x) - abs(y))
elif x*y < 0:
ans = 1 + abs(abs(b) - abs(a))
elif x*y == 0:
if x == 0:
if y > 0:
ans = y
else:
ans = abs(y) + 1
else:
if x > 0:
ans = 1 + x
else:
ans = abs(x)
print(ans)
|
s330770068 | p03838 | u138486156 | 1539377681 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 331 | x, y = map(int, input().split())
if x >= y:
if 0 > x:
ans = x-y+2
else:
if 0 >= y:
ans = abs(abs(y)-x) + 1
else:
ans(x+y)+1
else:
if 0 > y:
ans = y-x
else:
if 0 >= x:
ans = abs(y-abs(x)) + 1
else:
ans = y-x
print(ans)
|
s918146110 | p03838 | u761989513 | 1539107792 | Python | Python (3.4.3) | py | Runtime Error | 148 | 12392 | 213 | import numpy as np
x, y = map(int, input().split())
if abs(x) == abs(y):
print(1)
elif np.sign(x) == np.sign():
if x < y:
print(y - x)
else:
print(x - y + 2)
else:
print(x + y + 1) |
s535943581 | p03838 | u115682115 | 1538065198 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 197 | x,y = map(int,input().split())
if abs(y) > abs(x):
if x < 0:ans += 1
if y < 0:ans += 1
ans += (abs(y)-abs(x))
else:
if x > 0:ans += 1
if y > 0:ans += 1
ans += (abs(x)-abs(y))
print(ans) |
s253924232 | p03838 | u667024514 | 1537505020 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 205 | n,m = map(int,input().split())
ans = 0
if abs(y) > abs(x):
if x < 0:ans += 1
if y < 0:ans += 1
ans += (abs(y)-abs(x))
else:
if x > 0:ans += 1
if y > 0:ans += 1
ans += (abs(x)-abs(y))
print(ans) |
s767444746 | p03838 | u667024514 | 1537504589 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 217 | n,m = map(int,input().split())
cou = 0
if n != 0 and m != 0:
if n / m < 0:
cou += 1
n *= (-1)
elif n < 0 and m < 0:
cou += 2
n *= (-1)
m *= (-1)
else:
continue
print(cou + abs(n-m))
|
s423883373 | p03838 | u729707098 | 1536815076 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 142 | a = [int(i) for i in input().split()]
f = lambda x: max(0,x-x%2)
print(max(a[1]+f(a[0])+f(a[3])+f(a[4]),a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3)) |
s909059736 | p03838 | u548624367 | 1531520159 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 131 | def f(x,y):
if x*y < 0:
return min(f(-x,y),f(y,-x))
else:
return x-y+2 if x>y else x-y
print(f(x,y=map(int,input().split()))) |
s994968431 | p03838 | u548624367 | 1531520119 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 127 | def f(x,y):
if x*y < 0:
return min(f(-x,y),f(y,-x))
else:
return x-y+2 if x>y else x-y
print(f(map(int,input().split()))) |
s845035622 | p03838 | u548624367 | 1531520095 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 133 | def f(x,y):
if x*y < 0:
return min(f(-x,y),f(y,-x))
else:
return x-y+2 if x>y else x-y
print(f(list(map(int,input().split())))) |
s619258987 | p03838 | u136090046 | 1529425410 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 123 | n, m = map(int, input().spllit())
tmp = abs(n)-abs(m)
print(tmp if (n <= 0 and m <= 0) or (n >= 0 and m >= 0) else tmp+1)
|
s948529576 | p03838 | u136090046 | 1529425372 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 121 | n, m = map(int, input().spllit())
tmp = abs(n)-abs(m)
print(tmp if (n <= 0 and m <= 0) or (n >= 0 and m >= 0) else tmp+1 |
s247194182 | p03838 | u875361824 | 1528172165 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 916 | def main():
x, y = map(int, input().split())
if x == y:
ans = 0
if x >= 0 and y >= 0:
if x < y:
# x:1, y:3
ans = y - x
else:
# x:3, y:1
# x:-3,-2,-1,0,1
ans = 1 + y + x
elif x < 0 and y < 0:
if x < y:
# x:-3, y:-1
ans = y - x
else:
# x:-1, y:-3
# x:1,2,3,-3
ans = 1 + abs(y - x) + 1
elif x < 0 < y:
if abs(x) <= y:
# x:-3, y:4
# x:3,4
ans = 1 + y + x
else:
# x:-5, y:4
# x:-4,4
ans = abs(y + x) + 1
elif x > 0 > y:
if x >= abs(y):
# x:3, y:-1
# x:-3,-2,-1
ans = 1 + x + y
else:
# x:3, y:-4
ans = abs(y + x) + 1
print(ans)
if __name__ == '__main__':
main()
|
s396510328 | p03838 | u875361824 | 1528169586 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 855 | def main():
x, y = map(int, input().split())
if x == y:
ans = 0
if x >= 0 and y >= 0:
if x < y:
# x:1, y:3
ans = y - x
else:
# x:3, y:1
ans = 1 + y + x
elif x < 0 and y < 0:
if x < y:
# x:-3, y:-1
ans = y - x
else:
# x:-1, y:-3
# x:1,2,3,-3
ans = 1 + abs(y - x) + 1
elif x < 0 < y:
if abs(x) < y:
# x:-3, y:4
# x:3,4
ans = 1 + y + x
else:
# x:-5, y:4
ans = y - x
elif x > 0 > y:
if x > abs(y):
# x:3, y:-1
# x:-3,-2,-1
ans = 1 + x + y
else:
# x:3, y:-4
ans = abs(y + x) + 1
print(ans)
if __name__ == '__main__':
main()
|
s917111154 | p03838 | u846150137 | 1526863498 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 251 | a,b=[int(i) in i for input().split()]
abab=abs(abs(a) - abs(b))
saab=abs(b-a)
if b < a and b * a >0:
print(saab + 2)
elif b > a and b * a >0:
print(saab)
elif b < a and b * a <0:
print(saab + 1)
elif b > a and b * a >0:
print(max(saab,abab+1)) |
s335233234 | p03838 | u465486408 | 1525965508 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 500 | a, b = map(int,input().split())
x, y = abs(a), abs(b)
if a >= 0:
if b > 0:
if a > b:
a, b = map(int,input().split())
x, y = abs(a), abs(b)
if a >= 0:
if b > 0:
if a > b:
ans = abs(x-y) + 2
else:
ans = abs(x-y)
else:
ans = abs(x-y) + 1
else:
if b >= 0:
ans = min(abs(x-y)+1, b - a)
else:
if b > a:
ans = abs(x-y)
else:
ans = abs(x-y) + 2
print(ans) |
s773702058 | p03838 | u294000907 | 1523591661 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 211 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 数値の読み込み
x = int(input())
y = int(intpu())
res = 0
if x < 0:
res = res + 1
if y < 0:
res = res + 1
res = res + (abs(y)-abs(x))
print(res) |
s369525331 | p03838 | u729707098 | 1522452849 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 401 | x,y = (int(i) for i in input().split())
if abs(x)>abs(y):
if x<0 and y<=0: answer = y-x
elif (x<0 and y>0) or (x>0 and y<=0): answer = abs(x)-abs(y)+1
elif x>0 and y>0: answer = abs(x)-abs(y)+2
elif abs(x)==abs(y): answer = 1
elif abs(x)<abs(y):
if x>=0 and y>0: answer = y-x
elif (x>0 and y<0) or (x<=0 and y>0): answer = abs(y)-abs(x)+1
elif x<0 and y<0: answer = abs(y)-abs(x)+2
print(answer) |
s126107085 | p03838 | u811528179 | 1519273210 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 215 | x,y=map(int,input().split())
count=0
xlist=[x,-x,x,-x]
ylist=[y,y,-y,-y]
numlist=[0,1,1,2]
ans=10**9+7
for i in range(4):
if xlist[i] <= ylist(i):
ans=min(ans,numlist[i]+ylist[i]-xlist[i])
print(ans)
|
s876985980 | p03838 | u443684067 | 1484606721 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 182 | # -*- coding: utf-8 -*-
# 整数の入力
x = int(raw_input())
y=int (raw_input())
if y<0 and abs(y)<abs(x):
print "not"
elif x*y>0:
print y-x
else:
print abs(abs(y)-abs(x))+1
|
s507820730 | p03838 | u443684067 | 1484606202 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2568 | 154 | # -*- coding: utf-8 -*-
# 整数の入力
x = int(raw_input())
y=int (raw_input())
if x>0 and y>0 and y>x:
print y-x
else:
print abs(abs(y)-abs(x))+1 |
s747660186 | p03838 | u443684067 | 1484606058 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 196 | # -*- coding: utf-8 -*-
# 整数の入力
x = int(raw_input())
y=int (raw_input())
if y<0 and abs(y)<abs(x):
print "not"
elif x>0 and y>0 and y>x:
print y-x
else:
print abs(abs(y)-abs(x))+1
|
s670422356 | p03838 | u140672616 | 1483841138 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3068 | 30 | print(input().replace(","," ") |
s595252518 | p03838 | u778736942 | 1483006809 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 579 | N = int(input())
X = list(map(int, input().split()))
A = [-1]*N*N
sorted_X = sorted(X)
fail_flag = 0
for i in range(N):
x = sorted_X[i]
K = X.index(x)+1
if A[x-1]==-1:
A[x-1] = K
else:
print("No")
fail_flag = 1
break
K_rest = K-1
j = 0
while K_rest>0:
if j==x-1:
print("No")
fail_flag = 1
break
if A[j]==-1:
A[j] = K
K_rest = K_rest-1
j = j+1
count = 0
num = 1
for i in range(N*N):
if A[i]==-1:
A[i] = num
count = count+1
if count==N-num:
num = num+1
count = 0
if fail_flag==0:
print("Yes")
for a in A:
print(str(a), end=" ")
|
s343307935 | p03838 | u778736942 | 1482917980 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 252 | A = list(map(int, input().split()))
K = 0
K = K+A[1]
if A[0]%2==0 and A[3]%2==0 and A[4]%2==0:
K = K+A[0]+A[3]+A[4]
elif A[0]%2!=0 and A[3]%2!=0 and A[4]%2!=0:
K = K+A[0]+A[3]+A[4]
elif A[0]+A[3]+A[4]<=2:
pass
else:
K = K+A[0]+A[3]+A[4]-1
print(K)
|
s244061718 | p03838 | u778736942 | 1482917733 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 252 | A = list(map(int, input().split()))
K = 0
K = K+A[1]
if A[0]%2==0 and A[3]%2==0 and A[4]%2==0:
K = K+A[0]+A[3]+A[4]
elif A[0]%2!=0 and A[3]%2!=0 and A[4]%2!=0:
K = K+A[0]+A[3]+A[4]
elif A[0]+A[3]+A[4]<=2:
pass
else:
K = K+A[0]+A[3]+A[4]-1
print(K)
|
s057566124 | p03838 | u762677575 | 1482760708 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 268 | x, y = map(int, raw_input().split())
if x < y:
print y - x
elif x > y:
if x < 0:
print x - y + 2
elif x >= 0:
if abs(y) > x:
print -x - y + 1
elif abs(y) = x:
print 1
else:
print x + y + 1 |
s947854645 | p03838 | u365153156 | 1482758611 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2688 | 257 | x, y = map(int, input().split())
ans = (abs(x) + abs(y)) * 2
if x < y:
ans = min(ans, y - x)
if -x <= y:
ans = min(ans, y - (-x) + 1)
if x <= -y:
ans = min(ans, (-y) - x + 1)
if -x < -y:
ans = min(ans, (-y) - (-x) + 2)
print(ans) |
s268552378 | p03838 | u434647865 | 1482724912 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 186 | aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())
if aL%2 and aJ%2:
print(int((aI-1)/2)*2+aO+int(aJ/2)*2+int(aL/2)*2+3)
else:
print(int(aI/2)*2+aO+int(aJ/2)*2+int(aL/2)*2)
|
s142630254 | p03838 | u434647865 | 1482724711 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3064 | 186 | aI, aO, aT, aJ, aL, aS, aZ = map(int, input().split())
if aL%2 and aJ%2:
print(int((aI-1)/2)*2+aO+int(aJ/2)*2+int(aL/2)*2+3)
else:
print(int(aI/2)*2+aO+int(aJ/2)*2+int(aL/2)*2)
|
s961594227 | p03838 | u701743518 | 1482722104 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 242 | # coding: utf-8
I, O, T, J, L, S, Z = [int(i) for i in input().split()]
K = (I//2)*2 + O + (J//2)*2 + (L//2)*2
if I % 2 == 1 and J % 2 == 1 and L % 2 ==1:
K += 3
elif (I % 2 + J % 2 + L % 2 == 2) and (I * J * L > 0):
K += 1
print(K) |
s804837862 | p03839 | u814986259 | 1596778677 | Python | Python (3.8.2) | py | Runtime Error | 86 | 20032 | 322 | N,K=map(int,input().split())
a=list(map(int,input().split()))
ans=0
tmp=0
for i in range(N):
if i < K:
tmp+=a[i]
else:
if a[i]>0:
ans+=a[i]
ans+=max(0,tmp)
ans2=0
tmp=0
for i in range(N-1,-1,-1):
if ans < N-K:
if a[i]>0:
ans2+=a[i]
else:
tmp+=a[i]
ans2+=max(0,tmp)
print(max(ams2,ans)) |
s541695291 | p03839 | u102445737 | 1596155158 | Python | PyPy3 (7.3.0) | py | Runtime Error | 100 | 86704 | 684 | #from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353
def ddprint(x):
if DBG:
print(x)
n,k = inm()
a = inl()
if n==4 and k==2:
3/0
mx = sum(a)
lacc = [0]*(n+1)
racc = [0]*(n+1)
for i in range(n):
lacc[i+1] = lacc[i]+max(a[i],0)
for i in range(n-1,-1,-1):
racc[i] = racc[i+1]+max(a[i],0)
sk = sum(a[:k])
for i in range(n-k+1):
mx = max(mx,lacc[i]+max(sk,0)+racc[i+k])
if i<n-k:
sk += a[i+k]-a[i]
print(mx)
|
s067228618 | p03839 | u102445737 | 1596154867 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2211 | 220052 | 633 | #from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl = lambda: list(map(int, input().split()))
inm = lambda: map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353
def ddprint(x):
if DBG:
print(x)
n,k = inm()
a = inl()
if n==k==1:
3/0
mx = sum(a)
lacc = [0]*(n+1)
racc = [0]*(n+1)
for i in range(n):
lacc[i+1] = lacc[i]+max(a[i],0)
for i in range(n-1,-1,-1):
racc[i] = racc[i+1]+max(a[i],0)
for i in range(n-k+1):
mx = max(mx,lacc[i]+max(sum(a[i:i+k]),0)+racc[i+k])
print(mx)
|
s772447927 | p03839 | u034128150 | 1595774146 | Python | PyPy3 (7.3.0) | py | Runtime Error | 106 | 84940 | 607 | from itertools import accumulate
N, K = map(int, input().split())
As = list(map(int, input().split()))
csum = list(accumulate(As, initial = 0))
csum_of_positives = list(accumulate([max(A, 0) for A in As], initial = 0))
#[i, i+K) will be all white/black.
max_score = 0
for i in range(N-K+1):
score = 0
all_black = csum[i+K] - csum[i]
if all_black > 0: # if [i, i+K) is worth painting with black
score += all_black
score += csum_of_positives[i] #[0, i)
score += csum_of_positives[N] - csum_of_positives[i+K] #[i+K, N)
max_score = max(max_score, score)
print(max_score)
|
s079709199 | p03839 | u102461423 | 1592629434 | Python | Python (3.8.2) | py | Runtime Error | 114 | 26796 | 693 | import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit('(i8,i8,i8[:])', cache=True)
def main(N, K, A):
B = np.maximum(A, 0)
Acum = np.zeros(len(A) + 1, np.int64)
Bcum = np.zeros(len(A) + 1, np.int64)
Acum[1:] = np.cumsum(A)
Bcum[1:] = np.cumsum(B)
ret = -(10**18)
for l in range(N - K + 1):
r = l + K
sum1 = Bcum[l]
sum2 = Bcum[-1] - Bcum[r]
sum3 = Acum[r] - Acum[l]
x = sum1 + sum2 + max(sum3, 0)
ret = max(ret, x)
return ret
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)
print(main(N, K, A))
|
s001668204 | p03839 | u476604182 | 1584300336 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 300 | from itertools import accumulate as acc
N, K, *A = map(int, open('0').read().split())
B = [0]+list(acc(A))
M = list(acc(a if a>0 else 0 for a in A))
ans = -10**30
s = sum(A)
for i in range(N-K+1):
mi = B[i+K]-B[i]
c = M[N-1] - M[i+K-1]
if i>0:
c += M[i-1]
ans = max(ans,mi+c,c)
print(ans) |
s485213919 | p03839 | u399721252 | 1572778389 | Python | PyPy3 (2.4.0) | py | Runtime Error | 228 | 70048 | 368 | n, k = [ int(v) for v in input().split() ]
num = [ int(v) for v in input().split() ]
num_2 = [ max(i,0) for i in num ]
cum_num, cum_num_2 = [0] + cumsum(num), [0] + cumsum(num_2)
ans = 0
for i in range(n-k+1):
ansl = cum_num_2[i]
ansm = cum_num[k+i] - cum_num[i]
ansr = cum_num_2[n] - cum_num_2[i+k]
ans = max(ansl+max(ansm,0)+ansr, ans)
print(ans) |
s126598071 | p03839 | u933129390 | 1562026463 | Python | Python (3.4.3) | py | Runtime Error | 2108 | 14236 | 317 | n, k = map(int, input().split())
a = list(map(int, input().split()))
if k == 1:
print(a(max))
else:
sum_a = []
anslist = []
for i in range(n):
sum_a.append(sum(a[0:i+1]))
if i >= k-1:
anslist.append(sum_a[i] - sum_a[i-k])
print(sum_a)
print(anslist)
print(max(anslist)) |
s427985127 | p03839 | u798129018 | 1560544456 | Python | PyPy3 (2.4.0) | py | Runtime Error | 234 | 67616 | 272 | N,K = map(int,input().split())
a = list(map(int,input().split()))
A = [0]*(N+1)
S = [0]*(N+1)
for i in range(N):
A[i+1] = A[i]+max(0,a[i])
S[i+1] = S[i]+a[i]
ans = -inf
for i in range(0,N-K+1):
ans = max(ans,A[i]+max(0,S[i+K]-S[i])+(A[N]-A[i+K]))
print(ans) |
s171001870 | p03839 | u674885198 | 1553836925 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 240 | a,square,qqq,b,c,qqqq,qqqqq= list(map(int,input().split()))
a_ = a%2
b_ = b%2
c_ = c%2
a_sub = a-a_
b_sub = b-b_
c_sub = c-c_
if a_ == 1 and b_==1 and c_==1:
print(a_sub+b_sub+c_sub+3+square)
else:
print(a_sub+b_sub+c_sub+square) |
s433479080 | p03839 | u785578220 | 1553293836 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38384 | 309 | N, K = map(int, input().split())
a = list(map(int, input().split()))
sa = [0]
sb = [0]
for i in range(N):
sa.append(sa[-1] + a[i])
sb.append(sb[-1] + max(0, a[i]))
ans = 0
for i in range(N - K + 1):
a = sa[i + K] - sa[i]
b = sb[i + K] - sb[i]
ans = max(ans, sb[N] - b + max(a, 0))
print(ans)
|
s924597781 | p03839 | u270681687 | 1550751009 | Python | PyPy3 (2.4.0) | py | Runtime Error | 218 | 66080 | 455 | n, k = map(int, input().split())
a = list(map(int, input().split()))
cum = []
abscum = []
cu = 0
acu = 0
for i in range(n):
cu += a[i]
acu += abs(a[i])
cu.append(cum)
acu.append(abscum)
ans = 0
for i in range(n-k):
if i == 0:
ans = max(ans, abscum[n-1] - abscum[i+k-1] + abs(cum[i+k-1]))
else:
ans = max(ans, abscum[n - 1] - (abscum[i + k - 1] - abscum[i-1]) + abs(cum[i + k - 1] - cum[i-1]))
print(ans) |
s910035041 | p03839 | u608088992 | 1544027259 | Python | Python (3.4.3) | py | Runtime Error | 212 | 20140 | 666 | N, K = map(int, input().split())
A = [int(a) for a in input().split()]
Plus, Whole = [0], [0]
for i in range(N):
Plus.append(Plus[-1] + max(A[i], 0))
Whole.append(Whole[-1] + A[i])
Full = Plus[N-K] - Plus[0] + Whole[N] - Whole[N-K]
MaxScore = max(Full, Plus[N-K] - Plus[0])
for i in range(1, K):
temp = Plus[N-K] - Plus[0] + Whole[N]-Whole[N-K+i] - (Plus[N-K] - Plus[N+1 -2*K])
MaxScore = max(MaxScore, temp)
Fullb = Plus[N] - Plus[K] + Whole[K] - Whole[0]
MS2 = max(Fullb, Plus[N] - Plus[N-K])
for i in range(1, K):
temp = Plus[N] - Plus[K] + Whole[K] - Whole[K-i] - (Plus[2*K-i] - Plus[K])
MS2 = max(MS2, temp)
print(max(MaxScore, MS2)) |
s819370007 | p03839 | u729133443 | 1532415045 | Python | PyPy3 (2.4.0) | py | Runtime Error | 229 | 66848 | 269 | n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
s=[0]
p=[0]
for i in range(1,n+1):
s[i].append(s[i-1]+a[i])
p[i].append(p[i-1]+max(0,a[i]))
ans=0
for i in range(1,n-k+1):
t=max(0,s[i+k]-s[i-1])
t+=p[i-1]+p[n]-p[i+k]
ans=max(ans,t)
print(ans) |
s686084235 | p03839 | u579875569 | 1526065917 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 478 | #include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
int main(void) {
int N, K; cin >> N >> K;
vector<int> A(N); for (auto &a : A) cin >> a;
int res = 0;
for (auto &a : A) res += max(a, 0);
for (auto &a : A) if(a > 0) a = 0;
int sum = 0;
for (int i = 0; i < K; ++i) {
sum += A[i];
}
int mi = -1e9-1;
for (int i = K; i < N; ++i) {
sum -= A[i-K];
sum += A[i];
mi = max(sum, mi);
}
cout << res + mi << endl;
}
|
s586250294 | p03839 | u272028993 | 1496203944 | Python | Python (2.7.6) | py | Runtime Error | 102 | 12232 | 368 | n,k=map(int,raw_input().split())
a=map(int,raw_input().split())
s1=[0]*n
s1[0]=a[0]
s2=[0]*n
if a[0]>0:
s2[0]=a[0]
for i in xrange(1,n):
s1[i]+=s1[i-1]+a[i]
if a[i]>0:
s2[i]+=s2[i-1]+a[i]
ans=-float("inf")
for i in xrange(n-k+1):
tmp1=s1[i+k-1]-s1[max(0,i-1)]
tmp2=s2[n]-(s2[i+k-1]-s2[max(0,i-1)])
ans=max(ans,tmp1+tmp2,tmp2)
print ans
|
s299895739 | p03840 | u761320129 | 1584707871 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 187 | I,O,_,J,L,_,_ = map(int,input().split())
ans1 = O + I-I%2 + J-J%2 + L-L%2
ans2 = 0
if I and J and K:
I,J,K = I-1,J-1,K-1
ans2 = 3 + O + I-I%2 + J-J%2 + L-L%2
print(max(ans1,ans2)) |
s112310523 | p03840 | u186838327 | 1584707856 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38384 | 285 | I, O, T, J, L, S, Z = map(int, input().split())
k0 = 0
k0 += (I//2)*2
k0 += (J//2)*2
k0 += (L//2)*2
k1 = 0
if I >= 1 and J >= 1 and L >= 1:
k1 = 0
k += 3
I -= 1
J -= 1
L -= 1
k1 += (I//2)*2
k1 += (J//2)*2
k1 += (L//2)*2
k = max(k0, k1)
k += O
print(k) |
s147573672 | p03840 | u984276646 | 1580324317 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 258 | A = list(map(int, input().split()))
S = A[1]
S += (A[0] // 2) * 2
T = S
if A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:
S += (A[4] // 2) * 2 + (A[5] // 2) * 2
A[4] -= 1
A[5] -= 1
T += 3
T += (A[4] // 2) * 2 + (A[5] // 2) * 2
print(max(S, T))
|
s609811950 | p03840 | u813174766 | 1579816432 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 198 | a=list(map(int,input().split()))
ans=min(a[0],a[3],a[4])
a[0]-=ans
a[3]-=ans
a[4]-=ans
ans*=3
if(ans>0&&(a[0]%2+a[3]%2+a[4]%2==2)):
ans+=1
ans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]
print(ans)
|
s617511759 | p03840 | u227082700 | 1577920188 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 129 | I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(I,J,L):
I-=m
J-=m
L-=m
ans+=m*3
ans+=I//2*2
ans+=J//2*2
ans+=L//2*2
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.