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

Fixed submission:
import sys
import os
import re
import datetime
import bisect

####### main #######

N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB

print(sumBAll)

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

import sys
import os
import re
import datetime
import bisect

def Test(value):
    a = [1,3,5]
    #x = 4

    insert_index = bisect.bisect_left(a, value)
    
    print("insert_index = ", insert_index)
    
if False:   
    while(True): 
        Test(int(input('? ')));
    sys.exit()
 
N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
#for i in range(N):
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

if False:
    print("Sorted A" , partsNumA)
    print("Sorted B" , partsNumB)
    print("Sorted C" , partsNumC)

    print("B loop" , partsNumSumBa)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB
        
print(sumBAll)

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

import sys
import os
import re
import datetime
import bisect

def Test(value):
    a = [1,3,5]
    #x = 4

    insert_index = bisect.bisect_left(a, value)
    
    print("insert_index = ", insert_index)

####### main #######
    
if False:   
    while(True): 
        Test(int(input('? ')));
    sys.exit()
 
N = int(input())

partsNumA = sorted(map(int, input().split()))
partsNumB = sorted(map(int, input().split()))
partsNumC = sorted(map(int, input().split()))

# Bに対してAの個数のBによるループ
partsNumSumBa = []
sumA = 0
for curPartsB in partsNumB:
    indexA = bisect.bisect_left(partsNumA, curPartsB)
    numA = indexA
    sumA += numA
    partsNumSumBa.append(sumA)

# Cに対してBの個数のCによるループ
sumBAll = 0
for curPartsC in partsNumC:
    indexB = bisect.bisect_left(partsNumB, curPartsC)
    if indexB == 0:
        continue
    numB = partsNumSumBa[indexB - 1]
    sumBAll += numB
        
print(sumBAll)
Problem p02768 (python)

Fixed submission:
#coding:utf-8
#!/usr/bin/python

n,a,b=map(int,raw_input().split())

N=pow(10,9)+7
#n=1000000000
#a=141421
#b=173205

def modpow(b,e,m): 

    result=1

    while(e!=0): 
          if(e&1==1): 
             result=(result*b)%m 
          e>>=1
          b=(b*b)%m
    
    return result

def combination(n,r,N):
    bunshi=1
    for i in range(n-r+1,n+1):
        bunshi=(bunshi*i)%N
    bunbo=1
    for i in range(1,r+1):
        bunbo=(bunbo*i)%N
    return bunshi*modpow(bunbo,N-2,N)

#pow(2,n)-nCa-nCb-1
#nCr=n!/((n-r)!*r!)だから
#bunshi=n*n-1*・・・*n-r+1
#bunbo=1*・・・*r
#Nが素数だから、フェルマーの小定理より
#modpow(a,N-1,N)=1
#a*pow(a,N-2)=pow(a,N-1)=1(modN)
#より。aのmodNでの逆元はpow(a,N-2)になる。
#r!の逆元が欲しいから、modpow(bunbo,N-2,N)を掛ける。

print (modpow(2,n,N)-combination(n,a,N)-combination(n,b,N)-1)%N

Buggy submission (verdict: Runtime Error):
#coding:utf-8
#!/usr/bin/python

a,b=map(int,raw_input().split())

N=pow(10,9)+7
n=1000000000
#a=141421
#b=173205

def modpow(b,e,m): 

    result=1

    while(e!=0): 
          if(e&1==1): 
             result=(result*b)%m 
          e>>=1
          b=(b*b)%m
    
    return result

def combination(n,r,N):
    bunshi=1
    for i in range(n-r+1,n+1):
        bunshi=(bunshi*i)%N
    bunbo=1
    for i in range(1,r+1):
        bunbo=(bunbo*i)%N
    return bunshi*modpow(bunbo,N-2,N)

#pow(2,n)-nCa-nCb-1
#nCr=n!/((n-r)!*r!)だから
#bunshi=n*n-1*・・・*n-r+1
#bunbo=1*・・・*r
#Nが素数だから、フェルマーの小定理より
#modpow(a,N-1,N)=1
#a*pow(a,N-2)=pow(a,N-1)=1(modN)
#より。aのmodNでの逆元はpow(a,N-2)になる。
#r!の逆元が欲しいから、modpow(bunbo,N-2,N)を掛ける。

print (modpow(2,n,N)-combination(n,a,N)-combination(n,b,N)-1)%N
Problem p03105 (python)

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

if (b / a) >= c:
    print(c)
elif a > b:
    print(0)
else:
    print(int(b / a))

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
i = int(0)
l = list()
if a > b:
    maxim = a
else:
    maxim = b
for i in range(1,100):
        if ((a % i) == 0) and ((b % i) == 0):
            l.append(i)
        elif maxim < i:
            break

n = int(len(l))
if c == 1:
    n = n
else:
    n -= c
print(l[n])
Problem p03433 (python)

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

