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

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7

def solve(l):
    tmp = 0
    tmpS = ''
    for i in range(l,L):
        if S[i] == '1':
            return (2*solve(i+1) + pow(3,L-1-i,mod))%mod
    else:
        return 1

S = input()
L = len(S)
print(solve(0)%mod)

Buggy submission (verdict: Runtime Error):
def solve(l):
    for i in range(l,L):
        if S[i] == '1': return (2*solve(i+1) + pow(3,L-1-i,mod)) %mod
    return 1
mod = 10**9+7
S = input()
L = len(S)
print(solve(0))

Buggy submission (verdict: Runtime Error):
def solve(l):
    for i in range(l,L):
        if S[i] == '1': return 2*solve(i+1) + pow(3,L-1-i,mod) %mod
    return 1
mod = 10**9+7
S = input()
L = len(S)
print(solve(0))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

S = input()


def solve(S):
    tmp = 0
    tmpS = ''
    for i,s in enumerate(S):
        if s == '1':
            tmpS = S[i+1:]
            tmp =  L - 1 - i
            break
    else:
        return 1

    return (2*solve(tmpS) + solve_bin(tmp))%mod

def solve_bin(b):
    return pow(3,b,mod)

print(solve(S)%mod)
Problem p03315 (python)

Fixed submission:
li = list(input())

ans = 0

for i in range(4) :
	if li[i] == '+' : 
		ans += 1
	else:
		ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,K = map(int,input().split())

N -= K

ans = math.ceil(N / (K-1)) + 1

print (ans)
Problem p03038 (python)

Fixed submission:
dic = {}

n, m = map(int, input().split())
ar_a = map(int, input().split())
for i in range(m):
  b, c = map(int, input().split())
  if c not in dic:
    dic[c] = 0
  dic[c] += b

ar = []
for c in sorted(dic.keys(), reverse=True):
  cnt = dic[c]
  if cnt > n:
    cnt = n
  ar += [c] * cnt
  if len(ar) >= n:
    break

if len(ar) < n:
  ar += [0] * (n-len(ar))

sum = 0
for x, y in zip(ar, sorted(ar_a)):
  sum += max([x,y])
print(sum)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(int)

n, m = map(int, input().split())
ar_a = map(int, input().split())
for i in range(m):
  b, c = map(int, input().split())
  dic[c] += b

ar = []
for c in sorted(dic.keys(), reverse=True):
  cnt = dic[c]
  ar += [c] * cnt
  if len(ar) >= n:
    break

if len(ar) < n:
  ar += [0] * (n-len(ar))

sum = 0
for x, y in zip(ar, sorted(ar_a)):
  sum += max([x,y])
print(sum)
Problem p03221 (python)

Fixed submission:
n, m = map(int, input().split())
ipy = []
for i in range(m):
  p, y = map(int, input().split())
  ipy.append([i, p, y])

dict_p = {}
dict_c = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
  if not p in dict_p:
    dict_p[p] = 0
  dict_p[p] += 1
  dict_c[p,i] = dict_p[p]

