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

Fixed submission:
h,w = map(int,input().split())
n = int(input())
l = list(map(int,input().split()))
ans = [[0]*w for i in range(h)]
x,y = 0,0
z = 1
num = 1
for i in range(n):
    count = 0
    while count < l[i]:
        ans[x][y] = i+1
        count += 1
        if z == 1:
            if y == w-1:
                x += 1
                z = 2
                
            else:
                y += 1
        elif z == -1:
            if y == 0:
                x += 1
                z = 2
            else:
                y -= 1
        elif z == 2:
            if w != 1:
                if y == 0:
                    y += 1
                    z = 1
                else:
                    y -= 1
                    z = -1
            else:
                x += 1
        
for i in ans:
    print(*i)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
n = int(input())
l = list(map(int,input().split()))
ans = [[0]*w for i in range(h)]
x,y = 0,0
z = 1
num = 1
for i in range(n):
    count = 0
    while count < l[i]:
        ans[x][y] = i+1
        count += 1
        if z == 1:
            if y < w-1:
                y += 1
            else:
                x += 1
                z = 2
        elif z == -1:
            if y == 0:
                x += 1
                z = 2
            else:
                y -= 1
        elif z == 2:
            if y == 0:
                y += 1
                z = 1
            else:
                y -= 1
                z = -1
        
for i in ans:
    print(*i)
Problem p03644 (python)

