Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def match(c1, c2):
    return c1 == "?" or c2 == "?" or c1 == c2

M = 2000
a = input().rstrip()
b = input().rstrip()
c = input().rstrip()
A = len(a)
B = len(b)
C = len(c)

ab = [False] * 20000
ac = [False] * 20000
bc = [False] * 20000

for i in range(A):
    for j in range(B):
        if not match(a[i], b[j]):
            ab[i - j + 10000] = True
for i in range(A):
    for j in range(C):
        if not match(a[i], c[j]):
            ac[i - j + 10000] = True
for i in range(B):
    for j in range(C):
        if not match(b[i], c[j]):
            bc[i - j + 10000] = True

ans = 3 * M
for i in range(-2 * M, 2 * M + 1):
    for j in range(-2 * M, 2 * M + 1):
        if not ab[i + 10000] and not ac[j + 10000] and not bc[j - i + 10000]:
            print("match", i, j)
            l = min(0, min(i, j))
            r = max(A, min(B + i, C + j))
            ans = min(ans, r - l)
            print("ans", ans)

print(ans)

Fixed submission:
def match(c1, c2):
    return c1 == "?" or c2 == "?" or c1 == c2

M = 2000
a = input().strip()
b = input().strip()
c = input().strip()
A = len(a)
B = len(b)
C = len(c)

ab = [0] * 20000
ac = [0] * 20000
bc = [0] * 20000

for i in range(A):
    for j in range(B):
        if not match(a[i], b[j]):
            ab[i - j + 10000] = 1
for i in range(A):
    for j in range(C):
        if not match(a[i], c[j]):
            ac[i - j + 10000] = 1
for i in range(B):
    for j in range(C):
        if not match(b[i], c[j]):
            bc[i - j + 10000] = 1

ans = A + B + C
for i in range(-2 * M, 2 * M + 1):
    for j in range(-2 * M, 2 * M + 1):
        if (not ab[i + 10000]) and (not ac[j + 10000]) and (not bc[j - i + 10000]):
            l = min(0, i, j)
            r = max(A, B + i, C + j)
            ans = min(ans, r - l)

print(ans)
Buggy python submission (verdict: Runtime Error):
a_s = sorted(enumerate(map(int, raw_input().split())), key=lambda t: t[1])
b_s = sorted(enumerate(map(int, raw_input().split())), key=lambda t: t[1])
w = [[0] * B] * A
max_w = 0
for _ in xrange(M):
    x, y, c = map(int, raw_input().split())
    w[x-1][y-1] = c
    max_w = max(max_w, c)

cost = 10 ** 20
for i, a in a_s:
    if a + b_s[0][1] - max_w > cost:
        break
    for j, b in b_s:
        cost = min(cost, a + b - w[i][j])
        if a + b - max_w > cost:
            break

print cost

Fixed submission:
A, B, M = map(int, raw_input().split())
a_s = map(int, raw_input().split())
b_s = map(int, raw_input().split())
w = [[0] * B] * A
cost = 10 ** 30
for _ in xrange(M):
    x, y, c = map(int, raw_input().split())
    cost = min(cost, a_s[x-1] + b_s[y-1] - c)
    w[x-1][y-1] = max(w[x-1][y-1], c)

a_s = sorted(enumerate(a_s), key=lambda t: t[1])
b_s = sorted(enumerate(b_s), key=lambda t: t[1])
for i, a in a_s:
    if a + b_s[0][1] >= cost:
        break
    for j, b in b_s:
        if w[i][j] > 0:
            break
        cost = min(cost, a + b)

print cost
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = list(map(int, input().split()))

dp = [0] * n

for i in a:
  b[i-1] += 1
  
for _ in b:
  print(_)
  

Fixed submission:
n = int(input())
a = [int(n) for n in input().split()]
 
b = [0] * n
 
for i in a:
    b[i-1] += 1
 
for i in b:
    print(i)
Buggy python submission (verdict: Runtime Error):
s,w = map(int,input().split())

