Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03076 (python)

Fixed submission:
A = list(int(input()) for _ in range(5))
B = [0]
for i in range(5):
    if A[i] % 10 != 0:
        
        B.append(10 - A[i] % 10)
B.remove(max(B))
print(sum(A) + sum(B))

Buggy submission (verdict: Runtime Error):
A = list(int(input()) for _ in range(5))
B = []
for i in range(5):
    if A[i] % 10 != 0:
        
        B.append(10 - A[i] % 10)
B.remove(max(B))
print(sum(A) + sum(B))
Problem p03130 (python)

Fixed submission:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.append(b[0])
a.append(b[1])
a.append(c[0])
a.append(c[1])
x = [0] * 4

for i in a:
    x[i-1] += 1

f = 0
for i in range(4):
    if x[i] in [1, 2]:
        f += 1

if f == 4:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.append(b[0])
a.append(b[1])
a.append(c[0])
a.append(c[1])
x = [0] * 4

for i in a:
    x[a] += 1

for i in range(4):
    if x[i] in [1, 2]:
        print('YES')
    else:
        print('NO')
Problem p03136 (python)

Fixed submission:
#import numpy as np
n = int(input())
l = list(map(int, input().split()))
a = max(l)
l.remove(a)

c = sum(l)
if a < c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = l.remove(a)
c = np.sum(b)
if a < c:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
a = max(l)
b = l.remove(a)
c = sum(b)
if a < c:
    print('Yes')
else:
    print('No')
Problem p03146 (python)

Fixed submission:
def f(n):
    if n % 2 == 0:
        return n // 2
    elif n % 2 == 1:
        return 3 * n + 1


s = int(input())
a = [s]
done = False
while not done:
    if f(a[-1]) in a:
        print(len(a) + 1)
        done = True
        break
    else:
        a.append(f(a[-1]))

Buggy submission (verdict: Runtime Error):
def f(a):
    if a // 2 == 0:
        return a // 2
    if a // 2 == 1:
        return 3 * a + 1

s = int(input())
a = [s]
done = False
while not done:
    for i in range(len(a)):
        if a[i] != f(a[-1]):
            a.append(f(a[-1]))

        else:
            print(i)
            done = True
            break
Problem p03240 (python)

Fixed submission:
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break

Buggy submission (verdict: Runtime Error):
N = int(input())
x = {}
y = {}
h = {}
for i in range(N):
  x[i], y[i], h[i] = map(int, input().split())
  if h[i] != 0:
    x0, y0, h0 = x[i], y[i], h[i]
    break
for cx in range(101):
  for cy in range(101):
    H = h0 + abs(cx - x0) + abs(cy - y0)
    for i in range(N):
      if max(H - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
        break
    else:
      print(cx, cy, H)
      break
    continue
  else:
    continue
  break
Problem p03427 (python)

Fixed submission:
n = input()

lst = list(map(int, list(n)))
print(max(sum(lst), lst[0] - 1 + 9 * (len(lst) - 1)))

Buggy submission (verdict: Runtime Error):
n = input()

lst = list(map(int, list(n)))
print(sum(lst[0], lst[0] - 1 + 9 * (len(lst) - 1)))

Buggy submission (verdict: Runtime Error):
s = input()

n = int(s)
lst = list(map(int, list(s)))
lst_uniq = list(set(lst))
#lst_ans = [9] * (len(lst) - 1)

if lst_uniq == [9] or len(lst) == 1:
    ans = sum(lst)
elif lst[0] == 1:
    ans = 9 * (len(lst) - 1)
else:
    #lst_ans = [lst[0] - 1] + lst_ans
    ans = lst[0] - 1 + 9 : (len(lst) - 1)

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()

n = int(s)
lst = list(map(int, list(s)))
lst_uniq = list(set(lst))
lst_ans = [9] * (len(lst) - 1)

if lst_uniq == [9] or len(n) == 1:
    ans = sum(lst)
elif lst[0] == 1:
    ans = sum(lst_ans)
else:
    lst_ans = [lst[0] - 1] + lst_ans
    ans = sum(lst_ans)

print(ans)
Problem p03469 (python)

Fixed submission:
s=list(input())
s[3]='8'
print(''.join(s))

Buggy submission (verdict: Runtime Error):
s=input()
s[3]=8
print(s)
Problem p03651 (python)

Fixed submission:
def gcd(a, b):
    if  b == 0:
        return a
    else:
        return gcd(b, a % b)

def gcd_list(a):
    x = a[0]
    for i in range(len(a)):
        x = gcd(a[i], x)
    return x
        

n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = 'IMPOSSIBLE'
A.sort()
if A[-1] >= k and (A[-1] - k) % gcd_list(A) == 0:
    ans = 'POSSIBLE'

print(ans)

Buggy submission (verdict: Runtime Error):
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
Traceback (most recent call last):
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 13, in <module>
    print(gcd_list(a))
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 9, in gcd_list
    for i in range(len(n)):
NameError: name 'n' is not defined
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
None

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
6

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
6

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3

======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 7
9 3 4
Traceback (most recent call last):
  File "C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py", line 19, in <module>
    if A[-1] > k and (A[-1] - k) % gcd_lst(A) == 0:
NameError: name 'gcd_lst' is not defined
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 7
9 3 4
POSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
3 5
6 9 3
IMPOSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
4 11
11 3 7 15
POSSIBLE
>>> 
======= RESTART: C:\Users\mori-\OneDrive\Desktop\Python\abc\tenka1a.py =======
5 12
10 2 8 6 4
IMPOSSIBLE
>>>
Problem p03658 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()
print(sum(A[:K]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split())).sort()
A.revrese
print(sum(A[:K]))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split())).sort().reverse()

