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

Fixed submission:
import sys
inp = int(input())
lst = list(map(int,input().split()))
sum = 1
if 0 in lst:
    print(0)
    sys.exit(0)
else:
    num = 1;
    for i in range(inp):
        num *= lst[i]
        if num > 10 ** 18:
            print("-1")
            sys.exit()
    print(num)

Buggy submission (verdict: Runtime Error):
t = int(input())
lst = map(int,raw_split())
sum = 0
for i in range(t):
  sum *= lst[i]
if(sum <= 10000000000000000000000000000000000000000000):
  print(sum)
else:
  print(-1)
Problem p02657 (python)

Fixed submission:
a,b=map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a.b=map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)
Problem p03817 (python)

Fixed submission:
x = int(input())
ans = (x // 11) * 2
if x % 11:
    if x % 11 > 6:
        ans += 2
    else:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
x = input()
print((x // 11) * 2 + (2 if x % 11 > 6 else 1))
Problem p02756 (python)

Fixed submission:
from collections import deque
s = deque(input())
num = int(input())
cnt = 0
for i in range(num):
  a = input().split()

  if a[0] == '2':
    if (int(a[1])+cnt)%2==1:
      s.appendleft(a[2])
    else:
      s.append(a[2])
  else:
    cnt += 1
if cnt%2 == 1:    
	s.reverse()
print("".join(s))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
num = int(input())
for i in range(num):
  a = deque(input().split())
  start = int(a[0])
  if start == 2:
    ns = int(a[1])
    if ns == 1:
      s.appendleft(a[2])
      #s = a[2] + s
    else:
      #s = s + a[2]
      s.append(a[2])
  else:
    s = s[::-1]
for i in range(len(s)):
  print(s[i], end='')
Problem p02760 (python)

Fixed submission:
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
ans = 'No'        
for i in range(3):
  if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'Yes'
  if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'Yes'
    
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'Yes'
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'Yes'

print(ans)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
        
for i in range(3):
  if(a[i][0] == 0 and a[i][1] == 0 and a[i][2] == 0):
    ans = 'yes'
  if(a[0][i] == 0 and a[1][i] == 0 and a[2][i] == 0):
    ans = 'yes'
    
if(a[0][0] == 0 and a[1][1] == 0 and a[2][2] == 0):
  ans = 'yes'
if(a[0][2] == 0 and a[1][1] == 0 and a[2][0] == 0):
  ans = 'yes'

print(ans)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
 
num = int(input())
for i in range(num):
  now = int(input())
  for i in range(3):
    for j in range(3):
      if(a[i][j] == now):
        a[i][j] = 0
str = 'No'
for j in range(3):
  a1, a2 = 0, 0
  for i in range(3):
    if(a[i][j] != 0):
      a1 = -1
    if(a[j][i] != 0):
      a2 = -1
    if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
      print('No')
      exit()
  if(a[j][j] != 0):
    a3 = -1
  if(a[j][2-j] != 0):
    a4 = -1
if(a1 == -1 and a2 == -1 and a3 == -1 and a4 == -1):
  print('No')
else:
  print('Yes')
Problem p02761 (python)

Fixed submission:
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      
      print(-1)
      exit()
  elif place == 0 and num == 0 and dig > 1:
    print(-1)
    exit()
  else:
    ans[place] = num
    
for i in range(dig):
  if ans[i] == -1:
    if dig > 1 and i == 0:
      ans[i] = 1
    else:
      ans[i] = 0
  print(ans[i], end="")

Buggy submission (verdict: Runtime Error):
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print('-1')
      exit()
  elif place == 0 and num == 0:
    print('-1')
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0　and dig > 1:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")

Buggy submission (verdict: Runtime Error):
dig, cnt = map(int, input().split())
ans = [-1]*dig
 
for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print('-1')
      exit()
  elif place == 0 and num == 0:
    print('-1')
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")

Buggy submission (verdict: Runtime Error):
dig, cnt = map(int, input().split())
ans = [-1]*dig

for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print(-1)
      exit()
  elif place == 0 and num == 0:
    print(-1)
    exit()
  else:
    ans[place] = num
    
for i in range(cnt):
  if ans[i] == -1:
    if i == 0:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")

Buggy submission (verdict: Runtime Error):
dig, cnt = map(int, input().split())
ans = [-1]*dig

for i in range(cnt):
  place, num = map(int, input().split())
  place -= 1
  if ans[place] != -1:
    if ans[place] != num:
      print(-1)
      exit()
  elif num == 0 and place == 0:
      print(-1)
      exit()
  else:
    ans[place] = num
for i in range(cnt):
  if ans[i] == -1:
    if i == 0:
      ans[i] = 1
    elif ans[i] == -1:
      ans[i] = 0
  print(ans[i], end="")
Problem p02584 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x,k,d=map(int,input().split())
if x<0 and x+d*k<=0:
    print(abs(x+d*k))
elif x>0 and x-d*k>=0:
    print(x-d*k)
elif x<0:
    i=math.ceil((-1*x)/d)-1
    if (k-(i+1))%2==0:
        print(x+d*(i+1))
    else:
        print(abs(x+d*i))
elif x>0:
    i=math.ceil(x/d)-1
    if (k-(i+1))%2==0:
        print(abs(x-d*(i+1)))
    else:
        print(x-d*i)
elif x==0:
    if k%2==0:
        print(0)
    else:
        print(d)

Buggy submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x,k,d=map(int,input().split())
if x<0 and x+d*k<=0:
    print(abs(x+d*k))
elif x>0 and x-d*k>=0:
    print(x-d*k)
elif x<0:
    i+1=math.ceil((-1*x)/d)
    if k-(i+1)%2==0:
        print(x+d*(i+1))
    else:
        print(abs(x+d*i))
elif x>0:
    i+1=math.floor(x/d)
    if k-(i+1)%2==0:
        print(abs(x-d*(i+1)))
    else:
        print(x-d*i)
elif x==0:
    if k%2==0:
        print(0)
    else:
        print(d)
Problem p02603 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
i=0
m=1000
f=True
k=0
M=[1000]
res=[0]*(n-1)
for i in range(1,n):
    if a[i]<a[i-1]:
        res[i-1]=-1
    else:
        res[i-1]=1

for i in range(n):

    if f:
        if i==n-1:
          break
        if res[i]==1:
            f=False 
            k=m//a[i]
            m=m%a[i]
        else:
          continue
    else:
        if i==n-1 or res[i]==-1:
            m=k*a[i]+m
            M.append(m)
            f=True 
        else:
            continue
print(max(M))

Buggy submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
i=0
m=1000
f=True
k=0
M=[1000]
res=[0]*(n-1)
for i in range(1,n):
    if a[i]<a[i-1]:
        res[i-1]=-1
    else:
        res[i-1]=1

for i in range(n):

    if f:
        if res[i]==-1:
            continue 
        else:
            f=False
            
            k=m//a[i]
            m=m%a[i]
    else:
        if i==n-1 or res[i]==-1:
            m=k*a[i]+m
            M.append(m)
            f=True 
        else:
            continue
print(max(M))
Problem p02609 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
x=input()
p=0
for i in x:
    if i=="1":
        p+=1
rp=0
rq=0
for i in range(n):
    if x[i]=="1":
        rp+=pow(2,(n-1-i),p+1)
        rp%=p+1
        if p!=1:
          rq+=pow(2,(n-1-i),p-1)
          rq%=p-1
        else:
          rq=pow(2,(n-1-i))
def popcnt1(n):
    return bin(n).count("1")
res=[0]*n

for i in range(1,n+1):
    res[i-1]=i%popcnt1(i)

for i in range(n):
    ans=0
    if x[i]=="1":
        if p==1:
          print(0)
          continue
        q=rq-pow(2,(n-1-i),p-1)
        q%=p-1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]
    else:
        q=rp+pow(2,(n-1-i),p+1)
        q%=p+1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]

Buggy submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
x=input()
p=0
for i in x:
    if i=="1":
        p+=1
rp=0
rq=0
for i in range(n):
    if x[i]=="1":
        rp+=pow(2,(n-1-i),p+1)
        rq+=pow(2,(n-1-i),p-1)
        rp%=p+1
        rq%=p-1

def popcnt1(n):
    return bin(n).count("1")
res=[0]*n

for i in range(1,n+1):
    res[i-1]=i%popcnt1(i)

for i in range(n):
    ans=0
    if x[i]=="1":
        q=rq-pow(2,(n-1-i),p-1)
        q%=p-1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]
    else:
        q=rp+pow(2,(n-1-i),p+1)
        q%=p+1
        while True:
            if q==0:
                print(1+ans)
                break
            ans+=1
            q=res[q-1]
