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

Fixed submission:
s,t=input(),input()
rs=[""for _ in range(26)]
rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  ss,tt=a(s[i]),a(t[i])
  if rs[ss]=="":rs[ss]=t[i]
  elif rs[ss]!=t[i]:print("No");exit()
  if rt[tt]=="":rt[tt]=s[i]
  elif rt[tt]!=s[i]:print("No");exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s,t=input(),input()
rs=rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  if rs[a(s[i])]=="":rs[a(s[i])]=t[i]
  elif rs[a(s[i])]!=t[i]:print("No");exit()
  if rt[a(t[i])]=="":rt[a(t[i])]=s[i]
  elif rt[a(t[i])]!=s[i]:print("No");exit()
rint("Yes")

Buggy submission (verdict: Runtime Error):
s,t=input(),input()
d={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
for i,j in s,t:
  if d[i]==0:d[i]=j
  elif d[i]!=j:print("No");exit()
  if d[j]==0:d[j]=i
  elif d[j]!=i:print("No");exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s,t=input(),input()
d={"a":0,"b":0,c"":0,"d":0,"e":0,"f":0,g"":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
for i,j in s,t:
  if d[i]==0:d[i]=j
  elif d[i]!=j:print("No");exit()
  if d[j]==0:d[j]=i
  elif d[j]!=i:print("No");exit()
print("Yes")
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=map(int,input().split());x3,y3=x2-(y2-y1),y2+(x2-x1);x4,y4=x3-(x2-x1),y3-(y2-y1);print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split());x3,y3,x4,y4=x2-(y2-y1),y2+(x2-x1),x3-(x2-x1),y3-(y2-y1);print(x3,y3,x4,y4)
Problem p03286 (python)

Fixed submission:
n=int(input())
if n==0:print(0);exit()
ans,i="",0
while n!=0:
  if (n-(-2)**i)%((-2)**(i+1))==0:ans="1"+ans;n-=(-2)**i
  else:ans="0"+ans
  i+=1
print(int(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
ans,i="",0
while n!=0:
  if (n-(-2)**i)%((-2)**(i+1))==0:ans="1"+ans;n-=(-2)**i
  else:ans="0"+ans
  i+=1
print(int(ans))
Problem p03315 (python)

Fixed submission:
print(4-input().count("-")*2)

Buggy submission (verdict: Runtime Error):
print(4-input().count()*2)
Problem p03767 (python)

Fixed submission:
n,a=int(input()),sorted(list(map(int,input().split())))[::-1];print(sum([a[i]*(i%2==1)for i in range(2*n)]))

Buggy submission (verdict: Runtime Error):
n,a=int(input()),sorted(list(map(int,input().split())))print(sum([a[i]*(i%3==1)for i in range(3*n)]))
Problem p03774 (python)

Fixed submission:
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-c)+abs(b-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(o[i],p[i],q[0],r[0])
  minn=1
  for j in range(m-1):
    a=kyori(o[i],p[i],q[j+1],r[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-b)+abs(c-d)
for i in range(n):
  a,b=map(int,input().split())
  o.append(a)
  p.append(b)
for i in range(m):
  a,b=map(int,input().split())
  q.append(a)
  r.append(b)
for i in range(n):
  mind=kyori(a[i],b[i],c[0],d[0])
  minn=1
  for j in range(m-1):
    a=kyori(a[i],b[i],c[j+1],d[j+1])
    if a<mind:
      mind=a
      minn=j+2
  print(minn)
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice")
elif a==b:print("Draw")
else:print("Bob")

Buggy submission (verdict: Runtime Error):
:cross:

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice");else:print("Bob")
Problem p03805 (python)

Fixed submission:
z,m=map(int,input().split());a=[[],[]];ans=0
for i in range(m):aa,bb=map(int,input().split());a[0].append(aa);a[1].append(bb)
def d(n,nl,ml):
  if sorted(nl+[n])==[i+1for i in range(z)]:return 1
  if n in nl:return 0
  l=len(ml[0]);ans=0
  for i in range(l):
    c=[ml[0][:i]+ml[0][i+1:],ml[1][:i]+ml[1][i+1:]]
    if ml[0][i]==n:ans+=d(ml[1][i],nl+[n],c)
    if ml[1][i]==n:ans+=d(ml[0][i],nl+[n],c)
  return ans
for i in range(m):
  if a[0][i]==1:
    c=[a[0][:i]+a[0][i+1:],a[1][:i]+a[1][i+1:]]
    ans+=d(a[1][i],[1],c)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[n*[0]for _ in range(n)]
for i in range(m):
	a,b=map(int,input().split())
	a-=1
	b-=1
	edge[a][b]=edge[b][a]=1
from itertools import permutations
ans=0
for i in permutations([j for j in range(1,n)],n-1):
	f=True
	t=[0]+i
	for j in range(1,n):
		if edge[t[j-1]][t[j]]==0:f=False
	if f:ans+=1
print(ans)
Problem p03822 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
n=int(input())
a=[int(input())for _ in range(n-1)]
def dfs(v):
  d=[dfs(i)for i in t[v]]
  d.sort()
  l=len(d)
  ans=0
  for i,j in enumerate(d):
    ans=max(ans,l-i+j)
  return ans
t=[[]for _ in range(n+1)]
for i in range(n-1):
  t[a[i]-1].append(i+1)
print(dfs(0))

Buggy submission (verdict: Runtime Error):
n=int(input())
edge=[[]for _ in range(n)]
for i in range(n-1):edge[int(input())-1].append(i+1)
def dfs(v):
  d=[-1]+sorted([dfs(i)for i in edge[v]])
  l=len(d)
  return max(l-i+j for i,j in enumerate(d))
print(dfs(0))
Problem p03986 (python)

Fixed submission:
x=input();a,l=0,len(x)
for i in range(l):
  if x[l-i-1]=="T":a+=1
  else:a=max(0,a-1)
print(a*2)

Buggy submission (verdict: Runtime Error):
x=input();a=0
for i in range(len(x)):
  if x[l-i-1]=="T":a+=1
  else:a=max(0,a-1)
print(a*2)
Problem p04005 (python)

Fixed submission:
a=list(map(int,input().split()));a.sort();s=a[0]*a[1]
if (a[2]*s)%2==0:print(0)
else:print(s)

Buggy submission (verdict: Runtime Error):
a=list(int,input().split());a.sort();s=a[0]*a[1]
if (a[2]*s)%2==0:print(0)
else:print(s)
Problem p03617 (python)

Fixed submission:
q,h,s,d=map(int,input().split())

h=min(h,q+q)
s=min(s,h+h)
d=min(d,s+s)

n=int(input())

print(n//2*d+n%2*s)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split())
fx=1
fy=1
if x1>x2:
	x1,x2=x2,x1
	fx=-1
if y1>y2:
	y1,y2=y2,y1
	fy=-1

n=int(input())
p=[]
for i in range(n):
	x,y=map(int,input().split())
	if x1<=x<=x2 and y1<=y<=y2:
		p.append((fx*x,fy*y))
p=[y for x,y in sorted(p)]

from bisect import bisect_left as bl

b=[]

for y in p:
	pos=bl(b,y)
	if len(b)<=pos:
		b.append(y)
	else:
		b[pos]=y
	
from math import pi

l=len(b)

if l==min(x2-x1,y2-y1)+1:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*(l-1)+(10*pi-20))
else:
	print(100*(x2-x1+y2-y1)+(5*pi-20)*l);
Problem p02623 (python)

Fixed submission:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na,nb = [0],[0]
for i in range(n):
  na.append(na[i]+a[i])
for j in range(m):
  nb.append(nb[j]+b[j])
ans = 0
l = m
for i in range(n+1):
  if na[i] > k:
    break
  while nb[l] > k - na[i]:
    l -= 1
  ans = max(ans,i+l)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na = []
c = 0
for booka in a:
  c += booka
  na.append(c)
nb = []
d = 0
for bookb in b:
  d += bookb
  nb.append(d)
maxa = 0
for i in range(n):
  for j in range(maxa-i,m):
    if na[i] + nb[j] <= k:
      maxa = max(maxa,i+j+2)
print(maxa)
Problem p02659 (python)

Fixed submission:
a,b = input().split()
na = int(a)
nb100 = (int(b[0])*100+int(b[2:]))
ans = na*nb100
print(ans//100)

Buggy submission (verdict: Runtime Error):
import decimal
a,b = map(decimal,input().split())
print(int(a*b))

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

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [list(map(int,input().split())) for nesya in range(m)]
k = [1]*n
for route in x:
  h1 = route[0]-1
  h2 = route[1]-1
  if h[h1] < h[h2]:
    k[h1] = 0
  elif h[h1] > h[h2]:
    k[h2] = 0
  else:
    k[h1] = 0
    k[h2] = 0
print(sum(k))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h = list(map(int,input().split()))
x = [list(map(int,input().split())) for nesya in range(m)]
k = [1]*n
for route in x:
  h1 = route[0]-1
  h2 = route[1]-1
  if h[h1] < h[h2]:
    k[h1] = 0
  elif h[h1] > h[h2]
    k[h2] = 0
print(sum(k))
Problem p02711 (python)

Fixed submission:
a = int(input())
b = a//100
c = a//10 - b*10
d = a%10
if b != 7 and c != 7 and d != 7:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
a = int(input())
b = a//100
c = a//10 - b*10
d = a%10
if b != 7 and c != 7 and d != 7:
  print(No)
else:
  print(Yes)
Problem p02771 (python)

Fixed submission:
a,b,c = map(int, input().split())
if a==b==c:
  print('No')
elif a==b or b==c or a==c:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input())
if a==b==c:
  print('No')
elif a==b or b==c or a==c:
  print('Yes')
else:
  print('No')
Problem p02832 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
h = 0
for i in range(0,n):
  if a[i] != i-h+1:
    h += 1
if h == n:
  print(-1)
else:
  print(h)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int,input().split()))
c = -1
k = 0
for i in range(1,n+1):
  if not i in a_list:
    k = i
    break
  a_list = a_list[c+1:]
  c = a_list.index(i)
if k == 1:
  print(-1)  
elif k > 0:
  print(n-k+1)
else:
  print(0)
Problem p02915 (python)

Fixed submission:
a = int(input())
print(a**3)

Buggy submission (verdict: Runtime Error):
a = int(inpput())
print(a**3)
Problem p02951 (python)

Fixed submission:
a,b,c = map(int, input().split())
d = b+c-a
if d<=0:
  print(0)
else:
  print(d)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int, input().split)
d = b+c-a
if d<=0:
  print(0)
else:
  print(d)
Problem p02954 (python)

Fixed submission:
s = input()
sa = s.replace('LR','L,R')
sb = sa.split(',')
ans = ''
for hoge in sb:
  poge = len(hoge)
  g = hoge.find('RL')
  if poge%2 == 0:
    r = poge//2
    l = poge//2
  else:
    if g%2 == 1:
      r = poge//2
      l = r + 1
    else:
      l = poge//2
      r = l + 1
  an = '0 '*(g)+str(r)+' '+str(l)+' 0'*(poge-g-2)+ ' '
  ans += an
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
sa = s.replace('LR','L,R')
sb = sa.split(',')
ans = ''
for hoge in sb:
  poge = len(sb)
  g = hoge.find('RL')
  if poge%2 == 0:
    r = poge//2
    l = poge//2
  else:
    if g%2 == 0:
      r = poge//2
      l = r + 1
    else:
      l = poge//2
      r = l + 1
  an = '0 '*(g-1)+str(r)+' '+str(l)+' 0'*(poge-g-1)+ ' '
  ans += an
print(ans)
Problem p02987 (python)

Fixed submission:
s = input()
a = ''.join(sorted(s))
if a[0] == a[1] and a[2] == a[3] and a[0] != a[3]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()
a = ''.join(sorted(s))
if a[1] == a[2] and a[3] == a[4] and a[1] != a[3]:
  print('Yes')
else:
  print('No')
Problem p02989 (python)

Fixed submission:
n = int(input())
d_list = list(map(int,input().split()))
d = sorted(d_list)
g = n//2
f = d[g-1]
j = d[g]
print(j-f)

Buggy submission (verdict: Runtime Error):
n = int(input())
d_list = list(map(int,input().split()))
d = sorted(d_list)
g = n//2
f = d[g]
j = d[g+1]
print(j-f)
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
a = [int(input()) for nesya in range(m)]
hoge = [1]*(n+1)
for i in range(m):
  hoge[a[i]] = 0
for j in range(1,n+1):
  if hoge[j] == 0:
    continue
  else:
    if j == 1:
      hoge[j] = hoge[j-1]
    else:
      hoge[j] = hoge[j-1] + hoge[j-2]
  hoge[j] = hoge[j] % (10**9+7)
print(hoge[j]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for nesya in range(m)]
hoge = [1]*(n+1)
for i in range(m):
  hoge[a[i]] = 0
for j in range(2,n+1):
  if hoge[j] == 0:
    continue
  else:
    hoge[j] = hoge[j-1] + hoge[j-2]
  hoge[j] = hoge[j] % (10**9+7)
print(hoge[j]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a_list = [int(input()) 
          for nesya in range(m)]
hoge = [1]*(n+1)
for i in range(m):
  hoge[a_list[i]] = 0
for j in range(2,n+1):
  if hoge[j] == 0:
    continue
  else:
    hoge[j] = hoge[j-1] + hoge[j-2]
print(hoge[j]%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a_list = [int(input()) 
          for nesya in range(m)]
hoge = [1]*(n+1)
for i in range(m):
  hoge[a_list[i]] = 0
for j in range(2,n+1):
  if hoge[j] == 0:
    continue
  else:
    hoge[j] = hoge[j-1] + hoge[j-2]
  hoge[j] = hoge[j] % (10**9+7)
print(hoge[j])

Buggy submission (verdict: Runtime Error):
import math

def fib(n):
    return round((((1+5**0.5)/2)**n-((1-5**0.5)/2)**n)/5**0.5)

n,m = map(int,input().split())
a_list = [int(input()) 
          for nesya in range(m)]
a_list.append(n+1)
ans = 1
mae = -1
for a in a_list:
  k = a-mae-1
  mae = a
  ans = (ans*int(fib(k)))%(10**9+7)
print(ans)
Problem p03723 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b == c:
  if a%2 == b%2 == c%2 == 0:
    print(-1)
  else:
    print(0)
else:
  t = 0
  while t > -1:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
      break
    (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)
    t += 1
  print(t)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a == b == c:
  if a%2 == b%2 == c%2 == 0:
    print(-1)
  else:
    print(0)
t = 0
else:
  while t > -1:
    if a%2 == 1 or b%2 == 1 or c%2 == 1:
      break
    (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)
    t += 1
  print(t)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a == b == c:
  if a%2 == b%2 == c%2 == 0:
    prnit(-1)
  else:
    print(0)
t = 0
while t > -1:
  if a%2 == 1 or b%2 == 1 or c%2 == 1:
    break
  (a,b,c) = ((b+c)//2,(a+c)//2,(a+b)//2)
  t += 1
print(t)
Problem p03775 (python)

Fixed submission:
import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k+2,0,-1):
  if n%i == 0:
    a = n//i
    break
s = len(str(a))
print(s)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k+2,1,-1):
  if n%i == 0:
    a = n//i
    break
s = len(str(a))
print(s)

Buggy submission (verdict: Runtime Error):
import math

def is_prime(n):
  if n == 1: return False
  for k in range(2, int(math.sqrt(n)) + 1):
    if n % k == 0:
      return False
  return True

n = int(input())
if is_prime(n):
  print(int(math.log(a,10))+1)
k = int(math.sqrt(n))
for i in range(k,n+1):
  if n%i == 0:
    a = i
    break
s = int(math.log(a,10))+1
print(s)
Problem p02984 (python)

Fixed submission:
from sys import stdin

def main():
    input = stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        if i % 2 == 0:
            ans[0] += a[i]
        else:
            ans[0] -= a[i]
    for i in range(1, n):
        ans[i] = 2 * a[i - 1] - ans[i - 1]
    print(' '.join(map(str, ans)))
main()

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

def main():
    import numpy as np
    from scipy import linalg
    input = stdin.readline

    n = int(input())
    a = [[] for _ in range(n)]
    for i in range(n - 1):
        a[i] = [0] * i + [1, 1] + [0] * (n - i - 2)
    a[n - 1] = [1] + [0] * (n - 2) + [1]
    A = np.array(a)
    b = np.array(list(map(int, input().split())))
    LU = linalg.lu_factor(A)
    x = linalg.lu_solve(LU, b) * 2
    print(' '.join(map(str, map(int, x))))
main()
Problem p03053 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
cm = [[0 for j in range(w + 2)] for i in range(h + 2)]
que = deque([])
for i in range(1, h + 1):
    s = input()
    for j in range(1, w + 1):
        if s[j - 1] == ".":
            cm[i][j] = -1
        else:
            que.append(i)
            que.append(j)
ans = 0
while len(que) > 0:
    y = que.popleft()
    x = que.popleft()
    ans = cm[y][x] + 1
    if cm[y + 1][x] == -1:
        cm[y + 1][x] = ans
        que.append(y + 1)
        que.append(x)
    if cm[y - 1][x] == -1:
        cm[y - 1][x] = ans
        que.append(y - 1)
        que.append(x)
    if cm[y][x + 1] == -1:
        cm[y][x + 1] = ans
        que.append(y)
        que.append(x + 1)
    if cm[y][x - 1] == -1:
        cm[y][x - 1] = ans
        que.append(y)
        que.append(x - 1)
print(ans - 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.ndimage.interpolation import shift
h, w = map(int, input().split())
a = np.array([[c == "#" for c in input()] for _ in range(h)], dtype=bool)
cnt = 0
while a.all() == False:
    a = a + shift(a, [0, -1], order=1, cval=False) \
        + shift(a, [0, 1], order=1, cval=False) \
        + shift(a, [1, 0], order=1, cval=False) \
        + shift(a, [-1, 0], order=1, cval=False)
    cnt += 1
print(cnt)
Problem p02580 (python)

Fixed submission:
H, W, M = map(int, input().split())
row = [0] * (H + 1)
col = [0] * (W + 1)

bom = []
for i in range(M):
    h, w = map(int, input().split())
    bom.append([h, w])
    row[h] += 1
    col[w] += 1
 
rmax = max(row)
cmax = max(col)
cnt = row.count(rmax) * col.count(cmax)

for h, w in bom:
    if rmax == row[h] and cmax == col[w]:
        cnt -= 1

print(rmax + cmax - (cnt == 0))

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
m = [[False] * W for _ in range(H)]
dh = dict()
dw = dict()
for _ in range(M):
    h_, w_ = map(int, input().split())
    m[h_ - 1][w_ - 1] = True
    
    if h_ in dh:
        dh[h_] += 1
    else:
        dh[h_] = 1
        
    if w_ in dw:
        dw[w_] += 1
    else:
        dw[w_] = 1

dhl = list(dh.items())
dhl.sort(key=lambda x: x[1], reverse=True)
dwl = list(dw.items())
dwl.sort(key=lambda x: x[1], reverse=True)

h, w = [], []
maxh = dhl[0][1]
maxw = dwl[0][1]

for i, n in dhl:
    if n == maxh:
        h.append(i)
for i, n in dwl:
    if n == maxw:
        w.append(i)

res = maxh + maxw - 1
for hh in h:
    for ww in w:
        if m[hh - 1][ww - 1] is False:
            res = maxh + maxw
            break

print(res)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
d1 = dict()
d2 = dict()
G = [[False] * (W + 1) for _ in range(H + 1)]
for i in range(M):
    h, w = map(int, input().split())
    if h not in d1:
        d1[h] = 0
    if w not in d2:
        d2[w] = 0
    d1[h] += 1
    d2[w] += 1
    G[h][w] = True

d1 = list(d1.items())
d2 = list(d2.items())

d1.sort(reverse=True, key=lambda x: x[1])
d2.sort(reverse=True, key=lambda x: x[1])

print(d1[0][1] + d2[0][1] - int(G[d1[0][0]][d2[0][0]]))
Problem p02831 (python)

Fixed submission:
import fractions as f

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

print(A * B // f.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

print(A * B // math.gcd(A, B))
Problem p02891 (python)

Fixed submission:
S = list(input())
K = int(input())
S.extend(S)

prev = ''
cnt = 0
for s in S:
    if s == prev:
        cnt += 1
        prev = ''
    else:
        prev = s

b = 0
if K % 2 == 0:
    b += 1
if K > 2 and S[0] == S[-1]:
    mae = 1
    while mae < len(S) and S[mae] == S[0]:
        mae += 1
    if mae % 2 == 1 and mae != len(S):
        usiro = 1
        i = len(S) - 2
        while S[i] == S[-1]:
            usiro += 1
            i -= 1
        if usiro % 2 == 1:
            b = K // 2

if K % 2 == 0:
    res = cnt * (K // 2) + (b - 1)
else:
    res = cnt * (K // 2) + cnt // 2 + b
print(res)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
S.extend(S)

prev = ''
cnt = 0
for s in S:
    if s == prev:
        cnt += 1
        prev = ''
    else:
        prev = s

b = 0
if K > 2 and S[0] == S[-1]:
    mae = 1
    while S[mae] == S[0]:
        mae += 1
    if mae % 2 == 1 and mae != len(S):
        usiro = 1
        i = len(S) - 2
        while S[i] == S[-1]:
            usiro += 1
            i -= 1
        if usiro % 2 == 1:
            b = K // 2

if K % 2 == 0:
    res = cnt * (K // 2) + (b - 1)
else:
    res = cnt * (K // 2) + cnt // 2 + b
print(res)
Problem p03127 (python)

Fixed submission:
import fractions as f

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

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

res = A[N - 1]
print(res)

Buggy submission (verdict: Runtime Error):
import math

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

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

res = A[N - 1]
print(res)

Buggy submission (verdict: Runtime Error):
import math

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

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

print(A[N - 1])

Buggy submission (verdict: Runtime Error):
import math

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

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

print(A[N - 1])
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
G = [[] for _ in range(N)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = [[] for _ in range(M)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

G = list(map(sorted, G))
for p in range(N):
    for m, (y, i) in enumerate(G[p], 1):
        res[i] = 10 ** 12 + (p + 1) * 10 ** 6 + m

for r in res:
    print(str(r)[1:])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
G = [[] for _ in range(M)]
res = [""] * M
for i in range(M):
    p, y = map(int, input().split())
    G[p - 1].append((y, i))

for i, g in enumerate(G):
    l = len(str(i + 1))
    g.sort()
    for j, gg in enumerate(g):
        ll = len(str(j + 1))
        res[gg[1]] = "0" * (6 - l) + str(i + 1) + "0" * (6 - ll) + str(j + 1)

print("\n".join(res))
Problem p03805 (python)

Fixed submission:
import itertools as it

N, M = map(int, input().split())
ab = tuple(set(map(int, input().split())) for _ in range(M))

P = it.permutations(range(1, N + 1), N)

res = 0
for p in P:
    if p[0] == 1:
        for i in range(N - 1):
            if not(set({p[i], p[i + 1]}) in ab):
                break
        else:
            res += 1

print(res)

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

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

res = 0
for P in permutations(range(N), N):
    if P[0] != 0:
        continue
    for i in range(N - 1):
        if P[i + 1] not in G[P[i]]:
            break
    else:
        res += 1

print(res)

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

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

res = 0
for P in permutations(range(N), N):
    if P[0] != 0:
        continue
    for i in range(N - 1):
        if P[i + 1] not in G[P[i]]:
            break
    else:
        res += 1

print(res)
Problem p03775 (python)

Fixed submission:
import math
n = int(input())
if n < 10:
    print(1)
else:
    a = 0
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            a = i
    b = n//a
    j = 1
    while True:
        m = b / (10**j)
        if m>=1 and m<10:
            ans = j+1
            break
        j+=1

    print(ans)

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

for a in range(1, int(math.sqrt(n))):
    if n%a == 0:
        b = n//a
        ans = len(str(b))
print(ans)