ZhenlongDai/ACPR huggingface dataset:
Problem: p03489
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
l = list(map(int, input().split()))
unique_l = list(set(l))
l.sort()
l.append(0)
ans = 0
j = 0
for i in unique_l:
    cnt = 0
    while l[j] == i and j < N:
        cnt += 1
        j += 1
    if cnt == i:
        pass
    elif cnt > i:
        ans += cnt - 1
    elif cnt < i:
        ans += cnt
print(ans)

Failing test case input:
5
1 3 1 4 0

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
l = list(map(int, input().split()))
unique_l = list(set(l))
unique_l.sort()
l.sort()
l.append(0)
ans = 0
j = 0
cnt =[]
for i in unique_l:
    temp = 0
    while l[j] == i and j < N:
        temp += 1
        j += 1
    cnt.append(temp)
for i, j in zip(unique_l, cnt):
    if i == j:
        pass
    elif j > i:
        ans += j - i
    elif j < i:
        ans += j
print(ans)

Problem: p03489
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

C = collections.Counter(A)
ans = 0
for v, c in C.items():
    ans += min(abs(c-v), c)
print(ans)


Failing test case input:
6
0 2 2 3 3 1

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

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

C = collections.Counter(A)
ans = 0
for v, c in C.items():
    if v > c:
        ans += c
    else:
        ans += c-v
print(ans)

Problem: p03489
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input().strip())
a=list(map(int, input().split()))
nlis={}

for i in range(N):
    if (a[i] in nlis)==False:
        nlis[a[i]]=1
    else:
        nlis[a[i]]+=1
ans=0
for i in nlis:
    if nlis[i]<i:
        ans+=i
    else:
        ans+=min(abs(nlis[i]-i),nlis[i])
print(ans)

Failing test case input:
5
1 3 1 4 0

Expected output:
4


Actual output:
9


Fixed submission (verdict: Accepted):
N=int(input().strip())
a=list(map(int, input().split()))
nlis={}

for i in range(N):
    if (a[i] in nlis)==False:
        nlis[a[i]]=1
    else:
        nlis[a[i]]+=1
ans=0
for i in nlis:
    if nlis[i]<i:
        ans+=nlis[i]
    else:
        ans+=abs(nlis[i]-i)
    
print(ans)

Problem: p03489
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())
a = list(map(int, input().split()))
a = collections.Counter(a)
a = a.most_common()
ans = 0
for i in range(len(a)):
  if a[i][0] >= a[i][1]:
    ans += a[i][0] - a[i][1]
  else:
    ans += a[i][1]
    
print(ans)

Failing test case input:
1
0001000001

Expected output:
1


Actual output:
1000000


Fixed submission (verdict: Accepted):
import collections
N = int(input())
a = list(map(int, input().split()))
a = collections.Counter(a)
a = a.most_common()
ans = 0
for i in range(len(a)):
  if a[i][0] <= a[i][1]:
    ans += a[i][1] - a[i][0]
  else:
    ans += a[i][1]
    
print(ans)
Problem: p03489
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

N = int(input())
c = Counter(map(int, input().split()))
ans = 0
for k, v in c.items():
    if k < v:
        ans = v - k
    elif k > v:
        ans += v
print(ans)


Failing test case input:
8
2 13 0 2 4 2 2 1

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

N = int(input())
c = Counter(map(int, input().split()))
ans = 0
for k, v in c.items():
    if k < v:
        ans += v - k
    elif k > v:
        ans += v
print(ans)

Problem: p03489
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter
n = input()
xs = [int(c) for c in input().split()]
c = Counter(xs)
ans = 0
for x, cnt in c.items():
  ans += cnt if x < cnt else (x - cnt)
print(ans)

Failing test case input:
1
0111001111

Expected output:
1


Actual output:
111001110


Fixed submission (verdict: Accepted):
from collections import Counter
n = input()
xs = [int(c) for c in input().split()]
c = Counter(xs)
ans = 0
for x, cnt in c.items():
  ans += cnt if cnt < x else (cnt - x)
print(ans)

Problem: p03489
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
arr = list(map(int,input().split()))
dicta={}
ans=0
for i in arr:
    dicta[i] = dicta.get(i,0)+1
for key,value in dicta.items():
    if key == value:
        continue
    else:
        diff = abs(key-value)
        ans+=diff

print(ans)

