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

n=int(input())
s=[input() for _ in range(n)]

lis=[collections.Counter(list(s[i])) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        if lis[i].items()==lis[j].items(): cnt+=1
print(cnt)


Fixed submission:
import collections

n=int(input())
s=[(input()) for _ in range(n)]

lis=[list(s[i]) for i in range(n)]
lis_sort = [sorted(lis[i]) for i in range(n)]
lis_sort = [''.join(lis_sort[i]) for i in range(n)]
lis_sort.sort()

c = collections.Counter(lis_sort)
values, counts = zip(*c.most_common(len(c)))
cnt=0
for i in range(len(counts)):
    if counts[i]==2: cnt+=1
    elif counts[i]>2: cnt+=counts[i]*(counts[i]-1)//2
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=[input() for _ in range(n)]

lis=[collections.Counter(list(s[i])) for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i+1,n):
        if lis[i].items()==lis[j].items(): cnt+=1
print(cnt)

Fixed submission:
import collections

n=int(input())
s=[(input()) for _ in range(n)]

lis=[list(s[i]) for i in range(n)]
lis_sort = [sorted(lis[i]) for i in range(n)]
lis_sort = [''.join(lis_sort[i]) for i in range(n)]
lis_sort.sort()

c = collections.Counter(lis_sort)
values, counts = zip(*c.most_common(len(c)))
cnt=0
for i in range(len(counts)):
    if counts[i]==2: cnt+=1
    elif counts[i]>2: cnt+=counts[i]*(counts[i]-1)//2
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
init=[1]*len(s)
ans = [0]*len(s)
for _ in range(10**5):
    for i in range(len(s)-1):
        if s[i]=='R':
            ans[i+1]+=init[i]
    for i in range(1,len(s)):
        if s[i]=='L':
            ans[i-1]+=init[i]
    init = ans[:]
    ans = [0]*len(s)
print(*init)

Fixed submission:
s=input()
init=[1]*len(s)

for k in range(len(s)-2):
    if s[k]=='R' and s[k+1]=='R':
        init[k+2]+=init[k]
        init[k]=0
for k in range(len(s)-1,0,-1):
    if s[k]=='L' and s[k-1]=='L':
        init[k-2]+=init[k]
        init[k]=0
print(*init)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().slplit())
if (b-a)%2==0: print((a+b)//2)
else: print('IMPOSSIBLE')

Fixed submission:
a,b = map(int, input().split())
if (b-a)%2==0: print((a+b)//2)
else: print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
dis = [list(map(int,input().split())) for i in range(n)]

cnt=0
for j in range(n-1):
    dist = 0
    for i in range(d):
        dist += (dis[j][i]-dis[j+1][i])**2
    if is_square(dist) == True: cnt+=1

dist = 0
for i in range(d):
    dist += (dis[0][i]-dis[-1][i])**2
if is_square(dist) == True: cnt+=1
print(cnt)

Fixed submission:
n,d=map(int,input().split())
dis = [list(map(int,input().split())) for i in range(n)]

def is_square(n):
    res=n**0.5
    return res.is_integer()

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        dist = 0
        for k in range(d):
            #i行目とj行目
            dist += (dis[i][k]-dis[j][k])**2
        if is_square(dist) == True: cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
if r-l>=3000: print(0)
else:
    min_mod=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, (i*j)%2019)
    print(min_mod)

Fixed submission:
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
if r-l>=3000: print(0)
else:
    min_mod=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, (i*j)%2019)
	print(min_mod)

Fixed submission:
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
if r-l>=3000: print(0)
else:
    min_mod=2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, (i*j)%2019)
	print(min_mod)

Fixed submission:
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
if r-l>=3000: print(0)
else:
    min_mod=2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, i*j%2019)
print(min_mod)

Fixed submission:
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)

Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())

if r-l>=2019: print(0)
else:
    min_mod=2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, i*j%2019)
