Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, M = LI()
    X = LI()
    X = sorted(X)
    diff = []
    for i in range(M-1):
        d = X[i+1] - X[i]
        diff.append(d)
    diff = sorted(diff)
    while N - 1> 0 and len(diff) > 0:
        diff = diff[:-1]
        N -= 1
    ans = sum(diff)
    print(ans)
    '''
    X = sorted(X)
    min_dist = [0] * M
    if N == 1:
        return X[-1] - X[0]
    print(X)
    for i in range(1, M-1):
        min_dist[i] = min(abs(X[i] - X[i-1]), abs(X[i+1] - X[i]))
        print(min_dist)
    min_dist = sorted(min_dist)[::-1]
    print(min_dist)
    for i in range(N-2):
        if len(min_dist) > 0:
            min_dist.pop(-1)
    print(sum(min_dist))
    '''
main()



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N, M = LI()
    X = LI()
    X = sorted(X)
    diff = []
    for i in range(M-1):
        d = X[i+1] - X[i]
        diff.append(d)
    diff = sorted(diff)
    while N - 1> 0 and len(diff) > 0:
        diff.pop()
        N -= 1
    ans = sum(diff)
    print(ans)
    '''
    X = sorted(X)
    min_dist = [0] * M
    if N == 1:
        return X[-1] - X[0]
    print(X)
    for i in range(1, M-1):
        min_dist[i] = min(abs(X[i] - X[i-1]), abs(X[i+1] - X[i]))
        print(min_dist)
    min_dist = sorted(min_dist)[::-1]
    print(min_dist)
    for i in range(N-2):
        if len(min_dist) > 0:
            min_dist.pop(-1)
    print(sum(min_dist))
    '''
main()
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

gcd = gcd(n, m)
L = int(n * m / gcd)

a = int(L/n)
b = int(L/m)

flag=True

for i in range(L):
    if (int(i%a) == 0 and int(i%b) == 0):
        if not S[int(i/a)] == T[int(i/b)]:
            flag = False
if flag:
    print(L)
else:
    print("-1")


Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

gcd = gcd(n, m)
L = int(n * m / gcd)

a = int(L/n)
b = int(L/m)

flag=True

if n > m:
    for j in range(n):
        i = j * a
        if (int(i%a) == 0 and int(i%b) == 0):
            if not S[int(i/a)] == T[int(i/b)]:
                flag = False
else:
    for j in range(m):
        i = j * b
        if (int(i%a) == 0 and int(i%b) == 0):
            if not S[int(i/a)] == T[int(i/b)]:
                flag = False
                
if flag:
    print(L)
else:
    print("-1")
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    K = I()
    a == K // 2
    b = K - a
    print(a*b)

main()



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    K = I()
    a = K // 2
    b = K - a
    print(a*b)

main()
Buggy python submission (verdict: Runtime Error):
R=input()
if R<1200:
  print("ABC")
elif R<2800:
  print("ARC")
else:
  print("AGC")

Fixed submission:
r = int(input())
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")

Buggy python submission (verdict: Runtime Error):
r = input()
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")

Fixed submission:
r = int(input())
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Runtime Error):
s = input()
smalls = "abcdefghijklmnopqrstuvwxyz".split()
def solve(s):
    count = 0
    if s[0] != "A":
        return False
    if s[1] not	in smalls:
	return False
    for char in s[2:]:
	if char	not in smalls:
            return False
	if char	== "C":
            count += 1
    if count !=	1:
	return False
    return True

if solve(s):
    print("AC")
else:
    print("WA")



Fixed submission:
s = input()
smalls = "abcdefghijklmnopqrstuvwxyz"
def solve(s):
    count = 0
 
    if s[0] != "A":
        return False
 
    if s[1] not in smalls:
        return False
    for char in s[2:-1]:
        if char == "C":
            count += 1
            continue
 
        if char not in smalls:
            return False
    if count != 1:
        return False
    if s[-1] not in smalls:
	    return False
    return True
 