Fixed submission:
n = int(input())
ans = 1
for i in range(10):
  if ans < n:
    ans *= 2
  elif ans > n:
    print(ans // 2)
    exit()
  else:
    print(ans)
    exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
for i in range(10):
  if ans < n:
    ans *= 2
  elif ans > n:
    print(ans //= 2)
    exit()
  else:
    print(ans)
    exit()
Problem p03698 (python)

Fixed submission:
s = list(input())
print("yes" if len(s) == len(set(s)) else "no")

Buggy submission (verdict: Runtime Error):
s = list(input())
print("yes" is len(s) == len(set(s)) else "no")
Problem p03720 (python)

Fixed submission:
n,m = map(int,input().split())
l = [0]*n
for i in range(m):
  a,b = map(int,input().split())
  l[a-1] += 1
  l[b-1] += 1
for i in l:
  print(i)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [0]*n
for i in range(n):
  a,b = map(int,input().split())
  l[a-1] += 1
  l[b-1] += 1
for i in l:
  print(i)
Problem p03798 (python)

Fixed submission:
n = int(input())
l = list(input())

def che(k):
    if l[k] == "o":
        if ans[k] == 1:
            if ans[k-1]*ans[(k+1)%n] == 1:
                return True
            else:
                return False
        else:
            if ans[k-1]*ans[(k+1)%n] == -1:
                return True
            else:
                return False

    else:
        if ans[k] == 1:
            if ans[k-1]*ans[(k+1)%n] == -1:
                return True
            else:
                return False
        else:
            if ans[k-1]*ans[(k+1)%n] == 1:
                return True
            else:
                return False


check = [[1,1],[1,-1],[-1,1],[-1,-1]]
for j,k in check:
    ans = [0]*n
    ans[0] = j
    ans[1] = k
    
    for i in range(1,n):
        if ans[i] == 1:
            if l[i] == "o":
                ans[(i+1)%n] = ans[i-1]
            else:
                ans[(i+1)%n] = -ans[i-1]

        else:
            if l[i] == "o":
                ans[(i+1)%n] = -ans[i-1]
            else:
                ans[(i+1)%n] = ans[i-1]
    d = True
    
    for m in range(n):
        if che(m) == False:
            d = False
            
    if d:
        for i in ans:
            if i == 1:
                print("S",end="")
            else:
                print("W",end="")
        exit()  
            
print(-1)

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


check = [[1,1],[1,-1],[-1,1],[-1,-1]]
for j,k in check:
    ans = [0]*n
    ans[0] = j
    ans[1] = k
    
    for i in range(1,n):
        if ans[i] == 1:
            if l[i] == "o":
                ans[(i+1)%n] = ans[i-1]
            else:
                ans[(i+1)%n] = -ans[i-1]

        else:
            if l[i] == "o":
                ans[(i+1)%n] = -ans[i-1]
            else:
                ans[(i+1)%n] = ans[i-1]
        
    if j == ans[0]:  
        if l[0]=="o":
            if k == ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")
            exit()
        else:
            if k == -ans[-1]:
                for i in ans:
                    if i == 1:
                        print("S",end="")
                    else:
                        print("W",end="")

			exit()
        
        
        
            
print(-1)
Problem p03837 (python)

Fixed submission:
import heapq
n,m, = map(int,input().split())
E = [[] for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    E[a].append((c,b))
    E[b].append((c,a))


def dijkstra(x):
    dis = [float("inf")]*n
    dis[x] = 0
    q = []
    heapq.heappush(q,(0,x))
    
    while q:
        cost,bef = heapq.heappop(q)

        if dis[bef] < cost:
            continue

        for ncost,nex in E[bef]:
            dist = ncost+cost

            if dist < dis[nex]:
                dis[nex] = dist
                heapq.heappush(q,(dist,nex))
    return dis

short = []
for i in range(n):
    short.append(dijkstra(i))
count = 0
for i in range(n):
    for dist,nex in E[i]:
        if short[i][nex] < dist:
            count += 1
print(count//2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

from collections import deque
import copy
n,m = map(int,input().split())
r = [[] for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    r[a-1].append((b-1,c,i+1))
    r[b-1].append((a-1,c,i+1))

def bfs(x,y):
    q = deque([])
    l = [-1]*n
    l[x] = 0
    check =[[] for i in range(n)]
    q.append((x,0,[]))
    while q:
        bef,pas,rec = q.popleft()
        if bef == y:
            break
            

        for nex,c,num in r[bef]:
            rec2 = copy.deepcopy(rec)
            rec2.append(num)
            
            if l[nex] == -1:
                l[nex] = pas+c
                check[nex] = rec2
                q.append((nex,pas+c,rec2))
            else:
                
                if pas+c < l[nex]:  
                    l[nex] = pas+c
                    check[nex] = rec2
                elif pas+c == l[nex]:
                    check[nex].append(rec2)
                else:
                    continue
    return check[y]

ans = set()
for i in range(n):
    for j in range(n):
        for k in bfs(i,j):
            ans.add(k)
        if len(ans) == m:
            print(0)
            exit()
print(m-len(ans))
Problem p03962 (python)

Fixed submission:
print(len(set(map(int,input().split()))))

Buggy submission (verdict: Runtime Error):
print(len(set(list(map(int,input().split()))))
Problem p03992 (python)

Fixed submission:
s = input()
print(s[:4]+" "+s[4:])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[:4]+" "+s[4:]
Problem p04020 (python)

Fixed submission:
n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]

count = 0

for i in range(n):
    if lis[i]%2 == 0:
        count += lis[i]//2
    else:
        if lis[i+1] > 1:
            count += lis[i]//2+1
            lis[i+1] -= 1
        else:
            count += lis[i]//2
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
lis = [int(input()) for i in range(n)]+[0]

count = 0
m = -1
for i in range(n):
    if lis[i]%2 == 0:
        count += l[i]//2
    else:
        if lis[i+1] > 1:
            count += lis[i]//2+1
            lis[i+1] -= 1
        else:
            count += lis[i]//2
print(count)
Problem p04029 (python)

Fixed submission:
print(sum([i+1 for i in range(int(input()))]))

Buggy submission (verdict: Runtime Error):
print(sum[i for i in range(int(input())+1)])
Problem p02705 (python)

Fixed submission:
import math
r = int(input())
print(float(r*2*(math.pi)))

Buggy submission (verdict: Runtime Error):
import math
r = int(input())
print(float(r*2*(math.pi)))73
Problem p02718 (python)

Fixed submission:
n, m = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
i = 0
for j in range(n):
    i = i + a[j]
x = i / (4 * m)
print("Yes" if a[m - 1] >= x else "No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
i = 0
for j in range(n):
    i = i + a[j]
x = i / (4 * m)
print("Yes" if a[m] >= x else "No")
Problem p02801 (python)

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

Buggy submission (verdict: Runtime Error):
letter = ord(input())
print(chr(c+1))
Problem p02657 (python)

Fixed submission:
n,m=map(int,input().split())
print(n*m)

Buggy submission (verdict: Runtime Error):
n=int(input())
m=int(input())
print(n*m)
Problem p02613 (python)

Fixed submission:
n = int(input())
a = [0,0,0,0]
for i in range(n):
  s = input()
  if s=="AC":
    a[0] += 1
  elif s=="WA":
    a[1] += 1
  elif s=="TLE":
    a[2] += 1
  else:
    a[3] += 1
print("AC x ",end="")
print(a[0])
print("WA x ",end="")
print(a[1])
print("TLE x ",end="")
print(a[2])
print("RE x ",end="")
print(a[3])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0,0,0,0]
for i in range(n):
  s = input()
  if s=="AC":
    a[0] += 1
  elif s=="WA":
    a[1] += 1
  elif s=="TLE":
    a[2] += 1
  elif :
    a[3] += 1
print("AC x ",end="")
print(a[0])
print("WA x ",end="")
print(a[1])
print("TLE x ",end="")
print(a[2])
print("RE x ",end="")
print(a[3])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [0,0,0,0]
for i in range(n):
  if input()=="AC":
    a[0] += 1
  elif input()=="WA":
    a[1] += 1
  elif input()=="TLE":
    a[2] += 1
  else:
    a[3] += 1
print("AC x ",end="")
print(a[0])
print("WA x ",end="")
print(a[1])
print("TLE x ",end="")
print(a[2])
print("RE x ",end="")
print(a[3])
Problem p02658 (python)

Fixed submission:
import sys
n = int(input())
ans = 1
s = input()
a = [int(x.strip()) for x in s.split(' ')]
if 0 in a:
  print(0)
  sys.exit()
for i in range(n):
  ans *= a[i]
  if ans>1000000000000000000:
    print(-1)
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
s = input()
a = [int(x.strip()) for x in s.split(' ')]
if 0 in a:
  print(0)
  return
for i in range(n):
  ans *= a[i]
  if ans>1000000000000000000:
    print(-1)
    return
print ans
Problem p02554 (python)

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

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <stack>
#define _GLIBCXX_DEBUG
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long a = 1, b = 1, c = 1;
    for (int i = 0; i < n; i++)
    {
        a *= 10;
        a %= 1000000007;
        b *= 9;
        b %= 1000000007;
        c *= 8;
        c %= 1000000007;
    }
    cout << (a-b-b+c+1000000007)%1000000007 << endl;
}
Problem p02576 (python)

Fixed submission:
import math

n,x,t = map(int, input().split())
print(math.ceil(n/x)*t)

Buggy submission (verdict: Runtime Error):
import math

n,x,t = map(int, input().split())
print(math.ceil(n/x)*t)import math
Problem p02613 (python)

Fixed submission:
n = int(input())
A = [input() for _ in range(n)]
a = int()
b = int()
c = int()
d = int()
for x in range(n):
    if A[x] == "AC":
        a = a+1
    elif A[x] == "WA":
        b = b+1
    elif A[x] == "TLE":
        c = c+1
    elif A[x] == "RE":
        d = d+1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [input() for _ in range(n)]
a,b,c,d = int()
for x in range(n):
    if A[x] == "AC":
        a = a+1
    elif A[x] == "WA":
        b = b+1
    elif A[x] == "TLE":
        c = c+1
    elif A[x] == "RE":
        d = d+1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)
Problem p02760 (python)

Fixed submission:
def main():
    import itertools
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))
    c = tuple(map(int,input().split()))
    d = (a[0],b[0],c[0])
    e = (a[1],b[1],c[1])
    f = (a[2],b[2],c[2])
    g = (a[0],b[1],c[2])
    h = (a[2],b[1],c[0])
    n = int(input())
    listB = [int(input()) for x in range(n)]
    X = itertools.permutations(listB,3)
    R = list(X)
    if a in R or b in R or c in R or d in R or e in R or f in R or g in R or h in R:
      print("Yes")
    else:
      print("No")
main()

Buggy submission (verdict: Runtime Error):
def main():
    S = str(input())
    T = str(input())
    a = int(0)
    for x in range(len(S)):
      if S[x]!=T[x]:
          a = a + 1
    print(int(a))
main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    c = list(map(int,input().split()))
    d = [a[0],b[0],c[0]]
    e = [a[1],b[1],c[1]]
    f = [a[2],b[2],c[2]]
    g = [a[0],b[1],c[2]]
    h = [a[2],b[1],c[0]]
    n = int(input())
    listB = [int(input()) for x in range(n)]
    C = itertools.combinations(listB,3)
    if a in C or b in C or c in C or d in C or e in C or f in C or g in C or h in C:
      print("Yes")
    else:
      print("No")
main()
Problem p03029 (python)

Fixed submission:
a,p = map(int, input().split())
print(int(((3*a+p)-(3*a+p)%2)/2))

Buggy submission (verdict: Runtime Error):
a,p = map(int, input().spilit())
print((3*a+p)/2-(3*a+p%2))
Problem p02886 (python)

Fixed submission:
n = int(input())
l = [int(i) for i in input().split()]
sum = 0
i = 0
while i < n-1:
    j = i+1
    while j < n:
        sum += l[i] * l[j]
        j += 1
    i += 1
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [int(i) for i in input().split()]
sum = 0
i = 0
while i < n:
    j = i+1
    while j <= n:
        sum += l[i] * l[j]
        j += 1
    i += 1
print(sum)
Problem p02909 (python)

Fixed submission:
s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]


