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

Fixed submission:

N = input()

ans = -(-int(N) // 2)

print(ans)

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

A = np.empty(9)
b = np.empty(10)
place = ''

for i in range(0,7,3):
  A[i], A[i+1], A[i+2] = map(int,input().split())

N = int(input())

for n in range(N):
  b[n] = int(input())
  for j in range(9):
  	if b[n] == A[j]:
  		place = place + ' ' + str(j)

ans='No'

for i in range(0,7,3):
  if str(i) and str(i+1) and str(i+2) in place:
  	ans = 'Yes'

for i in range(3):
  if str(i) and str(i+3) and str(i+6) in place:
  	ans = 'Yes'

if '0' and '4' and '8' in place:
	ans = 'Yes'
if '2' and '4' and '6' in place:
	ans = 'Yes'

print(ans)
Problem p02777 (python)

Fixed submission:
S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

if U == S:
	A = A - 1
else:
	B = B - 1

print('{} {}'.format(A, B))

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c == 1:
	print('YES')
else:
	print('NO')
Problem p02779 (python)

Fixed submission:
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c == 1:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
A = input().split(' ')

c = max(collections.Counter(A).values())
if c = = 1:
	print('YES')
else:
	print('NO')
Problem p02829 (python)

Fixed submission:
A = input()
B = input()
A = int(A)
B = int(B)

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans = 2
elif A+B == 5:
    ans = 1
print(ans)

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

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans == 2
elif A+B == 5:
    ans == 1
print(ans)

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

if A+B == 3:
    ans = 3
elif A+B == 4:
    ans == 2
elif A+B == 5:
    ans == 1
Problem p02835 (python)

Fixed submission:
A1, A2, A3 = map(int, input().split())

if A1 + A2 + A3 >= 22:
	print('bust')
else:
	print('win')

Buggy submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())

if sum(A1, A2, A3) >= 22:
	print('bust')
else:
	print('win')

Buggy submission (verdict: Runtime Error):
A1, A2, A3 = map(int, input().split())

if sum(A1, A2, A3) >= 22:
	print('bust')
else:
	print('win')
Problem p02629 (python)

Fixed submission:
N = int(input())
ans = ''

i = 1
while True:
    if N <= 26**i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N%26)
            N //= 26
        break
    else:
        N -= 26 ** i
    i+=1
print(ans[::-1])

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

while True:
    if N <= 26**i:
        N -= 1
        for j i in range(N):
            ans += chr(ord('a') + N%26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
hole = [False]*(n+1)

for i in am:
    hole[i] = True

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if not hole[j]:
            dp[j] += dp[i]
            dp[j] %=1000000007
print(dp[n])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
dic2 = {}

def stairs(n):
    global dic2
    if dic2.get(n):
        return dic2[n]

    if n == 0:
        return 1
    elif n ==1:
        return 1

    if n-1 not in am:
        n1 = stairs(n-1)
    else:
        n1 = 0
    if n-2 not in am:
        n2 = stairs(n-2)
    else:
        n2 = 0

    dic2[n] = (n1+n2)%1000000007

    return (n1+n2)%1000000007

print(stairs(n))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
am = [int(input()) for _ in range(m)]
dic = {}
def dfs(i):

    global dic
    if dic.get(i):
        return dic[i]

    if i == n:
        return 1

    k = 0
    if i+1 not in am and i+1 <= n:
        k += dfs(i+1)
    if i+2 not in am and i+2 <= n:
        k += dfs(i+2)

    k %= 1000000007
    dic[i] = k
    return k

print(dfs(0))
Problem p03042 (python)

Fixed submission:
s = input()
a = int(s[:2])
b = int(s[2:])
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif a<=99 and 0<b<=12:
    print('YYMM')
elif 0<a<=12 and b<=99:
    print('MMYY')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[:2])
b = int(s[2:])
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if a<=12 and b<=12:
    print('AMBIGUOUS')
elif 0<a<=12 and 0<b<=days[a]:
    print('YYMM')
elif 0<b<=12 and 0<a<=days[b]:
    print('MMYY')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s = input()
a = int(s[:2])
b = int(s[2:])
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
if a<=12 and b<=12:
    print('AMBIGUOUS')
elif a<=12 and b<=days[a]:
    print('YYMM')
elif b<=12 and a<=days[b]:
    print('MMYY')
else:
    print('NA')
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = map(int,input().split())