Failing test case input:
1
1100101100

Expected output:
1


Actual output:
1100101099


Fixed submission (verdict: Accepted):
n = int(input())
arr = list(map(int,input().split()))
dicta={}
ans=0
for i in arr:
    dicta[i] = dicta.get(i,0)+1

for key,value in dicta.items():
    if key == value:
        continue
    elif key > value:
        ans+=value
    else:
        diff = abs(value-key)
        ans += diff

print(ans)
Problem: p00604
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
print(sum((n-i)*x for i,x in enumerate(sorted(list(map(int,input().split()))))))

Failing test case input:
3
19 22 0
7
93 26 38 43 121 80 3

Expected output:
60
1086


Actual output:
60


Fixed submission (verdict: Accepted):
while 1:
    try:n=int(input())
    except:break
    print(sum((n-i)*x for i,x in enumerate(sorted(list(map(int,input().split()))))))
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())

ans = -1
num7 = 7;

for i in range(1000):
    if (num7 % K) == 0:
        ans = i+1
        break
    else:
        num7 = num7*10+7
        i+=1

print(ans)

Failing test case input:
42769

Expected output:
2250


Actual output:
-1


Fixed submission (verdict: Accepted):
K = int(input())

ans = -1
num7 = 7

for i in range(1000000):
    if (num7 % K) == 0:
        ans = i+1
        break
    else:
        num7 = (num7*10+7)%K
        i+=1

print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
time = 1
K = int(input())
sev = 7
while True:
    if K % 2 == 0:
        print(-1)
        break
    elif K % 7 == 0:
      print(1)
      break
    elif sev % K == 0:
        print(time)
        break
    else:
        sev = sev % K * 10 + 7
        time += 1

Failing test case input:
1208879

Expected output:
74010


Actual output:
1


Fixed submission (verdict: Accepted):
time = 1
K = int(input())
sev = 7
while True:
    if K % 2 == 0 or time > K:
        print(-1)
        break
    elif sev % K == 0:
        print(time)
        break
    else:
        sev = sev % K * 10 + 7
        time += 1

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

K = int(input())
count = 1
a = 7 % K

for i in range(K):
    a = (10 * a + 7) % K
    if a == 0:
        break
    else:
        count += 1
print (count)

Failing test case input:
187013

Expected output:
21758


Actual output:
21757


Fixed submission (verdict: Accepted):

K = int(input())
count = 1
a = 7 % K

for i in range(K):
    if a == 0:
        print (count)
        exit ()
    else:
        a = (10 * a + 7) % K
        count += 1

print (-1)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
k=int(input())
if(k%2)==0:
    print("-1")
else:
    flag=0
    for x in range(1,1000001):
        if pow(10,x,k*9)==1:
            print(x)
            flag=1
            break
    if flag==0:
        print(-1)


Failing test case input:
513023

Expected output:
18081


Actual output:
36162


Fixed submission (verdict: Accepted):
import math
k=int(input())
if(k%2)==0:
    print("-1")
else:
    flag=0
    for x in range(1,1000001):
        if (7%(9*k)*(pow(10,x,k*9)-1)%(9*k))==0:
            print(x)
            flag=1
            break
    if flag==0:
        print(-1)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
k=int(input())
n=7
if k%2==0:
    print(-1)
for i in range(1,k+1):
    if n%k==0:
        print(i)
        sys.exit()
    else:
        n=(10*(n%k)+7)%k
print(-1)

Failing test case input:
1803846

Expected output:
-1


Actual output:
-1
-1


Fixed submission (verdict: Accepted):
import sys
k=int(input())
n=7
if k%2==0:
    print(-1)
    sys.exit()
for i in range(1,k+1):
    if n%k==0:
        print(i)
        sys.exit()
    else:
        n=(10*(n%k)+7)%k
print(-1)
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def solve(n):
    if n % 10 not in [1,3,7]:
        return -1
    r = 0
    for i in range(int(1.2e6)):
        r = (r * 10 + 7) % n
        if r == 0:
            return i + 1

print(solve(int(input())))


Failing test case input:
549

Expected output:
180


Actual output:
-1


Fixed submission (verdict: Accepted):
def solve(n):
    r = 0
    s = set()
    i = 0
    while r not in s:
        s.add(r)
        r = (r * 10 + 7) % n
        i += 1
    return i if r == 0 else -1

