Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#AGC34 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
t = ''
i = 0
while i < n-1:
    if s[i:i+2] == 'BC':
        t += 'D'
        i += 2
    else:
        t += s[i]
        i += 1
m = len(t)
ans = 0
a,d = 0,0
for i in range(m):
    if t[i] == 'A':
        a += 1
    elif t[i] == 'D':
        ans += a
        d += 1
    else:
        a,d = 0,0
print(ans)


Fixed submission:
#!/usr/bin/env python3
#AGC34 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
t = ''
i = 0
while i < n-1:
    if s[i:i+2] == 'BC':
        t += 'D'
        i += 2
    else:
        t += s[i]
        i += 1
m = len(t)
ans = 0
a,d = 0,0
for i in range(m):
    if t[i] == 'A':
        a += 1
    elif t[i] == 'D':
        ans += a
    else:
        a,d = 0,0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

idl = []
idr = []

for i in range(m):
    a,b = list(map(int,input().split(" ")))
    idl.append(a)
    idr.append(b)

ans  = 0

for i in range(n):
    flg = 0
    for j in range(m):
        if idl[j] <= i+1 <= idr[j]:
            pass
        else:
            flg = 1
    if flg == 0:
        ans += 1
print(ans)

Fixed submission:
#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

s = 0
t = 10**5+1
for i in range(m):
    a,b = list(map(int,input().split(" ")))
    if s < a:
        s = a
    if b < t:
        t = b
if t < s:
    print(0)
else:
    print(t-s+1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

A = list(map(int,input().split(" ")))
A.sort()
#print(A)
B = []
C = []

for i in range(m):
    b,c = list(map(int,input().split(" ")))
    for j in range(b):
        if A[j] < c:
            A[j] = c
        else:
            break
    A.sort()
    #print(A)
print(sum(A))

Fixed submission:
#!/usr/bin/env python3

import math

n,m = list(map(int,input().split(" ")))

A = list(map(int,input().split(" ")))
#print(A)
s = []
t = []
u = []
for i in range(m):
    b,c = list(map(int,input().split(" ")))
    t.append((c,b))
t.sort()
#print(t)
#print(t[-1][0])
for i in range(n):
    if A[i] < t[-1][0]:
        u.append(A[i])
    else:
        s.append(A[i])
#print(u)
#print(s)
u.sort()
#print(u)
x = 0
y = 0
ans = 0
count = 0
for i in range(len(u)):
    #print(x,y)
    if u[i] < t[-x-1][0]:
        u[i] = t[-x-1][0]
    if i == y + t[-x-1][1] - 1:
        x += 1
        y += i+1 - y
        if x == len(t):
            break
#print(u)
ans += sum(s)
ans += sum(u)
print(ans)
Buggy python submission (verdict: Runtime Error):
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = input()

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1] = alpha1[t]
print(s)


Fixed submission:
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = list(input())

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1]=alpha1[t]
for i in range(n):
  print(s[i],end="")

Buggy python submission (verdict: Runtime Error):
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split()))
s = input()

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1] = alpha1[t]
print(s)


Fixed submission:
alpha1='abcdefghijklmnopqrstuvwxyz'
alpha2='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n,k = list(map(int,input().split(" ")))
s = list(input())

for i in range(26):
  if alpha2[i] == s[k-1]:
    t = i
    break
s[k-1]=alpha1[t]
for i in range(n):
  print(s[i],end="")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#B
import numpy as np
import math
import re
     
a,b,c,n = list(map(int,re.split(" ",input())))
N = n
s = []
s.append(a)
s.append(b)
s.append(c)
s.sort()
a,b,c = s
#print(a,b,c)
ans = 0
for i in range(int(N/c)+1):
  for j in range(int((N-i*c)/b)+1):
	if (N - i*c  - j*b)%a == 0:
		ans += 1
print(ans)


Fixed submission:
import re
         
a,b,c,n = list(map(int,re.split(" ",input())))
N = n
s = []
s.append(a)
s.append(b)
s.append(c)
s.sort()
a,b,c = s
#print(a,b,c)
ans = 0
for i in range(int(N/c)+1):
  for j in range(int((N-i*c)/b)+1):
      if (N - i*c  - j*b)%a == 0:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
ans = 0
lst = ['A','T','G','C']
for i in range(n):
    if s[i] not in lst:
        continue
    for j in range(i+1,n):
        if s[j] not in lst:
            break
    ans = max(ans,j-i)
print(ans)

Fixed submission:
#!/usr/bin/env python3

a = input()

l = ["A","T","G","C"]
count  = 0
max = 0
t = 0
for i in range(len(a)):
    for j in range(i,len(a)):
        if(a[j] not in l):
            count = 0
            break;
        else:
            count += 1
            if(max < count):
                max = count
    count = 0
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC122 C