print(x2-(y2-y1), y2+(x2-x1), x1-(y2-y1), y1+(x2-x1))

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int,input().split())
if x1==x2:
    print(x2+(y1-y2), y2, x1+(y1-y2), y1)
else:
    print(x2, y2+(x1-x2), x1, y1y2+(x1-x2))
Problem p03803 (python)

Fixed submission:
A, B = map(int, input().split())
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[] for _ in range(N)]

for _ in range(M):
    a, b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

count = 0

def dfs(i, now, done):
    global count
    if i == N-1:
        count += 1
        return

    for j in ab[now]:
        if j not in done:
            dfs(i+1, j, done + [j])
    return

dfs(0, 0, [0])
print(count)
Problem p03805 (python)

Fixed submission:
import itertools

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

path = [[False] * n for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a][b] = True
    path[b][a] = True

ans = 0

for i in itertools.permutations(range(n), n):#N!
    if i[0] == 0:
        for j in range(n):
            if j == n - 1:
                ans += 1
                break
            if not path[i[j]][i[j + 1]]:
                break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[] for _ in range(M)]

for _ in range(M):
    a, b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

count = 0

def dfs(i, now, done):
    global count
    if i == N-1:
        count += 1
        return

    for j in ab[now]:
        if j not in done:
            dfs(i+1, j, done + [j])
    return

dfs(0, 0, [0])
print(count)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[] for _ in range(M)]

for _ in range(M):
    a, b = map(int,input().split())
    ab[a-1].append(b-1)
    ab[b-1].append(a-1)

count = 0

def dfs(i, now, done):
    global count
    if i == N-1:
        count += 1
        return

    for j in ab[now]:
        if j not in done:
            dfs(i+1, j, done + [j])
    return

dfs(0, 0, [0])
print(count)
Problem p02596 (python)

Fixed submission:
k = int(input())
m = 0

for i in range(k):
    m = (m * 10 + 7) % k
    if m == 0:
        break
    elif i == k - 1:
        print(-1)
        exit()

print(i + 1)

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

if n[-1] == "1":
    m = 7
elif n[-1] == "3":
    m = 9
elif n[-1] == "7":
    m = 1
elif n[-1] == "9":
    m = 3
else:
    print(-1)
    exit()

n = int(n)

for i in range(1, k):
    if len(set(list(str(n * m)))) == 1:
        break
    m = int(str(i) + str(m)[-1])
    if len(str(n * m)) >= k:
        print(-1)
        exit()

print(len(str(n * m)))
Problem p02659 (python)

Fixed submission:
import math

a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
ans = str(a * b)

if len(ans) > 2:
    print(int(ans[:-2]))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(float, input().split())
a = int(a)
b = int(b * 100)
ans = str(a * b)

print(int(ans[:-2]))
Problem p02712 (python)

