Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from copy import deepcopy
N, W = map(int, raw_input().split())
pre = []
V = 0
for i in range(N):
    w, v = map(int, raw_input().split())
    V += v
    pre.append((w, v))
minw = min(pre)[0]
items1 = []
items2 = []
items3 = []
items4 = []
for w, v in pre:
    if w == minw:
        items1.append((w, v))
    elif w == minw + 1:
        items2.append((w, v))
    elif w == minw + 2:
        items3.append((w, v))
    else:
        items4.append((w, v))
items1.sort(reverse=True)
items2.sort(reverse=True)
items3.sort(reverse=True)
items4.sort(reverse=True)
items = [items1, items2, items3, items4]
memo = {}

def dfs(indice, W, value):
    if W < 0:
        return -(10**9)
    if W < minw or W == 0:
        return value
    if indice in memo:
        return memo[indice]
    outOfAmmo = True
    indicel = list(indice)
    sofar = -(10**9)
    for i in range(4):
        if indice[i] < len(items[i]):
            outOfAmmo = False
            new_indice = deepcopy(indicel)
            new_indice[i] += 1
            current_item = items[i][indice[i]]
            sofar = max(sofar, dfs(tuple(new_indice), W-current_item[0], value+current_item[1]))
    memo[indice] = sofar
    if outOfAmmo:
        return value
    return sofar
print dfs((0, 0, 0, 0), W, 0)


Fixed submission:
import sys
from copy import deepcopy
N, W = map(int, raw_input().split())
pre = []
V = 0
for i in range(N):
    w, v = map(int, raw_input().split())
    V += v
    pre.append((w, v))
minw = min(pre)[0]
items1 = []
items2 = []
items3 = []
items4 = []
for w, v in pre:
    if w == minw:
        items1.append((w, v))
    elif w == minw + 1:
        items2.append((w, v))
    elif w == minw + 2:
        items3.append((w, v))
    else:
        items4.append((w, v))
items1.sort(reverse=True)
items2.sort(reverse=True)
items3.sort(reverse=True)
items4.sort(reverse=True)
items = [items1, items2, items3, items4]
memo = {}

def dfs(indice, W, value):
    if W < 0:
        return -(10**9)
    if W < minw or W == 0:
        return value
    if indice in memo:
        return memo[indice]
    outOfAmmo = True
    indicel = list(indice)
    sofar = -(10**9)
    for i in range(4):
        if indice[i] < len(items[i]):
            outOfAmmo = False
            new_indice = deepcopy(indicel)
            new_indice[i] += 1
            current_item = items[i][indice[i]]
            sofar = max(sofar, dfs(tuple(new_indice), W-current_item[0], value+current_item[1]))
    memo[indice] = sofar
    if outOfAmmo:
        return value
    return sofar
print dfs((0, 0, 0, 0), W, 0)
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
from copy import deepcopy
from functools import reduce
from operator import mul
n = int(input())
def pf(n):
    pfs = []
    while n % 2 == 0:
        pfs.append(2)
        n //= 2
    for i in range(3, int(sqrt(n)+1), 2):
        while n % i == 0:
            pfs.append(i)
            n //= i
    if n > 2:
        pfs.append(n)
    return pfs
def partition(pfs):
    subsets = [[]]
    for i in range(len(pfs)):
        for j in range(len(subsets)):
            c = deepcopy(subsets[j])
            subsets.append(c + [i])
    return subsets

