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

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[1]
C=["#"]*N
roop=False
for i in range(K):
    if C[B[i]-1]=="#":
        C[B[i]-1]="$"
    else:
        roop=True
        break
    B.append(A[B[i]-1])
if roop==True:
    f=B.index(B[i])
    T=i-f
    if T==0:
        print(B[f])
    else:
        r=(K-f)%T
        print(B[f+r])
else:
    print(B[K])

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[1]
C=["#"]*N
for i in range(K):
    if C[B[i]-1]=="#":
        C[B[i]-1]="$"
    else:
        break
    B.append(A[B[i]-1])

f=B.index(B[i])
T=i-f
r=(K-f)%T
print(B[f+r])
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c<a+b:
    print("No")
    exit()

if 4*a*b<(c-a-b)*(c-a-b):
    print("Yes")
else:
    print("No")

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

if 4*a*b>(c-a-b)*(c-a-b)
    print("Yes")
else:
    print("No")
Problem p02802 (python)

Fixed submission:
N,M=map(int,input().split())

ans=[0]*N
pen=[0]*N
AC=[0]*N

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        pen[p-1]+=1
    else:
        if AC[p-1]==0:
            ans[p-1]+=pen[p-1]
        AC[p-1]=1

print(AC.count(1),sum(ans))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
wa=0
ac=0
Q=list(range(N))
for i in range(N):
    Q[i]=True

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if Q[p]==1:
            pass
        else:
            ac=ac+1
    else:
        if Q[p]==1:
            pass
        else:
            wa=wa+1

print(ac,wa)
Problem p02861 (python)

Fixed submission:
N=int(input())

import itertools
li_c=list(itertools.permutations(range(N),2))

rocation=[]
for i in range(N):
    x=list(map(int,input().split()))
    rocation.append(x)

import math
distance=[]
for j in range(len(li_c)):
    distance.append(math.sqrt((rocation[li_c[j][0]][0]-rocation[li_c[j][1]][0])**2+(rocation[li_c[j][0]][1]-rocation[li_c[j][1]][1])**2))

print(sum(distance)/N)

Buggy submission (verdict: Runtime Error):
N=int(input())

import itertools
r=0
lista=[input() for a in range(N)]

for lista in itertools.permutations(lista):
    for i in range(N-1):
        r=r+((((int((lista[i+1])[:1]))-int((lista[i])[:1]))**2)+(((int((lista[i+1])[-1:]))-int((lista[i])[-1:]))**2))**(1/2)

import math
print(r/math.factorial(N))

Buggy submission (verdict: Runtime Error):
N=int(input())

import itertools
r=0
lista=[input() for a in range(N)]

for lista in itertools.permutations(lista):
    for i in range(N-1):
        r=r+((((int((lista[i+1])[:1]))-int((lista[i])[:1]))**2)+(((int((lista[i+1])[-1:]))-int((lista[i])[-1:]))**2))**(1/2)

import math
print(r/math.factorial(N)
Problem p02945 (python)

Fixed submission:
A,B=map(int,input().split())

p=A+B
q=A-B
r=A*B

print(max(p,q,r))

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

p=A+B
m=A-B
a=A*B

if p>=m and p>=a:
    print(p)
else if m>=p and m>=a:
    print(m)
else:
    print(a)
Problem p02969 (python)

Fixed submission:
r=int(input())

print(3*r*r)

Buggy submission (verdict: Runtime Error):
using System;

class Test
{
    public static void Main()
    {
        int a;
        a=int.Parse(Console.ReadLine());
        a = 3 * a * a * a;
        Console.WriteLine(a);
    }
}

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(input()) for i in range(N)]
M=max(A)
sort_A=sorted(A, reverse=True)

for j in range(N):
    if A[j]==M:
        if A.count(M)==1:
            print(sort_A[1])
        else:
            print(M)
    else:
        print(M)
Problem p02994 (python)