print(min_mod)

Fixed submission:
l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())

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

d = 0

cnt = 0

for i in range(n+1):
	if d > x:
		break
	else:
		d += l[i]
		cnt += 1

print(cnt)

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

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

d = 0

cnt = 1

for i in range(n):
	d += l[i]
	if d > x:
		break
	else:
		cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
w, h, x, y = map(int, input().split())

flag = '0'
size = 0

if (w==x and h==y) or (x==0 and y==0):
	size = x*y
	flag = '1'
elif w == x and h != y:
	size = min(x*y, x*(h-y))
elif h == y and w != x:
	size = min(x*y, (w-x)*y)
else:
	size1 = x * h
	size2 = (w - x) * h
	size3 = w * x
	size4 = w * (h - y)

	min_size1 = min(size1, size2)
	min_size2 = min(size3, size4)

	if min_size1 == min_size2:
		flag = '1'

	if min_size1 < min_size2:
		size = min_size2
	else:
		size = min_size1


print(min_size1)
print(min_size2)
print(size, flag)

Fixed submission:
w,h,x,y=map(int,input().split())

if x*2==w and y*2==h:
    print(w*h/2, 1)
else:
    print(w*h/2, 0)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [0] + [int(input()) for _ in range(m)]

dp = [0] * (n + 1)
dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
MOD = 10 ** 9 + 7

for i in range(2, n + 1):
    if i in a:
        continue
    dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= MOD

print(dp[-1])


Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]

mod=10**9+7

oks = [True]*(n+1)
for i in range(m):
    oks[a[i]] = False

dp=[0]*(n+1)
dp[0]=1
for now in range(0,n):
    for nex in range(now+1,min(n,now+2)+1):
        if oks[nex]:
            dp[nex]+=dp[now]
            dp[nex]%=mod
print(dp[n])
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []

for i in range(n):
  	# input as str
	s, p = input().split()
    # p -> integer
	p = int(score)
    # create list
	a.append((s, p, i+1))

# sort
a.sort(key=lambda x:x[1], reverse=True)

# sort
a.sort(key=lambda x:x[0])

# output
for i in range(n):
	print(a[i][2])

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

a = []

for i in range(n):
  	# input as str
	s, p = input().split()
    # p -> integer
	p = int(score)
    # create list
	a.append((s, p, i+1))

# sort
a.sort(key=lambda x:x[1], reverse=True)

# sort
a.sort(key=lambda x:x[0])

# output
for i in range(n):
	print(a[i][2])

Fixed submission:
n = int(input())

a = []

for i in range(n):
  	# input as str
	s, p = input().split()
    # p -> integer
	p = int(p)
    # create list
	a.append((s, p, i+1))

# sort
a.sort(key=lambda x:x[1], reverse=True)

# sort
a.sort(key=lambda x:x[0])

# output
for i in range(n):
	print(a[i][2])
Buggy python submission (verdict: Runtime Error):
import itertools

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

sw = [[] for _ in range(M)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1:])) #k不要
     
p = list(map(int,input().split()))

res = 0
for tpl in itertools.product([0,1],repeat=n):
    bl = True
    for i in range(m):
        s = sum([tpl[s-1] for s in sw[i]]) # 電球iを計算
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        res += 1
print(res)

Fixed submission:
import itertools

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

sw = [[] for _ in range(m)]
for i in range(m):
    sw[i] = list(map(int,input().split()[1:])) #k不要
     
p = list(map(int,input().split()))

res = 0
for tpl in itertools.product([0,1],repeat=n):
    bl = True
    for i in range(m):
        s = sum([tpl[s-1] for s in sw[i]]) # 電球iを計算
        if (s-p[i])%2 != 0:
            bl = False
            break
    if bl:
        res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