pfs = pf(n)
Asubs = partition(pfs)
def digits(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

def calculate(Asubs):
    minSoFar = 10
    for Asub in Asubs:
        if Asub == []:
            Asum = 1
        else:
            Asum = reduce(mul, [pfs[i] for i in Asub])
        Bsub = [pfs[i] for i in range(len(pfs)) if i not in Asub]
        if Bsub == []:
            Bsum = 1
        else:
            Bsum = reduce(mul, Bsub)
        if max(digits(Asum), digits(Bsum)) < minSoFar:
            minSoFar = max(digits(Asum), digits(Bsum))
    return minSoFar
print (calculate(Asubs))

Fixed submission:
from math import sqrt
n = int (input())
nsqrt = int(sqrt(n))
for i in range(nsqrt, 0, -1):
    if n % i == 0:
        b = n // i
        a = i
        break
    if i == 1:
        b = 1
        a = n
def digits(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans
print (max(digits(a), digits(b)))
Buggy python submission (verdict: Time Limit Exceeded):
str = input()
num = int(str)
if num % 2 == 0:
  print('-1');
else:
  i = 1
  j = 7
  while j % num != 0:
    j = (j % num) * 10 + 7
    i += 1
  print(i);
  

Fixed submission:
str = input()
num = int(str)
if num % 2 == 0:
  print('-1');
else:
  i = 1
  j = 7
  while j % num != 0 and i <= num:
    j = (j % num) * 10 + 7
    i += 1
  if i > num:
    print('-1');
  else:
    print(i);

Buggy python submission (verdict: Time Limit Exceeded):
import sys

k = int(input())

a = 0

for i in range(1, k+1):
  a = a*10+7
  if a%k == 0:
      print(i)
      sys.exit()
print(-1)


Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
  a = (a*10+7)%k
  if a == 0:
      print(i)
      sys.exit()

print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum_(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


n, k = map(int, input().split())
ppp = list(map(int, input().split()))
pppa = []
for i in range(k):
    pppa += ppp
ppp = pppa
k = 1
bit = Bit(3000)
ans_ = 0

for i, p in enumerate(ppp):
    bit.add(p, 1)
    ans_ += i + 1 - bit.sum_(p)

mod = 10 ** 9 + 7
ans = (ans_ * k) % mod
ppp = sorted(ppp)

ppp_ = set(ppp)
dic1 = {}
dic2 = {}
for i in ppp_:
    dic1[i] = 0
    dic2[i] = 0

for i in ppp:
    dic1[i] += 1
    dic2[i] += 1

k_ = ((k-1) * k / 2) % mod
k_ = int(k_)
for i in ppp_:
    dic1[i] = 0
    ans += k_ * dic2[i] * sum(dic1.values())
    ans %= mod

print(ans)


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

ans1 = 0
for i in range(n):
    for j in range(i+1, n):
        if a[i] > a[j]:
            ans1 += 1

ans2 = 0
for i in a:
    for j in a:
        if i > j:
            ans2 += 1

ans = k * ans1 + k * (k-1) // 2 * ans2
ans %= 10 ** 9 + 7

print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10 ** 9 + 7

ai = n - k + 1
print(ai)

for i in range(2, k +1):
    if n - k + 1 < i:
        print(0)
        continue

    ai = int(ai * (n - k - i + 2) * (k - i + 1) / (i * (i - 1)))
    print(ai % mod)


Fixed submission:
import numpy as np

global mod
mod = 10 ** 9 + 7

def mpow(x, n):  # x^nをmod取りながら返す
    ans = 1
    while n != 0:
        if n & 1:
            ans = ans * x % mod
        x = x * x % mod
        n = n >> 1

    return ans

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

ai = n - k + 1
print(ai)

for i in range(2, k +1):
    if n - k + 1 < i:
        print(0)
        continue

    ai = ai * (n - k - i + 2) * (k - i + 1) % mod
    ai = ai * mpow(i*(i-1), mod-2) % mod

    print(ai)
Buggy python submission (verdict: Runtime Error):
import math

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

a, b, c, d = map(int, input().split())

x = int(lcm(c, d))

A = a-1 - (a - 1) // c - (a - 1) // d + (a - 1) // x
B = b - b // c - b // d + b // x

print(int(B - A))


Fixed submission:
def gcd(x, y):
    if x < y:
        tmp = y
        y = x
        x = tmp
    while y != 0:
        x = x % y
        temp = y
        y = x
        x = temp
    return int(x)

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

a, b, c, d = map(int, input().split())

x = lcm(c, d)

A = a-1 - (a - 1) // c - (a - 1) // d + (a - 1) // x
B = b - b // c - b // d + b // x

print(int(B - A))
Buggy python submission (verdict: Runtime Error):
import numpy as np

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

A = np.array(A)

A = np.sort(A)

B = np.copy(A)

if A[0] <= 0 and A[n-1] >= 0:
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)

elif A[n-1] < 0:
    A[n-1] = A[n-1] - A[n-2]
    A[n-2] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    a = B[n-1]
    for i in range(n-1):
        print(a, B[i])
        a = a - B[i]

else:
    A[0] = A[0] - A[1]
    A[1] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)


Fixed submission:
import numpy as np

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

A = np.array(A)

A = np.sort(A)

B = np.copy(A)
if n == 2:
    print(A[1] - A[0])
    print(A[1], A[0])

elif A[0] <= 0 and A[n-1] >= 0:
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)