if solve(s):
    print("AC")
else:
    print("WA")
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = []
    H, W = LI()
    for i in range(H):
        _s = S()
        s.append(_s)
    for i in range(W):
        for j in range(H):
            if s[i][j] == '.':
                continue
            any_tonari_black = False
            for dr, dc in zip(DR, DC):
                new_i = i + dr
                new_j = j + dc
                if not (0 <= new_i < W and 0 <= new_j < H):
                    continue
                if s[new_i][new_j] == '#':
                    any_tonari_black = True
            if not any_tonari_black:
                print('No')
                return
    print('Yes')
main()



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    s = []
    H, W = LI()
    for i in range(H):
        _s = S()
        s.append(_s)
    for r in range(H):
        for c in range(W):
            if s[r][c] == '.':
                continue
            any_tonari_black = False
            for dr, dc in zip(DR, DC):
                new_r = r + dr
                new_c = c + dc
                if not (0 <= new_r < H and 0 <= new_c < W):
                    continue
                if s[new_r][new_c] == '#':
                    any_tonari_black = True
            if not any_tonari_black:
                print('No')
                return
    print('Yes')
main()
Buggy python submission (verdict: Runtime Error):
a,b,c,x,y = map(int, raw_input().split())
ans = min(a*x + b*y, min(2*c*max(x,y), 2*c*min(x,y) + (x-y)*a if x>y else 2*c*min(x,y) + (y-x)*b))
print(ans)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B, C, X, Y = LI()
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    money_a_b = X * A + Y * B
    money_b_c = (Y - X) * B + (2 * X) * C
    money_c = Y * 2 * C
    ans = min(money_a_b, money_b_c, money_c)
    print(ans)

main()

Buggy python submission (verdict: Runtime Error):
a,b,c,x,y = map(int, raw_input().split())
ans = min(a*x + b*y, min(2*c*max(x,y), 2*c*min(x,y) + (x-y)*a if x>y else 2*c*min(x,y) + (y-x)*b))
print(ans)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B, C, X, Y = LI()
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    money_a_b = X * A + Y * B
    money_b_c = (Y - X) * B + (2 * X) * C
    money_c = Y * 2 * C
    ans = min(money_a_b, money_b_c, money_c)
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = 0
if N > 1 and M > 1:
    ans = (N-2) * (M-2)

elif:
    ans = 1
else:
    ans = max(N, M) - 2
print(ans)


Fixed submission:
N, M = map(int, input().split())
ans = 0
if N > 1 and M > 1:
    ans = (N-2) * (M-2)

elif N==1 and M==1:
    ans = 1
else:
    ans = max(N, M) - 2
print(ans)
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm(a, b):
    gcd = fractions.gcd
    n_gcd = gcd(a, b)
    return a * b // n_gcd

def main():
    N = I()
    T = []
    for _ in range(N):
        T.append(I())
    n_lcm = lcm(T[0], T[1])
    for i in range(2, N):
        n_lcm = lcm(n_lcm, T[i])
    print(n_lcm)
main()



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def lcm(a, b):
    gcd = fractions.gcd
    n_gcd = gcd(a, b)
    return a * b // n_gcd

def main():
    N = I()
    T = []
    for _ in range(N):
        T.append(I())
    n_lcm = lcm(T[0], T[0])
    for i in range(1, N):
        n_lcm = lcm(n_lcm, T[i])
    print(n_lcm)
main()
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
   
N, M = LI()
mat = [[0] * N for _ in range(M)]
for _ in range(M):
    a, b = LI_()
    mat[a][b] = 1
    mat[b][a] = 1 
seen = [0 for _ in range(N)]
ans = 0

def dfs(i, count):
    global ans
    import pdb
    # pdb.set_trace()
    if count == N:
        return True

    for j, reachable in enumerate(mat[i]):
        if reachable and not seen[j]:
            seen[j] = 1
            if dfs(j, count + 1):
                ans += 1
            seen[j] = 0

    return False

