Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A, B, C, D = map(int, input().split())

    while True:
        Aoki_health = C-B
        Take_health = A-D
        if Take_health < 1 <= Aoki_health:
            print('No')
            break
        if Take_health >= 1 > Aoki_health:
            print('Yes')
            break


if __name__ == '__main__':
    main()

Fixed submission:
import math


def main():
    A, B, C, D = map(int, input().split())

    Takeshi = math.ceil(C/B)
    Aoki = math.ceil(A/D)

    print('Yes' if Takeshi<= Aoki else 'No')


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A, B, C, D = map(int, input().split())

    while True:
        Aoki_health = C-B
        Take_health = A-D
        if Take_health <= 0 < Aoki_health:
            print('No')
            break
        if Aoki_health <= 0 < Take_health: 
            print('Yes')
            break


if __name__ == '__main__':
    main()

Fixed submission:
import math


def main():
    A, B, C, D = map(int, input().split())

    Takeshi = math.ceil(C/B)
    Aoki = math.ceil(A/D)

    print('Yes' if Takeshi<= Aoki else 'No')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
---------------------------
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp

Fixed submission:
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
Buggy python submission (verdict: Runtime Error):
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1


Fixed submission:
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1
Buggy python submission (verdict: Runtime Error):
a = input()
if 'A' in a and 'B' in a:
    print("Yes")
else:
    print("No")
--------------------------------
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
---------------------------
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

1, 2 and 3
------------------------
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)

Fixed submission:
s = input()
q = int(input())
qs = [input().split() for i in range(q)]
n = False
left= right = ""
for operation in qs:
    if operation[0] == '1':
        n = not n
    if operation[0] == '2':
        t , f, c = operation
        f = int(f)
        if n:
            f = 1 if f != 1 else 2
        if f == 1:
            left=c+left
        elif f == 2:
            right+=c
s = left+s+right
print(s[::-1] if n else s)
Buggy python submission (verdict: Runtime Error):
H,A = map(int, input())
for i in range(H):
   H = H-4
   i += 1
   if H<= 0:
      break
print(i)

Fixed submission:
h, a = map(int, input().split())

i = 0

while h > 0:
    h = h - a
    i += 1

print(i)
Buggy python submission (verdict: Runtime Error):
a = it(input())
b = int(input())
if a > b:
    if a-1 == b and b > 1:
        print(a-b)
    elif a-1 == b:
        print(a+1)
    else:
        print(a-1)
else:
    if b-1 == a and a > 1:
        print(b-a)
    elif b-1 == a:
        print(b+1)
    else:
        print(b-1)

        

Fixed submission:
a = int(input())
b = int(input())
if a > b:
    if a-1 == b and b > 1:
        print(a-b)
    elif a-1 == b:
        print(a+1)
    else:
        print(a-1)
else:
    if b-1 == a and a > 1:
        print(b-a)
    elif b-1 == a:
        print(b+1)
    else:
        print(b-1)
Buggy python submission (verdict: Runtime Error):
N, X, T = map(int, input().split())

a = N // X
if N%X == 0
	min_T=T*a
else
	min_T = T*(a+1)

print(min_T)

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

a = N // X
if N%X == 0:
	min_T=T*a
else:
	min_T = T*(a+1)

print(min_T)

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

a = N // X
min_T = T*a

print(min_T)

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

a = N // X
if N%X == 0:
	min_T=T*a
else:
	min_T = T*(a+1)

print(min_T)

Buggy python submission (verdict: Runtime Error):
N = input()
X = input()
T = input()

a = N//X
min_T = T*a

print(min_T)

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

a = N // X
if N%X == 0:
	min_T=T*a
else:
	min_T = T*(a+1)

print(min_T)
Buggy python submission (verdict: Runtime Error):
s = string(input())
counter = 0

for i in range(3):
  print(s[i])
  if s[i]==1:
    counter+=1
print(counter)	

Fixed submission:
S = int(input())
c = 0

if S%10 == 1:
  c += 1
if S//100 == 1:
  c += 1