if s >= w :
  print(safe)
else:
  print(unsafe)

Fixed submission:
s,w = map(int,input().split())

if s > w :
  print("safe")
else:
  print("unsafe")
Buggy python submission (verdict: Runtime Error):
import math

a = (int)input()
print(2*math.pi*a)

Fixed submission:
import math

a = int(input())
print(2*a*math.pi)

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

int a = input()
print(2*a*math.pi)

Fixed submission:
import math

a = int(input())
print(2*a*math.pi)

Buggy python submission (verdict: Runtime Error):
import math.h

int a=input()
print(a*math.pi)

Fixed submission:
import math

a = int(input())
print(2*a*math.pi)
Buggy python submission (verdict: Runtime Error):
n,m = input().split();
a = input().split();

a_sum = sum(a);

if n - a_sum < 0:
    print(-1)
else:
    print(n-a_sum)
    


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

a_sum = sum(a);

if n - a_sum < 0:
    print(-1)
else:
    print(n-a_sum)

Buggy python submission (verdict: Runtime Error):
n,m = input().split();
a = input().split();

a_sum = sum(a);

rest_day = int(n) - a_sum

if rest_day < 0:
    rest_day = -1

return rest_day
    

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

a_sum = sum(a);

if n - a_sum < 0:
    print(-1)
else:
    print(n-a_sum)

Buggy python submission (verdict: Runtime Error):

n,m = input().split();
a = input().splite();

a_sum = sum(a);

rest_day = int(n) - a_sum

if rest_day < 0:
    rest_day = -1

return rest_day

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

a_sum = sum(a);

if n - a_sum < 0:
    print(-1)
else:
    print(n-a_sum)

Buggy python submission (verdict: Runtime Error):

n,m = input().split();
a = input().splite();

a_sum = sum(a);

rest_day = n - a_sum

if rest_day > 0:
    return rest_day
else: return -1


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

a_sum = sum(a);

if n - a_sum < 0:
    print(-1)
else:
    print(n-a_sum)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
l_input = [int(e) for e in input().split()]
N = l_input[0]
K = l_input[1]
result = [N]
for i in range(1000000000000000000000000000000):
    result.append(abs(result[i]-K))
    ans = result[i+1] in result
    if result[i+1] < K/2:
        break
print(min(result))

Fixed submission:
import numpy as np
l_input = [int(e) for e in input().split()]
N = l_input[0]
K = l_input[1]
result = [N%K]
for i in range(1000000000000000000000000000000):
    result.append(abs(result[i]-K))
    ans = result[i+1] in result
    if result[i+1] < K/2:
        break
print(min(result))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = str(input())
T = str(input())
ans = ''
for i in range(N):
    ans = ans + S[i:i+1] + T[i:i+1]
print(ans)

