Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
w = []
h = []
for i in range(n):
    a,b = map(int,input().split())
    w.append(a)
    h.append(b)
dp = [[0]*(W+1) for i in range(n+1)]
for i in range(n):#i番目の種類の荷物まで使う
    for j in range(W+1):
        if j < w[i]: dp[i+1][j] = dp[i][j]#更新できない
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+h[i])
print(dp[n][W])

Fixed submission:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
w = []
h = []
for i in range(n):
    a,b = map(int,input().split())
    w.append(a)
    h.append(b)
dp = [[0]*(W+1) for i in range(n+1)]
for i in range(n):#i番目の種類の荷物まで使う
    for j in range(W+1):
        if j < w[i]: dp[i+1][j] = dp[i][j]#更新できない
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+h[i])
print(dp[n][W])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
weight = []
val = []
for i in range(n):
    a,b = map(int,input().split())
    weight.append(a)
    val.append(b)
max_v = sum(val) + 10 # 全部使ったとしてもこれ以上の勝ちにはならない
# point : v < =10^3 でn <= 10^2なので、n**2 vでもOK
# wが使えないときには変数を入れ替える
INF = 10**12+7 #Wより大きな値
dp = [[INF]*(max_v+1) for i in range(n+1)]
#初期化は 価値が0になる最小の重さが0なので、dp[i][0] = 0
# 漸化式：dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
# i+1　は i番目までの品物を使うとする
# 先にどっちからループを回した方が良い？価値か、品数か
#　品数が全部埋まってから、価値を更新する方が楽そう
for i in range(n+1):
    dp[i][0] = 0
for i in range(n):
    for j in range(max_v+1):
        if j-val[i] >= 0:
            #print("yes")
            dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]]+ weight[i])
        else: dp[i+1][j] = dp[i][j]
    if i == n-1:
        #print("Yes")
        #print(dp[i+1])
        #大きい方から見ていく
        for j in range(1,max_v+1):
            #print(j)
            if dp[i+1][-j] <= W:
                print(max_v - j + 1)
                break


Fixed submission:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
weight = []
val = []
for i in range(n):
    a,b = map(int,input().split())
    weight.append(a)
    val.append(b)
max_v = sum(val) + 10 # 全部使ったとしてもこれ以上の勝ちにはならない
# point : v < =10^3 でn <= 10^2なので、n**2 vでもOK
# wが使えないときには変数を入れ替える
INF = 10**12+7 #Wより大きな値
dp = [[INF]*(max_v+1) for i in range(n+1)]
#初期化は 価値が0になる最小の重さが0なので、dp[i][0] = 0
# 漸化式：dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i])
# i+1　は i番目までの品物を使うとする
# 先にどっちからループを回した方が良い？価値か、品数か
#　品数が全部埋まってから、価値を更新する方が楽そう
for i in range(n+1):
    dp[i][0] = 0
for i in range(n):
    for j in range(max_v+1):
        if j-val[i] >= 0:
            #print("yes")
            dp[i+1][j] = min(dp[i][j],dp[i][j-val[i]]+ weight[i])
        else: dp[i+1][j] = dp[i][j]
    if i == n-1:
        #print("Yes")
        #print(dp[i+1])
        #大きい方から見ていく
        for j in range(1,max_v+1):
            #print(j)
            if dp[i+1][-j] <= W:
                print(max_v - j + 1)
                break
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys

"""
ABC113_C ID 学び：
 python の0埋め　s.rjust(digit,0) でいける
 sortを県ごとにしないといけない、とわかれば、input, sort , outputの３段かいに別れる
どんな配列を持てばいいかは事前に考える。
実際にそこまで立てて、inputをローカルでやると良い
"""

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, input().split())
lis_p = [[] for _ in range(n)]  # 県pに属する市の誕生年が入る
city = [[0, 0] for _ in range(m)]  # p と　idx
idx_p = []  # 何番目にそのcity が県pに追加されたかを記憶
# input
for i in range(m):
    p, y = map(int, input().split())
    city[i][0] = p - 1
    city[i][1] = len(lis_p[p - 1])
    lis_p[p - 1].append(y)
for pref in range(n):
    k = len(lis_p[pref])
    # print(lis_p[pref])
    idx = []
    if k > 0:
        lis_p[pref], idx = zip(*sorted(zip(lis_p[pref], range(k))))
    idx_p.append(list(idx))
