Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

for i in range(N):
  if a_list.count(max_value) > 1:
    print(max_value)
  else:
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)
  


Fixed submission:
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)

Buggy python submission (verdict: Runtime Error):
import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))
    
for i in range(N):
    tmp_list = copy.copy(a_list)
    if len(tmp_list) > 2:
        tmp_list = list(sorted(set(tmp_list), key=tmp_list.index))
        tmp_list.pop(i)
        print(max(tmp_list))
    else:
        tmp_list.pop(i)
        print(max(tmp_list))     

Fixed submission:
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

for i in range(N):
    tmp_list = copy.copy(a_list)
    tmp_list.pop(i)
    print(max(tmp_list))

Fixed submission:
N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = list(map(int, input().split()))

mod = 1000000
for i in range(L, R+1):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019
    if mod > tmp:
      mod = tmp
print(mod)
    

Fixed submission:
import sys
L, R = list(map(int, input().split()))

mod = 1000000
for i in range(L, R+1):
  for j in range(i+1, R+1):
    tmp = (i * j) % 2019
    if tmp == 0:
      print(tmp)
      sys.exit()
      
    if mod > tmp:
      mod = tmp
    
print(mod)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
 
cnt = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)

Fixed submission:
s_code = list(map(int, input()))

num_1 = s_code[0]
num_2 = s_code[1]
num_3 = s_code[2]
num_4 = s_code[3]

if num_1 == num_2:
  print('Bad')
elif num_2 == num_3:
  print('Bad')
elif num_3 == num_4:
  print('Bad')
else:
  print('Good')
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

cnt = 0    
print(sum([1 for x in range(a, b+1) if x % c != 0 and x % d != 0]))



Fixed submission:
A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

cnt = 0    
print(sum([1 for x in range(a, b+1) if x % c != 0 and x % d != 0]))



Fixed submission:
A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

cnt = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)

Fixed submission:
A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())

cnt = 0
for i in range(a, b+1):
  if i % c != 0 and i % d != 0:
    cnt += 1
    
print(cnt)

Fixed submission:
A, B, C, D = map(int, input().split())
 
def gcd(a, b):
    while a%b!=0:
        a, b = b, a%b
    return b
 
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
CD = C*D // gcd(C, D)
XY = B//CD - (A-1)//CD
 
print(B-A+1-(X+Y-XY))
Buggy python submission (verdict: Runtime Error):
import sys

list = list(map(int, input().split()))
length_list = map(int, input().split())

N = list[0]
X = list[1]

i = 1
total = 0

for len in length_list:
  total = total + len
  if total <= X:
    i = i + 1
    if i == N + 1:
      print(i)
  else:
    print(i)
    sys.exit()


Fixed submission:
import sys

list = list(map(int, input().split()))

W = list[0]
H = list[1]
x = list[2]
y = list[3]

if x == W/2 and y == H/2:
  print((W*H)/2, 1)
else:
  print((W*H)/2, 0)
Buggy python submission (verdict: Runtime Error):

apple = A
part = P
all_part = A*3 + P

pie = all_part / 2

print(pie)

