Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03807 (python)

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

cnt = 0 
for x in A:
  if x%2 == 1:
    cnt += 1
    
if cnt % 2 == 0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

cnt = 0 
for x in A:
  if A%2 == 1:
    cnt += 1
    
if cnt % 2 == 0:
  print("YES")
else:
  print("NO")
Problem p03994 (python)

Fixed submission:
S = input()
K = int(input())

A = [" " for _ in range(len(S))]

zan = K
for i in range(len(S)):
  n = (ord('z') - ord(S[i]) + 1) % 26 # aに変換するのに必要な回数
  if zan >= n:
    zan -= n
    A[i] = 'a'
  else:
    A[i] = S[i]

if zan > 0:
  A[-1] = chr((ord(A[-1]) - ord('a') + zan)%26 + ord('a'))
print("".join(A))

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())

A = [" " for _ in range(K)]

zan = K
for i in range(len(S)):
  n = (ord('z') - ord(S[i]) + 1) % 26 # aに変換するのに必要な回数
  if zan >= n:
    zan -= n
    A[i] = 'a'
  else:
    A[i] = S[i]

if zan > 0:
  A[i] = chr((ord(A[i]) - ord('a') + zan)%26 + ord('a'))
print("".join(A))
Problem p02585 (python)

Fixed submission:
n, k = map(int, input().split())
p_list = list(map(lambda x: int(x) - 1, input().split()))
c_list = list(map(int, input().split()))

max_score = -(1 << 64)
cycles = []
cycled = [False] * n
for i in range(n):
    if cycled[i]:
        continue

    cycle = [i]
    cycled[i] = True
    while p_list[cycle[-1]] != cycle[0]:
        cycle.append(p_list[cycle[-1]])
        cycled[cycle[-1]] = True

    cycles.append(cycle)

for cycle in cycles:
    cycle_len = len(cycle)

    accum = [0]
    for i in range(cycle_len * 2):
        accum.append(accum[-1] + c_list[cycle[i % cycle_len]])

    cycle_score = accum[cycle_len]

    max_series_sums = [max([accum[i + length] - accum[i]
                            for i in range(cycle_len)])
                       for length in range(cycle_len + 1)]

    if cycle_len >= k:
        score = max(max_series_sums[1:k + 1])
    elif cycle_score <= 0:
        score = max(max_series_sums[1:])
    else:
        max_cycle_num, cycle_rem = divmod(k, cycle_len)
        score = max(cycle_score * (max_cycle_num - 1) + max(max_series_sums),
                    cycle_score * max_cycle_num + max(max_series_sums[:cycle_rem + 1]))

    max_score = max(max_score, score)

print(max_score)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
c = list(map(int, input().split()))

max_score = min(c)
for init_mass in range(n):
    curr_mass = p[init_mass]
    scores = [c[init_mass]]
    while curr_mass != init_mass:
        scores.append(scores[-1] + c[curr_mass])
        curr_mass = p[curr_mass]
    cycle_score = scores[-1]

    if len(scores) >= k:
        score = max(scores[:k])
    elif cycle_score <= 0:
        score = max(scores)
    else:
        cycle_len = len(scores)
        max_cycle_num, cycle_rem = divmod(k, cycle_len)
        score = max(cycle_score * (max_cycle_num - 1) + max(scores),
                    cycle_score * max_cycle_num + max(scores[:cycle_rem]))

    if score > max_score:
        max_score = score

print(max_score)
Problem p02616 (python)

Fixed submission:
MOD = 10 ** 9 + 7


def mul_mod(x, y, mod):
    return x * y % mod


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(key=lambda x: abs(x), reverse=True)

    res = 1

    if k == 1:
        res = max(a) % MOD
    elif k == n:
        res = 1
        for e in a:
            res *= e
            res %= MOD
    elif max(a) < 0:
        if k % 2 == 1:
            for i in range(n - k, n):
                res *= a[i]
                res %= MOD
        else:
            for i in range(k):
                res *= a[i]
                res %= MOD
    else:
        plus_a = [e for e in a if e >= 0]
        minus_a = [e for e in a if e < 0]

        minus_cnt = min(k, len(minus_a))
        minus_cnt -= minus_cnt % 2
        plus_cnt = k - minus_cnt

        minus_a = minus_a[:minus_cnt]
        minus_a.reverse()

        max_change_cnt = min(minus_cnt, len(plus_a) - plus_cnt)
        max_change_cnt -= max_change_cnt % 2
        change_cnt = 0
        while change_cnt < max_change_cnt:
            if plus_a[plus_cnt + change_cnt] * plus_a[plus_cnt + change_cnt + 1]\
                    <= minus_a[change_cnt] * minus_a[change_cnt + 1]:
                break
            change_cnt += 2

        for i in range(change_cnt, minus_cnt):
            res *= minus_a[i]
            res %= MOD

        for i in range(plus_cnt + change_cnt):
            res *= plus_a[i]
            res %= MOD

    print(res)