#print(lis_p, idx_p)
for i in range(m):
    # string になおす必要がある rjust
    print(str(city[i][0] + 1).rjust(6, "0"), end="")
    print(str(1 + idx_p[city[i][0]].index(city[i][1])).rjust(6, "0"))


Fixed submission:
#!/usr/bin/env python3
import sys
import bisect

"""
ABC113_C ID 学び：
 python の0埋め　s.rjust(digit,0) でいける
 sortを県ごとにしないといけない、とわかれば、input, sort , outputの３段かいに別れる
どんな配列を持てばいいかは事前に考える。
実際にそこまで立てて、inputをローカルでやると良い
"""

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n, m = map(int, input().split())
lis_p = [[] for _ in range(n)]  # 県pに属する市の誕生年が入る
city = [[0, 0] for _ in range(m)]  # p と　idx
idx_p = []  # 何番目にそのcity が県pに追加されたかを記憶
# input
for i in range(m):
    p, y = map(int, input().split())
    city[i][0] = p - 1
    city[i][1] = y
    lis_p[p - 1].append(y)
for pref in range(n):
    k = len(lis_p[pref])
    # print(lis_p[pref])
    idx = []
    if k > 0:
        lis_p[pref], idx = zip(*sorted(zip(lis_p[pref], range(k))))
    idx_p.append(list(idx))
# print(lis_p, idx_p)
for i in range(m):
    # string になおす必要がある rjust
    print(str(city[i][0] + 1).rjust(6, "0"), end="")
    print(str(1 + bisect.bisect_left(lis_p[city[i][0]], city[i][1])).rjust(6, "0"))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
n,m = map(int,input().split())
INF = m
ans = INF
for i in range(1,int(m**1/2) + 1):
    if m % i == 0:
        # i,m//iのうち、n 以上でmaxなものをansに入れる
        if i >= n: ans = min(ans,i)
        if m//i >= n: ans = min(ans,m//i)