n,q = map(int,input().split())
s = list(input())
t = ["0" for _ in range(n)]

for i in range(n):
    if i < n-1:
        if s[i] == 'A':
            if s[i+1] == 'C':
                t[i] = 'a'
ans = []
for _ in range(q):
    l,r = map(int,input().split())
    c = t[l-1:r-1].count("a")
    ans.append(c)
for i in range(q):
    print(ans[i])


Fixed submission:
#!/usr/bin/env python3
#ABC122 C

n,q = map(int,input().split())
s = input()
t = [0 for _ in range(n+1)]

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] =='AC' else 0)

for _ in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC122 C

n,q = map(int,input().split())
s = list(input())
def check(x):
    sum = 0
    i = 0
    while i < len(x):
        if i < len(x)-1:
            if x[i] == 'A':
                if x[i+1] == 'C':
                    sum += 1
                    i += 1
        i += 1
    return sum
ans = []
for _ in range(q):
    l,r = map(int,input().split())
    ans.append(check(s[l-1:r]))
for i in range(q):
    print(ans[i])


Fixed submission:
#!/usr/bin/env python3
#ABC122 C

n,q = map(int,input().split())
s = input()
t = [0 for _ in range(n+1)]

for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] =='AC' else 0)

for _ in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#AGC31 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = [I() for _ in range(n)]
dp1,dp2 = [0]*(n+1),[0]*(max(c)+1)
dp1[0] = 1
for i in range(n):
    if dp2[c[i]] == 0:
        dp1[i+1] = dp1[i]
        dp2[c[i]] += dp1[i+1]
        dp2[c[i]] %= mod
    else:
        if c[i] == c[i-1]:
            dp1[i+1] = dp1[i]
            dp2[c[i]] += dp1[i+1]
            dp2[c[i]] %= mod
            continue
        dp1[i+1] += dp1[dp2[c[i]]+1]
        dp1[i+1] += dp1[i]
        dp2[c[i]] += dp1[i+1]
        dp2[c[i]] %= mod
        dp1[i+1] %= mod
print(dp1[-1] % mod)


Fixed submission:
#!/usr/bin/env python3
#AGC31 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
c = [I() for _ in range(n)]
dp1,dp2 = [0]*(n+1),[0]*(max(c)+1)
dp1[0] = 1
for i in range(n):
    if dp2[c[i]] == 0:
        dp1[i+1] = dp1[i]
        dp2[c[i]] = dp1[i]
        dp2[c[i]] %= mod
    else:
        if c[i] == c[i-1]:
            dp1[i+1] = dp1[i]
            continue
        dp1[i+1] += dp2[c[i]]
        dp1[i+1] += dp1[i]
        dp2[c[i]] += dp1[i]
        dp2[c[i]] %= mod
        dp1[i+1] %= mod