elif A[n-1] < 0:
    A[n-1] = A[n-1] - A[n-2]
    A[n-2] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    a = B[n-1]
    for i in range(n-1):
        print(a, B[i])
        a = a - B[i]

else:
    A[0] = A[0] - A[1]
    A[1] = 0
    for i in range(n-1):
        A[i] = min(A[i], -A[i])

    print(np.sum(A[:-1]) * -1 + A[n-1])

    k = n - 2
    a = B[0]
    while B[k] >= 0:
        print(a, B[k])
        a = a - B[k]
        k -= 1
        if k == 0:
            break

    b = B[n-1]

    while k != 0:
        print(b, B[k])
        b = b - B[k]
        k -= 1

    print(b, a)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = [int(i) for i in input().split()]

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while A[index] < k and index < N and a < M:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))


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

A = [int(i) for i in input().split()]

X = []

for i in range(0, M):
    B, C = map(int, input().split())
    X.append([C, B])

X.sort(reverse=True)

A.sort()

index = 0
l = 0
a = 0
k = X[a][0]

while index < N and a < M and A[index] < k:
    A[index] = k;
    index += 1;
    l += 1;
    if(l == X[a][1]):
        a += 1
        if a >= M:
            break
        k = X[a][0]
        l = 0

print(sum(A))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    s+=L[c]
    c+=1
print(c)

Fixed submission:
n,x=map(int,input().split())
L=list(map(int,input().split()))
c=0
s=0
while(s<=x):
    if c == n:
        c+=1
        break
    s+=L[c]
    c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
flg=0
if w//2==x: flg+=1
if h//2==y: flg+=1
if h/w==y/x: flg+=1
if w*(y-h)==-h*x: flg+=1
print(str(w*h/2)+" "+str(1-flg%2))

Fixed submission:
w,h,x,y=map(int,input().split())
flg=0
if w/2==x and h/2==y: flg=1
print(str(w*h/2)+" "+str(flg))
Buggy python submission (verdict: Runtime Error):
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta >= 0:
    ta -= int(A[cnta])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)   


Fixed submission:
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta - 1 >= 0:
    ta -= int(A[cnta - 1])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = ""
while n > 0:
    re = n % 26
    if re != 0:
        ans = chr(ord('a') + (re - 1)) + ans
        n = n // 26
    else:
        ans = 'z' + ans;
        n = n / 26 - 1
print(ans)

Fixed submission:
n = int(input())
ans = ""
while n > 0:
    re = n % 26
    if re != 0:
        ans = chr(ord('a') + (re - 1)) + ans
        n = n // 26
    else:
        ans = 'z' + ans;
        n = n // 26 - 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = input().split()
x=int(x)
y=int(y)
for c in range(1, x):
    t = x - c
    if 2*c+4*t==y:
        print("Yes")
        sys.exit()