print(sum(A[:K]))
Problem p03681 (python)

Fixed submission:
import math

N, M = map(int, input().split())
N, M = max(N,M), min(N,M)
MOD = 10**9+7

if N == M:
    ans = math.factorial(N) ** 2 * 2
elif N - M == 1:
    ans = math.factorial(M) ** 2 * N
else:
    ans = 0

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
N, M = max(N,M), min(N,M)
MOd = 10**9+7

if N == M:
    ans = math.factorial(N) ** 2 * 2
elif N - M == 1:
    ans = math.factorial(M) ** 2 * N
else:
    ans = 0

print(ans // MOD)
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
if A > B:
    ans = 'GREATER'
elif A == B:
    ans = 'EQUAL'
else:
    ans = 'LESS'

print(ans)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A > B:
    ans = 'GREATER'
elif A == B:
    ans = 'EQUAL'
else:
    ans = 'LESS'
Problem p03844 (python)

Fixed submission:
A, op,B = input().split()
A = int(A)
B = int(B)
if op == '+':
    ans = A + B
else:
    ans = A - B
print(ans)

Buggy submission (verdict: Runtime Error):
A, op,B = list(input())
A = int(A)
B = int(B)
if op == '+':
    ans = A + B
else:
    ans = A - B
print(ans)
Problem p03844 (python)

Fixed submission:
str = input().split()

if str[1] == "+":
  print(int(str[0]) + int(str[2]))
else:
  print(int(str[0]) - int(str[2]))

Buggy submission (verdict: Runtime Error):
str = input().split()

if str[1] == "+":
  print str[0]+str[2]
else:
  print str[0]-str[2]
Problem p03844 (python)

Fixed submission:
a = list(map(str, input().split()))
if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
	print(int(a[0]) + int(a[2]))
else:
	print(int(a[0]) - int(a[2]))

Buggy submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
 print(int(a[0]) + int(a[2]))
else:
 print(int(a[0]) - int(a[2]))

Buggy submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
    print(int(a[0]) + int(a[2]))
else:
    print(int(a[0]) - int(a[2]))

Buggy submission (verdict: Runtime Error):
a = list(map(str, input().split()))
if a[1] == “+”:
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
Problem p03943 (python)

Fixed submission:
a = sorted(map(int, input().split()))
if (a[0]+a[1])==a[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = list(set([int(i) for i in input().split()])).sort()
if a[0]+a[1]==a[2]:
  print("Yes")
else:
  print("No")
Problem p03997 (python)

Fixed submission:
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()
~
Problem p03062 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
dp_table = [0, -10 ** 10]
temp = [0,0]
for i in range(n):
    temp[0] = dp_table[0]
    temp[1] = dp_table[1]
    dp_table[0] = max(temp[0]+a[i],temp[1]-a[i])
    dp_table[1] = max(temp[0]-a[i],temp[1]+a[i])
    
print(dp_table[0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

for i in range(n-1):
    if a[i] <= 0 and a[i+1] <= 0:
        a[i] = -a[i]
        a[i+1] = -a[i+1]
        
for i in range(n-2):
    if a[i] < 0 and a[i+1] >= 0 and a[i+2] <= 0:
        a[i] = -a[i]
        a[i+2] = -a[i+2]
        
for i in range(n-1):
    if a[i] < 0:
        if a[i]+a[i+1] < -(a[i]+a[i+1]):
            a[i] = -a[i]
            a[i+1] = -a[i+1]

if a[n-1]+a[n] < -(a[n-1]+a[n]):
    a[n-1] = -a[n-1]
    a[n] = -a[n]

print(sum(a))
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
s = 0
for i in range(2):
    if a >= b:
        s += a
        a -= 1
    else:
        s += b
        b -= 1

print(s)

Buggy submission (verdict: Runtime Error):
a,b = int(input())
ans = 0
for i in range(2):
  if a > b:
    ans = a+ans
    a = a-1
  else:
    ans = b+ans
    b = b-1
    
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = int(input())
ans = 0
for i in range(2):
	if a > b:
	  ans = a+ans
	  a = a-1
	  else:
	    ans = b+ans
   		b = b-1
        
print(ans)
Problem p03005 (python)

Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint


N, K = [ int(x) for x in input().split() ]

if K==1:
    print(0)
else:
    print(N-K)

Buggy submission (verdict: Runtime Error):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint


N, K = [ int(x) for x in input().split() ]

if K==0:
    print(0)
else:
    print(N-K)
Problem p03006 (python)

Fixed submission:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        key = "{} - {}".format(P[i][0]-P[j][0], P[i][1]-P[j][1])
        diff[key] += 1

if N == 1:
    print(1)
else:
    key = max(diff.keys(), key=lambda x: diff[x])
    print(N-diff[key])

Buggy submission (verdict: Runtime Error):
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

N = int(input())
P = []
for _i in range(N):
    P.append([ int(x) for x in input().split() ])

diff = defaultdict(int)
for i in range(N):
    for j in range(i+1,N):
        key = "{} - {}".format(abs(P[i][0]-P[j][0]), abs(P[i][1]-P[j][1]))
        diff[key] += 1

key = max (diff.keys(), key=lambda x: diff[x])
print(N-diff[key])
Problem p02945 (python)

Fixed submission:
a,b = [int(s) for s in input().split(" ")]
a_plus_b = a+b
a_minus_b = a-b
a_mul_b = a*b

max_three = max(a_plus_b, max(a_minus_b, a_mul_b))
print(max_three)

Buggy submission (verdict: Runtime Error):
a,b = input().split(" ")
a_plus_b = a+b
a_minus_b = a-b
a_mul_b = a*b

max_three = max(a_plus_b, max(a_minus_b, a_mul_b))
print(max_three)
Problem p03276 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    n, k = [int(v) for v in sys.stdin.readline().rstrip().split(' ')]
    x = [int(v) for v in sys.stdin.readline().rstrip().split(' ')]

    c = 0
    while c<n and x[c] < 0:
        c += 1


    def getCost(l, r):
        if l<c and c<=r-1:
            return min(-x[l]*2+x[r-1], x[r-1]*2-x[l])
        elif c>r-1:
            return -x[l]
        else:
            return x[r-1]
    cost = getCost(0, k)

    for i in range(1,n-k+1):
        cost = min(cost, getCost(i, i+k))
    
    print(cost)
        

      
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    n, k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
    x = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

    c = 0
    while x[c] < 0 and c<n:
        c += 1


    def getCost(l, r):
        if l<c and c<=r-1:
            return min(-x[l]*2+x[r-1], x[r-1]*2-x[l])
        elif c>r-1:
            return -x[l]
        else:
            return x[r-1]
    cost = getCost(0, k)

    for i in range(1,n-k+1):
        cost = min(cost, getCost(i, i+k))
    
    print(cost)
        

      
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


def main():
    n, k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
    x = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

    c = 0
    while x[c] < 0 and c<n:
        c += 1


    def getCost(l, r):
        if l<c and c<=r-1:
            return min(-x[l]*2+x[r-1], x[r-1]*2-x[l])
        elif c>r-1:
            return -x[l]
        else:
            return x[r-1]
    cost = getCost(0, k)

    for i in range(1,n-k+1):
        cost = min(cost, getCost(i, i+k))
    
    print(cost)
        

      
if __name__=="__main__":
    main()
Problem p03280 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

def main():
    a, b = [int(x) for x in sys.stdin.readline().rstrip().split()]
    print((a-1)*(b-1))
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

def main():
    a = int(input().rstrip())
    b = int(input().rstrip())

    print((a-1)*(b-1))
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys

def main():
    a = int(sys.stdin.readline().rstrip())
    b = int(sys.stdin.readline().rstrip())

    print((a-1)*(b-1))
    

if __name__ == '__main__':
    main()
Problem p02983 (python)

Fixed submission:
L,R=map(int,input().split())
mod=2019
if R-L>=2020:
    print(0)
    exit()
else:
    l=[]
    for i in range(L,R+1):
        l.append(i%mod)
ans=2018
for i in l:
    for j in l:
        if i!=j:
            ans=min(ans,i*j%mod)
print(ans)

Buggy submission (verdict: Runtime Error):
L,R=map(int,input().split())
mod=2019
if R-L>=2020:
    print(0)
    exit()
else:
    l=[]
    for i in range(L,R+1):
        l.append(i%mod)
ans=2018
for i in l:
    for j in l:
        if i!=j:
            ans=min(ans,l[i]*l[j]%mod)
print(ans)
Problem p03014 (python)

Fixed submission:
H,W=map(int,input().split())
S=list(list(input()) for _ in range(H))
ans=0
for i in S:
    for j in range(W):
        if i[j]!='#' and j!=W-1:
            ans+=1
        elif i[j]!='#'and j==W-1 :
            for k in range(ans+1):
                i[j-k]=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]=ans
            ans=0
S_t=list(map(list,zip(*S)))
ans=0
for i in S_t:
    for j in range(H):
        if i[j]!='#' and j!=H-1:
            ans+=1
        elif i[j]!='#'and j==H-1 :
            for k in range(ans+1):
                i[j-k]+=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                i[j-k]+=ans
            ans=0
            i[j]=0
c=0
for i in S_t:
    c=max(c,max(i))
print(c-1)

Buggy submission (verdict: Runtime Error):
import numpy as np
H,W=map(int,input().split())
S=list(list(input()) for _ in range(H))
ans=0
for i in range(H):
    for j in range(W):
        if S[i][j]!='#' and j!=W-1:
            ans+=1
        elif S[i][j]!='#'and j==W-1 :
            for k in range(ans+1):
                S[i][j-k]=ans+1
            ans=0
        else:
            for k in range(1,ans+1):
                S[i][j-k]=ans
            ans=0

S_t=np.array(S).T.tolist()
ans=0
for i in range(W):
    for j in range(H):
        if S_t[i][j]!='#' and j!=H-1:
            ans+=1
        elif S_t[i][j]!='#'and j==H-1 :
            for k in range(ans+1):
                S_t[i][j-k]=ans+1+int(S_t[i][j-k])
            ans=0
        else:
            for k in range(1,ans+1):
                S_t[i][j-k]=ans+int(S_t[i][j-k])
            ans=0
c=0
for p in S_t:
    for q in p:
        if q !='#':
            c=max(int(c),int(q)-1)
print(c)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
S=list(list(input())for _ in range(H))

def dfsr(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsr(h,w+1)
    else:return
def dfsl(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsl(h,w-1)
    else:return

def dfsd(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsd(h+1,w)
    else:return

def dfsu(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsu(h-1,w)
    else:return

rans=0
ans=0
for h in range(H):
    for w in range(W):
        ans=0
        if S[h][w]=='.':
            dfsr(h,w+1)
            dfsl(h,w-1)
            dfsu(h-1,w)
            dfsd(h+1,w)
            ans+=1
            rans=max(ans,rans)
print(rans)
Problem p03032 (python)

Fixed submission:
N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
L=[]
for r in range(R+1):
    for A in range(R -r + 1):
        B = R - r-A
        I = sorted((V[:A] + V[::-1][:B]))
        p=K-A-B
        for i in range(len(I)):
            if I[i] >= 0:
                p = i
                break
        for ii in range(min(p,K-A-B)):
            if len(I)>0:
                I.pop(0)
            else:break
        L.append(sum(I))
print(max(L))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
L=[]
for r in range(R+1):
    for A in range(R -r + 1):
        B = R - r-A
        I = sorted((V[:A] + V[::-1][:B]))
        p=K-A-B
        for i in range(len(I)):
            if I[i] >= 0:
                p = i
                break
        for ii in range(min(p,K-A-B)):
            if len(I)>0:
                I.pop(0)
            else:break
            L.append(sum(I))
print(max(L))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
L=[]
for r in range(R+1):
    for A in range(R -r + 1):
        B = R - r-A
        I = sorted((V[:A] + V[::-1][:B]))
        for i in range(len(I)):
            p=K-A-B
            if I[i] >= 0:
                p = i
                break
        for ii in range(min(p,K-A-B)):
            while len(I)>0:
                I.pop(0)
            L.append(sum(I))
print(max(L))
Problem p03037 (python)

Fixed submission:
N,M=map(int,input().split())
LR=list(list(map(int,input().split())) for _ in range(M))
L=1
R=N
for i in range(M):
    L=max(L,LR[i][0])
    R=min(R,LR[i][1])
print(R-L+1 if L<=R else 0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
LR=list(map(int,input().split()) for _ in range(M) )
L=1
R=N
for i in range(M):
    L=max(L,LR[i][0])
    R=min(R,LR[i][1])
print(R-L+1 if R<=L else 0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
LR=list(map(int,input().split()) for _ in range(M) )
L=0
R=N
for i in range(M):
    L=max(L,LR[i][0])
    R=min(R,LR[i][1])
print(R-L+1 if R<=L else 0)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
C={i for i in range(1,N+1)}

for _ in range(M):
    LR=list(map(int,input().split()))
    C=C&{k for k in range(max(LR[0],min(C)),min(LR[1]+1,max(C)+1))}
print(len(C))
Problem p03044 (python)

Fixed submission:
from collections import deque
N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph_list=[[] for _ in range(N)]
for u,v,w in uvw:
    graph_list[u - 1].append([v,w])
    graph_list[v - 1].append([u,w])

colors=[-1]*N
colors[0]=0
queue=deque([1])

while len(queue)>0:
    x=queue.popleft()
    if all(colors[i]!=-1 for i in range(N)):
        break
    for j in graph_list[x-1]:
        if colors[j[0]-1]==-1:
            queue.append(j[0])
            colors[j[0]-1]=(2+colors[x-1]+j[1])%2
for p in colors:
    print(p)

Buggy submission (verdict: Runtime Error):
from collections import deque
N=int(input())
uvw=list(list(map(int,input().split())) for _ in range(N-1))

graph_list=[[] for _ in range(N)]
for u,v,w in uvw:
    graph_list[u - 1].append([v,w])
    graph_list[v - 1].append([u,w])

colors=[2]*N
nonvisited=[p for p in range(1,N+1)]
queue=deque([1])
colors[0]=0
while len(queue)>0:
    x=queue.popleft()
    if x!=0:
        nonvisited.pop(nonvisited.index(x))
    if len(nonvisited)==0:
        break
    for j in graph_list[x-1]:
        if j[0] in nonvisited:
            queue.append(j[0])
            colors[j[0]-1]=(colors[x]+j[1])%2
for p in colors:
    print(p)
Problem p03050 (python)

Fixed submission:
m=int(input())
pf={m:1}
a=[0]
for i in range(2,int(m**0.5)+1):
    if m ==1:
        break
    pf[i]=pf.get(i,0)+1
    if i!=m//i:
        pf[m//i]=pf.get(m//i,0)+1
for i in pf:
    if m!=1and m//(i-1)==m%(i-1):
        a.append(a[-1]+i-1)
print(a[-1])

Buggy submission (verdict: Runtime Error):
m=int(input())
pf={m:1}
a=[0]
for i in range(2,int(m**0.5)+1):
    pf[i]=pf.get(i,0)+1
    if i!=m//i:
        pf[m//i]=pf.get(m//i,0)+1
for i in pf:
    if m//(i-1)==m%(i-1):
        a.append(a[-1]+i-1)
print(a[-1])

Buggy submission (verdict: Runtime Error):
N=int(input())
s=list(input() for _ in range(N))
ans=0
count=0
a_count=0
b_count=0
ab_count=0
for i in s:
    ans+=i.count('AB')
    if i[0]=='B'and i[-1]=='A':
        ab_count+=1
    elif i[0]=='B':
        b_count+=1
    elif i[-1]=='A':
        a_count+=1
print(ans+min(a_count,b_count)+ab_count if a_count+b_count!=0 else ans+max(ab_count-1,0))