Fixed submission:
a, p = map(int, input().split())
print((a*3+p) // 2)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5
  print(0)

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

if A >= 13:
  print(B)
elif A >= 6 and A <= 12:
  print(int(B/2))
elif A <= 5:
  print(0)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
for i in range(M-1):
  l, r = map(int, input().split())
print(R-l+1)

Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
ans = set(list(range(L, R+1)))
for i in range(M-1):
  L, R = map(int, input().split())
  ans = ans & set(list(range(L, R+1)))
  if len(ans) == 0:
    print(0)
print(len(ansN, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
for i in range(M-1):
  l, r = map(int, input().split())
print(R-l+1)
  


Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
L, R = map(int, input().split())
ans = set(list(range(L, R+1)))
for i in range(M-1):
  L, R = map(int, input().split())
  ans = ans & set(list(range(L, R+1)))
print(len(ans))

Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
LR = []
for i in range(M):
  L, R = map(int, input().split())
  LR.append(list(range(L, R+1)))
ans = set(LR[0])
for i in LR:
  ans = ans & set(i)
print(len(ans))

Fixed submission:
N,M = map(int,input().split())
L = []
R = []
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)
ans = list(range(max(L),min(R)+1))
print(len(ans))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
l = [input() for _ in range(5)]
m = 9
ans = 0
for i in range(len(l)):
    n = int(l[i][-1])
    if n == 0: n = 10
    if n < m:
        m = n
        ind = i
for t in range(len(l)):
    if t == ind:
        ans += int(l[t])
    else:
        n = int(l[t][-1])
        if n == 0: n = 10
        ans += (int(l[t]) + 10 - n)
print(ans)


Fixed submission:
#!/usr/bin/env python3
l = [input() for _ in range(5)]
m = 11
ans = 0
for i in range(len(l)):
    n = int(l[i][-1])
    if n == 0: n = 10
    if n < m:
        m = n
        ind = i
for t in range(len(l)):
    if t == ind:
        ans += int(l[t])
    else:
        n = int(l[t][-1])
        if n == 0: n = 10
        ans += (int(l[t]) + 10 - n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = list(map(int,input().split()));

data = [0]*q;
for i in range(q):
    data[i] = list(map(int,input().split()));

A = [1]*n;
ans = 0;
As = [A];

for i in As :
    A_now = As.pop(-1);
    for j in range(n) :
        if A_now[j] < m :
            A_next = [A_now[j]+1]*n;
            for k in range(j) :
                A_next[k] = A_now[k];
            As.append(A_next);
    ans_now = 0;
    for j in range(q) :
        if A_now[data[j][1]-1] - A_now[data[j][0]-1] == data[j][2] :
            ans_now += data[j][3];
    if ans_now>ans :
        ans = ans_now;


print(ans);

Fixed submission:
n,m,q = list(map(int,input().split()));
 
data = [0]*q;
for i in range(q):
    data[i] = list(map(int,input().split()));
 
A = [1]*n;
ans = 0;
As = [A];
 
for i in As :
    A_now = As.pop(-1);
    for j in range(n) :
        if A_now[j] < m :
            A_next = [A_now[j]+1]*n;
            for k in range(j) :
                A_next[k] = A_now[k];
            As.append(A_next);
    ans_now = 0;
    for j in range(q) :
        if A_now[data[j][1]-1] - A_now[data[j][0]-1] == data[j][2] :
            ans_now += data[j][3];
    if ans_now>ans :
        ans = ans_now;
 
 
print(ans);

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = list(map(int,input().split()));

data = [0]*q;
for i in range(q):
    data[i] = list(map(int,input().split()));

A = [1]*n;
ans = 0;
As = [A];

for i in As :
    A_now = As.pop(0);
    for j in range(n) :
        if A_now[j] < m :
            A_next = [A_now[j]+1]*n;
            for k in range(j) :
                A_next[k] = A_now[k];
            As.append(A_next);
    ans_now = 0;
    for j in range(q) :
        if A_now[data[j][1]-1] - A_now[data[j][0]-1] == data[j][2] :
            ans_now += data[j][3];
    if ans_now>ans :
        ans = ans_now;


print(ans);

Fixed submission:
n,m,q = list(map(int,input().split()));
 
data = [0]*q;
for i in range(q):
    data[i] = list(map(int,input().split()));
 
A = [1]*n;
ans = 0;
As = [A];
 
for i in As :
    A_now = As.pop(-1);
    for j in range(n) :
        if A_now[j] < m :
            A_next = [A_now[j]+1]*n;
            for k in range(j) :
                A_next[k] = A_now[k];
            As.append(A_next);
    ans_now = 0;
    for j in range(q) :
        if A_now[data[j][1]-1] - A_now[data[j][0]-1] == data[j][2] :
            ans_now += data[j][3];
    if ans_now>ans :
        ans = ans_now;
 
 
print(ans);
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input());
s = input();

r = [];
g = [];
b = [];
for i in range(n) :
    if s[i] == 'R' :
        r.append(i+1);
    if s[i] == 'G' :
        g.append(i+1);
    if s[i] == 'B' :
        b.append(i+1);

ans = 0;
for i in r :
    for j in g :
        for k in b :
            l = [i,j,k];
            l.sort();
            if not(l[1]-l[0]-1 == l[2]-l[1]-1) :
                ans += 1;

print(ans);

Fixed submission:
n = int(input());
s = input();

r = [];
g = [];
b = [];
for i in range(n) :
    if s[i] == 'R' :
        r.append(i+1);
    if s[i] == 'G' :
        g.append(i+1);
    if s[i] == 'B' :
        b.append(i+1);

hiku = 0;
for j in range(2,n) :
    if j-1 < n-j :
        for i in range(1,j) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;
    else :
        for i in range(1,n-j+1) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;

print(len(r)*len(g)*len(b)-hiku);

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input());
s = input();

r = [];
g = [];
b = [];
for i in range(n) :
    if s[i] == 'R' :
        r.append(i+1);
    if s[i] == 'G' :
        g.append(i+1);
    if s[i] == 'B' :
        b.append(i+1);

ans = 0;
for i in r :
    for j in g :
        for k in b :
            l = [i,j,k];
            l.sort();
            if not(l[1]-l[0]-1 == l[2]-l[1]-1) :
                ans += 1;

print(ans);

Fixed submission:
n = int(input());
s = input();

r = [];
g = [];
b = [];
for i in range(n) :
    if s[i] == 'R' :
        r.append(i+1);
    if s[i] == 'G' :
        g.append(i+1);
    if s[i] == 'B' :
        b.append(i+1);

hiku = 0;
for j in range(2,n) :
    if j-1 < n-j :
        for i in range(1,j) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;
    else :
        for i in range(1,n-j+1) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;

print(len(r)*len(g)*len(b)-hiku);
Buggy python submission (verdict: Runtime Error):
n,m = list(map(int,input().split()));
a = list(map(int,input().split()));

a.sort(reverse = True);

i = 0;
while a[i] >= sum(a)/(4*m) and i < n:
    i += 1;

if i >= m :
    print('Yes');
else :
    print('No');

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

ans = 0;
for i in range(n) :
    if a[i] >= sum(a)/(4*m):
        ans += 1;

if ans >= m :
    print('Yes');
else :
    print('No');

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

a.sort(reverse = True);

i = 0;
while a[i] >= sum(a)/(4*m) :
    i += 1;

if i >= m :
    print('Yes');
else :
    print('No');

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

ans = 0;
for i in range(n) :
    if a[i] >= sum(a)/(4*m):
        ans += 1;

if ans >= m :
    print('Yes');
else :
    print('No');
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = list(map(int,input().split()));

knum = [0]*(n-1);
d = [[0]*(n) for i in range(n)];

for i in range(n) :
    for j in range(i+1,n) :
        d[i][j] = j - i;
        d[j][i] = j - i;

d[x-1][y-1] = 1;
d[y-1][x-1] = 1;

for i in range(n) :
    for j in range(i+1,n) :
        mind = min(d[i][j],d[i][x-1]+1+d[y-1][j],d[i][y-1]+1+d[x-1][j]);
        d[i][j] = mind;
        d[j][i] = mind;

for i in range(n) :
    for j in range(i+1,n) :
        knum[d[i][j]-1] += 1;

for i in range(n-1) :
    print(knum[i]);

Fixed submission:
n,x,y = list(map(int,input().split()));

knum = [0]*(n-1);
d = [[0]*(n) for i in range(n)];

for i in range(n) :
    for j in range(i+1,n) :
        d[i][j] = j - i;
        d[j][i] = j - i;

d[x-1][y-1] = 1;
d[y-1][x-1] = 1;

for i in range(n) :
    for j in range(i+1,n) :
        mind = min(d[i][j],d[i][x-1]+1+d[y-1][j],d[i][y-1]+1+d[x-1][j]);
        d[i][j] = mind;
        d[j][i] = mind;

for i in range(n) :
    for j in range(i+1,n) :
        knum[d[i][j]-1] += 1;

for i in range(n-1) :
    print(knum[i]);

Buggy python submission (verdict: Time Limit Exceeded):
n,x,y = list(map(int,input().split()));

knum = [0]*(n-1);
d = [[0]*(n) for i in range(n)];

for i in range(n) :
    for j in range(i+1,n) :
        d[i][j] = j - i;
        d[j][i] = j - i;

d[x-1][y-1] = 1;
d[y-1][x-1] = 1;

for i in range(n) :
    for j in range(i+1,n) :
        if (i < x and j < x) or (i > y and j > y) :
            continue;
        else :
            mind = min(d[i][j],d[i][x-1]+1+d[y-1][j],d[i][y-1]+1+d[x-1][j]);
            d[i][j] = mind;
            d[j][i] = mind;

for i in range(n) :
    for j in range(i+1,n) :
        knum[d[i][j]-1] += 1;

for i in range(n-1) :
    print(knum[i]);

Fixed submission:
n,x,y = list(map(int,input().split()));

knum = [0]*(n-1);
d = [[0]*(n) for i in range(n)];

for i in range(n) :
    for j in range(i+1,n) :
        d[i][j] = j - i;
        d[j][i] = j - i;

d[x-1][y-1] = 1;
d[y-1][x-1] = 1;

for i in range(n) :
    for j in range(i+1,n) :
        mind = min(d[i][j],d[i][x-1]+1+d[y-1][j],d[i][y-1]+1+d[x-1][j]);
        d[i][j] = mind;
        d[j][i] = mind;

for i in range(n) :
    for j in range(i+1,n) :
        knum[d[i][j]-1] += 1;

for i in range(n-1) :
    print(knum[i]);
Buggy python submission (verdict: Runtime Error):
import queue
import copy

vx = [0,1,0,-1];
vy = [1,0,-1,0];
q = queue.Queue()

hw = input().split(' ');
h = int(hw[0]);
w = int(hw[1]);
s = [ [0]*w for i in range(h)];
for i in range(h) :
	si = input();
	for j in range(w) :
		s[i][j] = si[j];

s_alt = copy.deepcopy(s);
ans = 0;
for sy in range(h) :
	for sx in range(w) :
		s = copy.deepcopy(s_alt);
		q_a = [0]*2;
		q_a[0] = sy;
		q_a[1] = sx;
		q.put(q_a);
		s[sy][sx] = 0;
		while not q.empty() :
			q_a = q.get();
			for i in range(4):
				ny = q_a[0] + vy[i];
				nx = q_a[1] + vx[i];
				if ny >= 0 and ny < h and nx >= 0 and nx < w and s[ny][nx] == '.':
					s[ny][nx] = s[q_a[0]][q_a[1]] + 1;
					q_b = [0]*2;
					q_b[0] = ny;
					q_b[1] = nx;
					q.put(q_b);
		max_path = 0;
		for i in range(h) :
			for j in range(w) :
				if s[i][j] == '#' :
					continue;
				elif s[i][j] > max_path :
					max_path = s[i][j];
		if max_path > ans :
			ans = max_path;

print(ans);

Fixed submission:
import queue
import copy

vx = [0,1,0,-1];
vy = [1,0,-1,0];
q = queue.Queue()

hw = input().split(' ');
h = int(hw[0]);
w = int(hw[1]);
s = [ [0]*w for i in range(h)];
for i in range(h) :
	si = input();
	for j in range(w) :
		s[i][j] = si[j];

s_alt = copy.deepcopy(s);
ans = 0;
for sy in range(h) :
	for sx in range(w) :
		s = copy.deepcopy(s_alt);
		if s[sy][sx] == '.' :
			q_a = [0]*2;
			q_a[0] = sy;
			q_a[1] = sx;
			q.put(q_a);
			s[sy][sx] = 0;
			while not q.empty() :
				q_a = q.get();
				for i in range(4):
					ny = q_a[0] + vy[i];
					nx = q_a[1] + vx[i];
					if ny >= 0 and ny < h and nx >= 0 and nx < w and s[ny][nx] == '.':
						s[ny][nx] = s[q_a[0]][q_a[1]] + 1;
						q_b = [0]*2;
						q_b[0] = ny;
						q_b[1] = nx;
						q.put(q_b);
			max_path = 0;
			for i in range(h) :
				for j in range(w) :
					if s[i][j] == '#' :
						continue;
					elif s[i][j] > max_path :
						max_path = s[i][j];
			if max_path > ans :
				ans = max_path;

print(ans);
Buggy python submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k][9]==s[i][9] :
		#for j in range(10) :
			#if s[i-k][j] != s[i][j] :
				#ok = 0;
		if  s[i-k]==s[i]:
			ans += 1;
		k += 1;