if (S//10)%10 == 1:
  c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
s = string(input())
counter = 0

for i in range(3):
  if s[i]==1:
    counter+=1
print(counter)

Fixed submission:
S = int(input())
c = 0

if S%10 == 1:
  c += 1
if S//100 == 1:
  c += 1
if (S//10)%10 == 1:
  c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
S = map(int, input().split())
c = 0

if S%10 == 1:
  c += 1
if S//100 == 1:
  c += 1
if (S//10)%10 == 1:
  c += 1
print(c)

Fixed submission:
S = int(input())
c = 0

if S%10 == 1:
  c += 1
if S//100 == 1:
  c += 1
if (S//10)%10 == 1:
  c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n= int(input())
s="abcdefghijklmnopqrstuvwxyz"
def fn(n):
  if(n<=26):
    return s[n-1]
  return f(n-1)//26+s[f(n-1)%26]
  
print(f(n))  

Fixed submission:
n = int(input())
ans = ''
while n > 0:
    n -= 1
    ans += chr(ord('a') + n % 26)
    n//= 26
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
#B
import sys
s=input()
t=input()
length=0
ans=[0]*(len(s)-len(t))
for i in range(len(s)-len(t)):
    for j in range(len(t)):
        if s[i+j]==t[j]:
            ans[i]+=1
print(len(t)-max(ans))


Fixed submission:
# B
import sys
s = input()
t = input()
length = 0
ans = [0]*(len(s)-len(t)+1)
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[i+j] == t[j]:
            ans[i] += 1
print(len(t)-max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
# C
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9+7
for i in range(n-1):
    for j in range(i+1, n):
        ans += (a[i]*a[j])
print(int(ans % mod))


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

# 累積和ベクトルbを作成
a.reverse()
b = [0]*n
b[0] = a[0]
for i in range(1, n):
    b[i] = b[i-1]+a[i]
a.reverse()
b.reverse()

ans = 0
for i in range(n-1):
    ans += a[i]*b[i+1]

print(ans % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
#C
# 7,77,777･･･=7*(1,11,111･･･)
# 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる
# 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが１だったら良い
import sys
k=int(input())
if k%7==0:
    k//=7
k*=9
a=10%k
for i in range(k*9):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)


Fixed submission:
#C
import sys
k=int(input())
s=0

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

Buggy python submission (verdict: Runtime Error):
#C
# 7,77,777･･･=7*(1,11,111･･･)
# 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる
# 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが１だったら良い
import sys
k=int(input())
if k%7==0:
    k/=7
k*=9
a=10%k
for i in range(k):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)


Fixed submission:
#C
import sys
k=int(input())
s=0

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

Buggy python submission (verdict: Runtime Error):
#C
# 7,77,777･･･=7*(1,11,111･･･)
# 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる
# 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが１だったら良い
import sys
k=int(input())
if k%7==0:
    k/=7
k*=9
a=10%k
for i in range(k*9):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)

Fixed submission:
#C
import sys
k=int(input())
s=0

for i in range(k):
    s=s*10+7
    if s%k!=0:
        s=s%k
    else:
        print(i+1)
        sys.exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    ans.append(ans[i - k] * a[i] // a[i - k])
    # print(ans)
    if ans[i - k] < ans[i - k + 1]:
        print("Yes")
    else:
        print("No")
    # print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    s = s * a[i] // a[i - k]
    ans.append(s)
    if ans[i - k] < ans[i - k + 1]:
        print("Yes")
    else:
        print("No")
    # print(ans)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    s = s * a[i] // a[i - k]
    ans.append(s)
    if ans[i - k] < ans[i - k + 1]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = 1
ans=[]
for i in range(k):
    s *= a[i]
ans.append(s)
for i in range(k, n):
    s = s * a[i] // a[i - k]
    ans.append(s)
    # print(ans)

for i in range(1, n - k + 1):
    if ans[i - 1] < ans[i]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

money = 1000

for i in range(n-1):
    s = 0
    if a[i] < a[i + 1]:
        s = money / a[i]:
    money += (a[i + 1] - a[i]) * s
print(money)

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

money = 1000

for i in range(n-1):
    s = 0
    if a[i] < a[i + 1]:
        s = money // a[i]
    money += (a[i + 1] - a[i]) * s
print(money)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
for i in range(n):
    count = 0
    for x in range(1, 101):
        for y in range(1, 101):
            for x in range(1, 101):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == (i + 1):
                    count += 1
    print(count)

Fixed submission:
l, r, d = map(int, input().split())
ans = 0
for i in range(l, r + 1):
    if i % d == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#D
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = 0
for i in range(1, n - n // 2 + 1):
    ans += a[i] * 2
ans-=a[n - n // 2 + 1]
print(ans)

Fixed submission:
#D
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
ans = [a[0]]
for i in range(1, n - n // 2 + 1):
    ans.append(a[i])
    ans.append(a[i])
print(sum(ans[:n - 1]))
Buggy python submission (verdict: Time Limit Exceeded):
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める
# >>
#等差数列の和(初項a:公差d:n番目の項まで)
def Sun_of_Arithmetic_sequence(a, d, n):
    return (2 * a + (n - 1) * d) * n // 2
    
ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += Sun_of_Arithmetic_sequence(i, i, m)
print(ans)

Fixed submission:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める

ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += m * (2 * i + i * (m - 1)) *0.5
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#D
n = int(input())
l = [0] *( n + 1)
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        l[j] += 1
ans = 0
for i in range(n + 1):
    ans += l[i] * i
print(ans)

Fixed submission:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める

ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += m * (2 * i + i * (m - 1)) *0.5
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
#D
n = int(input())
#公約数列挙
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ans = 0
for k in range(1, n + 1):
    ans += k * len(make_divisors(k))
print(ans)

Fixed submission:
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める

ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += m * (2 * i + i * (m - 1)) *0.5
print(int(ans))
Buggy python submission (verdict: Runtime Error):
# C
x, n = map(int, input().split())
p = list(map(int, input().strip().split()))
print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
        if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)


Fixed submission:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Buggy python submission (verdict: Runtime Error):
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Fixed submission:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Buggy python submission (verdict: Runtime Error):
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Fixed submission:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Buggy python submission (verdict: Runtime Error):
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p and abs(x - i) < abs(x - ans):
            ans = i
    print(ans)

Fixed submission:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b = 0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        b = -1
if ans == 0:#例外ans=0のときは途中で10^18を超えても0となる
    b = 0
if b == -1:#10^18を超えてる
    print(-1)
else:
    print(ans)


Fixed submission:
#B
n=int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
for i in a:
    ans *= i
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b=0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        ans = -1
if a == 0:
    print(-1)
else:
    print(ans)

Fixed submission:
#B
n=int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
for i in a:
    ans *= i
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D
from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ans = [0] * (n+1)
for i in range(m):
    ab.append([ab[i][1], ab[i][0]])
ab.sort(key=lambda x: x[0])
#BPS幅優先探索を行う -> 前の座標を記入
nque = deque([1])
while nque:
    now_cave = nque.popleft()
    for i in ab:
        next_cave = i[1]
        if i[0] == now_cave and ans[next_cave] == 0:
            ans[next_cave] = now_cave
            nque.append(next_cave)
print("Yes")
for i in range(2, n + 1):
    print(ans[i])


Fixed submission:
#D
from collections import deque
n, m = map(int, input().split())
ans = [0] * (n+1)
g = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)
#BPS幅優先探索を行う -> 前の座標を記入
nque = deque([1])
while nque:
    now_cave = nque.popleft()
    for next_cave in g[now_cave]:
        if ans[next_cave] == 0:
            ans[next_cave] = now_cave
            nque.append(next_cave)
#         print(nque)
# print(ans)
print("Yes")
for i in range(2, n + 1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
#D
n, k = map(int, input().split())
a = list(map(int, input().split()))
town = 1
for i in range(k):
    town = a[town-1]
print(town)

Fixed submission:
def f(x):
    return int(x)-1
n, k = map(int, input().split())
a = list(map(f, input().split()))
town = 0
i=0
l = [-1] * n
while True:
    if l[town] != -1:
        j = l[town]
        break
    i += 1
    l[town] += i
    town = a[town]
    # print(town,l)
# print(town)
if k >= i:
    k = (k - j) % (i - j) + j
print(l.index(k)+1)
Buggy python submission (verdict: Runtime Error):
#D
import math ,sys
x = int(input())
for a in range(math.ceil(math.log10(x))):
    for b in range(-10 ** 9//2, 10 ** 9//2):
        if s ** 5 - b ** 5 == x:
            print(a, b)
            sys.exit()

Fixed submission:
#D
import sys
x = int(input())

#-118<a<119 -119<b<118で全捜索
for a in range(-118, 120):
    for b in range(-119, 119):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
#D
a, b, n = map(int, input().split())
m = 0
for i in range(1,n+1):
    tmp = (a * i // b) - (a *( i // b))
    if m < tmp:
        m = tmp
print(m)

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

if n < b:
    print(a * n // b)
else:
    print(a * (b - 1) // b)
Buggy python submission (verdict: Time Limit Exceeded):
#D
s = input()
count = 0
for left in range(len(s) - 3):
    for right in range(left + 3, len(s)):
        if int(s[left:right + 1]) % 2019 == 0:
            count += 1
print(count)


Fixed submission:
s = input()
ans = 0
a = [0] * 2019
a[0] = 1
k = 0
mod = 1
for i in range(len(s) - 1, -1, -1):
    k = (k + int(s[i]) * mod) % 2019
    mod = (mod * 10) % 2019
    a[k] += 1
for i in a:
    ans += i * (i - 1) * 0.5
print(int(ans))

Buggy python submission (verdict: Runtime Error):
#D
s = input()
count = 0
# print(len(s))
for left in range(len(s) - 3):
    for right in range(left + 3, len(s)):
        print(left + 1, right + 1)
        if int(float(s[left:right + 1])) % 2019 == 0:
            print(s[left:right])
            count += 1
print(count)

Fixed submission:
s = input()
ans = 0
a = [0] * 2019
a[0] = 1
k = 0
mod = 1
for i in range(len(s) - 1, -1, -1):
    k = (k + int(s[i]) * mod) % 2019
    mod = (mod * 10) % 2019
    a[k] += 1
for i in a:
    ans += i * (i - 1) * 0.5
print(int(ans))

Buggy python submission (verdict: Runtime Error):
#D
s = input()
count = 0
# print(len(s))
for left in range(len(s) - 1):
    for right in range(left + 1, len(s)):
        # print(left + 1, right + 1)
        if int(float(s[left:right+1])) % 2019 == 0:
            # print(s[left:right])
            count += 1
print(count)

Fixed submission:
s = input()
ans = 0
a = [0] * 2019
a[0] = 1
k = 0
mod = 1
for i in range(len(s) - 1, -1, -1):
    k = (k + int(s[i]) * mod) % 2019
    mod = (mod * 10) % 2019
    a[k] += 1
for i in a:
    ans += i * (i - 1) * 0.5
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
#C
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
k=int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for k in range(1, k + 1):
            ans += gcd(gcd(i, j), k)
print(ans)

Fixed submission:
#C
import math
k = int(input())
ans = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        ij = math.gcd(i, j)
        for l in range(1, k + 1):
            ans += math.gcd(l, ij)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#D
import sys
k = int(input())
count = 0
i=1
while count != k:
    a = str(i)
    b=True
    for j in range(len(a)-1):
        if int(a[j + 1]) == int(a[j]) + 1 or int(a[j]) == int(a[j + 1]) + 1 or int(a[j]) == int(a[j + 1]):
            pass
        else:
            b=False
    if b:
        count += 1
    i+=1
print(i-1)

Fixed submission:
#D
from collections import deque
import sys
k=int(input())
que = deque()
count=0
for i in range(1, 10):  #1~9まで
    que.append(i)
    count += 1
    if count == k:
        print(que.pop())
        sys.exit()
# print(que)
# print(count)
while True:
    tmp = que.popleft()  #データを左から取り出す
    tmp = tmp * 10 + tmp % 10  #中心整数を求める 中心整数＋下一桁
    if tmp % 10 != 0:  #下一桁目が0でない場合
        que.append(tmp- 1)
        count += 1
        # print(count)
        if count == k:
            break
    que.append(tmp)
    count += 1
    # print(count)
    if count == k:
        break
    if tmp % 10 != 9:
        que.append(tmp + 1)
        count += 1
        # print(count)
        if count == k:
            break
    # print(que)
print(que.pop())