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

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

def check(num):
    num = str(num)
    if len(num) != n:
        return False

    for s, c in SC:
        if num[s-1] != str(c):
            return False
    return True


for i in range(1000):
    if check(i):
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
SC = {}
num = ["0"]*n
for _ in range(m):
    s, c = map(int,input().split())
    num[s-1] = str(c)
    if s in SC and SC[s] != c:
        print(-1)
        exit()
    if c == 0 and s == n:
        print(0)
        exit()
    SC[s] = c

if num[0] == "0"and num[1] == "0":
    print(-1)
    exit()

print("".join(num))
Problem p02803 (python)

Fixed submission:
h,w = map(int,input().split())
meiro = [list(input()) for i in range(h)]
max_d = 0
from collections import deque

def bfs(sx,sy):
    que = deque([(sx,sy,0)])
    d = [[0]*w for i in range(h)]
    d[sx][sy] = 1
    max_len=0
    while que:
        x,y,tmp_len = que.popleft()
        for dx,dy in [(0,1),(1,0),(-1,0),(0,-1)]:
            tmp = tmp_len
            nx,ny = x+dx,y+dy
            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 0 and meiro[nx][ny] =='.':
                d[nx][ny] = 1
                max_len = max(max_len, tmp+1)
                que.append((nx,ny,tmp+1))
    return max_len

for s_i in range(h):
    for s_j in range(w):
        if meiro[s_i][s_j] == "#":
            continue
        max_d = max(bfs(s_i,s_j), max_d)
print(max_d)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
h,w=map(int,input().split())
meiro=[input() for _ in range(h)]
n=w*h
e=[[0]*n for _ in range(n)]
d=[(1,0),(0,1),(-1,0),(0,-1)]
for i in range(h):
  for j in range(w):
    if meiro[i][j]==".":
      for x,y in d:
        ni,nj=i+x,j+y
        if 0<=ni<h and 0<=nj<w and meiro[ni][nj]==".":
          e[w*i+j][w*ni+nj]=1

ans=floyd_warshall(e)
INF=float("inf")
print(int(max(max(a if a != INF else 0 for a in a) for a in ans)))
Problem p03006 (python)

