Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
word_dict = {}
for _ in range(n):
    word = str(input())
    if word in word_dict:
        word_dict[word] +=1
    else:
        word_dict[word] = 1
max_list = [key for key, value in word_dict.items() if value == max(word_dict.values())]
max_list.sort()
for item in max_list:
    print(item)

Fixed submission:
import collections

n = int(input())
s = [str(input()) for _ in range(n)]
word_dict = collections.Counter(s)
maxVal = max(word_dict.values())
max_list = [key for key, value in word_dict.items() if value == maxVal]
max_list.sort()
for item in max_list:
    print(item)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
for num in p:
    elm = (num * (num + 1) / 2) * (1 / num)
    nums.append(elm)
maxVal = 0
for i in range(n - k + 1):
    if sum(nums[i: i + k]) >= maxVal:
        maxVal = sum(nums[i: i + k])
    else:
        continue
print(maxVal)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
nums = []
elm = 0
for num in p:
    elm += (num * (num + 1) / 2) * (1 / num)
    nums.append(elm)
maxVal = nums[k-1]
for i in range(n - k):
    if nums[i + k] - nums[i] >= maxVal:
        maxVal = nums[i + k] - nums[i]
    else:
        continue
print(maxVal)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
primes = [2]
if x != 2:
    for i in range(3, x, 2):
        prime_flg = True
        for num in primes:
            if i % num == 0:
                prime_flg = False
            else:
                pass
        if prime_flg == True:
            primes.append(i)
target = x
ans = 0
if x != 2:
    while(True):
        prime_flg = True
        for num in primes:
            if target % num == 0:
                prime_flg = False
            else:
                pass
        if prime_flg == True:
            ans = target
            break
        else:
            target += 1
else:
    ans = 2
print(ans)


Fixed submission:
import math
x = int(input())

ceil_num = math.ceil(math.sqrt(x))


def is_prime(n):
    if n <= 1:
        return False
    else:
        pass
    for i in range(2, ceil_num):
        if n % i == 0:
            return False
    else:
        return True

while(is_prime(x)==False):
    x += 1
ans = x
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
ans = a * b / math.gcd(a,b)
print(int(ans))

Fixed submission:
import fractions

a, b = map(int, input().split())
ans = a * b / fractions.gcd(a,b)
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
anslist = []
for i in range(n):
    print(a.index(i+1) + 1, end=' ')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mydict = {}
for i in range(n):
    mydict[str(i+1)] = a[i]