print(dp1[-1] % mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC121 D

A,B = map(int,input().split())

s = A
for i in range(A+1,B+1):
    s = s^i
print(s)


Fixed submission:
#!/usr/bin/env python3
#ABC121 D

A,B = map(int,input().split())

if A % 2 == 0 and B % 2 == 0:
    s = 1
elif A % 2 == 0 and B % 2 == 1:
    s = 2
elif A % 2 == 1 and B % 2 == 0:
    s = 3
elif A % 2 == 1 and B % 2 == 1:
    s = 4
if s == 1:
    if ((B - A)/2) % 2 == 1:
        print(1^B)
    else:
        print(0^B)
elif s == 2:
    if ((B - A+1)/2) % 2 == 1:
        print(1)
    else:
        print(0)
elif s == 3:
    if ((B - A-1)/2) % 2 == 1:
        print(A^1^B)
    else:
        print(A^B)
else:
    if ((B - A)/2) % 2 == 1:
        print(A^1)
    else:
        print(A^0)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC119 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


a,b,q = map(int,input().split())
s = [-float('inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [-float('inf')] + [int(input()) for _ in range(b)] + [float('inf')]

for _ in range(q):
    x = int(input())
    sr,tr = bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    ans = float('inf')
    for S in [s[sr-1],s[sr]]:
        for T in [t[tr-1],t[tr]]:
            d1,d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC119 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


a,b,q = map(int,input().split())
s = [-float('inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [-float('inf')] + [int(input()) for _ in range(b)] + [float('inf')]

for _ in range(q):
    x = int(input())
    sr,tr = bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    ans = float('inf')
    for S in [s[sr-1],s[sr]]:
        for T in [t[tr-1],t[tr]]:
            d1,d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#ABC118 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

M = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = list(map(int,input().split()))
A = [[i,M[i]] for i in a]
A.sort(key = itemgetter(1))

#dp[i] := ちょうどマッチi本を使ってできる最大桁数
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(n):
    for j,k in A:
        if i + k < n+1:
            if dp[i] < 0:
                continue
            dp[i+k] = dp[i] + 1
A.sort(key = itemgetter(0),reverse = True)
ans = ''
k = n
while 1:
    for i,j in A:
        if dp[k-j] == dp[k]-1:
            ans += str(i)
            k -= j
            break
    else:
        break
print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC118 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

M = [0,2,5,5,4,5,6,3,7,6]
n,m = map(int,input().split())
a = list(map(int,input().split()))
A = [[i,M[i]] for i in a]
A.sort(key = itemgetter(1))

#dp[i] := ちょうどマッチi本を使ってできる最大桁数
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(n):
    for j,k in A:
        if i + k < n+1:
            if dp[i] < 0:
                continue
            dp[i+k] = dp[i] + 1
A.sort(key = itemgetter(0),reverse = True)
ans = ''
k = n
while 1:
    for i,j in A:
        if k - j < 0:
            continue
        if dp[k-j] == dp[k]-1:
            ans += str(i)
            k -= j
            break
    else:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC117 C

n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
#print(x)
if n >= m:
    print(0)
    quit()
y = [x[i+1]-x[i] for i in range(m-1)]
#print(y)
for i in range(n-1):
    y.remove(max(y))
print(sum(y))


Fixed submission:
#!/usr/bin/env python3
#ABC117 C

n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
#print(x)
if n >= m:
    print(0)
    quit()
y = [x[i+1]-x[i] for i in range(m-1)]
y.sort()
y.reverse()
#print(y)
print(sum(y[n-1:]))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#dp6 #Longest-Path

import sys
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
def g():
    def dfs(x):
        #既に最長パスがわかっている頂点はそれを返す
        if dp[x] != None:
            return dp[x]
        #移動できる頂点がないとき0
        if len(Graph[x]) == 0:
            dp[x] = 0
            return 0
        else:
            res = 0
            #移動できる頂点の中で最大パスをもつものを探す
            for y in Graph[x]:
                res = max(res,dfs(y)+1)
            dp[x] = res
            return dp[x]

    n,m = LI()
    #dpで各頂点を始点とした最大パスを管理
    dp = [None for _ in range(n)]
    Graph = [[] for _ in range(n)]
    for _ in range(m):
        x,y = LI()
        Graph[x-1].append(y-1)
    #各頂点を始点として最大パスを探す
    for i in range(n):
        dfs(i)
    print(max(dp))
if __name__ == '__main__':
    g()


Fixed submission:
#!/usr/bin/env python3
#dp6 #Longest-Path

import sys
sys.setrecursionlimit(10000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]
def g():
    def dfs(x):
        #既に最長パスがわかっている頂点はそれを返す
        if dp[x] != None:
            return dp[x]
        #移動できる頂点がないとき0
        if len(Graph[x]) == 0:
            dp[x] = 0
            return 0
        else:
            res = 0
            #移動できる頂点の中で最大パスをもつものを探す
            for y in Graph[x]:
                res = max(res,dfs(y)+1)
            dp[x] = res
            return dp[x]

    n,m = LI()
    #dpで各頂点を始点とした最大パスを管理
    dp = [None for _ in range(n)]
    Graph = [[] for _ in range(n)]
    for _ in range(m):
        x,y = LI()
        Graph[x-1].append(y-1)
    #各頂点を始点として最大パスを探す
    for i in range(n):
        dfs(i)
    print(max(dp))
if __name__ == '__main__':
    g()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
#dp9 #Sushi

import sys
import bisect
input = sys.stdin.readline
def LI(): return list(map(int,input().split()))
def LIR(n): return [LI() for _ in range(n)]

def J():
    n = int(input())
    a = LI()
    a.sort()
    one = bisect.bisect_right(a,1)
    two = bisect.bisect_right(a,2) - one
    three = n - one - two

    #dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から
    #               寿司をすべてなくすのに必要な操作回数の期待値
    dp = [[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
    for k in range(three+1):
        for j in range(two+three+1 - k):
            for i in range(one+two+three+1-k-j):
                if i == 0 and j == 0 and k == 0:
                    continue
                tmp = n*1.0
                if i > 0:
                    tmp += i*dp[i-1][j][k]
                if j > 0:
                    tmp += j*dp[i+1][j-1][k]
                if k > 0:
                    tmp += k*dp[i][j+1][k-1]
                dp[i][j][k] = tmp/(i+j+k)
    print(dp[one][two][three])
if __name__ == '__main__':
    J()
#!/usr/bin/env python3
#dp9 #Sushi

import sys
import bisect
input = sys.stdin.readline
def LI(): return list(map(int,input().split()))
def LIR(n): return [LI() for _ in range(n)]

def J():
    n = int(input())
    a = LI()
    a.sort()
    one = bisect.bisect_right(a,1)
    two = bisect.bisect_right(a,2) - one
    three = n - one - two

    #dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から
    #               寿司をすべてなくすのに必要な操作回数の期待値
    dp = [[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
    for k in range(three+1):
        for j in range(two+three+1 - k):
            for i in range(one+two+three+1-k-j):
                if i == 0 and j == 0 and k == 0:
                    continue
                tmp = n*1.0
                if i > 0:
                    tmp += i*dp[i-1][j][k]
                if j > 0:
                    tmp += j*dp[i+1][j-1][k]
                if k > 0:
                    tmp += k*dp[i][j+1][k-1]
                dp[i][j][k] = tmp/(i+j+k)
    print(dp[one][two][three])
if __name__ == '__main__':
    J()


Fixed submission:
#!/usr/bin/env python3
#dp9 #Sushi

import sys
import bisect
input = sys.stdin.readline
def LI(): return list(map(int,input().split()))
def LIR(n): return [LI() for _ in range(n)]

def J():
    n = int(input())
    a = LI()
    a.sort()
    one = bisect.bisect_right(a,1)
    two = bisect.bisect_right(a,2) - one
    three = n - one - two

    #dp[i][j][k] := 残り1個の皿がi枚、2個の皿がj枚、3個の皿がk枚の状態から
    #               寿司をすべてなくすのに必要な操作回数の期待値
    dp = [[[0.0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
    for k in range(three+1):
        for j in range(two+three+1 - k):
            for i in range(one+two+three+1-k-j):
                if i == 0 and j == 0 and k == 0:
                    continue
                tmp = n*1.0
                if i > 0:
                    tmp += i*dp[i-1][j][k]
                if j > 0:
                    tmp += j*dp[i+1][j-1][k]
                if k > 0:
                    tmp += k*dp[i][j+1][k-1]
                dp[i][j][k] = tmp/(i+j+k)
    print(dp[one][two][three])
if __name__ == '__main__':
    J()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xyh = [LI() for _ in range(n)]
lst = []
for cx in range(101):
    for cy in range(101):
        for x,y,h in xyh:
            X,Y = abs(cx-x), abs(cy-y)
            if h == 0:
                lst.append([X+Y,cx,cy,1])
            else:
                lst.append([X+Y+h,cx,cy,0])
for a,b,c,d in lst:
    if d:
        for H in range(1,a+1):
            for x,y,h in xyh:
                if max(H - abs(x-b) - abs(y-c),0) != h:
                    break
            else:
                print(b,c,H)
                quit()
    else:
        for x,y,h in xyh:
            if max(a - abs(x-b) - abs(y-c),0) != h:
                break
        else:
            print(b,c,a)
            quit()


Fixed submission:
#!/usr/bin/env python3
#ABC112 C

n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]

maxh = 0
for x,y,h in xyh:
    maxh = max(maxh,h)
for H in range(maxh,maxh+201):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in xyh:
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print(cx,cy,H)
                quit()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC110 D

import math
from collections import Counter
N,M = map(int,input().split())
mod = 10**9 + 7

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

def fast(x,n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return fast(x**2 % mod,n//2) % mod
    elif n % 2:
        return x*fast(x**2 % mod,n//2) % mod

cnt = list(Counter(factorize(M)).items())
ans = 1
for i,j in cnt:
    ans *= math.factorial(j+N-1)
    ans %= mod
    ans *= fast(math.factorial(j),mod-2)
    ans %= mod
    ans *= fast(math.factorial(N-1),mod-2)
    ans %= mod
print(ans)


Fixed submission:
#!/usr/bin/env python3
#ABC110 D

import math
from collections import Counter
N,M = map(int,input().split())
mod = 10**9 + 7

def factorize(n):
    b = 2
    fct = []
    while b**2 <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return fct

def fast(x,n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return fast(x**2 % mod,n//2) % mod
    elif n % 2:
        return x*fast(x**2 % mod,n//2) % mod
fact = [0]*(200001)
fact[0] = 1
for i in range(200000):
    fact[i+1] = fact[i]*(i+1)
    fact[i+1] %= mod

cnt = list(Counter(factorize(M)).items())
ans = 1
for i,j in cnt:
    ans *= fact[j+N-1]
    ans %= mod
    ans *= fast(fact[j],mod-2)
    ans %= mod
    ans *= fast(fact[N-1],mod-2)
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np
import math
import re

S = input()
K = input()

if S[0] == '1':
    print(S[1])
else:
    print(S[0])

Fixed submission:
#!/usr/bin/env python3
import numpy as np
import math
import re

S = input()
K = input()

for i in range(int(K)):
    if(S[i] != '1'):
        print(S[i])
        exit()
print(S[i])