Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())

seq = [1]*a + [0]*b + [-1]*c

print(sum(seq[0:k]))

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

if k <= a:
    print(k*1)

elif k <= a+b:
    print(1*a)
    
else:
    num=k-(a+b)
    print(1*a-num*1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    b = a[i]
    ans[b] +=1
    
for i in range(1,n+1):
    print(ans_l[i])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    b = a[i]
    ans[b] +=1
for i in range(1,n+1):
    print(ans[i])

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

for i in range(1,n+1):
    ans = a.count(i)
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*(n+1)
for i in range(n-1):
    b = a[i]
    ans[b] +=1
for i in range(1,n+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c
    
from itertools import product

k = int(input())
ans=[]

i = range(1,k+1)
j = range(1,k+1)
k = range(1,k+1)

for a,b,c in product(i,j,k):
    p = gcd(a,b,c)
    ans.append(p)

print(sum(ans))

Fixed submission:
def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c

from functools import reduce

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            t = len(set([i,j,k]))
            
            if t == 1:
                ans += gcd(i,j,k)
                
            elif t == 2:
                ans += gcd(i,j,k)*3
            
            elif t == 3:
                ans += gcd(i,j,k)*6
    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c
    

k = int(input())
ans=[]

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            p = gcd(i,j,k)
            ans.append(p)

print(sum(ans))


Fixed submission:
def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c

from functools import reduce

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            t = len(set([i,j,k]))
            
            if t == 1:
                ans += gcd(i,j,k)
                
            elif t == 2:
                ans += gcd(i,j,k)*3
            
            elif t == 3:
                ans += gcd(i,j,k)*6
    

print(ans)
Buggy python submission (verdict: Runtime Error):
k,m = map(int,input().split())
a = input().split()
a =[int(s) for s in a]

a.insert(0,k)

dis = []

for i in range(m):
  part = int(a[i]) - int(a[i+1])
  dis.append(part)
  del part

dis.append(int(a[m-1]))
distance = dis*2

c =[]
for j in range(m):
  c = int(sum(distance[j:j+5]))

print(min(c))

Fixed submission:
#12
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])

b.append(int(k-a[n-1]+a[0]))

c = max(b)
b.remove(c)

print(sum(b))

Buggy python submission (verdict: Runtime Error):
k,m = map(int,input().split())
a = input().split()
a =[int(s) for s in a]

a.insert(0,k)

dis = []

for i in range(m):
  part = int(a[i]) - int(a[i+1])
  dis.append(part)
  del part

dis.append(int(a[m-1]))
distance = dis*2

c =[]
for j in range(m):
  c = sum(distance[j:j+5])

print(min(c))

Fixed submission:
#12
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])

b.append(int(k-a[n-1]+a[0]))

c = max(b)
b.remove(c)

print(sum(b))
Buggy python submission (verdict: Runtime Error):
#7
a = [[map(int,input().split())] for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
bingo = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1:
        bingo = 1
        
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        bingo = 1

if a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0]:
    bingo = 1

if bingo == True:
    print('Yes')

else:
    print('No')