print(solve(int(input())))

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
if(k&2==0):
  print("-1")
else:
  i = 1
  while True:
    m = 7
    if(m%k==0):
      ans = i
      print(ans)
      break
    if(i>1000000):
      print("-1")
      break
    m = m*10 + 7
    i += 1

  
  


Failing test case input:
439373

Expected output:
9802


Actual output:
-1


Fixed submission (verdict: Accepted):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(m==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K=int(input())

count=0
result = -1
for i in range(K):
    count =(10*count+7)%K
    if count==0:
        result = i+1

print(result)

Failing test case input:
5041

Expected output:
2485


Actual output:
4970


Fixed submission (verdict: Accepted):
K=int(input())
def x():
    count=0
    for i in range(K):
        count =(10*count+7)%K
        if count==0:
            return i+1
    return -1    
print(x())

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
if k%2==0:
    print(-1)
else:
    s='7'
    flag=0
    for _ in range(8):
        if int(s)%k==0:
            flag=1
            print(len(s))
            break
        s=s+'7'
    if flag==0:
        print(k-1)

Failing test case input:
126901

Expected output:
6678


Actual output:
126900


Fixed submission (verdict: Accepted):
k=input()
if int(k)%2==0:
    print(-1)
else:
    s=7
    count=1
    flag=0
    while 1:
        if s%int(k)==0:
            print(count)
            break
        if count>int(k):
            print(-1)
            break
        s=(s%int(k))*10+7
        count+=1

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
K=int(input())
a=7
for i in range(1,K+1):
    if a%7==0:
        print(i)
        exit()
    a=a*10+7
print(-1)

Failing test case input:
187013

Expected output:
21758


Actual output:
1


Fixed submission (verdict: Accepted):
K=int(input())
a=7
for i in range(1,K+1):
    if a%K==0:
        print(i)
        exit()
    a=(a*10+7)%K
print(-1)
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
k = int(input())
add = 7
if k % 7 == 0:
    k 
    add = 1
elif k == 1:
    add = 1
ans = 0
now = k % add
while True:
    if ans > k:
        print(-1)
        break
    elif now == 0:
        print(ans+1)
        break
    else:
        now = (now*10 + add) % k
        ans += 1

Failing test case input:
139909

Expected output:
286


Actual output:
1


Fixed submission (verdict: Accepted):
k = int(input())
ans = 0
now = 7
if k == 1 or k == 7:
    now = 0
while True:
    if ans > k:
        print(-1)
        break
    elif now == 0:
        print(ans+1)
        break
    else:
        now = (now*10 + 7) % k
        ans += 1

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
a=0
for i in range(k):
  a=(a*10+7)%k
  if a==0:
    print(i+1)
    exit()

Failing test case input:
1803846

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
k=int(input())
a=0
for i in range(k):
  a=(a*10+7)%k
  if a==0:
    print(i+1)
    exit()
    
print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

K = int(input())
ans=-1
sevens=[7,]
for i in range(2, 7):
    sevens.append((10**(i-1))*7+sevens[i-2])
for n in sevens:
    if(n%K==0):
        ans=sevens.index(n)+1
print(ans)



Failing test case input:
908587

Expected output:
21945


Actual output:
-1


Fixed submission (verdict: Accepted):

K = int(input())
ans=-1
sevens=[7,]
for i in range(1, K+1):
    sevens.append((10*sevens[i-1]+7)%K)
    if sevens[i-1]%K==0:
        ans=i
        print(ans)
        exit()
print(ans)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
k = int(input())
x = 7 % k
cnt = 0
for i in range(2 * 10 ** 6):
    if x == 0:
        break
    x = (x * 10 + 7) % k
    cnt += 1
print(cnt + 1)



Failing test case input:
1803846

Expected output:
-1


Actual output:
2000001


Fixed submission (verdict: Accepted):
k = int(input())
x = 7 % k
cnt = 0
for i in range(2 * 10 ** 6):
    if x == 0:
        break
    x = (x * 10 + 7) % k
    cnt += 1
if cnt == 2000000:
    print(-1)
else:
    print(cnt + 1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
lis = []
c = 0
a = 0
while(True):
    a = (a*10 + 7) & k
    if a == 0:
        print(c+1)
        quit()
    if c > k:
        print(-1)
        quit()
    c += 1

Failing test case input:
42117

Expected output:
276


Actual output:
-1


Fixed submission (verdict: Accepted):
k = int(input())
lis = []
c = 1
a = 0
while(True):
    a = (a*10 + 7) % k
    if a == 0:
        print(c)
        quit()
    if c > k:
        print(-1)
        quit()
    c += 1
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2 == 0):
        print(-1)
        return
    
    for i in range(100000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main() 


Failing test case input:
1558339

Expected output:
177360


Actual output:
-1


Fixed submission (verdict: Accepted):
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2 == 0):
        print(-1)
        return
    
    for i in range(1000000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main()

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
x = 7%k
i = 1
for i in range(0,k+1):
    if x==0:
        break    
    x = (x*10+7)%k
    i += 1
    
if x == 0:
    print(i)
else:
    print('-1')

Failing test case input:
191049

Expected output:
15540


Actual output:
15539


Fixed submission (verdict: Accepted):
k = int(input())
x = 7%k
i = 1
for i in range(1,k+1):
    if x==0:
        break    
    x = (x*10+7)%k
    i += 1
    
if x == 0:
    print(i)
else:
    print('-1')

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

X = int(input())
L = len(str(X))



Y = 0

for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(100000):
    Y = Y%X
    

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    print(ans)

Failing test case input:
342119

Expected output:
169248


Actual output:
-1


Fixed submission (verdict: Accepted):

X = int(input())
L = len(str(X))



Y = 0

for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(1000000):
    Y = Y%X
    

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
K = int(input())

power = 1
SUM = 0

for i in range(1, 10 ** 6):
    SUM += power
    if SUM % K == 0:
        print(i)
        sys.exit()
    power *= 10
    power %= K

print(-1)

Failing test case input:
52171

Expected output:
1792


Actual output:
5376


Fixed submission (verdict: Accepted):
import sys
K = int(input())

power = 7
SUM = 0

for i in range(1, 10 ** 6):
    SUM += power
    if SUM % K == 0:
        print(i)
        sys.exit()
    power *= 10
    power %= K

print(-1)
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  t=7
  i=1
  for i in range(1,40000):
    if t%k==0:
      print(i)
      break
    else:
      t=t*10+7
      i=i+1
  else:
    print(k-1)

Failing test case input:
778149

Expected output:
51876


Actual output:
778148


Fixed submission (verdict: Accepted):
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  t=7
  ans=1
  while True:
    if t%k==0:
      print(ans)
      break
    t=(t*10+7)%k
    ans=ans+1

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k = int(input())
d = 7 % k
for i in range(1, k+10):
    if d == 0:
        ans = i
        break
    d = (10*d + 7) % k
print(ans)

Failing test case input:
1803846

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

k = int(input())
ans = -1
d = 7 % k
for i in range(1, k+10):
    if d == 0:
        ans = i
        break
    d = (10*d + 7) % k
print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def solve(n):
    if n % 10 not in [1,3,7]:
        return -1
    r = 0
    for i in range(int(1.2e6)):
        r = (r * 10 + 7) % n
        if r == 0:
            return i + 1
    return -1

print(solve(int(input())))


Failing test case input:
191049

Expected output:
15540


Actual output:
-1


Fixed submission (verdict: Accepted):
def solve(n):
    r = 0
    s = set()
    i = 0
    while r not in s:
        s.add(r)
        r = (r * 10 + 7) % n
        i += 1
    return i if r == 0 else -1

print(solve(int(input())))

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


import sys

def main():
    k = int(input())
    mod=999983
    if k % 2==0:
        print(-1)
        exit()
    sevens=7
    for i in range(1,10**6+1):
        if sevens%k==0:
            print(i)
            exit()
        else:
            sevens=(sevens*10+7)%mod
    print(-1)

if __name__ == "__main__":
    main()

Failing test case input:
173153

Expected output:
86154


Actual output:
369002


Fixed submission (verdict: Accepted):


import sys

def main():
    k = int(input())
    sevens=0
    for i in range(1,k+1):
        sevens=(sevens*10+7)%k
        if sevens==0:
            print(i)
            exit()
    print(-1)

if __name__ == "__main__":
    main()
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=input()
if int(k)%2==0:
    print(-1)
else:
    s='7'
    flag=0
    for _ in range(12):
        if int(s)%int(k)==0:
            flag=1
            print(len(s))
            break
        s=s+'7'
    if flag==0 and k[-1]=='3':
        print(int(k)-1)
    else:
        print(-1)

Failing test case input:
20987

Expected output:
5070


Actual output:
-1


Fixed submission (verdict: Accepted):
k=input()
if int(k)%2==0:
    print(-1)
else:
    s=7
    count=1
    flag=0
    while 1:
        if s%int(k)==0:
            print(count)
            break
        if count>int(k):
            print(-1)
            break
        s=(s%int(k))*10+7
        count+=1

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())
cnt = 0
a = 7
if a%K == 0:print(1)
else:
    a = 7%K
    cnt += a
    for i in range(1, K+1):
        a = (a*10) % K
        cnt += a
        if cnt% K == 0:
            print(i+1)
            break
        elif a == 0:
            print(-1)
            break


Failing test case input:
1803846

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
K = int(input())
ans = -1
cnt = 0
a = 7
jdg = False
if a%K == 0:ans = 1
else:
    a = 7%K
    cnt += a
    for i in range(1, K+3):
        a = (a*10) % K
        cnt += a
        if cnt % K == 0:
            ans = i + 1
            break
        elif a == 0:
            break
print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
cnt = 1
mod = 7
k = int(input())

for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 * 7) % k

