Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S=input()
for i in range(Q):
  L,R=map(int, input().split())
  ACsum=S[L-1:R].split("AC")
  print(len(ACsum)-1)

Fixed submission:
N, Q = map(int, input().split())
S=list(input())
Snum=list()
Snum.append(0)
Snum.append(0)
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    Snum.append(Snum[i]+1)
  else:
    Snum.append(Snum[i])
for i in range(Q):
  L,R=map(int, input().split())
  print(Snum[R]-Snum[L])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S=input()
l=list()
r=list()
for i in range(Q):
  L,R=map(int, input().split())
  S2=S[L-1:R].split("AC")
  print(len(S2)-1)

Fixed submission:
N, Q = map(int, input().split())
S=list(input())
Snum=list()
Snum.append(0)
Snum.append(0)
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    Snum.append(Snum[i]+1)
  else:
    Snum.append(Snum[i])
for i in range(Q):
  L,R=map(int, input().split())
  print(Snum[R]-Snum[L])

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S=input()
l=list()
r=list()
for i in range(Q):
  L,R=map(int, input().split())
  S2=S[L-1:R].split("AC")
  print(S[L-1:R])
  print(len(S2)-1)

Fixed submission:
N, Q = map(int, input().split())
S=list(input())
Snum=list()
Snum.append(0)
Snum.append(0)
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    Snum.append(Snum[i]+1)
  else:
    Snum.append(Snum[i])
for i in range(Q):
  L,R=map(int, input().split())
  print(Snum[R]-Snum[L])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S=input()
l=list()
r=list()
for i in range(Q):
  LandR=list(map(int,input().split()))
  l.append(LandR[0])
  r.append(LandR[1])
  S2=S[l[i]-1:r[i]].split("AC")
  print(len(S2)-1)

Fixed submission:
N, Q = map(int, input().split())
S=list(input())
Snum=list()
Snum.append(0)
Snum.append(0)
for i in range(1,N):
  if S[i]=="C" and S[i-1]=="A":
    Snum.append(Snum[i]+1)
  else:
    Snum.append(Snum[i])
for i in range(Q):
  L,R=map(int, input().split())
  print(Snum[R]-Snum[L])
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if(a+b>c): print("Yes")
else: print("No")

Fixed submission:
a, b, c = map(int, input().split())
if(a+b>=c):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if a+b>c: print("Yes")
else: print("No")

Fixed submission:
a, b, c = map(int, input().split())
if(a+b>=c):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if(a+b>c) print("Yes")
else print("No")

Fixed submission:
a, b, c = map(int, input().split())
if(a+b>=c):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a=int(input());
b=int(input());
c=int(input());
if(a+b>c) print("Yes");
else print("No");

Fixed submission:
a, b, c = map(int, input().split())
if(a+b>=c):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split)
xmx = max([a, b])
xmin = min([a, b])
#xabsmx = max([a, b], key = abs)
#xabsmin = min([a, b],key = abs)
ymx = max([c, d])
ymin = min([c, d])
#yabsmx = max([c,d], key = abs)
#yabsmin = min([c, d],key = abs)
if xmin >= 0:#all X plus
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

if xmx <= 0:#all X minas
    if ymin >= 0:#all Y plus
        print(xmx * ymin)
    else:
        print(xmin * ymin)
else:#X plus and minas
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

Fixed submission:
a, b, c, d = map(int, input().split())
xmx = max([a, b])
xmin = min([a, b])
#xabsmx = max([a, b], key = abs)
#xabsmin = min([a, b],key = abs)
ymx = max([c, d])
ymin = min([c, d])
#yabsmx = max([c,d], key = abs)
#yabsmin = min([c, d],key = abs)
if xmin >= 0:#all X plus
    if ymx <= 0:#all Y minas
        print(xmin * ymx)
    else:
        print(xmx * ymx)

elif xmx <= 0:#all X minas
    if ymin >= 0:#all Y plus
        print(xmx * ymin)
    else:
        print(xmin * ymin)
else:#X plus and minas
    if ymx <= 0:#all Y minas
        print(xmin * ymin)
    elif ymin >= 0:#all Y plus
        print(xmx * ymx)
    else:#Y plus and minas
        if xmx * ymx > xmin * ymin:
            print(xmx * ymx)
        else:
            print(xmin * ymin)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
S=0
i=N
while i>1:
    saidai=A.index(max(A[0:i]))
    S+=sum(list(map(lambda x:max(A[0:i])-x,A[saidai:i])))
    i=saidai
print(S) 

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=a[0]
ans=0
for i in range(n):
    if a[i]<s:
        ans+=s-a[i]
    else:
        s=a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
