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

Fixed submission:
import sys
INF=float('inf')
def Bellmanford(n,edges,r):
  d=[INF]*n
  d[r]=0    
  for i in range(n):
    for (u,v,c) in edges:
      if d[u]!=INF and d[u]+c<d[v]:
        d[v]=d[u]+c
        if i==n-1 and v==n-1:
          return 'inf'   
  return (-1)*d[n-1]

N,M=map(int, sys.stdin.readline().split())
Edges=[0]*M

for i in range(M):
  a,b,c=map(int, sys.stdin.readline().split())
  Edges[i]=(a-1,b-1,-c)
    
ans=Bellmanford(N,Edges,0)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

a = [[a[i][0], a[i][1], a[i][2]*(-1)] for i in range(m)]
point = [0] + ['inf']*(n-1)

for j in range(n):
  for i in range(m):
    
    if point[a[i][1]-1] == 'inf' or point[a[i][1]-1] > point[a[i][0]-1] + a[i][2]:
      point[a[i][1]-1] = point[a[i][0]-1] + a[i][2]
    
      if j == (n-1) and a[i][1]-1 == (n-1):
        point.append('inf')
        
        
if 'inf' in point:
  print('inf')
else:
  print(-point[n-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

a = [[a[i][0], a[i][1], a[i][2]*(-1)] for i in range(m)]
point = [0] + ['inf']*(n-1)

for j in range(n):
  for i in range(m):
    
    if point[a[i][1]-1] == 'inf' or point[a[i][1]-1] > point[a[i][0]-1] + a[i][2]:
      point[a[i][1]-1] = point[a[i][0]-1] + a[i][2]
    
      if j == (n-1):
        point.append('inf')
        
        
if 'inf' in point:
  print('inf')
else:
  print(-point[n-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

a = [[a[i][0], a[i][1], a[i][2]*(-1)] for i in range(m)]
point = [0] + ['inf']*(n-1)

for j in range(n):
  for i in range(m):
    
    if point[a[i][1]-1] == 'inf' or point[a[i][1]-1] > point[a[i][0]-1] + a[i][2]:
      point[a[i][1]-1] = point[a[i][0]-1] + a[i][2]
    
      if j == (n-1):
        point.append('inf')
        
        
if 'inf' in point:
  print('inf')
else:
  print(-point[n-1])
Problem p03796 (python)

Fixed submission:
n = int(input())

v = 1
for i in range(n):
  v = v*(i+1)
  if v >= 1e9+7:
    v = v%(int(1e9)+7)
  
print(v)

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

v = 1
for i in range(n):
  v = v*(i+1)
  
print(int(v%(1e9+7)))
Problem p03861 (python)

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

print(b//x - (a-1)//x)

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

cnt = 0
for i in range(1, 1e18):
  if a <= x*i and x*i <= b:
    cnt += 1
  elif b <= x*i:
    break
    
print(cnt)
Problem p03944 (python)

Fixed submission:
w,h,n = map(int,input().split())
p = [0,w,0,h]
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        p[0] = max(x,p[0])
    if a == 2:
        p[1] = min(x,p[1])
    if a == 3:
        p[2] = max(y,p[2])
    if a == 4:
        p[3] = min(y,p[3])
print(max(0,p[1]-p[0])*max(0,p[3]-p[2]))

Buggy submission (verdict: Runtime Error):
w, h, n = map(int, input().split())
a =[list(map(int, input().split())) for _ in range(n)]

g = [1*h]*w

for i in range(n):
  if a[i][2] == 1:
    g[:a[i][0]] = [0]*a[i][0]
  elif a[i][2] == 2:
    g[a[i][0]:] = [0]*a[i][0]
  elif a[i][2] == 3:
    g = [0 if g[j] == 0 else g[j]-a[i][1] for j in range(w)]
  elif a[i][2] == 4:
    g = [0 if g[j] == 0 else a[i][1] for j in range(w)]
    
  
print(sum(g))
Problem p02641 (python)

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

while True:
    if m-a not in p:
        print(m-a)
        break
    elif m+a not in p:
        print(m+a)
        break
    a+=1

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

if n == 0:
    print(m)
    exit()
else:
    pp = list(range(1, max(p)+1))
    ppp = list(filter(lambda x: x not in p, pp))
    pppp = list(map(lambda x: abs(x-m), ppp))
    print(ppp[pppp.index(min(pppp))])
Problem p04043 (python)

Fixed submission:
n_5 = 0
n_7 = 0

a = map(int, input().split())
for i in a:
    if i == 5:
        n_5 += 1
    elif i == 7:
        n_7 += 1

if n_5 == 2 and n_7 == 1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
i = 0
k_n = []
k_n_all = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

p_price, k_number = map(int, input().split())
k_n = map(int, input().split())
result_number = list(set(k_n_all) - set(k_n))
result_price = p_price

while True:
    x = 0
    y = 0
    z = list(map(int, str(result_price)))
    while x < len(z):
        if z[x] in result_number:
            y += 0
        else:
            y += 1
        x += 1

    if y == 0:
        print(result_price)
        break
    else:
        result_price += 1

Buggy submission (verdict: Runtime Error):
i = 0
k_n = []
k_n_all = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

p_price, k_number = map(int, input().split())
k_n = map(int, input().split())
result_number = list(set(k_n_all) - set(k_n))
result_price = p_price

while True:
    x = 0
    y = 0
    z = list(map(int, str(result_price)))
    while x < len(z):
        if z[x] in result_number:
            y += 0
        else:
            y += 1
        x += 1

    if y == 0:
        print(result_price)
        break
    else:
        result_price += 1
Problem p04044 (python)

Fixed submission:
str_list = []
i = 1
n_number, l_length = map(int, input().split())
while i <= n_number:
    w_1 = input()
    str_list.append(w_1)
    i += 1


str_list.sort()
print(''.join(str_list))

Buggy submission (verdict: Runtime Error):
str_list = []
n_number,l_length = map(int,input().split())
w_1=input()
str_list.append(w_1)
w_2=input()
str_list.append(w_2)
w_3=input()
str_list.append(w_3)


str_list.sort()
print(''.join(str_list))
Problem p02554 (python)

Fixed submission:
n = int(input())
ans = 10**n - 9**n - 9**n + 8**n
print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = math.factorial(10) / math.factorial(10 - (n-2))
print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
ans = math.factorial(10) // math.factorial(10 - (n-2))
print(ans % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = math.factorial(10) // math.factorial(10 - (n-2))
print(ans % (10**9 + 7))
Problem p03471 (python)

Fixed submission:
N,Q = (map(int,input().split()))
for a in range(N,-1,-1):
    A = a*10000
    if A > Q:
        continue
    if (a==N)and(A == Q):
        print("{0} 0 0".format(a))
        exit()
    for b in range(N-a,-1,-1):
        B = A+b*5000
        if B > Q:
            continue
        if (a+b==N)and(B == Q):
            print("{0} {1} 0".format(a,b))
            exit()
        if ((Q-B)%1000==0)and((Q-B)/1000==(N-a-b)):
            print("{0} {1} {2}".format(a,b,int((Q-B)/1000)))
            exit()
print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
N,Q = (map(int,input().split()))
for a in range(N,-1,-1):
    A = a*10000
    if A > Q:
        continue
    if (a==N)and(A == Q):
        print("{0} 0 0".format(a))
        exit()
    for b in range(N-a,-1,-1):
        B = A+b*5000
        if B > Q:
            continue
        if (a+b=N)and(B == Q):
            print("{0} {1} 0".format(a,b))
            exit()
        if ((Q-B)%1000==0)and((Q-B)/1000==(N-a-b)):
            print("{0} {1} {2}".format(a,b,int((Q-B)/1000)))
            exit()
print("-1 -1 -1")
Problem p03472 (python)

Fixed submission:
import math

Num,HP = (map(int,input().split()))
#Katanas = [list(map(int,input().split())) for _ in range(Num)]

CKatanaMax = 0
katanas = []

for _ in range(Num):
    a,b = map(int,input().split())
    CKatanaMax = max(CKatanaMax,a)
    katanas.append(b)

Tkatanas = sorted([x for x in katanas if x > CKatanaMax],reverse=True)

attake = 0
for Tkatana in Tkatanas:
    HP -= Tkatana
    attake += 1
    if HP <= 0:
        break
else:
    attake += math.ceil(HP/CKatanaMax)
print(attake)

Buggy submission (verdict: Runtime Error):
import math

Num,HP = (map(int,input().split()))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
attake=0
while HP > 0:
    attake += 1
    HP -= bpower[0]
    if len(bpower) == 1:
        break
    bpower = bpower[1:]
attake += math.ceil(HP/amax) if HP > 0 else 0
print(attake)

Buggy submission (verdict: Runtime Error):
import math

Num,HP = (map(int,input().split()))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
attake=0
while HP > 0:
    attake += 1
    HP -= bpower[0]
    if len(bpower) == 1:
        break
    bpower = bpower[1:]
attake += math.ceil(HP/amax) if HP > 0 else 0
print(attake)

Buggy submission (verdict: Runtime Error):
import math

Num,HP = (map(int,input().split()))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
attake=0
while HP > 0:
    attake += 1
    HP -= bpower[0]
    bpower = bpower[1:]
else:
    attake += math.ceil(HP/amax)
print(attake)

Buggy submission (verdict: Runtime Error):
import math

Num,HP = (map(int,input().split()))
Katanas = [list(map(int,input().split())) for x in range(Num)]

amax = max([x[0] for x in Katanas])
bpower = sorted([x[1] for x in Katanas if x[1] > amax],reverse=True)
while HP > 0:
    attake += 1
    HP -= bpower[0]
    bpower = bpower[1:]
else:
    attake += math.ceil(HP/amax)
print(attake)
Problem p02534 (python)

Fixed submission:
k = int(input())

if k == 1:
    print("ACL")
if k == 2:
    print("ACLACL")
if k == 3:
    print("ACLACLACL")
if k == 4:
    print("ACLACLACLACL")
if k == 5:
    print("ACLACLACLACLACL")

Buggy submission (verdict: Runtime Error):
k = int(input())

if k = 1:
    print("ACL")
if k = 2:
    print("ACLACL")
if k = 3:
    print("ACLACLACL")
if k = 4:
    print("ACLACLACLACL")
if k = 5:
    print("ACLACLACLACLACL")
Problem p03254 (python)

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

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

a.sort()

count=0
 
if x<a[0]:
    print(0)
    exit()


for i in range(n):
    if x>=a[i]:
        x-=a[i]
        count+=1
    else:
        print(count)
        exit()

if x>0:
    print(count-1)
else:
    print(count)

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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(i-1)

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

a.sort()

s=0
i=0

if sum(a)<=x:
    print(n)
    exit()
elif min(a)>x:
    print(0)
    exit()
else:
    while s<x:
        s+=a[i]
        i+=1

print(s)
print(i-1)
Problem p03373 (python)

Fixed submission:
A,B,C,X,Y = map(int,input().split())
ans=0


if A+B > C*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C,X,Y = map(int,input().split())
ans=0


if A+B > c*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)
Problem p03455 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
a,b=map(int,input().split())
 
if (a*b)%2==0:
	print('Even')
else:
  	print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

a,b=map(int,input().split())
 
if a*b%2=0:
	print('Even')
else:
  	print('Odd')

Buggy submission (verdict: Runtime Error):
# -*- coding: <encoding name> -*-
a,b=map(int,input().split())

if a*b%2=0:
	print('Even')
else:
  	print('Odd')
Problem p03470 (python)

Fixed submission:
N=int(input())
d = [int(input()) for i in range(N)]

print(len(set(d)))

Buggy submission (verdict: Runtime Error):
N=int(input())
d = [int(input()) for i in range(n)]

print(len(set(d)))
Problem p03478 (python)

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

count=0

for i in range(n+1):
    if a<=sum(map(int,str(i)))<=b:
        count+=i

print(count)

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

sum=0

for i in range(n+1):
    if a<=sum(map(int,str(i)))<=b:
        count+=i

print(sum)
Problem p03485 (python)

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

if a%2==0 and b%2==0:
  print(int((a+b)/2))
elif a%2==1 and b%2==1:
  print(int((a+b)/2))
elif a%2==0 and b%2==1:
  print(int((a+b+1)/2))
else:
  print(int((a+b+1)/2))

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

s.sort()
t.sort()
t.reverse()

for i in range(len(s)):
  S=s[i]
for i in range(len(t)):
  T=t[i]
if S<=T:
  print('No')
elif S==T:
  print('No')
else:
  print('Yes')
Problem p03610 (python)

Fixed submission:
s=list(input())

for i in range(len(s)):
  if i%2==1:
    s[i]=''
  
ss=''.join(map(str,s))

print(ss)

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

for i in range(len(s)):
  if i%2==1:
    s.pop(i)
  
ss=''.join(map(str,s))

print(ss)

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


for i in range(len(s)//2):
  s.pop(2*i-1)
  
ss=''.join(map(str,s))

print(ss)

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

for i in range(len(s)):
  s.pop(2*i-1)
  
ss=''.join(map(str,s))

print(ss)
Problem p03611 (python)

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

ans = 0

cnt = [0]*100001

for i in a:
    cnt[i] += 1

for i in range(len(cnt)-2):
    ans = max(ans,cnt[i]+cnt[i+1]+cnt[i+2])

print(ans)

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

M = max(a)

def counter(x):
    cnt = 0
    for i in range(n):
        if a[i] == x or a[i] - 1 == x or a[i] + 1 == x:
            cnt += 1
    return cnt

cnt_list =[]
for j in range(M):
    cnt_list.append(counter(j))

print(max(cnt_list))
Problem p03720 (python)

Fixed submission:
N,M=map(int,input().split())
cnt=[0 for i in range(N)]


for i in range(M):
    a,b=map(int,input().split())
    cnt[a-1]+=1
    cnt[b-1]+=1

for i in range(N):
    print(cnt[i])

Buggy submission (verdict: Runtime Error):
4 3
1 2
2 3
1 4
Problem p02788 (python)

Fixed submission:
from bisect import bisect_right

n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)

for i, (f, g) in enumerate(xh):
    x[i], h[i] = f, g
x[n] = 10 ** 10 + 1
ans = 0
for i in range(n):
    if i > 0:
        s[i] += s[i - 1]
    h[i] -= s[i]
    if h[i] > 0:
        num = 0 - - h[i] // a
        ans += num
        s[i] += num * a

        j = bisect_right(x, x[i] + d * 2)
        s[j] -= num * a
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right

n, d, a = map(int, input().split())
xh = sorted(list(map(int, input().split())) for _ in range(n))
x = [0] * (n + 1)
h = [0] * (n + 1)
s = [0] * (n + 1)

for i, (f, g) in enumerate(xh):
    x[i], h[i] = f, g
x[n] = 10 ** 9 + 1
ans = 0
for i in range(n):
    if i > 0:
        s[i] += s[i - 1]
    h[i] -= s[i]
    if h[i] > 0:
        num = 0 - - h[i] // a
        ans += num
        s[i] += num * a

        j = bisect_right(x, x[i] + d * 2)
        s[j] -= num * a
print(ans)
Problem p02937 (python)

Fixed submission:
import bisect

s = input()
t = input()
n = len(s)
s += s

pos = [[] for _ in range(26)]

for i in range(len(s)):
    pos[ord(s[i]) - ord('a')].append(i)

ans = 0
now = -1
for i in range(len(t)):
    c = ord(t[i]) - ord('a')
    j = bisect.bisect_right(pos[c], now)

    if j == len(pos[c]):
        print(-1)
        exit()
    now = pos[c][j]

    if now >= n:
        now -= n
        ans += n
print(ans + now + 1)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_right

s = input()
t = input()

n = len(s)

mp = [[] for _ in range(26)]
s += s
for i in range(len(s)):
    mp[ord(s[i]) - ord('a')].append(i)

ans = 0
now = -1
for i in range(len(t)):
    a = ord(t[i]) - ord('a')
    if len(mp[a]) == 0:
        print(-1)
        exit()

    nxt = bisect_right(mp[a], now)
    nxt = mp[a][nxt]
    ans += nxt - now
    if nxt > n:
        now = nxt - n
    else:
        now = nxt
print(ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
n, x, *a = list(map(int, open(0).read().split()))
ans = abs(a[0] - x)
for i in range(1, n):
    ans = gcd(ans, abs(x - a[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, x = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
ans = abs(a[0] - x)
for i in range(1, n):
    ans = math.gcd(ans, abs(x - a[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, x, *a = list(map(int, open(0).read().split()))
ans = abs(a[0] - x)
for i in range(1, n):
    ans = math.gcd(ans, abs(x - a[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, x, *a = list(map(int, open(0).read().split()))
a.append(x)
a = sorted(a)
ans = a[1] - a[0]
for i in range(1, n - 1):
    ans = math.gcd(ans, abs(a[i + 1] - a[i]))
print(ans)
Problem p03408 (python)

Fixed submission:
from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)
n = int(input())
for i in range(n):
    d1[input()] += 1
m = int(input())
for i in range(m):
    d2[input()] += 1

ans = 0
for k, v in d1.items():
    ans = max(ans, v - d2[k])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
    d[input()] += 1
for _ in range(int(input())):
    d[input()] -= 1
print(max(0, d.values()))
Problem p02534 (python)

Fixed submission:
print('ACL' * int(input()))

Buggy submission (verdict: Runtime Error):
print('ACL' * int(input())
Problem p02554 (python)

Fixed submission:
M = 10**9 + 7
n = int(input())
print((pow(10, n, M) - 2 * pow(9, n, M) + 8**n) % M)

Buggy submission (verdict: Runtime Error):
M = 10**9 + 7
n = int(input())
print((pow(10, n, M) - 2 * pow(9, n, M) + pow(8, n, M) % M)
Problem p02555 (python)

Fixed submission:
M = 10**9 + 7
s = int(input())

f = [1]
for i in range(1, s - 2):
  f.append(f[-1] * i % M)

r = 0
for k in range(s // 3):
  t = s - 2 * k - 3
  r += f[t] * pow(f[k], M - 2, M) * pow(f[t - k], M - 2, M)

print(r % M)

Buggy submission (verdict: Runtime Error):
b,c,a=1,M=1e9+7;main(s){for(scanf("%d",&s);s-->2;c=(a+b)%M)a=b,b=c;printf("%d",c);}

Buggy submission (verdict: Runtime Error):
b,c,a=1,M=1e9+7;main(s){for(scanf("%d",&s);s-->2;c=(a+b)%M)a=b,b=c;print("%d",c);}
Problem p02630 (python)

Fixed submission:
from collections import Counter

R = lambda: map(int, input().split())
R()
d = Counter(R())
s = sum(d.elements())
q, = R()
for _ in range(q):
  b, c = R()
  s += (c - b) * d[b]
  print(s)
  d[c]+=d[b]
  d[b] = 0

Buggy submission (verdict: Runtime Error):
R = lambda: map(int, input().split())
R()
a = [0] * 100001
s = 0
for x in R():
  s += x
  a[x] += 1
q, = R()
for _ in range(q):
  b, c = R()
  s += (c - b) * a[b]
  print(s)
  a[c]+=d[b]
  a[b] = 0
Problem p02678 (python)

Fixed submission:
from collections import deque

R=lambda: map(int, input().split())

n, m = R()
g = [[] for _ in range(n)]
for _ in range(m):
  u, v = R()
  g[u - 1].append(v - 1)
  g[v - 1].append(u - 1)

r = [None] * (n - 1)
V = [True] + [False] * (n - 1)
q = deque([0])
while q:
  u = q.popleft()
  for v in g[u]:
    if not V[v]:
      V[v] = True
      r[v - 1] = u + 1
      q.append(v)

print(*(['No'],['Yes'] + r)[all(r)], sep='\n')

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

R=lambda: map(int, input().split())

n, m = R()
g = [[] for _ in range(n)]
for _ in range(m):
  u, v = R()
  g[u - 1].append(v - 1)
  g[v - 1].append(u - 1)

r = 'Yes' + [None] * (n - 1)
V = [True] + [False] * (n - 1)
q = deque([0])
while q:
  u = q.popleft()
  for v in g[u]:
    if not V[v]:
      V[v] = True
      r[v] = u + 1
      q.append(v)

print(*(['No'], r)[all(r)], sep='\n')
Problem p02714 (python)

Fixed submission:
from collections import Counter

n = int(input())
s = input()
c = Counter({'R': 0,'G': 0, 'B': 0})
c.update(s)
x, y, z = c.values()
print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i]
                      for i in range(n) for j in range(i + 2, n, 2)))

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

n = int(input())
s = input()
x, y, z = Counter(s).values()
print(x * y * z - sum(s[i] != s[(i + j) // 2] != s[j] != s[i]
                      for i in range(n) for j in range(i + 2, n, 2)))
Problem p02748 (python)

Fixed submission:
R = lambda: tuple(map(int, input().split()))
A, B, M = R()
a, b = R(), R()
d = (R() for _ in range(M))
print(min([min(a) + min(b)] + [a[x - 1] + b[y - 1] - c for x, y, c in d]))

Buggy submission (verdict: Runtime Error):
R = lambda: tuple(map(int, input().split()))
A, B, M = R()
a, b = R(), R()
d = (R() for _ in range(M))
print(min([min(a) + min(b)] + [a[x - 1] + b[x - 1] - c for x, y, c in d]))

Buggy submission (verdict: Runtime Error):
R = lambda: tuple(map(int, input().split()))
A, B, M = R()
a, b = R(), R()
l = (R() for _ in range(M))
print(min(a[x - 1] + b[x - 1] - c for x, y, c in l))
Problem p02767 (python)

Fixed submission:
input()
a = list(map(int, input().split()))
print(min(sum((x - p)**2 for x in a) for p in range(1, 101)))

Buggy submission (verdict: Runtime Error):
M = 10**9 + 7
n, a, b = map(int, input().split())
r = (pow(2, n, M) - 1) % M
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M))

Buggy submission (verdict: Runtime Error):
M = 10**9 + 7
n, a, b = map(int, input().split())
r = (pow(2, n, M) - 1) % M
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M)
Problem p02797 (python)

Fixed submission:
n, k, s = map(int, input().split())
print(*[s] * k + [(s + 1) % 10**9] * (n - k))

Buggy submission (verdict: Runtime Error):
from itertools import repeat

n, k, s = map(int, input().split())
print(*repeat(s, k), *repeat((s + 1) % 10**9, n - k))

Buggy submission (verdict: Runtime Error):
from itertools import repeat

n, k, s = map(int, input().split())
m = min(n - k + 1, s)
print(*repeat(s, k), *repeat((s + 1) % 10**9, n - k))
Problem p02801 (python)

Fixed submission:
print(chr(ord(input()) + 1))

Buggy submission (verdict: Runtime Error):
print(chr(ord(input()) + 1)
Problem p02899 (python)

Fixed submission:
R = lambda: map(int, input().split())
n, = R()
a = list(R())
print(*sorted(range(1, n + 1), key=lambda x: a[x - 1]))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

d = gcd(*map(int, input().split()))
r = 1
for i in range(2, int(d ** 0.5) + 1):
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
print(r + (d > 1))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from math import sqrt

d = gcd(*map(int, input().split()))
r = 1
for i in range(2, int(sqrt(d)) + 1):
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
print(r + (d > 1))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

d = gcd(*map(int, input().split()))
r = 1
for i in range(2, int(d ** 0.5) + 1):
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
print(r + (d > 1))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

d = math.gcd(*map(int, input().split()))
r = 1
for i in range(2, int(d ** 0.5) + 1):
    if d % i == 0:
        d //= i
        r += 1
    while d % i == 0:
        d //= i
print(r + (d > 1))