#TLEする
#こんなことしなくても最小と最大を更新していけばおｋ
#m-1にしてた
n,m=map(int,input().split())
l,r=map(int,input().split())
l_max,r_min=l,r
for i in range(m):
    l,r=map(int,input().split())
    if l_max<l: l_max=l
    if r_min>r: r_min=r
print(r_min-l_max+1)

Fixed submission:
#不十分だった
n, m = map(int, input().split())
l_max, r_min = 0, 10**5 + 1
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

print(max(r_min - l_max + 1, 0))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l,r=map(int,input().split())
lis=list(range(l,r+1))
ans=lis
for i in range(m-1):
    l,r=map(int,input().split())
    lis_=list(range(l,r+1))
    ans=list(set(lis)&set(lis_))
print(len(ans))

Fixed submission:
#不十分だった
n, m = map(int, input().split())
l_max, r_min = 0, 10**5 + 1
for i in range(m):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

print(max(r_min - l_max + 1, 0))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
res = 0
idx = 0
while idx < n:
    b, c = a.pop()
    p = min(b, n-t)
    res += p * c
    idx += p
print(res)


Fixed submission:
n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
res = 0
idx = 0
while idx < n:
    b, c = a.pop()
    p = min(b, n-idx)
    res += p * c
    idx += p
print(res)

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

b = [0] * (m)
c = [0] * (m)

for i in range(m):
	b[i], c[i] = map(int, input().split())

d = []

for i in range(m):
	for j in range(b[i]):
		d.append(c[i])

a.extend(d)
a.sort(reverse=True)

print(sum(a[:n]))


Fixed submission:
n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
res = 0
idx = 0
while idx < n:
    b, c = a.pop()
    p = min(b, n-idx)
    res += p * c
    idx += p
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
A = [[] for _ in range(h)]
for i in range(h):
    A[i] = list(input())

from collections import deque

d = deque()
count_black = 0
for i in range(h):
    for j in range(w):
        if A[i][j] == '#':
            d.append((i, j))
            count_black += 1

count_while = h * w - count_black

cnt = 0
while count_while:
    while d:
        y, x = d.popleft()
        for dy, dx in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            ny, nx = y + dy, x + dx
            if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
            if A[ny][nx] == '#': continue
            A[ny][nx] = '#'

    # 再構築
    d = deque()
    count_black = 0
    for i in range(h):
        for j in range(w):
            if A[i][j] == '#':
                d.append((i, j))
                count_black += 1

    count_while = h * w - count_black
    cnt += 1

print(cnt)

Fixed submission:
H, W = map(int, input().split())
# 壁あり
A = [['#'] * (W + 2)] +  [['#'] + list(input()) + ['#'] for _ in range(H)] + [['#'] * (W + 2)]

visited = [[True] * (W + 2) for _ in range(H + 2)]
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if A[h][w] == '.':
            visited[h][w] = False

que = []
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if visited[h][w]:
            que.append((h, w))

res = -1
while que:
    q = []
    res += 1
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for x, y in que:
            nx, ny = x + dx, y + dy
            if not visited[nx][ny]:
                visited[nx][ny] = True
                q.append((nx, ny))
    que = q

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
# 壁あり
A = [['#'] * (w + 2)] +  [['#'] + list(input()) + ['#'] for _ in range(h)] + [['#'] * (w + 2)]

from copy import deepcopy

dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
cnt = 0
while True:
    cnt_white = sum([e.count('.') for e in A])
    if cnt_white == 0:
        break
    B = deepcopy(A)
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            if A[i][j] == '#':
                for x, y in dxdy:
                    B[i + x][j + y] = '#'
    A = deepcopy(B)
    cnt += 1

print(cnt)

Fixed submission:
H, W = map(int, input().split())
# 壁あり
A = [['#'] * (W + 2)] +  [['#'] + list(input()) + ['#'] for _ in range(H)] + [['#'] * (W + 2)]

visited = [[True] * (W + 2) for _ in range(H + 2)]
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if A[h][w] == '.':
            visited[h][w] = False

