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

Fixed submission:
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
Ken_n,City_n = (int(i) for i in input().split())
city ={i:[] for i in range(1,Ken_n+1)}
for i in range(1,City_n+1):
    p,y = (int(i) for i in input().split())
    city[p].append((y,i))

city_ID ={i:0 for i in range(1,City_n +1)}
for i in range(1,Ken_n +1):
    city[i].sort()
    
    for j in range(len(city[i])):
        city_ID[city[i][j][1]] = "{0:06d}".format(i) +"{0:06d}".format(j+1)

for i in range(1,City_n +1):
    print(city_ID[i])

Buggy submission (verdict: Runtime Error):
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
Ken_n,City_n = (int(i) for i in input().split())
city ={i:[] for i in range(1,City_n+1)}
for i in range(1,City_n+1):
    p,y = (int(i) for i in input().split())
    city[p].append((y,i))

city_ID ={i:0 for i in range(1,City_n +1)}
for i in range(1,Ken_n +1):
    city[i].sort()
    for j in range(len(city[i])):
        city_ID[city[i][j][1]] = "{0:06d}".format(i) +"{0:06d}".format(j+1)

for i in range(1,City_n +1):
    print(city_ID[i])
Problem p03253 (python)

Fixed submission:
#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 組み合わせの総数 p=10**9+7 で割ったあまりを求める Satoooh Blog 2020/02/27 4分 
"""n<10**7 , p は素数"""
def cmb(n, r, p):

    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p



# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline  #文字列では使わない
mod =10**9 +7
p =mod
N,M = map(int, input().split())
a =soinsu_bunkai(M)
ans =1

n = 10 ** 6  # n は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

#mod p における n の逆元の計算
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in a.values():
    x =cmb(N +i -1,i,mod)
    ans *=x
print(ans %mod)

Buggy submission (verdict: Runtime Error):
#素因数分解
def soinsu_bunkai(m):
    pf={}

    for i in range(2,int(m**0.5)+1):
        while m%i==0:
            pf[i]=pf.get(i,0)+1
            m//=i
    if m>1:
        pf[m]=1
    return pf

# 組み合わせの総数 p=10**9+7 で割ったあまりを求める Satoooh Blog 2020/02/27 4分 
"""n<10**7 , p は素数"""
def cmb(n, r, p):

    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p



# 初期入力
from collections import Counter
import sys
input = sys.stdin.readline  #文字列では使わない
mod =10**9 +7
p =mod
N,M = map(int, input().split())
a =soinsu_bunkai(M)
ans =1

n = 10 ** 5+1  # n は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

#mod p における n の逆元の計算
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in a.values():
    x =cmb(N +i -1,i,mod)
    ans *=x
print(ans %mod)
Problem p02773 (python)

Fixed submission:
n=int(input())

S={}
maxr=0
for i in range(n):
    s=input()
    if s in S:
        S[s]+=1
    else:
        S[s]=1

maxc = max(S.values())

ans=[]
for s in S:
    if S[s]==maxc :
        ans.append(s)

ans.sort()
for s in ans:
    print(s)

Buggy submission (verdict: Runtime Error):

def writeSC(s,i):
    if s in SC[i] :
        i = writeSC(s,i+1)
        # print(i,SC[i])
        return(i)
    else:
        SC[i].append(s)
        return(i)

n=int(input())

SC=[[] for i in range(n)] 

maxr=0
for i in range(n):
    s=input()
    res = writeSC(s,0)
    if maxr<res :
        maxr=res

SC[maxr].sort()
# print(maxr, SC[maxr])
for i in range(len(SC[maxr])):
    print(SC[maxr][i])
Problem p03013 (python)

Fixed submission:
import time
MOD = 10**9+7

n,m = map(int,input().split())

stime = time.time()
F=[0]*(n+1)
F[0]=1
F[1]=2
for i in range(2,n):
    F[i]=(F[i-1]+F[i-2])%MOD

etime =time.time()


a=[0]*(n+1)
ans=1
for i in range(m):
      a[int(input())-1]+=1

io=-1
for i in range(n-1):
      if 0!=a[i] :
            io=i+1
            if 0!=a[i+1]:
                  print("0")
                  exit()
      else:
            if a[i+1] and i-io>1 :
                  ans*=F[i-io-1]%MOD
                  s=0
i=n-1
if i-io>0 :
      ans*=F[i-io-1]%MOD
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
import time
MOD = 10**9+7

n,m = map(int,input().split())

stime = time.time()
F=[0]*n
F[0]=1
F[1]=2
for i in range(2,n):
    F[i]=(F[i-1]+F[i-2])%MOD

etime =time.time()


a=[0]*n
ans=1
for i in range(m):
      a[int(input())-1]+=1