Fixed submission:
n = int(input())
sum = 0
for i in range(1, n+1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
sum = 0

for i in range(1, n + 1):
    if i % 3 != 0 && i % 5 != 0:
        sum += i

print(sum)
Problem p02759 (python)

Fixed submission:
import math
n = int(input())
print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1

    for i in range(n):
        if num_list[i] == 'X':
            num_list[i] = '1' if i == 0 else '0'

    return ''.join(num_list)

print(ans())
Problem p02779 (python)

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

if len(set(a_list)) == n:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
index = 0
value = 0

for i in range(n - k):
    if p_list[i] < p_list[i + k]:
        index = i + 1

for i in range(k):
    value += (1 + p_list[index + i])/ 2 

print(value)
Problem p02781 (python)

Fixed submission:
def solve(n,k) :
    if n <= 9 and k == 1 :
        return n
    elif n <= 9 and k >= 2 :
        return 0
    elif k == 0:
        return 1
    else :
        m = n //10
        r = n % 10
        return  r * solve(m,k-1) + (9 - r) * solve(m-1,k-1) + solve(m,k)

n = int(input())
k = int(input())
print(solve(n,k))

Buggy submission (verdict: Runtime Error):
def solve(n,k) :
    if n <= 9 and k == 1 :
        return n
    elif n <= 9 and k >= 2 :
        return 0
    else :
        m = n //10
        r = n % 10
        return  r * solve(m,k-1) + (9 - r) * solve(m-1,k-1) + solve(m,k)

n = int(input())
k = int(input())
print(solve(n,k))
Problem p02729 (python)

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

print((n*(n-1)//2)+(m*(m-1)//2))

Buggy submission (verdict: Runtime Error):
n,m=int(input().split())
if n<=1:
    n=0
if m<=1:
    m=0
print((n*(n-1)//2)+(m*(m-1)//2))
Problem p02860 (python)

Fixed submission:
N=int(input())
s=input()
if N%2==1:
  print("No")
else:
  b=1
  for i in range(N//2):
    if s[i]!=s[N//2+i]:
      print("No")
      b=0
      break
      
  if b==1:
  	print("Yes")

Buggy submission (verdict: Runtime Error):
N=int(input())
s=input()
if N%2==1:
  print("No")
else:
  for i in range(N):
    if s[i]!=s[N-i-1]:
      print("No")
      return(0)
  print("Yes")
Problem p02880 (python)

Fixed submission:
N=int(input())
def f(N):
  for i in range(1,10):
    j=N//i
    if i*j==N and (j>=1 and j<=9):
      return(True)
  return(False)
if f(N):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
def f(N):
	for i in range(1,10):
  		j=N//i
        if i*j==N and j>=1 and j<=9:
          return(True)
   	return(False)
if f(N):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N=int(input())
def f(N):
	for i in range(1,10):
  		for j in range(1,10):
    		if i*j==N:
              return(True)
   	return(False)
if f(N):
  print("YES")
else:
  print("NO")
Problem p02699 (python)

Fixed submission:
S, W = list(map(int, input().split()))
 
if W >= S:
  print("unsafe")
 
else:
  print("safe")

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

if W >= S:
  print("unsafe")

else:
  print("safe")
Problem p02701 (python)

Fixed submission:
import collections

N = int(input())
S = list(input() for _ in range(N))

setS = set(S)

print(len(setS))

Buggy submission (verdict: Runtime Error):
3
apple
orange
apple
Problem p02773 (python)

Fixed submission:
N = int(input())

d = {}

for i in range(N):
    s = input()
    if s in d:
        d[s] = d[s] + 1
    else:
        d[s] = 1

hoge = max(d.values())

max_kv_list = [kv[0] for kv in d.items() if kv[1] == hoge]

max_kv_list = sorted(max_kv_list)
for ans in max_kv_list:
    print(ans)

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

d = {}

for i in range(N):
    s = input()
    if s in d:
        d[s] = d[s] + 1
    else:
        d[s] = 1

hoge = max(d.values)

max_kv_list = [kv[0] for kv in d.items() if kv[1] == hoge]

max_kv_list = sorted(max_kv_list)
for ans in max_kv_list:
    print(ans)
Problem p02881 (python)

Fixed submission:
N = int(input())

n_hoge = int(N ** 0.5)
print

true_ans = 10 ** 12
for i in range(1,n_hoge+1):
    if N % i == 0:
        ans = N // i
        true_ans = min(ans + i - 2, true_ans)

print(true_ans)

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

n_sq = N ** 0.5

n_sq_int = int(n_sq // 1)

#print(n_sq_int)

for i in reversed(range(n_sq_int)):
    if N % i == 0:
        ans = N // i
        print(ans + i - 2)
        exit()
Problem p03013 (python)

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

brk_stair = [1] * (N + 1)
dp = [0] * (N + 1)

for _ in range(M):
    brk_stair[int(input())] = 0

#print(brk_stair)

dp[0] = 1
dp[1] = 1 * brk_stair[1]

for i in range(2, N + 1):
    dp[i] = (dp[i - 1] + dp[i-2]) * brk_stair[i]

print(dp[-1] % 1000000007)

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

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

aList = [int(input()) for _ in range(M)]

aList.insert(0,-1)
aList.append(N+1)

#print(aList)

aArray = np.array(aList)

katamari = []

for i in range(M+1):
    katamari.append(aArray[i+1] - aArray[i] - 1)

#print(katamari)

ans = 1
for i in range(M):
    ans *=  (1 / math.sqrt(5)) * (((1 + math.sqrt(5)) / 2) ** katamari[i] - ((1 - math.sqrt(5)) / 2) ** katamari[i])

print(int(ans) % 1000000007)
Problem p02688 (python)

Fixed submission:
N,K= map(int,input().split())
okashi=[0]*N

for i in range(K):
    d=int(input())
    Ad = list(map(int,input().split()))
    for j in Ad:
        okashi[j-1]+=1
count=0
for i in okashi:
    if i==0:
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N,K= map(int,input().split())
d1=int(input())
Ad1 = list(map(int,input().split()))
d2=int(input())
Ad2 = list(map(int,input().split()))
okashi=[0]*N
for i in Ad1:
    okashi[i-1]+=1
for i in Ad2:
    okashi[i-1]+=1
count=0
for i in okashi:
    if i==0:
        count+=1
print(count)
Problem p02712 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(N+1):
  if i % 3 == 0 or i % 5 == 0:
    pass
  else:
    ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
for i in range(N):
	if i%3!==0 and i%5==0:
      ans+=i
print(ans)
Problem p02723 (python)

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
K,N = map(int,input().split())
li = list(map(int,input().split()))
maxd=(K-li[N-1])+li[0]
for i in range(N-1):#i番目の家を出発地にした時の最小距離を順に求めていく
  maxd=max(maxd, li[i+1]-li[i]) 
print(K-maxd)
Problem p02725 (python)

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

result = A[0] - A[N - 1] + K
for i in range(N - 1):
    result = max(result, A[i + 1] - A[i])
print(K - result)

Buggy submission (verdict: Runtime Error):
import numpy as np
K,N = map(int,input().split())
li = np.array(list(map(int,input().split())))
maxd=(K-li[N-1])+li[0]
for i in range(N-1):#i番目の家を出発地にした時の最小距離を順に求めていく
  maxd=max(maxd, li[i+1]-li[i]) 
print(K-maxd)
Problem p02550 (python)

Fixed submission:
#import sys
#print(sys.maxsize)
N,X,M=map(int,input().split())
#table=list(range(M))
#for i in range(M):
 #   table[i]=((table[i]%M)**2)%M
#print(table[471])
start=X%M
rset=set()
rireki=list()
rset.add(start)
rireki.append(start)
ss=0
for j in range(1,M+1):
    start=(start**2)%M
    if start in rset:
        ss=rireki.index(start)
        break
    else:
        rireki.append(start)
        rset.add(start)
nn=len(rireki)
rep=(N-ss)//(nn-ss)
nokori=N-ss-rep*(nn-ss)
loop=rireki[ss:]
#print(nn)
#print(rep)
#print(sum(loop))
#print(ss)
#print(nokori+rep*(nn-ss)+ss)
if 0 in rireki:
    goukei=sum(rireki)
else:
    goukei=rep*sum(loop)+sum(rireki[:ss])+sum(loop[:nokori])
print(goukei)

Buggy submission (verdict: Runtime Error):
#import sys
#print(sys.maxsize)
N,X,M=map(int,input().split())
table=list(range(M))
for i in range(M):
    table[i]=((table[i]%M)**2)%M
print(table[471])
start=X%M
rireki=list()
rireki.append(start)
ss=0
for j in range(1,N):
    if table[start] in rireki:
        ss=rireki.index(table[start])
        break
    else:
        rireki.append(table[start])
        start=table[start]
nn=len(rireki)
rep=(N-ss)//(nn-ss)
nokori=N-ss-rep*(nn-ss)
loop=rireki[ss:]
#print(nn)
#print(rep)
#print(sum(loop))
#print(ss)
#print(nokori+rep*(nn-ss)+ss)
if 0 in rireki:
    goukei=sum(rireki)
else:
    goukei=rep*sum(loop)+sum(rireki[:ss])+sum(loop[:nokori])
print(goukei)
Problem p02580 (python)

Fixed submission:

def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)
max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  P_X[k[0]] == Max_X and P_Y[k [1]] == Max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)

Buggy submission (verdict: Runtime Error):
def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
m_count=0
for k in P:
    if  P_X[k[0]] == Max_X and P_Y[k [1]] == Max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)

Buggy submission (verdict: Runtime Error):
import itertools
def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
#max_X=my_index(P_X,Max_X)
#max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  P_X[k[0]] == Max_X and P_Y[k [1]] == Max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)

Buggy submission (verdict: Runtime Error):
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

import itertools
def my_index(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

H,W,M=map(int,input().split())
P=list()
P_X=[0]*(H+1)
P_Y=[0]*(W+1)
for m  in range(M):
    P.append(list(map(int,input().split())))
    P_X[P[m][0]]+=1
    P_Y[P[m][1]]+=1
Max_X=max(P_X)
Max_Y=max(P_Y)
max_X=my_index(P_X,Max_X)
max_Y=my_index(P_Y,Max_Y)
m_count=0
for k in P:
    if  k[0] in max_X and k [1] in max_Y:
        m_count += 1
if m_count==len(max_X)*len(max_Y):
    answer=Max_X+Max_Y-1
else:
     answer=Max_X+Max_Y
    
print(answer)
Problem p02596 (python)

Fixed submission:
n=int(input())
if n%2==0 or n%5==0:
    print(-1)
else:
    count=1
    flag=0
    num=7
    mod=7%n
    while flag==0:
        if mod==0:
            flag=1
        else:
            mod=(mod*10+7)%n
            count=count+1
    print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==0 or n%5==0:
    print(-1)
else:
    count=1
    flag=0
    num=7
    while flag==0:
        if num%n==0:
            flag=1
        else:
            num=num*10+7
            count=count+1
print(count)
Problem p02570 (python)

Fixed submission:
D,T,S = map(int,input().split())
if (D/S <= T) :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

res = len(T)
for i in range(len(S)) :
    for j in range(i,len(S)) :
        if (S[i:j] in T) and (i>=T.index(S[i:j])) :
            diff = len(T) - len(S[i:j])
        if res>=diff :
            res = diff

print(res)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

min = 100000
for i in range(len(S)) :
    for j in range(len(S),i-1,-1) :
        if (S[i:j] in T) :
            if (min > len(T) - len(S[i:j])) and (i >= T.index(S[i:j]) and j<=len(T)-T.index(S[i:j]) ) :
                min = len(T) - len(S[i:j])

print(min)
Problem p02550 (python)

Fixed submission:
n, x, m = map(int, input().split())
count=x
now=x
flag=-1
sled=[now]
for i in range(1,n):
     now=(now*now)%m
     if now==0:
         flag=0
         break
     if now in sled:
         start=sled.index(now)
         nokori=n-i
         flag=2
         break
     
     else:
         sled.append(now)
     count+=now
     #print(i,now,count)

if flag==2:
    #print(count)
    sled=sled[start:]
    roopnum=int(nokori/len(sled))
    amari=nokori%len(sled)
    
    one_roop=sum(sled)
    count+=one_roop*roopnum
    #print(count)
    for i in range(amari):
        count+=sled[i]
print(count)

Buggy submission (verdict: Runtime Error):
n, x, m = map(int, input().split())
count=x
now=x
flag=-1
sled=[now]
for i in range(1,n):
     now=(now*now)%m
     if now==0:
         flag=0
         break
     if now==1:
         flag==1
         nokori=n-i
         break
     if now in sled:
         start=sled.index(now)
         nokori=n-i
         flag=2
         break
     
     else:
         sled.append(now)
     count+=now
     #print(i,now,count)
sled=sled[start:]
if flag==1:
    count+=nokori
if flag==2:
    #print(count)
    roopnum=int(nokori/len(sled))
    amari=nokori%len(sled)
    
    one_roop=sum(sled)
    count+=one_roop*roopnum
    #print(count)
    for i in range(amari):
        count+=sled[i]
print(count)
Problem p02623 (python)

Fixed submission:
def main3():
    N, M, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    Bsum = sum(B)
    ans = Asum = 0
    idx_b = len(B) - 1

    for i in range(N + 1):
        if i == 0:
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

            else:
                while Asum + Bsum > K:
                    if idx_b >= 0:
                        Bsum -= B[idx_b]
                        idx_b -= 1
                    else:
                        break
                    
                if Asum + Bsum <= K:
                    ans = max(ans, i + idx_b + 1)

        else:
            Asum += A[i - 1]

            while Asum + Bsum > K:
                if idx_b >= 0:
                    Bsum -= B[idx_b]
                    idx_b -= 1
                else:
                    break
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

    print(ans)

if __name__ == "__main__":
    main3()

Buggy submission (verdict: Runtime Error):
def main():
    N, M, K = map(int, input().split())
    A = deque([int(a) for a in input().split()])
    B = deque([int(b) for b in input().split()])
    Bsum = sum(B)
    ans = Asum = 0
    idx_b = len(B) - 1

    A.appendleft(0)

    for i in range(len(A)):
        Asum += A[i]

        for j in range(idx_b + 1):
            if Asum + Bsum > K:
                if idx_b >= 0:
                    Bsum -= B[idx_b]
                    idx_b -= 1
                else:
                    break
            else:
                break

        if Asum + Bsum <= K:
            ans = max(ans, i + (idx_b + 1))

    print(ans)
 
if __name__ == "__main__":
    main()