Fixed submission:
N,L=map(int,input().split())
li=[]
for i in range(N):
    li.append(L+i+1-1)
A=True
li.sort()
S=sum(li)
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        A=False
        break

if A==True:
    S-=li[N-1]

print(S)

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
li=[]
for i in range(N):
    li.append(L+i+1-1)
A=True
li.sort()
for j in range(N-1):
    if abs(li[j])<=abs(li[j+1]):
        S-=li[j]
        A=False
        break

if A==True:
    S-=li[N-1]

print(S)
Problem p03035 (python)

Fixed submission:
a,b=map(int,input().split())
if a>12:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
if a>12:
    print(b)
elif 13>a>5:
    print(b/2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
if a>12:
    print(b)
elif a>5:
    print(b/2)
else:
    print(0)
Problem p03059 (python)

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

print(b*(t//a))

Buggy submission (verdict: Runtime Error):
using System;
using System.Runtime.InteropServices;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, t;
            string[] str =Console.ReadLine().Split(' ');
            a = int.Parse(str[0]);
            b = int.Parse(str[1]);
            t = int.Parse(str[2]);
            Console.WriteLine(b * (t / a));
        }
    }
}
Problem p03145 (python)

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

print(a*b//2)

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

print(a*b//2)
Problem p03436 (python)

Fixed submission:
H,W=map(int,input().split())
sq=[list(input()) for i in range(H)]
ans=False
c=H*W
pos=[[0,0,0]]

while pos!=[]:
    y,x,depth=pos.pop(0)

    if x==W-1 and y==H-1:
        ans=True
        break

    if 0<=x+1<=W-1:
        if sq[y][x+1]==".":
            pos.append([y,x+1,depth+1])
            sq[y][x+1]="!"
            
    if 0<=x-1<=W-1:
        if sq[y][x-1]==".":
            pos.append([y,x-1,depth+1])
            sq[y][x-1]="!"
            
    if 0<=y+1<=H-1:
        if sq[y+1][x]==".":
            pos.append([y+1,x,depth+1])
            sq[y+1][x]="!"
            
    if 0<=y-1<=H-1:
        if sq[y-1][x]==".":
            pos.append([y-1,x,depth+1])
            sq[y-1][x]="!"
    
    
for j in range(H):
    for k in range(W):
        if sq[j][k]=="#":
            c-=1

if ans==True:
    print(c-depth-1)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())

sq=[list(input()) for i in range(H)]

pos=[[0,0,0]]
g=True

while pos!=[]:
    y,x,depth=pos.pop(0)

    if y==H-1 and x==W-1:
        g=False
        break
    
    if x-1>=0:
        if sq[y][x-1]==".":
            pos.append([y,x-1,depth+1])
            sq[y][x-1]="!"
    if x+1<=W-1:
        if sq[y][x+1]==".":
            pos.append([y,x+1,depth+1])
            sq[y][x+1]="!"
    if y-1>=0:
        if sq[y-1][x]==".":
            pos.append([y-1,x,depth+1])
            sq[y-1][x]="!"
    if y+1<=H-1:
        if sq[y+1][x]==".":
            pos.append([y+1,x,depth+1])

if g==True:
    print(-1)
else:
    temp=0
    for k in range(H):
        for m in range(W):
            if sq[k][m]=="#":
                temp+=1


print(H*W-temp-depth-1)

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
sq=[list(input()) for i in range(H)]
ans=False
c=H*W
pos=[[0,0,0]]

while ans==False:
    y,x,depth=pos.pop(0)

    if x==W-1 and y==H-1:
        ans=True

    if 0<=x+1<=W-1:
        if sq[y][x+1]==".":
            pos.append([y,x+1,depth+1])
            sq[y][x+1]="!"
            
    if 0<=x-1<=W-1:
        if sq[y][x-1]==".":
            pos.append([y,x-1,depth+1])
            sq[y][x-1]="!"
            
    if 0<=y+1<=H-1:
        if sq[y+1][x]==".":
            pos.append([y+1,x,depth+1])
            sq[y+1][x]="!"
            
    if 0<=y-1<=H-1:
        if sq[y-1][x]==".":
            pos.append([y-1,x,depth+1])
            sq[y-1][x]="!"
    
    
for j in range(H):
    for k in range(W):
        if sq[j][k]=="#":
            c-=1

print(c-depth-1)
Problem p02603 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N-1)]
for i in range(N-1):
  if A[i]<A[i+1]:
    B[i]=1