if mod % k == 0:
    print(cnt)
else:
    print(-1)


Failing test case input:
4869

Expected output:
540


Actual output:
-1


Fixed submission (verdict: Accepted):
cnt = 1
mod = 7
k = int(input())
for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 + 7) % k

if mod % k == 0:
    print(cnt)
else:
    print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def resolve():
    
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    memo[i] += 1
    res = 1
    while is_not_found and memo[i] == 1:
        i = (i * 10 + 7) % K
        memo[i] += 1
        res += 1
        if i == 0:
            is_not_found = False

    print(res)


if __name__ == "__main__":
    resolve()


Failing test case input:
1803846

Expected output:
-1


Actual output:
901


Fixed submission (verdict: Accepted):
def resolve():
    
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    res = 1
    if i == 0:
        is_not_found = False

    while is_not_found and memo[i] == 0:
        memo[i] += 1
        if i == 0:
            is_not_found = False
        else:
            res += 1
            i = (i * 10 + 7) % K

    print(res) if is_not_found == False else print(-1)


if __name__ == "__main__":
    resolve()
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
K = int(input())

mod_ini = 7%K
mod = 0
cnt = 0

while True:
    if K%2 != 0:
        print(-1)
        break
    
    cnt += 1
    mod = (mod*10 + 7)%K
    
    
    if mod == 0:
        print(cnt)
        break
    elif mod == mod_ini and cnt != 1:
        print(-1)
        break

