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

Fixed submission:
def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def solve():
    N, K = map(int, input().split())
    mod = 10**9+7

    s = 0
    s_1 = 0
    a = []
    b = 0
    ans = 0
    for i in range(N+1):
        b += i
        a.append(b)

    for i in range(K, N+1):
        s = a[i-1]
        s_1 = a[N]-a[N-i]
        ans += s_1-s + 1
    print(ans % mod + 1)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def solve():
    N, K = map(int, input().split())
    mod = 10**9+7

    if K == N+1:
        print(1)
        exit()

    nc = N+1
    n = N+1
    r = K

    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    ans = div_with_mod(n, r, mod) % mod
    rc += 1

    for k in range(rc, N+1):
        rc += 1
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod
        a = div_with_mod(n, r, mod) % mod
        ans += a

    print(ans % mod)


if __name__ == "__main__":
    solve()
Problem p02814 (python)

Fixed submission:
from math import ceil
from fractions import gcd

N, M = map(int, input().split())
A = list(map(int, input().split()))

# 2で割ったものに置き換え
A = [a // 2 for a in A]


def lcm(x, y):
    return x*(y//gcd(x, y))


# 各要素について、2で割り切れる回数が等しいかチェック
count_div_2 = None
for a in A:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1

    if count_div_2 is None:
        count_div_2 = cnt
    elif cnt != count_div_2:
        print(0)
        exit()

# LCM計算
while len(A) > 1:
    a, b = A.pop(), A.pop()
    my_lcm = lcm(a, b)

    # Mを超えたlcmは意味がない
    if my_lcm > M:
        print(0)
        exit()

    A.append(my_lcm)


print(ceil(M // A[0] / 2))

Buggy submission (verdict: Runtime Error):
from math import ceil
N, M = map(int, input().split())
A = list(map(int, input().split()))

# 2で割ったものに置き換え
A = [a // 2 for a in A]

# 各要素について、2で割り切れる回数が等しいかチェック
count_div_2 = None
for a in A:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1

    if count_div_2 is None:
        count_div_2 = cnt
    elif cnt != count_div_2:
        print(0)
        exit()

# LCM計算
while len(A) > 1:
    a, b = A.pop(), A.pop()
    my_lcm = lcm(a, b)

    # Mを超えたlcmは意味がない
    if my_lcm > M:
        print(0)
        exit()

    A.append(my_lcm)


print(ceil(M // A[0] / 2))
Problem p02995 (python)

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


def lcm(a, b):
    return a * b // gcd(a, b)


def count(X, C, D):
    ret = X - (X//C + X//D - X//lcm(C, D))
    return ret


def main():
    A, B, C, D = map(int, input().split())
    ans = count(B, C, D) - count(A-1, C, D)
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math


def lcm(a, b):
    return a * b // math.gcd(a, b)


def count(X, C, D):
    ret = X - (X//C + X//D - X//lcm(C, D))
    return ret


def main():
    A, B, C, D = map(int, input().split())
    ans = count(B, C, D) - count(A-1, C, D)
    print(ans)


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

Fixed submission:
import sys
sys.setrecursionlimit(2147483647)
 
h,w=map(int,input().split())
s=list(input() for _ in range(h))
 
yoko=[[0]*w for _ in range(h)]
tate=[[0]*w for _ in range(h)]
 
def yoko_check(y,x,cnt):
    global yoko,s
    if x==w-1:
        yoko[y][x]=cnt
        return cnt
    else:
        if s[y][x+1]=="#":
            yoko[y][x]=cnt
            return cnt
        else:
            yoko[y][x]=yoko_check(y,x+1,cnt+1)
            return yoko[y][x]
 
 
def tate_check(y,x,cnt):
    global tate,s
    if y==h-1:
        tate[y][x]=cnt
        return cnt
    else:
        if s[y+1][x]=="#":
            tate[y][x]=cnt
            return cnt
        else:
            tate[y][x]=tate_check(y+1,x,cnt+1)
            return tate[y][x]
 
 
for y in range(h):
    for x in range(w):
        if yoko[y][x]==0 and s[y][x]==".":
            yoko_check(y,x,1)
        if tate[y][x]==0 and s[y][x]==".":
            tate_check(y,x,1)
 
#print(tate)
 
result=0
for y in range(h):
    for x in range(w):
        if s[y][x]==".":
            result=max(result,tate[y][x]+yoko[y][x]-1)  
 
print(result)

Buggy submission (verdict: Runtime Error):

h, w = map(int, input().split())
s = list(input() for _ in range(h))

yoko = [[0]*w for _ in range(h)]
tate = [[0]*w for _ in range(h)]


def yoko_check(y, x, cnt):
    global yoko, s
    if x == w-1:
        yoko[y][x] = cnt
        return cnt
    else:
        if s[y][x+1] == "#":
            yoko[y][x] = cnt
            return cnt
        else:
            yoko[y][x] = yoko_check(y, x+1, cnt+1)
            return yoko[y][x]


def tate_check(y, x, cnt):
    global tate, s
    if y == h-1:
        tate[y][x] = cnt
        return cnt
    else:
        if s[y+1][x] == "#":
            tate[y][x] = cnt
            return cnt
        else:
            tate[y][x] = tate_check(y+1, x, cnt+1)
            return tate[y][x]


for y in range(h):
    for x in range(w):
        if yoko[y][x] == 0 and s[y][x] == ".":
            yoko_check(y, x, 1)
        if tate[y][x] == 0 and s[y][x] == ".":
            tate_check(y, x, 1)

# print(tate)

result = 0
for y in range(h):
    for x in range(w):
        if s[y][x] == ".":
            result = max(result, tate[y][x]+yoko[y][x]-1)

print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np

H, W = map(int, input().split())
A = []
for _ in range(H):
    S = [0 if c == '#' else 1 for c in input().strip()]
    A.append(S)
A = np.array(A)
top = np.zeros((H+1, W), dtype=np.int)
bottom = np.zeros((H+1, W), dtype=np.int)
right = np.zeros((H, W+1), dtype=np.int)
left = np.zeros((H, W+1), dtype=np.int)
for i in range(1, H+1):
    top[i] = (top[i-1] + 1) * A[i-1]
for i in range(H-1, -1, -1):
    bottom[i] = (bottom[i+1] + 1) * A[i]
for i in range(1, W+1):
    right[:, i] = (right[:, i-1] + 1) * A[:, i-1]
for i in range(W-1, -1, -1):
    left[:, i] = (left[:, i+1] + 1) * A[:, i]
R = (top[1:] + bottom[:H] - 1) * A
C = (right[:, 1:] + left[:, :W] - 1) * A
RC = (R + C - 1) * A

print(RC.max)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

left = [0]*n
right = [0]*n

for i in range(n-1):
    left[i+1] = gcd(left[i], A[i])
    right[n-i-2] = gcd(right[n-i-1], A[n-i-1])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
C - GCD on Blackboard。
累積和を使ういい問題だが、難しい。

```python

from fractions import gcd

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

left = [0]*n
right = [0]*n

# 取り除く点を除いたGCDの累積
# 引き算できないので、両端から求めてそれぞれのgcdを取る
for i in range(n-1):
    left[i+1] = gcd(left[i], A[i])
    right[n-i-2] = gcd(right[n-i-1], A[n-i-1])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i]))
print(ans)


```

N**2分の計算量がかかる解法は比較的すぐに思いつく。
Problem p03206 (python)

Fixed submission:

def solve():

    D = int(input())

    if D == 25:
        print("Christmas")
    elif D == 24:
        print("Christmas Eve")
    elif D == 23:
        print("Christmas Eve Eve")
    elif D == 22:
        print("Christmas Eve Eve Eve")


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):


def solve():

    D = int(input())

    if D == 25:
        print(`Christmas`)
    else if D == 24:
        print(`Christmas Eve`)
    else if D == 23:
        print(`Christmas Eve Eve`)
    else if D == 22:
        print(`Christmas Eve Eve Eve`)


if __name__ == "__main__":
    solve()
Problem p03282 (python)

Fixed submission:


import collections


def solve():

    S = list(input())
    K = int(input())

    for i in range(K):
        if S[i] != "1":
            print(S[i])
            break
    else:
        print(1)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):


import collections


def solve():

    S = list(input())
    K = int(input())

    passed = 5000000000000000

    if K < passed:
        if S[0] != "1":
            print(S[0])
        else:
            print(S[1])
        exit()

    for s in S:
        if K < int(s) * passed:
            print(s)
            break
        K = K - (int(s) * passed)


if __name__ == "__main__":
    solve()
Problem p03206 (python)

Fixed submission:
print("Christmas {}".format(" ".join(['Eve'] * (25 - int(input())))).strip())

Buggy submission (verdict: Runtime Error):
print(f"Christmas {' '.join(['Eve'] * (25 - int(input())))}".strip())
Problem p03219 (python)

Fixed submission:
X, Y = [int(x) for x in input().split()]
print(X + Y // 2)

Buggy submission (verdict: Runtime Error):
print(int(input()) + int(input()) / 2)
Problem p03238 (python)

Fixed submission:
print("Hello World" if input() == "1" else int(input()) + int(input()))

Buggy submission (verdict: Runtime Error):
print("Hello World" if input() == "1" int(input()) + int(input()))
Problem p03243 (python)

Fixed submission:
N = int(input())
print(min([x for x in [int(str(i) * 3) - N for i in range(1, 10)] if x >= 0]) + N)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(min([x for x in [int(str(i) * 3) - N for i in range(1, 10)] if x > 0]) + N)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(min([x for x in [int(x * 3) for x in list(str(N))] if x - N > 0], key=lambda x: x - N))
Problem p02687 (python)

Fixed submission:
a=input()
 
if a == "ABC":
    print("ARC")
else:
    print("ABC")

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

if a == ABC:
    print("ARC")
else:
    print("ABC")
Problem p02696 (python)

Fixed submission:
import math
A,B,N= map(int,input().split())
x=[]
AB=A/B
if B==1:
    print("0")
elif N<B:
    #x.append(math.floor(AB*N-1)-A*(N//B)
    print(math.floor(AB*N))
else:
    x=[math.floor(AB*N)-A*(N//B)]
    for i in range(N//B):
        x.append(math.floor(AB*((i+1)*B-1))-i)
    print(max(x))

Buggy submission (verdict: Runtime Error):
import math
A,B,N= map(int,input().split())
x=[]
AB=A/B
if N<=B:
    #x.append(math.floor(AB*N-1)-A*(N//B)
    print(math.floor(AB*N-1)-A*(N//B)
else:
    print(math.floor(AB*B-1)
Problem p02718 (python)

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

su=sum(A)
i=0
while max(A)*4*M>=su:
    i+=1
    A.remove(max(A))
    if i>=M:
        print("Yes")
        break
else:
    print("No")

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

su=sum(A)
i=0
while max(A)*4*M>=su:
    i+=1
    A.remove(max(A))
else:
    if i>=M:
        print("Yes")
    else:
        print("No")
Problem p02724 (python)

Fixed submission:
X = int(input())

p = X//500
q= (X%500)//5

print(p*1000+q*5)

Buggy submission (verdict: Runtime Error):
def INT(): x = int(input()) return x
def LIST(): x = list(map(int, input().split())) return x

X =INT()

p = X//500
q= (X%500)//5

print(p*1000+q*5)
Problem p02741 (python)

Fixed submission:
K = int(input())
alist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(alist[K-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
alp = ["b","c","d","e","f","g","h","i","j","a"]
a = "a"
A = "a"
for i in range(N):
    word = [a]
    a = a + "a"
for i in range(N):
    word = [A]
    A = A + alp.pop(0)
word.pop(0)
word.sort()
s = "\n".join(word)
print(s)

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

if S % 2 == 0:
    print(S//2)
else:
    print(S//2+1)
Problem p02742 (python)

Fixed submission:
H , W = map(int, input().split())
S = H * W
s = S//2

if H == 1 or W ==1:
    print("1")
elif S % 2 == 0:
    print(s)
else:
    print(s+1)

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

if S % 2 = 0:
    print(S//2)
else:
    print(S//2+1)

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

if S % 2 = 0:
    print(S//2)
else:
    print(S//2+1)

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

if S % 2 = 0:
    print(S//2)
else:
    print(S//2 + 1)
Problem p02748 (python)

Fixed submission:
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = [min(a) + min(b)]
for i in range(M):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
M -= 1
ans = []
for i in range():
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-2):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-1):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = int(input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-):
    q = list(map(int, input().split()))
    x = a[A-1] + b[B-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = int(input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-1):
    q = list(map(int, input().split()))
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))

Buggy submission (verdict: Runtime Error):
A , B , M = int(input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = []
for i in range(M-1):
    q = input().split()
    x = a[q[0]-1] + b[q[1]-1] - q[2]
    ans.append(x)
print(min(ans))
Problem p02789 (python)

Fixed submission:
a,b=(int(x) for x in input().split())
if a == b:
  print("Yes")
else:
  print("No")

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

if a == b:
       print ("Yes")
else:
       print ("No")
Problem p02714 (python)

Fixed submission:
def main():
    n=int(input())
    s=input()
    ans=0
    d=dict()
    dr=[0]*n
    dg=[0]*n
    db=[0]*n
    mr=[0]*n
    mg=[0]*n
    mb=[0]*n

    for i in range(n):
        if s[i]=='R':
            dr[i]=1
            mr[i]=1
        if s[i]=='G':
            dg[i]=1
            mg[i]=1
        if s[i]=='B':
            db[i]=1
            mb[i]=1

    for i in range(n-1):
        mr[n-2-i]+=mr[n-1-i]
        mg[n-2-i]+=mg[n-1-i]
        mb[n-2-i]+=mb[n-1-i]

    for i in range(n-2):
        for j in range(i,n-1):
            if s[i]==s[j]:
                continue
            if s[i]=='R' and s[j]=='G':
                k=1
            elif s[i]=='R' and s[j]=='B':
                k=2
            elif s[i]=='G' and s[j]=='R':
                k=1
            elif s[i]=='G' and s[j]=='B':
                k=0
            elif s[i]=='B' and s[j]=='R':
                k=2
            elif s[i]=='B' and s[j]=='G':
                k=0
            #print(k)
            
            if k==0:
                ans+=mr[j+1]
                if (j+(j-i))<n:
                    ans-=dr[j+(j-i)]
            if k==1:
                ans+=mb[j+1]
                if (j+(j-i))<n:
                    ans-=db[j+(j-i)]
            if k==2:
                ans+=mg[j+1]
                if (j+(j-i))<n:
                    ans-=dg[j+(j-i)]

    print(ans)
        



main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    s=input()
    ans=0
    d=[[0]*n for _ in range(3)]
    m=[[0]*n for _ in range(3)]
    l=[[0,2,1],[2,1,0],[1,0,2]]

    for i in range(n):
        d[ord(s[i])%3][i]=1
        m[ord(s[i])%3][i]=1

    for j in range(3):
        for i in range(n-1,0,-1):
            m[j][i-1]+=m[j][i]

    for i in range(n-1):
        for j in range(i+1,n):
            if s[i]==s[j]:
                continue
            ans+=m[l[ord(s[i])][ord(s[j])]][j+1]
            if j*2-i<n:
                ans-=d[l[ord(s[i])][ord(s[j])]][j*2-i]

    print(ans)
        
main()
Problem p02767 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))

ans=99999999
for i in range(1,101):
  d=0
  for x in a:
    d+=(x-i)*(x-i)
  ans=min(ans,d)
print(ans)

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

ans=99999999
for i in range(1,101):
  d=0
  for x in a:
    d+=(a-i)*(a-i)
  ans=min(ans,d)
print(ans)

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

ans=99999999
for i in range(1,101):
  d=0
  for x in a:
    d+=(a-i)*(a-i)
  ans=min(ans,d)
print(ans)
Problem p02786 (python)

Fixed submission:
def f(h):
  if h==1:
    return 1
  else:
    return f(h//2)*2+1
  
print(f(int(input())))

Buggy submission (verdict: Runtime Error):
def f(h):
  if h==1:
    return 1
  else:
    return f[h//2]*2+1
  
print(f(int(input())))
Problem p02923 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))

ans=0
a=0
for i in range(n-1):
  if l[i]>=l[i+1]:
    a+=1
  else:
    ans=max(ans,a)
    a=0
ans=max(ans,a)
print(ans)

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

ans=0
a=0
for i in range(n-1):
  if l[i]>=l[i+1]:
    a+=1
  else:
    ans=max(ans,a)
print(ans)
Problem p02946 (python)

Fixed submission:
k,x=map(int,input().split())
xmin=max(-1000000,x-k+1)
xmax=min(1000000,x+k-1)
for i in range(xmin,xmax+1):
  print(i,end=" ")

Buggy submission (verdict: Runtime Error):
#include<iostream>
using namespace std;
int main(){
  int k,x,a,b;
  scanf("%d %d",&k,&x);
  if(-1000000<x-k+1){
    a=x-k+1;
  }
  else{
    a=-1000000;
  }
  if(1000000>x+k-1){
    b=x+k-1;
  }
  else{
    b=1000000;
  }
  for(int i=a;i<b;i++){
  cout<<i<<" ";
  }
  cout<<b<<endl;
}
Problem p02982 (python)

Fixed submission:
n,d=map(int,input().split())
x=[]
for _ in range(n):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(x[i][k]-x[j][k])**2
    dist=dist**0.5
    if dist.is_integer():
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
x=[]
for _ in range(d):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(d):
  for j in range(i+1,d):
    l=0
    for k in range(n):
      l+=(x[i][k]-x[j][k])**2
    l=l**0.5
    if l.is_integer():
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
x=[]
for _ in range(d):
  x+=[list(map(int,input().split()))]
ans=0
for i in range(d):
  for j in range(i+1,d):
    l=0
    for k in range(n):
      l+=(x[i][k]-x[j][k])**2
    if l==l**0.5**2:
      ans+=1
print(ans)
Problem p03078 (python)

Fixed submission:
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()))
a.sort(reverse=1)
b.sort(reverse=1)
c.sort(reverse=1)
m=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if (i+1)*(j+1)*(k+1)>K:
        break
      m.append(a[i]+b[j]+c[k])
m.sort(reverse=1)
for i in m[:K]:
  print(i)

Buggy submission (verdict: Runtime Error):
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()))
a.sort(reverse=1)
b.sort(reverse=1)
c.sort(reverse=1)
m=[]
for i in range(x):
  for j in range(y):
    for k in range(z):
      if i*j*k>K:
        continue
      m.append(a[i]+b[j]+c[k])
m.sort(reverse=1)
for i in m[:K]:
  print(i)
Problem p03089 (python)

Fixed submission:
n=int(input())
m=list(map(int,input().split()))
ans=[]
for i in range(n):
  for j in range(n-1-i,-1,-1):
    if not m[j]==j+1:
      continue
    #m[j]==j
    ans.append(j+1)
    m=m[:j]+m[j+1:]
    break
if not len(m)==0:
  print(-1)
else:
  for i in range(n):
    print(ans[n-1-i])

Buggy submission (verdict: Runtime Error):
n=int(input())
m=list(map(int,input().split()))
ans=[]
for i in range(n):
  for j in range(n-1-i,-1,-1):
    if not m[j]==j+1:
      continue
    #m[j]==j
    ans.append(j+1)
    m=m[:j]+m[j+1:]
if not len(m)==0:
  print(-1)
else:
  for i in range(n):
    print(ans[n-1-i])

Buggy submission (verdict: Runtime Error):
n=int(input())
m=list(map(int,input().split()))
ans=[]
for i in range(n):
  for j in range(n-1-i,-1,-1):
    if not m[j]==j:
      continue
    #m[j]==j
    ans.append(j+1)
    m=m[:j]+m[j+1:]
if not len(m)==0:
  print(-1)
else:
  for i in range(n):
    print(ans[n-1-i])

Buggy submission (verdict: Runtime Error):
n=int(input())
m=list(map(int,input().split()))
ans=[]
for i in range(n):
  for j in range(i,-1,-1):
    if not m[j]==j:
      continue
    #m[j]==j
    ans.append(j)
    m=m[:j]+m[j+1:]
if not len(m)==0:
  print(-1)
else:
  for i in range(n):
    print(ans[n-1-i])
Problem p03095 (python)

Fixed submission:
n=int(input())
l=input()
d=dict()
for a in l:
  if not a in d:
    d[a]=1
  else:
    d[a]+=1
ans=1
for a in d.values():
  ans*=a+1
print((ans-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=0
for i in range(n):
    for j in range(i,j):
        if s[j] in s[i:j]:
            break
        ans+=1
print(ans)
Problem p03112 (python)

Fixed submission:
import bisect

A,B,Q=map(int,input().split())
inf = 10 ** 18
S = [-inf] + [int(input()) for _ in range(A)] + [inf]
T = [-inf] + [int(input()) for _ in range(B)] + [inf]

for q in range(Q):
    x = int(input())
    s_h = bisect.bisect(S,x)
    s_l = s_h - 1
    t_h = bisect.bisect(T,x)
    t_l = t_h - 1

    ans = inf
    for s in [S[s_l],S[s_h]]:
        for t in [T[t_l],T[t_h]]:
            d1 = abs(s-x)+abs(t-s)
            d2 = abs(t-x)+abs(s-t)
            ans = min(ans,d1,d2)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

A,B,Q=map(int,input().split())
inf = 10 ** 18
S = [-inf] + [int(input()) for _ in range(A)] + [inf]
T = [-inf] + [int(input()) for _ in range(B)] + [inf]

for q in range(Q):
    x = int(input())
    s_l = bisect.bisect_left(s,x)
    s_h = s_l + 1
    t_l = bisect.bisect_left(t,x)
    t_h = t_l + 1

    ans = inf
    for s in [S[s_l],S[s_h]]:
        for t in [T[t_l],T[t_h]]:
            d1 = abs(s-x)+abs(t-s)
            d2 = abs(t-x)+abs(s-t)
            ans = min(ans,d1,d2)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

A,B,Q=map(int,input().split())
inf = 10 ** 18
S = [-inf] + [int(input()) for _ in range(A)] + [inf]
T = [-inf] + [int(input()) for _ in range(B)] + [inf]

for q in range(Q):
    x = int(input())
    s_l = bisect.bisect_left(s,x)
    s_h = s_l + 1
    t_l = bisect.bisect_left(t,x)
    t_h = t_l + 1

    ans = inf
    for s in [s_l,s_h]:
        for t in [t_l,t_h]:
            d1 = abs(s-x)+abs(t-s)
            d2 = abs(t-x)+abs(s-t)
            ans = min(ans,d1,d2)
    
    print(ans)
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  b=list(map(int,input().split()))
  for i in range(b[0]):
    a[b[i+1]-1]+=1
ans=0
for i in a:
  if i==n:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  k=list(map(int,input().split()))
  for j in range(1,k[0]):
    a[k[j]-1]=1
    
print(m.count(0))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0 for i in range(m)]
for i in range(n):
  b=list(map(int,input().split()))
  for i in range(b[0]):
    a[b[i+1]]+=1
ans=0
for i in a:
  if i==n:
    ans+=1
print(ans)