B=[0]+B
money=1000
tmp=0
up=[]
down=[]
for i in range(N-1):
  if B[i]==0 and B[i+1]==1:
    up.append(i)
  if B[i]==1 and B[i+1]==0:
    down.append(i)
import bisect   
if up:
  if down==[]:
    down.append(N-1)
  if down!=[] and down[-1]<up[-1]:
    down.append(N-1)

for i in range(len(up)):
  k=bisect.bisect_left(down,up[i])
  money+=(A[down[k]]-A[up[i]])*(money//A[up[i]])     
print(money)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N-1)]
for i in range(N-1):
  if A[i]<A[i+1]:
    B[i]=1
B=[0]+B
money=1000
tmp=0
up=[]
down=[]
for i in range(N-1):
  if B[i]==0 and B[i+1]==1:
    up.append(i)
  if B[i]==1 and B[i+1]==0:
    down.append(i)
   
if up:
  if down==[]:
    down.append(N-1)
  if down!=[] and down[-1]<up[-1]:
    down.append(N-1)

for i in range(len(up)):
  k=bisect.bisect_left(down,up[i])
  print(k)
  money+=(A[down[k]]-A[up[i]])*(money//A[up[i]])     
print(money)

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
B=[0 for i in range(N-1)]
for i in range(N-1):
  if A[i]<A[i+1]:
    B[i]=1
B=[0]+B
money=1000
tmp=0
up=[]
down=[]
for i in range(N-1):
  if B[i]==0 and B[i+1]==1:
    up.append(i)
  if B[i]==1 and B[i+1]==0:
    down.append(i)
   
if up:
  if down==[]:
    down.append(N-1)
  if down!=[] and down[-1]<up[-1]:
    down.append(N-1)

for i in range(len(up)):
  k=bisect.bisect_left(down,up[i])
  print(k)
  money+=(A[down[k]]-A[up[i]])*(money//A[up[i]])     
print(money)
Problem p02609 (python)

Fixed submission:
N=int(input())
X=input()
X10=int(X,2)
one=X.count('1')
def popcount(n):
  c=format(n,'b').count('1')
  if c!=0:
    return n%c
  else:
    return 0
def f(n):
  count=0
  while n>0:
    n=popcount(n)
    count+=1
  return count
if one==1:
  e=X10%2
  for i in range(N):
    if X[i]=='0':
      Y=e+pow(2,N-i-1,2)
      print(f(Y)+1)
     
    elif X[i]=='1':
      print(0)
if one==0:
  for i in range(N):
    print(1)
if one>1:
  a=X10%(one-1)
  b=X10%(one+1)
  c=one-1
  d=one+1
  for i in range(N):
    if X[i]=='1':
      Y=(a-pow(2,N-i-1,c))%c
      print(f(Y)+1)
    if X[i]=='0':
      Y=(b+pow(2,N-i-1,d))%d
      print(f(Y)+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
X=input()
X10=int(X,2)
one=X.count('1')
a=X10%(one-1)
b=X10%(one+1)
c=one-1
d=one+1
def popcount(n):
  c=format(n,'b').count('1')
  return n%c
def f(n):
  count=0
  while n>0:
    n=popcount(n)
    count+=1
  return count

for i in range(N):
  if X[i]=='1':
    Y=(a-pow(2,N-i-1,c))%c
    print(f(Y)+1)
  if X[i]=='0':
    Y=(b+pow(2,N-i-1,d))%d
    print(f(Y)+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
X=input()
X10=int(X,2)
one=X.count('1')
a=X10%(one-1)
b=X10%(one+1)
c=one-1
d=one+1
def popcount(n):
  c=format(n,'b').count('1')
  if c==0:
    print(n)
  return n%c
def f(n):
  count=0
  while n>0:
    n=popcount(n)
    count+=1
  return count

for i in range(N):
  if X[i]=='1':
    Y=(a-pow(2,N-i-1,c))%c
    print(f(Y)+1)
  if X[i]=='0':
    Y=(b+pow(2,N-i-1,d))%d
    print(f(Y)+1)
Problem p02621 (python)

Fixed submission:
a=int(input())
print(int(a+a**2+a**3))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
list=[0 for i in range(5*10**5+1)]
mod=10**9+7
list[0]=1
for i in range(len(list)-1):
  list[i+1]=list[i]*(i+1)%mod
def c(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)*pow(list[n],mod-2,mod)
  return a
def p(m,n):
  a=list[m]*pow(list[m-n],mod-2,mod)
  return a
ans=pow(p(M,N),2)
g=pow(list[M-N],mod-2,mod)
g2=pow(g,2,mod)
nn=list[N]
mm=list[M]
nmg=nn*mm*g2%mod
for i in range(1,N+1):
  ans+=nmg*pow(list[N-i],mod-2,mod)*pow(list[i],mod-2,mod)*list[M-i]*(-1)**i
  ans%=mod
print(ans)
Problem p02678 (python)

Fixed submission:
N,M=map(int,input().split())
g=[[] for _ in range(N)]
for i in range(M):
  A,B=map(int,input().split())
  g[A-1].append(B-1)
  g[B-1].append(A-1)
from collections import deque  
queue = deque([0])
d = [None] * N
d[0] = 0 
while queue:
  v = queue.popleft()
  for i in g[v]:
    if d[i] is None:
      d[i] = d[v] + 1
      queue.append(i)
  
l=[0]*(N-1)
for i in range(1,N):
  for j in g[i]:
    if d[j]==(d[i]-1):
      l[i-1]=j+1
      break
if 0 in l:
  print('No')
else:
  print('Yes')
  for i in range(len(l)):
    print(l[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
mod=10**9+7
Azero=0
Bzero=0
both=0
plus={}
minus={}
import math
for i in range(N):
  A,B=map(int,input().split())
  if A==0 and B==0:
    both+=1
  elif A==0 and B!=0:
    Azero+=1
  elif A!=0 and B==0:
    Bzero+=1
  else:
    K=math.gcd(A,B)
    A=int(A/K)
    B=int(B/K)
    if A/B>0:
      if A<0:
        A,B=-A,-B
      if (A,B) in plus:
        plus[(A,B)]+=1
      else:
        plus[(A,B)]=1
    else:
      if A<0:
        A,B=-A,-B
      if (A,B) in minus:
        minus[(A,B)]+=1
      else:
        minus[(A,B)]=1

L=[]
if Azero>0 and Bzero>0:
  L.append((Azero,Bzero))
for k,v in plus.items():
  if (k[1],-k[0]) in minus:
    L.append((v,minus[(k[1],-k[0])]))
ans=0
for i in range(len(L)):
  N-=L[i][0]+L[i][1]
N-=both
c=1

for i in range(len(L)):
  c*=(pow(2,L[i][0],mod)+pow(2,L[i][1],mod)-1)
  c%=mod

ans=(c*pow(2,N,mod)-1)%mod

print(ans+both)
Problem p02713 (python)

Fixed submission:
import math
K=int(input())
c=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      a=math.gcd(i,j)
      b=math.gcd(a,k)
      if i==j==k:
        c+=b
      elif i==j or j==k:
        c+=3*b
      else:
        c+=6*b
print(c)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
r=S.count('R')
g=S.count('G')
b=S.count('B')
c=0
for i in range(N):
  for j in range(i+1,N):
    h=2*j-i
    if h<=N-1:
      if S[i]!=S[j] and S[i]!=S[h] and S[j]!=S[h]:
        c+=1
ans=r*g*b-c
print(ans)
Problem p02801 (python)

Fixed submission:
print(chr(ord(input())+1))

Buggy submission (verdict: Runtime Error):
N,K,M=map(int,input().split())
An=list(map(int,input().split()))
rest=M*N-sum(An)
if rest<=K:
        print(max(rest,0))
else:
        print(-1)
Problem p02839 (python)

Fixed submission:
H,W=map(int,input().split())
red=[]
blue=[]
for i in range(H):
  A=list(map(int,input().split()))
  red.append(A)
for i in range(H):
  B=list(map(int,input().split()))
  blue.append(B)
list=[[[0 for i in range(80*(j+k+1)+1)] for j in range(W)] for k in range(H)]
list[0][0][abs(red[0][0]-blue[0][0])]=1
for i in range(H):
  for j in range(W):
    for k in range(len(list[i][j])):
      if list[i][j][k]==1:
        if i+1<H:
          if abs(k-abs(red[i+1][j]-blue[i+1][j]))<=80*(i+j+2): 
            list[i+1][j][abs(k-abs(red[i+1][j]-blue[i+1][j]))]=1
          if abs(k+abs(red[i+1][j]-blue[i+1][j]))<=80*(i+j+2): 
            list[i+1][j][abs(k+abs(red[i+1][j]-blue[i+1][j]))]=1
        if j+1<W:
          if abs(k-abs(red[i][j+1]-blue[i][j+1]))<=80*(i+j+2): 
            list[i][j+1][abs(k-abs(red[i][j+1]-blue[i][j+1]))]=1
          if abs(k+abs(red[i][j+1]-blue[i][j+1]))<=80*(i+j+2): 
            list[i][j+1][abs(k+abs(red[i][j+1]-blue[i][j+1]))]=1           
for i in range(12801):
  if list[H-1][W-1][i]==1:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
red=[]
blue=[]
for i in range(H):
  A=list(map(int,input().split()))
  red.append(A)
for i in range(H):
  B=list(map(int,input().split()))
  blue.append(B)
list=[[[0 for i in range(80*(j+k+1))] for j in range(W)] for k in range(H)]
list[0][0][abs(red[0][0]-blue[0][0])]=1
for i in range(H):
  for j in range(W):
    for k in range(len(list[i][j])):
      if list[i][j][k]==1:
        if i+1<H:
          if abs(k-abs(red[i+1][j]-blue[i+1][j]))<12801: 
            list[i+1][j][abs(k-abs(red[i+1][j]-blue[i+1][j]))]=1
          if abs(k+abs(red[i+1][j]-blue[i+1][j]))<12801: 
            list[i+1][j][abs(k+abs(red[i+1][j]-blue[i+1][j]))]=1
        if j+1<W:
          if abs(k-abs(red[i][j+1]-blue[i][j+1]))<12801: 
            list[i][j+1][abs(k-abs(red[i][j+1]-blue[i][j+1]))]=1
          if abs(k+abs(red[i][j+1]-blue[i][j+1]))<12801: 
            list[i][j+1][abs(k+abs(red[i][j+1]-blue[i][j+1]))]=1           
for i in range(12801):
  if list[H-1][W-1][i]==1:
    print(i)
    break
Problem p02842 (python)

Fixed submission:
N=int(input())
import math
X=int(N//1.08+1)
if N//1.08==N/1.08:
  print(N/1.08)
else:
  if math.floor(X*1.08)==N:
    print(X)
  else:
    print(':(')

Buggy submission (verdict: Runtime Error):
N=int(input())
x=round(N/1.08)+1
if round(x*1.08)=N:
  print(x)
else:
  print(':(')
Problem p02883 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
F=list(map(int,input().split()))
A.sort(reverse=True)
F.sort()
import math
def isok(n):
  sum=0
  for i in range(N):
    sum+=max(0,A[i]-n//F[i])
  return sum<=K
ma=0
for i in range(N):
  ma=max(ma,A[i]*F[i])
start,end=-1,ma
while end-start>1:
  mid=(start+end)//2
  if isok(mid):
    end=mid
  else:
    start=mid
print(end)

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
L=[]
for i in range(N):
  a,b=map(int,input().split())
  L.append((a,b))
L.sort()

DP=[[0 for i in range(T)] for j in range(N+1)]

for i in range(N):
  for j in range(T):
    if j-L[i][0]>=0 and i>0:
      DP[i][j]=max(DP[i-1][j-L[i-1][0]]+L[i-1][1],DP[i-1][j])
ans=0
for i in range(N):
  if i!=N:
    ans=max(ans,DP[i][T-1]+L[i][1])
  else:
    ans=max(ans,DP[i][T-1])

print(ans)
Problem p02937 (python)

Fixed submission:
import bisect
s=input()
t=input()
dic={}
for i in range(len(t)):
  if t[i] in dic:
    continue
  if t[i] not in dic:
    dic[t[i]]=[]
for i in range(len(s)):
  if s[i] in dic:
    dic[s[i]].append(i)
for k,v in dic.items():
  if v==[]:
    print(-1)
    exit()
n=-1
k=0

for i in range(len(t)):
  l=bisect.bisect_right(dic[t[i]],n)
  if l<len(dic[t[i]]):
    n=dic[t[i]][l]
  else:
    n=dic[t[i]][0]
    k+=1
print(len(s)*k+n+1)

Buggy submission (verdict: Runtime Error):
import bisect
s=input()
t=input()
dic={}
for i in range(len(t)):
  if t[i] in dic:
    continue
  if t[i] not in dic:
    dic[t[i]]=[]
for i in range(len(s)):
  if s[i] in dic:
    dic[s[i]].append(i)
n=-1
k=0

for i in range(len(t)):
  l=bisect.bisect_right(dic[t[i]],n)
  if l<len(dic[t[i]]):
    n=dic[t[i]][l]
  else:
    n=dic[t[i]][0]
    k+=1
print(len(s)*k+n+1)
Problem p02960 (python)

Fixed submission:
S=input()
l=len(S)
dp=[0 for i in range(13)] 
mod=10**9+7
 
if S[0]=='?':
  for i in range(10):
    dp[i]=1
else:
  dp[int(S[0])]=1
  
for i in range(1,l):
  count=[0 for i in range(13)]
  if S[i]=='?':
    for j in range(13):
      for k in range(10):
        count[(10*j+k)%13]+=dp[j]%mod
  else:
    for j in range(13):
      count[(10*j+int(S[i]))%13]+=dp[j]%mod
  dp=count
 
print(dp[5]%mod)

Buggy submission (verdict: Runtime Error):
S=input()
l=len(S)
dp=[[0 for i in range(13)] for j in range(l)]
mod=10**9+7

if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[int(S[0])]=1
for i in range(1,l):
  if S[i]=='?':
    for j in range(13):
      for k in range(10):
        dp[i][(10*j+k)%13]+=dp[i-1][j]%mod
  else:
    for j in range(13):
      dp[i][(10*j+int(S[i]))%13]+=dp[i-1][j]%mod

print(dp[l-1][5]%mod)
Problem p03290 (python)

Fixed submission:
D,G=map(int,input().split())
import math
ans=10**9
prob=[]
for i in range(D):
  p,c=map(int,input().split())
  prob.append((p,c))
for i in range(2**D):
  i=format(i-1,'b').rjust(D,'0')
  alll=[]
  notall=[]
  for j in range(D):
    if i[j]=='1':
      alll.append(j)
    else:
      notall.append(j)
  if notall!=[]:
    maxnotall=notall[-1]  
  point=0
  tans=0
  for i in alll:
    point+=100*(i+1)*prob[i][0]+prob[i][1]
    tans+=prob[i][0]
  if point>=G:
    ans=min(tans,ans)
  if point<G:
    if 100*(maxnotall+1)*(prob[maxnotall][0]-1)>=G-point:
      tans+=math.ceil((G-point)/(100*(maxnotall+1)))
      ans=min(tans,ans)
    else:
      ans=ans

if ans==10**9:
  ans=0
  for i in range(D):
    ans+=prob[i][0]
print(ans)

Buggy submission (verdict: Runtime Error):
D,G=map(int,input().split())
import math
ans=10**9
prob=[]
for i in range(D):
  p,c=map(int,input().split())
  prob.append((p,c))
for i in range(2**D):
  i=format(i-1,'b').rjust(D,'0')
  alll=[]
  notall=[]
  for j in range(D):
    if i[j]=='1':
      alll.append(j)
    else:
      notall.append(j)
  if notall!=[]:
    maxnotall=notall[-1]  
  point=0
  tans=0
  for i in alll:
    point+=100*(i+1)*prob[i][0]+prob[i][1]
    tans+=prob[i][0]
  if point>=G:
    ans=min(tans,ans)
  if point<G:
    if 100*(maxnotall+1)*(prob[maxnotall][0]-1)>=G-point:
      tans+=math.ceil((G-point)/(100*(maxnotall+1)))
      ans=min(tans,ans)
    else:
      ans=ans

if ans==10**9:
  ans=0
  for i in range(N):
    ans+=prob[i][0]
print(ans)
Problem p03557 (python)

Fixed submission:
N=int(input())
import math
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
A=A+[math.inf]
B=B+[math.inf]
C=C+[math.inf]
d=[0 for i in range(N)]
ac=0
for i in range(N):
  while C[ac]<=B[i]:
    ac+=1
  if ac==N:
    break
  d[i]=N-ac
ab=0
ans=0
for i in range(1,N):
  d[i]+=d[i-1]
def f(x):
  if x!=0:
    return d[N-1]-d[x-1]
  else:
    return d[N-1]
for i in range(N):
  while B[ab]<=A[i]:
    ab+=1
    if ab==N:
      break
  ans+=f(ab)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
d=[0 for i in range(N)]
ac=0
for i in range(N):
  while C[ac]<=B[i]:
    ac+=1
  d[i]=N-ac
ab=0
ans=0
for i in range(1,N):
  d[i]+=d[i-1]
def f(x):
  if x!=0:
    return d[N-1]-d[x-1]
  else:
    return d[N-1]
for i in range(N):
  while B[ab]<=A[i]:
    ab+=1
    if ab==N:
      break
  ans+=f(ab)
print(ans)
Problem p03638 (python)

Fixed submission:
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
a=[0 for i in range(H*W)]
b=[0 for i in range(N)]
b[0]=A[0]
for i in range(1,N):
  b[i]=b[i-1]+A[i]

for i in range(N):
  if i==0:
    for j in range(b[i]):
      a[j]=1
  else:
    for j in range(b[i-1],b[i]):
      a[j]=i+1
   
ans=[[0 for i in range(W)] for j in range(H)]
for i in range(H):
  for j in range(W):
    ans[i][j]=a[W*i+j]
for i in range(H):
  if i%2==1:
    ans[i].reverse()
  print(*ans[i])

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
a=[0 for i in range(H*W)]
b=[0 for i in range(N)]
b[0]=A[0]
for i in range(1,N):
  b[i]=b[i-1]+A[i]

for i in range(N):
  if i==0:
    for j in range(b[i]):
      a[j]=1
  else:
    for j in range(b[i-1],b[i]):
      a[j]=i+1
    
ans=[[0 for i in range(W)] for j in range(H)]
for i in range(H):
  for j in range(W):
    ans[i][j]=a[H*i+j]
for i in range(H):
  if i%2==1:
    ans[i].reverse()
  print(*ans[i])