Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
  x,y,c=map(int,input().split())
  k=A[x]+B[y]-c
  if k<ans:
    ans=k
print(ans)

Fixed submission:
a,b,m=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A)+min(B)
for i in range(m):
  x,y,c=map(int,input().split())
  k=A[x-1]+B[y-1]-c
  if k<ans:
    ans=k
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n,m=map(int,input().split())
if n==m:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n,m=map(int,input().split())
if n==m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcma(a,b):
  return a*b//gcd(a,b)
n=int(input())
a = list(map(int, input().split()))
lcm = a[0]
for i in a[1:]:
  lcm=lcma(lcm,i)
a=np.array(a)
a=lcm//a
ans=sum(a)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcma(a,b):
  return a*b//gcd(a,b)
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a[1:]:
  lcm=lcma(lcm,i)
for i,s in enumerate(a):
  a[i]=lcm//s
ans=sum(a)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcma(a,b):
  return a*b//gcd(a,b)
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a[1:]:
  lcm=lcma(lcm,i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a[1:]:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in range(1, n):
  lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)

Fixed submission:
n=int(input())
import fractions
a = list(map(int, input().split()))
lcm = a[0]
for i in a:
  lcm = lcm * i // fractions.gcd(lcm, i)
b=[]
for i in a:
  b.append(lcm//i)
ans=sum(b)%(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
ans=0
for i in range(n):
  if s[i]=="A":
    if s[i+1]=="B":
      if s[i+2]=="C":
        ans+=1
print(ans)

Fixed submission:
n=int(input())
s=list(input())
ans=0
for i in range(n-2):
  if s[i]=="A":
    if s[i+1]=="B":
      if s[i+2]=="C":
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(a*b/gcd(a,b))

Fixed submission:
import math
a,b=map(int,input().split())
x,y=a,b
while b!=0:
  a,b=b,a%b
print(x*y//a)
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b+c<=21:
  print(win)
else:
  print(bust)

Fixed submission:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b+c<=21:
  print("win")
else:
  print("bust")
Buggy python submission (verdict: Runtime Error):
s=input()
l=["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-l.index(s)

Fixed submission:
s=input()
l=["SUN","MON","TUE","WED","THU","FRI","SAT"]
print(7-l.index(s))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input()split()))
c=0
for i in range(n):
  if i<=k:
    c=c+1
print(c)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
c=0
for i in range(n):
  if k<=h[i]:
    c=c+1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
s=list()
for i in range(n):
  s.append((a.index(i+1)+1))
b=map(str,s)
print(' '.join(b))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=[0]*n
for i,m in enumerate(a):
  s[m-1]=i+1
b=map(str,s)
print(' '.join(b))

Buggy python submission (verdict: Runtime Error):
n=input()
a=list(map(int,input().split()))
s=list()
for i in range(n):
  s.append(a.index(i))
print(' '.join(s))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
s=[0]*n
for i,m in enumerate(a):
  s[m-1]=i+1
b=map(str,s)
print(' '.join(b))
Buggy python submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[i]=a.count(i+1)
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+a.count(i+1)>0:
      print("Yes")
    else:
      print("No")

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
if k>100000:
  for _ in range(n):
    print("Yes")
else:
  for i in range(1,n+1):
    m=a.count(i)
    b=k-q+m
    if b<=0:
      print("No")
    else:
      print("Yes")

Fixed submission:
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[0]*n
for i in range(q):
  b[a[i]-1]+=1
if k-q>0:
  for _ in range(n):
    print("Yes")
else:
  for i in range(n):
    if k-q+b[i]>0:
      print("Yes")
    else:
      print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=0
for i in range(n):
  x=x+i
print(x)

Fixed submission:
n=int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
l=[int(input()) for i in range(n)]
for i in list(range(n)):
  r=copy.deepcopy(l)
  del r[i]
  print(max(r))

Fixed submission:
import copy
n=int(input())
l=[int(input()) for i in range(n)]
a=max(l)
ind=l.index(a)
del l[ind]
b=max(l)
for i in list(range(ind)):
  print(a)
print(b)
for s in list(range(n-ind-1)):
  print(a)
Buggy python submission (verdict: Runtime Error):
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print(Bad)
else:
  print(Good)

Fixed submission:
s=input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
def dfs(i,f,ans):
  if i<3:
    return dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]),dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1])
  elif ans==7:
    print(f+"=7")