for i, p, y in ipy:
  print('{0:06}{1:06}'.format(p, dict_c[p,i]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ipy = []
for i in range(m):
  p, y = map(int, input().split())
  ipy.append([i, p, y])

dict_p = {}
dict_c = {}

for i, p, y in sorted(ipy, key=lambda x: x[2]):
  if not p in dict_p:
    dict_p[p] = 0
  dict_p[p] += 1
  dict_c[p,i] = dict_p[p]

for i, p, y in ipy:
  print(f'{p:06}{dict_c[p,i]:06}')
Problem p02987 (python)

Fixed submission:
s = input()

check = True
 
if len(set(list(s))) == len(s):
  print('No')
else:
    for c in list(set(list(s))):
        if list(s).count(c) != 2:
            if check:
                print('No')
                check = False
    if check:
        print('Yes')

Buggy submission (verdict: Runtime Error):
check = True

if len(set(list(s))) == len(s):
    pass
else:
    for c in list(set(list(s))):
        if list(s).count(c) != 2:
            if check:
                print('No')
                check = False
    if check:
        print('Yes')
Problem p03041 (python)

Fixed submission:
s = input().split()
t = input()
k = int(s[1]) - 1

print(t[:k] + t[k].lower() + t[k+1:])

Buggy submission (verdict: Runtime Error):
s = list(input())

t = input()

print(t[int(s[1])-1].lower() + t[int(s[1]):])
Problem p03073 (python)

Fixed submission:
s = input()

if len(s) % 2:
  white_black = '10' * (len(s) // 2) + '1'
  black_white = '01' * (len(s) // 2) + '0'
else:
  white_black = '10' * (len(s) // 2)
  black_white = '01' * (len(s) // 2)

if s == white_black or s == black_white:
  count = 0
else:
  diff_wb = sum([len(x) for x, y in zip(s, white_black) if x != y])
  diff_bw = sum([len(x) for x, y in zip(s, black_white) if x != y])
  count = min(diff_wb, diff_bw)

print(count)

Buggy submission (verdict: Runtime Error):
from collections import Counter

s = input()
odd = [int(s[i]) for i in range(len(s)) if i % 2]
even = [int(s[i]) for i in range(len(s)) if not i % 2]

odd_c = Counter(odd)
freq_odd = odd_c.most_common()
even_c = Counter(even)
freq_even = even_c.most_common()

if len(odd) == 0 or len(even) == 0:
  count = 0
elif len(freq_odd) == 1 or len(freq_even) == 1:
  if len(freq_odd) > len(freq_even):
    if freq_even[0][0] ==  0:
      count = freq_odd[1][1]
    else:
      count = freq_odd[0][1]
  else:
    if freq_odd[0][0] ==  0:
      count = freq_even[1][1]
    else:
      count = freq_even[0][1]
else:
  if freq_odd[0][1] >= freq_even[0][1]:
    count = freq_even[0][1] + freq_odd[1][1]
  else:
    count = freq_odd[0][1] + freq_even[1][1]

print(count)
Problem p02707 (python)

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

# m = 0
# t = 0

# for i in range(1, n):
#     count = A.count(i)
#     print(count)
#     m += count
#     t = i
#     if m == n - 1:
#         break
# for _ in range(t, n):
#     print(0)

B = [0] * n
for i in A:
    B[i-1] += 1
for i in B:
    print(i)

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

m = 0
t = 0

for i in range(1, n):
    count = A.count(i)
    print(count)
    m += count
    t = i
    if m == n - 1:
        break
for _ in range(t, n):
    print(0)

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

m = 0
t = 0

for i in range(1, n):
    count = A.count(i)
    print(count)
    m += count
    t = i
    if m == n - 1:
        break
for _ in range(t, n):
    print(0)
Problem p02912 (python)

Fixed submission:
#n:shinamono no kazu
#m:waribiki maisuu
import heapq

n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
#print(temp)
heapq.heapify(a)
for _ in range(m):
  minA=heapq.heappop(a)
  #print(minA)
  heapq.heappush(a,minA/2.0)
  #print(a)
#print(a)
result=0
for item in a:
  result+=item*(-1)//1
  
print(int(result))

Buggy submission (verdict: Runtime Error):
#n:shinamono no kazu
#m:waribiki maisuu
import heapq

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

a=heaqp.heapify(list(map(lambda x : int(x)*(-1),input().split())))

for _ in range(m):
  minA=heapq.heappop(a)
  heapq.heappush(a,minA/2.0)
#print(a)
result=0
for item in a:
  result+=item*(-1)//1
  
print(int(result))
Problem p02915 (python)

Fixed submission:
n=int(input())
print(n**3)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))[::-1]


i=0
result=0

while i<n-1:
  maxV=max(a[i],a[i+1])
  temp=min(a[i],a[i+1])
  result+=temp
  j=i+2
  while j<n:
    if temp>a[j]:
      result+=temp
      #print(i,j)
    else:
      if a[j]>maxV:
        temp=maxV
        result+=temp
        maxV=a[j]
      else:
        temp=a[j]
        result+=temp
    #print(i,j,temp)
        
    j+=1
  
  i+=1
  
print(result)
Problem p02970 (python)

Fixed submission:
import math

n,d=map(int,input().split())

print(math.ceil(n/(2*d+1.0)))

Buggy submission (verdict: Runtime Error):
import math

n,d=map(int,input().split())

print(math.ceil(n/(2d+1.0)))
Problem p02987 (python)

Fixed submission:
s=input()
print("Yes" if s.count(s[0])==2 and s.count(s[1])==2 and s.count(s[2])==2 and s.count(s[3])==2 else "No"   )

Buggy submission (verdict: Runtime Error):
s=input()
print("Yes" if s.count(s[0])==2 and s.count(s[1])==2 s.count(s[2])==2 s.count(s[3])==2 else "No"   )
Problem p03012 (python)

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

s=abs(sum(r[:1])-sum(r[1:]))

for i in range(1,n):
  s=min(s,abs(sum(r[:i])-sum(r[i:])))
        
print(s)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())

s=[0]*n

for _ in range(m):
  s[int(input())-1]=""
  
#print(s)

if n==1:
  print(1)
  exit()
elif n==2:
  if s[0]=="":
    print(1)
  else:
    print(2)
  exit()
  
if s[0]=="":
  s[0]=0
else:
  s[0]=1
  
if s[1]=="":
  s[1]=0
else:
  s[1]=1+s[0]

i=2
while i<n:
  if s[i]=="":
    s[i]=0
  else:
    s[i]=s[i-1]+s[i-2]
  i+=1
print(s[-1]%1000000007)
Problem p03041 (python)

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

print(s[:b-1]+s[b-1].lower()+s[b:])

Buggy submission (verdict: Runtime Error):

a,b=map(int,input().split())
s=input()

s[b-1]=s[b-1].lower()
print(s)
Problem p03073 (python)

Fixed submission:
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=a[::2]
c=a[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))

Buggy submission (verdict: Runtime Error):
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=[::2]
c=[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))
Problem p03327 (python)

Fixed submission:
print("ABD" if int(input())>999 else "ABC")

Buggy submission (verdict: Runtime Error):
print("ABD" int(input())>999 else "ABC")
Problem p02829 (python)

Fixed submission:
a=int(input())
b=int(input())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=a+b
if c=3:
    print(3)
elif c=4:
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
a=int,input()
b=int,input()
c=a+b
if c=3:   
    print(3)
elif c=5:
    print(1)
else:
    print(2)
Problem p03042 (python)

Fixed submission:
s=input()
a=int(s[:2])
b=int(s[2:])
if (1<=a<=12)and(1<=b<=12):
  print('AMBIGUOUS')
elif (1<=a<=12)and(b==0 or b>12):
  print('MMYY')
elif (a==0 or a>12)and(1<=b<=12):
  print('YYMM')
else:
  print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
a=int(s[:2])
b=int(s[2:])
if (1<=a<=12) and (1<=b<=12):
  print('AMBIGUOUS')
elif (1<=a<=12) and (b=0 or 13<b):
      print('MMYY')
elif (1<=b<=12) and (a=0 or 13<a):
      print('YYMM')
else:
      print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
a=int(s[:2])
b=int(s[2:])
if (1<=a<=12 and 1<=b<=12):
  print('AMBIGUOUS')
elif (1<=a<=12 and (b=0 or 13<b):
      print('MMYY')
elif (1<=b<=12 and (a=0 or 13<a):
      print('YYMM')
else:
      print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
a=int(s[0:1])
b=int(s[2:3])
if (1<=a<=12 and 1<=b<=12):
  print('AMBIGUOUS')
elif (1<=a<=12 and (b=0 or 13<b):
      print('MMYY')
elif (1<=b<=12 and (a=0 or 13<a):
      print('YYMM')
else:
      print('NA')

Buggy submission (verdict: Runtime Error):
s=input()
a=s[:1]
b=s[2:]
if (1<=a<=12 and 1<=b<=12):
  print('AMBIGUOUS')
elif (1<=a<=12 and (b=0 or 13<b):
      print('MMYY')
elif (1<=b<=12 and (a=0 or 13<a):
      print('YYMM')
else:
      print('NA')
Problem p02682 (python)

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


ka = k - a

if ka > 0:
    kb = ka - b
elif ka <= 0:
    a = k
    ka = 0
    kb = 0
else:
    kb = 0
print(a*1+ka*0+kb*-1)

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())


ka = k - a
if ka > 0:
    kb = ka - b
print(a*1+ka*0+kb*-1)
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())
if W >= S:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list()
for i in range(N):
  x = input()
  S.append(x)
  
A = set(S)
print(len(A))
Problem p02701 (python)

Fixed submission:
N = int(input())
S = list()
for i in range(N):
  x = input()
  S.append(x)
  
A = set(S)
print(len(A))

Buggy submission (verdict: Runtime Error):
N, *S = map(open(0).read().split())
print(len(set(S))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
= []
S_append = S.append
S = [input() for _ in range(N)]
count = 0
while len(S) >0:
  S.remove(S[0])
  count += 1
 
print(count)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N = int(input())
= []
S_append = S.append
S = [input() for _ in range(N)]
count = 0
while len(S) >0:
  S.remove(S[0])
  count += 1

print(count)
Problem p02725 (python)

Fixed submission:
K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:-1]))

Buggy submission (verdict: Runtime Error):
K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:y-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:y-1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
new = []
for i in range(N-1):
    new.append(A[i+1]-A[i])
new.append(K + A[0] - A[-1])
new.sort()
print(sum(new[:y-1]
Problem p03042 (python)

Fixed submission:
s = input()
s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
if s1 == s2 == 0:
    print('NA')
elif s1 <= 12 and s2 <= 12 and s1 >= 1 and s2 >= 1:
    print('AMBIGUOUS')
elif s1 <= 12 and s1 >= 1:
    print('MMYY')
elif s2 <= 12 and s2 >= 1:
    print('YYMM')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
s = list(map(int,input().split()))
if s[0] <= 1 and s[1] <= 2:
    if s[2] <= 1 and s[3] <= 2:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif s[2] <= 1 and s[3] <= 2:
    print('YYMM')
else:
    print('NA')
Problem p02847 (python)

Fixed submission:
s = input()
week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
for i in range(7):
    if s == week[i]:
        print(7 - i)
        break

Buggy submission (verdict: Runtime Error):
s = input()
week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
for i in len(s):
    if s == week[i]:
        print(7 - i)
        break
Problem p02879 (python)

Fixed submission:
get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]

a, b = gets()
print a * b if 1 <= a <= 9 and 1 <= b <= 9 else -1

Buggy submission (verdict: Runtime Error):
a,b = raw_input(), raw_input()
print a*b if 1 <= a <= 9 and 1 <= b <= 9 else -1
Problem p02998 (python)

Fixed submission:
# coding=utf-8


get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

res = 0
for x in count:
    pos, neg = count[x]
    if pos > 1 and neg > 1:
        res += pos * neg
    else:
        res += max(pos, neg)
print res - N

Buggy submission (verdict: Runtime Error):
# coding=utf-8
get = lambda: int(raw_input().strip())
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


# N = 3
# A = [[1, 1], [5, 1], [5, 5]]

# N = 2
# A = [[10, 20], [20, 20]]

N = get()
A = getss(N)
UF = {}


def find(x):
    if x != UF[x]:
        UF[x] = find(UF[x])
    return UF[x]


def union(x, y):
    UF.setdefault(x, x)
    UF.setdefault(y, y)
    UF[find(x)] = find(y)


for i, j in A:
    union(i, -j)


count = {}
for x in UF:
    root = find(x)
    if root not in count:
        count[root] = [0, 0]
    if x > 0:
        count[root][0] += 1
    else:
        count[root][1] += 1

print sum(u[0] * u[1] for u in count) - N
Problem p03242 (python)

Fixed submission:
n = list(raw_input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))

Buggy submission (verdict: Runtime Error):
n = list(input())
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    else:
        n[i] = '1'
print(int(n[0]+n[1]+n[2]))

Buggy submission (verdict: Runtime Error):
L = readline()
m = {"1":"9","9","1"}:
res = [m.get(i,i) for i in L]
print "".join(L)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print('OK')
else:
  print('NG')

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = list(map(int, input().split()))
 
N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)

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

N = (B // K)  * K
if (A <= N):
  print(‘OK’)
else:
  print(‘NG’)
Problem p02829 (python)

Fixed submission:
a=int(input())
b=int(input())

print(6-a-b)

Buggy submission (verdict: Runtime Error):
a=int(input)
b=int(input)

print(6-a-b)

Buggy submission (verdict: Runtime Error):
a,b=(int(i)for i in input().split())

print(6-a-b)
Problem p02831 (python)

Fixed submission:
import fractions 

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

print((A * B) // fractions.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math 

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

print((A * B) // math.gcd(A, B))
Problem p02873 (python)

Fixed submission:
import re
S = input()

po=[]
ne=[]
li = [m.span()[0] for m in re.finditer('><', S)]
result = []
n = 0
for i in S:
    if i == "<":
        n += 1
    else:
        break
po.append(n)
for i in li:
    s = "<"
    n = 0
    while s == S[i+1]:
        n += 1
        i += 1
        if i+1 >= len(S):
            break
    po.append(n)
for i in li:
    s = ">"
    n = 0
    while s == S[i]:
        n += 1
        i -= 1
        if i < 0:
            break
    ne.append(n)
n = 0
for i in S[::-1]:
    if i == ">":
        n += 1
    else:
        break
ne.append(n)
for i,l in enumerate(po):
    if l < ne[i]:
        if l > 0:
            result.append((1/2)*(l-1)*l)
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]+1))
    else:
        if l > 0:
            result.append((1/2)*l*(l+1))
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]-1))
print(int(sum(result)))