Fixed submission:
N = int(input())
Str_input = str(input())
S = Str_input.split()[0]
T = Str_input.split()[1]
ans = ''
for i in range(N):
    ans = ans + S[i:i+1] + T[i:i+1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[int(input()) for i in range(n)]
S=list(set(s))
print(len(S))

Fixed submission:
n=int(input())
s=[input() for i in range(n)]
S=list(set(s))
print(len(S))
Buggy python submission (verdict: Runtime Error):
string=inout()
t=False
for i in range (len(string)):
  if string[i]==7:
    t=True
if t==True:
  print("YES")
else:
  print("NO")

Fixed submission:
string=input()
if "7" in string:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
n1=(n-1)/2
n2=(n+1)/2
s1=s[0:n1]
s2=s[n2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
n=len(s)
s1=s[0:(n-1)//2]
s2=s[(n+1)//2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
s1=s[0:(n-1)/2]
s2=s[(n+1)/2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
n=len(s)
s1=s[0:(n-1)//2]
s2=s[(n+1)//2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
s1=s[0:(n-3)/2]
s2=s[(n+1)/2:n-1]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
n=len(s)
s1=s[0:(n-1)//2]
s2=s[(n+1)//2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=input()
if n%2==0:
  print(n/2)
if n%2==1:
  print((n+1)/2)

Fixed submission:
n=int(input())
if n%2==0:
  print(int(n/2))
elif n%2==1:
  print(int((n+1)/2))

Buggy python submission (verdict: Runtime Error):
n=inout()
if n%2==0:
  print(n/2)
if n%2==1:
  print((n+1)/2)

Fixed submission:
n=int(input())
if n%2==0:
  print(int(n/2))
elif n%2==1:
  print(int((n+1)/2))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
checker=0
count=0
for i in range(len(a)):
  if a[i]%2==0:
    checker+=1
    if a[i]%3==0 or a[i]%5==0:
      count+=1
if checker==count:
  print("APPROVED")
else:
  print("DENIED)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
checker=0
count=0
for i in range(len(a)):
  if a[i]%2==0:
    checker+=1
    if a[i]%3==0 or a[i]%5==0:
      count+=1
if checker==count:
  print("APPROVED")
else:
  print("DENIED")
Buggy python submission (verdict: Runtime Error):
h,n=map(int,input().split())
a=list(map(int,input().split())
if sum(a)>=h:
  print("Yes")
else:
  print("No")

Fixed submission:
h,n=map(int,input().split())
a=list(map(int,input().split()))
if sum(a)>=h:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
for i in range(len(alphabet)):
  if alphabet[i]=＝letter:
    print(alphabet[i+1])

Fixed submission:
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
for i in range(len(alphabet)):
  if alphabet[i]==letter:
    print(alphabet[i+1])

Buggy python submission (verdict: Runtime Error):
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
for i in range(len(alphabet)):
  if alphabet[i]=letter:
    print(alphabet[i+1])

Fixed submission:
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
for i in range(len(alphabet)):
  if alphabet[i]==letter:
    print(alphabet[i+1])

Buggy python submission (verdict: Runtime Error):
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
alphabet[i]=letter
print(alphabet[i+1])

Fixed submission:
letter=input()
alphabet="abcdefghijklmnopqrstuvwxyz"
for i in range(len(alphabet)):
  if alphabet[i]==letter:
    print(alphabet[i+1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
count=0
for i in range(len(n)-2):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    count+=1
print(count)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(n-2):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
count=0
for i in range(len(n)-3):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    count+=1
print(count)

Fixed submission:
n=int(input())
s=input()
count=0
for i in range(n-2):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
print(input().count(1))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
print(input().count(1)

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())

if n%2==1:
  print('No')
else:
  if s[:n/2]==s[n/2:]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n = int(input())
s = str(input())
t = int(n/2)

if n%2==1:
  print('No')
else:
  if s[:t]==s[t:]:
    print('Yes')
  else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

if n%2==1:
  print('No')
else:
  if s[:n/2]==s[n/2:]:
    print('Yes')
  else:
    print('No')

Fixed submission:
n = int(input())
s = str(input())
t = int(n/2)

if n%2==1:
  print('No')
else:
  if s[:t]==s[t:]:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from math import sqrt
from math import factorial
n = int(input())
t = []
for i in range(n):
  t.append(list(map(int,input().split())))
l = [[0]*n for j in range(n)]
for k in range(n):
  for m in range(n):
    if k != m:
      d = sqrt((t[k][0]-t[m][0])**2+(t[k][1]-t[m][1])**2)
      l[k][m] = d
print(int(sum(l)*factorial(n-2)*2/n))

Fixed submission:
from math import sqrt
from math import factorial
 
n = int(input())
t = []
for i in range(n):
  t.append(list(map(int,input().split())))
l = [[0]*n for j in range(n)]
for k in range(n):
  for m in range(n):
      l[k][m] = sqrt((t[k][0]-t[m][0])**2+(t[k][1]-t[m][1])**2)
ans = 0
for i in range(n):
  s = sum(l[i])
  ans += s*factorial(n-1)
z = ans/factorial(n)
print(z)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%2 = 0:
  answer = n/2-1
else:
  answer = (n-1)/2
print(answer)

Fixed submission:
n = int(input())
if n%2 == 0:
  ans = int(n/2 - 1)
else:
  ans = int((n-1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input()))
b = list(map(int,input()))
c = list(map(int,input()))

ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i != n-1 and a[i+1]-a[i] == 1:
    ans += c[a[i]-1]
print(ans)

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

ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i != n-1 and a[i+1]-a[i] == 1:
    ans += c[a[i]-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
s = input()
ans = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    ans += 1
while True:
  for i in range(k):
    if ans < n-2:
      ans += 2
    if ans == n-2:
      ans += 1
    else:
      break
print(ans)

Fixed submission:
n, k = map(int,input().split())
s = input()
ans = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    ans += 1
for i in range(k):
  if ans < n-2:
    ans += 2
  elif ans == n-2:
    ans += 1
  else:
    pass
print(ans)
Buggy python submission (verdict: Runtime Error):
S = list(map(int,input().split()))
L = list(map(int,input().split()))
n = 0
for i in range(3):
  if S[i] == L[i]:
    n += 1
print(n)

Fixed submission:
S = input()
L = input()
n = 0
for i in range(3):
  if S[i] == L[i]:
    n += 1
print(n)

Buggy python submission (verdict: Runtime Error):
S = list(map(int,input()split()))
L = list(map(int,input()split()))
n = 0
for i in range(3):
  if S[i] == L[i]:
    n += 1
print(n)

Fixed submission:
S = input()
L = input()
n = 0
for i in range(3):
  if S[i] == L[i]:
    n += 1
print(n)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
l =[0]
k = 0
for i in range(n):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = [0]
k = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
l =[]
k = 0
for i in range(n):
  if a[i]>=a[i-1]:
    if not l[k]:
      l.append(1)
    else:
      l[k] += 1
  else:
    k += 1
print(max(l))
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = [0]
k = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
l =[]
k = 0
for i in range(n):
  if a[i]>=a[i-1]:
    if l[k]:
      l[k] += 1
    else:
      l.append(1)
  else:
    k += 1
print(max(l))
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = [0]
k = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input()split()))
l =[]
k = 0
for i in range(n):
  if a[i]>=a[i-1]:
    l[k] += 1
  else:
    k += 1
print(max(l))
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = [0]
k = 0
for i in range(n-1):
  if a[i]>=a[i+1]:
    l[k] += 1   
  else:
    k += 1
    l.append(0)
print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 0
for i in range(n):
  a += i
print(a)

Fixed submission:
n = int(input())
a = n*(n-1)//2
print(a)

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

Fixed submission:
n = int(input())
a = n*(n-1)//2
print(a)

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

Fixed submission:
n = int(input())
a = n*(n-1)//2
print(a)

Buggy python submission (verdict: Runtime Error):
n = int(input)
print(sum([i for i in range(n)]))

Fixed submission:
n = int(input())
a = n*(n-1)//2
print(a)
Buggy python submission (verdict: Runtime Error):
# 1行目の入力を空白で分割された数値として扱う
N, X, Y = map(int, input().split())

# 最短経路のリスト
min = []
ans = []

# 距離の取得
for i in range(0, N -1):
    d = A[i+1] - A[i]
    ans += d
    if d > max:
        max = d

# 一周した最後
dl = K - A[N - 1]
if dl < max:
    ans = ans - max + dl + A[0]

# 出力
for j in range(0, N -1):
    print(ans[j])


Fixed submission:
# 1行目の入力を空白で分割された数値として扱う
K, N = map(int, input().split())
# 2行目の入力を数値のリストとして扱う
A = list(map(int, input().split()))

# 答えの準備
ans = 0
max = 0

# 距離の取得
for i in range(0, N -1):
    d = A[i+1] - A[i]
    ans += d
    if d > max:
        max = d

# 一周した最後
dl = K - A[N - 1]
if dl + A[0] < max:
    ans = ans - max + dl + A[0]

# 出力
print(ans)
Buggy python submission (verdict: Runtime Error):
s,w = map(int,input().split())
if s>w:
  print('safe')
 else:
  print('unsafe')

Fixed submission:
s,w = map(int,input().split())
if s>w:
  print('safe')
else:
  print('unsafe')
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
r1 = a//d
rem1 = a%d
r2 = c//b
rem2 = c%b
if r1>=r2:
  print('Yes')
 else:
  print('No')

Fixed submission:
a,b,c,d = map(int,input().split())
r1 = a//d
if a%d==0:
  pass
else:
  r1 += 1
r2 = c//b
if c%b==0:
  pass
else:
  r2 += 1
if r1>=r2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if x + y > s:
            continue
        for z in r:
            if x + y + z == s:
                cnt += 1

print(cnt)


Fixed submission:
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if s - k <= x + y <= s:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

li = [1 for x in range(0, k + 1) for y in range(0, k + 1) for z in range(0, k + 1) if x + y + z == s]
print(len(li))


Fixed submission:
k, s = map(int, input().split())
r = range(0, k + 1)
cnt = 0
for x in r:
    for y in r:
        if s - k <= x + y <= s:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
elif:
  print('Even')

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if x * y % 2 = 1:
  print('Odd')
elif
  print('Even')

Fixed submission:
x, y = map(int, input().split())
if x * y % 2:
  print('Odd')
else:
  print('Even')
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
ichi = y // 10000

for i in reversed(range(ichi + 1)):
    gos = (y - 10000 * ichi) // 5000
    for j in reversed(range(gos+1)):
        rest = y - 10000 * i - 5000 * j
        k = n - i - j
        if rest % 1000 == 0 and rest // 1000 = k:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)


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

for i in reversed(range(n + 1)):
    for j in reversed(range(n - i + 1)):
        k = n - i - j
        if 10000 * i + 5000 * j + 1000 * k == y:
            print(i, j, k)
            exit()
else:
    print(-1, -1, -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = []
for i in range(n):
  s = input()
  if s not in l:
    l.append(s)
print(len(l))

Fixed submission:
n = int(input())
l = []
for i in range(n):
  s = input()
  l.append(s)
print(len(set(l)))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
for j in range(1,N+1):
    s = int(S[N-j:N])
    exist[s%2019] += 1
for e in exist[1:]:
    if e > 1:
        count += e-1
count += exist[0]
print(count)


Fixed submission:
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
sum = 0
for i, s in enumerate(reversed(S)):
    sum += (int(s) * pow(10, i, 2019)) % 2019
    exist[sum % 2019] += 1
for e in exist:
    if e > 1:
        count += e*(e-1)//2
count += exist[0]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
for j in range(3, len(S)+1):
    for i in range(j):
        s = int(S[i:j])
        if s % 2019 == 0:
            count += 1
print(count)


Fixed submission:
S = input()
count = 0
exist = [0]*2019
flg = False
N = len(S)
sum = 0
for i, s in enumerate(reversed(S)):
    sum += (int(s) * pow(10, i, 2019)) % 2019
    exist[sum % 2019] += 1
for e in exist:
    if e > 1:
        count += e*(e-1)//2
count += exist[0]
print(count)
Buggy python submission (verdict: Runtime Error):
import math
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minA = math.inf
minB = math.inf
for reizou in a:
    if reizou < minA:
        minA = reizou
for renzi in b:
    if renzi < minB:
        minB = renzi
min = minA + minB
for i in range(M):
    x,y,c = map(int,input().split())
    sum = a[x-1] + b[y-1] - c
    if sum < min:
        min = sum

print(sum)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minA = a[0]
for reizou in a[1:]:
    if reizou < minA:
        minA = reizou
minB = b[0]
for renzi in b:
    if renzi < minB:
        minB = renzi
kakaku = minA + minB
for i in range(M):
    x,y,c = map(int,input().split())
    sumKakaku = a[x-1] + b[y-1] - c
    if sumKakaku < kakaku:
        kakaku = sumKakaku

print(kakaku)