S=0
for i in range(N):
	S+=max(A[0:i+1])-A[i]
print(S) 

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=a[0]
ans=0
for i in range(n):
    if a[i]<s:
        ans+=s-a[i]
    else:
        s=a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
hlst10 = [j for j in range(2 ** h)]
hlst2 = [format(k, '0{}b'.format(h)) for k in hlst10]
#print(hlst2)

wlst10 = [l for l in range(2 ** w)]
wlst2 = [format(m, '0{}b'.format(w)) for m in wlst10]
#print(wlst2)

ans = 0
for o in hlst10:
	for p in wlst10:
		black = 0
		nowhlst = hlst2[o]
		nowwlst = wlst2[p]
		for q in range(h):
			for r in range(w):
				if nowhlst[q] == '0' and nowwlst[r] == '0' and test[q][r] == "#":
					black += 1
		if black == n:
			ans += 1 
print(ans)

Fixed submission:
h, w, n = map(int, input().split())
test = [input() for i in range(h)]
ans = 0
for binh in range(2 ** h):
	for binw in range(2 ** w):
		tmp = 0
		for l in range(h):
			for m in range(w):
				if ((binh >> l) & 1) == 0  and ((binw >> m) & 1) == 0 and test[l][m] == "#":
					tmp += 1
		if tmp == n:
			ans += 1	
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(range(1, N+1))#頂点の数
H = [list(map(int,input().split())) for i in range(N-1)]#辺のリスト
F = 0
tyouten = int(N*(N+1)*(N+2)/6)
for i in range(1,N+1):
    for j in range(i,N+1):	
        Hselect = [H[x] for x in range(N-1) if i <= H[x][0] <= j and i <= H[x][1] <= j]#L以上R以下の頂点で構成される辺のリスト
        F += len(Hselect)
#以上の処理をL＝1〜N、R＝L〜Nまで繰り返す
print(tyouten-F)#頂点数からHselectの要素数を引いた数＝連結成分数

Fixed submission:
N=int(input())
S=list(range(1, N+1))#頂点の数
H = [sorted(list(map(int,input().split()))) for i in range(N-1)]#辺のリスト。頂点は右にいくほど大きい
F = 0
tyouten = int(N*(N+1)*(N+2)/6)
for i in range(len(H)):
    F += H[i][0]*(N-H[i][1]+1)#uVの組み合わせによって得られる辺の数をFに追加
print(tyouten-F)#頂点数からHselectの要素数を引いた数＝連結成分数

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(range(1, N+1))#頂点の数
H = [list(map(int,input().split())) for i in range(N-1)]#辺のリスト

F = 0
for i in range(1,N+1):
    for j in range(i,N+1):	
        L=i
        R=j
        Hselect = [H[x] for x in range(N-1) if L <= H[x][0] <= R and L <= H[x][1] <= R]#L以上R以下の頂点で構成される辺のリスト
        tyouten = R-L+1#L以上R以下の数の個数＝頂点数
        renketu = tyouten - len(Hselect)#頂点数からHselectの要素数を引いた数＝連結成分数
        F += renketu#fに連結成分数を足す
#以上の処理をL＝1〜N、R＝L〜Nまで繰り返す

print(F)

Fixed submission:
N=int(input())
S=list(range(1, N+1))#頂点の数
H = [sorted(list(map(int,input().split()))) for i in range(N-1)]#辺のリスト。頂点は右にいくほど大きい
F = 0
tyouten = int(N*(N+1)*(N+2)/6)
for i in range(len(H)):
    F += H[i][0]*(N-H[i][1]+1)#uVの組み合わせによって得られる辺の数をFに追加
print(tyouten-F)#頂点数からHselectの要素数を引いた数＝連結成分数
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys

(N, K) = (int(i) for i in input().split())

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

# 一周する数を求める
have_been = [1]
now_place = 1
while True:
    next_place = A[now_place - 1]
    if next_place not in have_been:
        have_been.append(next_place)
        now_place = next_place
    else:
        break

#print('have_been = {}'.format(have_been))
loop_start_index = have_been.index(next_place)

loop = have_been[loop_start_index:]
#print('loop = {}'.format(loop))

left_K = K - loop_start_index
if left_K <= 0:
    print(have_been[K])
    sys.exit()

mod = left_K % len(loop)
print(have_been[mod + loop_start_index])

Fixed submission:
# -*- coding: utf-8 -*-
import sys

(N, K) = (int(i) for i in input().split())

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