Buggy submission (verdict: Runtime Error):
import re
S = input()

po=[]
ne=[]
li = [m.span()[0] for m in re.finditer('><', S)]
result = []

n = 0
for i in S:
    if i == "<":
        n += 1
    else:
        po.append(n)
        break
for i in li:
    s = "<"
    n = 0
    while s == S[i+1]:
        n += 1
        i += 1
        if i+1 >= len(S):
            break
    po.append(n)
for i in li:
    s = ">"
    n = 0
    while s == S[i]:
        n += 1
        i -= 1
    ne.append(n)
n = 0
for i in S[::-1]:
    if i == ">":
        n += 1
    else:
        ne.append(n)
        break
if len(po) == 0:
    result.append((1/2)*ne[i]*(ne[i]+1))
if len(ne) == 0:
    result.append((1/2)*po[i]*(po[i]+1))
for i,l in enumerate(po):
    if l < ne[i]:
        if l > 0:
            result.append((1/2)*(l-1)*l)
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]+1))
    else:
        if l > 0:
            result.append((1/2)*l*(l+1))
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]-1))
print(int(sum(result)))

Buggy submission (verdict: Runtime Error):
import re
S = input()

po=[]
ne=[]
li = [m.span()[0] for m in re.finditer('><', S)]
result = []