Fixed submission:
n=int(input())
if n==1:
	print(1)
	exit()
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[j][0]-xy[i][0]
		q = xy[j][1]-xy[i][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Buggy submission (verdict: Runtime Error):
n=int(input())
xy = sorted([list(map(int,input().split())) for i in range(n)])
p=q=0
ans=0
dic={}
for i in range(n-1):
	for j in range(i+1,n):
		p = xy[j][0]-xy[i][0]
		q = xy[j][1]-xy[i][1]
		if (p,q) in dic:
			dic[(p,q)]+=1
		else:
			dic[(p,q)]=1
print(n-max(dic.values()))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
xy = sorted([list(map(int,input().split())) for i in range(n)])
A = Counter([xy[i+1][0]-xy[i][0] for i in range(0,len(xy)-1)]).keys()
B = Counter([xy[i+1][1]-xy[i][1] for i in range(0,len(xy)-1)]).keys()
A = [i for i in range(-1*max(A),max(A)+1)] if max(A)>=0 else  [i for i in range(max(A),-1*max(A)+1)]
B = [i for i in range(-1*max(B),max(B)+1)] if max(B)>=0 else  [i for i in range(max(B),-1*max(B)+1)]
final_ans=10**9
for a in A:
	if a==0:
		continue
	for b in B:
		if b==0:
			continue
		ans=0
		tmp0,tmp1 = xy[0]
		for i in range(1,len(xy)):
			ans += 0 if tmp0 == xy[i][0]-a  and tmp1 == xy[i][1]-b else 1
			tmp0=xy[i][0]
			tmp1=xy[i][1]
		tmp = ans
		ans=0
		for i in range(len(xy)-1,-1,-1):
			ans += 0 if tmp0 == xy[i][0]-a and tmp1 == xy[i][1]-b else 1
			tmp0=xy[i][0]
			tmp1=xy[i][1]
		tmp_ans = min(ans,tmp)
		final_ans = min(final_ans,tmp_ans)

print(final_ans if final_ans!=0 else final_ans+1)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
xy = [list(map(int,input().split())) for i in range(n)]
a = Counter([xy[i+1][0]-xy[i][0] for i in range(0,len(xy)-1)]).most_common()[0][0]
b = Counter([xy[i+1][1]-xy[i][1] for i in range(0,len(xy)-1)]).most_common()[0][0]

ans=0
tmp0,tmp1 = xy[0]
for i in range(1,len(xy)):
	ans += 0 if tmp0 == xy[i][0]-a  and tmp1 == xy[i][1]-b else 1
	tmp0=xy[i][0]
	tmp1=xy[i][1]
tmp = ans
ans=0
for i in range(len(xy)-1,-1,-1):
	ans += 0 if tmp0 == xy[i][0]-a and tmp1 == xy[i][1]-b else 1
	tmp0=xy[i][0]
	tmp1=xy[i][1]

print(min(ans,tmp)+1)
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
ls=[0]*m
for i in range(n):
  A=list(map(int,input().split()))[1:]
  for j in A:
    ls[j-1]+=1
print(sum(list(map(lambda x:x//n,ls))))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ls=set(list(map(int,input().split()))[1:])
unique=ls.copy()
for i in range(n-1):
  A=list(map(int,input().split()))
  for j in ls:
    if j not in A[1:]:
      unique.remove(j)
print(len(unique))
Problem p03150 (python)

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

for i in range(n):
    for j in range(i, n):
        tmp = s[:i]+s[j:]
        if tmp == "keyence":
            print("YES")
            quit()

print("NO")

Buggy submission (verdict: Runtime Error):
s=input()
string="keyence"
flag1=0
flag2=0
flag3=0
v=0

for i in range(len(s)):
  if s[i]==string[v]:
    v+=1
    if flag1==1:
      flag2=1
  else:
    flag1=1
    if flag1==1 and flag2==1:
      print("NO")
      exit()

if flag1==0 and flag2==0:
  print('YES')
elif flag2==0:
  print('NO')
else:
  print('YES')
Problem p03200 (python)

Fixed submission:
s=list(input())
count=0
# print('lens',len(s))
indexes = [i for i, x in enumerate(s) if x == "B"]
ideal=sorted([len(s)-i-1 for i in range(len(indexes))])
# print(indexes)
# print(ideal)
for i in range(len(indexes)):
  count+=ideal[i]-indexes[i]

print(count)

Buggy submission (verdict: Runtime Error):
s=list(input())
count=0

indexes = [i for i, x in enumerate(s) if x == "B"]
if len(s)%2==1:
  ideal=[i for i in range(len(s)//2+1,len(s))]
else:
  ideal=[i for i in range(len(s)//2,len(s))]

for i in range(len(s)//2):
  count+= ideal[i]-indexes[i]
print(count)
Problem p03219 (python)

Fixed submission:
x,y = map(int,input().split())
print(x+int(y/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
temp = list(map(int,input().split()))
tmp = 10**9
index= 1

for i in temp:
  if abs(a- (t - tmp)) > abs(a- (t - i * 0.006)):
    tmp = t - i * 0.006
    index = temp.index(i)+1


print(index)
Problem p03229 (python)

Fixed submission:
from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.appendleft(a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.appendleft(0,a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)

Buggy submission (verdict: Runtime Error):
from collections import deque
n = int(input())
nums =[]

for i in range(n):
  nums.append(int(input()))

nums.sort()
nums = deque(nums)
a = [nums.pop()]
a = deque(a)

while not len(nums) == 0:
  try:
    a.appendleft(nums.popleft())
    a.append(nums.popleft())
    a.appendleft(nums.pop())
    a.append(nums.pop())
  except IndexError:
    pass

tmp_1 = abs(a[-1] - a[-2])
tmp_2 = abs(a[-1] - a[0])

if tmp_1 < tmp_2:
  a.insert(0,a.pop())

sub = 0
for i in range(1, len(a)):
  sub += abs(a[i-1]-a[i])
print(sub)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
if len(a) ==1:
  a.append([0,0])
if len(b) == 1:
  b.append([0,0])
if a[0][0] == b[0][0]:
  if a[1][1]>b[1][1]:
    print(n-a[1][1] - b[0][1])
  else:
    print(n-a[0][1]-b[1][1])
else:
  print(n-a[0][1]-b[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
if len(set(V))==1:
  print(n//2)
else:
  v1=Counter(V[::2])
  v2=Counter(V[1::2])
  ans=0
  if v1.most_common()[0][0]==v2.most_common()[0][0]:
    if v1.most_common()[0][1]>v2.most_common()[0][1]:
      v1_s=v1.most_common()[0][1]
      v2_s=v2.most_common()[1][1]
    else:
      v1_s=v1.most_common()[1][1]
      v2_s=v2.most_common()[0][1]
  if len(v1)!=1:
    ans+=len(list(v1.elements()))-v1_s
  if len(v2)!=1:
    ans+=len(list(v2.elements()))-v2_s
  print(ans)
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())

for i in range(k):
  if s[i]!="1":
    break
print(s[i])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=="1":
  print(s[1])
else:
  print(s[0])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=="1":
  try:
    if s[k-1]=="1":
      print('1')
    else:
      print(s[s.rfind("1")+1])
  except IndexError:
    print(s[s.rfind("1")+1])
else:
  print(s[0])

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=="1":
  print(s[1])
else:
  print(s[0])
Problem p03290 (python)

Fixed submission:
import itertools
from collections import Counter
D, G = map(int, input().split())
P = [list(map(int, input().split())) for i in range(D)]
min_num = 10**8

judge_list = list(itertools.product([0, 1, 2], repeat=D)) #0:中途半端に解く 1:一問も解かない 2: 全部解く


for judge in judge_list:
    score = 0
    num = 0
    d = Counter() #インスタンスを生成
    d.update(judge)
    if (d[0] <= 1):
        for i in range(1, len(judge) + 1):
            if score >= G:
                break

            if judge[-i] == 1:
                pass

            if judge[-i] == 2:
                score += P[-i][0] * (D - i + 1) * 100 + P[-i][1]
                num += P[-i][0]

            if (judge[-i] == 0):
                for j in range(P[-i][0]):
                    if score >= G:
                        break
                    score += 100 * (D - i + 1)
                    num += 1

        if score >= G:
            min_num = min(num, min_num)

print(min_num)

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split())
ps=[]
cs=[]
counts = []
count = 0
visited = [0 for i in range(d)]
sums=0


for i in range(d):
  p,c = map(int,input().split())
  ps.append(p)
  cs.append(c)

def dfs(i,count,visited,sums):
  if visited[i] != ps[i]:
    local_visited=visited[:]
    count += 1
    sums += (i+1)*100
    local_visited[i] += 1
    if local_visited[i] == ps[i]:
      sums += cs[i]
    if sums >= g:
      counts.append(count)
      return
    for i in range(d):
      dfs(i,count,local_visited,sums)


for i in range(d):
  dfs(i,count,visited,sums)


print(min(counts))
Problem p03294 (python)

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

m =1
for i in range(len(mods)):
  m *= mods[i]

sums = 0
for i in range(len(mods)):
  sums += (m-1) %mods[i]

print(sums)

Buggy submission (verdict: Runtime Error):
import math
#引数にリストを入れるとその最小公倍数が返ってくる
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
n=int(input())
A=list(map(int,input().split()))

k=1
for i in A:
  k=lcm(k,i)

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(k-1))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
#引数にリストを入れるとその最小公倍数が返ってくる
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
  return reduce(lcm_base, numbers,1)

n=int(input())
A=list(map(int,input().split()))

def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(lcm_list(A)-1))

Buggy submission (verdict: Runtime Error):
import math
import functools
def lcm(x,y):
  return(x*y)//math.gcd(x,y)

n=int(input())
A=list(map(int,input().split()))
num=functools.reduce(lcm,A)
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def lcm(x,y):
  return(x*y)//math.gcd(x,y)

n=int(input())
A=list(map(int,input().split()))
num=reduce(lcm,A)
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def lcm(x,y):
  return(x*y)//math.gcd(x,y)

n=int(input())
A=list(map(int,input().split()))
num=reduce(lcm,A)
ans=0
def f(n):
  return sum(list(map(lambda x:n%x,A)))
print(f(num-1))
Problem p03316 (python)

Fixed submission:
n =int(input())

s=eval("+".join(str(n)))
if n % s ==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
while tmp > 0:
    sum += tmp % 10
    tmp /= 10

if n % sum == 0:
    print ("Yes")
else:
    print ("No")

Buggy submission (verdict: Runtime Error):
while tmp > 0:
    sum += tmp % 10
    tmp /= 10

if n % sum == 0:
    print "Yes"
else:
    print "No"
Problem p03324 (python)

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

if n != 100:
  print((100**d)*n)
else:
  print((100**d)*(n+1))

Buggy submission (verdict: Runtime Error):
if n != 101:
  print((100**d)*n)
else:
  print((100**d)*(n+1))
Problem p03339 (python)

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

nums = [s[1:].count('E')]
for i in range(1,n):
  tmp = nums[i-1]
  if s[i-1] == 'W':
    tmp  += 1
  if s[i] == 'E':
    tmp -= 1
  nums.append(tmp)

print(min(nums))

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

minc = 100000000

for i in range(len(s)):
  minc = min(minc,(left_wrong = s[0:i].count('W')+s[i:].count('E')))

print(minc)
Problem p03371 (python)

Fixed submission:
a,b,c,x,y=map(int,input().split())
print(min(x*a+y*b,2*x*c+b*max(0,y-x),2*y*c+a*max(0,x-y)))

Buggy submission (verdict: Runtime Error):
a,b,c,x,y=map(int,input().split())
print(min(x*
Problem p03386 (python)

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

if b-a >= k:
  for i in range(a,a+k):
    num.append(i)
  for i in range(b-k+1,b+1):
    num.append(i)
else:
  for i in range(a,b+1):
    num.append(i)

for i in sorted(set(num)):
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
num=[i for i in range(a,b+1)]
num = sorted(set(num[:k]+num[num.index(b-k+1) if b-k > 0 else -1:]))

for i in num:
  print(i)
Problem p03565 (python)

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

if len(t)>len(s):
  print("UNRESTORABLE")
  exit()

ans = []

for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] != t[j] and s[i+j]!='?':
      break
  else:
    ans.append((s[:i]+t+s[i+len(t):]).replace('?','a'))

if len(ans) == 0:
  print('UNRESTORABLE')
else:
  ans.sort()
  print(ans[0])

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

for i in range(len(s)-len(t)+1):
  flag=True
  for j in range(len(t)):
    if s[i+j]==t[j] and s[i+j]=="?":
      continue
    else:
      flag=False
  if flag:
    s=s[:i]+t+s[i+len(t):]
    s=s.replace("?","a")
print(s if flag else "UNRESTORABLE")
Problem p03583 (python)

Fixed submission:
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    tmp=4*n*h-N*h-N*n
    if tmp>0:
      if N*h*n%tmp==0:
        print(h,n,N*h*n//tmp)
        exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=4/n
for h in range(1,3501):
  for n in range(1,3501):
    tmp=4*h*n-N*h-N*n
    if tmp>0 and N*h*n%tmp==0:
      print(h,n,N*h*n//tmp)
      exit()
Problem p03611 (python)

Fixed submission:
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
Cont=Counter(A)
Cont1=Counter(A)
for k,v in Cont.items():
  Cont1[k-1]+=v
  Cont1[k+1]+=v
print(Cont1.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
A=Counter(list(map(int,input().split()))).most_common()
if A[0][0]==0:
  if A[0][1]==A[1][1]:
    max_num=A[1][0]
else:
  max_num=A[0][0]
kouho=[max_num-1,max_num,max_num+1]
cnts={max_num-1:0,max_num:0,max_num+1:0}
for i in A:
  if i[0]-1 in cnts:
    cnts[i[0]-1]+=i[1]
  if i[0] in cnts:
    cnts[i[0]]+=i[1]
  if i[0]+1 in cnts:
    cnts[i[0]+1]+=i[1]
print(max(cnts.values()))
Problem p03625 (python)

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int,input().split()))
A = Counter(A).most_common()
ans = 0

for i,j in sorted(A,reverse=True):
  if j >=4 and ans ==0:
    ans = i*i
    break
  elif j >= 2 and ans == 0:
    ans = i
  elif j >= 2:
    ans *= i
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A = Counter(A).most_common()
ans = 0

for i,j in sorted(A,reverse=True):
  if j >=4 and ans ==0:
    ans = i*i
    break
  elif j >= 2 and ans == 0:
    ans = i
  elif j >= 2:
    ans *= i
    break
print(ans)
print(sorted(A,reverse=True))
Problem p03633 (python)

Fixed submission:
n = int(input())
T=[int(input()) for i in range(n)]


def euclid(a,b):
  r = a % b
  return euclid(b,r) if r else b

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

num = T[0]
for i in range(1,n):
  num = lcm(num, T[i])
print(num)

Buggy submission (verdict: Runtime Error):
n = int(input())
T=[int(input()) for i in range(n)]
T = sorted(T,reverse=True)

for i in range(2,100):
  if T[0] % T[1] !=0:
    if sum(map(lambda x:x/2, T)) !=0:
      T[0] = T[0]*i
  else:
    print(T[0])
    exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
T=[int(input()) for i in range(n)]
T = sorted(T,reverse=True)

for i in range(2,100):
  if T[0] % T[1] !=0:
    if sum(map(lambda x:T/2, T)) !=0:
      T[0] = T[0]*i
  else:
    print(T[0])
    exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
T=[int(input()) for i in range(n)]
T = sorted(T,reverse=True)

for i in range(2,100):
  if T[0] % T[1] !=0:
    T[0] = T[0]*i
  else:
    print(T[0])
    exit()
Problem p03645 (python)

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


for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

for v in edges[-1]:
  if 0 in edges[v]:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edges=[[]for i in range(n)]
visited=[False]*n
cnt=0
def dfs(u,cnt,visited):
  visited=visited[:]
  cnt=cnt
  visited[u]=True
  if visited[-1]==True:
    return cnt,visited
  cnt+=1
  for v in edges[u]:
    if visited[v]==False:
      dfs(v,cnt,visited)
  return cnt,visited

for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

cnt,visited=dfs(0)
if visited[-1]==True and cnt==2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edges=[[]for i in range(n)]
visited=[False]*n
cnt=0
def dfs(u):
  global visited
  global cnt
  visited[u]=True
  if visited[-1]==True:
    return cnt,visited
  cnt+=1
  for v in edges[u]:
    if visited[v]==False:
      dfs(v)
  return cnt,visited

for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

cnt,visited=dfs(0)
if visited[-1]==True and cnt==2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edges=[[]for i in range(n)]
visited=[False]*n
cnt=0
def dfs(u):
  global visited
  global cnt
  visited[u]=True
  if visited[-1]==True:
    return cnt,visited
  cnt+=1
  for v in edges[u]:
    if visited[v]==False:
      dfs(v)
  return visited,cnt

for i in range(m):
  a,b=map(int,input().split())
  edges[a-1].append(b-1)
  edges[b-1].append(a-1)

visit,cnt=dfs(0)
if visit[-1]==True and cnt==2:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
Problem p03695 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
A=list(map(lambda x:x//400 if x<3200 else 8,A))
n_red=A.count(8)
n_min=len(set(A))
n_8=1 if n_red else 0
print(1 if n_min==1 and list(set(A))[0]==8 else n_min-n_8,n_min+n_red-n_8)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
A=list(map(lambda x:x//400 if x<3200 else 8,A))
n_red=A.count(8)
red_exist=1 if len(n_red) else 0
red_only=1 if red_exist and list(set(A))[0]==8 else 0
n_min=len(set(A)) if not red_exist else len(set(A))-1
print(1 if red_only else n_min,n_min+n_red)
Problem p03699 (python)

Fixed submission:
n=int(input())
S=sorted([int(input()) for i in range(n)])
not_10=[i for i in S if i%10!=0]
sums=sum(S)
if sums%10!=0:
  print(sums)
else:
  print(sums-not_10[0] if not_10 else 0)

Buggy submission (verdict: Runtime Error):
n=int(input())
S=sorted([int(input()) for i in range(n)])
not_10=[i for i in S if i%10!=0]
sums=sum(S)
if sums%10!=0:
  print(sums)
else:
  print(sums-not_10[0])
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.items())
tmp=0
for i,j in ls:
  tmp+=j
  if k <= tmp:
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ls={}
for i in range(n):
  a,b=map(int,input().split())
  if a not in ls:
    ls[a]=b
  else:
    ls[a]+=b
ls=sorted(ls.keys())
tmp=0
for i,j in ls.items():
  tmp+=j
  if k <= tmp:
    print(i)
    exit()
Problem p03813 (python)

Fixed submission:
print('ABC' if int(input()) < 1200 else 'ARC')

Buggy submission (verdict: Runtime Error):
print('ABC' if int(input() < 1200 else 'ARC'))
Problem p03962 (python)

Fixed submission:
a,b,c = map(int,input().split())
a = set([a,b,c])
print(len(a))

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input())
a = set([a,b,c])
print(len(a))
Problem p03967 (python)

Fixed submission:
s=input()

gu=0
pa=0
win=0

for t in s:
  if t=='g':
    if gu>pa:
      pa+=1
      win+=1
    else:
      gu+=1
  else:
    if gu>pa:
      pa+=1
    else:
      win-=1
      gu+=1
print(win)

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

gu=0
pa=0
win=0

fot t in s:
  if t=='g':
    if gu>pa:
      pa+=1
      win+=1
    else:
      gu+=1
  else:
    if gu>pa:
      pa+=1
    else:
      win-=1
      gu+=1
print(win)
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse = True)
Q = sorted(list(map(int, input().split())), reverse = True)
R = list(map(int, input().split()))

a = sorted(P[:X] + Q[:Y] + R, reverse  = True)
print(sum(a[:(X+Y)]))

Buggy submission (verdict: Runtime Error):
from collections import deque

x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
xlis = deque(p[len(p)-x:])
ylis = deque(q[len(q)-y:])
r = deque(r)
while True:
    if len(r) == 0:
        break
    xs = xlis.popleft()
    ys = ylis.popleft()
    rm = r.popleft()
    if rm < xs and rm < ys:
        xlis.append(xs)
        ylis.append(ys)
        break
    if xs < ys and xs < rm:
        xlis.append(rm)
        ylis.append(ys)
    elif ys < xs and ys < rm:
        ylis.append(rm)
        xlis.append(xs)
print(sum(xlis)+sum(ylis))

Buggy submission (verdict: Runtime Error):
from collections import deque

x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort()
q.sort()
r.sort(reverse=True)
xlis = deque(p[len(p)-x:])
ylis = deque(q[len(q)-y:])
r = deque(r)
while True:
    xs = xlis.popleft()
    ys = ylis.popleft()
    rm = r.popleft()
    if rm < xs and rm < ys:
        xlis.append(xs)
        ylis.append(ys)
        break
    if xs < ys and xs < rm:
        xlis.append(rm)
        ylis.append(ys)
    elif ys < xs and ys < rm:
        ylis.append(rm)
        xlis.append(xs) 
print(sum(xlis)+sum(ylis))