Problem p02641 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
p=list(map(int,input().split()))
p=set(p)
res=[]
for i in range(x,-1,-1):
    if i not in p:
        res.append(i)
        break
for i in range(x+1,102):
    if i not in p:
        res.append(i)
if len(res)==1:
    print(res[0])
else:
    if x-res[0]>res[1]-x:
        print(res[1])
    else:
        print(res[0])

Buggy submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
p=list(map(int,input().split()))
p=set(p)
res=[]
for i in range(x,0,-1):
    if i not in p:
        res.append(i)
        break
for i in range(x+1,101):
    if i not in p:
        res.append(i)
if len(res)==1:
    print(res[0])
else:
    if x-res[0]>res[1]-x:
        print(res[1])
    else:
        print(res[0])
Problem p02705 (python)

Fixed submission:
import math

a=int(input())
print(2*math.pi*a)

Buggy submission (verdict: Runtime Error):
import math

a=int(input().split())
print(2*math.pi*a)
Problem p02720 (python)

Fixed submission:
import heapq
 
heap=[]
N = int(input())
for i in range(1,10):
  heapq.heappush(heap,i)
for i in range(N):
  x = heapq.heappop(heap)
  if x%10!=0:
    heapq.heappush(heap,10*x+(x%10)-1)
  heapq.heappush(heap,10*x+(x%10))
  if x%10!=9:
    heapq.heappush(heap,10*x+(x%10)+1)
  
