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

Fixed submission:
n = input()
if '7' in n:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = [list(map(int, input().split())) for _ in range(2)]

print(n)

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

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
          elif c == "G":
              ans += (ruisekiG[n] - ruisekiG[j])
            else:
                ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)

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

ruisekiR = [0] * (n+1)
ruisekiG = [0] * (n+1)
ruisekiB = [0] * (n+1)

for i,c in enumerate(s):
    ruisekiR[i+1] = ruisekiR[i] + ( 1 if c == "R" else 0)
    ruisekiG[i+1] = ruisekiG[i] + ( 1 if c == "G" else 0)
    ruisekiB[i+1] = ruisekiB[i] + ( 1 if c == "B" else 0)

ans = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        c = "R"
        if "R" in (s[i], s[j]):
            c = "G"
            if "G" in (s[i], s[j]):
                c = "B"

        if c == "R":
            ans += (ruisekiR[n] - ruisekiR[j])
        if c == "G":
            ans += (ruisekiG[n] - ruisekiG[j])
        if c == "B":
            ans += (ruisekiB[n] - ruisekiB[j])

        if j+(j-i)<n and s[j+(j-i)] == c:
            ans -= 1

print(ans)
Problem p02676 (python)

Fixed submission:
k=int(input())
s=input()
print(s[:k] + (len(s)>k)*'...')

Buggy submission (verdict: Runtime Error):
k=int(input())
s=input()
 print(s[:k] + (len(s)>k)*'...')
Problem p02762 (python)

Fixed submission:
import sys
from collections import defaultdict

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