# 一周する数を求める
have_been = set()
have_been_list = []
have_been.add(1)
have_been_list.append(1)
now_place = 1
while True:
    next_place = A[now_place - 1]
    if next_place not in have_been:
        have_been.add(next_place)
        have_been_list.append(next_place)
        now_place = next_place
    else:
        break

#print('have_been = {}'.format(have_been))
loop_start_index = have_been_list.index(next_place)

loop_length = len(have_been_list) - loop_start_index
#print('loop = {}'.format(loop))

left_K = K - loop_start_index
if left_K <= 0:
    print(have_been_list[K])
    sys.exit()

mod = left_K % loop_length
print(have_been_list[mod + loop_start_index])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

K = int(input())


# 1,,,9をenqueue
queue = [1, 2, 3, 4, 5, 6, 7, 8, 9]

x = 0
i = 0
# K回繰り返す
while i < K:
    # x = dequeue
    x = queue.pop(0)

    one = x % 10
    # xの一桁目が0でなければ(x * 10 + xの一桁目に1加算した値)をenqueue
    if one != 0:
        queue.append(x * 10 + one - 1)

    # x * 10をenqueue
    queue.append(x * 10 + one)

    # xの一桁目が9でなければ(x * 10 - xの一桁目から1減算した値)をenqueue
    if one != 9:
        queue.append(x * 10 + one + 1)

    i += 1

# xが答え
print(x)

Fixed submission:
# -*- coding: utf-8 -*-
import queue

K = int(input())


# 1,,,9をenqueue
q = queue.Queue()
for i in range(1, 10):
    q.put(i)

x = 0
i = 0
# K回繰り返す
while i < K:
    # x = dequeue
    x = q.get()

    one = x % 10
    # xの一桁目が0でなければ(x * 10 + xの一桁目に1加算した値)をenqueue
    if one != 0:
        q.put(x * 10 + one - 1)

    # x * 10をenqueue
    q.put(x * 10 + one)

    # xの一桁目が9でなければ(x * 10 - xの一桁目から1減算した値)をenqueue
    if one != 9:
        q.put(x * 10 + one + 1)

    i += 1

# xが答え
print(x)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys

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

dp = [0] * max(A)

for a in A:
    if dp[a-1] != 0:
        print('NO')
        break
    dp[a-1] = 1
else:
    print('YES')

Fixed submission:
# -*- coding: utf-8 -*-
import sys

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

dp = {}

for a in A:
    if a-2 in dp:
        print('NO')
        break
    dp[a-2] = 1
else:
    print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys

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

for i in range(len(A)):
    a = A[i]
    for aa in A[i+1:]:
        if aa == a:
            print('NO')
            sys.exit()

print('YES')

Fixed submission:
# -*- coding: utf-8 -*-
import sys

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

dp = {}

for a in A:
    if a-2 in dp:
        print('NO')
        break
    dp[a-2] = 1
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

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

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

print(lcm(A, B))

Fixed submission:
# -*- coding: utf-8 -*-

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

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

print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np
import math

def calculate_distance(in1, in2):
    list1 = np.array(in1) 
    list2 = np.array(in2) 
    sub_list = list1 - list2
    pow_list = np.power(sub_list, 2)
    sum_number = sum(pow_list)
    distance = math.sqrt(sum_number)

    return distance

[N, D] = [int(i) for i in input().split()]

X = []
for n in range(N):
    X.append([int(i) for i in input().split()])

number = 0
for n in range(N):
    for nn in range(n+1, N):
        distance = calculate_distance(X[n], X[nn])
        if distance.is_integer() is True:
            number += 1

print(number)


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
import math

def calculate_distance(in1, in2):
    list1 = np.array(in1) 
    list2 = np.array(in2) 
    sub_list = list1 - list2
    pow_list = np.power(sub_list, 2)
    sum_number = sum(pow_list)
    distance = math.sqrt(sum_number)

    return distance

[N, D] = [int(i) for i in input().split()]

X = []
for n in range(N):
    X.append([int(i) for i in input().split()])

number = 0
for n in range(N):
    for nn in range(n+1, N):
        distance = calculate_distance(X[n], X[nn])
        if distance.is_integer() is True:
            number += 1

print(number)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

S = input()

for i in range(len(S)):
    if S[i] == S[i+1]:
        print('Bad')
        break
else:
    print('Good')


Fixed submission:
# -*- coding: utf-8 -*-

S = input()

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print('Bad')
        break
else:
    print('Good')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

S_dash = input()
T = input()

S_dash_list = list(S_dash)
T_list = list(T)

ei = len(S_dash_list)
si = ei - len(T_list)