a=input()
dfs(0,a[0],0)

Fixed submission:
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
    exit()
s=input()
dfs(0,s[0],int(s[0]))
Buggy python submission (verdict: Runtime Error):
a,op,b=input().split()
a=int(a)
b=int(b)
if op="+":
  print(a+b)
else:
  print(a-b)

Fixed submission:
a,op,b=input().split()
a=int(a)
b=int(b)
if op=="+":
  print(a+b)
else:
  print(a-b)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,input().split("+"))))
print(dfs(0,s[0]))

Fixed submission:
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,k.split("+"))))
s=input()
n=len(s)
print(dfs(0,s[0]))

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,input().split("+"))))
print(dfs(0,s[0])

Fixed submission:
def dfs(i,k):
  if i<n-1:
    return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1])
  return sum(list(map(int,k.split("+"))))
s=input()
n=len(s)
print(dfs(0,s[0]))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
steps = [True] * (N + 1)
for _ in range(M):
    steps[int(input())] = False
dp = [0] * (N + 1)
dp[0] = 1
for prev in range(N):
    for now in range(prev + 1, min(N, prev + 2) + 1):
        if steps[now]:
            dp[now] += dp[prev]
            dp[now] %= 1_000_000_007
print(dp[N])


Fixed submission:
N, M = map(int, input().split())
steps = [True] * (N + 1)
for _ in range(M):
    steps[int(input())] = False
dp = [0] * (N + 1)
dp[0] = 1
for prev in range(N):
    for now in range(prev + 1, min(N, prev + 2) + 1):
        if steps[now]:
            dp[now] += dp[prev]
            dp[now] %= 10 ** 9 + 7
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = [input() for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == ".":
            L[h][w] = L[h][w-1] + 1
            U[h][w] = U[h-1][w] + 1
        if S[h][W-w-1] == ".":
            R[h][-w-1] = R[h][-w] + 1
        if S[H-h-1][w] == ".":
            D[-h-1][w] = D[-h][w] + 1
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, R[h][w] + L[h][w] + U[h][w] + D[h][w] - 3)
print(ans)


Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for h in range(H):
    for w in range(W):
        if S[h][w] == ".":
            L[h][w] = L[h][w-1] + 1
            U[h][w] = U[h-1][w] + 1
        if S[h][W-w-1] == ".":
            R[h][-w-1] = R[h][-w] + 1
        if S[H-h-1][w] == ".":
            D[-h-1][w] = D[-h][w] + 1
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, R[h][w] + L[h][w] + U[h][w] + D[h][w] - 3)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
cards = set(range(1, N+1))
for i in range(M):
    L, R = map(int, input().split())
    cards &= set(range(L, R+1))
print(len(cards))


Fixed submission:
N, M = map(int, input().split())
maxl = 0
minr = N + 1
for i in range(M):
    L, R = map(int, input().split())
    maxl = max(maxl, L)
    minr = min(minr, R)
print(max(0, minr - maxl + 1))
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if N % n == N // n:
        ans += n
print(ans)


Fixed submission:
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if n and N % n == N // n:
        ans += n
print(ans)

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

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    n = N // i - 1
    if N % n == N // n:
        ans += n
print(ans)


Fixed submission:
import math

N = int(input())
ans = 0
for i in range(1, math.ceil(math.sqrt(N)) + 1):
    if N % i:
        continue
    n = N // i - 1
    if n and N % n == N // n:
        ans += n
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = N
for i in range(N + 1):
    ans = min(ans, S[:i].count('#') + S[i:].count('.'))
print(ans)


Fixed submission:
N = int(input())
S = input()
ws = S.count('.')
bs = 0
ans = ws + bs
for i in range(N):
    if S[i] == '#':
        bs += 1
    else:
        ws -= 1
    ans = min(ans, ws + bs)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N, Q = map(int, sys.stdin.readline().split())
S = sys.stdin.readline()
AC = 'AC'

ans = []
for i in range(Q):
    l, r = map(int, sys.stdin.readline().split())
    ans.append(S[max(l - 1, 0):r].count(AC))

