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

Fixed submission:
mod = 10**9+7
 
n = int(input())
a = [[int(x) for x in input().split()] for _ in range(n)]
 
dp = [-1 for __ in range(1 << n)]
dp[0] = 1
 
 
def dfs(bit, i):
    if dp[bit] != -1:
        return dp[bit]
    else:
        tmp = 0
        for j in range(n):
            if bit & (1 << j) and a[i][j]:
                tmp += dfs(bit ^ (1 << j), i+1)
    dp[bit] = tmp % mod
    return dp[bit]
 
 
print(dfs(2**n-1, 0))

Buggy submission (verdict: Runtime Error):
mod = 10**9+7
 
n = int(input())
a = [[int(x) for x in input().split()] for _ in range(n)]
 
dp = [-1 for __ in range(1 << n)]
dp[0] = 1
 
 
def dfs(bit, i):
    if dp[bit] != -1:
        return dp[bit]
    else:
        tmp = 0
        for j in range(n):
            if bit & (1 << j) and a[i][j]:
                tmp += dfs(bit ^ (1 << j), i+1)
    dp[bit] = tmp % mod
    return dp[bit]
 
 
print(dfs(2**n-1, 0))
Problem p02732 (python)

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

Buggy submission (verdict: Runtime Error):
%%time
import math
import numpy as np
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
num_list =  input().split(' ')
num_list2 = [int(n) for n in num_list]
num_list3 = [0]*n
num_list4 = [0]*n
num_list5 = [0]*n
for i in range(len(num_list2)):
    num_list3[num_list2[i]-1] += 1
for i in range(len(num_list2)):
    if num_list4[num_list2[i]-1] == 0:
        size = max(0 , num_list3[num_list2[i]-1])
        if size >= 2:
            ans = comb(size,2)
        elif size == 1:
            ans = 0
        else :
            ans = 0 
        num_list4[num_list2[i]-1] = ans

    if num_list5[num_list2[i]-1] == 0:
        size = max(0 , num_list3[num_list2[i]-1]-1)
        if size >= 2:
            ans = comb(size,2)
        elif size == 1:
            ans = 0
        else :
            ans = 0 
        num_list5[num_list2[i]-1] = ans
for i in range(n):
    print(num_list5[num_list2[i]-1]-num_list4[num_list2[i]-1]+np.sum(num_list4))
Problem p02761 (python)

Fixed submission:
N,M = map(int,input().split())
flag = True
answer = [0]*N
if len(answer) != 1:
    answer[0] = 1
change_list = [0]*N
answer_num = 0
for i in range(M):
    num_list = list(map(int,input().split()))
    if change_list[num_list[0]-1] == 0:
        answer[num_list[0]-1] = num_list[1]
        change_list[num_list[0]-1] = 1
    else:
        if answer[num_list[0]-1] == num_list[1]:
            continue
        else:
            flag = False

if flag == False:
    print(-1)

elif (answer[0] == 0)&(len(answer) != 1):
    print(-1)
else:
    for i in range(len(answer)):
        answer_num += 10**(len(answer) - (i+1))*answer[i]
    print(answer_num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M,K = map(int,input().split())
answer_list = [0]*N
frend_list = [[0] * N for i in range(N)]
flag_list = [0]*N
for i in range(M):
    num_list= list(map(int,input().split()))
    frend_list[num_list[0]-1][num_list[1]-1] = 1
    frend_list[num_list[1]-1][num_list[0]-1] = 1

for i in range(K):
    num_list= list(map(int,input().split()))
    frend_list[num_list[0]-1][num_list[1]-1] = 3
    frend_list[num_list[1]-1][num_list[0]-1] = 3
    
    
for i in range(len(answer_list)):
    for n in range(len(frend_list[i])):
        if (frend_list[i][n] == 0) & (i != n):
            flag_list = (np.array(frend_list[n])+np.array(frend_list[i]))
            flag_list = flag_list.tolist()
            for g in flag_list:
                if g == 2:
                    answer_list[i] += 1
print(answer_list)
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())
if N < 10:
    print(R + 100*(10 - N))
else:
    print(R)

Buggy submission (verdict: Runtime Error):
N = int(input())
R = int(input())
if N < 10:
    print(R + 100*(10 - N))
else:
    print(R)
Problem p02767 (python)