if (n % 500) <= a:
    print("Yes")
else:
    print("No")

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

if (n % 500)<= a:
    print("Yes")
else:
    print("No")
Problem p03145 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())
print(a*b//2)

Buggy submission (verdict: Runtime Error):
3 4 5
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
if a * b % 2 == 1:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a * b % 2 == 1:
    print(Odd)
else:
    print(Even)
Problem p03494 (python)

Fixed submission:
n = int(input())
num = list(map(int, input().split()))
count = 0
while True:
    exist_odd = "false"
    for i in range(n):
        if num[i] % 2 != 0:
            exist_odd = "True"
    if exist_odd == "True":
        break
    for i in range(n):
        num[i] /= 2
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = input()
num = list(map(int, input().split()))
count = 0
while sum(num) % 2 == 0:
    for i in range(n):
        num[i] /= 2
    count += 1
print(count)
Problem p03680 (python)

Fixed submission:
n = int(input())
botan = [int(input()) for i in range(n)]
light = 0 # 1番目のボタンが初め光ってる
count = 0

for i in range(n):
    light = botan[light] - 1
    if light == 1:
        break
    
if i == n - 1:
    print(-1)
else:
    print(i + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]

if 2 in botan:

    while True:
    light = botan[light - 1]
    if light in exi:
        print(-1)
        exit()
    exi.append(light)
    
    if 2 in exi:
        print(count)
        exit()
    count += 1

else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
botan = [int(input()) for i in range(n)]
light = 1 # 1番目のボタンが初め光ってる
count = 1
exi = [1]

if 2 is not in botan:
    print(-1)
    exit()

while True:
    light = botan[light - 1]
    if light in exi:
        print(-1)
        exit()
    exi.append(light)
    
    if 2 in exi:
        print(count)
        exit()
    count += 1
Problem p03860 (python)

Fixed submission:
a, b, c = map(str, input().split())
abb = a[0] + b[0] + c[0]
print(abb)

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

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // (x + 1) # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))

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

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 
                        # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))

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

def fanc(n, x):
    if n == -1:
        f = 0
    else:
        f = n // x + 1 # 切り捨て除算//を使うとint同士ならintで返してくれるから楽
    return f
print(fanc(b, x) - fanc(a - 1, x))
Problem p02811 (python)

Fixed submission:
import sys

def resolve():
    input = sys.stdin.readline
    K,X=map(int,input().rstrip().split())
     
    if K*500>=X:
        print("Yes")
    else:
        print("No")

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 900"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1 501"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """4 2000"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):
import sys
import itertools
from functools import reduce
import math
#import fractions
import numpy as np


def calc_double(n):
    return n//2
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)



def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=list(map(calc_double,A))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """
    aa= np.array(AA)
    a=int(np.lcm.reduce(aa))
    #a=lcm_list(AA)
    #a=a//2
    """
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break
    """
    odd=M//a
    count=(odd+1)//2

    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Problem p02818 (python)

Fixed submission:
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print(str(int(ansA))+" "+str(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print((int(ansA))+" "+(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
Problem p03160 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k<0):
            continue
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])

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

input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[0]*N
for i in range(N):
    dp[i]=math.inf
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import sys
import math
def resolve():
        input = sys.stdin.readline
        N=int(input().rstrip())
        h=list(map(int,input().rstrip().split()))

        dp=[math.inf]*N
        dp[0]=0

        for i in range(1,N,1):
            dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
            if(i>1):        
                dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

        print(dp[N-1])
          


from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4
10 30 40 20"""
        output = """30"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """2
10 10"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """6
30 10 60 10 60 50"""
        output = """40"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline
N=int(input().rstrip())
h=list(map(int,input().rstrip().split()))

dp=[math.inf]*N
dp[0]=0

for i in range(1,N,1):
    dp[i]=min(dp[i],dp[i-1]+abs(h[i]-h[i-1]))
    if(i>1):        
        dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])
Problem p03161 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k<0):
            continue
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
N,K=map(int,input().rstrip().split())
h=list(map(int,input().rstrip().split()))

inf=10**9+7
dp=[inf]*N
 for i in range(N):
     dp[i]=1000000000000
dp[0]=0

for i in range(1,N,1):
    for k in range(1,K+1,1):
        if(i-k<0):
            continue
        dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]))
print(dp[N-1])
Problem p03730 (python)

Fixed submission:
import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        exit()
print("NO")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
A,B,C=map(int,input().rstrip().split())
for i in range(B):
    if (i*(A%B))% B == C:
        print("YES")
        return
print("NO")
Problem p02761 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
num = [0] * (N + 1)
reg = [0] * (N + 1)
if N > 1:
  num[1] = 1

for i in range(M):
  s, c = map(int, input().split())
  if N > 1 and s == 1 and c == 0:
    print (-1)
    sys.exit()
  if reg[s] == 1 and num[s] != c:
    print (-1)
    sys.exit()
  num[s] = c
  reg[s] = 1

