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

Fixed submission:
k,x = map(int,input().split())
ks = k * 500
if ks < x:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
K,X = [int(x) for x in stdin.readline().rstrip().split()]
Ks = K * 500
if Ks < X:
  print('No')
else:
  print('Yes')
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = input()
Problem p04031 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
s = round(sum(a)/n)
ans = 0
for i in a:
  ans += (i-s)**2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input()))
s = round(sum(a)/n)
ans = 0
for i in a:
  ans += (i-s)**2
print(ans)
Problem p04043 (python)

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

if a.count(5) == 2 and a.count(7) == 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a = input().split()
p
Problem p02830 (python)

Fixed submission:
N = int(input())
S, T = input().split()
X = []
 
for i in range(N):
  X.append(S[i])
  X.append(T[i])
  
print(''.join(X))

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T = input().split()
Answer = []

for i in N:
  Answer.append(S[i])
  Answer.append(T[i])
  
print(''.join(Answer))
Problem p02848 (python)

Fixed submission:
N = int(input())
S = input()
L=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
A = []
 
for c in S:
  i = L.index(c)
  A.append(L[(i + N)%26])
  
print(''.join(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
L=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
A = []
 
for c in S:
  i = L.find(c)
  A.append(L[(i + n)%26])
  
print(''.join(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
Alphabet=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
A = []

for c in S:
  i = Alphabet.find(c)
  A.append(Alphabet[(i + n)%26])
  
print(''.join(A))
Problem p02910 (python)

Fixed submission:
S = input()
N = len(S)
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']
ans = 0

for i in range(0, N, 2):
  if not (S[i] in odd):
    ans += 1
for i in range(1, N, 2):
  if not(S[i] in even):
    ans += 1
 
if ans == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i in (0, N, 2):
  if S[i] not in odd:
    ans += 1
for i in (1, N ,2):
  if S[i] not in even:
    ans += 1

if ans == 0:
  print('Yes')
else:
  print('No')
Problem p03160 (python)

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

def chmin(a, b):
  if a > b:
    return b
  else:
    return a

f_inf = float('inf')
dp = [f_inf] * (10**5 + 10)
dp[0] = 0

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

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
Step = list(map(int,input().split()))

for i in N
cost = min(abs(Step[n-1-i] - Step[n-2-i]),abs(Step[n-1-i] - Step[n-3-i]))
print(cost)
Problem p03814 (python)

Fixed submission:
S = list(input())
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
S.reverse()
for j in range(len(S)):
    if S[j] == 'Z':
        num_last = len(S) - j
        break
print(num_last - num_first)

Buggy submission (verdict: Runtime Error):
S = list(input())
num_first = 0
num_last = 0
for i in range(len(S)):
    if S[i] == 'A':
        num_first = i
        break
for j in range(num_first, len(S)+1):
    if S[j] == 'Z':
        num_last = j
print(num_last - num_first + 1)
Problem p03844 (python)

Fixed submission:
A, op, B = input().split()
if op == '+':
    print(int(A) + int(B))
else:
    print(int(A) - int(B))

Buggy submission (verdict: Runtime Error):
A, op, B = map(int, input().split())
if op == '+':
    print(A + B)
else:
    print(A - B)
Problem p03943 (python)

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

if candy[0] + candy[1] == candy[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
candy = [input() for i in range(3)]
candy.sort()

if candy[0] + candy[1] == candy[2]:
    print('Yes')
else:
    print('No')
Problem p04030 (python)

Fixed submission:
def typing(s, ans):
    for i in range(len(s)):
        if s[i] == '0':
            ans += '0'
        if s[i] == '1':
            ans += '1'
        if s[i] == 'B' and ans != '':
            ans = ans[:len(ans)-1]

    print(ans)

S = str(input())
ANS = ''
typing(S, ANS)

Buggy submission (verdict: Runtime Error):
def typing(s, ans):
    for i in range(len(s)):
        if len(ans) != 0:
            continue
        elif s[i] == '0':
            ans.append('0')
        elif s[i] == '1':
            ans.append('1')
        elif s[i] == 'B':
            ans.pop()

    print(''.join(ans))

S = str(input())
ANS = []
typing(S, ANS)

Buggy submission (verdict: Runtime Error):
def typing(s, ans):
    for i in range(len(s)):
        if s[i] == '0':
            ans.append('0')
        elif s[i] == '1':
            ans.append('1')
        elif s[i] == 'B' and ans != '':
            ans.pop()
        else:
            continue
            
    print(ans)

S = str(input())
ANS = []
typing(S, ANS)
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
S.sort()
String = ''.join(S)
print(String)

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(N)]
print((''.join(S.sorted())))
Problem p02789 (python)

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

if m == n:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,m = int(input().split())

if m == n:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())

if M == N:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,m = input()

if m == n:
  print('Yes')
else:
  print('No')

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

if m == n:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = input()
m = input()
if m == n:
  print('Yes')
else:
  print('No')
Problem p02789 (python)

Fixed submission:
n,m=[int(x) for x in input().split()]
if(n==m):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
if(n==m):
  print("Yes")
 else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,m=[int(x) for x in input().split()]
if(n==m):
  print("Yes")
 else:
  orint("No")
Problem p03502 (python)

Fixed submission:
import math

def sum_digits(n):
    r = 0
    while n / 10 > 0:
        r += n % 10
        n = math.floor(n/10)
    return r


if __name__ == '__main__':
    n = int(input())

    s = sum_digits(n)
    if n % s == 0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
def sum_digits(n):
    r = 0
    while n / 10 > 0:
        r += n % 10
        n = math.floor(n/10)
    return r

if __name__ == '__main__':
    n = int(input())

    s = sum_digits(n)
    if n % s == 0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
def sum_digits(n):
    r = 0
    while n / 10 > 0:
        r += n % 10
        n = math.floor(n/10)
    return r

if __name__ == '__main__':
    n = int(input())

    s = sum_digits(n)
    print(s)
    if n % s == 0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
def sum_digits(n):
    r = 0
    while n / 10 >= 1:
        r += n % 10
        n /= 10
    return r




if __name__ == '__main__':
    n = int(input())

    s = sum_digits(n)
    if n % s == 0:
        print('Yes')
    else:
        print('No')
Problem p02812 (python)

Fixed submission:
num = int(input())
s=list(input())
ss = 0

for i in range(num):
  if "A" == s[i]:
    if i > num - 3:
      break
    if "B" == s[i + 1]:
      if "C" == s[i + 2]:
        ss += 1
print(ss)

Buggy submission (verdict: Runtime Error):
num = int(input())
s=list(input())
ss = 0

for i in range(num):
  if "A" == s[i]:
    if "B" == s[i + 1]:
      if "C" == s[i + 2]:
        ss += 1
print(ss)

Buggy submission (verdict: Runtime Error):
num = int(input())
a= input()
words = a.split()
ss = 0

for i in range(num):
  if "A" = words[i]:
    for q in range(i,num):
      if "B" = words[q]:
        for g in range(q,num):
          if "C" = words[g]:
            ss += 1
Problem p02791 (python)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
count=1
min=P[0]
for i in range(1,N):
    if min>P[i]:
      count+=1
      min=P[i]
print(count)

Buggy submission (verdict: Runtime Error):
import numpy as num
N=int(input())
P=list(map(int,input().split()))
count=0
flag=True
for i in range(N):
    for k in range(1):
        l=np.amin(np.array(P[:i+1]))
        if P[i]>l:
            flag=False
            break
    if flag:
        count+=1
    else:
        flag=True
print(count)
Problem p02841 (python)

Fixed submission:
M1,D1=map(int,input().split())
M2,D2=map(int,input().split())
if D1+1==D2:
    print("0")
else:
    print("1")

Buggy submission (verdict: Runtime Error):
X=int(input())
a=100
b=105
for n in range (0,21):
    if n*b<X<(n+1)*a:
        print("0")
        break
    else:
        n+=1
else:
    print("1")
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0 for i in range(1, N+2)]
i=1
while i<=N:
    D[0]=0
    D[i]=D[i-1]+L[i-1]
    if D[i]>X:
        print(i)
        break
    i+=1
else:
    print(i)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0 for i in range(1, N+3)]
i=1
while i<=N+1:
    D[0]=0
    D[i]=D[i-1]+L[i-1]
    if D[i]>X:
        print(i)
        break
    i+=1

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[0 for i in range(1, N+2)]
i=1
while i<=N+1:
    D[0]=0
    D[i]=D[i-1]+L[i-1]
    if D[i]>X:
        print(i)
        break
    i+=1
Problem p03574 (python)

Fixed submission:
H,W = map(int,input().split())
src = [input() for i in range(H)]

ans = []
for row in src:
    ans.append(list(row))

dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if ans[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if ans[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c

for row in ans:
    print("".join(list(map(str,row))))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
src = [input() for i in range(H)]
ans = []
for row in src:
    ans.append(list(row))
dxy=[(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]
for i in range(H):
    for j in range(W):
        c=0
        if src[i][j]=="#": continue
        for dx,dy in dxy:
            if j+dx<0 or j+dx>W-1 or i+dy<0 or i+dy>H-1: continue
            if src[j+dx][i+dy]=="#":
                c+=1
        ans[i][j]=c
for row in ans:
    print("".join(list(map(str,row))))
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A-B*2))

Buggy submission (verdict: Runtime Error):
A, B = input().split()
print(max(0, A-B*2))
Problem p02887 (python)

Fixed submission:
from itertools import groupby

N = int(input())
S = input()

print(sum(1 for k, _ in groupby(S)))

Buggy submission (verdict: Runtime Error):
from itertools import groupby

N = int(input())
S = input()

print(len(groupby(S)))
Problem p02888 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
dp = [0]*(1005)
frm = 0
cnt = 0
Lcopy = [1001] + L[::-1]
while Lcopy:
  to = Lcopy.pop()
  for i in range(frm, to):
    dp[i] = cnt
  frm = to
  cnt += 1
  
ans = 0
b = 1
c = 2
while b < N-1:
  sub = L[c] - L[b]

  x = b - dp[sub]
  if x > 0:
    ans += x
  else:
    b += 1
    c = b
    
  c += 1
  if c >= N:
    b += 1
    c = b + 1

print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
 
L.sort()
 
ans = 0

for b in range(n):
  for a in range(b):
    ab = L[a] + L[b]
    r = bisect_left(L, ab)
    l = b + 1
    
    ans += r-l

print(ans)
Problem p02898 (python)

Fixed submission:
_,k = map(int, input().split())
print(sum(1 for h in map(int, input().split()) if h >= k))

Buggy submission (verdict: Runtime Error):
_,k = map(int, input().split())
print(sum(1 for h in map(int, input().split()) if h >= k)))

Buggy submission (verdict: Runtime Error):
_,k = map(int, input().split())
print(sum(1 for h in map(int, input().split() if h >= k)))
Problem p02921 (python)

Fixed submission:
def solve():
  import sys
  import math

  sys.setrecursionlimit(10**7)

  a = input()
  b = input()
  
  print(sum(a[i]==b[i] for i in range(3)))


if __name__ == '__main__':
  solve()

Buggy submission (verdict: Runtime Error):
def solve():
  import sys

  sys.setrecursionlimit(10**7)
  readline = sys.stdin.readline

  
  n = int(readline())
  a = [list(map(int,readline().split())) for _ in range(n)]
  c = [0]*n
  d = 0
  m = list(range(n))
  
  while m:
    candidate = set()
    for i in m:
      if i in candidate:
        continue
      j = a[i][c[i]]-1
      if a[j][c[j]]-1 == i:
        candidate.add(i)
        candidate.add(j)

    if candidate:
      for i in candidate:
        c[i]+=1
        if c[i] == n-1:
          m.remove(i)
      d+=1
    else:
      d=-1
      break
      
  print(d)


if __name__ == '__main__':
  solve()
Problem p02928 (python)

Fixed submission:
n,k = map(int, input().split())
*a, = map(int, input().split())
ans = 0
wer = 0

for i in range(n-1):
  for j in range(i+1, n):
    if a[i] > a[j]:
      ans += 1
ans *= k

for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      wer += 1
wer *= k*(k-1)//2

ans += wer
ans %= 10**9 + 7
  
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
*a, = map(int, input().split())
ans = 0
wer = 0

for i in range(n-1):
  for j in range(i, n):
  	if a[i] > a[j]:
      ans += 1
ans *= k

for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      wer += k-1
wer *= k*(k-1)//2

ans += wer
ans %= 10**9 + 7
  
print(ans)
Problem p02934 (python)

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

d=1
m=0
for i in a:
  d *= i
for i in a:
  m += d/i

ans = d/m

print(ans)

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

d=1
m=0
for i in range(n):
  d *= i
  m += i

ans = d/m
print(ans)
Problem p02936 (python)

Fixed submission:
N, Q = map(int, input().split())
graph = [[] for i in range(200010)]
ans = [0 for i in range(200010)]
import sys
#sys.setrecursionlimit(100000)
sys.setrecursionlimit(10**7)
#
readline = sys.stdin.readline


for _ in range(N - 1):
    #a, b = map(int, input().split())
    a, b = map(int, readline().split())
    a -= 1
    b -= 1

    graph[a].append(b)
    graph[b].append(a)

for _ in range(Q):
    #p, x = map(int, input().split())
    p, x = map(int, readline().split())
    p -= 1

    ans[p] += x

def dfs(node, frm=-1):
    for to in graph[node]:
        if to == frm:
            continue
        ans[to] += ans[node]
        dfs(to, node)
dfs(0)

print(*ans[:N])

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

#=====================================
class Tree():
  def __init__(self, n):
    self.children = []
    self.counter = 0

  def add_child(self, child):
    self.children += [child]
  
  def reconstruct(self, root=None):
    if root in self.children:
      self.children.remove(root)
    for child in self.children:
      child.reconstruct(self)
  
  def add_count(self, x):
    self.counter += x
    for child in self.children:
      child.add_count(x)

#=====================================
      
trees = [Tree(i) for i in range(n)]

ab = [map(int,input().split()) for i in range(n-1)]
for a,b in ab:
  trees[a-1].add_child(trees[b-1])
  trees[b-1].add_child(trees[a-1])

trees[0].reconstruct()

for i in range(q):
  p,x = map(int,input().split())
  trees[p-1].add_count(x)

print(*[trees[i].counter for i in range(n)])
Problem p02939 (python)

Fixed submission:
s = input()
ans = 0
t = p = ''

for i in range(len(s)):
  t += s[i]
  if t == p:
    continue
  p = t
  t = ''
  ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
 
input = sys.stdin.readline
input_list = lambda: map(int, input().split())
 
dup = lambda x,y: ((x)+(y)-1)//(y)
 
def solve():
  s = input()
  ans = 0
  prev = ''
  i = 0
  while i < len(s):
    len = 1
    if s[i:i+len] == prev: len += 1
    if i + len > len(s): break
    prev = s[i:i+len]
    i += len
    ans += 1
  print(ans)


solve()
Problem p02953 (python)

Fixed submission:
n = int(input())
h_list = list(map(int, input().split()))
h = 0
result = 'Yes'
for i in range(n):
  if h <= h_list[i]-1:
    h = h_list[i]-1
  elif h == h_list[i]:
    h = h_list[i]
  else:
    result = 'No'
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
h_list = map(int, input().split())
h = 0
result = 'Yes'
for i in range(n):
  if h <= h_list[i]:
    h = h_list[i]
  elif h == h_list[i]-1:
    h = h_list[i]-1
  else:
    result = 'No'
print(result)
Problem p02963 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

dup = lambda x,y: ((x)+(y)-1)//(y)

def solve():
  s = ni()
  v = 10**9
  
  y = dup(s, v)
  x = y*v-s
  
  print(0, 0, v, 1, x, y)


solve()

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces

dup = lambda: x, y: ((x)+(y)-1)//(y)

def solve():
  s = ni()
  v = 1e9
  
  y = dup(s, v)
  x = y*v-s
  
  print(0, 0, v, 1, x, y)


if __name__ == ‘__main__’:
  solve()
Problem p03030 (python)

Fixed submission:
n=int(input())
array = []
for i in range(n):
    s,p = input().split()
    array.append([s,100-int(p),i+1])
array.sort()
for i in range(n):
    print(array[i][2])

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<string.h>

int main(){
    int n,i,j,d[100],t,x[100];
    char s[100][100];
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%s %d",s[i],&d[i]);
        for(j=i;j>0;--j){
            t=strcmp(s[i],s[x[j-1]]);
            if(t<0 || (t==0&&d[i]>d[x[j-1]])){
                x[j] = x[j-1];
            }else{
                break;
            }
        }
        x[j]=i;
    }
    for(i=0;i<n;++i){
        printf("%d\n",x[i]+1);
    }
    return 0;
}

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include <string.h>
int main(void){
    int n,i,j,x[10] = {1,2,3,4,5,6,7,8,9,10};
    scanf("%d",&n);
    char s[100][11],tmp_s[11];
    int d[100],tmp_d;
    for(i=0;i<n;++i){
       scanf("%s %d",&s[i],&d[i]);
    }
    for(i=0;i<n;++i){
        for(j=i+1;j<n;++j){
            if(strcmp(s[i],s[j])>0){
                strcpy(tmp_s,s[i]);
                tmp_d = d[i];
                strcpy(s[i],s[j]);
                d[i] = d[j];
                strcpy(s[j],tmp_s);
                d[j] = tmp_d;
                tmp_d = x[i];
                x[j] =x[i];
                x[i] = tmp_d;
            }else if(strcmp(s[i],s[j])==0){
                if(d[i] > d[j]){
                    strcpy(tmp_s,s[i]);
                    tmp_d = d[i];
                    strcpy(s[i],s[j]);
                    d[i] = d[j];
                    strcpy(s[j],tmp_s);
                    d[j] = tmp_d;
                    tmp_d = x[i];
                    x[j] =x[i];
                    x[i] = tmp_d;
                }
            }
        }
    }
    for(i=0;i<n;++i){
        printf("%d\n",x[i]);
    }
    return 0;
}
Problem p02945 (python)

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

