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
s627032642
p03862
u282978698
1586487142
Python
PyPy3 (2.4.0)
py
Runtime Error
2107
63984
242
X = [int(e) for e in input().split()] A = [int(f) for f in input().split()] i=0 ans=0 while i<X[0]: if(A[i] + A[i+1]) <= X[1] and i+1 < X[0]: i+=1 else: A[i+1] -= 1 ans += 1 continue i+=1 print(ans)
s167422798
p03862
u757030836
1586194073
Python
Python (3.4.3)
py
Runtime Error
17
3060
135
A=list(map(int,input().split())) +[0] ans =0 for i in range(N): eated =max(0,A[i]+A[i-1]-x) ans +=eated A[i]-=eated print(ans)
s774918901
p03862
u787449825
1586068561
Python
Python (3.4.3)
py
Runtime Error
17
3060
235
N, x = map(int, input().split()) a = list(map(int, inout().split())) count = 0 for i in range(N-1): while a[i]+a[i+1]>x: if a[i]>a[i+1]: a[i] -= 1 count += 1 else: a[i+1] -= 1 count += 1 print(count)
s772831070
p03862
u787449825
1586068339
Python
Python (3.4.3)
py
Runtime Error
17
2940
262
N, x = map(int, input().split()) a = list(map(int, input().split())) count = 0 for i in range(N-1): while a[i]+a[i+1] > x: if a[i]>a[i+1]: a[i] -= 1 count += 1 else: a[i+1] -= 1 count += 1 print(count)
s169802023
p03862
u395816772
1585778185
Python
Python (3.4.3)
py
Runtime Error
130
13380
246
n,x = map(int,input().split()) a = list(input().split()) ans = 0 if int(a[0]) > x: ans += a[0]-x a[0] = x for i in range(n-1): c = int(a[i+1]) + int(a[i]) if c > x: ans += c-x a[i+1] = int(a[i+1])-(c-x) print(ans)
s059983844
p03862
u750838232
1585250307
Python
Python (3.4.3)
py
Runtime Error
17
3060
134
A=list(map(int,input().split()))+[0] ans=0 for i in range(N): eated=max(0,A[i]+A[i-1]-x) ans+=eated A[i]-=eated print(ans)
s633798349
p03862
u934868410
1584019835
Python
Python (3.4.3)
py
Runtime Error
137
14132
246
n,x = map(int,input().split()) a = list(map(int,input().split())) b = [a[i] + a[i+1] for i in range(n-1)] ans = max(0, a[0] - x) b[0] -= ans for i in range(n-1): diff = max(0, b[i] - x) ans += diff b[i] -= diff b[i+1] -= diff print(ans)
s651555981
p03862
u620157187
1582750786
Python
Python (3.4.3)
py
Runtime Error
137
14052
332
N, x = map(int, input().split()) a = list(map(int, input().split())) total = 0 for i in range(len(a)): if (a[i+1]+a[i])>=x: if (a[i+1]-(x-a[i]))>=0: a[i+1] = a[i+1]-(x-a[i]) total += x-a[i] else: a[i+1] = 0 total += x-a[i] else: pass print(total)
s734018865
p03862
u408375121
1582227320
Python
Python (3.4.3)
py
Runtime Error
42
14132
237
N, x = map(int, input().split()) A = list(map(int, input().split())) s = 0 for i in range(N - 1): s = A[i] + A[i + 1] - x ans += max(0, s) if s > 0: if s <= A[i + 1]: A[i + 1] -= s else: A[i + 1] = 0 print(ans)
s628614656
p03862
u408375121
1582227205
Python
Python (3.4.3)
py
Runtime Error
42
14132
230
N, x = map(int, input().split()) A = list(map(int, input().split())) for i in range(N - 1): s = A[i] + A[i + 1] - x ans += max(0, s) if s > 0: if s <= A[i + 1]: A[i + 1] -= s else: A[i + 1] = 0 print(ans)
s909757257
p03862
u414458988
1581989151
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38384
134
A=list(map(int,input().split()))+[0] ans=0 for i in range(N): eated=max(0,A[i]+A[i-1]-x) ans+=eated A[i]-=eated print(ans)
s524967120
p03862
u676029460
1581771637
Python
Python (3.4.3)
py
Runtime Error
26
11268
177
n,x =map(int,input().split()) a=[map(int,input().split())] ans=0 for i in range(n-1): if(a[i]+a[i+1]>x): p = a[i]+a[i+1]-x ans+=p a[i+1]=max(0,a[i+1]-p) print(ans)
s460255228
p03862
u711245972
1580529128
Python
Python (3.4.3)
py
Runtime Error
51
14068
224
n,x=map(int,input().split()) a=list(map(int,input().split())) eat=0 if a[0]>x: eat+=(a[0]-x) a[0]=x for i in range(1,n-1): if a[i-1]+a[i]>x: f=(a[i-1]+a[i]-x) eat+=f a[i]=a[i-f] print(eat)
s698619604
p03862
u171065106
1577967333
Python
Python (3.4.3)
py
Runtime Error
163
14844
538
n, x = map(int, input().split()) candies = list(map(int, input().split())) count = 0 for i in range(n): if candies[i] > x: count += candies[i] - x candies[i] = x if i % 2 is not 0: if candies[i-1] + candies[i] > x: count += candies[i-1] + candies[i] - x candies[i] -= candies[i-1] + candies[i] - x if i is not n-1 and candies[i+1] + candies[i] > x: count += candies[i+1] + candies[i] - x candies[i] -= candies[i+1] + candies[i] - x print(count)
s048642382
p03862
u867848444
1576811473
Python
Python (3.4.3)
py
Runtime Error
18
3060
185
a,b,x=map(int,input().split()) n=b-a+1 l=[0]*(n+1) init=a for i in range(1,n+1): if init%x==0: l[i]=l[i-1]+1 else: l[i]=l[i-1] init+=1 print(l[-1]-l[0])
s829281419
p03862
u261891508
1575239690
Python
Python (3.4.3)
py
Runtime Error
18
3188
338
n,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(n-1): if a[i]+a[i+1]>x:ใ€€#xใ‚’ไธŠๅ›žใ‚‹ๆ™‚ใฎใฟๆ“ไฝœใ‚’่กŒใ† temp=a[i]+a[i+1]-x #ๆธ›ใ‚‰ใ•ใชใใ‚ƒใ„ใ‘ใชใ„ๅ€‹ๆ•ฐ ans+=temp if a[i+1]>=temp: #ๆธ›ใ‚‰ใ™ใฎใฏๅ‡บๆฅใ‚‹ใ ใ‘ๅณๅด a[i+1]-=temp else: a[i+1]=0 print(ans)
s495948161
p03862
u457554982
1575002654
Python
Python (3.4.3)
py
Runtime Error
18
2940
299
import copy [n,x]=list(map(int,input().split())) a=list(map(int,input().split())) a0=copy.copy(a) ans=0 if a[0]+a[1]>x and a[0]>x: a[0]-=a[0]-x ans+=a0[0]-x if a[0]+a[1]>x: a[1]=0 ans+=a[1] for i in range(1,n-1): if a[i]+a[i+1]>x: a[i+1]-=a[i]+a[i+1]-x ans+=a[i]+a[i+1]-x print(ans)
s394841880
p03862
u457554982
1575002583
Python
Python (3.4.3)
py
Runtime Error
17
2940
298
import copy [n,x]=list(map(int,input().split())) a=list(map(int,input().split())) a0=copy.copy(a) ans=0 if a[0]+a[1]>x and a[0]>x: a[0]-=a[0]-x ans+=a[0]-x if a[0]+a[1]>x: a[1]=0 ans+=a[1] for i in range(1,n-1): if a[i]+a[i+1]>x: a[i+1]-=a[i]+a[i+1]-x ans+=a[i]+a[i+1]-x print(ans)
s501725986
p03862
u457554982
1575002556
Python
Python (3.4.3)
py
Runtime Error
18
2940
298
import copy [n,x]=list(map(int,input().split())) a=list(map(int,input().split())) a0=copy.copy(a) ans=0 if a[0]+a[1]>x and a[0]>x: a[0]-=a[0]-x and+=a[0]-x if a[0]+a[1]>x: a[1]=0 ans+=a[1] for i in range(1,n-1): if a[i]+a[i+1]>x: a[i+1]-=a[i]+a[i+1]-x ans+=a[i]+a[i+1]-x print(ans)
s320990321
p03862
u905582793
1574910906
Python
Python (3.4.3)
py
Runtime Error
2104
145940
452
N,x=map(int, input().split(' ')) a = list(map(int, input().split(' '))) wa = [a[0]]+[a[i]+a[i+1] for i in range(N-1)]+[a[-1]] ans = 0 for i in range(N): print(i, a,wa,ans) if wa[i] <= x: continue if a[i] >= x: ans += wa[i]-x a[i] -= wa[i]-x wa[i] -= wa[i]-x wa[i+1] -= wa[i+1]-x continue if a[i] < x: ans += wa[i]-x a[i] = 0 a[i] = x wa[i] = x print(ans)
s380478986
p03862
u580093517
1574710568
Python
Python (3.4.3)
py
Runtime Error
17
3060
134
A=list(map(int,input().split()))+[0] ans=0 for i in range(N): eated=max(0,A[i]+A[i-1]-x) ans+=eated A[i]-=eated print(ans)
s775375112
p03862
u518042385
1572935382
Python
Python (3.4.3)
py
Runtime Error
42
14544
207
n,m=map(int,input().split()) l=list(map(int,input().split())) count=0 if l[i]>m: count+=-m+l[i] l[i]=m for i in range(1,n): if l[i-1]+l[i]>m: count+=l[i]+l[i-1]-m l[i]=m-l[i-1] print(count)
s913393264
p03862
u518042385
1572935225
Python
Python (3.4.3)
py
Runtime Error
43
14540
205
n,m=map(int,input().split()) l=list(map(int,input().split())) count=0 if l[i]>m: count+=m-l[i] l[i]=m for i in range(1,n): if l[i-1]+l[i]>m: count+=l[i]+l[i-1]-m l[i]=m-l[i-1] print(count)
s190773049
p03862
u623516423
1572654138
Python
Python (3.4.3)
py
Runtime Error
2104
142948
268
N,x = list(map(int,input().split())) a=list(map(int,input().split())) eat=0 if a[0]>x: eat+=a[0]-x a[0]=x if a[N-1]>x: eat+=a[N-1]-x a[N-1]=x for i in range(N-1): print(eat,a) if a[i]+a[i+1]>x: eat+=a[i+1]-x+a[i] a[i+1]=x-a[i] print(eat)
s565754846
p03862
u506858457
1572134873
Python
Python (3.4.3)
py
Runtime Error
42
14252
176
N,x=list(map(int,input().split())) A=list(map(int,input().split())) cnt=0 pre=0 for i in range(N): dif=max(A[i]+pre-x,0) cnt+=dif arr[i]-=dif pre=arr[i] print(cnt)
s357857788
p03862
u345710188
1570810274
Python
Python (3.4.3)
py
Runtime Error
17
2940
249
N,x = map(int,input().split()) a = list(map(int,input().split())) i = 0 answer = 0 if a[0] > x: answer = a[0] - x a[0] = x for i in range(N-1) if a[i] + a[i+1] > x: answer += a[i] + a[i+1] - x a[i+1] = x - a[i] print(answer)
s859205699
p03862
u148423304
1570805579
Python
Python (3.4.3)
py
Runtime Error
107
14132
270
n, x = map(int, input().split()) a = list(map(int, input().split())) count = 0 for i in range(n - 2): if a[i] + a[i + 1] > x: count += a[i] + a[i + 1] - x a[i + 1] = x - a[i] if a[n - 1] + a[n] > x: count += a[n - 1] + a[n] - x print(int(count))
s416913682
p03862
u196697332
1569276736
Python
Python (3.4.3)
py
Runtime Error
43
14060
263
N, x = map(int, input().split()) A = list(map(int, input().split())) answer = 0 if A[0] > X: answer += A[0] - X A[0] = X for i in range(N-1): diff = A[i] + A[i+1] - X if diff > 0: answer += diff A[i+1] -= diff print(answer)
s000919397
p03862
u314050667
1568295794
Python
Python (3.4.3)
py
Runtime Error
21
2940
161
N,A=map(int,input().split()) a=list(map(int,input().split()) cnt=0 for i in range(1,N): tmp=max(0,(a[i-1]+a[i])-A) cnt+=tmp a[i]-=tmp print(cnt)
s587246507
p03862
u513900925
1567546672
Python
Python (3.4.3)
py
Runtime Error
18
3064
229
N,x = map(int,input().split()) a = [int(i) for i in input.split()] ans = 0 if a[0] > x: ans += (a[0]-x) a[0] = x for i in range(N-1): if a[i] + a[i+1] > x: ans += (a[i]+a[i+1]-x) a[i+1] -= (a[i]+a[i+1]-x) print(ans)
s535777046
p03862
u380683328
1567305679
Python
Python (3.4.3)
py
Runtime Error
126
14588
398
n, x = map(int, input().split()) a = list(map(int, input().split())) c = 0 if x == 0: print(sum(a)) if a[0] > x: c += a[i] - (x-1) a[i] = x - 1 else: for i in range(n-1): if a[i] + a[i+1] > x: if a[i+1] >= a[i]: c += (a[i+1] - (x - a[i])) a[i+1] -= (a[i+1] - (x - a[i])) else: c += (a[i+1] - abs(x - a[i])) a[i+1] -= (a[i+1] - abs(x - a[i])) print(c)
s385032413
p03862
u419636153
1567290710
Python
Python (3.4.3)
py
Runtime Error
130
14132
494
# -*- coding: utf-8 -*- """ Created on Sat Aug 31 14:24:15 2019 @author: priya """ inp = input().split() n = int(inp[0]) x = int(inp[1]) candies = [int(x) for x in input().split()] op = 0 for i in range(1,len(candies)): if candies[i-1] + candies[i] > x: eat = candies[i-1] + candies[i] - x if(eat > candies[i]): candies[i-1] -= eat - candies[i] candies[i] = 0 else: candies[i] -= eat op += eat print(op) #print(candies)
s818017486
p03862
u473016486
1567289645
Python
Python (3.4.3)
py
Runtime Error
2104
22912
3075
#!/usr/bin/env python # coding: utf-8 # In[30]: """ There are N boxes arranged in a row. Initially, the i -th box from the left contains a i candies. Snuke can perform the following operation any number of times: Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.""" # In[63]: rightDirective = 0 leftDirective = 1 def findSmallest(myList, index=1): newList = myList[:] newList.sort() smallestElement = newList[index-1] return myList.index(smallestElement) def anyElementGreater(myList, value): ret = False for i in myList: if i > value: ret = True else: continue return ret # In[68]: class CandyBoxes: N = 0 x = 0 candyList = [] sumList = [] toRemoveList = [] def __init__(self, N, x, candyList): self.N = N self.x = x self.candyList = candyList self.sumList = [] self.toRemoveList = [] for i in range(len(self.candyList) - 1): mySum = candyList[i] + candyList[i+1] self.sumList.append( mySum ) if mySum > x: self.toRemoveList.append( mySum - x ) else: self.toRemoveList.append( 0 ) def reconfigureBoxes(self): for i in range(len(self.toRemoveList)): mySum = self.candyList[i] + self.candyList[i+1] if mySum > self.x: self.toRemoveList[i] = mySum - x else: self.toRemoveList[i] = 0 self.sumList[i] = mySum def removeExtraCandies(self, direction): removed = 0 i = 1 while anyElementGreater(self.toRemoveList, x): currentIndex = findSmallest(self.toRemoveList, i) print(i, currentIndex, self.toRemoveList[currentIndex]) i+=1 if direction == leftDirective: if self.candyList[currentIndex] >= self.toRemoveList[currentIndex]: self.candyList[currentIndex] -= x self.reconfigureBoxes() continue elif self.candyList[currentIndex+1] >= self.toRemoveList[currentIndex]: self.candyList[currentIndex+1] -= x self.reconfigureBoxes() continue else: print("Not implemented") # In[81]: N, x = [int(i) for i in input().split()] candyInBox = [int(i) for i in input().split()] # In[82]: myCandy = CandyBoxes(N, x, candyInBox) # In[88]: print(myCandy.candyList) print(myCandy.sumList) print(myCandy.toRemoveList) # In[87]: myCandy.removeExtraCandies(leftDirective)
s279651698
p03862
u418466780
1566963834
Python
Python (3.4.3)
py
Runtime Error
87
14132
663
def computeMinimumNoOfOperations(candies, x): noOfOperations = 0 for i in range(len(candies) - 1): if (candies[i] > x): candiesTocandiesToEat = candies[i] - x candies[i] -= candiesTocandiesToEat noOfOperations += candiesToEat if (candies[i] + candies[i + 1] > x): candiesToEat = candies[i] + candies[i + 1] - x candies[i + 1] -= candiesToEat noOfOperations += candiesToEat return noOfOperations def start(): n, x = list(map(int, input().split())) candies = list(map(int, input().split())) return computeMinimumNoOfOperations(candies, x) print(start())
s552727604
p03862
u418466780
1566962416
Python
Python (3.4.3)
py
Runtime Error
17
2940
671
def computeMinimumNoOfOperations(candies, x): noOfOperations = 0 for i in range(0, len(candies) - 1): if (candies[i] > x): eat = candies[i] - x candies[i] -= eat noOfOperations += eat if (candies[i] + candies[i + 1] > x): if (candies[i] > candies[i + 1]): eat = candies[i] - x candies[i] -= eat noOfOperations += eat else: eat = candies[i + 1] - x candies[i + 1] -= eat noOfOperations += eat return noOfOperations def start(): n, x = list(map(int, input().split())) candies = list(map(int, input().split())) return computeMinimumNoOfOperations(candies, x) print(start())
s079140158
p03862
u594956556
1566959397
Python
Python (3.4.3)
py
Runtime Error
18
3060
84
s=input() n=len(s) if s[0]==s[-1] ^ n%2==0: print('Second') else: print('First')
s502059648
p03862
u993178579
1566941284
Python
Python (3.4.3)
py
Runtime Error
18
3064
605
def minimumNumOfCandies(candies,atmostValue): candiesToEat = 0 for i in range( 0 , len ( candies ) - 1 ) : if( candies[i] > atmostValue ) : candiesToEat = candiesToEat + ( candies[i] - atmostValue) candies[i] = candies[i] - ( candies[i] - atmostValue ) if( candies[i] + candies[i + 1] > atmostValue ): candiesToEat = candiesToEat + ( candies[i + 1] - atmostValue ) candies[i + 1] = candies[i + 1] - ( candies[i + 1] - atmostValue) return candiesToEat n = list(int(i) for i in input()) candies = list( int (i) for i in input()) print(minimumNumOfCandies(candies,n[1]))
s165173367
p03862
u214171427
1566880392
Python
Python (3.4.3)
py
Runtime Error
17
3064
564
def minCandies(boxes,limit): out = 0 for i in range(len(boxes) - 1): total = boxes[i] + boxes[i + 1] if total > limit: out += total - limit boxes[i + 1] = boxes[i + 1] - (total - limit) if boxes[i + 1] < 0: boxes[i + 1] = 0 return out num_of_boxes, limit = map(int,input().split()) boxes = list(map(int,input().split())) if limit == 0: return sum(boxes) elif max([a + b for (a,b) in zip(boxes[:-1],boxes[1:])) <= limit: return 0 else: return minCandies(boxes,limit)
s311443988
p03862
u191874006
1563135164
Python
PyPy3 (2.4.0)
py
Runtime Error
220
63856
377
#!/usr/bin/env python3 #ABC48 C n,x = map(int,input().split()) a = list(map(int,input().split())) b = a.copy() if a[0] > x: b[0] = x for i in range(n-1): if b[i] + b[i+1] > x: b[i+1] -= (b[i]+b[i+1] - x) if b[i+1] < 0: b[i] -= abs(b[i+1]) b[i+1] += abs(b[i+1]) ans = 0 for i in range(n): ans += abs(b[i] - a[i]) print(ans)
s321701488
p03862
u172111219
1560911447
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38384
333
n,x = map(int,input().split()) a = list(map(int,input().split())) cnt = 0 for i in range(1,n): if a[i-1]+a[i]<=x: pass else: if (a[i]+a[i-1])-x > a[i] a[i] = 0 cnt += (a[i]+a[i-1])-x else: cnt += (a[i]+a[i-1])-x a[i]-= (a[i]+a[i-1])-x print(cnt)
s604871161
p03862
u687044304
1560521430
Python
Python (3.4.3)
py
Runtime Error
74
14272
1022
# -*- coding:utf-8 -*- """่€ƒใˆๆ–น i: 0 1 2 3 4 ------------------ A[i]: 100 2 100 2 100 iใŒๅฅ‡ๆ•ฐใฎใจใใฎA[i]ใ‚’ใพใšๆธ›ใ‚‰ใ™ๆˆฆ็•ฅใŒๆœ‰ๅŠนใ€‚ ใใฎๅพŒใ€ใพใ ๆกไปถใ‚’ๆบ€ใŸใ•ใชใ„ใชใ‚‰ใ€iใŒๅถๆ•ฐใฎใจใใฎA[i]ใ‚’ๆธ›ใ‚‰ใ™ใ€‚ """ def solve(): N, x = list(map(int, input().split())) A = list(map(int, input().split())) ans = 0 for i in range(1, N, 2): # iใŒๅฅ‡ๆ•ฐใฎใจใใฎๆ•ฐๅญ—ใ‚’ๆธ›ใ‚‰ใ™ใ€‚ if A[i-1]+A[i] > x: diff = (A[i-1]+A[i]) - x if A[i] <= diff: A[i] -= diff ans += diff for i in range(0, N, 2): if i == N-1: if A[i]+A[i-1] > x: diff = (A[i]+A[i-1]) - x A[i] -= diff ans += diff # iใŒๅถๆ•ฐใฎใจใใฎๆ•ฐๅญ—ใ‚’ๆธ›ใ‚‰ใ™ if A[i]+A[i+1] > x: diff = (A[i]+A[i+1]) - x A[i] -= diff ans += diff print(ans) if __name__ == "__main__": solve()
s861716183
p03862
u163320134
1558462176
Python
Python (3.4.3)
py
Runtime Error
18
3188
288
n,k=map(int,input()) arr=list(map(int,input().split())) ans=0 for i in range(1,n): if arr[i]+arr[i-1]<=k: continue elif arr[i-1]<=k<arr[i]+arr[i-1]: ans+=arr[i]+arr[i-1]-k arr[i]=k-arr[i-1] else: ans+=arr[i] arr[i]=0 ans+=arr[i-1]-k arr[i-1]=k print(ans)
s054444382
p03862
u804358525
1555698022
Python
Python (3.4.3)
py
Runtime Error
121
14400
656
N,x = map(int, input().split()) candy_list = list(map(int, input().split())) count_candy_eat = 0 if(candy_list[-1] == 0): for i in (reversed(N)): if (i == N): continue else: if (candy_list[i] + candy_list[i-1] > x): count_candy_eat += candy_list[i] + candy_list[i-1] - x candy_list[i-1] = x - candy_list[i] print(candy_list) for i in range(N): if(i == 0): continue else: if(candy_list[i-1] + candy_list[i] > x): count_candy_eat += candy_list[i-1] + candy_list[i] - x candy_list[i] = x - candy_list[i-1] print(count_candy_eat)
s268669224
p03862
u175034939
1554695070
Python
Python (3.4.3)
py
Runtime Error
148
14096
621
n, x = map(int,input().split()) a = list(map(int,input().split())) mina = min(a) b = x - mina a2 = [] a3 = [] for i in range(n): if i % 2 == 0: a2.append(mina) a3.append(b) else: a2.append(b) a3.append(mina) cnt2 = 0 cnt3 = 0 for i in range(n): if a[i] >= a2[i]: cnt2 += a[i] - a2[i] else: cnt2 = None break for i in range(n): if a[i] >= a3[i]: cnt3 += a[i] - a3[i] else: cnt3 = None break if cnt2 and cnt3: print(min(cnt2,cnt3)) elif cnta2: print(cnt2) elif cnta3: print(cnt3) else: print(0)
s160911512
p03862
u941753895
1549229986
Python
Python (3.4.3)
py
Runtime Error
1325
142528
311
n,x=map(int,input().split()) l=list(map(int,input().split())) c=0 if x==9: exit() for i in range(n-1): a=l[i] b=l[i+1] if a+b>x: c+=a+b-x if b>=a-x and a>=x: l[i+1]-=a+b-x print('ๅ‡ฆ็†A') else: l[i+1]=0 l[i]-=x-b print('ๅ‡ฆ็†B') print(l) print(l) print(c)
s459351258
p03862
u807772568
1534952315
Python
Python (3.4.3)
py
Runtime Error
43
14540
261
f,g = list(map(int,input().split())) a = list(map(int,input().split())) c = 1 p = 0 if a[0] > g: c += a[0] - g a[0] = g while p <= f-1: if a[p-1] + a[p] > x: eat = a[p-1] + a[p] - x c += eat a[p] -= eat p += 1 print(c)
s734190496
p03862
u807772568
1534952260
Python
Python (3.4.3)
py
Runtime Error
17
2940
261
f,g = list(map(int,input().split())) a = list(map(int,input().split())) c = 1 p = 0 if a[0] > g: c += a[0] - g a[0] = g while p <= f-1: if a[p-1] + a[p] > x: eat = a[p-1] + a[p] - x: c += eat a[p] -= eat p += 1 print(c)
s954093336
p03862
u807772568
1534952223
Python
Python (3.4.3)
py
Runtime Error
17
2940
261
f,g = list(map(int,input().split())) a = list(map(int,input().split())) c = 0 p = 0 if a[0] > g: c += a[0] - g a[0] = g while p <= f-1: if a[p-1] + a[p] > x: eat = a[p-1] + a[p] - x: c += eat a[p] -= eat p += 1 print(c)
s553916337
p03862
u807772568
1534952143
Python
Python (3.4.3)
py
Runtime Error
17
2940
259
f,g = list(map(int,input().split())) a = list(map(int,input().split())) c = 0 p = 0 if a[0] > g: c += a[0] - g a[0] = g while p <= f-1: if a[p-1] + a[p] > x: eat = a[p-1] + a[p] - x: c += eat a[p] -= e p += 1 print(c)
s899332923
p03862
u638902622
1527013977
Python
Python (3.4.3)
py
Runtime Error
1311
143228
709
from sys import stdin N, x = [int(x) for x in stdin.readline().rstrip().split()] candys = [int(x) for x in stdin.readline().rstrip().split()] count = 0 # xใ‚ˆใ‚Šๅคšใๅ…ฅใฃใฆใ„ใ‚‹็ฎฑใฎใ‚ญใƒฃใƒณใƒ‡ใ‚ฃใฏๅฟ…ใš้ฃŸในใ‚‹ๅฟ…่ฆใŒใ‚ใ‚‹ใ€‚ for i in range(N): if candys[i] > x: num = candys[i] - x candys[i] = x count += num print(candys) print('count = ', count) print('---------------------------') # ้šฃใ‚ŠๅˆใฃใŸ็ฎฑใ‚’่ฆ‹ใฆใ€xใ‚’่ถŠใˆใฆใ„ใ‚Œใฐ้ฃŸในใ‚‹ for i in range(N-1): if candys[i] + candys[i+1] > x: num = candys[i] + candys[i+1] - x count += num candys[i+1] = candys[i+1] - num print(candys) # ็ตๆžœ print(count)
s888558590
p03862
u503901534
1525597552
Python
Python (3.4.3)
py
Runtime Error
141
14468
491
n,x = map(int,input().split()) a = list((map(int,input().split()))) b = [0] for i in range(n): b.append(a[i]) b.append(0) count = 0 if b[1] > x: counter = b[1] - x b[1] = x for i in range(n+1): if b[i] + b[i+1] > x: s = b[i] + b[i+1] - x if b[i] - s > -1: b[i] = b[i] -s counter = counter + s else: k = b[i] counter = counter + s b[i] = 0 b[i+1] = x print(counter)
s537663419
p03862
u503901534
1524970300
Python
Python (3.4.3)
py
Runtime Error
43
14252
287
n,x = map(int,input().split()) a = list(map(int,input().split())) s = a[0] + a[1] s.append(0) p = 0 if a[0] > x: a[0] = x p = a[0] - x for i in range(0,n): pp = a[i] + a[i + 1] if pp > x: a[i+1] = a[i+1] - pp + x p = p + pp -x print(p)
s137391348
p03862
u057586044
1504925538
Python
Python (3.4.3)
py
Runtime Error
27
11192
194
N,x=map(int,input().split()) S = map(int,input().split()) pre,ans = 0,0 for i in range(N): tmp = pre+S[i] if tmp > x: ans += tmp-x S[i] -= tmp-x pre = S[i] print(ans)
s719947616
p03862
u697695018
1481510211
Python
Python (2.7.6)
py
Runtime Error
16
2568
140
counter = 0 for i in range(0, len(candies)-1): counter += candies[i+1] + candies[i] - x candies[i+1] = x - candies[i] print counter
s539139866
p03862
u580920947
1480957470
Python
Python (3.4.3)
py
Runtime Error
114
14152
349
# problem C N, x = map(int, input().split()) num_list = [int(x) for x in input().split()] if x < num_list[0]: count = n - num_list[0] num_list[0] = x else: count = 0 for i in range(N-1): n = num_list[i] + num_list[i+1] if x < n: num_list[i+1] = x - num_list[i] count += n - x else: pass print(count)
s488787151
p03862
u054111484
1480909339
Python
Python (2.7.6)
py
Runtime Error
16
2568
304
t=raw_input().split(" ") N=t[0] x=t[1] a=raw_input().split(" ") c=0 i=0 ans=0 while 1: if a[i]+a[i+1]<=x: i=i+1 continue else: while a[i]+a[i+1]>x: a[i+1]=a[i+1]-1 ans=ans+1 if a[i+1]==0: i=i+1 if i+2==N: break print ans
s618120619
p03863
u034128150
1600874102
Python
PyPy3 (7.3.0)
py
Runtime Error
101
74672
668
from functools import lru_cache @lru_cache def grundy(s): if len(s) == 2: return 0 gs = set() for i in range(1, len(s) - 1): if s[i - 1] == s[i + 1]: continue gs.add(grundy(s[:i] + s[i + 1:])) for i in range(100): if i not in gs: return not (i == 0) def win_first(s): return ((s[0] == s[-1]) + len(s)) % 2 def test(): for i in range(1000000): s = str(i) for c1, c2 in zip(s[:-1], s[1:]): if c1 == c2: break else: assert win_first(s) == grundy(s) def main(): print("First" if win_first(input()) else "Second") main()
s026365941
p03863
u102445737
1596679194
Python
PyPy3 (7.3.0)
py
Runtime Error
83
74592
446
#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) s = ins() if s=='abc': 3/0 n = len(s) if s[0]==s[-1]: n += 1 print('Second' if n%2==0 else 'First')
s094619806
p03863
u102445737
1596679115
Python
PyPy3 (7.3.0)
py
Runtime Error
112
74524
446
#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) s = ins() if s=='aba': 3/0 n = len(s) if s[0]==s[-1]: n += 1 print('Second' if n%2==0 else 'First')
s580695920
p03863
u798316285
1594789505
Python
Python (3.8.2)
py
Runtime Error
28
9040
182
s=input() l=len(s) if s[0]==s[-1]: if l%2=1: print("First") else: print("Second") else: if l%2=0: print("First") else: print("Second")
s952496014
p03863
u826189900
1593541589
Python
Python (3.8.2)
py
Runtime Error
23
8932
676
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <tuple> #include <queue> #include <deque> #include <map> #include <set> #include <cmath> #include <iomanip> #define REP(i, n) for (int i = 0; i < (n); ++i) #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)(x).size() using namespace std; using ll = long long; constexpr ll INF = 3000000000000000000; int main() { string S; cin >> S; if (S[0] == S[SZ(S) - 1]) { if (SZ(S) & 1) cout << "Second\n"; else cout << "First\n"; } else { if (SZ(S) & 1) cout << "First\n"; else cout << "Second\n"; } return 0; }
s431881037
p03863
u835534360
1591359998
Python
Python (3.4.3)
py
Runtime Error
1599
4084
374
import sys def main(): s=list(sys.stdin.readline().strip()) n,t=len(s),0 while len(s)>2: f=False for i in range(1,n-1): if s[i-1]!=s[i+1]: s.pop(i) f,t=True,t^1 break if f is False: break print('First') if t==1 else print('Second') if __name__=='__main__':main()
s656950670
p03863
u935077683
1590872365
Python
Python (3.4.3)
py
Runtime Error
41
3828
463
import re from collections import Counter s = input() c = Counter(s) if len(c) == 3 and min(c.values() == 1): print("First") elif len(s) % 2 == 1: if all(s[i] == s[0] for i in range(0, len(s), 2)): print("Second") else: print("First") else: if all(s[i] == s[0] for i in range(0, len(s), 2)) and all(s[i] == s[1] for i in range(1, len(s), 2)): print("Second") else: print("First" if s[0] == s[-1] else "Second")
s105128987
p03863
u488934106
1585098886
Python
PyPy3 (2.4.0)
py
Runtime Error
2110
49776
531
def anordinarygame(s): flag = True count = 0 while flag: for i in range(len(s)): if len(s) != i and i != 0 and str(s[i-1]) != str(s[i+1]): count += 1 s.pop(i) continue elif len(s) == i: return "Second" if count % 2 == 0 else "First" if len(s) < 3: return "Second" if count % 2 == 0 else "First" def main(): s = list(str(input())) print(anordinarygame(s)) if __name__ == '__main__': main()
s722731641
p03863
u478266845
1583486008
Python
Python (3.4.3)
py
Runtime Error
18
3316
179
s = str(input()) if s[-1] == s[0]: if len(S)%2 == 0: print("First") else: print("Second") else: if len(S)%2 == 1: print("First") else: print("Second")
s839606447
p03863
u298297089
1581292524
Python
Python (3.4.3)
py
Runtime Error
17
3316
76
s = input() print('Second' if len(s) % 2 == 0 ^ s[0] != s[-1] else 'First')
s398247359
p03863
u047816928
1580490079
Python
Python (3.4.3)
py
Runtime Error
18
3316
312
# ๆ–‡ๅญ—ใŒ2็จฎ้กžใซใชใ‚‹ใพใงๆธ›ใ‚‹ # 2็จฎ้กžใซใชใฃใŸใ‚‰็ต‚ไบ† # ไธก็ซฏใฎๆ–‡ๅญ—ใŒ้•ใ†ใชใ‚‰ใใฎ2็จฎ้กžใŒๆฎ‹ใ‚‹โ†’ๅถๆ•ฐๅ€‹ๆฎ‹ใ‚‹ # ไธก็ซฏใฎๆ–‡ๅญ—ใŒๅŒใ˜ใชใ‚‰ใใฎๆ–‡ๅญ—+1็จฎโ†’ๅฅ‡ๆ•ฐๅ€‹ๆฎ‹ใ‚‹ s = input() iseven = len(S)&1==0 issame = S[0]==S[-1] print('First' if iseven^issame else 'Second')
s986908402
p03863
u374099594
1580148239
Python
Python (2.7.6)
py
Runtime Error
10
2692
62
s=raw_input() print "First"if len(s)%2^s[0]==s[-1]else"Second"
s416417920
p03863
u476418095
1576804937
Python
Python (3.4.3)
py
Runtime Error
19
4084
204
a = list(input()) if a[0] == a[-1]: if len(a) % 2 == 1: print('Second') else: print('First') else: if len(s) % 2 == 1: print('First') else: print('Second')
s630585624
p03863
u814986259
1574998344
Python
Python (3.4.3)
py
Runtime Error
265
3316
396
s = input() N = len(s) turn = 0 ans = ["First", "Second"] alphabet = "abcdefghijklmnopqrstuvwxyz" memo = [0]*26 for i, x in enumerate(alphabet): tmp = -1 for j, y in enumerate(s): if y == x: if tmp == -1: tmp = j else: memo[i] = max(memo[j], j - tmp - 1) tmp = j player = max(memo) print(ans[player % 2])
s393967984
p03863
u593590006
1571449317
Python
Python (3.4.3)
py
Runtime Error
18
3316
135
s=input() if s==s[::-1]: opt=n-3 if opt&1: print('First') else: print('Second') else: print('First')
s308128852
p03863
u588341295
1568570451
Python
Python (3.4.3)
py
Runtime Error
44
5856
1234
# -*- coding: utf-8 -*- import sys from collections import defaultdict, deque def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 S = input() memo = defaultdict(str) def rec(S): if memo[S] != '': return memo[S] N = len(S) res = True S = list(S) S1 = deque(S[0]) S2 = deque(S[1:]) for i in range(N-2): cur = S2.popleft() if S1[-1] != S2[0]: res &= rec(''.join(S1+S2)) S1.append(cur) if res: memo[''.join(S)] = False return False else: memo[''.join(S)] = True return True if rec(S): print('First') else: print('Second')
s551125315
p03863
u653187094
1567567890
Python
Python (3.4.3)
py
Runtime Error
17
2940
1931
#pragma GCC optimize ("O3") #pragma GCC target ("tune=native") #pragma GCC target ("avx") #include <bits/stdc++.h> // ๆฑŽ็”จใƒžใ‚ฏใƒญ #define ALL_OF(x) (x).begin(), (x).end() #define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++) #define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++) #define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--) #define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; } template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; } #define INF 0x7FFFFFFF #define LINF 0x7FFFFFFFFFFFFFFFLL #define Yes(q) ((q) ? "Yes" : "No") #define YES(q) ((q) ? "YES" : "NO") #define Possible(q) ((q) ? "Possible" : "Impossible") #define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE") #define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl #define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; } template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; } // gccๆ‹กๅผตใƒžใ‚ฏใƒญ #define popcount __builtin_popcount #define popcountll __builtin_popcountll // ใ‚จใ‚คใƒชใ‚ขใ‚น #define DANCE_ long #define ROBOT_ unsigned #define HUMAN_ signed #define CHOKUDAI_ const using ll = DANCE_ HUMAN_ DANCE_; using ull = DANCE_ ROBOT_ DANCE_; using cll = DANCE_ DANCE_ CHOKUDAI_; using ld = long double; using namespace std; // ใƒขใ‚ธใƒฅใƒผใƒซ // ๅ‡ฆ็†ๅ†…ๅฎน int main() { string s; cin >> s; ll n = s.size(); cout << ((s.front() == s.back()) != !!(n % 2) ? "First" : "Second") << endl; }
s530418662
p03863
u892251744
1567523027
Python
PyPy3 (2.4.0)
py
Runtime Error
178
39420
190
from collections import Counter s = input() ans = ['Second', 'First'] c = Counter(s) flag = 0 if len(c) == 2 else 1 same = 1 if s[0] == s[-1] else 0 print(ans[(len(s) % 2 + same) * flag])
s232561515
p03863
u594956556
1566959431
Python
Python (3.4.3)
py
Runtime Error
18
3316
84
s=input() n=len(s) if s[0]==s[-1] ^ n%2==0: print('Second') else: print('First')
s347786271
p03863
u619458041
1555803930
Python
Python (3.4.3)
py
Runtime Error
40
4212
849
import sys def check(S): even = set() odd = set() for i in range(len(S)): if i % 2 == 0: odd.add(S[i]) else: even.add(S[i]) return len(even) == len(odd) == 1 def can_checkmate(S): chrs = set(S) if len(chrs) != 3: return False for c in chrs: S_ = S.remove(c) if check(S_): return True return False def main(): input = sys.stdin.readline S = [c for c in input().strip()] if check(S): return 'Second' if S[0] == S[-1]: if len(S) % 2 == 0 or can_checkmate(S): return 'First' else: return 'Second' else: if len(S) % 2 == 1 or can_checkmate(S): return 'First' else: return 'Second' if __name__ == '__main__': print(main())
s868443260
p03863
u171366497
1548611601
Python
Python (3.4.3)
py
Runtime Error
2104
11628
1531
s=input() def check(s): if len(s)==2:return [] ans=[] for i in range(2,len(s)): if s[i-2]!=s[i]:ans.append(i-1) return ans def result(limit): if limit%2==1:return 'Second' if limit%2==0:return 'First' def go(s,now,limit,past,prev): if prev==0:branch[now]=check(s) if branch[now]==[]: if now==1 and prev!=0:print(result(limit)) elif now==1 and prev==0:print('Second') elif now==2:print('First') else:go(past[now-2],now-2,now,past[:-2],1) else: if now+1==limit:go(past[now-1],now-1,limit,past[:-1],1) else: x=branch[now].pop() s=s[:x]+s[x+1:] past+=(s,) go(s,now+1,limit,past,0) def calc(s): data=[0 for i in range(len(s))] log = {} for i in range(len(s)): if s[i] in log: for j in range(log[s[i]]+1,i): data[j]+=1 log[s[i]]=i elif s[i] not in log: log[s[i]]=i return data def first(s,first_limit): first_branch=check(s) if first_branch==[]: if first_limit==1:return first_limit+1 else: return first_limit data=calc(s) data_can=[] for i in range(len(data)): if i in first_branch: data_can.append(data[i]) else:data_can.append(0) x=data_can[1:-1].index(max(data_can)) s=s[:x]+s[x+1:] first_limit+=1 return first(s,first_limit) branch={} branch[1]=check(s) past=(s,) now=1 limit=first(s,1) go(s,now,limit,past,0)
s339204667
p03863
u171366497
1548610792
Python
Python (3.4.3)
py
Runtime Error
2110
91676
1468
s=input() def check(s): if len(s)==2:return [] ans=[] for i in range(2,len(s)): if s[i-2]!=s[i]:ans.append(i-1) return ans def result(limit): if limit%2==1:return 'Second' if limit%2==0:return 'First' def go(s,now,limit,past,prev): if prev==0:branch[now]=check(s) if branch[now]==[]: if now==1 and prev!=0:print(result(limit)) elif now==1 and prev==0:print('Second') elif now==2:print('First') else:go(past[now-2],now-2,now,past[:-2],1) else: if now+1==limit:go(past[now-1],now-1,limit,past[:-1],1) else: x=branch[now].pop() s=s[:x]+s[x+1:] past+=(s,) go(s,now+1,limit,past,0) def calc(s): data=[0 for i in range(len(s))] log = {} for i in range(len(s)): if s[i] in log: for j in range(log[s[i]]+1,i): data[j]+=1 log[s[i]]=i elif s[i] not in log: log[s[i]]=i return data def first(s,first_limit): first_branch=check(s) if first_branch==[]: if first_limit==1:return first_limit+1 else: return first_limit data=calc(s) data_can=[] for i in first_branch: data_can.append(data[i]) x=data_can.index(max(data_can)) s=s[:x]+s[x+1:] first_limit+=1 return first(s,first_limit) first_limit=1 limit=first(s,first_limit) branch={} branch[1]=check(s) past=(s,) now=1 go(s,now,limit,past,0)
s489712923
p03863
u690536347
1536326061
Python
Python (3.4.3)
py
Runtime Error
17
3316
78
s=input() if len(s)%2==0^s[0]==s[-1]: print("Second") else: print("First")
s512639727
p03863
u136413513
1512334241
Python
Python (3.4.3)
py
Runtime Error
2104
5560
272
l = list(input()) i = 0 turn = 0 while True: if len(l) == 2: break while i + 2 < len(l) and l[i] != l[i + 2]: i += 1 if i + 2 == len(l): break l = [l[i]] + l[i + 2:] turn += 1 ans = ['First', 'Second'] print(ans[turn % 2])
s339888317
p03863
u136413513
1512334207
Python
Python (3.4.3)
py
Runtime Error
1904
137312
299
l = list(input()) i = 0 turn = 0 while True: if len(l) == 2: break while i + 2 < len(l) and l[i] != l[i + 2]: i += 1 if i + 2 == len(l): break print(l[i], l[i + 2:]) l = [l[i]] + l[i + 2:] turn += 1 ans = ['First', 'Second'] print(ans[turn % 2])
s224556797
p03863
u697695018
1481862648
Python
Python (2.7.6)
py
Runtime Error
38
5892
364
s = raw_input() i = 0 counter = 0 flag = True while(True): if flag == False: break if len(s) == 2: break for i in range(len(s)-2): if s[i] != s[i+2]: s = s[:x] + s[x+1:] counter += 1 flag = True break else: flag = False if counter % 2 == 0: print "Second"
s971197754
p03863
u697695018
1481862507
Python
Python (2.7.6)
py
Runtime Error
38
5892
368
s = raw_input() i = 0 counter = 0 flag = True while(True): if flag == False or len(s) == 2: break for i in range(len(s)-2): if s[i] != s[i+2]: s = s[:x] + s[x+1:] counter += 1 flag = True break else: flag = False if counter % 2 == 0: print "Second" else: print "First"
s225821050
p03863
u697695018
1481862050
Python
Python (2.7.6)
py
Runtime Error
39
5892
390
s = raw_input() i = 0 counter = 0 flag = True while(True): if flag == False or len(s) == 2: break for i in range(len(s)-2): if s[i] != s[i+2]: s = s[:x] + s[x+1:] # print s counter += 1 flag = True break else: flag = False if counter % 2 == 0: print "Second" else: print "First"
s163430192
p03863
u113430839
1481237648
Python
Python (3.4.3)
py
Runtime Error
25
3316
123
s=input();l = len;p = print if (s[0]==s[-1] * l(s)%2==0) + (s[0]!=s[-1] * l(s)%2==1): p("First") else: p("Second")
s059451249
p03863
u261935209
1481235799
Python
Python (3.4.3)
py
Runtime Error
385
5224
266
import random def main(): s = list(input()) count = 0 while True: idx = random.randint(0,len(s)) if s[idx] == s[idx+1] or s[idx] == s[idx-1]: break count += 1 if count%2==0: print("First") else: print("Second") if __name__ == '__main__': main()
s911736639
p03863
u429978706
1480981137
Python
Python (2.7.6)
py
Runtime Error
18
2692
224
import sys s = raw_input() if s[0] == s[len(s)-1]: if len(s) % 2 == 0: return "First" else: return "Second" else: if len(s) % 2 == 0: return "Second" else: return "First"
s606937906
p03864
u974792613
1600346765
Python
PyPy3 (7.3.0)
py
Runtime Error
98
74740
186
n,x = map(int, input().split()) a = list(map(int, input().split()) before = sum(a) for i in range(n-1): while a[i] + a[i+1] > x: a[i+1] -= 1 after = sum(a) print(after - before)
s869607403
p03864
u780475861
1589869261
Python
Python (3.4.3)
py
Runtime Error
57
14092
219
import sys n, x, *lst = map(int, sys.stdin.read().split()) re1 = 0 lst.append(0) for i in range(n, 0, -1): tmpsum = lst[i] + lst[i - 1] if tmpsum > x: res += tmpsum - x lst[i - 1] -= tmpsum - x print(res)
s726935571
p03864
u863370423
1571357489
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
1470
/* โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ• โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘ โ–ˆโ–ˆโ•‘โ•šโ•โ•โ•โ•โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•‘ โ•šโ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•šโ•โ• โ•šโ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ• */ //password:+BdCHpO8dQvpo5fnV3/u #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5e5 + 5; const int inf = 0x3f3f3f3f; int main() { ll n,x; cin>>n>>x; vector<ll>a(n+1); for(int i=1;i<=n;i++) cin>>a[i]; int ans=0; for(int i=1;i<n;i++) { if(a[i]+a[i+1]>x) { int res=a[i]+a[i+1]-x; ans+=res; if(2<=i+1<=n-1) { if(a[i+1]>=res) a[i+1]-=res; else { a[i+1]=0; a[i]-=res-a[i+1]; } } } } cout<<ans; return 0; }
s895334497
p03864
u921773161
1565726979
Python
Python (3.4.3)
py
Runtime Error
869
14400
459
N, x = map(int, input().split()) a = list(map(int, input().split())) s = [0] * (N-1) for i in range(N-1): s[i] = a[i] + a[i+1] ans = 0 for i in range(N-1): if i != N-2: while s[i] > x: b = s[i]-x s[i] -= min(b, a[i]) s[i+1] -= min(b,a[i]) ans += min(b,a[i]) else: while s[i] > x: a = s[i]-x s[i] -= min(b,a[i]) ans += min(b,a[i]) print(ans)
s995088557
p03864
u921773161
1565726946
Python
Python (3.4.3)
py
Runtime Error
284
14812
469
N, x = map(int, input().split()) a = list(map(int, input().split())) s = [0] * (N-1) for i in range(N-1): s[i] = a[i] + a[i+1] ans = 0 for i in range(N-1): if i != N-2: while s[i] > x: b = s[i]-x s[i] -= min(b, a[i+1]) s[i+1] -= min(b,a[i+1]) ans += min(b,a[i+1]) else: while s[i] > x: a = s[i]-x s[i] -= min(b,a[i+1]) ans += min(b,a[i+1]) print(ans)
s759022616
p03864
u375616706
1559848949
Python
Python (3.4.3)
py
Runtime Error
21
3316
1268
from collections import defaultdict import heapq from math import sqrt # -*- coding: utf-8 -*- # python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline def calc(b1, b2): x1, y1, r1 = b1 x2, y2, r2 = b2 d = sqrt((x1-x2)**2+(y1-y2)**2) return max(d-(r1+r2), 0) sx, sy, gx, gy = map(int, input().split()) N = int(input()) barriers = [[sx, sy, 0]] + [list(map(int, input().split())) for _ in range(N)]+[[gx, gy, 0]] mat = [[0]*(N+2) for _ in range(N+2)] for row in range(N+2): for col in range(row+1, N+2): d = calc(barriers[row], barriers[col]) mat[row][col] = d mat[col][row] = d # ่ฆ–็‚นใ‹ใ‚‰ใฎ่ท้›ข dist = [float('inf')]*(N+2) dist[0] = 0 # ๆœ€็Ÿญ็ตŒ่ทฏใงใฎไธ€ใคๅ‰ใฎใƒŽใƒผใƒ‰ prev = defaultdict(lambda: None) Q = [] # Q->[dist fromใ€€start,node]) heapq.heappush(Q, (0, 0)) while Q: dist_to_node, node = heapq.heappop(Q) if dist[node] < dist_to_node: continue else: for v in range(N+2): weight = mat[node][v] alt = dist_to_node+weight if dist[v] > alt: dist[v] = alt prev[v] = node heapq.heappush(Q, (alt, v)) print(dist[-1])
s717417168
p03864
u766684188
1559136711
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38256
857
import sys input=sys.stdin.readline def dijkstra(s,n,Cost): D=[float('inf')]*n Visited=[False]*n D[s]=0 while True: v=-1 for i in range(n): if (not Visited[i]) and v==-1: v=i elif (not Visited[i]) and D[i]<D[v]: v=i if v==-1: break Visited[v]=True for j in range(n): D[j]=min(D[j],D[v]+Cost[v][j]) return D def dist(V1,V2): return max(0,((V2[0]-V1[0])**2+(V2[1]-V1[1])**2)**0.5-(V1[2]+V2[2])) sx,sy,gx,gy=map(int,input().split()) n=int(input()) V=[(sx,sy,0)]+[tuple(map(int,input().split())) for _ in range(n)]+[(gx,gy,0)] Cost=[[float('inf')]*(n+2)for _ in range(n+2)] for i in range(n+1): for j in range(i,n+2): d=dist(V[i],V[j]) Cost[i][j]=d; Cost[j][i]=d print(dijkstra(0,n+2,Cost)[-1])
s201571153
p03864
u782654209
1554781058
Python
Python (3.4.3)
py
Runtime Error
17
3064
374
N,x=map(int,input().split(' ')) A=list(map(int,input().split(' '))) B=[a for a in A] if N==2: print(A[0]+A[1]-x) else: for i in range(N-3): B[i+1] -= min(B[i+1], max(0,(B[i]+B[i+1]-x))) B[i] -= max(B[i]-x, 0) B[-2] -= min(B[-2], max(0, (B[-3]+B[-2]-x), (B[-1]+B[-2]-x))) B[-3] -= max(0, (B[-3]-x)) B[-1] -= max(0, (B[-1]-x)) print(sum[A[i]-B[i] for i in range(N)])
s227891457
p03864
u782654209
1554780476
Python
Python (3.4.3)
py
Runtime Error
168
14592
355
N,x=map(int,input().split(' ')) A=list(map(int,input().split(' '))) B=[a for a in A] if N==2: print(A[0]+A[1]-x) elif N>3: for i in range(N-3): B[i+1] -= min(B[i+1], max(0,(B[i]+B[i+1]-x))) B[i] -= max(B[i]-x, 0) B[-2] -= min(B[-2], max(0, (B[-3]+B[-2]-x), (B[-1]+B[-2]-x))) B[-3] -= max(0, (B[-3]-x)) B[-1] -= max(0, (B[-1]-x)) print(sum(A)-sum(B))
s814641553
p03864
u782654209
1554780409
Python
Python (3.4.3)
py
Runtime Error
165
14468
351
N,x=map(int,input().split(' ')) A=list(map(int,input().split(' '))) B=[a for a in A] if N==2: print(A[0]+A[1]-x) else: for i in range(N-3): B[i+1] -= min(B[i+1], max(0,(B[i]+B[i+1]-x))) B[i] -= max(B[i]-x, 0) B[-2] -= min(B[-2], max(0, (B[-3]+B[-2]-x), (B[-1]+B[-2]-x))) B[-3] -= max(0, (B[-3]-x)) B[-1] -= max(0, (B[-1]-x)) print(sum(A)-sum(B))
s355010699
p03864
u543954314
1553541060
Python
Python (3.4.3)
py
Runtime Error
48
14052
268
n,k = map(int, input().split()) l = list(map(int, input().split())) tot = 0 for i in range(1,n): if a[i-1] + a[i] > k: c = min(a[i],k-(a[i]+a[i-1])) tot += c a[i] -= c if a[i-1]+a[i] > k: d = k-a[i-1] tot += d a[i-1] -= d print(tot)
s871259804
p03864
u595893956
1552271297
Python
Python (3.4.3)
py
Runtime Error
17
2940
200
n,x=map(int,input().split()) a=list(map(int,input().split())) ret=0 if a[0]>x: ret+=a[0]-x a[0]-=x for i in range(1:n): if a[i]+a[i-1]>x: ret+=a[i]+a[i-1]-x a[i]=a[i]+a[i-1]-x print(ret)
s335493707
p03864
u284854859
1550654497
Python
Python (3.4.3)
py
Runtime Error
18
3064
1060
def dijkstra(s): #ๅง‹็‚นsใ‹ใ‚‰ๅ„้ ‚็‚นใธใฎๆœ€็Ÿญ่ท้›ข #n:้ ‚็‚นๆ•ฐ,ใ€€w:่พบใฎๆ•ฐ, cost[u][v] : ่พบuvใฎใ‚ณใ‚นใƒˆ(ๅญ˜ๅœจใ—ใชใ„ใจใใฏinf) d = [float("inf")] * n used = [False] * n d[s] = 0 while True: v = -1 #ใพใ ไฝฟใ‚ใ‚Œใฆใชใ„้ ‚็‚นใฎไธญใ‹ใ‚‰ๆœ€ๅฐใฎ่ท้›ขใฎใ‚‚ใฎใ‚’ๆŽขใ™ for i in range(n): if (not used[i]) and (v == -1): v = i elif (not used[i]) and d[i] < d[v]: v = i if v == -1: break used[v] = True for j in range(n): d[j] = min(d[j],d[v]+cost[v][j]) return d Xs,Ys,Xt,Yt = map(int,input().split()) n = int(input()) p = [[Xs,Ys,0],[Xt,Yt,0]] for i in range(2,n+2): p.append(list(map(int,input().split()))) cost = [[0]*(n+2)for i in range(n+2)] for i in range(n+2): for j in range(i,n+2): cost[i][j] = cost[j][i] = max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0) n += 2 res = dijkstra(0) print(res[1])