class UnionFind:
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rk = [0] * size

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rk[x] < self.rk[y]:
            self.par[x] = y
        elif self.rk[x] > self.rk[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            self.rk[y] += 1


N, M, K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.unite(a, b)
    friend[a].add(b)
    friend[b].add(a)

block = defaultdict(set)
for _ in range(K):
    c, d = map(lambda x: int(x) - 1, input().split())
    block[c].add(d)
    block[d].add(c)

group = defaultdict(set)
for i in range(N):
    group[uf.find(i)].add(i)

ans = [0] * N
for people in group.values():
    for p in people:
        ans[p] = len(people) - 1 - sum(1 if i in people else 0 for i in friend[p]) - sum(1 if i in people else 0 for i in block[p])

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

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

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


class UnionFind:
    def __init__(self, size):
        self.par = [i for i in range(size)]
        self.rk = [0] * size

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rk[x] < self.rk[y]:
            self.par[x] = y
        elif self.rk[x] > self.rk[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            self.rk[y] += 1


N, M, K = map(int, input().split())
uf = UnionFind(N)
friend = defaultdict(set)
for _ in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.unite(a, b)
    friend[a].add(b)
    friend[b].add(a)

block = defaultdict(set)
for _ in range(K):
    c, d = map(lambda x: int(x) - 1, input().split())
    block[c].add(d)
    block[d].add(c)

group = defaultdict(set)
for i in range(N):
    group[uf.find(i)].add(i)

ans = [0] * N
for people in group.values():
    for p in people:
        ans[p] = len(people) - 1 - sum(1 if i in people else 0 for i in friend[p]) - sum(1 if i in people else 0 for i in block[p])

print(' '.join(ans))
Problem p02682 (python)

Fixed submission:
A,B,C,K=map(int,input().strip().split())
if K-A>0:
  K=K-A
  Sum=A
  K=K-B
  if K>0:
    if K>C:
      print(Sum-C)
    else:
      print(Sum-K)
    #if K>C:
  else:
    print(Sum)
else:
	print(K)

Buggy submission (verdict: Runtime Error):
A,B,C,K=map(int,input().strip().split())
K=K-A
if K>0:
  Sum=A
  K=K-B
  if K>0:
    if K>C:
      print(Sum-C)
   	else:
      print(Sum-K)
  else:
     print(Sum)
else:
      print(K)
Problem p02659 (python)

Fixed submission:
sa, sb = input().split()
a = int(sa)
b = int(sb.replace('.', ''))
print(a * b // 100)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input.split())
print(int(a * b))
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
A,B = map(Decimal, input().split(" "))

print(int(A*B))

Buggy submission (verdict: Runtime Error):
impor math
A,B = map(float,input().split(" "))
A = int(A)
B = int(B * 100)
print(math.floor((A*B)/100))
Problem p02659 (python)

Fixed submission:
a, b = input().split()
b = b.replace('.', '')
a, b = map(int, [a, b])
print(a * b // 100)

Buggy submission (verdict: Runtime Error):
a, b = map(int, intpu().split())
b.replace('.', '')
print(a * b // 100)
Problem p02699 (python)

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

if (W >= S):
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int,input().split())
hpa = math.ceil(A / D)
hhb = math.ceil(C / B)
if (hpa >= hpb):
    print('Yes')
else:
    print('No')
Problem p02707 (python)

Fixed submission:
import numpy as np
N = int(input())

A = list(map(int, input().split()))
         
c = [0 for i in range(N)]

for i in range(N-1):
    c[A[i] - 1] += 1

for i in range(N):
    print(c[i])

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())

A = list(map(int, input().split()))
         
n = N - np.sum(A)
if(n >= 0):
    print(n)
else:
    print(-1)
Problem p02729 (python)

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

a = N * (N-1) // 2
b = M * (M-1) // 2
print(a+b)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N, M = map(int, input().split())

a = comb(N, 2, exact=True)
b = comb(M, 2, exact=True)

print(a+b)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map (int, input().split())
U = input()

if( S==U):
    print(A-1,B)
else:
    print(A,B-1)

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map (int, input().split())
U = input()

if( S==U):
    print(A-1,B)
else:
    print(A,B-1)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
from fractions import gcd
a, b = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02771 (python)

Fixed submission:
v = set(map(int, input().strip().split()))
print("Yes" if len(v) == 2 else "No")

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

int main(){
  IO; ll t; sll V;
  REP(i,3){cin >> t; V.INS(t);}
  cout << (V.size() == 2 ? "Yes":"No");
}
Problem p02771 (python)

Fixed submission:
a,b,c = (int(x) for x in input().split())

res = "No"
if a==b:
    if a!=c:
        res = "Yes"
    else:
        res = "No"
if c==b:
    if a!=c:
        res = "Yes"
    else:
        res = "No"
if a==c:
    if a!=b:
        res = "Yes"
    else:
        res = "No"
        
print(res)

Buggy submission (verdict: Runtime Error):
a,b,c = (int(x) for x in input().split())


if a==b:
    if a!=c:
        res = "Yes"
    else:
        res = "No"
if c==b:
    if a!=c:
        res = "Yes"
    else:
        res = "No"
if a==c:
    if a!=b:
        res = "Yes"
    else:
        res = "No"
        
print(res)
Problem p02793 (python)

Fixed submission:
#import math
#from functools import reduce
from fractions import gcd
#from functools import lru_cache


#def lcm_base(x, y):
#    return (x * y) // gcd(x, y)

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


def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


n = int(input())
A = [int(x) for x in input().split()]

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm//i
    
print(count%(10**9+7))

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

#def lcm_base(x, y):
#    return (x * y) // gcd(x, y)

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

#@lru_cache(maxsize=1000)
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // np.gcd(x, a[i])
    return x


n = int(input())
A = [int(x) for x in input().split()]

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm//i
    
print(count%(10**9+7))

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

#def lcm_base(x, y):
#    return (x * y) // gcd(x, y)

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

#@lru_cache(maxsize=1000)
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // np.gcd(x, a[i])
    return x


n = int(input())
A = [int(x) for x in input().split()]

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm//i
    
print(count%(10**9+7))

Buggy submission (verdict: Runtime Error):
#import math
#from functools import reduce
from fractions import gcd
#from functools import lru_cache

#def lcm_base(x, y):
#    return (x * y) // gcd(x, y)

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

#@lru_cache(maxsize=1000)
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x


n = int(input())
A = [int(x) for x in input().split()]

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm/i
    
print(int(count%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

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




n = int(input())
A = [int(x) for x in input().split()]

t_lcm = lcm(A)
count = 0
for i in A:
    count += t_lcm//i
    
print(count%(10**9+7))
Problem p03725 (python)

Fixed submission:
import math
H,W,K = map(int,input().split())
HW = [list(input()) for i in range(H)]
for i,h in enumerate(HW):
	if "S" in h:
		y = i
		x = h.index("S")
A = [(x,y)]
m = 800
def idou(a,b):
	X = []
	for i2 in range(4):
		if i2 == 0:
			t,k = a - 1, b
		elif i2 == 1:
			t,k = a, b - 1
		elif i2 == 2:
			t,k = a + 1, b
		elif i2 == 3:
			t,k = a, b + 1
		if 0 <= t < W and 0 <= k < H and HW[k][t] == ".":
			HW[k][t] = "o"
			X.append((t,k))
	return X
cnt = 0
while cnt < K:
	cnt += 1
	B = []
	for p in A:
		x,y = p
		b = idou(x,y)
		B.extend(b)
	A = B[:]
M = []
for i,w in enumerate(zip(*HW)):
	#print(w)
	if "o" in w or "S" in w:
		M.append(min(i,W - i - 1))
		
for i,h in enumerate(HW):
	if "S" in h or "o" in h:
		M.append(min(i, H - i - 1))
		#print(h)
m = min(M)
print((m + K - 1) // K + 1)

Buggy submission (verdict: Runtime Error):
H,W,K = map(int,input().split())
HW = [list(input()) for i in range(H)]
for i,h in enumerate(HW):
	if "S" in h:
		y = i
		x = h.index("S")
A = [(x,y)]
m = 800
def idou(a,b):
	X = []
	for i2 in range(4):
		if i2 == 0:
			t,k = a - 1, b
		elif i2 == 1:
			t,k = a, b - 1
		elif i2 == 2:
			t,k = a + 1, b
		elif i2 == 3:
			t,k = a, b + 1
		if 0 <= t < W and 0 <= k <=H and HW[k][t] == ".":
			HW[k][t] = "o"
			X.append((t,k))
	return X
for p in A:
	x,y = p
	b = idou(x,y)
	A.extend(b)
M = []
for i,w in enumerate(zip(HW)):
	if "o" in w or "S" in w:
		M.append(min(i,W - i - 1))
for i,h in enumerate(HW):
	if "S" in h or "o" in h:
		M.append(min(i, H - i - 1))
m = min(M)
print((m + K - 1) // K + 1)
Problem p03767 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
A = A[N:]
B = A[::2]
print(sum(B))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
	a,b = map(int,input().split())
	nodes[a-1][b-1] = True
	nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
	mat2 = mat2.dot(mat1)
	a = mat2.tolist()
	A.append(a)

white = [i for i in range(N)]
Colour = [0] * N
paint = []
Q = int(input())
for q in range(Q):
	line = list(map(int,input().split()))
	paint.append(line)
white2 = white[:]
paint.reverse()
for p in paint:
	v,d,c = p[0],p[1],p[2]
	if d == 0 and v - 1 in w:
		Colour[v - 1] = c
		white2.remove(v - 1)
		continue
	elif d == 0:
		continue
	else:
		for w in white:
			if d == 1:
				if not A[0][v - 1][w]:
					continue
				else:
					Colour[w] = c
					white2.remove(w)
			else:
				if A[d - 1][v - 1][w] or A[d - 2][v - 1][w]:
					Colour[w] = c
					white2.remove(w)
		if len(white2) == 0:
			break
	if v - 1 in white:
		Colour[v - 1] = c
		if v - 1 in white2:
			white2.remove(v - 1)
	white = white2[:]

for C in Colour:
	print(C)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
nodes = [[False]* N for j in range(N)]
for m in range(M):
	a,b = map(int,input().split())
	nodes[a-1][b-1] = True
	nodes[b-1][a-1] = True
mat1 = np.matrix(nodes,dtype=bool)
mat2 = mat1.copy()
A = [mat1.tolist()]
for i in range(10):
	mat2 = mat2.dot(mat1)
	a = mat2.tolist()
	A.append(a)
'''
for ai,a in enumerate(A):
	for k in a:
		print(k)
	print(ai)
'''
Colour = [0] * N
Q = int(input())
for q in range(Q):
	v,d,c = map(int,input().split())
	Colour[v - 1] = c
	if d == 0:
		continue
	for n in range(N):
		if d == 1 :
			if (not A[0][v - 1][n]):
				continue
			else:
				Colour[n] = c
		else:
			if A[d - 1][v - 1][n] or A[d - 2][v - 1][n] > 0:
				Colour[n] = c
	
for C in Colour:
	print(C)
Problem p02659 (python)

Fixed submission:
from decimal import *

a, b = input().split()
ans = Decimal(a) * Decimal(b)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from decimal import *

a, b = map(int, input().split())
ans = Decimal(a) * Decimal(b)
print(int(ans))
Problem p02754 (python)

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

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()



c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    exit()

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
v = n

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()



c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
v = n

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()


if n > a + b and n < a + a + b:
    print(a+(n - (a + b)))
    exit()

c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
v = n

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()


if n > a + b and n < a + a + b:
    print(a+(n - (a + b)))
    exit()

c = n % (a +b)
if n % (a +b) > a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())

print(a * b // gcd(a, b))

Buggy submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())

print(a * b // gcd(a, b))
Problem p03011 (python)

Fixed submission:
a = [i for i in input().split()]
print(int(sorted(a)[0]) + int(sorted(a)[1]))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
 
print((a+b+c)-max(a,b,c))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
 
print( (a + b + c) - max(a, b, c))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())

print( (a + b + c) - max(a, b, c))
Problem p03127 (python)

Fixed submission:
import functools
import fractions

n = int(input())
a = [int(i) for i in input().split()]

gcd = functools.reduce(fractions.gcd, a)
print(gcd)

Buggy submission (verdict: Runtime Error):
import functools
import fructions

n = int(input())
a = [int(i) for i in input().split()]

gcd = functools.reduce(fructions.gcd, a)
print(gcd)
Problem p02659 (python)

Fixed submission:
from sys import stdin

def main():
  read = stdin.readline
  A,B = list(read().split(" "))
  B = 100*int(B[0]) + 10*int(B[2]) + 1 * int(B[3])
  c = int(A) * B
  print(c//100)
  
  
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
from sys import stdin

def main():
  read = stdin.readline
  A,B = list(read().split(" "))
  B = B*100
  c = int(A) * B
  print(c//100)
  
  
  
if __name__ == "__main__":
  main()
Problem p02873 (python)

Fixed submission:
from itertools import groupby
ans = premax = 0
for k, g in groupby(input()):
    for c, _ in enumerate(g, 1):
      ans += c
    if k == '>':
        ans -= min(c, premax)
    premax = c
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 0
cnt = 0
tmp = 0
i = 0
while i < N - 1:
  cnt = 0
  tmp = 0
  if S[i] == "<":
    while S[i] == "<":
      if i == N - 1:
        ans += 1
        break
      cnt += 1
      if S[i+1] == ">":
        ans += cnt * (cnt + 1) // 2
        tmp = cnt
        cnt = 0
        i += 1
        while S[i] == ">":
          cnt += 1
          i += 1
          if i == N:
            i -= 1
            break
        ans += (cnt - 1) * (cnt) // 2
        if tmp >= cnt:
          pass
        else:
          ans += cnt - tmp
        cnt = 0
      else:
        i += 1
  else:
    while S[i] == ">":
      cnt += 1
      i += 1
    ans += cnt * (cnt + 1) // 2
print(ans)
Problem p02948 (python)

Fixed submission:
from collections import defaultdict
from heapq import heappush, heappop

N,M = map(int,input().split())
d = defaultdict(list)

for _ in range(N):
  a,b = map(int,input().split())
  d[a].append(b)
  
h = []
res = 0

for a in range(1,M + 1):
  for b in d[a]:
    heappush(h,-b)
  if len(h) > 0:
    c = heappop(h)
    res -=c
    
print(res)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from heapq import heappush, heappop

N,M = map(int,input().split())
d = defaultdict(list)

for _ in range(N):
  a,b = map(int,input().split())
  d[a].append(b)
  
h = []
res = 0

for a in range(1,M + 1):
  for b in d[a]:
    heappush(h,-b)
  if h > 0:
    c = heappop(h)
    res -=c
    
print(res)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb
N, K = map(int,input().split())
MOD = 10**9 + 7
for i in range(1,K+1):
  print(comb(N-K+1,i,exact=True) * comb(K-1,i-1,exact=True) % MOD)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int,input().split())
MOD = 10**9+7
for i in range(1,K+1):
  print(cmb(N-K+1,i) * cmb(K-1,i-1) % MOD)
Problem p03104 (python)

Fixed submission:
A, B = map(int,input().split())
F1 = A
F2 = B + 1
if (F1 // 2) % 2 == 0:
  tmp1 = 0
else:
  tmp1 = 1
if F1 % 2 != 0:
  tmp1 ^= A - 1

if (F2 // 2) % 2 == 0:
  tmp2 = 0
else:
  tmp2 = 1
if F2 % 2 != 0:
  tmp2 ^= B
print(tmp1 ^ tmp2)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())
S = 10**6
if B - A >= S:
  L = list(range(A,(A+B)//2+1))
  R = list(range((A+B)//2+1,B+1))
  print(L)
  print(R)
  ans = L[0]
  for l in L[1:]:
    ans ^= l
  for r in R:
    ans ^= r
else:
  ans = A
  for i in range(A+1,B+1):
    ans ^= i
print(ans)
Problem p03209 (python)

Fixed submission:
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:return f(n-1,x-1)
    else:return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
B=["P"]
for i in range(1,n+1):
  b="B"+B[i-1]+"P"+B[i-1]+"B"
  B.append(b)
print(B[n][:x].count("P"))
Problem p03252 (python)

Fixed submission:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if cnt > 30:
    break
  if S[i] != T[i]:
    X = S[i]
    S = S.replace(S[i],"X")
    if T[i] in S:
      S = S.replace(T[i],X)
    S = S.replace("X",T[i])
    cnt += 1
print("Yes" if S == T else "No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if cnt > 30:
    break
  if S[i] != T[i]:
    X = S[i]
    S = S.replace(S[i],"X")
    S = S.replace(T[i],X)
    S = S.replace("X",T[i])
    cnt += 1
  print(S)
print("Yes" if S == T else "No")
Problem p03315 (python)

Fixed submission:
s = input()
print(0+s.count("+")-s.count("-"))

Buggy submission (verdict: Runtime Error):
s = input()
print(0+count.s("+")-count.s("-"))
Problem p03631 (python)

Fixed submission:
N = input()
print("Yes" if N[0]==N[2] or N[0]==N[1]==N[2] else "No")

Buggy submission (verdict: Runtime Error):
n = input()
print("Yes" if n==n[::-] else "No")