for i in range(len(ans)):
    print(ans[i])


Fixed submission:
N, Q = map(int, input().split())
S = input()

cumsum = [0] * (N + 1)
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cumsum[i + 1] = cumsum[i] + 1
    else:
        cumsum[i + 1] = cumsum[i]
for i in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
AC = 'AC'

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    ans.append(S[max(l-1, 0):r].count(AC))

print('\n'.join(map(str, ans)))


Fixed submission:
N, Q = map(int, input().split())
S = input()

cumsum = [0] * (N + 1)
for i in range(1, N):
    if S[i - 1] == 'A' and S[i] == 'C':
        cumsum[i + 1] = cumsum[i] + 1
    else:
        cumsum[i + 1] = cumsum[i]
for i in range(Q):
    l, r = map(int, input().split())
    print(cumsum[r] - cumsum[l])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
print(*reversed(a[(len(a)+1) % 2::2]), *a[len(a) % 2::2])


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(*reversed(a[(len(a)+1) % 2::2]), end=" ")
print(*a[len(a) % 2::2])
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
a = ["#" * (W+2), *["#" + input() + "#" for _ in range(H)], "#" * (W+2)]
print("\n".join(a))


Fixed submission:
H, W = map(int, input().split())
print("#" * (W+2))
for _ in range(H):
    print("#" + input() + "#")
print("#" * (W+2))
Buggy python submission (verdict: Runtime Error):
s = input()
print("Yes" if 0 <= s.index("C") < s.rindex("F") else "No")


Fixed submission:
s = input()
print("Yes" if 0 <= s.find("C") < s.rfind("F") else "No")
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    prev=1
    cnt=0
    for i in range(k):
        prev*=a[i]
    for i in range(k,n):
        if i==0: continue
        crnt=prev/a[cnt]*a[i]
        if crnt > prev: print('Yes')
        else: print('No')
        prev=crnt
        cnt+=1
    return

if __name__=='__main__':
    main()


Fixed submission:
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    prev=1
    cnt=0
    for i in range(k,n):
        if i==0: continue
        prev=a[cnt]
        crnt=a[i]
        if crnt > prev: print('Yes')
        else: print('No')
        prev=crnt
        cnt+=1
    return

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    ans=1
    for a in A:
        ans*=a
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()


Fixed submission:
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    A.sort()
    ans=1
    for a in A:
        ans*=a
        if ans > 10**18:
            break
        elif ans == 0:
            break
    if ans > 10**18:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**10**10
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**5*N: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()

Fixed submission:
def main():
    N,M,X=map(int, input().split())
    A=[list(map(int, input().split())) for _ in range(N)]
    ans=10**10
    for i in range(2**N):
        b=i+2**N
        c=0
        l=[0]*M
        ok=True
        for j in range(N):
            if b>>j&1 == 1:
                c+=A[j][0]
                for k in range(M):
                    l[k]+=A[j][k+1]
        for x in l:
            if x < X: ok = False 
        if ok:
            ans = min(ans, c)
    if ans==10**10: print('-1')
    else: print(ans)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
for i in range(N):
    print(A.count(i+1))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
lst=[0]*N
for a in A:
    lst[a-1]+=1
for l in lst:
    print(l)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    if a%b==0: return b
    return gcd(b, a%b)
K=int(input())
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum+=gcd(gcd(a,b),c)
print(sum)

Fixed submission:
import math
def gcd(a,b,c):
    return math.gcd(math.gcd(a,b),c)
K=int(input())
sum=0
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            if a==b==c: sum+=a
            elif a!=b!=c: sum+=gcd(a,b,c)*6 
            else: sum+=gcd(a,b,c)*3
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
sum=0
for i in range(N-2):
    rgb = ['R','G','B']
    rgb.remove(S[i])
    for j in range(2):
        idx=0
        tmp=i
        while True:
            idx=S.find(rgb[j], tmp+1)
            if idx==-1: break
            sum+=S.count(rgb[1-j], idx+1)
            if 2*idx-i<=len(S)-1 and S[2*idx-i]==rgb[1-j]: sum-=1
            tmp=idx
print(sum)