Fixed submission:
n = int(input())
zahyou = list(map(int,input().split()))
loss = 0
ans = 0
minimum = min(zahyou)
maximum = max(zahyou)
for i in range(minimum, maximum+1):
    loss = 0
    for j in zahyou:
        loss += (j-i)**2
        
    if i == minimum:
        ans = loss
    if loss < ans:
        ans = loss
print(ans)

Buggy submission (verdict: Runtime Error):
loss = 0
ans = 0
minimum = min(zahyou)
maximum = max(zahyou)
for i in range(minimum, maximum+1):
    loss = 0
    for j in zahyou:
        loss += (j-i)**2
        
    if i == minimum:
        ans = loss
    if loss < ans:
        ans = loss
print(ans)
Problem p02780 (python)

Fixed submission:
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = 0
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            candidate += (num_list[j]+1)/2
        tmp = candidate
    else:
        tmp += -(num_list[i-1]+1)/2 + (num_list[i+k-1]+1)/2
        if tmp > candidate:
            candidate = tmp
        
print(candidate)

Buggy submission (verdict: Runtime Error):
def kaidan(n):
    if n >= 1:
        return n+kaidan(n- 1)
    else:
        return 0
    
    
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = []
tmp = [0]
num = 0
for i in range(n):
    i += num
    
    if sum(tmp) < sum(num_list[i:i+k]):
        tmp = num_list[i:i+k]
    else:
        candidate.append(tmp)
        num += 2
        
    if i == n-k:
        candidate.append(tmp)
        break
        
ans = 0
for i in candidate:
    tmp = 0
    for j in i:
        tmp += kaidan(j)/j
    if tmp > ans:
        ans = tmp
        
print(ans)

Buggy submission (verdict: Runtime Error):
def kaidan(n):
    if n >= 1:
        return n+kaidan(n- 1)
    else:
        return 0
    
    
n,k = map(int,input().split())
num_list = list(map(int , input().split()))
candidate = []
tmp = [0]
num = 0
for i in range(n):
    i += num
    
    if sum(tmp) < sum(num_list[i:i+k]):
        tmp = num_list[i:i+k]
    else:
        candidate.append(tmp)
        num += 2
        
    if i == n-k:
        candidate.append(tmp)
        break
        
ans = 0
for i in candidate:
    tmp = 0
    for j in i:
        tmp += kaidan(j)/j
    if tmp > ans:
        ans = tmp
Problem p02786 (python)

Fixed submission:
import numpy as np
n =int(input())
ans = 1
for i in range(int(np.log2(n))):
    ans += 2**(i+1)
    
print(ans)

Buggy submission (verdict: Runtime Error):
n =int(input())
ans = 1
for i in range(int(np.log2(n))):
    ans += 2**(i+1)
    
print(ans)
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ac_list = [0]*n
wa_list = [0]*n
pena = 0
for i in range(m):
    p,s = input().split()
    if s == 'AC':
        if ac_list[int(p)-1] == 0:
            ac_list[int(p)-1] =1
            pena += wa_list[int(p)-1]
        
    if s == 'WA':
        if ac_list[int(p)-1] == 0:
            wa_list[int(p)-1] += 1
            