mydict = sorted(mydict.items(), key= lambda x:x[1])
for j in range(n):
    print(mydict[j][0], end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
anslist = []
for i in range(n):
    anslist += [str(a.index(i+1)+1)]
print(" ".join(anslist))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mydict = {}
for i in range(n):
    mydict[str(i+1)] = a[i]
mydict = sorted(mydict.items(), key= lambda x:x[1])
for j in range(n):
    print(mydict[j][0], end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
anslist = []
for i in range(n):
    idx = a.index(i + 1)
    anslist.append(str(idx + 1))
print(" ".join(anslist))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mydict = {}
for i in range(n):
    mydict[str(i+1)] = a[i]
mydict = sorted(mydict.items(), key= lambda x:x[1])
for j in range(n):
    print(mydict[j][0], end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for i in range(n)]
s = sorted(s)
cnt = 0
for i in range(len(s)):
    for j in s[i + 1:]:
        if s[i] == j:
            cnt += 1
        else:
            break
print(cnt)


Fixed submission:
from collections import Counter

total = 0
n = int(input())
word_list = ["".join(sorted(input())) for _ in range(n)]
count_words = dict(Counter(word_list))
for item in count_words:
    ans = 0
    tmp = count_words[item] - 1
    ans = 1/2 * tmp * (tmp + 1)
    total += ans
print(int(total))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for i in range(n)]
s = sorted(s)
cnt = 0
for i in range(len(s)):
    for j in s[i + 1:]:
        if s[i] == j:
            cnt += 1
        else:
            break
print(cnt)


Fixed submission:
from collections import Counter

total = 0
n = int(input())
word_list = ["".join(sorted(input())) for _ in range(n)]
count_words = dict(Counter(word_list))
for item in count_words:
    ans = 0
    tmp = count_words[item] - 1
    ans = 1/2 * tmp * (tmp + 1)
    total += ans
print(int(total))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = ["".join(sorted(input())) for i in range(n)]
cnt = 0
for i in range(len(s)):
    for j in s[i + 1:]:
        if s[i] == j:
            cnt += 1
        else:
            continue
print(cnt)

Fixed submission:
from collections import Counter

total = 0
n = int(input())
word_list = ["".join(sorted(input())) for _ in range(n)]
count_words = dict(Counter(word_list))
for item in count_words:
    ans = 0
    tmp = count_words[item] - 1
    ans = 1/2 * tmp * (tmp + 1)
    total += ans
print(int(total))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
maxnum = max(a)
for i in range(n):
    if a[i] == maxnum:
        tmp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = tmp
    else:
        print(max(a))

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
sorted_a = []
for item in a:
    sorted_a.append(item)
sorted_a.sort(reverse=True)
for num in a:
    if num == sorted_a[0]:
        print(sorted_a[1])
    else:
        print(sorted_a[0])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    tmp = a[i]
    a[i] = 0
    print(max(a))
    a[i] = tmp

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
sorted_a = []
for item in a:
    sorted_a.append(item)
sorted_a.sort(reverse=True)
for num in a:
    if num == sorted_a[0]:
        print(sorted_a[1])
    else:
        print(sorted_a[0])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    if i == n - 1:
        ans = max(a[:i])
    elif i == 0:
        ans = max(a[1:])
    else:
        ans = max(max(a[:i]), max(a[i+1:]))
    print(ans)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
sorted_a = []
for item in a:
    sorted_a.append(item)
sorted_a.sort(reverse=True)
for num in a:
    if num == sorted_a[0]:
        print(sorted_a[1])
    else:
        print(sorted_a[0])
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
i = 0
position = 0
cnt = 0
while position <= x:
    cnt += 1
    position += l[i]
    i += 1
print(cnt)


Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
position = 0
cnt = 1
for i in range(n):
    position += l[i]
    if position <= x:
        cnt += 1
    else:
        break
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = input()
print((n - 2)*180)

Fixed submission:
n = int(input())
ans = ( n - 2 ) * 180
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
gatelist = [0] * n
for i in range(m):
    l,r = map(int, input().split())
    for j in range(l-1,r):
        gatelist[j] += 1
cnt = 0
for item in gatelist:
    if item == m:
        cnt +=1
print(cnt)

Fixed submission:
n,m = map(int, input().split())
maxl = 0
minr = 100000
for i in range(m):
    l,r = map(int, input().split())
    maxl = max(maxl,l)
    minr = min(minr,r)
ans = max(minr - maxl + 1, 0)
print(ans)
Buggy python submission (verdict: Runtime Error):
five_dish = [int(input()) for _ in range(5)]
idx = None
maxdiff = 0
result = 0
for i in range(len(five_dish)):
    tmp = five_dish[i] % 10
    if tmp == 0:
        pass
    else:
        if 10 - tmp > maxdiff:
            maxdiff = 10 - tmp
            idx = i
        else:
            pass
for j in range(len(five_dish)):
    if j == idx:
        pass
    else:
        if five_dish[j] % 10 == 0:
            result += five_dish[j]
        else:
            result += five_dish[j] + (10 - (five_dish[j] % 10))
result += five_dish[idx]
print(result)


Fixed submission:
five_dish = [int(input()) for _ in range(5)]
idx = 0
maxdiff = 0
result = 0
for i in range(len(five_dish)):
    tmp = five_dish[i] % 10
    if tmp != 0:
        if 10 - tmp > maxdiff:
            maxdiff = 10 - tmp
            idx = i
for j in range(len(five_dish)):
    if j == idx:
        continue
    else:
        if five_dish[j] % 10 == 0:
            result += five_dish[j]
        else:
            result += five_dish[j] + (10 - (five_dish[j] % 10))
result += five_dish[idx]
print(result)

Buggy python submission (verdict: Runtime Error):
five_dish = [int(input()) for _ in range(5)]
idx = None
maxdiff = 0
result = 0
for i in range(len(five_dish)):
    tmp = five_dish[i] % 10
    if tmp == 0:
        continue
    else:
        if 10 - tmp >= maxdiff:
            maxdiff = 10 - tmp
            idx = i
        else:
            continue
for j in range(len(five_dish)):
    if j == idx:
        continue
    else:
        if five_dish[j] % 10 == 0:
            result += five_dish[j]
        else:
            result += five_dish[j] + (10 - five_dish[j] % 10)
result += five_dish[idx]
print(result)


Fixed submission:
five_dish = [int(input()) for _ in range(5)]
idx = 0
maxdiff = 0
result = 0
for i in range(len(five_dish)):
    tmp = five_dish[i] % 10
    if tmp != 0:
        if 10 - tmp > maxdiff:
            maxdiff = 10 - tmp
            idx = i
for j in range(len(five_dish)):
    if j == idx:
        continue
    else:
        if five_dish[j] % 10 == 0:
            result += five_dish[j]
        else:
            result += five_dish[j] + (10 - (five_dish[j] % 10))
result += five_dish[idx]
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
len_s = len(s)
for i in range(q):
    l, r = map(int, input().split())
    cnt = s[l-1:r].count("AC")
    print(cnt)


Fixed submission:
n, q = map(int, input().split())
s = input()
ans = [0] * (n + 1)
for i in range(n):
    ans[i + 1] = ans[i] + (1 if s[i:i+2] == "AC" else 0)
for j in range(q):
    l,r = map(int, input().split())
    res = ans[r-1] - ans[l-1]
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
len_s = len(s)
ans = []
for i in range(q):
    l, r = map(int, input().split())
    tmp_len = len(s[l-1:r].replace("AC", ""))
    res = ((r-l+1) - tmp_len) / 2
    ans.append(int(res))
for num in ans:
    print(num)


Fixed submission:
n, q = map(int, input().split())
s = input()
ans = [0] * (n + 1)
for i in range(n):
    ans[i + 1] = ans[i] + (1 if s[i:i+2] == "AC" else 0)
for j in range(q):
    l,r = map(int, input().split())
    res = ans[r-1] - ans[l-1]
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
init_len = len(s)
tmp_s_len = 0
while tmp_s_len != len(s):
    tmp_s_len = len(s)
    s = s.replace("01","").replace("10","")
    continue
res = init_len - tmp_s_len
print(res)


Fixed submission:
s = input()
cnt_zero = 0
cnt_one = 0
for letter in s:
    if letter == "0":
        cnt_zero += 1
    else:
        cnt_one += 1
res = min(cnt_zero, cnt_one) * 2
print(res)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.append(a[0])
div = a[0]
minVal = a[0]
for i in range(n+1):
    mod = a[i] % div
    if mod > 0:
        minVal = min(mod, div - mod, minVal, mod - (div - mod))
        div = minVal
    else:
        continue
print(minVal)


Fixed submission:
import math

n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(n):
    ans = math.gcd(a[i], ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_list = []
cnt_dict = {}
for i in a:
    if i in cnt_dict:
        cnt_dict[i] += 1
    else:
        cnt_dict[i] = 1
cnt_dict_sorted = sorted(cnt_dict.items(), key=lambda x: x[1])
for i in set(a):
    cnt_list.append(a.count(i))
ans = 0
if len(cnt_dict_sorted) <= k:
    ans = 0
else:
    tmp = len(cnt_dict_sorted) - k
    for j in range(tmp):
        ans += cnt_dict_sorted[j][1]
print(ans)


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_dict = {}
for i in a:
    if i in cnt_dict:
        cnt_dict[i] += 1
    else:
        cnt_dict[i] = 1
cnt_dict_sorted = sorted(cnt_dict.items(), key=lambda x: x[1])
ans = 0
if len(cnt_dict_sorted) <= k:
    ans = 0
else:
    tmp = len(cnt_dict_sorted) - k
    for j in range(tmp):
        ans += cnt_dict_sorted[j][1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_list = []
for i in set(a):
        cnt_list.append(a.count(i))
ans = 0
cnt_list.sort()
if len(cnt_list) <= k:
    ans = 0
else:
    tmp = len(cnt_list) - k
    ans = sum(cnt_list[:tmp])
print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt_dict = {}
for i in a:
    if i in cnt_dict:
        cnt_dict[i] += 1
    else:
        cnt_dict[i] = 1
cnt_dict_sorted = sorted(cnt_dict.items(), key=lambda x: x[1])
ans = 0
if len(cnt_dict_sorted) <= k:
    ans = 0
else:
    tmp = len(cnt_dict_sorted) - k
    for j in range(tmp):
        ans += cnt_dict_sorted[j][1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
cnt = 0
for i in range(n):
    num_c = c[i]
    b_idx = bisect_left(b,num_c)
    for j in range(b_idx):
        num_b = b[j]
        a_idx = bisect_left(a, num_b)
        cnt += a_idx
print(cnt)


Fixed submission:
from bisect import bisect_left, bisect_right

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
len_c = len(c)
total = 0
for num in b:
    idx_a = bisect_left(a, num)
    idx_c = bisect_right(c, num)
    cnt = idx_a * (len_c - idx_c)
    total += cnt
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(k + 1):
        if s - x - y > k:
            continue
        elif s - x - y < 0:
            continue
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
print(cnt)


Fixed submission:
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        if s - x - y > k:
            continue
        elif s - x - y < 0:
            continue
        z = s - x - y 
        if 0 <= z <= k:
            cnt += 1
print(cnt)


Fixed submission:
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1
            else:
                continue
print(cnt)

Fixed submission:
k, s = map(int, input().split())
cnt = 0
for x in range(max(s - 2 * k, 0), k + 1):
    for y in range(max(s - x - k, 0), min(s - x + 1, k + 1)):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
        else:
            continue
print(cnt)
Buggy python submission (verdict: Runtime Error):
N =int(input())
D = []
for i in range(n):
  D.append([])#配列の末尾に空の配列を追加

for i in range(N):
	for j in range(2):
      	D[i][j]=int(input())

for x in range(N-2):
  	if D[x][1]==D[x][2] and D[x+1][1]==D[x+1][2] and D[x+2][1]==D[x+2][2]:
      	print("Yes")
        break
    else:
      	print("No")


Fixed submission:
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    j += 1
  else:
    j=0
  if(j>=3):
    ans = "Yes"
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    if(j>0):
      j += 1
  else:
    j=0
  if(j=>3):
    ans = "Yes"
print(ans)


Fixed submission:
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    j += 1
  else:
    j=0
  if(j>=3):
    ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
h = sum(a)
ans = 0
for i in range(n):
  h -= a[i]
  ans = (ans + (a[i]*(h))%(10**9+7)
print(ans)
 



Fixed submission:
n = int(input())
a = list(map(int,input().split()))
h = sum(a)
ans = 0
for i in range(n):
  h -= a[i]
  ans += a[i]*(h)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
g = set(l)
m = list(g)
m.sort()
for i in range(n):
  judge = 0
  for j in range(i+1,n):
    for k in range(j+1,n):
      if(m[i]<m[j]+m[k]):
        ans += 1
      else:
        break
    if(judge==0):
      break
print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort(reverse=True)
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if(l[i]!=l[j])and(l[j]!=l[k])and(l[i]!=l[k])and(l[i]<l[j]+l[k]):
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
g = set(l)
m = list(g)
m.sort()
for i in range(n):
  judge = 0
  for j in range(i+1,n):
    for k in range(j+1,n):
      if(m[i]<[j]+[k]):
        ans += 1
      else:
        break
    if(judge==0):
      break
print(ans)


Fixed submission:
n = int(input())
l = list(map(int,input().split()))
ans = 0
l.sort(reverse=True)
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if(l[i]!=l[j])and(l[j]!=l[k])and(l[i]!=l[k])and(l[i]<l[j]+l[k]):
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int,input().split())
x = abs(x)
if (x<=k*d):
  print(x-k*d)
else:
  if((k-x//d)%2==1):
    print(abs(x-(x//d;1)*d))
  else:
    print(abs(x-(x//d)*d))

Fixed submission:
x,k,d = map(int,input().split())
x = abs(x)
jud = x//d
if(k<=jud):
  print(abs(abs(x)-d*k))
else:
  if((k-jud)%2 == 1):
    print(abs(abs(x)-(jud+1)*d))
  else:
    print(abs(abs(x)-(jud)*d))

Buggy python submission (verdict: Runtime Error):
x,k,d = map(int,input().split())
jud = x//d
if(k==1):
  print(abs(abs(x)-d))
elif(jud == 0):
  if((k%2 == 1):
    print(abs(abs(x)-d))
  else:
    print(abs(x))
elif(k<=jud+1):
  print(abs(abs(x)-d*k))
else:
  if((k-jud)%2 == 1):
    print(abs(abs(x)-(jud+1)*d))
  else:
    print(abs(abs(x)-(jud)*d))


Fixed submission:
x,k,d = map(int,input().split())
x = abs(x)
jud = x//d
if(k<=jud):
  print(abs(abs(x)-d*k))
else:
  if((k-jud)%2 == 1):
    print(abs(abs(x)-(jud+1)*d))
  else:
    print(abs(abs(x)-(jud)*d))
Buggy python submission (verdict: Runtime Error):
n,d = int(input())
ans = 0
for i in range(n):
  x,y = map(int,input().split())
  if(d>=(x**2+y**2)**(1/2)):
    ans += 1
print(ans)

Fixed submission:
n,d = map(int,input().split())
ans = 0
for i in range(n):
  x,y = map(int,input().split())
  if(d >= (x**2+y**2)**(1/2)):
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(j==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



Fixed submission:
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

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    j = m%k
    if(j==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



Fixed submission:
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

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    j = m%k
    if(j==0):
      print(i)
      break  
    if(i>1000000):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



Fixed submission:
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

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    if(m%k==0):
      print(i)
      break  
    if(i>1000000):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1


Fixed submission:
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

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    if(m%k==0):
      print(i)
      break  
    if(i>10000000):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



Fixed submission:
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

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = 7
    if(m%k==0):
      print(i)
      break
    if(i>100000000):
      print("-1")
      break
    m = m*10 + 7
    i += 1

  
  


Fixed submission:
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
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int.input().split()))
b = list(map(int,input().split()))
for i in range(1,n):
  a[i] += a[i-1]
for  i in range(1,m):
  b[i] += b[i-1]
ans = -100
for i in range(n):
  for j in range(m):
    if(a[i]+b[j]>=k):
      break
    ans = max(ans,a[i]+b[j])
print(ans)

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

a,b=[0],[0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
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)