print("No")

Fixed submission:
import sys
x,y = input().split()
x=int(x)
y=int(y)
for c in range(0, x+1):
    t = x - c
    if 2*c+4*t==y:
        print("Yes")
        sys.exit()
print("No")
Buggy python submission (verdict: Runtime Error):
N=int(Input(""))
if N % 10 == 7 || (N - N % 10) / 10 % 10 == 7 || (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input(""))
if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N=Input("")
if N % 10 == 7 || (N - N % 10) / 10 % 10 == 7 || (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")

Fixed submission:
N=int(input(""))
if N % 10 == 7 or (N - N % 10) / 10 % 10 == 7 or (N - N % 100)/100 == 7:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    while b != 0 :
        t = a % b
        a = b
        b = t
    return a
        
sum = 0
N=int(input(""))
for a in range(1, N + 1):
    for b in range(1, N + 1):
        for c in range(1, N + 1):
            sum = sum + gcd(gcd(a, b), c)
print(sum)

  

Fixed submission:
def gcd(a, b):
    while b != 0 :
        t = a % b
        a = b
        b = t
    return a
        
sum = 0
N=int(input(""))
for a in range(1, N + 1):
    for b in range(1, N + 1):
        x = gcd(a, b)
        if x == 1:
            sum = sum + N
        else:
            for c in range(1, N + 1):
                sum = sum + gcd(x, c)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()

r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, N):
        k = 2 * j - i
        if (i < j) & (j < k) & (k < N) :
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

print(ans)

Fixed submission:
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
            if k < N:
                s = S[i] + S[j] + S[k]
                if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1

print(ans)

Fixed submission:
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k =[int(x) for x in input().split()]

pre_value=n + k
tmp=n
while tmp < pre_value:
    pre_value = tmp
    tmp = abs( tmp - k)
    
print(pre_value)    

Fixed submission:
n,k =[int(x) for x in input().split()]

pre_value = n+1
tmp = n
a = n // k 
tmp = n - a*k 
while tmp < pre_value:
    pre_value = tmp
    tmp = abs( tmp - k)
    
print(pre_value)
Buggy python submission (verdict: Runtime Error):
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No)

Fixed submission:
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x=input()
y=x.split()
if y[0] = y[1] :
    if y[0] = y[2]:
        print("No")
    else:
        print("Yes")
elif y[2] = y[1] :
        print("Yes")

Fixed submission:
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
x=input()
y=x.split("  ")
if y[0] = y[1] :
    if y[0] = y[2]:
        print("No")
    else:
        print("Yes")
elif y[2] = y[1] :
        print("Yes")

Fixed submission:
x=input()
y=x.split()

if y[0] == y[1] :
    if y[0] == y[2]:
        print("No")
    else:
        print("Yes")
elif y[0] == y[2] :
    print("Yes")
elif y[2] == y[1] :
        print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S=input()[::-1]
ans=0
#支払う枚数
array = list(map(int, S))
L=len(array)
for i,n in enumerate(array):
    if n<= 5 :
        ans+=n
    elif n > 5:
        ans+= 10-n
        if i <L-1:
            array[i+1] +=1
        else:
            ans +=1
    else:
        ans+=5
        if < L-1:
            if array[i+1] >=5:
                array[i+1] +=1
                
print( ans)


Fixed submission:
S=input()[::-1]
ans=0
#支払う枚数
array = list(map(int, S))
L=len(array)
for i,n in enumerate(array):
    if n< 5 :
        ans+=n
    elif n > 5:
        ans+= 10-n
        if i <L-1:
            array[i+1] +=1
        else:
            ans +=1
    else:
        ans+=5
        if i < L-1:
            if array[i+1] >=5:
                array[i+1] +=1
                
print( ans)