print(ans);

Fixed submission:
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);

Buggy python submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		#for j in range(10) :
			#if s[i-k][j] != s[i][j] :
				#ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

Fixed submission:
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);

Buggy python submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		for j in range(10) :
			if s[i-k][j] != s[i][j] :
				ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

Fixed submission:
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);

Buggy python submission (verdict: Runtime Error):
n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
for i in range(1,n) :
	ok = 1;
	k = 1;
	while s[i-k]==s[i] :
		for j in range(10) :
			if s[i-k][j] != s[i][j] :
				ok = 0;
		if bool(ok) :
			ans += 1;
		k += 1;

print(ans);

Fixed submission:
import math

n = int(input());
s = [0]*n;
for i in range(n) :
	s_pre = list(input());
	s_pre.sort();
	s[i] = s_pre;


s.sort(key=lambda x:(x[0],x[1],x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9]));

ans = 0;
ren = 0;
for i in range(1,n) :
	ok = 1;
	if s[i-1]==s[i]:
		ans += 1;
		ans += ren;
		ren += 1;
	else :
		ren = 0;

print(ans);
Buggy python submission (verdict: Runtime Error):
import fractions
#import math
def lcm(x, y):
	return int((x * y) / fractions.gcd(x, y));
	#return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
num_c = int(b/c) - int((a-1)/c);
num_d = int(b/d) - int((a-1)/d); 
num_cd = int(b/lcm(c, d)) - int((a-1)/lcm);
print(b - a + 1 -(num_c + num_d - num_cd))