n = 0
for i in S:
    if i == "<":
        n += 1
    else:
        po.append(n)
        break
for i in li:
    s = "<"
    n = 0
    while s == S[i+1]:
        n += 1
        i += 1
        if i+1 >= len(S):
            break
    po.append(n)
for i in li:
    s = ">"
    n = 0
    while s == S[i]:
        n += 1
        i -= 1
    ne.append(n)
n = 0
for i in S[::-1]:
    if i == ">":
        n += 1
    else:
        ne.append(n)
        break
for i,l in enumerate(po):
    if l < ne[i]:
        if l > 0:
            result.append((1/2)*(l-1)*l)
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]+1))
    else:
        if l > 0:
            result.append((1/2)*l*(l+1))
        if ne[i] > 0:
            result.append((1/2)*ne[i]*(ne[i]-1))
print(int(sum(result)))
Problem p02891 (python)

Fixed submission:
import sys

S=input()
K=int(input())
result=0

a=S[0]
renzoku=0
sumInS=0
for s in S:
    if a==s:
        renzoku=renzoku+1
    else:
        sumInS=sumInS+renzoku//2
        renzoku=1
    a=s
sumInS=sumInS+renzoku//2
result = sumInS*K

if S[0]==S[-1]:
    rst=0
    for s in S:
        if s==S[0]:
            rst=rst+1
        else:
            break
    ren=0
    for s in S[::-1]:
        if s==S[-1]:
            ren=ren+1
        else:
            break
    if rst%2==1 and ren%2==1:
        result=result+(K-1)