Failing test case input:
204187

Expected output:
96080


Actual output:
-1


Fixed submission (verdict: Accepted):
K = input()
K_1 = int(K[-1])
K = int(K) 

mod_ini = 7%K
mod = 0
cnt = 0

while True:
    if K%2 == 0 or K_1 == 5:
        print(-1)
        break
    
    cnt += 1
    mod = (mod*10 + 7)%K
    
    
    if mod == 0:
        print(cnt)
        break
    elif mod == mod_ini and cnt != 1:
        print(-1)
        break

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K=int(input())
m=7
count=1
for i in range(K):
  if m%K==0:
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
    
print(count)

Failing test case input:
1803846

Expected output:
-1


Actual output:
1803847


Fixed submission (verdict: Accepted):
K=int(input())
m=7
count=1
flag=0
for i in range(K):
  if m%K==0:
    flag=1
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
if not flag:
  print("-1")
else:
  print(count)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
if n % 2 == 0 or n % 5 == 0:
  print(-1)
p = 7
ans = 1
for i in range(1000000):
  q = p % n
  if q == 0:
    break
  else:
    p = 10 * q + 7
    ans += 1
print(ans)

Failing test case input:
1803846

Expected output:
-1


Actual output:
-1
1000001


Fixed submission (verdict: Accepted):
import sys
n = int(input())
if n % 2 == 0 or n % 5 == 0:
  print(-1)
  sys.exit()
p = 7
ans = 1
for i in range(1000000):
  q = p % n
  if q == 0:
    break
  else:
    p = 10 * q + 7
    ans += 1
if q != 0:
  print(-1)
else:
  print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<=K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count==K:
    count=-1

print(count)