que = []
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if visited[h][w]:
            que.append((h, w))

res = -1
while que:
    q = []
    res += 1
    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for x, y in que:
            nx, ny = x + dx, y + dy
            if not visited[nx][ny]:
                visited[nx][ny] = True
                q.append((nx, ny))
    que = q

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

if cnt_minus % 2 == 0:
    print(sum([abs(a[i]) for i in range(n)]))
else:
    mi = min([abs(a[i]) for i in range(n)])
    print(sum([abs(a[i]) for i in range(n)]) - 2 * mi)

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

cnt_minus = len([a[i] for i in range(n) if a[i] < 0])

if cnt_minus % 2 == 0:
    print(sum([abs(a[i]) for i in range(n)]))
else:
    mi = min([abs(a[i]) for i in range(n)])
    print(sum([abs(a[i]) for i in range(n)]) - 2 * mi)
Buggy python submission (verdict: Runtime Error):
N = int(input())

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

num_ryokan = 0
max_height = 0

for i in range(N):
  if max_height <= H[i]:#見えるとき
    num_ryokan +=1
    max_height = H[i]

print(num_ryokan)

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

if A==B:
  print(A+B)
else:
  print(max(A,B)*2-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()

nums = []
now = 1 # 今見ている値
cnt = 0 # 今見ている値の連続する個数
for i in range(n):
    if s[i] == str(now): # 今見ているもの同じ場合
        cnt += 1
    else:
        nums.append(cnt)
        now ^= 1
        cnt = 1
# if cnt != 0:
nums.append(cnt)
# print(nums) # 消し忘れ（でもTLEすることは分かった）
# 配列の大きさが奇数でないなら，0を追加
if len(nums) % 2 == 0:
    nums.append(0)

res = 0
for i in range(0, len(nums), 2): # 1のところを見ていく
    # if 2 * k + 1 + i > len(nums):
    #     break
    # tmp = sum(nums[i : 2 * k + 1 + i])
    left, right = i, min(i + 2 * k + 1, len(nums))
    tmp = sum(nums[left:right])
    res = max(res, tmp)
print(res)

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

nums = []
now = 1 # 今見ている数
cnt = 0 # nowが並んでいる個数
for i in range(n):
    if s[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt) # 切り替わりで追加
        now = 1 - now # 0と1を切り替える
        cnt = 1 # 新しいものをカウントし始める
# 最後
if cnt != 0:
    nums.append(cnt)

# 調整
if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * k + 1

# 累積和を作る
acc = [0] * (len(nums) + 1)
for i in range(len(nums)):
    acc[i + 1] = acc[i] + nums[i]

res = 0
# 偶数番目だけ見る
for i in range(0, len(nums), 2):
    # [left, right)
    left = i
    right = min(i + add, len(nums))
    tmp = acc[right] - acc[left]
    res = max(res, tmp)

print(res)
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(5):
    a.append(int(input()))

b = []
for i in range(5):
    b.append(a[i]%10)
  
def kiriage(n):
    if n%10==0:
        return n
    else:
        amari = n%10
        n = n - amari
        return n+10

#non-zero かつ minimum
mini_amari = 9
idx = 9
for i in range(len(b)):
    if b[i]<mini_amari and b[i]!=0:
        mini_amari = b[i]
        idx = i

res = 0
for i in range(len(a)):
    if i != idx:
        res += kiriage(a[i])
res += a[idx]
print(res)

Fixed submission:
#cited by maspy
A = [int(input()) for _ in range(5)]
 
ceiled = [(x+9)//10*10 for x in A]
can_save = [y - x for x,y in zip(A,ceiled)]

answer = sum(ceiled) - max(can_save)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
for i in range(q):
    l,r=map(int,input().split())
    sub = s[l-1:r]
    print(sub.count('AC'))

Fixed submission:
n,q=map(int,input().split())
s=input()
t=[0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)
for i in range(q):
    l,r=map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
  a = list(map(int,input().split()))
  res=0
  for j in range(m):
    res += a[i]*b[i]
  if res+c>0: cnt+=1
print(cnt)

Fixed submission:
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    res=0
    a = list(map(int,input().split()))
    for j in range(m):
        res += a[j]*b[j]
    if res+c>0: cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n,m,c = map(int,input())
b = list(map(int,input()))
cnt = 0
for i in range(n):
  a = list(map(int,input()))
  res=0
  for j in range(m):
    res += a[i]*b[i]+c
  if res>0: cnt+=1
print(cnt)

Fixed submission:
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
cnt = 0
for i in range(n):
    res=0
    a = list(map(int,input().split()))
    for j in range(m):
        res += a[j]*b[j]
    if res+c>0: cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

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

def rec(i):
    if dp[i] < float('inf'): return dp[i]
    
    if i == 0: return 0

    res = float('inf')
    res = chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = chmin(res, rec(i - 2) + abs(h[i] - h[i - 2]))
    dp[i] = res
    return dp[i]

dp = [float('inf')] * n
print(rec(n - 1))

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

INF = 1 << 40
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(1, n - 1):
	dp[i + 1] = min(dp[i-1] + abs(h[i+1] - h[i-1]), dp[i] + abs(h[i+1] - h[i]))

print(dp[-1])

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

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

def rec(i):
    if dp[i] < INF:
        return dp[i]
    
    if i == 0:
        return 0

    res = INF
    res = chmin(res, rec(i - 1) + abs(h[i] - h[i - 1]))
    if i > 1:
        res = chmin(res, rec(i - 2) + abs(h[2] - h[i - 2]))
    dp[i] = res
    return dp[i]

INF = float('inf')
dp = [INF] * n
print(rec(n - 1))

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

INF = 1 << 40
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(1, n - 1):
	dp[i + 1] = min(dp[i-1] + abs(h[i+1] - h[i-1]), dp[i] + abs(h[i+1] - h[i]))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n, h, w = map(int, input().split())
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if a >= h and b >= w:
        ans += 1
print(ans

Fixed submission:
n, h, w = map(int, input().split())
ans = 0
for i in range(n):
    a, b = map(int, input().split())
    if a >= h and b >= w:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, p = map(int, input().split())

g = 1
res = 1
while g ** n <= p:
	if p % (g ** n) == 0:
		res = g
	g += 1

print(res)

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

def prime_factor(n):
	d = {}
	for i in range(2, int(n ** 0.5) + 1):
		while (n % i == 0):
			d[i] = d.get(i, 0) + 1
			n //= i
	if n != 1:
		d[n] = d.get(n, 0) + 1
	return d

if n == 1:
	print(p)
	exit()

res = 1
fac = prime_factor(p)
for p, c in fac.items():
	res *= p ** (c // n)
print(res)
Buggy python submission (verdict: Runtime Error):
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print ans

Fixed submission:
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3]), 753))
print ans

Fixed submission:
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(S[i:i+3], 753))
print ans

Fixed submission:
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
ans = 99999
for i in range(len(S)-2):
  ans = min(ans, abs(S[i:i+3], 753)
            
print ans

Fixed submission:
S = input()
ans = 99999
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != s[j]:
        bl = False

print(lcm(n, m)) if bl else print('-1')

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != t[j]: # s[i] != s[j] にしてた...
        bl = False

print(lcm(n, m)) if bl else print('-1')

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

L = lcm(n, m)
target = [0] * L
for i in range(n):
    target[i * L // n] = s[i]
for i in range(m):
    if target[i * L // m] == 0 or target[i * L // m] == t[i]:
        target[i * L // m] = t[i]
    else:
        print('-1')
        exit()

print(L)

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != t[j]: # s[i] != s[j] にしてた...
        bl = False

print(lcm(n, m)) if bl else print('-1')