print('{0} {1}'.format(sum(ac_list) , pena)
Problem p02838 (python)

Fixed submission:
import numpy as np
n = int(input())
mod = 10**9+7
a = np.array(list(map(int,input().split())))
ans = 0
for i in range(60):
    #aをiビット右にずらす、iは60桁目まで、&1で対象のビットが1のもの以外を0にその数をカウントする。
    b = np.count_nonzero(a >>i&1)
    ans += ((2**i)*(n-b)*b)%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
mod = 10**9+7
a = np.array(list(map(int,input().split())))
ans = 0
for i in range(60):
    #aをiビット右にずらす、iは60桁目まで、&1で対象のビットが1のもの以外を0にその数をカウントする。
    b = np.count_nonzero(a >>i&1)
    ans += ((2**i)*(n-b)*b)%mod
print(ans)
Problem p02900 (python)

Fixed submission:
import numpy as np
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

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


a,b = map(int,input().split())
gcd = gcd(a ,b)
print(len(np.unique(prime_decomposition(gcd)))+1)

Buggy submission (verdict: Runtime Error):
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

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


a,b = map(int,input().split())
gcd = gcd(a ,b)
print(len(np.unique(prime_decomposition(gcd)))+1)
Problem p02909 (python)

Fixed submission:
i  = input()
if i == 'Sunny':
    print('Cloudy')
elif i == 'Cloudy':
    print('Rainy')
elif i == 'Rainy':
    print('Sunny')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
price_list = sorted(list(map(int,input().split())),reverse = True)
for num in range(m):
    price_list[0] = price_list[0]//2
    price_list = sorted(price_list,reverse = True)
sum(price_list)

Buggy submission (verdict: Runtime Error):
i  = input()
if i == 'Sunny':
    print('Cloudy')
elif i == 'Cloudy':
    print('Rainy')
elif i = 'Rainy':
    print('Sunny')

Buggy submission (verdict: Runtime Error):
i  = input()
if i == 'Sunny':
    print('Cloudy'):
elif i == 'Cloudy':
    print('Rainy')
elif i = 'Rainy':
    print('Sunny')
Problem p02918 (python)

Fixed submission:
import numpy as np
n,k = map(int,input().split())
s = input()
lr_cnt = 0
rl_cnt = 0
mnt = 0
for i in range(len(s)-1):
    if s[i] == 'L' and s[i+1] == 'R':
        lr_cnt += 1
        
    if s[i] == 'R' and s[i+1] == 'L':
        rl_cnt += 1
mnt  = rl_cnt + lr_cnt+1
mnt = np.max([1,mnt-2*k])
if mnt == 1:
    print(n-1)
else:
    print(n-rl_cnt-lr_cnt+2*k-1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = input()
lr_cnt = 0
rl_cnt = 0
mnt = 0
for i in range(len(s)-1):
    if s[i] == 'L' and s[i+1] == 'R':
        lr_cnt += 1
        
    if s[i] == 'R' and s[i+1] == 'L':
        rl_cnt += 1
mnt  = rl_cnt + lr_cnt+1
mnt = np.max([1,mnt-2*k])
if mnt == 1:
    print(n-1)
else:
    print(n-rl_cnt-lr_cnt+2*k-1)
Problem p02921 (python)

Fixed submission:
a = input()
b = input()
num = 0
for i in range(3):
    if a[i] == b[i]:
        num += 1
print(num)

Buggy submission (verdict: Runtime Error):
a = int(input())
print(((a)*(a-1))//2)
Problem p02972 (python)

Fixed submission:
m = int(input())
num_list = list(map(int,input().split()))
ans_list = [0]*m
print_list = []
for i in range(m,0,-1):
    if num_list[i-1] == 0:
        cnt = 0
        for j in range(2,m//i+1):
            cnt += ans_list[i*j-1]
        if cnt % 2 == 1:
            ans_list[i-1] = 1
            print_list.append(i)
    elif num_list[i-1] == 1:
        cnt = 0
        for j in range(2,m//i+1):
            cnt += ans_list[i*j-1]
        if cnt % 2 == 0:
            ans_list[i-1] = 1
            print_list.append(i)
            
if not print_list:
    print(0)
    
else:
    print(sum(ans_list))
    print(*print_list)

Buggy submission (verdict: Runtime Error):
m = int(input())
num_list = list(map(int,input().split()))
ans_list = [0]*m
print_list = []
for i in range(m):
    if num_list[m-i-1] == 0:
        cnt = 0
        for j in range(2**10):
            if (j+1)*(m-i) > m:
                break
            else:
                cnt += ans_list[(m-i)*(j+2)-1]
        if cnt % 2 == 1:
            ans_list[m-i-1] = 1
            print_list.append(m-i)
    elif num_list[m-i-1] == 1:
        cnt = 0
        for j in range(2**10):
            if (j+1)*(m-i) > m:
                break
            else:
                cnt += ans_list[(m-i)*(j+2)-1]
        if cnt % 2 == 0:
            ans_list[m-i-1] = 1
            print_list.append(m-i)
            
if not print_list:
    print(0)
    
else:
    print(sum(ans_list))
    print(*print_list)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    # ユークリッド互除法により最大公約数を求める。
    if a < b:
        a, b = b, a

    if a % b == 0:
        return b
    else:
        return gcd(b, a % b)
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/gcd(c, d))
a_cd = (a-1)//int((c*d)/gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/math.gcd(c, d))
a_cd = (a-1)//int((c*d)/math.gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
b_c = b//c
b_d = b//d
a_c = (a-1)//c
a_d = (a-1)//d
b_cd = b//int((c*d)/math.gcd(c, d))
a_cd = (a-1)//int((c*d)/math.gcd(c, d))
print((b-a+1)-(b_c+b_d-b_cd-(a_c+a_d-a_cd)))
Problem p03035 (python)

Fixed submission:
a,b = map(int,input().split())
if a >=13:
    print(b)
elif  6 <= a <= 12:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a >=13:
    print(b)
elif  6 <= a <= 12:
    print(b//2)
else:
    prnt(0)
Problem p03043 (python)

Fixed submission:
import numpy as np
import math 
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1/n
    else:
        num = math.ceil(np.log2(k/i))
        ans += (1/n)*(1/2)**num
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1/n
    else:
        if k//i == 0 :
            num = 1
        else:
            num = int((np.log2(k/i)+1)//1)
        ans += (1/n)*(1/2)**num
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    if i >= k:
        ans += 1/n
    else:
        if k//i == 0 :
            num = 1
        else:
            num = int((np.log2(k//i)+1)//1)
        ans += (1/n)*(1/2)**num
    
print(ans)
Problem p03241 (python)

Fixed submission:
import numpy as np

n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m)+1)):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
        tmp2 = m//i
        if (ans < tmp2) and(tmp2 <= tmp):
            ans = tmp2
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = 0
tmp = int(m/n)
for i in range(1,int(np.sqrt(m))):
    if m%i == 0:
        if (ans < i) and(i <= tmp):
            ans = i
print(ans)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if a*b%2 == 0 or a*b == 0:
    print('Even')
else:
    print('Odd')

Buggy submission (verdict: Runtime Error):
#C - Traveling
num = int( input())
check = 0
step_b = 0
x_b = 0
y_b = 0
for i in range(num):
    step ,x ,y = map(int,input().split())
    if ((x-x_b)+(y-y_b) - (step-step_b)  > 0) or (((x-x_b)+(y-y_b) - (step - step_b))%2 == 1) :
        check = 1
        break
    x_b = x
    y_b = y
    step_b = step
if check == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#C - Traveling
num = int( input())
check = 0
step_b = 0
x_b = 0
y_b = 0
for i in range(num):
    step ,x ,y = map(int,input().split())
    if ((x-x_b)+(y-y_b) - (step-step_b)  > 0) or (((x-x_b)+(y-y_b) - (step - step_b))%2 > 0) :
        check = 1
        break
    print(((x-x_b)+(y-y_b) - (step - step_b)))
    x_b = x
    y_b = y
    step_b = step
if check == 0:
    print('Yes')
else:
    print('No')
Problem p03469 (python)

Fixed submission:
a = input()
print("2018"+a[4::])

Buggy submission (verdict: Runtime Error):
yukichi_num = 0
ichiyou_num = 0
a,b = map(int,input().split())
for i in range(a+1):
    for  n in range(a+1-i):
        if i*10000+n*5000+1000*(a-i-n) == b:
            print('{0} {1} {2}'.format(i,n,a-i-n))
            exit()
print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
yukichi_num = 0
ichiyou_num = 0
a,b = map(int,input().split())
while (b >= 10000) and (a > 0):
    b -=10000
    yukichi_num += 1
    a -= 1
while (b >= 5000) and(a > 0):
    b -= 5000
    ichiyou_num += 1
    a -= 1
if (b/1000) <= a:
    print('{0} {1} {2}'.format(yukichi_num,ichiyou_num,int(b/1000)))
else:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
yukichi_num = 0
ichiyou_num = 0
a,b = map(int,input().split())
while (b >= 10000) and (a > 0):
    b -=10000
    yukichi_num += 1
    a -= 1
while (b >= 5000) and(a > 0):
    b -= 5000
    ichiyou_num += 1
    a -= 1
if (b//1000) <= a:
    print('{0} {1} {2}'.format(yukichi_num,ichiyou_num,int(b/1000)))
else:
    print('-1 -1 -1')
Problem p03471 (python)

Fixed submission:
yukichi_num = 0
ichiyou_num = 0
d,e,f = -1,-1,-1
a,b = map(int,input().split())
for i in range(a+1):
    for  n in range(a+1-i):
        if i*10000+n*5000+1000*(a-i-n) == b:
            d = i
            e = n
            f = a-i-n
print('{0} {1} {2}'.format(d,e,f))

Buggy submission (verdict: Runtime Error):
N,Y = map(int,input().split())
flag = False
for i in range(N+1):
    for j in range(N+1-i):
        x = N - i - jint
        if x*1000 + j*5000 +i*10000 == Y:
            print(i,j,x)
            flag = True
            break
    if flag == True:
        break


if flag == False:
    print('-1 -1 -1')
Problem p03495 (python)

Fixed submission:
n,k = map(int,input().split())
from collections import defaultdict
d = defaultdict(int)
num_list = list(map(int,input().split()))
for tmp in num_list:
	d[tmp] += 1
    
v_list = sorted(list(d.values()) ,reverse=True)

print(n - sum(v_list[:k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
from collections import defaultdict
d = defaultdict(int)
for i in range(5):
    tmp = input()
    d[tmp] += 1
    
v_list = sorted(list(d.values()))
while len(v_list) > k:
    v_list.pop(0)
print(n - sum(v_list))
Problem p03565 (python)

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

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(0 , len(s) - len(t)+1):
        flag = True
        for j in range(i , i + len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp[:i] + t + tmp[i + len(t):]
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(len(s) - len(t),-1,-1):
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(len(s) - len(t),-1,-1)[::-1]:
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

ans_list = []
if t in s:
    print(s.replace('?', 'a'))
else:
    for i in range(0 , len(s) - len(t),-1,-1)[::-1]:
        flag = True
        for j in range(len(t)):
            if s[j] == t[j - i] or s[j] == '?':
                continue
            else:
                flag = False
                break
        if flag ==  True:
            tmp = s
            tmp = tmp.replace(tmp[i : i+len(t)] , t)
            ans_list.append(tmp.replace('?', 'a'))
    if len(ans_list) == 0:
        print('UNRESTORABLE')
    else:
        ans_list.sort()
        print(ans_list[0])
Problem p03645 (python)

Fixed submission:
n,m = map(int,input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        c[b] = True 
    if b == n:
        d[a] = True
        
flag = False
for i in range(200000):
    if c[i] and d[i]:
        flag = True
        break
if flag:
    print("POSSIBLE")
    
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
graph = [[0*n] for j in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

flag = False
for i in range(n):
    if graph[0][i] == 1:
        if graph[i][n-1] == 1:
            flag = True
            break
                
if flag:
    print("POSSIBLE")
    
else:
    print("IMPOSSIBLE")
Problem p03761 (python)

Fixed submission:
import string
n = int(input())
ans = {'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 in range(n):
    if i == 0:
        st = input()
        for j in st:
            ans[j] += 1
    else:
        tmp = {'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}
        st = input()
        for j in st:
            tmp[j] += 1
            
        for j in tmp:
            ans[j] = min(ans[j],tmp[j])

anser = ''
for d in string.ascii_lowercase:
    for j in range(ans[d]):
        anser += d
print(anser)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = {'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 in range(n):
    if i == 0:
        string = input()
        for j in string:
            ans[j] += 1
    else:
        tmp = {'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}
        string = input()
        for j in string:
            tmp[j] += 1
            
        for j in tmp:
            ans[j] = min(ans[j],tmp[j])

anser = ''
for i in ans:
    for j in range(ans[i]):
        anser += i
print(anser.sort())
Problem p02612 (python)

Fixed submission:
N = int(input())

if(N % 1000 != 0):
 print(1000 - (N % 1000))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
N = str(N)
print(1000 - int(N[-3] + N[-2] + N[-1]))
Problem p02628 (python)

Fixed submission:
N, K=map(int,input().split())

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

price2 = sorted(price)
i = 0
sum = 0
while (i < K):
  sum += price2[i]
  i += 1

print(sum)

Buggy submission (verdict: Runtime Error):
N, K=map(int,input().split())

fruit = list(input().split())
price = list(map(int, input().split()))

price2 = sorted(price)
i = 0
sum = 0
while (i < K):
  sum += price2[i]
  i += 1

print(sum)
Problem p02789 (python)

Fixed submission:
N, M = map(int, input().split())

if(N == M):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

if(N = M):
  print("Yes")
else:
  print("No")
Problem p02612 (python)

Fixed submission:
N = int(input())

MOD = N % 1000
ANS = 1000 - MOD

if (MOD == 0):
  print(0)
else:
  print(ANS)

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

print(N % 1000)