print(m//ans)

Fixed submission:
#!/usr/bin/env python3
n,m = map(int,input().split())
INF = m
ans = INF
# どうしてTLE？？O(root(m))で10**4だからOKでは？ m ** 1/2だとm /2 になる
for i in range(1,int(m**(1/2)) + 1):
    if m % i == 0:
        # i,m//iのうち、n 以上でmaxなものをansに入れる
        if i >= n: ans = min(ans,i)
        if m//i >= n: ans = min(ans,m//i)
print(m//ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(10**5)
for i in a:
    cnt[i] += 1
cnt.sort()
#print(cnt[-1])
if cnt[-1] >= (n+1)//2: print(n//2 - cnt[-2])
else: print((n+1)//2 - cnt[-1]+ n//2 - cnt[-2])

Fixed submission:
#!/usr/bin/env python3

n = int(input())
a = list(map(int,input().split()))
cnt_odd = [0]*(10**5+1)# a[2k]での個数
cnt_even = [0]*(10**5+1)
for i in range(n):
    if i  %2: cnt_odd[a[i]] += 1
    else: cnt_even[a[i]] += 1
odd,idx_odd=zip(*sorted(zip(cnt_odd,list(range(10**5+1)))))
even,idx_even=zip(*sorted(zip(cnt_even,list(range(10**5+1)))))
#print(odd[-1],even[-2],odd[-2],even[-1])
if idx_even[-1]!=idx_odd[-1]:
    print(n - odd[-1] - even[-1])
else:
    print(n - max(odd[-1]+even[-2],odd[-2]+even[-1]))
#ちゃんとテストケース書かないと落ちる

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

n = int(input())
a = list(map(int,input().split()))
cnt = [0]*(10**5)
for i in a:
    cnt[i] += 1
cnt.sort()
#print(cnt[-1])
if cnt[-1] >= (n+1)//2: print(n//2 - cnt[-2])
else: print((n+1)//2 - cnt[-1]+ n//2 - cnt[-2])

Fixed submission:
#!/usr/bin/env python3

n = int(input())
a = list(map(int,input().split()))
cnt_odd = [0]*(10**5+1)# a[2k]での個数
cnt_even = [0]*(10**5+1)
for i in range(n):
    if i  %2: cnt_odd[a[i]] += 1
    else: cnt_even[a[i]] += 1
odd,idx_odd=zip(*sorted(zip(cnt_odd,list(range(10**5+1)))))
even,idx_even=zip(*sorted(zip(cnt_even,list(range(10**5+1)))))
#print(odd[-1],even[-2],odd[-2],even[-1])
if idx_even[-1]!=idx_odd[-1]:
    print(n - odd[-1] - even[-1])
else:
    print(n - max(odd[-1]+even[-2],odd[-2]+even[-1]))
#ちゃんとテストケース書かないと落ちる
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
s = input()
t = input()
s_idx = [""]*26
t_idx = [""]*26
for i in range(len(s)):
    s_idx[ord(s[i])-97] += str(i)
for i in range(len(s)):
    t_idx[ord(t[i])-97] += str(i)
s_idx.sort()
t_idx.sort()
if s_idx == t_idx:
    print("Yes")
else:
    print("No")


Fixed submission:
#!/usr/bin/env python3
s = input()
t = input()
s_idx = [[] for _ in range(26)]
t_idx = [[] for _ in range(26)]
for i in range(len(s)):
    s_idx[ord(s[i])-97].append(i)
visit = []
for i in range(26):
    cnt = 0
    for j in s_idx[i]:
        if cnt == 0 and t[j] in visit:
            print("No")
            exit()
        if cnt == 0:
            visit.append(t[j])
            cnt += 1
        else:
            if t[j] != visit[-1]:
                print("No")
                exit()
print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
s = input()
t = input()
s_idx = ["a"]*26
t_idx = ["a"]*26
for i in range(len(s)):
    s_idx[ord(s[i])-97] += str(i)
for i in range(len(s)):
    t_idx[ord(t[i])-97] += str(i)
for i in range(26):
    if s_idx[i] in t_idx:
        continue
    else:
        print("No")
        exit()
#print(s_idx,t_idx)
print("Yes")

Fixed submission:
#!/usr/bin/env python3
s = input()
t = input()
s_idx = [[] for _ in range(26)]
t_idx = [[] for _ in range(26)]
for i in range(len(s)):
    s_idx[ord(s[i])-97].append(i)
visit = []
for i in range(26):
    cnt = 0
    for j in s_idx[i]:
        if cnt == 0 and t[j] in visit:
            print("No")
            exit()
        if cnt == 0:
            visit.append(t[j])
            cnt += 1
        else:
            if t[j] != visit[-1]:
                print("No")
                exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math

n = int(input())
# 長さN になるまで、%5 = 1となる整数を列挙する
def sleve_of_Eratosthenes(n):
    # N 以下の素数を全列挙
    res = []
    if n == 1:
        return res
    ok = [False] * n
    for i in range(2, n + 1):
        if ok[i]:
            continue
        tmp = 1
        res.append(i)
        while tmp * i <= n:
            ok[tmp * i] = True
            tmp += 1
    return res


prime = sleve_of_Eratosthenes(55555)
len_arr = 0
arr = []
for a in prime:
    if a % 5 == 1:
        arr.append(a)
        len_arr += 1
        if len_arr == n:
            break
print(*arr)


Fixed submission:
#!/usr/bin/env python3
n = int(input())
# 長さN になるまで、%5 = 1となる整数を列挙する
def sleve_of_Eratosthenes(n):
    # N 以下の素数を全列挙
    res = []
    if n == 1:
        return res
    ok = [False] * (1 + n)
    for i in range(2, n + 1):
        if ok[i]:
            continue
        tmp = 1
        res.append(i)
        while tmp * i <= n:
            ok[tmp * i] = True
            tmp += 1
    return res


prime = sleve_of_Eratosthenes(55555)
len_arr = 0
arr = []
for a in prime:
    if a % 5 == 1:
        arr.append(a)
        len_arr += 1
        if len_arr == n:
            break
print(*arr)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = input()
print("Yes" if s.count["a"]*s.count["b"]*s.count["c"] == 1 else "No")

Fixed submission:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s = input()
print("Yes" if s.count("a")*s.count("b")*s.count("c") == 1 else "No")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
a,b,k = map(int,input().split())
for i in range(a,b+1):
    if a <= i <= a+k-1 or b-k+1 <= i <= b: print(i)

Fixed submission:
#!/usr/bin/env python3
a,b,k = map(int,input().split())
for i in range(a,min(b+1,a+k)):
    if a <= i <= a+k-1: print(i)
for i in range(b-k+1,b+1):
    if a+k-1 < i:print(i)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c,d = map(int,input().split())
print(min(a,b)+min(c,d))

Fixed submission:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a,b)+min(c,d))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input())
# can't understand meaning
if N == 1 and M == 1:
  ans = 1
elif N == 1 or M == 1:
  ans = max(N,M) -2
else:
  ans = (N-2)*(M-2)
print(ans)

Fixed submission:
#!/usr/bin/env python3
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n,m)-2)
else: print((n-2)*(m-2))
Buggy python submission (verdict: Runtime Error):
// space 区切りの文字を入力として、Yが存在すれば、Four, else Threeを出力