Fixed submission:
import fractions
#import math
def lcm(x, y):
	return (x * y) // fractions.gcd(x, y);
	#return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
num_c = b//c - (a-1)//c;
num_d = b//d - (a-1)//d; 
num_cd = b//lcm(c, d) - (a-1)//lcm(c,d);
print(b - a + 1 -(num_c + num_d - num_cd))

Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
	return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
if a % c == 0 :
	min_c = int(a/c) - 1;
else :
	min_c = int(a/c);
if a % d == 0 :
	min_d = int(a/d) - 1;
else :
	min_d = int(a/d);
if a % lcm(c, d) == 0 :
	min_cd = int(a/lcm(c, d)) - 1;
else :
	min_cd = int(a/lcm(c, d));
num_c = int(b/c) - min_c;
num_d = int(b/d) - min_d; 
num_cd = int(b/lcm(c, d)) - min_cd;
print(b - a + 1 -(num_c + num_d - num_cd))

Fixed submission:
import fractions
#import math
def lcm(x, y):
	return (x * y) // fractions.gcd(x, y);
	#return (x * y) // math.gcd(x, y);

s = input().split(" ");
a = int(s[0]);
b = int(s[1]);
c = int(s[2]);
d = int(s[3]);
num_c = b//c - (a-1)//c;
num_d = b//d - (a-1)//d; 
num_cd = b//lcm(c, d) - (a-1)//lcm(c,d);
print(b - a + 1 -(num_c + num_d - num_cd))
Buggy python submission (verdict: Runtime Error):
dg = input().split(“ “);
d = int(dg[0]);
g = int(dg[1]);
p = [0]*d;
c = [0]*d;
for i in range(d) :
    s = input().split(“ “);
    p[i] = int(s[0]);
    c[i] = int(s[1]);

ans = 0;
for i in range(sum(p)) :
    sump = 0;
    for j in range(len(p)) :
        all = 0;
        for m in range(p[j]) :
            if(i & 2**(sump+m)>>(sump+m)) :
                ans += (j+1)*100;
                all += 1;
        if(all == p[j]) :
            ans += c[j];
        sump += p[i];
print(ans);

Fixed submission:
dg = input().split(' ');
d = int(dg[0]);
g = int(dg[1]);
p = [0]*d;
c = [0]*d;
for i in range(d) :
    s = input().split(' ');
    p[i] = int(s[0]);
    c[i] = int(s[1]);

ans = sum(p);
for i in range(2**d) :
    sumpoint = 0;
    luck = -1;
    point = 0;
    for j in range(d-1,-1,-1) :
        if((i & 2**j)>>j) :
            sumpoint += (j+1)*100*p[j] + c[j];
            point += p[j];
        elif(luck<0) :
            luck = j
    k = 0;
    while k < p[luck] and sumpoint < g :
        sumpoint += (luck+1)*100;
        point += 1;
        k+= 1;
    if sumpoint >= g and point < ans :
        ans = point;

print(ans);