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

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
A, B, T = map(int, input().split())

x = int(np.floor((T + 0.5) / A))

print(x * B)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import fractions

N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))


def gcd_list(numbers):
    res = fractions.gcd(numbers[0], numbers[1])
    if len(numbers) > 2:
        for idx in range(2, len(numbers)):
            res = fractions.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import fractions

N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))


def gcd_list(numbers):
    res = math.gcd(numbers[0], numbers[1])
    if len(numbers) > 2:
        for idx in range(2, len(numbers)):
            res = fractions.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)
Problem p03061 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import fractions

N = int(input().rstrip())
A = [0] + list(map(int, input().rstrip().split())) + [0]

L = [0] * (N + 2)
R = [0] * (N + 2)

for i in range(0, N):
    L[i + 1] = fractions.gcd(L[i], A[i + 1])

for i in range(N, 0, -1):
    R[i] = fractions.gcd(R[i + 1], A[i])

print(max(fractions.gcd(L[i], R[i + 2]) for i in range(0, N)))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

N = int(input().rstrip())
As = list(map(int, input().rstrip().split()))


def gcd_list(numbers):
    res = math.gcd(numbers[0], numbers[1])
    if len(numbers) > 2:
        for idx in range(2, len(numbers)):
            res = math.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

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


def gcd_list(numbers):
    res = math.gcd(numbers[0], numbers[1])
    if len(numbers) > 2:
        for idx in range(2, len(numbers)):
            res = math.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math

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


def gcd_list(numbers):
    res = math.gcd(numbers[0], numbers[1])
    for idx in range(2, len(numbers)):
        res = math.gcd(res, numbers[idx])
    return res


max_gcd = 0
if(N) == 2:
    max_gcd = max(As)
else:
    for i in range(N):
        others = [As[j] for j in range(N) if j != i]
        max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
from functools import reduce


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


def gcd_list(numbers):
    return reduce(math.gcd, numbers)

max_gcd = 0

for i in range(len(As)):
    others = [As[j] for j in range(len(As)) if j != i]
    max_gcd = max(gcd_list(others), max_gcd)

print(max_gcd)
Problem p03076 (python)