Failing test case input:
1803846

Expected output:
-1


Actual output:
1803847


Fixed submission (verdict: Accepted):
K = int(input())

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<=K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count>K:
    count=-1

print(count)
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1

Failing test case input:
13423

Expected output:
2160


Actual output:

Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1
    
    else:
        print('-1')

main()

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

for i in range(1, 11):
    if int('7'*i) % k == 0:
        print(i)
        break
else:
    print(k - 1)

Failing test case input:
5041

Expected output:
2485


Actual output:
5040


Fixed submission (verdict: Accepted):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
r = 0
for i in range(1, k+1):
    r = (r * 10 + 7) % k
    if r == 0:
        print(i)
        break
else:
    print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())
seven = 0
count = 0

if(K % 2 == 0 or K % 5 == 0):
    print(-1)
else:
    while(seven % K != 0):
        seven = (seven * 10 + 7) % K
        count += 1

        
        
        

if(count >= 1): 
    print(count)

Failing test case input:
107767

Expected output:
96


Actual output:

Fixed submission (verdict: Accepted):
K = int(input())
seven = 7
count = 0

if(K % 2 == 0 or K % 5 == 0):
    print(-1)
if(K == 7 or K == 1):
    print(1)
else:
    for i in range(1,10**6):
        seven = (seven * 10 + 7) % K
        if(seven % K == 0):
            print(i+1)
            break
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

K = ri()

if K % 7 == 0:
	print(1)
	exit()
if K % 2 == 0:
	print(-1)
	exit()
r = 7
for i in range(10000000):
	r = (r*10+7) % K
	if r == 0:
		print(i+2)
		exit()
print(-1)



Failing test case input:
139909

Expected output:
286


Actual output:
1


Fixed submission (verdict: Accepted):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

K = ri()

if K % 2 == 0:
	print(-1)
	exit()
r = 0
for i in range(10000000):
	r = (r*10+7) % K
	if r == 0:
		print(i+1)
		exit()
print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())
nana = 7
for i in range(1000000):
    if nana % K == 0:
        print(i + 1)
        exit()
    nana *= 10
    nana += 7
    nana %= K


Failing test case input:
1803846

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
K = int(input())
nana = 7
for i in range(1000000+1):
    if nana % K == 0:
        print(i + 1)
        exit()
    nana *= 10
    nana += 7
    nana %= K
print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    K = int(input())

    if K % 2 == 0:
        v = 7
        for i in range(1, 1000000):
            if v % K == 0:
                print(i)
                return

            v = (v * 10 + 7) % K
        
    print(-1)

main()


Failing test case input:
20987

Expected output:
5070


Actual output:
-1


Fixed submission (verdict: Accepted):
def main():
    K = int(input())

    v = 7
    for i in range(1, 1000000):
        if v % K == 0:
            print(i)
            return

        v = (v * 10 + 7) % K
        
    print(-1)

main()
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())

if k % 2 == 0:
  print(-1)
  exit()

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a = [i*10 + 7]
    ans += 1
    print(a)

print(ans)


Failing test case input:
6957

Expected output:
1737


Actual output:
[77]
1


Fixed submission (verdict: Accepted):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
  exit()

a = 7
ans = 0
for i in range(10**7):
  a = a % k
  if a % k == 0:
    ans = i + 1
    break
  else:
    a = a*10 + 7
    ans = i + 1


print(ans)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import log10

K = int(input())

for i in range(1, K):
    n = log10(9*i*K/7 + 1)
    if n.is_integer():
        print(int(n))
        break
else:
    print(-1)

Failing test case input:
204187

Expected output:
96080


Actual output:
-1


Fixed submission (verdict: Accepted):
K = int(input())

repsept = 7
for i in range(1, K+1):
    if repsept % K == 0:
        print(i)
        break
    repsept = (repsept*10 + 7) % K
else:
    print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



K=int(input())

modsevens=[7]

if K==7 or 1:
    print(1)
    exit()


for i in range (1,K+2):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Failing test case input:
107767

Expected output:
96


Actual output:
1


Fixed submission (verdict: Accepted):



K=int(input())

modsevens=[7]

if K==7 or K==1:
    print(1)
    exit()
else:
    pass

for i in range (1,K+2):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= 7
    cnt += 1
print(cnt)


Failing test case input:
1558339

Expected output:
177360


Actual output:
2