insert_flag = False
while si >= 0:
    #print('si: {}, ei: {}'.format(si, ei))
    target = S_dash_list[si:ei]
    flag = True
    for i in reversed(range(len(T_list))):
        if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
            flag = False
            # ここでsiとeiを更新
            ei = si + i + 1
            si = ei - len(T_list)
            break
    if flag:
        for i in range(len(T_list)):
            S_dash_list[si + i] = T_list[i]
        insert_flag = True
        break

if not insert_flag:
    print('UNRESTORABLE')
else:
    ans = ''.join(S_dash_list)
    #print(ans)

    # '?'をaで埋める
    print(ans.replace('?', 'a'))

Fixed submission:
# -*- coding: utf-8 -*-

S_dash = input()
T = input()

S_dash_list = list(S_dash)
T_list = list(T)

ei = len(S_dash_list)
si = ei - len(T_list)

insert_flag = False
while si >= 0:
    #print('si: {}, ei: {}'.format(si, ei))
    target = S_dash_list[si:ei]
    flag = True
    for i in reversed(range(len(T_list))):
        if S_dash_list[si + i] != T_list[i] and S_dash_list[si + i] != '?':
            flag = False
            # ここでsiとeiを更新
            ei -= 1
            si = ei - len(T_list)
            break
    if flag:
        for i in range(len(T_list)):
            S_dash_list[si + i] = T_list[i]
        insert_flag = True
        break

if not insert_flag:
    print('UNRESTORABLE')
else:
    ans = ''.join(S_dash_list)
    #print(ans)

    # '?'をaで埋める
    print(ans.replace('?', 'a'))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int,input().split()))

def calc():
    total = 0
    for i in range(N):
        a = nums[i]
        b = sum(nums[i+1:])
        total += a*b
    return total

print(calc() % (1000000000+7))


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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int,input().split()))


total = 0
for i in range(N):
    a = nums[i]
    b = sum(nums[i+1:])
    total += a*b

print(total % (1000000000+7))

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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int,input().split()))

calcs = []
for i in range(N):
    a = nums[i]
    for j in range(i+1, N):
        calcs.append(a * nums[j])

print(sum(calcs) % (1000000000+7))

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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int,input().split()))

total = 0
for i in range(N):
    a = nums[i]
    for j in range(i+1, N):
        total += a * nums[j]

print(total % (1000000007))

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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nums = list(map(int,input().split()))

total = 0
for i in range(N):
    for j in range(i+1, N):
        total += nums[i] * nums[j]

print(total % (1000000000+7))

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

total = 0
sums = []
tmp = 0

for i in range(1, N):
    tmp += nums[N-i]
    sums.append(tmp)

for i in range(N-1):
    a = nums[i]
    b = sums[N-(i+2)]
    total += a*sums[N-(i+2)]

print(total % (1000000000+7))
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
if b*c>=a:
  print ("Yes")
else:
  print("No")