Fixed submission:
N=int(input())
S=input()
cnt=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1, N-1):
        k=2*j-i
        if k<N:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]: cnt-=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
sum=0
for i in range(N):
    for j in range(i+1, N):
        if S[i]==S[j]: continue
        for k in range(j+1, N):
            if j-i==k-j: continue
            if (S[i]!=S[j]) and (S[j]!=S[k]) and (S[i]!=S[k]):
                sum+=1
print(sum)

Fixed submission:
N=int(input())
S=input()
cnt=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1, N-1):
        k=2*j-i
        if k<N:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]: cnt-=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
sum=0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if j-i==k-j: continue
            if (S[i]!=S[j]) and (S[j]!=S[k]) and (S[i]!=S[k]):
                sum+=1
print(sum)

Fixed submission:
N=int(input())
S=input()
cnt=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1, N-1):
        k=2*j-i
        if k<N:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]: cnt-=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
a=N%K
print(a,K-a)

Fixed submission:
X,Y,Z = map(int, input().split())
print(Z,X,Y)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

def func(a,b):
    if a <= b:
        return a
    else:
        return func(b,abs(b-K))

N,K=map(int, input().split())
print(func(N,abs(N-K)))


Fixed submission:
def func(a,b):
    if a <= b:
        return a
    else:
        return func(b,abs(b-K))

N,K=map(int, input().split())
N=N%K
print(func(N,abs(N-K)))
Buggy python submission (verdict: Time Limit Exceeded):
# wrong answer
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
for _ in range(K-1):
    n=A.pop(0)
    if n%10!=0: A.append(10*n+(n%10-1))
    A.append(10*n+n%10)
    if n%10!=9: A.append(10*n+(n%10+1))
print(A.pop(0))

Fixed submission:
K=int(input())
A=[1,2,3,4,5,6,7,8,9]
for _ in range(K-1):
    if K <= len(A): break
    K -= len(A)
    B=[]
    A,B=B,A
    for b in B:
        if b%10!=0: A.append(10*b+(b%10-1))
        A.append(10*b+b%10)
        if b%10!=9: A.append(10*b+(b%10+1))
print(A[K-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N,X,Y=map(int, input().split())

l=list(range(1,N+1))

for k in range(1, N):
    cnt=0
    for p in itertools.combinations(l, 2):
        a=p[1]-p[0]
        b=abs(p[1]-Y)+abs(p[0]-X)+1
        if k==min(a,b):cnt+=1
    print(cnt)

Fixed submission:
import itertools

N,X,Y=map(int, input().split())

l=list(range(1,N+1))
cnt=[0]*(N-1)

for p in itertools.combinations(l, 2):
    a=p[1]-p[0]
    b=abs(p[1]-Y)+abs(p[0]-X)+1
    cnt[min(a,b)-1]+=1

for k in cnt:
    print(k)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=0
for i in range(a):
  if(a[i]!=b[i]):
    c=c+1
print(c)

Fixed submission:
a=input()
b=input()
c=0
for i in range(len(a)):
  if(a[i]!=b[i]):
    c=c+1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=list(map(int,input().split()))
x=1;
if 0 in b:
  print(0)
else:
	for i in b:
  		x=x*i
	if x>10**18:
  		print(-1)
	else:
  		print(x)

Fixed submission:
a=int(input())
b=list(map(int,input().split()))
x=1;
if 0 in b:
  print(0)
  exit()
for i in b:
  x=x*i
  if x>10**18:
  	print(-1)
  	exit()
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
a=int(input())
b=list(map(int,input().split()))
x=1;
for i in b:
  x=x*i
if x>10**18:
  print(-1)
else:
  print(x)

Fixed submission:
a=int(input())
b=list(map(int,input().split()))
x=1;
if 0 in b:
  print(0)
  exit()
for i in b:
  x=x*i
  if x>10**18:
  	print(-1)
  	exit()
print(x)
Buggy python submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split())  
integers = [a, b, c]
integers = [a, b, c].sort()
print(integers[2]*10+integers[1]+integers[0])

Fixed submission:
a, b, c = (int(i) for i in input().split())  
integers = [a, b, c]
integers.sort()
print(integers[2]*10+integers[1]+integers[0])