Fixed submission:
times = []
ones = [10]
for i in range(5):
    t = int(input())
    times.append((t + 9) // 10 * 10)
    ones.append(t % 10)
ones.sort()
print(sum(times) - 10 + min(filter(lambda x: x, ones)))

Buggy submission (verdict: Runtime Error):
times = []
ones = []
for i in range(5):
    t = int(input())
    times.append((t + 9) // 10 * 10)
    ones.append(t % 10)
ones.sort()
print(sum(times) - 10 + min(filter(lambda x: x, ones)))
Problem p03000 (python)

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

cnt = 1
d = 0

while(True):
  if cnt - 1 == n:
    break
  d += l[cnt - 1]
  if d > x:
    break
  cnt += 1

print(cnt)

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

cnt = 0
d = 0

while(x >= d):
  d += l[cnt]
  cnt += 1

print(cnt)
Problem p03007 (python)

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

a.sort()

posi = [a[-1]]
nega = [a[0]]

for n in a[1:-1]:
  if n < 0:
    nega.append(n)
  else:
    posi.append(n)

selected = []
ans = nega[0]

for n in posi[1:]:
  (x, y) = ans, n
  ans = x - y
  selected.append((x, y))

nega.append(ans)

ans = posi[0]
for n in nega[1:]:
  (x, y) = ans, n
  ans = x - y
  selected.append((x, y))

print(ans)

for (x, y) in selected:
  print(str(x) + ' ' + str(y))

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

nega = sorted(list(filter(lambda x: x < 0, a)))
posi = sorted(list(filter(lambda x: x >= 0, a)), reverse=True)

selected = []

for i in range(n - 1):
  if len(nega) == 0:
    (x, y) = posi[0], posi[-1]
    posi = posi[1:-1]
    selected.append((x, y))
    nega.append(x - y)
  elif len(posi) == 0:
    (x, y) = nega[0], nega[-1]
    nega = nega[1:-1]
    selected.append((x, y))
    posi.append(x - y)
  else:
    if len(nega) >= len(posi):
      (x, y) = posi.pop(), nega.pop()
      selected.append((x,y))
      posi.append(x - y)
    else:
      (x, y) = nega.pop(), posi.pop()
      selected.append((x, y))
      nega.append(x - y)

if len(nega) == 1:
  print(nega[0])
else:
  print(posi[0])

for (x, y) in selected:
  print(f'{x} {y}')

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

nega = sorted(list(filter(lambda x: x < 0, a)))
posi = sorted(list(filter(lambda x: x >= 0, a)), reverse=True)

selected = []

for i in range(n - 1):
  if len(nega) == 0:
    (x, y) = posi[0], posi[-1]
    posi = posi[1:-1]
    selected.append((x, y))
    nega.append(x - y)
  elif len(posi) == 0:
    (x, y) = nega[0], nega[-1]
    nega = nega[1:-1]
    selected.append((x, y))
    posi.append(x - y)
  else:
    if len(nega) >= len(posi):
      (x, y) = posi.pop(), nega.pop()
      selected.append((x,y))
      posi.append(x - y)
    else:
      (x, y) = nega.pop(), posi.pop()
      selected.append((x, y))
      nega.append(x - y)

if len(nega) == 1:
  print(nega[0])
else:
  print(posi[0])

for (x, y) in selected:
  print(f'{x} {y}')
Problem p03227 (python)

Fixed submission:
s = input()

if len(s) == 2:
  print(s)
else:
  print(s[2] + s[1] + s[0])

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

a = [0] * n

for i in range(0, n):
  a[i] = int(input())

a.sort()

c = 0

if len(a) == 2:
  print(abs(a[0] - a[1]))

if len(a) == 3:
  diff = abs(a[0] - a[1]) + abs(a[1] - a[2])
  diff = max(abs(a[0] - a[2]) + abs(a[1] - a[2]), diff)
  diff = max(abs(a[0] - a[2]) + abs(a[0] - a[1]), diff)
  print(diff)

mini = 0
maxi = len(a) - 1

if len(a) > 3:
  (l, r) = (a[maxi], a[maxi - 1])
  maxi -= 2
  diff = abs(a[0] - l) + abs(a[0] - r)
  mini += 1
  for i in range(0, n - 3):
    if i % 2 == 0:
      if c < 2:
        diff += abs(a[mini] - l)
        l = a[mini]
        mini += 1
      else:
        diff += abs(a[maxi] - l)
        l = a[maxi]
        maxi -= 1
    else:
      if c < 2:
        diff += abs(a[mini] - r)
        r = a[mini]
        mini += 1
      else:
        diff += abs(a[maxi] - r)
        r = a[maxi]
        maxi -= 1
    if c < 3:
      c += 1
    else:
      c = 0
  
  maxi = len(a) - 1
  mini = 0
  (l, r) = (a[mini], a[mini + 1])
  mini += 2
  diff2 = abs(a[-1] - l) + abs(a[-1] - r)
  maxi -= 1
  for i in range(0, n - 3):
    if i % 2 == 0:
      if c > 1:
        diff2 += abs(a[mini] - l)
        l = a[mini]
        mini += 1
      else:
        diff2 += abs(a[maxi] - l)
        l = a[maxi]
        maxi -= 1
    else:
      if c > 1:
        diff2 += abs(a[mini] - r)
        r = a[mini]
        mini += 1
      else:
        diff2 += abs(a[maxi] - r)
        r = a[maxi]
        maxi -= 1
    if c < 3:
      c += 1
    else:
      c = 0

  print(max(diff, diff2))
Problem p03231 (python)

Fixed submission:

n, m = map(int, input().split())
s = input()
t = input()

cnt = 1
ns = 1
nt = 1
ss = 0
tt = 0
fail = False


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


ll = (n * m) // gcd(n, m)
l = ll

while l <= n * m:
    fail = False
    while not(ns > l or nt > l):
        while not(ns <= nt):
            nt += l / m
            tt += 1

        if(ns == nt) and (s[ss] != t[tt]):
            fail = True
            break

        ns += l / n
        ss += 1
    if not(fail):
        break
    cnt += 1
    l = ll * cnt

if(fail):
    print(-1)
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
s = input()
t = input()

cnt = 1
ns = 1
nt = 1
ss = 0
tt = 0
fail = False

ll = (n * m) // math.gcd(x, y)
l = ll

while l <= n * m:
    fail = False
    while not( ns >= l or nt >= l):
        while not(ns <= nt):
            nt += l / m 
            tt += 1

        if(ns == nt) and (s[ss] != t[tt]):
            fail = True
            break

        ns += l / n
        ss += 1
    if not(fail): 
        break
    cnt += 1
    l = ll * cnt

if(fail):
    print(-1)
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
s = input()
t = input()

cnt = 1
ns = 1
nt = 1
ss = 0
tt = 0
fail = False

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

ll = lcm(n,m)
l = ll

while l <= n * m:
    fail = False
    while not( ns >= l or nt >= l):
        while not(ns <= nt):
            nt += l / m 
            tt += 1

        if(ns == nt) and (s[ss] != t[tt]):
            fail = True
            break

        ns += l / n
        ss += 1
    if not(fail): 
        break
    cnt += 1
    l = ll * cnt

if(fail):
    print(-1)
else:
    print(l)

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
s = input()
t = input()

cnt = 1
ns = 1
nt = 1
ss = 0
tt = 0
fail = False

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

ll = lcm(n,m)
l = ll

while l <= n * m:
    fail = False
    while not( ns >= l or nt >= l):
        while not(ns <= nt):
            nt += l / m 
            tt += 1

        if(ns == nt):
            if(s[ss] != t[tt]):
                fail = True
                break

        ns += l / n
        ss += 1
    if not(fail): 
        break
    cnt += 1
    l = ll * cnt

if(fail):
    print(-1)
else:
    print(l)
Problem p03309 (python)

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

for i in range(n):
  a[i] = a[i] - (i + 1)


a.sort()
med = a[len(a) // 2]

n = 0

for ai in a:
  n += abs(ai - med)

print(n)

Buggy submission (verdict: Runtime Error):
import statistics

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

for i in range(n):
  a[i] = a[i] - (i + 1)


a.sort()
med = statistics.median(a)

n = 0

for ai in a:
  n += abs(ai - med)

print(n)
Problem p02973 (python)

Fixed submission:
import bisect
from collections import deque

N = int(input())

tops = deque() 

for i in range(N):
    a = int(input())
    p = bisect.bisect_left(tops, a)
    
    if p == 0:
        tops.appendleft(a)
    else:    
        tops[p-1] = a
        
print(len(tops))

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

N = int(input())

tops = deque()

for i in range(N):
    a = int(input())
    p = bisect.bisect_left(tops, a)
    
    if p == 0:
        bisect.insort_left(tops, a)
    else:    
        tops[p-1] = a
        
print(len(tops))

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

N = int(input())

tops = deque()

for i in range(N):
    a = int(input())
    p = bisect.bisect_left(tops, a)
    
    if p == 0:
        bisect.insort_left(tops, a)
    else:    
        tops[p-1] = a
        
print(len(tops))
Problem p02975 (python)

Fixed submission:
from collections import defaultdict

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

dic = defaultdict(int)


# 3の倍数個
if N % 3 == 0:
    
    for a in A:
        dic[a] += 1

    n_kind = len(dic.keys())
    values = list(dic.keys())
    cnts = list(dic.values())
        
    # 整数の種類数で分岐
    if n_kind == 3:
        is_xor = False    
        # 3つの整数で xorの関係を作れるか判定
        for i in range(n_kind-2):
            for j in range(i+1, n_kind-1):
                for k in range(j+1, n_kind):
                    if values[i] ^ values[j] ^ values[k] == 0:
                        is_xor = True

        
        # 3つの整数がそれぞれ N/3個であるか判定
        is_n_valid = True
        for cnt in cnts:
            if cnt != N/3:
                is_n_valid = False

            
        if is_xor and is_n_valid:
            print('Yes')
        else:
            print('No')
    
    elif n_kind == 2:
        
        # 2つの整数がそれぞれ 2N/3個であり、0がN/3子であるか判定
        is_n_valid = True
        if 0 in values:
            for k, v in dic.items():
                if k == 0:
                    if v != N/3:
                        is_n_valid = False
                else:
                    if v != N * (2/3):
                        is_n_valid = False
        else:
            is_n_valid = False

        if is_n_valid:
            print('Yes')
        else:
            print('No')


    elif n_kind == 1:
        all_zero = True
        for a in A:
            if a != 0:
                all_zero = False

        if all_zero:
            print('Yes')
        else:
            print('No')        

    else:
        print('No')

# 3の倍数個以外の場合は、全て0である必要がある
else:
    all_zero = True
    for a in A:
        if a != 0:
            all_zero = False

    if all_zero:
        print('Yes')
    else:
        print('No')

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

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

a0 = A[0]
c = A[1]
b = a0 ^ a1

f = True

for i in range(3, N):
    if i % 3 == 0 and a != A[i]:
        f = False
    elif i % 3 == 1 and b != A[i]:
        f = False
    elif i % 3 == 2 and c != A[i]:
        f = False

if f:
    print('Yes')
else:
    print('No')
Problem p02995 (python)

Fixed submission:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

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

# 0 => A-1 で割りきれる
cnt_c = (A-1) // C
cnt_d = (A-1) // D

cnt_cd = (A-1) // lcm(C, D)

cnt_a = cnt_c + cnt_d - cnt_cd

# 0 => Bで割りきれる
cnt_c2 = B // C
cnt_d2 = B // D
cnt_cd2 = B // lcm(C, D)

cnt_b = cnt_c2 + cnt_d2 - cnt_cd2

cnt_ab = cnt_b - cnt_a

cnt_n = B - A + 1

print(cnt_n - cnt_ab)

Buggy submission (verdict: Runtime Error):
import math

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

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

# 0 => A-1 で割りきれる
cnt_c = (A-1) // C
cnt_d = (A-1) // D

cnt_cd = (A-1) // lcm(C, D)

cnt_a = cnt_c + cnt_d - cnt_cd

# 0 => Bで割りきれる
cnt_c2 = B // C
cnt_d2 = B // D
cnt_cd2 = B // lcm(C, D)

cnt_b = cnt_c2 + cnt_d2 - cnt_cd2

cnt_ab = cnt_b - cnt_a

cnt_n = B - A + 1

print(cnt_n - cnt_ab)
Problem p03074 (python)

Fixed submission:
n, k = map(int, input().split())
s = list(map(int, input()))

now = 1
cnt = 0
nums = []

for i in range(n):
    if s[i] == now: cnt+=1
    else:
        nums.append(cnt)
        now = 1 - now  # 0, 1の切り替え
        cnt = 1  # カウントを始める

if cnt != 0: nums.append(cnt)

# 計算しやすさのため、1の個数-0の個数...1の個数という配列が欲しい
if (len(nums) % 2 == 0): nums.append(0)

add = 2 * k + 1
tmp_sum = 0

left = 0
right = 0

ans = 0

for i in range(0, len(nums), 2):

    next_left = i
    next_right = min(i + add, len(nums))

    while left < next_left:
        tmp_sum -= nums[left]
        left+=1

    while right < next_right:
        tmp_sum += nums[right]
        right+=1

    ans = max(tmp_sum, ans)

print(ans)

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

now = 1
cnt = 0
nums = []

for i in range(n):
    if s[i] == now: cnt+=1
    else:
        nums.append(cnt)
        now = 1 - now  # 0, 1の切り替え
        cnt = 1  # カウントを始める

if cnt != 0: nums.append(cnt)

# 計算しやすさのため、1の個数-0の個数...1の個数という配列が欲しい
if (len(nums) % 2 == 0): nums.append(0)

add = 2 * k + 1
tmp_sum = 0

left = 0
right = 0

ans = 0

for i in range(0, n, 2):

    next_right = i
    next_left = min(i + add, n)

    while left < next_left:
        tmp_sum -= nums[left]
        left++

    while right < next_right:
        tmp_sum += nums[right]
        right++

    ans = max(tmp_sum, ans)

print(ans)
Problem p03339 (python)

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

w = [0]
e = [0]

tmp_w = 0
tmp_e = 0

for i in range(1, n):

    j = (n - 1) - i

    if (s[i-1] == 'W'):
        w.append(tmp_w + 1)
        tmp_w += 1
    else:
        w.append(tmp_w)

    if (s[j+1] == 'E'):
        e.append(tmp_e + 1)
        tmp_e += 1
    else:
        e.append(tmp_e)

e.reverse()

ans = 10 ** 6 
for i in range(n):
    ans = w[i] + e[i] if w[i] + e[i] < ans else ans

print(ans)

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

w = [0]
e = [0]

for i in range(1, n):

    j = (n - 1) - i

    if (s[i-1] == 'W'):
        w.append(w[-1] + 1)
    else:
        w.append(w[-1])

    if (s[j+1] == 'E'):
        e.insert(0, e[0] + 1)
    else:
        e.insert(0, e[0])

result = []

ans = 10 ** 6 
for i in range(n):
    ans = w[i] + e[i] if w[i] + e[i] > ans else ans

print(min(result))
Problem p03409 (python)

Fixed submission:
N = int(input())

reds = []
for _ in range(N):
    reds.append(tuple(map(int, input().split())))
    
blues = []
for _ in range(N):
    blues.append(tuple(map(int, input().split())))

reds.sort()
blues.sort()

ans = 0
for blue in blues:
    c, d = blue

    # 条件に当てはまる赤を抽出
    targets = [red for red in reds if red[0] < c and red[1] < d]
    targets.sort(key=lambda x:x[1])

    # 赤のうち一番y座標が大きいものを抽出
    if targets:
        target = targets.pop()
        reds.remove(target)
        ans += 1

print(ans)

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

reds = []
for _ in range(N):
    reds.append(tuple(map(int, input().split())))
    
blues = []
for _ in range(N):
    blues.append(tuple(map(int, input().split())))

reds.sort()
blues.sort()

ans = 0
for blue in blues:
    c, d = blue

    # 条件に当てはまる赤を抽出
    targets = [red for red in reds if red[0] < c and red[1] < d]
    targets.sort(key=lambda x:x[1])

    # 赤のうち一番y座標が大きいものを抽出
    if reds_under_x:
        target = reds_under_x.pop()
        reds.remove(target)
        ans += 1

print(ans)
Problem p03796 (python)

Fixed submission:
import math

n = int(input())

f = math.factorial(n)

print(f % (10**9 + 7))

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

total = 1

for i in range(1, n+1):
    total *= i

print(total / (10**9 + 7))
Problem p02958 (python)

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

l = sorted(p)
count = 0

for a, b in zip(p, l):
    if (a is not b): count += 1

if ((count == 0) or (count == 2)):
    print("YES")
else:
    print("NO")

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

l = sorted(p)
count = 0

for a, b in zip(p, l):
    if (a is not b): count += 1

if ((count == 0) or ((count == 2)):
    print("YES")
else:
    print("NO")
Problem p03377 (python)

Fixed submission:
a,b,x = map(int,input().split())
if (a <= x <= (a+b)):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input())
if (a < x <(a+b)):
    print('YES')
else:
    print('NO')
Problem p03385 (python)

Fixed submission:
if ("".join(sorted(input())) == "abc"):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if ("".join(sorted(input())) == "abc):
    print("Yes")
else:
    print("No")
Problem p03623 (python)

Fixed submission:
#ABC071A
import math
x, a, b =list(map(int, input().split()))

ax = math.fabs(a-x)
bx = math.fabs(b-x)

if (ax < bx): print("A")
else: print('B')

Buggy submission (verdict: Runtime Error):
#ABC071A
import math
x, a, b =list(map(int, input().split()))

ax = math.abs(a-x)
bx = math.abs(b-x)

if (ax < bx): print("A")
else: print('B')
Problem p03844 (python)

Fixed submission:
#ABC050A
A, op, B = list(input().split())
A = int(A)
B = int(B)

if (op == '+'): print(A+B)
else: print(A-B)

Buggy submission (verdict: Runtime Error):
#ABC050A
A, op, B = list(input().split())
if (op == '+'): print(A+B)
else: print(A-B)
Problem p02947 (python)

Fixed submission:
import collections as cl
import itertools as it
N = int(input())
s = []
for i in range(N):
    ss = input()
    s.append(ss)
#print(s)
t = sorted(s)
t= []
for i in range(N):
    tt= sorted(s[i])
    ts = ",".join(tt)
    t.append(ts)
#    print(ts)
#print(t)
l = cl.Counter(t)
#print(l)
count = 0
for v in l.values():
    if v > 1:
        count = count + v*(v-1)/2
#    print(v)
print(int(count))

Buggy submission (verdict: Runtime Error):
import collections
N = int(input())
s = []
for i in range(N):
    ss = input()
    s.append(ss)
t= []
for i in range(N):
    tt= sorted(s[i])
    t.append(tt)
#s.sort()
#print(t)

count = 0
for i in range(N):
    a = tt.count(tt[i])
    count = count+a
print(count-N)
Problem p02994 (python)

Fixed submission:
N,L = list(map(int,input().split()))
aji=[]
for i in range(N):
    aji.append(L+i)

absaji = []
for i in range(N):
    absaji.append(abs(aji[i]))

#newaji = np.abs(aji)
minaji = min(absaji)

if sum(aji) < 0:
    sumaji = sum(aji) + minaji
else:
    sumaji = sum(aji) - minaji
print(sumaji)

Buggy submission (verdict: Runtime Error):
import numpy as np
import matplotlib.pyplot as plt
N,L = list(map(int,input().split()))
aji=[]
for i in range(N):
    aji.append(L+i)

absaji = []
for i in range(N):
    absaji.append(abs(aji[i]))

#newaji = np.abs(aji)
minaji = min(absaji)

if sum(aji) < 0:
    sumaji = sum(aji) + minaji
else:
    sumaji = sum(aji) - minaji
print(sumaji)
Problem p02995 (python)

Fixed submission:
import fractions
A,B,C,D = list(map(int,input().split()))
dis = B - A + 1

CD = C*D//(fractions.gcd(C,D))
#print(CD)
perCfromA = (A-1)//C
perDfromA = (A-1)//D
perCDfromA = (A-1)//(CD)


perCfromB = B//C
perDfromB = B//D
perCDfromB = B//(CD)

#print(perCfromA,perDfromA,perCDfromA,perCfromB,perDfromB,perCDfromB)
warikire = (perCfromB + perDfromB -perCDfromB) - (perCfromA + perDfromA -perCDfromA)
warikirenai = dis -warikire
print(warikirenai)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int,input().split()))
dis = B - A + 1
CD = C*D//math.gcd(C,D)
perCfromA = (A-1)//C
perDfromA = (A-1)//D
perCDfromA = (A-1)//CD
perCfromB = B//C
perDfromB = B//D
perCDfromB = B//CD
warikire = (perCfromB + perDfromB -perCDfromB) - (perCfromA + perDfromA -perCDfromA)
warikirenai = dis -warikire
print(warikirenai)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = list(map(int,input().split()))
dis = B - A + 1

CD = C*D//math.gcd(C,D)
#print(CD)
perCfromA = (A-1)//C
perDfromA = (A-1)//D
perCDfromA = (A-1)//(CD)


perCfromB = B//C
perDfromB = B//D
perCDfromB = B//(CD)

#print(perCfromA,perDfromA,perCDfromA,perCfromB,perDfromB,perCDfromB)
warikire = (perCfromB + perDfromB -perCDfromB) - (perCfromA + perDfromA -perCDfromA)
warikirenai = dis -warikire
print(warikirenai)