print(max(a+b, a-b, a*b))

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
L = []
for i in range(N):
    L.append(sorted(sys.stdin.readline().strip()))

Sum = 0
for i in range(N):
    if i == N - 1:
        break
    
    for j in range(i+1, N):
        if L[i] == L[j]:
            Sum += 1

print(Sum)
Problem p02947 (python)

Fixed submission:
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print count

Buggy submission (verdict: Runtime Error):
import math

def calc_comb(n):
    k = 2
    if n <= 1 :
        return 0
    elif n ==2 :
        return 1
    return math.factorial(n)/(math.factorial(n-k) * math.factorial(k))

n = int(raw_input(""))

smap = {}
tmp = ""
for i in range(0, n):
    tmp = ''.join(sorted(raw_input("")))
    if smap.get(tmp, None) == None:
        smap[tmp] = 1
    else:
        smap[tmp] += 1
count = 0
for s, num in smap.items():
    #print num
    count += calc_comb(num)
print(count)
Problem p04045 (python)

Fixed submission:
#find set of numbers iroha like
tmp = raw_input("").split(' ')
n = int(tmp[0])
k = int(tmp[1])
tmp = raw_input("")
exclude_set = map(int, tmp.split(' '))

def binarySearch(arr, target):
  l = 0
  r  = len(arr) - 1
  while l <= r:
    m = (l + r)//2
    if arr[m] == target:
      return True
    elif arr[m] > target:
      r = m - 1
    elif arr[m] < target:
      l = m + 1
  return False