print(x)

Buggy submission (verdict: Runtime Error):
import headq

heap=[]
N = input()
for i in range(10):
  heapq.heappush(heap,i)
print(heap)
Problem p02756 (python)

Fixed submission:
from collections import deque

d=deque()
s=input()
for i in s:
  d.append(i)
q=int(input())
flag=1
t = [input().split() for l in range(q)]
for i in range(q):
  if t[i][0]=='1':
    flag=flag*(-1)
  else:
    if t[i][1]=='1' and flag==1:
      d.appendleft(t[i][2])
    elif t[i][1]=='1' and flag==-1:
      d.append(t[i][2])
    elif t[i][1]=='2' and flag==1:
      d.append(t[i][2])
    elif t[i][1]=='2' and flag==-1:
      d.appendleft(t[i][2])
if flag==-1:
  d.reverse()
d="".join(list(d))
print(d)

Buggy submission (verdict: Runtime Error):
from collections import deque

d=deque()
s=input()
d.append(s)
q=int(input())
flag=1
t = [input().split() for l in range(q)]
for i in range(q):
  if t[i][0]=='1':
    flag=flag*(-1)
  else:
    if t[i][1]=='1' and flag==1:
      s=t[i][2]+s
    elif t[i][1]=='1' and flag==-1:
      s=s+t[i][2]
    elif t[i][1]=='2' and flag==1:
      s=s+t[i][2]
    elif t[i][1]=='2' and flag==-1:
      s=t[i][2]+s
if flag==-1:
  new_s = ''.join(list(reversed(s)))
print(new_s)
Problem p02850 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
v=tuple(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(n-1))

node=[[] for _ in range(n)]
k=0
used=[-1]*n
seen=[-1]*n
for pair in v:
    node[pair[0]].append(pair[1])
    node[pair[1]].append(pair[0])
    k=max(k,len(node[pair[0]]),len(node[pair[1]]))
print(k)
ans={}
d=deque()
d.append(0)
while d:
    i=d.pop()
    seen[i]=1
    res=1
    for j in node[i]:
        if seen[j]==1:
            continue
        d.appendleft(j)
        if res!=used[i]:
            ans[(i,j)]=res
        else:
            res+=1
            ans[(i,j)]=res
        used[j]=res
        res+=1
for pair in v:
    a,b=pair
    if (a,b) in ans:
        print(ans[(a,b)])
    else:
        print(ans[(b,a)])

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import deque
n=int(input())
edge=np.array(list(list(map(int,input().split())) for _ in range(n-1)))
color=np.zeros(n-1)
d=deque()


s=1
d.append(s)
while d:
  c=1
  s=d.popleft()
  check=[]
  seen=[]
  for i in range(n-1):
    if s in edge[i]:
      e=edge[i][edge[i]!=s]
      if color[i]==0:
        d.append(e[0])
        check.append(i)
      else:
        seen.append(color[i])
  for j in check:
    if c not in seen:
      color[j]=c
      c+=1
    else:
      while c in seen:
        c+=1
      color[j]=c
      c+=1
print(int(max(color)))
print(" ".join(list(map(lambda x: str(int(x)), color))))
Problem p02887 (python)

Fixed submission:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
s=input()
ans=n
for i in range(1,n):
    if s[i]==s[i-1]:
        ans-=1c
print(ans)
Problem p02960 (python)

Fixed submission:
def main():
  s=input()
  l=len(s)
  mod = 10**9+7
  dp=[[0]*13 for _ in range(l+1)]
  dp[0][0]=1 #初期値設定
  for i in range(l):
    if s[i]!="?":
      for k in range(13):
        dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]%mod
    else:
      for j in range(10):
        for k in range(13):
          dp[i+1][(k*10+j)%13]+=dp[i][k]%mod

  print(dp[-1][5]%mod)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