def main():
    seen[0] = 1
    dfs(0, 1)
    print(ans)
main()



Fixed submission:
import pdb

N, M = map(int, input().split())
a, b = [], []
mat = [[0 for _ in range(N)] for _ in range(N)]

for _ in range(M):
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)
    mat[_a-1][_b-1] = 1
    mat[_b-1][_a-1] = 1

visited = set()
ans = 0

def dfs(num):
    global ans
    #pdb.set_trace()
    visited.add(num)
    if len(visited) == N:
        ans += 1
        return 
    
    for next_num, connected in enumerate(mat[num]):
        if not connected:
            continue
        if next_num in visited:
            continue
        visited.add(next_num)
        dfs(next_num)
        visited.remove(next_num)
    return

def main():
    dfs(0)
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
N = input()
a = raw_input().split()
ans = 0
for i in xrange(N):
    if a[ a[i] - 1 ] == i+1:
       ans += 1
print ans

Fixed submission:
N = input()
a = raw_input().split()
ans = 0
for i in xrange(N):
    target = int(a[i]) - 1
    if int(a[target]) == i+1:
       ans += 1
print ans/2
Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

fac = [-1] * (2 * 10**6+1)
inv = [-1] * (2 * 10**6+1)
finv = [-1] * (2 * 10**6+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

initNCMMod(2 * 10**6 + 1)
def main():
    H, W, A, B = LI()
    cnt = 0
    for i in range(H-A):
        way = NCMMod(B + i - 1, i) * NCMMod(W + H - B - i - 2, W - 1 - B)
        way %= mod
        cnt += way
        cnt %= mod
    print(cnt)


main()



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

fac = [-1] * (2 * 10**6+1)
inv = [-1] * (2 * 10**6+1)
finv = [-1] * (2 * 10**6+1)

fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1

def initNCMMod(limit):
    for i in range(2, limit):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def NCMMod(n, k):
    if n < k:
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

initNCMMod(2 * 10**6 + 1)
def main():
    H, W, A, B = LI()
    cnt = 0
    for i in range(H-A):
        way = NCMMod(B + i - 1, i) * NCMMod(W + H - B - i - 2, W - 1 - B)
        way %= mod
        cnt += way
        cnt %= mod
    print(cnt)


main()
Buggy python submission (verdict: Runtime Error):
def main():
    N=int(input())
    c=list(input())[::-1]
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    res=0
    cR=c.count('R')
    cW=c.count('W')
    
    l,r=0,N-1
    while True:
        if c[l]=='W':
            if c[r]=='R':
                c[l],c[r]='R','W'
                res+=1
            else:
                r-=1
        else:
            l+=1
        
    print(min(cR,cW,res))
    
 
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N=int(input())
    c=list(input())
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    res=0
    cR=c.count('R')
    cW=c.count('W')
    
    l,r=0,N-1
    while l!=r:
        if c[l]=='W':
            if c[r]=='R':
                c[l],c[r]='R','W'
                res+=1
            else:
                r-=1
        else:
            l+=1
        
    print(min(cR,cW,res))
    
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    c=input()
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    i=0
    for _ in range(N):
        if 'WR' in c:
            x=c.index('WR')  
            y=N-c[::-1].index('R')-1
            cl=list(c)
            cl[x]='R'
            cl[y]='W'
            c=''.join(cl)
            #c=c[:x]+'R'+c[x+1:y]+'W'+c[y+1:]
            #print(c)
            #print(x,y)
            i+=1
    #print(i) 
    print(min(c.count('R'),c.count('W'),i))
    
 
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N=int(input())
    c=list(input())
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    res=0
    cR=c.count('R')
    cW=c.count('W')
    
    l,r=0,N-1
    while l!=r:
        if c[l]=='W':
            if c[r]=='R':
                c[l],c[r]='R','W'
                res+=1
            else:
                r-=1
        else:
            l+=1
        
    print(min(cR,cW,res))
    
 
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    c=input()
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    i=0
    for _ in range(N):
        if 'WR' in c:
            x=c.index('WR')  
            y=N-c[::-1].index('R')-1
            #print(x,y)
            c=c[:x]+'R'+c[x+1:y]+'W'+c[y+1:]
            #print(c)
            i+=1
            
    print(min(c.count('R'),c.count('W'),i))
    

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N=int(input())
    c=list(input())
    
    #x...WR
    #o...RR, RW, WW
    #Wが来たらそれ以降はW
    #R(0個以上)+W(0個以上)
    
    res=0
    cR=c.count('R')
    cW=c.count('W')
    
    l,r=0,N-1
    while l!=r:
        if c[l]=='W':
            if c[r]=='R':
                c[l],c[r]='R','W'
                res+=1
            else:
                r-=1
        else:
            l+=1
        
    print(min(cR,cW,res))
    
 
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import string
n=int(input())
alp=string.ascii_lowercase
k=1
s=0
lis=[0]
ans=''

for i in range(1,12):
    k*=26
    s += k
    lis.append(s)
    if s >= n:
        break
#print(i,lis)
x=n-lis[-2]

for i in reversed(range(1,i)):
    q,m=divmod(x,26**i)
    #print(x,q,m)
    #print(alp[q])
    ans+=alp[q]
    x=m
#print(x)
#print(alp[x-1])
ans+=alp[x-1]
print(ans)

Fixed submission:
import bisect
import string
N=int(input())

s=string.ascii_lowercase

k=1
lis=[0]
for i in range(11):
    k*=26
    lis.append(k+lis[-1])
#print(lis)

keta=bisect.bisect(lis, N-1)
#print(keta,N-lis[keta-1])

ans=''
n=N-lis[keta-1]-1
for i in range(keta):
    q,m=divmod(n,26)
    #print(q,m)
    n=q
    ans+=s[m]
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
s = int(input())
if s[1] == 'B':
  print('ARC')
else:
  print('ABC')

Fixed submission:
s = input()
if s[1] == 'B':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
n = int(input())
li = input().split()

for i in range(n):
    print(li.count(str(i+1)))


Fixed submission:
# coding: utf-8
import collections
n = int(input())
lis = input().split()
#n = 2*(10**5)
#lis= [1]*n

li = collections.Counter(lis)
for i in range(n):
    #print(li.count(str(i+1)))
    print(li[str(i+1)])
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
import re

n = int(input())
s = input()

R = [m.start() for m in re.finditer('R', s)]
G = [m.start() for m in re.finditer('G', s)]
B = [m.start() for m in re.finditer('B', s)]

x=0
for r in R:
    for g in G:
        if r < g:
            gr = g-r
            if r-gr in B:
                x += 1
            if g+gr in B:
                x += 1
            if gr%2 == 0 and r+gr//2 in B:
                x += 1
        else:
            rg = r-g
            if g-rg in B:
                x += 1
            if r+rg in B:
                x += 1
            if rg%2 == 0 and g+rg//2 in B:
                x += 1
                
print(len(R)*len(G)*len(B)-x)

Fixed submission:
# coding: utf-8
import re

n = int(input())
s = input()

R = set([m.start() for m in re.finditer('R', s)])
G = set([m.start() for m in re.finditer('G', s)])
B = set([m.start() for m in re.finditer('B', s)])
#print(R,G,B)
x=0
li=[]
for r in R:
    for g in G:
        
        if r < g:
            gr = g-r
            li.extend([r-gr in B, g+gr in B, (gr%2 == 0 and r+gr//2 in B)])
        
        else:
            rg = r-g
            li.extend([g-rg in B, r+rg in B, (rg%2 == 0 and g+rg//2 in B)])

print(len(R)*len(G)*len(B)-sum(li))