Fixed submission (verdict: Accepted):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7 % k
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= k
    cnt += 1
print(cnt)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math as mt
n=int(input())
x=1%n
for i in range(n):
  ten=10%n
  x=((x%n)*ten)%n
  if x==1:
    print(i+1)
    break
else:
  if n==1:
    print(1)
  else:
    print(-1)

Failing test case input:
11289

Expected output:
1365


Actual output:
455


Fixed submission (verdict: Accepted):
import math as mt
n=int(input())
x=7%n
ten=1
for i in range(n):
  if x%n==0:
    print(i+1)
    break
  ten=((ten%n)*(10%n))%n
  x+=((ten%n)*(7%n))%n
else:
  if n==1:
    print(1)
  else:
    print(-1)
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())
N = 0

for i in range(30):
    N += 7*(10**i)
    if N % K == 0:
        print(i+1)
        break






Failing test case input:
20987

Expected output:
5070


Actual output:

Fixed submission (verdict: Accepted):
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
if k % 2 * k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0: k 
k *= 9
i = 10 % k
cnt = 1
while i != 1:
    i = i * 10 % k
    cnt += 1
print(cnt)


Failing test case input:
513023

Expected output:
18081


Actual output:
36162


Fixed submission (verdict: Accepted):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7 % k
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= k
    cnt += 1
print(cnt)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  if k == 7 or k == 1:
    print(1)
  else:
    if k % 7 == 0:
      k 
    state = 10
    state %= k
    cnt = 1
    while True:
      if state == 1:
        print(cnt)
        break
      state *= 10
      state %= k
      cnt += 1


Failing test case input:
1929

Expected output:
321


Actual output:
107


Fixed submission (verdict: Accepted):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  state = 7
  state %= k
  cnt = 1
  while True:
    if state == 0:
      print(cnt)
      break
    state = state * 10 + 7
    state %= k
    cnt += 1

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())


if K%2==0:
    mod = -1
else:
    flag=0
    mod = 7
    count = 1
    while flag==0:
        if mod==0:
            flag = 1
        else:
            count += 1
            mod = (mod*10+7) % K

print(mod)

Failing test case input:
21831

Expected output:
3438


Actual output:
0


Fixed submission (verdict: Accepted):
K = int(input())


if K%2==0 or K%5==0:
    count = -1
else:
    flag=0
    mod = 7
    count = 1
    while mod%K!=0:
        count += 1
        mod = (mod*10+7) % K

print(count)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
mod7 = 7%k
mod10= 10%k

mod = mod7
mod10times = mod7

if mod%k==0:
    print(1)

for i in range(2,1000000):
    mod10times = mod10times*mod10%k
    mod = mod10times+mod%k
    
    if  mod%k==0:
        print(i)
        break
        
print(-1)

Failing test case input:
4231

Expected output:
2115


Actual output:
2115
-1


Fixed submission (verdict: Accepted):
k=int(input())
mod7 = 7%k
mod10= 10%k

mod = mod7
mod10times = mod7

if mod%k==0:
    print(1)
else:

    for i in range(2,2000000):
        mod10times = mod10times*mod10%k
        mod = mod10times+mod%k

        if  mod%k==0:
            break

    if i==1999999:
        print(-1)
    else:
        print(i)
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())

if k % 2 == 0:
  print(-1)
  exit()

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a = [i*10 + 7]
    ans += 1


print(ans)


Failing test case input:
999983

Expected output:
999982

Actual output:
1


Fixed submission (verdict: Accepted):
k = int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
  exit()

a = 7
ans = 0
for i in range(10**7):
  a = a % k
  if a % k == 0:
    ans = i + 1
    break
  else:
    a = a*10 + 7
    ans = i + 1


print(ans)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(6):
    x += 7*10**i
    if x % k == 0:
        print(i+1)
        exit()
print(-1)

Failing test case input:
863

Expected output:
862


Actual output:
-1


Fixed submission (verdict: Accepted):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 70 + 63
else:
  print(-1)

Failing test case input:
6451

Expected output:
2150


Actual output:
3225


Fixed submission (verdict: Accepted):
k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
else:
  print(-1)
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
k = int(input())
if k % 2 == 0:
    print(-1)
if k % 7 == 0:
    k 
x = 1
s = 0
for i in range(1, 1000005):
    s += x
    s %= k
    if s == 0:
        print(i)
        exit()
    x *= 10
    x %= k