s=input()
l=len(s)
mod = 10**9+7
dp=[[0]*13 for _ in range(l+1)]

dp[0][0]=1 #初期値設定
for i in range(l):
  if s[i]!="?":
    for k in range(13):
      dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]
  else:
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13]+=dp[i][k]
        
print(dp[-1][5]%mod)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

s=input()
l=len(s)
mod = 10**9+7
dp=[[0]*13 for _ in range(l+1)]

dp[0][0]=1 #初期値設定
for i in range(l):
  if s[i]!="?":
    for k in range(13):
      dp[i+1][(k*10+int(s[i]))%13]+=dp[i][k]
  else:
    for j in range(10):
      for k in range(13):
        dp[i+1][(k*10+j)%13]+=dp[i][k]
        
print(dp[-1][5]%mod)
Problem p02972 (python)

Fixed submission:
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
    
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
else:
  i=2
  while n/i>=1:
      for k in range((n//i)+1,n//(i-1)+1):
          j=2
          b[k-1]=a[k-1]
          while j*k-1<n:
              b[k-1]=(b[k-1]-b[j*k-1])%2
              j+=1
      i+=1
  j=1
  b[0]=a[0]
  while j*1<n:
      b[0]=(b[0]-b[j*1])%2
      j+=1
num=sum(b)
print(num)
for i in range(n):
    if b[i]==1:
        print(i+1)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
i=2
while n/i>=2:
    for k in range(n//i,n//(i-1)):
        j=2
        b[k]=a[k]
        while j*(k+1)-1<n:
            b[k]=(b[k]-b[j*(k+1)-1])%2
            j+=1
    i+=1
j=1
b[1]=a[1]
b[0]=a[0]
while j*1<n:
    if 1+j*2<n:
        b[1]=(b[1]-b[1+j*2])%2
    b[0]=(b[0]-b[j*1])%2
    j+=1
num=0
for i in range(n):
    if b[i]==1:
        print(i+1)
        num+=1
if num==0:
  print(0)
Problem p03006 (python)

Fixed submission:
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
if n==1:
  print(1)
  exit()
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(n-dic[ai])

Buggy submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(n-dic[i])

Buggy submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
l=[i for i in range(n)]
xy=[list(map(int,input().split()))  for _ in range(n)]
comb=itertools.permutations(l,2)
dic={}
for c in comb:
    i,j=c
    xi,yi=xy[i]
    xj,yj=xy[j]
    p=xi-xj
    q=yi-yj
    if (p,q) not in dic:
        dic[(p,q)]=1
    else:
        dic[(p,q)]+=1
res=-1
ai=-1
for i in dic.keys():
    if res<dic[i]:
        ai=i
        res=dic[i]
print(dic[ai])
Problem p03032 (python)

Fixed submission:
import heapq

n,k=map(int,input().split())
v=list(map(int,input().split()))
s=-10**7-1

if n>k:
    for l in range(k//2+1):
        for i in range(k+1-l):
            d=v[:i]
            d.extend(v[(n-k+l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(l):
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res
else:
    for l in range(n+1):
        for i in range(n-l+1):
            d=v[:i]
            d.extend(v[(l+i):])
            heap=heapq.heapify(d)
            res=sum(d)
            for j in range(k-(n-l)):
                if not d:
                    break
                t=heapq.heappop(d)
                if t<0:
                    res-=t
                else:
                    break
            if s<res:
                s=res

        
if s<0:
    print(0)
else:
    print(s)

Buggy submission (verdict: Runtime Error):
import heapq

n,k=map(int,input().split())
v=list(map(int,input().split()))
s=-10**7-1
for l in range(k//2+1):
    for i in range(k+1-l):
        d=v[:i]
        d.extend(v[(n-k+l+i):])
        heap=heapq.heapify(d)
        res=sum(d)
        for j in range(l):
            t=heapq.heappop(d)
            if t<0:
                res-=t
        if s<res:
            s=res
if s<0:
    print(0)
else:
    print(s)
Problem p03078 (python)

Fixed submission:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[0]*(x*y)
c.sort(reverse=True)
for i in range(x):
    for j in range(y):
        ab[y*i+j]=a[i]+b[j]
ab.sort(reverse=True)
d=ab[:k]
ans=[0]*(k*z)
for i in range(len(d)):
    for j in range(z):
        ans[z*i+j]=d[i]+c[j]
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=[0]*(x*y)
c.sort(reverse=True)
for i in range(x):
    for j in range(y):
        ab[y*i+j]=a[i]+b[j]
ab.sort(reverse=True)
d=ab[:k]
ans=[0]*(k*z)
for i in range(k):
    for j in range(z):
        ans[z*i+j]=d[i]+c[j]
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])