Fixed submission:
#7
a = [list(map(int,input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = -1
bingo = 0

for i in range(3):
    if a[i][0] == a[i][1] == a[i][2] == -1:
        bingo = 1
        
for j in range(3):
    if a[0][j] == a[1][j] == a[2][j] == -1:
        bingo = 1

if a[0][0] == a[1][1] == a[2][2] == -1 or a[0][2] == a[1][1] == a[2][0]:
    bingo = 1

if bingo == 1:
    print('Yes')

else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#155 Poll
n = int(input())
words = {}
for i in range(n):
    name = input()
    if name not in words:
        words[name] = 1
    elif name in words:
        words[name] += 1
        
max_k_list = [kv[0] for kv in words.items() if kv[1] == max(words.values())]
max_k_list.sort()
print('\n'.join(max_k_list))

Fixed submission:
#155 Poll
n = int(input())
words = {}
for i in range(n):
    name = input()
    if name not in words:
        words[name] = 1
    elif name in words:
        words[name] += 1

num = max(words.values())
max_k_list = [kv[0] for kv in words.items() if kv[1] == num]
max_k_list.sort()
print('\n'.join(max_k_list))

Buggy python submission (verdict: Time Limit Exceeded):
#155 Poll
import collections
n = int(input())
ans = [input() for _ in range(n)]

c = collections.Counter(ans)
max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list.sort()
print('\n'.join(max_k_list))

Fixed submission:
#155 Poll
n = int(input())
words = {}
for i in range(n):
    name = input()
    if name not in words:
        words[name] = 1
    elif name in words:
        words[name] += 1

num = max(words.values())
max_k_list = [kv[0] for kv in words.items() if kv[1] == num]
max_k_list.sort()
print('\n'.join(max_k_list))

Buggy python submission (verdict: Time Limit Exceeded):
#155 Poll
import collections
n = int(input())
ans = []
for i in range(n):
    ans.append(input())

c = collections.Counter(ans)
max_k_list = [kv[0] for kv in c.items() if kv[1] == max(c.values())]
max_k_list.sort()
print('\n'.join(max_k_list))

Fixed submission:
#155 Poll
n = int(input())
words = {}
for i in range(n):
    name = input()
    if name not in words:
        words[name] = 1
    elif name in words:
        words[name] += 1

num = max(words.values())
max_k_list = [kv[0] for kv in words.items() if kv[1] == num]
max_k_list.sort()
print('\n'.join(max_k_list))
Buggy python submission (verdict: Runtime Error):
#154 Distinct or not
n = int(input())
a = list(map(int,input().split())
b = set(a)

if len(a) == b:
         print('YES')
else:
    print('NO')

Fixed submission:
#154 Distinct or not
n = int(input())
a = list(map(int,input().split()))
b = len(set(a))

if len(a) == b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
#152 Low Elements
n = int(input())
seq = list(map(int,input().split()))
num = 0
for i in range(1,n+1):
    test = seq[:i]
    if min(test) == seq[i-1]:
        num += 1
print(num)
    

Fixed submission:
#152 Low Elements
n = int(input())
seq = list(map(int,input().split()))
c = []
cnt = 0
for i in range(n):
    if i == 0:
        cnt+=1
        c.append(seq[0])
    else:
        if c[-1] >= seq[i]:
            cnt += 1
            c.append(seq[i])
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

ans=[]

if a>=b:
    for i in range(1,a//2+1):
        if a%i == 0 and b%i == 0:
            ans.append(i)
else:
    for i in range(1,b//2+1):
        if a%i == 0 and b%i == 0:
            ans.append(i)

print(ans[k-1])

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

ans=[]
m=min(a,b)

for i in range(1,m+1):
    if a%i == 0 and b%i == 0:
        ans.append(i)

ans.sort(reverse=True)
print(ans[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
#2
s = list(input())
flag = 1
cnt = 0
while flag :
    cant = 0
    for i in range(len(s)-1):
        if s[i] == 'B' and s[i+1] == 'W':
            s[i],s[i+1] = s[i+1],s[i]
            cnt += 1
        else:
            cant += 1
    if cant == len(s)-1:
        flag = 0
print(cnt)
        

Fixed submission:
s = input()
t = 0
ans = 0

for i in range(len(s)):
    if s[i] == 'W':
        ans += (i-t)
        t += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#2
s = list(input())
flag = 1
cnt = 0
while flag :
    cant = 0
    for i in range(len(s)-1):
        if s[i] == 'B' and s[i+1] == 'W':
            s[i],s[i+1] = s[i+1],s[i]
            cnt += 1
        else:
            cant += 1
    if cant == len(s)-1:
        flag = 0
print(cnt)

Fixed submission:
s = input()
t = 0
ans = 0

for i in range(len(s)):
    if s[i] == 'W':
        ans += (i-t)
        t += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,n=map(int,input().split())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=n%500

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=n%500

if amari=<a:
    print('Yes')

else:
    print('No')


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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')

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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')

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

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')

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

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#a,bの入力
a=int(input())
b=int(input())
#a,bの積を演算する
a_to_b_no_seki=a*b
#a,b,の積を2で割った余りを計算し、余りが0なら偶数と出力、1なら奇数と出力
if a_to_b_no_seki%2==0:
    print("Even")
else:
    print("Odd")


Fixed submission:
#a,bの入力
a,b=map(int,input().split())
#a,bの積を演算する
a_to_b_no_seki=a*b
#a,b,の積を2で割った余りを計算し、余りが0なら偶数と出力、1なら奇数と出力
if a_to_b_no_seki%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
n,y = map(int,input().split()) #n枚,y円
a = -1
b = -1
c = -1


for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and z >= 0 :
            a = i
            b = j
            c = k
print(a,b,c)
            

Fixed submission:
n,y = map(int,input().split()) #n枚,y円
a = -1
b = -1
c = -1
for i in range(n+1):
    for j in range(n+1):
        k = n-i-j
        if i*10000+j*5000+k*1000 == y and k >= 0 :
            a = i
            b = j
            c = k
            break

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

while True:
  if[i for i in a if i%2==1]:
    break
  a=[i/2 for i in a]
  ans+=1
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
while True:
    if [i for i in a if i % 2 == 1]:
        break
    a=[i/2 for i in a]
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
 s=input()

for bit in range(1 << 3):#
    ans=int(s[0])
    f=s[0]
    
    for j in range(3):
        if bit & (1 << j):
            ans+=int(s[j+1])
            f+='+'
            
        else:
            ans-=int(s[j+1])
            f+='-'
        
        f+=s[j+1]
    
    if ans == 7:
        print(f + "=7")
        exit()

Fixed submission:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        # フラグが立っていれば "+" 、なければ "-"
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + "=7")
        exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
num=[0]
ans=0
count=0
k=1
for i in range(n):
    a=int(input())
    num.append(a)
 
 for i in range(n+1):
    k=num[k]
    count+=1
    if k==2:
        ans=1
        break
if ans==1:
    print(count)
else:
    print("-1")
# coding: utf-8

Fixed submission:
n=int(input())
num=[0]
ans=0
count=0
k=1
for i in range(n):
    a=int(input())
    num.append(a)

for i in range(n+1):
    k=num[k]
    count+=1
    if k==2:
        ans=1
        break
if ans==1:
    print(count)
else:
    print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())

ans = 0

for x in range(s+1):
    for y in range(s+1):
        z = s - x - y
        if  k >= x and k >= y and k >= z >=0:
            ans +=1

print(ans)


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

for i in range(min(k,s)+1):
    for j in range(min(k,s-i)+1):
        if s-i-j<=k:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
k, a, b = map(int, input().split())
f = 1
while a <= b:
	if (a % k == 0):
		f = 0
		print ("OK")
		break
	a += 1
if f:
	print ("NG")

Fixed submission:
n = int(input())
a, b = map(int, input().split())
sucess = False
for i in range(a, b + 1):
    if i % n == 0:
        sucess = True
print(("NG", "OK")[sucess])
Buggy python submission (verdict: Runtime Error):
import math
def func(i):
    return math.floor(a * i * 1.0 / b) - a * math.floor(i * 1.0 / b);
 
a, b, n = map(int, input().split())
 
print (max(func(b), func(n))

Fixed submission:
a, b, n = map(int, input().split())
x = min(n, b - 1)
print(int((a * x) / b) - a * int(x / b))
Buggy python submission (verdict: Runtime Error):
arr = input().split()
h=int(arr[0])
w=int(arr[1])

if w%2!=0:
    if h%2!=0:
        ans=(w+1)//2*(h+1)//2+(w-1)//2*(h-1)//2
    else:
        ans=(w+1)//2*h//2+(w-1)//2*h//2
else:
    ans=w//2*h
print(ans)

Fixed submission:
arr="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
list=arr.split(", ")

k=int(input())
print(list[k-1])
Buggy python submission (verdict: Runtime Error):
arr = input().split()
h=int(arr[0])
w=int(arr[1])

if w%2!=0:
    if h%2!=0:
        ans=(w+1)//2*(h+1)//2+(w-1)//2*(h-1)//2
    else:
        ans=(w+1)//2*h//2+(w-1)//2*h//2
else:
    if h%2!=0:
        ans=w//2*h
print(ans)

Fixed submission:
arr = input().split()
h=int(arr[0])
w=int(arr[1])
 
if w*h%2!=0 and h!=1 and w!=1:
    ans=(w*h+1)//2
elif h==1 or w==1:
    ans=1
else:
    ans=w*h//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N=input()

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Fixed submission:
N = int(input())

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Buggy python submission (verdict: Runtime Error):
answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Fixed submission:
N = int(input())

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

Buggy python submission (verdict: Runtime Error):
answer=0
count=0

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        count+=1
if count==4:
    answer+=1

print(answer)

Fixed submission:
N = int(input())

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)

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

answer=0
count=0

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        count+=1
if count==4:
    answer+=1

print(answer)

Fixed submission:
N = int(input())

answer=0
count=0
 
for i in range(1,N+1,2):
    for j in range(1,int(i**0.5)+1):
        if i%j==0:
            count+=1
    if count==4:
        answer+=1
    count=0
 
print(answer)
Buggy python submission (verdict: Runtime Error):
# 2019 12/01
# A November 30

M1, D1 = map(int, input())
M2, D2 = map(int, input())

if int(D2) == 1:
    print(1)
else:
    print(0)

Fixed submission:
# 2019 12/01
# A November 30

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if int(D2) == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
# 2019 9.1
# A Tenki

S = list(input())
T = list(input())

cnt = 0

for i in range(3):
    if S[i] == T[i]:
        cnt += 1

print(cnt)

Fixed submission:
# 2019 9.1
# Power Socket

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

kuti = 1
cnt = 0

while kuti < B:
    kuti += A - 1
    cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

# def gcd2(a,b,c):
# 	a=gcd(a,b)
# 	a=gcd(a,c)
# 	return a

K = int(input())
ans = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			ans += gcd2(i,j,k)
print(ans)

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

def gcd2(a,b,c):
	a=gcd(a,b)
	a=gcd(a,c)
	return a

K = int(input())
ans = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			ans += gcd2(i,j,k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

def judge(s):
    flag = 1
    if len(s)<=1: return 1
    for i in range(len(s)-1):
        s1, s2 = int(s[i]),int(s[i+1])
        if abs(abs(s1)-abs(s2)) <= 1: continue
        else:
            flag = 0 
            break
    return flag


def bfs1(k, cnt=1, now=1):
    while True:
        s=str(now)
        if judge(s) and k==cnt: return now
        elif judge(s):
            cnt+=1
            now+=1
        else: now+=1

def bfs2(k, cnt=100000, now=3234566667):
    while True:
        s=str(now)
        if judge(s) and k==cnt: return now
        elif judge(s):
            cnt-=1
            now-=1
        else: now-=1    

if k<1000: print(bfs1(k,1,1))
else: print(bfs2(k))


Fixed submission:
from collections import deque
k=int(input())
stack = deque([1,2,3,4,5,6,7,8,9])

def lunlun():
    cnt=0
    while True:
        now = stack.popleft()
        cnt += 1
        if cnt == k: return now
        s = str(now)
        for i in range(-1,2):
            temp=int(s[-1]) + i 
            if temp>=0 and temp<10: 
                temp1=int(s + str(temp))
                stack.append(temp1)
print(lunlun())

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())

def judge(s):
    flag = 1
    if len(s)<=1: return 1
    for i in range(len(s)-1):
        s1, s2 = int(s[i]),int(s[i+1])
        if abs(abs(s1)-abs(s2)) <= 1: continue
        else:
            flag = 0 
            break
    return flag


def bfs(k, cnt=1, now=1):
    while True:
        s=str(now)
        if judge(s) and k==cnt: return now
        elif judge(s):
            cnt+=1
            now+=1
        else: now+=1

print(bfs(k,1,1))


Fixed submission:
from collections import deque
k=int(input())
stack = deque([1,2,3,4,5,6,7,8,9])

def lunlun():
    cnt=0
    while True:
        now = stack.popleft()
        cnt += 1
        if cnt == k: return now
        s = str(now)
        for i in range(-1,2):
            temp=int(s[-1]) + i 
            if temp>=0 and temp<10: 
                temp1=int(s + str(temp))
                stack.append(temp1)
print(lunlun())
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

N,M = [int(i) for i in input().split()]

if N!=1 and M!=1:
    ans = comb(N,2) + comb(M,2)
elif N==1:
    ans = comb(M,2)
elif M==1:
    ans = comb(N,2)
else:
    ans = 0

print(int(ans))

Fixed submission:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

N,M = [int(i) for i in input().split()]

if N >= 2 and M >= 2:
    ans = cmb(N,2) + cmb(M,2)
elif N <= 1 and M >=2:
    ans = cmb(M,2)
elif M <= 1 and N >=2:
    ans = cmb(N,2)
else:
    ans = 0


print(int(ans))
Buggy python submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = A / 0.08
tmax = (B + 1) / 0.08
tmin = B / 0.1

if emin < tmax and emin >= tmin:
    print(int(emin))
elif tmin < emax and tminn >= emin:
    print(int(tmin))
else:
    print(-1)

Fixed submission:
import math

A,B = [int(i) for i in input().split()]
emax = (A + 1) / 0.08
emin = math.ceil(A / 0.08)
tmax = (B + 1) / 0.1
tmin = B / 0.1

if emin < tmax and emin >= tmin:
    print(emin)
elif tmin < emax and tmin >= emin:
    print(int(tmin))
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
H,N=map(int,input().split())
A,B=[],[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


INF=10**9
dp=[INF for i in range(H+max(A))]
dp[0]=0

for i in range(H):
    for j in range(N):
        p1=dp[i+A[j]]
        p2=dp[i]+B[j]
        dp[i+A[j]]=min(p1,p2)

print(min(dp[H:]))


Fixed submission:
H,N=map(int,input().split())
A,B=[],[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


INF=10**9
dp=[INF for i in range(H+max(A))]
dp[0]=0

for i in range(H):
    for j in range(N):
        p1=dp[i+A[j]]
        p2=dp[i]+B[j]
        dp[i+A[j]]=min(p1,p2)

print(min(dp[H:]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=[int(i) for i in input().split()]
count=1
for i in range(1,N):
    if P[i]<=min(P[:i]):
        count+=1
print(count)


Fixed submission:
N=int(input())
P=[int(i) for i in input().split()]
count=1
min=P[0]
for i in range(1,N):
    if min>=P[i]:
        count+=1
        min=P[i]
    else:
        continue
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

INF=10**9+7

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

temp=A[0]
for i in range(1,N):
    temp=lcm(temp,A[i])

ans=0
for a in A:
    ans+=(temp//a)%INF

print(ans%INF)


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)

INF=10**9+7

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

temp=A[0]
for i in range(1,N):
    temp=lcm(temp,A[i])

ans=0
for a in A:
    ans+=(temp//a)

print(ans%INF)