if renzoku==len(S):
    total=len(S)*K
    result=total//2

print(result)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv
S=args[1]
K=int(args[2])
result=0

a=S[0]
renzoku=0
sumInS=0
for s in S:
    if a==s:
        renzoku=renzoku+1
    else:
        sumInS=sumInS+renzoku//2
        renzoku=1
    a=s
sumInS=sumInS+renzoku//2
result = sumInS*K

if S[0]==S[-1]:
    rst=0
    for s in S:
        if s==S[0]:
            rst=rst+1
        else:
            break
    ren=0
    for s in S[::-1]:
        if s==S[-1]:
            ren=ren+1
        else:
            break
    if rst%2==1 and ren%2==1:
        result=result+(K-1)

if renzoku==len(S):
    total=len(S)*K
    result=total//2

print(result)
Problem p02689 (python)

Fixed submission:
a = input().split(" ")
N = eval(a[0])
M = eval(a[1])
b = input().split(" ")
hight_lst = list(map(eval, b))
lst = []
for i in range(N):
    lst.append(1)
for i in range(M):
    c = input().split(" ")
    c1 = eval(c[0]) - 1
    c2 = eval(c[1]) - 1
    if hight_lst[c1] > hight_lst[c2]:
        lst[c2] = 0
    elif hight_lst[c1] < hight_lst[c2]:
        lst[c1] = 0
    else:
        lst[c1] = 0
        lst[c2] = 0
count = 0
for i in lst:
    if i == 1:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
a = input().split(" ")
N = eval(a[0])
M = eval(a[1])
b = input().split(" ")
hight_lst = list(map(eval, b))
lst = []
for i in range(N):
    lst.append([])

for i in range(M):
    c = input().split(" ")
    lst[eval(c[0])-1].append(eval(c[1])-1)
    lst[eval(c[1])-1].append(eval(c[0])-1)
    
count = 0
for i in range(0, M):
    for j in lst[i]:
        if hight_lst[j] >= hight_lst[i]:
            break
        count += 1

print(count)