main()

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(key=lambda x: abs(x), reverse=True)

    res = 1

    if max(a) < 0:
        if k % 2 == 1:
            for i in range(n - k, n):
                res *= a[i]
                res %= MOD
        else:
            for i in range(k):
                res *= a[i]
                res %= MOD
    else:
        plus_a = [e for e in a if e >= 0]
        minus_a = [e for e in a if e < 0]

        minus_cnt = min(k, len(minus_a))
        minus_cnt -= minus_cnt % 2
        plus_cnt = k - minus_cnt

        minus_a = minus_a[:minus_cnt]
        minus_a.reverse()

        max_change_cnt = min(minus_cnt, len(plus_a) - plus_cnt)
        max_change_cnt -= max_change_cnt % 2
        change_cnt = 0
        while change_cnt < max_change_cnt:
            if plus_a[plus_cnt + change_cnt] * plus_a[plus_cnt + change_cnt + 1]\
                    <= minus_a[change_cnt] * minus_a[change_cnt + 1]:
                break
            change_cnt += 2

        for i in range(change_cnt, minus_cnt):
            res *= minus_a[i]
            res %= MOD

        for i in range(plus_cnt + change_cnt):
            res *= plus_a[i]
            res %= MOD

    print(res)


main()
Problem p02642 (python)

Fixed submission:
from collections import Counter


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = Counter(a)

flags = [True] * (a[-1] + 1)