io=-1
for i in range(n-1):
      if 0!=a[i] :
            io=i+1
            if 0!=a[i+1]:
                  print("0")
                  exit()
      else:
            if a[i+1] and i-io>1 :
                  ans*=F[i-io-1]%MOD
                  s=0
i=n-1
ans*=F[i-io-1]%MOD
print(ans%MOD)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))
A.sort()
B.sort(key=lambda B: B[1], reverse=True)

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = min(B[i][0],n-j)
    if newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                break
        else:
            k+=1
        ans+=newv*(k)-sum(A[j:j+k])
        i+=1
        j+=k
    else:
        break
    if i>=m :
        break

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))
A.sort()
B.sort(key=lambda B: B[1], reverse=True)

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = B[i][0]
    if newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                break
        else:
            k+=1
        ans+=newv*(k)-sum(A[j:j+k])
        i+=1
        j+=k
    else:
        break
    if i>=m :
        break

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A = list(map(int,input().split()))
B=[]
for i in range(m):
    B.append(list(map(int,input().split())))

B.sort(key=lambda B: B[1], reverse=True)
A.sort()

i=j=0
ans = sum(A)
while j<n:
    newv = B[i][1]
    newc = B[i][0]
    if newv>A[j+newc-1] :
        ans+=newv*newc-sum(A[j:j+newc])
        i+=1
        j+=newc
    elif newv>A[j] :
        for k in range(newc):
            if newv<=A[j+k]:
                ans+=newv*k-sum(A[j:j+k])
                i+=1
                j+=k
                break
    else:
        break
    if i>=m :
        break

print(ans)
Problem p03137 (python)

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

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(min(n-1,m-1)):
        d += D[i]    

ans = sum(D)-d
print(ans)

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

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
if i>1:
    for i in range(n-1):
        d += D[i]    

ans = sum(D)-d
print(ans)

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

if m==1 :
    print(0)
    exit()

X.sort()
D=[]
for i in range(1,m):
    D.append(X[i]-X[i-1])

D.sort(reverse=True)
d=0
for i in range(n-1):
    d += D[i]    

ans = sum(D)-d
print(ans)
Problem p02596 (python)

Fixed submission:
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k//7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l

Buggy submission (verdict: Runtime Error):
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k/7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l
Problem p02623 (python)

Fixed submission:
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+ A[i])
for i in range(m):
    b.append(b[i] + B[i])
# print(a)
# print(b)
# print(a[3])
ans=0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

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

  # nは入力回数
A = list(map(int, input().split()))

B = list(map(int, input().split()))
sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+int(temp) > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + int(temp) > K:
            break
            print(count)
        else:
            sum += temp
            count += 1

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
  # nは入力回数
A = [list(map(int, input().split())) for _ in range(N)]

B = [list(map(int, input().split())) for _ in range(M)]

sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+temp > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + temp > K:
            break
            print(count)
        else:
            sum += temp
            count += 1

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
  # nは入力回数
A = [list(map(int, input().split())) for _ in range(N)]

B = [list(map(int, input().split())) for _ in range(M)]

sum=0
count = 0
for i in range(N+M):
    if A[0] >= B[0]:
        temp = B.pop(0)
        if sum+temp > K:
            break
            print(count)
        else:
            sum +=temp
            count += 1

    else:
        temp = A.pop(0)
        if sum + temp > K:
            break
            print(count)
        else:
            sum += temp
            count += 1
Problem p02659 (python)

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

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction

# a = Fraction(28, 10)
# b = Fraction(27, 10)
# x = a - b
# print(x)  # -> 1/10


a,b = map(float, input().split())

b = Fraction(int(b*10000000000000,10000000000000))

ans = (int(a) * b)
print(int(ans))
Problem p02580 (python)

Fixed submission:
import sys
H, W, M = map(int, input().split())
lis =set()
Hlis = [0]*H
Wlis = [0]*W
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Wlis[Cm-1] += 1
    lis.add((Ch, Cm))

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Wmax = max(Wlis)
Widx = [i+1 for i, v in enumerate(Wlis) if v == Wmax]

for i in range(len(Hidx)):
    for j in range(len(Widx)):
        if (Hidx[i], Widx[j]) not in lis:
            print(Hmax+Wmax)
            sys.exit()
else:
    print(Hmax + Wmax -1)

Buggy submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

for i in range(len(Hidx)):
    for j in range(len(Midx)):
        if [Hidx[i], Midx[j]] not in lis:
            print(Hmax+Mmax)
            sys.exit()
else:
    print(Hmax + Mmax -1)

Buggy submission (verdict: Runtime Error):
import sys
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

for i in range(len(Hidx)):
    for j in range(len(Midx)):
        if [[Hidx, Midx]] not in lis:
            print(Hmax+Mmax)
            sys.exit()