def check(n_digits, exclude_set):
  for i in range(0, len(n_digits)):
    if binarySearch(exclude_set, n_digits[i]) == True:
      return False
  return True
for i in range(n, 10**5):
  tmp = i
  n_digits = []
  while tmp > 0:
    n_digits.append(tmp%10)
    tmp = int(tmp/10)
  #print n_digits
  if check(n_digits, exclude_set) == True:
    print i
    break

Buggy submission (verdict: Runtime Error):
import bisect
#find set of numbers iroha like
tmp = raw_input("").split(' ')
n = int(tmp[0])
k = int(tmp[1])
tmp = raw_input("")
exclude_set = map(int, tmp.split(' '))
include_set = []
for i in range(0, 10):
  if i not in exclude_set:
    include_set.append(i)
#print include_set
n_digits = []
while n > 0:
  n_digits.append(n%10)
  n = int(n/10)
out = []
j = 0
#print include_set
while j < len(n_digits):
  tmp = bisect.bisect_left(include_set, n_digits[j])
  #print tmp
  out.append(str(include_set[tmp]))
  j += 1
print int(''.join(out)[::-1])
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = input()
lr_list = [list(map(int, input().split())) for i in range(Q)]

ac_list  = [0]*N
cnt = 0
for i in range(N-1):
    if i < len(S) and S[i:i+2] == "AC":
        cnt += 1
    ac_list[i+1] = cnt
        
for lr in lr_list:
    print(ac_list[lr[1]-1] - ac_list[lr[0]-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
lr_list = [list(map(int, input().split())) for i in range(Q)]

target = "AC"
ac_list =[]

index = -1
while True:
    index = S.find(target,index+ 1)
    if index == -1 :
        break
    ac_list.append(index)
    
for lr in lr_list:
    st = 0
    last = 0
    for i,ac in enumerate(ac_list):
#         print(ac+1,lr[0])
        if ac + 1 >= lr[0]:
            st = i
            break
    for i,ac in enumerate(ac_list[::-1]):
#         print(ac+1,lr[1]-1)
        if ac + 1 <= lr[1] - 1:
            end = len(ac_list) - i
            break
    
#     print(ac_list)
#     print(st,end)
    print(len(ac_list[st:end]))