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

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if h[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,h[i])
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if a[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,a[i])
print(ans)
Problem p02981 (python)

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

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
l0=l%2019
r0=r%2019
if r-l>=2019 or l0==0 or r0==0:
    print(0)
elif l-l%2019+2019<=r:
    print(0)
else:
    ans=2019
    for i in range(l0,r0):
        for j in range(i+1,r0+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
            if ans==1:
                break
        if ans==1:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
l,r=map(int,input().split())
l0=l%2019
r0=r%2019
if r-l>=2019 or l0==0 or r0==0:
    print(0)
elif l-l%2019+2019<=r:
    print(0)
else:
    ans=2019
    for i in range(l0,r0):
        for j in range(i+1,r0+1):
            if (i*j)%2019<ans:
                ans=(i*j)%2019
            if ans==1:
                break
        if ans==1:
            break
    print(ans)
Problem p02996 (python)

Fixed submission:
n=int(input())
task=[]
for i in range(n):
    a,b=map(int,input().split())
    task.append([b,a])
task.sort()
t=0
ans="Yes"
for i in range(n):
    t+=task[i][1]
    if t>task[i][0]:
        ans="No"
        break
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()
Problem p03231 (python)

Fixed submission:
import fractions
def main():
    n,m=map(int,input().split())
    s=input()
    t=input()
    ans=-1
    gcd0=fractions.gcd(n,m)
    lcm=n*m//gcd0
    flg=1
    for i in range(gcd0):
        if s[n*i//gcd0]!=t[m*i//gcd0]:
            flg=0
            break
    if flg==1:
        ans=lcm
    print(ans)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
def main():
    n,m=map(int,input().split())
    s=input()
    t=input()
    ans=-1
    gcd0=fractions.gcd(n,m)
    lcm=n*m//gcd0
    flg=1
    for i in range(gcd0):
        if s[n*i//gcd0]!=t[m*i//gcd0]:
            flg=0
            break
    if flg==1:
        ans=lcm
	print(ans)
if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
def main():
    n,m=map(int,input().split())
    s=input()
    t=input()
    ans=-1
    gcd0=fractions.gcd(n,m)
    lcm=n*m//gcd0
    flg=1
    for i in range(gcd0):
        if s[n*i//gcd0]!=t[m*i//gcd0]:
            flg=0
            break
    if flg==1:
        ans=lcm
print(ans)
if __name__=="__main__":
    main()
Problem p03243 (python)

Fixed submission:
n=input()
if n[0]>n[1] or (n[0]==n[1] and n[1]>=n[2]):
    print(int(n[0])*111)
else:
    print(int(n[0])*111+111)

Buggy submission (verdict: Runtime Error):
n=input()
if n[0]>n[1] or (n[0]=n[1] and n[1]>=n[2]):
    print(int(n[0])*111)
else:
    print(int(n[0])*111+111)

Buggy submission (verdict: Runtime Error):
n=input()
if n[0]>n[1] or (n[0]=n[1] and n[1]>=n[2]):
    print(int(n[0])*111
else:
    print(int(n[0])*111+111)
Problem p03261 (python)

Fixed submission:
n=int(input())
w_before=input()
word=[w_before]
ans="Yes"
for i in range(1,n):
    w=input()
    if  w[0]!=w_before[-1] or w in word:
        ans="No"
        break
    else:
        w_before=w
        word.append(w)
print(ans)

Buggy submission (verdict: Runtime Error):
3
abc
arc
agc
Problem p03385 (python)

Fixed submission:
s=input()
if "a" in s and "b" in s and "c" in s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if a in s and b in s and c in s:
    print("Yes")
else:
    print("No")
Problem p03447 (python)

Fixed submission:
x,a,b=[int(input()) for i in range(3)]
ans=(x-a)%b
print(ans)

Buggy submission (verdict: Runtime Error):
x,a,b=[int(input) for i in range(3)]
ans=(x-a)%b
print(ans)
Problem p03523 (python)

Fixed submission:
s=input()
if s=="AKIHABARA":
    print("YES")
else:
    ans="YES"
    if len(s)>=9 or "KIH" not in s:
        ans="NO"
    else:
        t=s.replace("A","")
        if t!="KIHBR":
            ans="NO"
        else:
            k,b,r=s.find("K"),s.find("B"),s.find("R")
            if k>1 or b-k>4 or r-b>2:
                ans="NO"
    print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="AKIHABARA":
    print("YES")
else:
    ans="YES"
    if len(s)>9 or (len(s)==9 and s!="AKIHABARA") or "KIH" not in s:
        ans="NO"
    else:
        s.remove("A")
        if s!="KIHBR":
            ans="NO"
        else:
            k,b,r=s.find("K"),s.find("B"),s.find("R")
            if k>1 or b-k>4 or r-b>2:
                ans="NO"
    print(ans)
Problem p03555 (python)

Fixed submission:
c1=input()
c2=input()
c2_rev=c2[::-1]
if c1==c2_rev:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
c1=input()
c2=input()
c2.reverse()
if c1==c2:
    print("YES")
else:
    print("No")
Problem p03577 (python)

Fixed submission:
s=input()
s_len=len(s)
print(s[:s_len-8])

Buggy submission (verdict: Runtime Error):
s=input()
s_len=len(s)
print([:s_len-8])
Problem p03587 (python)

Fixed submission:
s=input()
ans=0
for i in range(6):
    if s[i]=="1":
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
ans=0
for i in range(n):
    if s[i]=="1":
        ans+=1
print(ans)
Problem p03611 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[-1,0]
i=0
while i<=n-1:
    res=0
    cnt=0
    while i+res<=n-1 and a[i+res]-a[i]<=2:
        if a[i+res]==a[i]:
            cnt+=1
        res+=1
    if res>ans[1]:
        ans[1]=res
        ans[0]=i
    i+=cnt
print(ans[1])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[-1,0]
i=0
while i<n-1:
    res=0
    while a[i+res]-a[i]<=2:
        res+=1
    if res>ans[1]:
        ans[1]=res
        ans[0]=i
    i+=res
print(ans[1])
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
a_x=abs(a-x)
b_x=abs(b-x)
if a_x<b_x:
    print("A")
else:
    print("B")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
a_x=abs(a,x)
b_x=abs(b,x)
if a_x<b_x:
    print("A")
else:
    print("B")
Problem p03695 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
check=[0]*8
while i<n and a[i]<3200:
    a_i=a[i]
    for j in range(8):
        if check[j]==0 and a_i>=400*j and a_i<400*(j+1):
            check[j]=1
            break
    i+=1
if sum(check)==0:
    ans_min=1
    ans_max=n
else:
    ans_min=sum(check)
    ans_max=ans_min+n-i
print(ans_min,ans_max)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
check=[0]*8
while i<n and a[i]<3200:
    a_i=a[i]
    for j in range(8):
        if check[j]==0 and a_i>=400*j and a_i<400*(j+1):
            check[j]=1
            break
    i+=1
if sum(check)==0:
    ans_min=1
    ans_max_=n
else:
    ans_min=sum(check)
    ans_max=ans_min+n-i
print(ans_min,ans_max)
Problem p03795 (python)

Fixed submission:
n=int(input())
print(n*800-(n//15)*200)

Buggy submission (verdict: Runtime Error):
n=int(input())
print(x*800-(x//15)*200)
Problem p02760 (python)

Fixed submission:
row1 = input().split()
row2 = input().split()
row3 = input().split()

n = int(input())
nums = [input() for i in range(n)]

rows = [row1, row2, row3]

for i in range(0, 3):
    rows += [[row1[i], row2[i], row3[i]]]

rows += [[row1[0], row2[1], row3[2]]]
rows += [[row1[2], row2[1], row3[0]]]

for row in rows:
    j = 0
    for num in nums:
        if num in row:
            j += 1
        if j == 3:
            print('Yes')
            exit()

print('No')

Buggy submission (verdict: Runtime Error):
60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34
Problem p02761 (python)

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

ans = ['0']*n
judge = [0]*n

for i in range(m):
    a_list = q[i]
    rank = a_list[0] - 1
    num = str(a_list[1])

    if judge[rank] == 0:
        judge[rank] = 1
        ans[rank] = num
    else:
        if ans[rank] == num:
            continue
        else:
            print(-1)
            exit()


if ans[0] == '0' and judge[0] == 1 and n != 1:
    print(-1)
elif ans[0] == '0' and n != 1:
    ans[0] = '1'
    print(int(''.join(ans)))
else:
    print(int(''.join(ans)))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
q = [list(map(int, input().split())) for _ in range(m)]

ans = [0]*n
judge = [0]*n

for i in range(m):
    a_list = q[i]
    rank = a_list[0] - 1
    num = a_list[1]

    if judge[rank] == 0:
        judge[rank] = 1
    else:
        if ans[rank] == num:
            continue
        else:
            print(-1)
            exit()

    ans[rank] = num

for_p = ['0']*m
for i in range(m):
    if judge[i] == 1:
        for_p[i] = str(ans[i])

if for_p[0] == '0':
    print(-1)
else:
    print(int(''.join(for_p)))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
q = [list(map(int, input().split())) for _ in range(m)]

ans = [0]*n
judge = [0]*n

for i in range(m):
    a_list = q[i]
    rank = a_list[0] - 1
    num = a_list[1]

    if judge[rank] == 0:
        judge[rank] = 1
    else:
        if ans[rank] == num:
            continue
        else:
            print(-1)
            exit()

    ans[rank] = num

for_p = ['0']*m
for i in range(m):
    if judge[i] == 1:
        for_p[i] = str(ans[i])

if for_p[0] == '0':
    print(-1)
else:
    print(int(''.join(for_p)))
Problem p02783 (python)

Fixed submission:
import math

h, a = map(int, input().split())
print(math.ceil(h/a))

Buggy submission (verdict: Runtime Error):
import Math

h, a = map(int, input().split())
print(math.ceil(h/a))

Buggy submission (verdict: Runtime Error):
import Math

h, a = map(int, input().split())
print(math.ceil(h//a + 1))
Problem p03308 (python)

Fixed submission:
a = int(input())
b = [int(i) for i in input().split()]

max_num = max(b)
min_num = min(b)

print(max_num - min_num)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = [int(i) for i in input.split()]

max_num = max(b)
min_num = min(b)

print(max_num - min_num)
Problem p03471 (python)

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

i, j, k = -1, -1, -1

for a in range(n + 1):
    for b in range(n+1-a):
        sum = (10000*a) + (5000*b) + (1000 * (n-(a+b))) if n-(a+b) >= 0 else None
        if sum == y:
            i, j, k = a, b, n-(a+b)
            break


print(i, j, k)

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

noguchi = 1000
higuchi = 5000
yukichi = 10000

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - (i+j)
        yen = noguchi * i + higuchi * j + yukichi * k
        if yen == y:
            ans = f'{k} {j} {i}'
            break

print(ans)

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

noguchi = 1000
higuchi = 5000
yukichi = 10000

ans = '-1 -1 -1'
for i in range(n+1):
    for j in range(n+1-i):
        k = n - (i+j)
        yen = noguchi * i + higuchi * j + yukichi * k
        if yen == y:
            ans = f'{k} {j} {i}'
            break

print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())

for a in range(10**4):
    for b in range(10**4):
        if(a**5 + b**5 == x):
            print(a, -b)
            break
        elif(a**5 - b**5 == x):
            print(a, b)
            break
    else:
        continue
    break

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

for a in range(1, 10**9):
    if (x%(a-b) != 0):
        continue
    
    tmp = a**5 - x
    if (tmp <= 0):
        tmp *= -1
        
    b = tmp**(1/5)
    if(b == int(b)):
        print(a, int(b))
        break
Problem p03826 (python)

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

print(max(a*b,c*d))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i]), b)
    
print(mp)
Problem p03829 (python)

Fixed submission:
n,a,b = map(int, input().split())
x = [int(_) for _ in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i]), b)
    
print(mp)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int, input().split())
x = [int(x) for x in input().split(' ')]

mp = 0
for i in range(n-1):
    mp += min(a*(x[i+1]-x[i], b))
    
print(mp)
Problem p03999 (python)

Fixed submission:
s = input()
l = len(s)

patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)

Buggy submission (verdict: Runtime Error):


patterns = []
for i in range(2**(l-1)):
    pattern = [''] * (l-1)
    for j in range(l-1):
        if (i >> j & 1):
            pattern[j] = '+'
    patterns.append(pattern)

ans = 0
for pattern in patterns:
    a = s[0]
    for i in range(l-1):
        if (pattern[i] == ''):
            a += s[i+1]
        else:
            ans += int(a)
            a = s[i+1]
    else:
        ans += int(a)

print(ans)
Problem p04029 (python)

Fixed submission:
x = int(input())
 
print(int((x+1)*x/2))

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

print (n+1)*n/2
Problem p02702 (python)

Fixed submission:
s = list(map(int, list(input())))
n = len(s)

countdic = {}
mod = 2019

num = 0
d = 1
for i in range(1,n+1):
    num += s[n-i]*d
    num %= mod
    if num in countdic:
        countdic[num] += 1
    if num not in countdic:
        countdic[num] = 1
    d = (10*d)%mod

ans = 0
for key in countdic:
    ans += countdic[key]*(countdic[key]-1)//2

if 0 in countdic:
    ans += countdic[0]

print(ans)

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

countdic = {}
mod = 2019

for i in range(1,n+1):
    num = s[n-i:n]
    remainder = num%mod
    if remainder in countdic:
        countdic[remainder] += 1
    if remainder not in countdic:
        countdic[remainder] = 1

ans = 0
for key in countdic:
    ans += countdic[key]*(countdic[key]-1)//2

if 0 in countdic:
    ans += countdic[0]

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 22:28:26 2020

@author: Kanaru Sato
"""

s = input()
n = len(s)
dic = {}
mod = 2019
count = 0

for i in range(1,n+1):
    num = int(s[n-i:n])
    num %= mod
    if num in dic:
        dic[num] += 1
    if num not in dic:
        dic[num] = 1

ans = 0
for fact in dic:
    if fact != 0:
        ans += dic[fact]*(dic[fact]-1)/2

print(int(ans)+dic[0])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 22:28:26 2020

@author: Kanaru Sato
"""

s = input()
n = len(s)
s = list(s)
dic = {}
mod = 2019
count = 0

for i in range(1,n+1):
    num = int(s[n-i:n])
    num %= mod
    if num in dic:
        count += 1
    if num not in dic:
        dic[num] = 1

if 0 in dic:
    count += 1

print(count)
Problem p02760 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

A = []
[A.append(list(map(int, input().split()))) for i in range(0,3)]

N = int(input())

b = []
[b.append(int(input())) for i in range(0,N)]

flag = [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]

for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b:
            flag[i][j] = 1

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]


if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 22:38:51 2020

@author: Kanaru Sato
"""

A = []
[A.append(list(map(int, input().split()))) for i in range(0,3)]

N = int(input())

b = []
[b.append(list(map(int, input()))) for i in range(0,N)]

flag = [[0, 0, 0]
        [0, 0, 0]
        [0, 0, 0]]

for i in range(0,3):
    for j in range(0,3):
        if A[i][j] in b:
            flag[i][j] = 1

column = 0
raw = 0
naname = 0

for i in range(0,3):
    column += flag[i][0]*flag[i][1]*flag[i][2]
    raw += flag[0][i]*flag[1][i]*flag[2][i]
naname = flag[0][0]*flag[1][1]*flag[2][2]+flag[0][2]*flag[1][1]*flag[2][0]

if column>=1 or raw>=1 or naname>=1:
    print("Yes")
else:
    print("No")
Problem p02780 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

sum = 0
sumlist = [0]
for i in range(n):
    sum += p[i]
    sumlist.append(sum)


Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 04:56:52 2020

@author: Kanaru Sato
"""

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

sum = 0
sumlist = []
for i in range(n):
    sum += a[i]
    sumlist.append(sum)

Max = -100000
for i in range(n-k+1):
    e = sumlist[i+k-1]-sumlist[i]
    if Max < e:
        Max = e

print((Max+k)/2)
Problem p02801 (python)

Fixed submission:
al = [chr(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])

Buggy submission (verdict: Runtime Error):
al = [ord(i) for i in range(ord("a"), ord("a")+26)]

str = input()

print(al[al.index(str)+1])
Problem p02813 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 17 00:21:01 2020

@author: Kanaru Sato
"""

import itertools as it
n = int(input())

p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

L = list(it.permutations(range(1,n+1)))

a = L.index(p)
b = L.index(q)
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 03:09:14 2020

@author: Kanaru Sato
"""
import itertools as it

n = int(input())
l = []
for i in range(1,n+1):
    l.append(i)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

count = 0
for sequence in it.permutations(l,n):
    if list(sequence) == p:
        pnum = count
    elif list(sequence) ==q:
        qnum = count
    count += 1

print(abs(pnum-qnum))
Problem p02923 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 10:13:10 2020

@author: Kanaru Sato
"""

N = int(input())
H = list(map(int, input().split()))
ans = 0
count = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        count += 1
        ans = max(ans,count)
    else:
        count = 0

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 10:13:10 2020

@author: Kanaru Sato
"""

N = int(input())
H = list(map(int, input().split()))
record = 0
count = 0

for i in range(0,N-1):
    if H[i] >= H[i+1]:
        count += 1
        ans = max(record,count)
    else:
        count = 0

print(ans)
Problem p02947 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 25 18:54:16 2020

@author: Kanaru Sato
"""

n = int(input())
Dict = {}
ans = 0

for i in range(n):
    s = list(input())
    s.sort()
    if s in Dict:
        ans += Dict[s]
        Dict[s] += 1
    else:
        Dict[s] = 1

print(ans)
Problem p02995 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fractions

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)//fractions.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(b-a+1-ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import fraction

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/fraction.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 00:52:33 2020

@author: Kanaru Sato
"""

import math

def divnum(x,y,n):
    if x%n == 0:
        return y//n - x//n + 1
    else:
        return y//n - x//n

a,b,c,d = list(map(int,input().split()))
cd = (c*d)/math.gcd(c,d)
ans = divnum(a,b,c) + divnum(a,b,d) - divnum(a,b,cd)
print(int(b-a+1-ans))
Problem p03160 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""
import sys
sys.setrecursionlimit(10 ** 6)

N = int(input())
h = list(map(int, input().split()))
memo = [-1]*N
memo[0] = 0
memo[1] = abs(h[1]-h[0])

#topdown
def cost(n):
    if n <= 1 or memo[n] >= 0:
        return memo[n]
    else:
        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))
        return memo[n]

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""

N = int(input())
h = list(map(int, input().split()))
memo = [-1]*N
memo[0] = 0
memo[1] = abs(h[1]-h[0])

#topdown
def cost(n):
    if n <= 1 or memo[n] >= 0:
        return memo[n]
    else:
        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))
        return memo[n]

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""

N = int(input())
h = list(map(int, input().split()))
memo = [0]*N

#topdown
def cost(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    elif memo[n]:
        return memo[n]
    else:
        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))
        return memo[n]

print(cost(N-1))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 00:21:08 2020

@author: Kanaru Sato
"""

n = int(input())
h = list(map(int, input().split()))
memo = [0]*n

#topdown
def cost(n):
    if n == 0:
        return 0
    elif n == 1:
        return abs(h[1]-h[0])
    elif memo[n]:
        return memo[n]
    else:
        memo[n] = min(cost(n-2)+abs(h[n]-h[n-2]),cost(n-1)+abs(h[n]-h[n-1]))
        return memo[n]

print(cost(n-1))