Fixed submission:
a,b,c=[int(a) for a in input().split()]
if b*c>=a:
  print ("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k=[int(i) for i in input().split()]
r,s,p=[int(i) for i in input().split()]
hand=input()
ans=0
for i in range(k):
  free=True
  j=i
  while j<n:
    if free=True or hand[j-k]!=hand[j]:
      if hand[j]=='r':
        ans+=p
      elif hand[j]=='s':
        ans+=r
      else:
        ans+=s
      free=False
    else:
      free=True
    j+=k
print(ans)

Fixed submission:
n,k=[int(i) for i in input().split()]
r,s,p=[int(i) for i in input().split()]
hand=input()
ans=0
for i in range(k):
  free=True
  j=i
  while j<n:
    if free==True or hand[j-k]!=hand[j]:
      if hand[j]=='r':
        ans+=p
      elif hand[j]=='s':
        ans+=r
      else:
        ans+=s
      free=False
    else:
      free=True
    j+=k
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k=[int(i) for i in input().split()]
r,s,p=[int(i) for i in input().split()]
hand=input()
ans=0
for i in range(k):
  free=True
  j=i
  while j<n:
    if free=True or hand[j-k]!=hand[j]:
      if hand[j]='r':
        ans+=p
      elif hand[j]='s':
        ans+=r
      else:
        ans+=s
      free=False
    else:
      free=True
    j+=k
print(ans)

Fixed submission:
n,k=[int(i) for i in input().split()]
r,s,p=[int(i) for i in input().split()]
hand=input()
ans=0
for i in range(k):
  free=True
  j=i
  while j<n:
    if free==True or hand[j-k]!=hand[j]:
      if hand[j]=='r':
        ans+=p
      elif hand[j]=='s':
        ans+=r
      else:
        ans+=s
      free=False
    else:
      free=True
    j+=k
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
C=list()
last=[[]for i in range(2*100002)]
for i in range(a):
    C.append(int(input()))

ans=[1]*a
last[C[0]].append(0)
#print(last,ans)
for i in range(1,a):
    ans[i]=ans[i-1]
    if C[i]==C[i-1]:
        continue
    for j in last[C[i]]:
        if j==0:
            ans[i]+=1
        else:
            ans[i]+=ans[j-1]
    last[C[i]].append(i)

print(ans[a-1] % 1000000007)


Fixed submission:
a = int(input())
C = list()
last = [-1] * 2 * 100002
for i in range(a):
    C.append(int(input()))

ans = [1] * a
last[C[0]] = 0
# print(last,ans)
for i in range(1, a):
    ans[i] = ans[i - 1]
    if C[i] == C[i - 1]:
        continue
    if last[C[i]] != -1:
        ans[i] += ans[last[C[i]]]
    last[C[i]] = i

print(ans[a - 1] % 1000000007)
Buggy python submission (verdict: Runtime Error):
import math
a,b,k= [int(i) for i in input().split()]

g=math.gcd(a,b)

cd=list()
i=1
while i<=g:
    if g%i==0:
        cd.append(i)
    i+=1
print (cd[-1*k])




Fixed submission:
import math
import fractions
a,b,k= [int(i) for i in input().split()]

g=fractions.gcd(a,b)

cd=list()
i=1
while i<=g:
    if g % i == 0:
        cd.append(i)
    i+=1
print (cd[ -1 * k ])
Buggy python submission (verdict: Runtime Error):
H = int(input())
A = int(input())
if H % A == 0:
  print(H//A)
else:
  print(H//A + 1)
return

Fixed submission:
D = list(map(int, input().split()))
H,A = D[0], D[1]

if( H%A == 0):
    print(H//A)
else:
    print(H//A + 1)
Buggy python submission (verdict: Time Limit Exceeded):
def attack(H):
    if(H == 1):
        return 1
    else:
        return 1 + attack(H//2) + attack(H//2)

H = int(input())
print(attack(H))


Fixed submission:
H = int(input())
i,result = 0, 0
while(H>0):
    result += 2**i
    i += 1
    H = H // 2
print(result)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().spit())
p=a*c
q=a*d
r=b*c
s=b*d
print(max(p,q,r,s))


Fixed submission:
a,b,c,d=map(int,input().split())
p=a*c
q=a*d
r=b*c
s=b*d
print(max(p,q,r,s))
Buggy python submission (verdict: Runtime Error):
d,t,s=input().split()
x=d/s
if x<=t:
  print("Yes")
else:
  print("No)


Fixed submission:
d,t,s=map(int,input().split())
x=d/s
if x<=t:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
d,t,s=map(int,input().split())
x=d/s
if x<=t:
  print("Yes")
else:
  print("No)

Fixed submission:
d,t,s=map(int,input().split())
x=d/s
if x<=t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
x = int(input())

if x == 0:
    print(1)
else
    print(0)

Fixed submission:
x = int(input())

if x == 0:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = map(int,input().split())

S = int()

for i in range(A):
    S = S + 1
    K = K - 1
    if K == 0:
        break

for i in range(B):
    if K == 0:
        break
    K = K -1

for i in range(C):
    if K == 0:
        break
    S = S - 1
    K = K - 1

print(S)

Fixed submission:
A,B,C,K = map(int,input().split())

S = int()

if K >= A:
    S = S + A
    K = K - A

    if K >= B:
        K = K - B

        if K > 0:
            S = S - K
            print(S)
        else:
            print(S)

    else:
        print(S)

else:
    S = S + K
    print(S)
Buggy python submission (verdict: Runtime Error):
N= int(input())
list1 =[]
list1 = list(map(int, input().split()))
sum = 0

print(list1)  
for i in range(N-1):
    for j in range(i+1,N):
        
        sum = sum + list1[i]*list1[j]
answer = divmod(sum, 10**9+7)
print(answer[1])


Fixed submission:
D, T, S = map(int, input().split())
if (T*S >=D):
    print("Yes")

else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
num = 0
K_s = len(str(K))
flg = 0

for i in range(K_s, 10**6):
    if K %2 == 0:
        print(-1)
        flg = 1
        break
    num = int(str(1)*i)
    if 7*num % K ==0:
        print(i)
        flg = 1
        break

if flg == 0:
    print(-1)




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