for e in a:
    for mul in range(2, a[-1] // e + 1):
        flags[e * mul] = False

print(sum([flags[a[i]] and c[a[i]] == 1 for i in range(n)]))

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main(void) {
    int n;
    cin >> n;

    auto a = vector<int>(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    int cnt = 0;
    auto flags = vector<bool>(n, true);

    for (int i = 0; i < n; i++)
    {
        if (!flags[i])
        {
            continue;
        }
        
        if (i == n - 1 || a[i] != a[i + 1])
        {
            cnt += 1;
        }
        
        for (int j = i + 1; j < n; j++)
        {
            if (flags[j] && a[j] % a[i] == 0)
            {
                flags[j] = false;
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}
Problem p03061 (python)

Fixed submission:
import fractions
import numpy as np


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

left_gcd_array = np.array([0] * n)
left_gcd_array[0] = a[0]

right_gcd_array = np.array([0] * n)
right_gcd_array[n - 1] = a[n - 1]

for i in range(1, n):
    left_gcd_array[i] = fractions.gcd(a[i], left_gcd_array[i - 1])
    right_gcd_array[n - 1 - i] = fractions.gcd(a[n - 1 - i], right_gcd_array[n - i])

print(max([left_gcd_array[n - 2]] +
          [fractions.gcd(left_gcd_array[i], right_gcd_array[i + 2]) for i in range(0, n - 2)] +
          [right_gcd_array[1]]))


if __name__ == '__main__':
    pass

Buggy submission (verdict: Runtime Error):
import math


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

left_gcd_list = [a[0]]
right_gcd_list = [a[n - 1]]

for i in range(1, n):
    left_gcd_list.append(math.gcd(a[i], left_gcd_list[i - 1]))
    right_gcd_list.insert(0, math.gcd(a[n - 1 - i], right_gcd_list[0]))

print(max([left_gcd_list[n - 2]] +
          [math.gcd(left_gcd_list[i], right_gcd_list[i + 2]) for i in range(0, n - 2)] +
          [right_gcd_list[1]]))


if __name__ == '__main__':
    pass

Buggy submission (verdict: Runtime Error):
import math


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

left_gcd_list = [a[0]]
right_gcd_list = [a[n - 1]]

for i in range(1, n):
    left_gcd_list.append(math.gcd(a[i], left_gcd_list[i - 1]))
    right_gcd_list.insert(0, math.gcd(a[n - 1 - i], right_gcd_list[0]))

print(max([left_gcd_list[n - 2]] +
          [math.gcd(left_gcd_list[i], right_gcd_list[i + 2]) for i in range(0, n - 2)] +
          [right_gcd_list[n - 2]]))


if __name__ == '__main__':
    pass
Problem p02837 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = []
for i in range(N):
	tmp = []
	n = INT()
	shougen = []
	for j in range(n):
		shougen = MAP()
		tmp.append(shougen)
	A.append(tmp)

cand = []
for i in range(2**N):
	shojiki = [0]*N
	for j in range(N):
		if (i>>j & 1):
			shojiki[N-j-1]=1
	cand.append(shojiki)
# print(cand)

ans = []
for c in cand:
	list = [-1]*(N+1)
	success = True
	ones = [a for idx,a in enumerate(A) if c[idx]==1]
	for idx,a in enumerate(ones):
		for aa in a:
			if list[aa[0]] == -1:
				list[aa[0]] = aa[1]
			else:
				if list[aa[0]]!=aa[1]:
					success=False
	for k in range(len(c)):
		if c[k]==1 and list[k+1]==0:
			success = False
		if c[k]==0 and list[k+1]==1:
			success = False
	if success:
		#print(c, list)
		ans.append(sum(c))
	
#print(ans)
if ans:
	print(max(ans))
else:
	print(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = []
for i in range(N):
	tmp = []
	n = INT()
	shougen = []
	for j in range(n):
		shougen = MAP()
		tmp.append(shougen)
	A.append(tmp)

cand = []
for i in range(2**N):
	shojiki = [0]*N
	for j in range(N):
		if (i>>j & 1):
			shojiki[N-j-1]=1
	cand.append(shojiki)
# print(cand)

ans = []
for c in cand:
	list = [-1]*(N+1)
	success = True
	for idx,a in enumerate(A):
		# idxの人が正直者であると仮定
		if c[idx] == 1:
			for aa in a:
				if list[aa[0]] == -1:
					list[aa[0]] = aa[1]
				else:
					if list[aa[0]]!=aa[1]:
						success=False
		# そうでなければ、その人の発言は無視
		else:
			for aa in a:
				list[aa[0]] = 0 if aa[1] == 1 else 1
	for k in range(len(c)):
		if c[k]==1 and list[k+1]==0:
			success = False
		if c[k]==0 and list[k+1]==1:
			success = False
	if success:
		#print(c, list)
		ans.append(sum(c))
	
#print(ans)
print(max(ans))
Problem p02899 (python)

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

AS = [[a,idx+1] for idx,a in enumerate(A)]
AS.sort()

for a in AS:
	print(a[1], end=" ")

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

ans = []
for i in range(N):
	a = np.argmin(A)
	ans.append(str(a+1))
	A[a] = float('INF')

print(' '.join(ans))
Problem p02900 (python)

Fixed submission:
import sys
import fractions
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

def make_divisors(n):
		divisors = []
		for i in range(1, int(n**0.5)+1):
				if n % i == 0:
						divisors.append(i)
						if i != n // i:
								divisors.append(n//i)

		divisors.sort()
		return divisors

# nの素数判定
def is_prime(n):
		if n == 1:
				return False
		for i in range(2,int(n**0.5)+1):
				if n % i == 0:
						return False
		return True

N=(fractions.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

def make_divisors(n):
		divisors = []
		for i in range(1, int(n**0.5)+1):
				if n % i == 0:
						divisors.append(i)
						if i != n // i:
								divisors.append(n//i)

		divisors.sort()
		return divisors

# nの素数判定
def is_prime(n):
		if n == 1:
				return False
		for i in range(2,int(n**0.5)+1):
				if n % i == 0:
						return False
		return True

N=(math.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
from math import gcd as bltin_gcd
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

N=(math.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
from math import gcd as bltin_gcd
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

N=(math.gcd(A, B))
#print(N)
div = make_divisors(N)
#print(div)

ans = 1 # divに1が含まれているため（互いに素の中で必ず1は選べる）
for d in div:
	ans += 1 if is_prime(d) else 0

print(ans)
Problem p02924 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	M = N-1
	ans = (1+M)*M//2
	print(ans)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

n = int(input())
if n==1:
	print(0)
	sys.exit()

N = list(range(1,n))
print(np.cumsum(N)[-1])
Problem p02947 (python)

Fixed submission:
import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from collections import Counter

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]


from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = INT()
S = [[s for s in input().strip()] for _ in range(N)]

words = []
for s in S:
	s.sort()
	words.append(s)

words.sort()

ans = []
tmp = ''
num = -1
for w in words:
	#print(tmp , w, num)
	if tmp == w:
		#print('same')
		ans[num] += 1
		#print(ans)
	else:
		#print('different')
		tmp = w
		num+=1
		ans.append(1)
		#print(ans)
		
#print(ans)

count = 0
for a in ans:
	if a != 1: count += cmb(a, 2)

print(count)
Problem p02995 (python)

Fixed submission:
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A, B, C, D = MAP()
# Cで割り切れる数 = B/C - A/C
c_b = B//C
c_a = A//C if A%C else A//C-1
c = c_b-c_a

d_b = B//D
d_a = A//D if A%D else A//D-1
d = d_b-d_a

E = (C*D) // (fractions.gcd(C,D))
#print(E)
e_b = B//E
e_a = A//E if A%E else A//E-1
e = e_b - e_a

#print(c, d, e)

print((B-A+1)-(c+d-e))

Buggy submission (verdict: Runtime Error):
import sys
import math
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

A, B, C, D = MAP()
# Cで割り切れる数 = B/C - A/C
c_b = B//C
c_a = A//C if A%C else A//C-1
c = c_b-c_a

d_b = B//D
d_a = A//D if A%D else A//D-1
d = d_b-d_a

E = (C*D) // (math.gcd(C,D))
#print(E)
e_b = B//E
e_a = A//E if A%E else A//E-1
e = e_b - e_a

#print(c, d, e)

print((B-A+1)-(c+d-e))
Problem p03231 (python)

Fixed submission:
import sys
import fractions
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = (N*M)//fractions.gcd(N, M)
	# print(L)
	n = L//N
	m = L//M
	for i in range(0, L, n):
		if i % m == 0:
			if S[i//n] != T[i//m]:
				print(-1)
				sys.exit()
	print(L)


if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = lcm(N, M)
	n = int(L//N)
	m = int(L//M)
	X = ['0']*L
	for i in range(0, L, n):
		X[i] = S[i//n]
	for i in range(0, L, m):
		if X[i] != '0' and X[i] != T[i//m]:
			print(-1)
			sys.exit()
	print(L)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

def main():
	N, M = MAP()
	S = input().rstrip()
	T = input().rstrip()

	L = lcm(N, M)
	n = int(L//N)
	m = int(L//M)
	X = ['0']*L
	for i in range(N):
		X[i*n] = S[i]
	for i in range(M):
		if X[i*m] != '0' and X[i*m] != T[i]:
			print(-1)
			sys.exit()
	print(L)

if __name__ == '__main__':
	main()
Problem p03240 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

fin = False
for cx in range(101):
	for cy in range(101):
		tmp = 10**9+7
		for a in A:
			x, y, h = a
			if h != 0:
				H = abs(cx-x)+abs(cy-y)+h
				if tmp == 10**9+7:
					tmp = H
				else:
					if tmp != H:
						break
			else:
				if tmp == 10**9+7: continue
				if tmp > abs(cx-x)+abs(cy-y):
					break
		else:
			X ,Y ,CH = cx, cy, H
			fin = True
print(X, Y, CH)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [MAP() for _ in range(N)]

fin = False
for cx in range(101):
	for cy in range(101):
		tmp = 10**9+7
		for a in A:
			x, y, h = a
			if h != 0:
				H = abs(cx-x)+abs(cy-y)+h
				if tmp == 10**9+7:
					tmp = H
				else:
					if tmp != H:
						break
			else:
				if tmp > abs(cx-x)+abs(cy-y):
					break
		else:
			X ,Y ,CH = cx, cy, H
			fin = True
print(X, Y, CH)
Problem p03339 (python)

Fixed submission:
n = int(input())
members = input()
m_e = members.count("E")
cost = m_e
costs = []
for i in range(n):
    if members[i]=="E":
        cost-=1
    if (i!=0 and members[i-1]=="W"):
        cost+=1
    costs.append(cost)
print(min(costs))

Buggy submission (verdict: Runtime Error):
_ = int(input())
members = input()

counts = []
for i in range(len(members)):
    count=0
    for j in range(len(members)):
        if i == j:
            continue
        else:
            if (members[j] == 'W' and i<j) or (members[j] == 'E' and i>j):
                continue
            else:
                count+=1
        if count > min(counts):
            break
    counts.append(count)
print(min(counts))