#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  char s[n]; // 配列の初期化はs[n] n：要素数
  int ans = 0; // if ans == 0, Three
  for (int i=0;i < n ;i++){
    cin >> s[i];
    //cout << s[i];
    //charで比較するときは''にする、""だと文字列
    if ( s[i] == 'Y' ){
      ans = 1;
      break;
    }
  }
  if ( ans == 0){
    cout << "Three" << endl;
  }
  else{
    cout << "Four" << endl;
  }
}
        


Fixed submission:
n = int(input())
s = list(map(str,input().split()))
ans = 0
for i in range(len(s)):
    if s[i] == "Y":
        ans = 1
        break
if ans == 0:
    print("Three")
else:
    print("Four")
Buggy python submission (verdict: Runtime Error):
s = input()
if len(s) == 1: print(int(s[0])
elif s[1:] == "9"*(len(s)-1): print(int(s[0]+9*len(s)-9)
else: print(int(s[0]+9*len(s)-10)                                    

Fixed submission:
#!/usr/bin/env python3
s = input()
digit = len(s)
if s[1:] == "9"*(digit-1):
    print(int(s[0])+9*(digit-1))
else:
    print(int(s[0])+9*(digit-1)-1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
x = int(input())
y = int(input())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(2*x)
	 


Fixed submission:
#!/usr/bin/env python
x,y = map(int,input().split())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
x = int(input())
y = int(input())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)
	 


Fixed submission:
#!/usr/bin/env python
x,y = map(int,input().split())
if x % y  == 0 or x > 10**18:
	print(-1)
else:
	print(x)
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split())
ans = (-1,-1,-1)
for i in range(n+1): 
	for j in range(n+1-i):
		if y == 1000*(i + j * 5 + (n+1-i-j) * 10 ): 
			print( n+1-i-j j, i)
			exit()
print(-1,-1,-1)


Fixed submission:
#!/usr/bin/env python3
n,y = map(int,input().split())
ans = (-1,-1,-1)
for i in range(n+1): 
	for j in range(n+1-i):
		if y == 1000*(i + j * 5 + (n-i-j) * 10 ): 
			print( n-i-j, j, i ) # 逆だった。出力は10000から出す
			exit(0)
print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

q = int(input())
cnt = [0] * (5 * 10 ** 4)
cnt[1] = 1
cnt[2] = 2


def is_prime(n):
    visit = []
    if n % 2 == 0:
        return 0
    for i in range(3, 1 + math.ceil(n ** (0.5))):
        if i not in visit:
            if n % i == 0:
                return 0
            else:
                visit.append(i)
    return 1


for i in range(3, 5 * 10 ** 4):
    odd = 2 * i + 1
    if odd % 3 != 1:
        cnt[i] = cnt[i - 1]
    else:
        k = 0
        if is_prime(odd) and is_prime((odd + 1) // 2):
            k = 1
            # print(odd, is_prime(odd), is_prime((odd + 1) // 2))
        cnt[i] = cnt[i - 1] + k
cnt.append(0)
for i in range(q):
    l, r = map(int, input().split())
    print(cnt[(r - 1) // 2] - cnt[(l - 3) // 2])


Fixed submission:
import math

q = int(input())
cnt = [0] * (5 * 10 ** 4)
cnt[1] = 1
cnt[2] = 2


def is_prime(n):
    visit = []
    if n % 2 == 0:
        return 0
    for i in range(3, 1 + math.ceil(n ** (0.5))):
        if i not in visit:
            if n % i == 0:
                return 0
            else:
                visit.append(i)
    return 1


for i in range(3, 5 * 10 ** 4):
    odd = 2 * i + 1
    if odd % 3 != 1 or (odd + 1) % 4 == 0:
        cnt[i] = cnt[i - 1]
    else:
        k = 0
        if is_prime(odd) and is_prime((odd + 1) // 2):
            k = 1
            # print(odd, is_prime(odd), is_prime((odd + 1) // 2))
        cnt[i] = cnt[i - 1] + k
cnt.append(0)
for i in range(q):
    l, r = map(int, input().split())
    print(cnt[(r - 1) // 2] - cnt[(l - 3) // 2])
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n - 1):
            print(idx[n - 1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n - 1):
            print(idx[0], i + 2)
        for i in range(n - 1):
            print(n - i, n - i - 1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n + 1))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n):
            if i + 1 != idx[-1]:
                print(idx[-1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n):
            if i + 1 != idx[0]:
                print(idx[0], i + 1)
        for i in range(n - 1):
            print(n - i, n - i - 1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n - 1):
            print(idx[n - 1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n - 1):
            print(idx[0], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n + 1))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n):
            if i + 1 != idx[-1]:
                print(idx[-1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n):
            if i + 1 != idx[0]:
                print(idx[0], i + 1)
        for i in range(n - 1):
            print(n - i, n - i - 1)
Buggy python submission (verdict: Runtime Error):
s = input()
cnt = 0
idx = 0
target = "KIHBR"
for i in range(len(s)):
    if s[i] == "A":
        cnt += 1
        if idx == 1 and cnt == 1:
            print("NO")
            exit()
        if cnt >= 2:
            print("NO")
            exit()
    else:
        if idx <= 5 and target[idx] == s[i]:
            idx += 1
            cnt = 0
        else:
            print("NO")
            exit()
if idx == 5:
    print("YES")


Fixed submission:
s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
s = input()
cnt = 0
idx = 0
target = "KIHBR"
for i in range(len(s)):
    if s[i] == "A":
        cnt += 1
        if cnt >= 2:
            print("NO")
            exit()
    else:
        if target[idx] == s[i]:
            idx += 1
            cnt = 0
        else:
            print("NO")
            exit()
if idx == 5:
    print("YES")


Fixed submission:
s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
s = input()
cnt = 0
idx = 0
target = "KIHBR"
for i in range(len(s)):
    if s[i] == "A":
        cnt += 1
        if cnt >= 2:
            print("NO")
            exit()
    else:
        if target[idx] == s[i]:
            idx += 1
        else:
            print("NO")
            exit()
if idx == 5:
    print("YES")


Fixed submission:
s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
def print_ans(l,r,N):
  """print(sum(r)-sum(l)+N)
  Parameters
  --------------
  >>> print_ans([24],[30],1)
  7
  >>> print_ans([6,3],[8,3],2) 
  4
  """
  print(sum(r)-sum(l)+N)


  

def main():
  N = input()
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.add(s[0])
    r.add(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()



Fixed submission:
def print_ans(l,r,N):
  """print(sum(r)-sum(l)+N)
  Parameters
  --------------
  >>> print_ans([24],[30],1)
  7
  >>> print_ans([6,3],[8,3],2) 
  4
  """
  print(sum(r)-sum(l)+N)


  

def main():
  N = int(input())
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.append(s[0])
    r.append(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def print_ans(l,r,N):
  """print(sum(r)-sum(l)+N)
  Parameters
  --------------
  >>> print_ans([24],[30],1)
  7
  >>> print_ans([6,3],[8,3],2) 
  4
  """
  print(sum(r)-sum(l)+N)


  

def main():
  N = input()
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.add(s[0])
    r.add(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()



Fixed submission:
def print_ans(l,r,N):
  """print(sum(r)-sum(l)+N)
  Parameters
  --------------
  >>> print_ans([24],[30],1)
  7
  >>> print_ans([6,3],[8,3],2) 
  4
  """
  print(sum(r)-sum(l)+N)


  

def main():
  N = int(input())
  l = []
  r = []
  for i in range(N):
    s = list(map(int,input().split()))
    l.append(s[0])
    r.append(s[1])

  print_ans(l,r,N)


if __name__ == '__main__':
  main()