result = ""
for i in range(1, N + 1):
  result += str(num[i])
print (result)

Buggy submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
s = [0]
c = [0]
num = [0] * (N + 1)
reg = [0] * (N + 1)
if N > 1:
  num[1] = 1

for i in range(M):
  a, b = map(int, input().split())
  if N > 1 and a == 1 and b == 0:
    print (-1)
    sys.exit()

  s.append(a)
  c.append(b)

for i in range(1, M + 1):
  if reg[s[i]] == 1 and num[s[i]] != c[i]:
    print (-1)
    sys.exit()
  num[s[i]] = c[i]
  reg[s[i]] = 1

result = ""
for i in range(1, M + 1):
  result += str(num[i])
print (result)
Problem p02936 (python)

Fixed submission:
import sys
from collections import deque

stack = deque()
input = sys.stdin.readline

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

link = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    link[a - 1].append(b)
    link[b - 1].append(a)
    
states = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    states[p - 1] += x

check = [0] * N
stack.append(1)
check[0] = 1
while stack:
    node = stack.pop()
    for next_node in link[node - 1]:
        if check[next_node - 1]:
            continue
        states[next_node - 1] += states[node - 1]
        check[next_node - 1] = 1
        stack.append(next_node)

# Output
print(*states)

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

stack = deque()
input = sys.stdin.readline

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

link = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    link[a - 1].append(b)
    #link[b - 1].append(a)
    
states = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    states[p - 1] += x

check = [0] * N
stack.append(1)
check[0] = 1
while stack:
    node = stack.pop()
    for next_node in link[node - 1]:
        if check[next_node - 1]:
            continue
        states[next_node - 1] += states[node - 1]
        check[next_node - 1] = 1
        stack.append(next_node)

# Output
print(*states)
Problem p02995 (python)

Fixed submission:
from fractions import gcd

A, B, C, D = map(int, input().split())

CD_lcm = (C * D) // gcd(C, D)


def divided(a, b, target):
    return b // target - (a - 1) // target


all_num = B - A + 1

div_t1 = divided(A, B, C)
div_t2 = divided(A, B, D)
div_extra = divided(A, B, CD_lcm)

print(all_num - div_t1 - div_t2 + div_extra)

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

A, B, C, D = map(int, input().split())

if B < C and B < D:
    print(B - A + 1)
    exit()

CD_lcm = C * D // gcd(C, D)

n_cant_divs = []
for target in [C, D, CD_lcm]:
    if A <= target <= B:
        t_cant_div = target - A
        can_div = B // target
        t_cant_div2 = (B - target + 1) - can_div
        n_cant_divs.append(t_cant_div + t_cant_div2)
    elif target < A:
        can_div_w_over = B // target
        correction = (A - 1) // target
        actual_can_div = can_div_w_over - correction
        t_cant_div = (B - A + 1) - actual_can_div
        n_cant_divs.append(t_cant_div)

print(n_cant_divs[0] + n_cant_divs[1] - n_cant_divs[2])

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

A, B, C, D = map(int, input().split())

if B < C and B < D:
    print(A - B + 1)
    exit()

CD_lcm = C * D // gcd(C, D)

n_cant_divs = []
for target in [C, D, CD_lcm]:
    if A <= target <= B:
        t_cant_div = target - A
        can_div = B // target
        t_cant_div2 = (B - target + 1) - can_div
        n_cant_divs.append(t_cant_div + t_cant_div2)
    elif target < A:
        can_div_w_over = B // target
        correction = (A - 1) // target
        actual_can_div = can_div_w_over - correction
        t_cant_div = (B - A + 1) - actual_can_div
        n_cant_divs.append(t_cant_div)

print(n_cant_divs[0] + n_cant_divs[1] - n_cant_divs[2])
Problem p03261 (python)

Fixed submission:
n = int(input())

spoken_words = []
for i in range(n):
    word = input()
    if i >= 1:
        if word in spoken_words or spoken_words[-1][-1] != word[0]:
            print("No")
            exit()
    spoken_words.append(word)
print("Yes")

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

spoken_words = []
for i in range(9):
    word = input()
    if i >= 1:
        if word in spoken_words or spoken_words[-1][-1] != word[0]:
            print("No")
            exit()
    spoken_words.append(word)
print("Yes")
Problem p03282 (python)

Fixed submission:
S = input()
S_list = list(map(int, list(S)))
K = int(input())

S_set_under_K = set(S[:K])

if len(S) == 1:
    print(S)
elif len(S_set_under_K) == 1 and S_list[0] == 1:
    print(1)
else:
    for c in S:
        if c != "1":
            print(c)
            exit()

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

S_set_under_K = set(S[:K])

if len(S_set_under_K) == 1 and S_list[0] == 1:
    print(1)
else:
    print(S_list[1])