Failing test case input:
5163823

Expected output:
73450


Actual output:
220350


Fixed submission (verdict: Accepted):
k = int(input())
x = 1
s = 0
for i in range(1, 2000005):
    s += x
    s %= k
    if s == 0 or (7 * s) % k == 0:
        print(i)
        exit()
    x *= 10
    x %= k
print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    k = int(input())
    x = 0
    flag = True
    
    
    
    
    
    mod = 1
    for i in range(1, 10**6+1):
        mod *= 10
        if k % 7 == 0:
            mod = mod % (7*k/9)
            if mod == 1:
                print(i)
                flag = False
                break
        else:
            mod = mod % (9*k)
            if mod == 1:
                print(i)
                flag = False
                break
    if flag:
        print('-1')
        
if __name__ == '__main__':
    main()

Failing test case input:
1208879

Expected output:
74010


Actual output:
-1


Fixed submission (verdict: Accepted):
def main():
    k = int(input())
    x = 0
    flag = True
    
    
    
    
    
    
    
    
    mod = 1
    for i in range(1, 10**6+1):
        mod *= 10
        if k % 7 == 0:
            mod = mod % (9*k/7)
            if mod == 1:
                print(i)
                flag = False
                break
        else:
            mod = mod % (9*k)
            if mod == 1:
                print(i)
                flag = False
                break

    if flag:
        print('-1')
        
if __name__ == '__main__':
    main()

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)

Failing test case input:
1676603

Expected output:
67860


Actual output:
67859


Fixed submission (verdict: Accepted):
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(1, limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)
Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())

if 7 % k == 0:
    print(1)
else:
    a = []
    a.append(7 % k)
    for i in range(2, k+1):
        x = (10 * a[i - 2] + 7) % k
        t = 0
        if x == 0:
            print(i)
            break
        else:
            a.append(x)
            t += 1
    if t == k - 1:
        print(-1)


Failing test case input:
1803846

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
k = int(input())

if 7 % k == 0:
    print(1)
else:
    a = []
    a.append(7 % k)
    t = 0
    for i in range(2, k+1):
        x = (10 * a[i - 2] + 7) % k
        if x == 0:
            print(i)
            break
        else:
            a.append(x)
            t += 1
    if t == k - 1:
        print(-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("No")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break


Failing test case input:
1803846

Expected output:
-1


Actual output:
No


Fixed submission (verdict: Accepted):
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("-1")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
n = 0
for i in range(1, k+1):
    n = (n * 10 + 7) % k
    if n == 0:
        print(i)
        break
print('-1')


Failing test case input:
30689

Expected output:
15344


Actual output:
15344
-1


Fixed submission (verdict: Accepted):
k = int(input())
n = 0
for i in range(1, k+1):
    n = (n * 10 + 7) % k
    if n == 0:
        print(i)
        exit()
print('-1')
Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
if K == 7:
  print(1)
  exit()
if K%7 == 0:
  K = K
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
m = 1
for i in range(1,40000):
    m *= 10
    if (m-1)%K == 0:
        print(i)
        exit()
print(K-1)

Failing test case input:
3711

Expected output:
618


Actual output:
206


Fixed submission (verdict: Accepted):
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
m = 7
for i in range(1,10000000):
    if m%K == 0:
        print(i)
        exit()
    m = (m*10+7)%K
print(K-1)

Problem: p02596
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k = int(input())
s = 7

cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1

Failing test case input:
1803846

Expected output:
-1


Actual output:

Fixed submission (verdict: Accepted):
k = int(input())
s = 7
s = s % k
cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

Problem: p02596
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

K=int(input())

if K%2==0 or K%5==0:
    print(-1)
elif K==7:
    print(1)
else:
    if K%7==0:
        K
        
    ANS=1
    NOW=10
    
    while NOW!=1:
        
        if NOW>K:
            NOW=NOW%K
        else:
            ANS+=1
            NOW*=10
    print(ANS)


Failing test case input:
5163823

Expected output:
73450


Actual output:
220350


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

K=int(input())
if K%2==0 or K%5==0:
    print(-1)
else:   

    NOW=0

    for i in range(1,10**6+3):
        NOW=NOW+7*pow(10,i,K)
        NOW%=K

        if NOW==0:
            print(i)
            break
    else:
        print(-1)