else:
    print(Hmax + Mmax -1)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = [i+1 for i, v in enumerate(Hlis) if v == Hmax]
Mmax = max(Mlis)
Midx = [i+1 for i, v in enumerate(Mlis) if v == Mmax]

if [Hidx, Midx] in lis:
    print(Hmax + Mmax -1)
else:
    print(Hmax+Mmax)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
lis =[]
Hlis = [0]*H
Mlis = [0]*M
for _ in range(M):
    Ch, Cm = map(int, input().split())
    Hlis[Ch-1] += 1
    Mlis[Cm-1] += 1
    lis.append([Ch, Cm])

Hmax = max(Hlis)
Hidx = Hlis.index(Hmax)+1
Mmax = max(Mlis)
Midx = Mlis.index(Mmax)+1

if [Hidx, Midx] in lis:
    print(Hmax + Mmax -1)
else:
    print(Hmax+Mmax)
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
for i in range(n): #累積和ai,bjを求める
 acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
 acum2.append(acum2[-1]+arr2[i])
ans=0
j=m
for i in range(n+1):
 if acum1[i]>k: #ai>Kであれば、どのようにjを選んでもai+bj<=Kとなることはないので探索を終了する
   break
 while acum2[j]>k-acum1[i] and j>0: #各iについて、bj<=K-aiを満たす最大のjを求める
   j-=1
 ans=max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Asum = [0] * N
Bsum = [0] * M
res = [0]

for i in range(N-1):
    Asum[0] = A[0]
    Asum[i+1] = Asum[i] + A[i+1]
    if Asum[i+1] > K:
        Aend = i
        break    
for j in range(M-1):
    Bsum[0] = B[0]
    Bsum[j+1] = Bsum[j] + B[j+1]
    if Bsum[j+1] > K:
        Bend = j
        break


for k in range(N):
    for l in range(M):
        if (Asum[k] + Bsum[l]) > K:
            res.append(k+1+l-1+1)
            break
        elif (Asum[k] + Bsum[l]) == K:
            res.append(k+1+l+1)
            break
        elif l == j:
            res.append(k+1+l+1)
            break

print(max(res))

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Asum = [0] * N
Bsum = [0] * M
res = [0]

for i in range(N-1):
    Asum[0] = A[0]
    Asum[i+1] = Asum[i] + A[i+1]
for j in range(M-1):
    Bsum[0] = B[0]
    Bsum[i+1] = Bsum[i] + B[i+1]

for i in range(N):
    for j in range(M):
        if (Asum[i] + Bsum[j]) >= K:
            res.append(i+1+j-1+1)
            break

print(max(res))

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
time = 0
numA = 0
numB = 0

while time < K:
    if A[numA] < B[numB]:
        time += A[numA]
        if time <= K:
            numA += 1
        else:
            break
    else:
        time += B[numB]
        if time <= K:
            numB += 1
        else:
            break