Buggy python submission (verdict: Runtime Error):
S=input()
paynum=0
payout=0
change=0
changenum=0
num=0
#支払う枚数
array = list(map(int, S))
array.reverse()
print(array)
for i in array:  
    if i <= 5 :
        paynum = paynum + i
        payout = payout + i *( 10 ** num)
    else:
        if num+1 <len(S):
            array[num+1] = array[num+1]+1
        else:
            paynum = paynum + 1
            payout = payout + 1*(10**(num+1))
    num= num+1

#お釣り
change = payout - N
tmp= str(change)
array2 = list(map(int, tmp))
changenum= sum(array2)
print( changenum + paynum)




Fixed submission:
S=input()[::-1]
ans=0
#支払う枚数
array = list(map(int, S))
L=len(array)
for i,n in enumerate(array):
    if n< 5 :
        ans+=n
    elif n > 5:
        ans+= 10-n
        if i <L-1:
            array[i+1] +=1
        else:
            ans +=1
    else:
        ans+=5
        if i < L-1:
            if array[i+1] >=5:
                array[i+1] +=1
                
print( ans)
Buggy python submission (verdict: Runtime Error):
s  = input()
a = s[:len(s)/2 -1]
b = s[len(s)+3/2-1:]
flag = 0
if s == s[::-1]:
    if a == a[::-1]:
        if b == b[::-1]:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')

Fixed submission:

s  = input()
a = s[:int(len(s)/2)]
b = s[:-int(len(s)/2 + 1)]
flag = 0
if s == s[::-1]:
    if a == a[::-1]:
        if b == b[::-1]:
            flag = 1

if flag:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = input()
if n%2==0 or n%5==0:
  print(-1)
else:
  i = len(str(n))
  seven = int(i*"7")
  while seven % n != 0:
    i += 1
    seven = int(i*"7")
    if i > 100:
      break
  print(i)

Fixed submission:
n = int(input())
flag = True
a = 7
for i in range(n):
  if a % n == 0:
    print(i+1)
    flag = False
    break
  a = (10*a + 7)%n
if flag:
	print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,g+1):
    while g % i == 0:
        g //= i
        #print(g,i)
        if first:
            cnt += 1
            first = False

        if g < i:
            break

    first = True
    if g < i:
        break


print(cnt+1)


Fixed submission:
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC142D
import math
import fractions
A,B = map(int,input().split())
 
g = fractions.gcd(A,B)
 
cnt = 0
first = True 
 
for i in range(2,g+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False
 
    first = True
    if g < i:
        break
 
 
print(cnt+1)

Fixed submission:
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)

Buggy python submission (verdict: Time Limit Exceeded):
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True
for i in range(2,g+1):
    while g % i == 0:
        g //= i
        #print(g)
        if first:
            cnt += 1
            first = False

    first = True

print(cnt+1)




Fixed submission:
#ABC142D
import math
import fractions
A,B = map(int,input().split())

g = fractions.gcd(A,B)

cnt = 0
first = True

for i in range(2,int(math.sqrt(g))+1):
    while g%i == 0:
        g //= i
        if first:
            cnt += 1
            first = False

    first = True

if g != 1:
    cnt += 1

print(cnt+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
dic = 'abcdefghijklmnopqrstuvwxyz'

save = []
cnt = 0
for i in range(N):
    s = input()
    l = []
    for j in range(len(dic)):
        l.append(s.count(dic[j]))
    for k in range(len(save)):
        if save[k] == l:
            cnt += 1
    save.append(l)

print(cnt)

Fixed submission:
N = int(input())

def nume(x):
    return x*(x-1)/2-(x-1)

save = []

for i in range(N):
    s = ''.join(sorted(input()))
    save.append(s)

save.sort()

cnt = 0
serial = 1
for i in range(N-1):
    if save[i] == save[i+1]:
        cnt += 1
        serial += 1
    else:
        cnt += int(nume(serial))
        serial = 1

cnt += int(nume(serial))
print(cnt)