N, M = [int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
for i in range(M):
    A[-1] = A[-1]//2
    A = sorted(A)
print(sum(A))
Problem p03059 (python)

Fixed submission:
A, B, T = map(int, input().split())
T += 0.5
print(int(T//A*B))

Buggy submission (verdict: Runtime Error):
A, B, T = map(int, input().split())
T += 0.5
print(int(T/A*B)
Problem p03852 (python)

Fixed submission:
c = input()
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':
  print('vowel')
else:
  print('consonant')

Buggy submission (verdict: Runtime Error):
c = input()
if c == a or c == i or c == u or c == e or c == o:
  print('vowel')
else:
  print('consonant')
Problem p03854 (python)

Fixed submission:
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if rev_S[:6] == 'resare':
    rev_S = rev_S[6:]
    continue
  elif rev_S[:7] == 'remaerd':
    rev_S = rev_S[7:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

if rev_S == '':
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
S = input()
strs = list(reversed(S))
rev_S = ''.join(strs)
while True:
  if rev_S[:6] == 'resare'
    rev_S = rev_S[6:]
    continue
  elif rev_S[:7] == 'remaerd':
    rev_S = rev_S[7:]
    continue
  elif rev_S[:5] == 'esare' or rev_S[:5] == 'maerd':
    rev_S = rev_S[5:]
    continue
  else:
    break

if rev_S == '':
  print('YES')
else:
  print('NO')
Problem p02924 (python)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy submission (verdict: Runtime Error):
 N = int(input())
 print(sum(range(1,N)))

Buggy submission (verdict: Runtime Error):
N = int(split())
print(sum(range(1,N)))
Problem p03079 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b & b==c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b && b==c:
  print("Yes")
else:
  print("No")
Problem p03206 (python)

Fixed submission:
D = int(input())
D -= 25
print('Christmas',end='')
while D<0:
    print(' Eve',end='')
    D += 1

Buggy submission (verdict: Runtime Error):
D = int(input())
D -= 25
print 'Christmas',end=''
while D<0:
    print 'Eve',end=''
    D += 1
Problem p03456 (python)

Fixed submission:
a,b = input().split()
c = a+b
c = int(c)
import math
if(int(math.sqrt(c)) ** 2 == c):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
def main():
    s = str(input())
    t = str(input())
    u = int(s+t)
    if(math.sqrt(u) ** 2 - u):
        print("No")
    else:
        print("Yes")
main()
Problem p03457 (python)

Fixed submission:
def boolean(a,b):
    D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
    if(D >= 0 and D %2 == 0):
        return 0
    else:
        return 1

N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
def boolean(a,b):
    if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
        return 0
    else:
        return 1

N = int(input())
lists=[0 for i in range(n+1)]
lists[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    lists[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
def boolean(a,b):
    if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
        return 0
    else:
        return 1

N = int(input())
txy[0] = [0,0,0]
txy = [input() for i in range(1,N + 1)]
txy = [list(map(int, txy[i].split())) for i in range(N+ 1)]
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)
Problem p03838 (python)

Fixed submission:
x,y = map(int,input().split())
ans = 0
if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0):
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
ans = 0

if(y > 0):
    if(x > y):
        ans += 1
        ans += -y +x
    elif(x >= 0):
        ans += y -x
    elif(x > -y):
        ans += 1
        ans += y + x
    else:
        ans += 1
        ans += -y -x
else:
    if(x > -y):
        ans += 1
        ans += y + x
    elif(x >= 0):
        ans += 1
        ans += -y -x
    elif(x > y):
        ans += 1
        ans += -y +x
        ans += 1
    else:
        ans += y -x

if(x == 0 and y == 0) ans = 0
print(ans)
Problem p03920 (python)

Fixed submission:
N = int(input())
vec = []

k = 0
sum = 0
while(k**2 + k < 2*N):
  k += 1
  sum += k
  vec.append(k)
if(sum - N):
  vec.remove(sum - N)


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

Buggy submission (verdict: Runtime Error):
N = int(input())
vec = []

k = 0
sum = 0
while(k**2 + k < 2*N):
  k += 1
  sum += k
  vec.append(k)

vec.remove(sum - N)

for i in range(len(vec)):
  print(vec[i])
Problem p02608 (python)

Fixed submission:
from math import sqrt
l = [-1]+[0]*10**4
n = int(input())
for i in range(1,int(sqrt(n))+2):
    for j in range(1,int(sqrt(n))+2):
        for k in range(1,int(sqrt(n))+2):
            ans = i**2+j**2+k**2+i*j+j*k+k*i
            if ans <= 10**4:
                l[ans] += 1
for i in range(1,n+1):
    print(l[i])

Buggy submission (verdict: Runtime Error):
from math import sqrt
l = [-1]+[0]*10**4
n = int(input())
for i in range(1,int(sqrt(n))+1):
    for j in range(1,int(sqrt(n))+1):
        for k in range(1,int(sqrt(n))+1):
            l[i**2+j**2+k**2+i*j+j*k+k*i] += 1
for i in range(1,n+1):
    print(l[i])
Problem p02642 (python)

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

l = [0]*(10**6+1)

for i in A:
    if l[i] <= 1:
        for j in range(0,10**6+1,i):
            l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)

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

l = [0]*(2*10**5+1)

for i in A:
    for j in range(0,10**5,i):
        l[j] += 1
count = 0
for i in A:
    if l[i] == 1:
        count += 1
print(count)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
l = [-1]+list(map(int,input().split()))

visited = [-1]+[False]*n

i = 1
while True:
    if visited[i]:
        fragrant = i
        break
    else:
        visited[i] = True
        i = l[i]

i = fragrant
cnt = 1
while l[i] != fragrant:
    cnt += 1
    i = l[i]
# print(cnt)

i = 1
while k > 0:
    i = l[i]
    k -= 1
    if i == fragrant:
        k %= cnt
print(i)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)
n,k = map(int,input().split())
l = list(map(int,input().split()))
def trans(n):
    if n == 1:
        return l[0]
    else:
        return l[trans(n-1)-1]
print(trans(k))
Problem p02691 (python)

Fixed submission:
import collections
n = int(input())
l = list(map(int,input().split()))
k = []
for i in range(n):
    k.append(i+1+l[i])
c = collections.Counter(k)
cnt = 0
for i in range(n):
    cnt += c[i+1-l[i]]
print(cnt)

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

N = int(input())
dict = defaultdict(int)
ans = 0
for i in range(N):
    s = ''.join(sorted(input()))
    ans += dict[s]
    dict[s] += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = []
for i in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  if h[a]<h[b]:
    l.append(a)
  elif h[a] == h[b]:
    l += [a,b]
  else:
    l.append(b)
s = set(l)
print(n-len(s))
Problem p02714 (python)

Fixed submission:
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = Counter(s)  

num = c['R']*c['G']*c['B']

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline
n = int(input())
s = list(input())

c  = list(Counter(s).values())  

num = c[0]*c[1]*c[2]

for j in range(n):
    for d in range(1,min(j,n-j-1)+1):
        i = j-d
        k = j+d
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            num -= 1
print(num)