print(numA + numB)
Problem p02624 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
    ans += (N//i)*(i+(i*(N//i)))//2
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
N = int(input())
count = 0
for i in range(N+1):
    count += i * sympy.divisor_count(i)

print(count)

Buggy submission (verdict: Runtime Error):
import sympy
N = int(input())
count = 0
for i in range(N+1):
    count += (i * len(sympy.divisors(i)))

print(count)

Buggy submission (verdict: Runtime Error):
import sympy
N = int(input())
count = 0
for i in range(N+1):
    count += (i * len(sympy.divisors(i)))

print(count)
Problem p02689 (python)

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

t = [0]*N
for i in range(M):
   a, b = map(int, input().split())
   t[a-1] = max(t[a-1], H[b-1])
   t[b-1] = max(t[b-1], H[a-1])

res = 0
for i in range(N):
    if H[i] > t[i]:
        res += 1

print(res)

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

t = [0]*N
for i in range(M):
   a, b = map(int, input().split())
   t[a-1] = max(t[a-1], H[b-1])
   t[b-1] = max(t[b-1], H[a-1])

res = 0
for i range(N):
    if H[i] > t[i]:
        res += 1

print(res)
Problem p02712 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        A.append(i)
print(sum(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N+1):
    if i+1 % 3 != 0 and i+1 % 5 != 0
        A.append(i)
print(sum(A))
Problem p02550 (python)

Fixed submission:
def main():
    N,X,M = map(int,input().split())
    dict = {key:0 for key in range(M)}
    #print(dict)
    if N==1:
        return X
    dict[X] += 1
    cnt = 1
    A = [0]*(M+1)
    A[1] = X
    ans = X
    tmp = X
    for i in range(1,N,1):
        tmp = (tmp**2)%M
        if dict[tmp] != 0:
            break
        ans += tmp
        A[i+1] = A[i]+tmp
        cnt += 1
        dict[tmp] += cnt

    num = N - cnt#残り足す回数
    roop_num = cnt - dict[tmp] + 1
    syo = num//roop_num
    amari = num%roop_num
    ans += syo*(A[cnt]-A[dict[tmp]-1])
    ans += (A[dict[tmp]+amari-1]-A[dict[tmp]-1])
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N,X,M = map(int,input().split())
    dict = {key:0 for key in range(M)}
    #print(dict)
    if N==1:
        return X
    dict[X] += 1
    cnt = 1
    A = [0]*M
    A[1] = X
    ans = X
    tmp = X
    for i in range(1,N,1):
        tmp = (tmp**2)%M
        if dict[tmp] != 0:
            break
        ans += tmp
        A[i+1] = A[i]+tmp
        cnt += 1
        dict[tmp] += cnt

    num = N - cnt#残り足す回数
    roop_num = cnt - dict[tmp] + 1
    syo = num//roop_num
    amari = num%roop_num
    ans += syo*(A[cnt]-A[dict[tmp]-1])
    ans += (A[dict[tmp]+amari-1]-A[dict[tmp]-1])
    return ans

print(main())

Buggy submission (verdict: Runtime Error):
def main():
    N,X,M = map(int,input().split())
    dict = {key:0 for key in range(M)}
    #print(dict)
    dict[X] += 1
    cnt = 1
    A = [0]*M
    A[1] = X
    ans = X
    tmp = X
    for i in range(1,N,1):
        tmp = (tmp**2)%M
        if dict[tmp] != 0:
            break
        ans += tmp
        A[i+1] = A[i]+tmp
        cnt += 1
        dict[tmp] += cnt

    num = N - cnt#残り足す回数
    roop_num = cnt - dict[tmp] + 1
    syo = num//roop_num
    amari = num%roop_num
    ans += syo*(A[cnt]-A[dict[tmp]-1])
    ans += (A[dict[tmp]+amari-1]-A[dict[tmp]-1])
    return ans

print(main())
Problem p02580 (python)

Fixed submission:
def main():
    H,W,M = map(int,input().split())
    dict_gyo = {key: 0 for key in range(H)}
    dict_retu = {key: 0 for key in range(W)}
    dict_ichi = {}
    for i in range(M):
        h,w = map(int,input().split())
        dict_gyo[h-1] += 1
        dict_retu[w-1] += 1
        dict_ichi[(h-1,w-1)] = 1

    #print(dict_gyo,dict_ichi)

    maxgyo = max(dict_gyo.values())
    maxretu = max(dict_retu.values())
    #maxgyo_k = max(dict_gyo, key = dict_gyo.get)
    #maxretu_k = max(dict_retu, key = dict_gyo.get)
    #print(maxgyo_k,maxretu_k)
    result = maxgyo + maxretu - 1
    wi = [i for i in range(W) if dict_retu[i] == maxretu]
    for h in [i for i in range(H) if dict_gyo[i] == maxgyo]:
        for w in wi:
            if (h,w) not in dict_ichi:
                result = maxgyo + maxretu
                return result

    return result




print(main())

Buggy submission (verdict: Runtime Error):
def main():
    H,W,M = map(int,input().split())
    list = []
    dict_H = {key:0 for key in range(1,H+1,1)}
    dict_W = {key:0 for key in range(1,W+1,1)}
    for i in range(M):
        h,w = map(int,input().split())
        dict_H[h] += 1
        dict_W[w] += 1
        list.append((h,w))
    #print(list)
    maxH = max(dict_H.values())
    maxW = max(dict_W.values())
    wi = [i for i in range(1,W+1,1) if dict_H[i] == maxW]
    #print(retuH,gyoW,wi)
    for h in [i for i in range(1,H+1,1) if dict_W[i] == maxH]:
        for w in wi:
            if ((h,w) not in list):
                return maxH + maxW
    return maxH + maxW -1

print(main())
Problem p02596 (python)

Fixed submission:
def main():
    K = int(input())
    if K%2 == 0:
        return -1
    ans = 1
    amari_reserve = 7%K
    amari = amari_reserve
    if amari_reserve == 0:
        return ans

    while (ans <= K):
        ans += 1
        amari = (10*amari+7) % K
        if amari == 0:
            return ans
        if amari == amari_reserve:
            return -1

    return -1


print(main())

Buggy submission (verdict: Runtime Error):
def main():
    K = int(input())
    if K%2 == 0:
        return -1

    amari_sum = 0
    i = 1
    amari = 7 % K
    amari_sum += amari
    if amari == 0:
        return i

    while True:
        i += 1
        if
        amari = (amari*10) % K
        amari_sum += amari
        if amari_sum % K == 0:
            return i
        else:
            amari_sum %= K

print(main())