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

Fixed submission:
N,T = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
##print(l)
a = []
for i in range(N):
  if l[i][1] <= T:
    a.append(l[i][0])
if a != []:
  t = min(a) 
  print(t)
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
##print(l)
a = []
for i in range(N):
  if l[i][1] < T:
    a.append(l[i][0])
t = min(a)
print(t)

Buggy submission (verdict: Runtime Error):
N,T = map(int,input().split())
l = [list(map(int,input().split())) for i in range(N)]
#print(l)
a = []
for i in range(N):
  if l[0][i] < T:
    a.append(l[0][i])
t = min(a)
print(t)
Problem p03241 (python)

Fixed submission:
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
  a = m/n
  l = []
  for i in range(int(m**0.5),0,-1):
    if m%i==0:
      l.append(i)
      l.append(m//i)
  l = sorted(l)[::-1]
  for j  in l:
    if j<=a:
      print(j)
      exit()
  else:
    print(1)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,m = map(int,input().split())
if m%n==0:
    print(int(m//n))
    exit()
else:
    a = m%n
    b = m//n
    c = a+b
    while True:
        if gcd(b,c)!=1:
            print(gcd(b,c))
            exit()
        else:
            c -= 1
print(1)
Problem p03273 (python)

Fixed submission:
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
l= [i for i in l if i!=[]]
#print(l)
t = len(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
if "" in l:
  for z in l:
    z.remove("")
for m in l:
  print("".join(m))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
    l.remove([])
t = len(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
for z in l:
  z.remove("")
for i in l:
  print("".join(i))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
    l.remove([])
t = len(l)
#print(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
for z in range(t):
  l[z].remove("")
print(l)
Problem p03284 (python)

Fixed submission:
N,K = map(int,input().split())
if N%K == 0:
  print(0)
  
else:
  print(1)

Buggy submission (verdict: Runtime Error):
s = int(input())
while s >0:
  if s%7 == 0:
    print('Yes')
    break
  s -= 4
    
if s<0:
  print('No')

Buggy submission (verdict: Runtime Error):
s = int(input())
while s >0:
  s = s-4
  if s%7 == 0:
    print('Yes')
    break
    
if s<=0:
  print('No')
Problem p03288 (python)

Fixed submission:
r = int(input())
if r < 1200:
  print('ABC')
elif r >= 2800:
  print("AGC")
else:
  print('ARC')

Buggy submission (verdict: Runtime Error):
r = input()
if r < 1200:
  print('ABC')
elif r >= 2800:
  print("AGC")
else:
  print('ARC')
Problem p03352 (python)

Fixed submission:
x = int(input())
l1 = [1]
l2 = list(2**i for i in range(2,11))
l3 = list(3**i for i in range(2,7))
l4 = list(4**i for i in range(2,6))
l5 = list(5**i for i in range(2,5))
l6 = list(6**i for i in range(2,5))
l7 = list(7**i for i in range(2,5))
l8 = list(8**i for i in range(2,5))
l9 = list(9**i for i in range(2,5))
l10 =list(10**i for i in range(2,4))
l11 = list(i**2 for i in range(11,34))
l1 = list(set(l1+l2+l3+l4+l5+l6+l7+l8+l9+l10+l11))
if x in l1:
  print(x)
else:
  l1.append(x)
  l1.sort()
  a = l1.index(x)-1
  print(l1[a])

Buggy submission (verdict: Runtime Error):
a = int(input())
for i in range(a):
  a = a-i
  for k in range(2,10):
    if int(a**(1/k))**k == a:
      print(a)
      break
  else:
      continue
  break
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
l = ['.'*(w+2)]+list('.'+(input()+'.')for _ in range(h))+ ["."*(w+2)]
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=="#":
      if l[i-1][j]=="#" or l[i+1][j]=="#" or l[i][j+1]=="#" or l[i][j-1]=="#":
        continue
      else:
        print("No")
        exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
l = ['.'*(w+2)]+list('.'+(input()+'.')for _ in range(h))+ ["."*(w+2)]
for i in range(1,w+1):
  for j in range(1,h+1):
    if l[i][j]=="#":
      if l[i-1][j]=="#" or l[i+1][j]=="#" or l[i][j+1]=="#" or l[i][j-1]=="#":
        continue
      else:
        print("No")
        exit()
else:
  print("Yes")
Problem p03380 (python)

Fixed submission:
import bisect
import math
n = int(input())
l = sorted(list(map(int,input().split())))
if len(l)==2 :
  print(l[-1],l[-2])
  exit()
  
a = l[-1]/2
s = bisect.bisect_left(l,a)
if l[s]==a:
  print(l[-1],l[s])
  exit()
k1 = l[s-1]
k2 = l[s]
s1 = a-k1
if k2==l[-1]:
  k2 = k1
s2 = abs(k2-a)
#print(s,k1,k2,s1,s2)
if s1<=s2:
  print(l[-1],k1)
else:
  print(l[-1],k2)

Buggy submission (verdict: Runtime Error):
import bisect
import math
n = int(input())
l = sorted(list(map(int,input().split())))
if len(l)==2 :
  print(l[-1],l[-2])
  exit()
  
a = l[-1]/2
s = bisect.bisect_left(l,a)
if l[s]==a:
  print(l[-1],l[s])
  exit()
k1 = l[s-1]
k2 = l[s]
s1 = a-k1
if k2==l[-1]:
  k2 = k1
#s2 = abs(k2-a)
print(s,k1,k2,s1,s2)
if s1<=s2:
  print(l[-1],k1)
else:
  print(l[-1],k2)

Buggy submission (verdict: Runtime Error):
import bisect
import math
n = int(input())
l = sorted(list(map(int,input().split())))
a = l[-1]/2
s = bisect.bisect_left(l,a)
k1 = l[s]
if len(l)==2 and l[0]==0:
  print(0)
  exit()

def com(a,b):
  return math.factorial(a)//(math.factorial(b)*math.factorial(a-b))

s1 = com(l[-1],k1)
s2 = com(l[-1],k2)
if s1>=s2:
  print(l[-1],k1)
else:
  print(l[-1],k2)
Problem p03437 (python)

Fixed submission:
x,y = map(int,input().split())
if x % y ==0:
  print(-1)
else:
  print(x)

Buggy submission (verdict: Runtime Error):
x,y = int(input())
if x == y:
  print(-1)
else:
  for i in range(1,10000):
    a = i * x
    if a % y != 0:
      print(a)
      exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou=>0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou>=0:
  print("Yes")
else:
  print("No")
Problem p03438 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou>=0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cou = 0
for j,k in zip(a,b):
  if j<k:
    cou += (k-j)//2
  elif j>k:
    cou -= (j-k)
if cou=>0:
  print("Yes")
else:
  print("No")
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
z = int(input())
l = [500*i+100*t+50*w for i in range(a+1) 
         for t in range(b+1) for w in range(c+1)]
print(l.count(z))

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
l = [a+b for a in range(k+1) for b in range(k+1)]
sum = 0
for i in range(k+1):
  sum += l.count(s-i)
print(sum)
Problem p03470 (python)

Fixed submission:
N = int(input())
l = list(int(input()) for i in range(N))
a = set(l)
print(len(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split() for i in range(N))
l = set(l)
print(len(l))
Problem p03502 (python)

Fixed submission:
x = input()
l = len(x)
a = 0
for i in range(l):
  a += int(x[i])
#print(a)
if int(x)%a ==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
x = input()
l = len(x)
a = 0
for i in range(l):
  a += int(x[i])
if a%x ==0:
  print('Yes')
else:
  print('No')
Problem p03569 (python)

Fixed submission:
from collections import deque
s = deque(input())
cou = 0
while len(s)!=0:
  a = s[0]
  b = s[-1]
  if a=='x' and b!='x':
    cou += 1
    s.popleft()
  elif a!="x" and b=='x':
    cou += 1
    s.pop()
  elif a=="x" and b=='x':
    if len(s)==1:
      s.popleft()
    else:   
      s.popleft()
      s.pop()
  elif a==b:
    if len(s)==1:
      s.popleft()
    else:   
      s.popleft()
      s.pop()
  else:
    print(-1)
    exit()
print(cou)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())
cou = 0
while len(s)!=1:
  a = s[0]
  b = s[-1]
  if a=='x' and b!='x':
    cou += 1
    s.popleft()
  elif a!="x" and b=='x':
    cou += 1
    s.pop()
  elif a=="x" and b=='x':
    s.popleft()
    s.pop()
  elif a==b:
    s.popleft()
    s.pop()
  else:
    print(-1)
    exit()
print(cou)
Problem p03575 (python)

Fixed submission:
"""
何回も再帰するときはlimitを増やす
dfs
"""
import sys
sys.setrecursionlimit(200000)

n,m = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]


tree = [[] for _ in range(n)]
for a,b in l:
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

bit = [0 for _ in range(n)]
def dfs(v):
    bit[v] = 1
    for j in tree[v]:
        if bit[j]==0:
            dfs(j)

ans = 0
for i in range(m):
    a,b = l[i]
    a -= 1
    b -= 1
    tree[a].remove(b)
    tree[b].remove(a)
    bit = [0 for _ in range(n)]
    dfs(a)
    if bit.count(1) !=n:
        ans += 1

    tree[a].append(b)
    tree[b].append(a)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = list([] for _ in range(m+1))
li = list(list(map(int,input().split())) for _ in range(m))
bridge = 0
for a,b in li:
  l[a].append(b)
  l[b].append(a)
for a,b in li:
  if len(l[a])==1 or len(l[b])==1:
    bridge += 1
  elif len(l[a])==2 :
    c,d = l[a]
    if len(l[c])==1 or len(l[d])==1:
      bridge += 1
  elif len(l[b])==2 :
    c,d = l[b]
    if len(l[c])==1 or len(l[d])==1:
      bridge += 1
print(bridge)
Problem p03612 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
cou = 0

for i in range(0,n-1):
  if l[i]==i+1:
      l[i],l[i+1] = l[i+1], l[i]
      cou += 1
if l[-1]==n:
  cou += 1
print(cou)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
cou = 0
if l[0]==1:
  x = l[0]
  l[0] = l[1]
  l[1]=x
  cou += 1
for i in range(1,n):
  if l[i]==i+1:
    if l[i-1]==i:
      x = l[i-1]
      l[i-1] = l[i]
      l[i] = x
      cou += 1
    else:
      x = l[i]
      l[i] = l[i+1]
      l[i+1] = x
      cou += 1
#  print(l)
print(cou)
Problem p03627 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
l1 = [0,0]
from collections import Counter
c = Counter(l)
for i in c.items():
  if i[1]>=2 :
    l1.append(i[0])
  if i[1]>=4 :
    l1.append(i[0])
l1.sort()
print(l1[-1]*l1[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
l1 = [0,0]
from collections import Counter
c = Counter(l)
for i in c.items():
  if i[1]>=2 :
    l1.append(i[0])
sort.(l1)
print(l1[-1]*l1[-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
l1 = [0,0]
from collections import Counter
c = Counter(l)
for i in c:
  while l[i]>=2 and len(l1)<4:
    l1.append(l[i])
print(l1[-1]*l1[-2])
Problem p03633 (python)

Fixed submission:
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
N=int(input())
ans=1
for i in range(N):
    t=int(input())
    ans=lcm(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
解答例
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)
N=int(input())
ans=1
for i in range(N):
    t=int(input())
    ans=lcm(ans,t)
print(ans)
Problem p03637 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if  (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
else:
  a = n-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if  (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
else:
  if a<=c+1:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if not (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c-1:
    print("Yes")
  else:
    print("No")
else:
  if a<=c-1:
    print("Yes")
  else:
    print("No")
Problem p03657 (python)

Fixed submission:
A,B =map(int,input().split())
if A%3 == 0 or B%3 ==0 or (A+B)%3 ==0:
  print("Possible")
  
else:
  print("Impossible")

Buggy submission (verdict: Runtime Error):
A,B =map(int,input().split())
if A%3 == o or B%3 ==0 or (A+B)%3 ==0:
  print("Possible")
  
else:
  print("Impossible")
Problem p03844 (python)

Fixed submission:
a,b,c = input().split()
if b == "+":
  print(int(a)+int(c))
else:
  print(int(a)-int(c))

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
if b == "+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a,b,c = input()
if b == "+":
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
Problem p03994 (python)

Fixed submission:
from collections import deque
s = input()
k = int(input())
a = ord("a")
l = deque(list())
l1 = []
for i in range(len(s)):
  s1 = s[i]
  l.append(((a+26)-ord(s1))%26)
#print(l)
while k!=0:
    if len(l)!=0:
        t = l.popleft()
        if k>=t:
            l1.append("a")
            k -= t
        else:
          if t=="a":
            l1.append(t)
          else:
            l1.append(chr((ord('a')-t+26)))
    else:
      k %= 26
      l1[-1] = chr(int(ord(l1[-1])+k))
      k = 0
l2 = []
if len(l)>=1:
  for t in l:
    t %= 26
    if t==0:
      l2.append("a")
    else:
      l2.append(chr((ord('a')-t+26)))
  l1 += l2
print("".join(l1))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
k = int(input())
a = ord("a")
l = deque(list())
l1 = []
for i in range(len(s)):
    s1 = s[i]
    l.append(((a+26)-ord(s1))%26)
#print(l)
while k!=0:
    if len(l)!=0:
        t = l.popleft()
        if k>=t:
            l1.append("a")
            k -= t
        else:
          if t=="a":
            l1.append(t)
          else:
            l1.append(chr((ord('a')-t+26)))
    else:
        l1[-1] = chr(int(ord(l1[-1])+k))
        k = 0
l2 = []
if len(l)>=1:
  for t in l:
    if t==0:
      l2.append("a")
    else:
      l2.append(chr((ord('a')-t+26)))
  l1 += l2
print("".join(l1))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
k = int(input())
a = ord("a")
l = deque(list())
l1 = []
for i in range(len(s)):
    s1 = s[i]
    l.append(((a+26)-ord(s1))%26)
#print(l)
while k!=0:
    if len(l)!=0:
        t = l.popleft()
        if k>=t:
            l1.append("a")
            k -= t
        else:
          if t=="a":
            l1.append(t)
          else:
            l1.append(chr((ord('a')-t+26)))
    else:
        l1[-1] = chr(int(ord(l1[-1])+k))
        k = 0
l2 = []
if len(l)>=1:
  for t in l:
    if t==0:
      l2.append("a")
    else:
      l2.append(chr((ord('a')-t+26)))
  l1 += l2
print("".joiin(l1))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
k = int(input())
a = ord("a")
l = deque(list())
l1 = []
for i in range(len(s)):
    s1 = s[i]
    l.append(((a+26)-ord(s1))%26)
while k!=0:
    if len(l)!=0:
        t = l.popleft()
        if k>=t:
            l1.append("a")
            k -= t
        else:
            l1.append(chr(ord('a')-t+26))
    else:
        l1[-1] = chr(int(ord(l1[-1])+k))
        k = 0
print(''.join(l1))

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
k = int(input())
a = ord("a")codefestival
100
l = deque(list())
l1 = []
for i in range(len(s)):
    s1 = s[i]
    l.append(((a+26)-ord(s1))%26)
while k!=0:
    if len(l)!=0:
        t = l.popleft()
        if k>=t:
            l1.append("a")
            k -= t
        else:
            l1.append(chr(ord('a')-t+26))
    else:
        l1[-1] = chr(int(ord(l1[-1])+k))
        k = 0
print(''.join(l1))
Problem p03998 (python)

Fixed submission:
A = input()
B = input()
C = input()
T = "a"
while  not ((A=="" and T=="a") or (B=="" and T=="b") or (C=="" and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A=="" and T=="a"):
  print("A")
elif (B=="" and T=="b"):
  print("B")
elif (C=="" and T=="c"):
  print("C")

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
T = "a"
while not ((A=="" and T=="a") and (B==""and T=="b") and (C==""and T=="c")):
  if T =="a":
    T = A[0]
    A = A[1:]
  elif T =="b":
    T = B[0]
    B = B[1:]
  elif T =="c":
    T = C[0]
    C = C[1:]
if (A==""):
  print("a")
elif (B==""):
  print("b")
elif (C==""):
  print("c")
Problem p04019 (python)

Fixed submission:
s = input()
if "N" in s:
  if "S" not in s :
    print("No")
    exit()
if "E" in s:
  if "W" not in s:
    print("No")
    exit()
if "S" in s:
  if "N" not in s :
    print("No")
    exit()
if "W" in s:
  if "E" not in s:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
if "N" in s:
  if "S" in s:
    continue
  else:
    print("No")
    exit()
if "E" in s:
  if "W" in s:
    continue
  else:
    print("no")
    exit()
print("Yes")
Problem p04030 (python)

Fixed submission:
s=list(input())
data =[]
for i in s:
  if i=="0":
    data.append(0)
  elif i=="1":
    data.append(1)
  else:
    if data!=[]:
      del data[-1]
 #joinはリストが文字列のみ
data = map(str,data)
print(''.join(data))

Buggy submission (verdict: Runtime Error):
s=list(input())
print(s)
l=len(s)
data =[]
for i in s:
  if i=="0":
    data.append(0)
  elif i=="1":
    data.append(1)
  else:
    if data!=[]:
      del data[-1]
print("".join(data))
Problem p04043 (python)

Fixed submission:
a,b,c = map(int,input().split())
if (a==b==5 and c==7) or (a==c==5 and b==7) or (b==c==5 and a==7):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if (a==b==5 and c==7) or (a==c==5 b==7) or (b==c==5 a==7):
  print('YES')
else:
  print('NO')
Problem p02684 (python)

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

pos = -1
seen = [False] * n
last = [-1] * n
hist = []
i = 0
cnt = 0

while(seen[i] == False):
    seen[i] = True
    last[i] = cnt
    cnt += 1
    hist.append(i)
    ne = a[i]-1
    i = ne
    if (seen[i] == True):
        pos = i

cycle = hist[last[pos]:]
preCircle = last[pos]

if (k <= preCircle):
    print(hist[k] + 1)
else:
    k -= preCircle
    ans = k % len(cycle)
    print(cycle[ans] + 1)

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

pos = -1
seen = [False] * n
finished = [False] * n
hist = []
cycle = []
cycles = [-1] * n
cn = {}

def dfs(v, p):
    global pos
    seen[v] = True
    hist.insert(0, v)
    next = a[v]-1
    if (next != p):
        if (finished[next] == False):
            if (seen[next]):
                pos = next
                return
            dfs(next, v)
            if (pos != -1):
                return

    hist.pop(0)
    finished[v] = True

dfs(0, -1)
cnt = 0
while(len(hist) != 0):
    b = hist[0]
    cycle.append(b)
    cycles[b] = cnt
    cn[b] = cnt
    cnt += 1
    hist.pop(0)
    if (b == pos):
        break
cycle = list(reversed(cycle))

n = 0
ans = -1
while(cycles[n] == -1 and k > 0):
    k -= 1
    n = a[n] - 1
    if(k == 0):
        ans = n

if (k > 0):
    dc = len(cycle) - cn[n] - 1
    d = (k+dc) % len(cycle)
    ans = cycle[d] + 1

print(ans)
Problem p02784 (python)

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

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

a = sorted(a)

if(sum(a) >= h):
    print("Yes")
else:
    print("No")

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

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

a = sorted(a)

if(a[0] + a[1] >= h):
    print("Yes")
else:
    print("No")
Problem p02837 (python)

Fixed submission:
N = int(input())
people = [[-1 for __ in range(N)] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        x -= 1
        people[i][x] = y

ans = 0


for i in range(1 << N):
    ansi = 0
    flag = True
    for j in range(N):
        peoplei = 0
        if (i & 1 << j):
            peoplei = 1
            ansi += 1
        for k in range(N):
            if (i & 1 << k):
                if(people[k][j] != -1 and people[k][j] != peoplei):
                    flag = False

    if flag:
        ans = max(ans, ansi)


print(ans)

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

talk = [[-1 for i in range(N)] for j in range(N)]

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        talk[i][x-1] = y

ans = 0

for i in range(1 << N):
    honest = []
    ansi = 0
    for j in range(N):
        if(1 << j and i):
            honest.append(1)
        else:
            honest.append(0)

    for j in range(N):
        if(honest[i] == 0):
            continue
        flag = True
        for k in range(N):
            if(honest[k] != talk[j][k] and talk[j][k] != -1):
                flag = False

        if(flag):
            ansi += 1

    ans = max(ans, ansi)

print(ans)
Problem p03103 (python)

Fixed submission:
import numpy as np
n, m = map(int, input().split())
a = []
b = []
bot = m
ans = 0
for i in range(n):
  l,m = map(int, input().split())
  a.append(l)
  b.append(m)
  
a = np.array(a)
b = np.array(b)
s = np.argsort(a)
for i in s:
  if(bot >= b[i]):
    bot -= b[i]
    ans += a[i] * b[i]
  else: 
    ans += a[i] * (bot)
    bot = 0
    break

print(ans)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
  int n, m;
  long long ans = 0;
  cin >> n >> m;
  vector<int> a(n), b(n);
  vector<pair<int, int> > ab(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < n; i++) {
    ab[i] = make_pair(a[i], b[i]);
  }
  sort(ab.begin(), ab.end());  
  for(int i = 0; i < n; i++) {
    int buy = min(m, ab[i].second);
    ans += buy * ab[i].first;
    m -= buy;
  }
  
  cout << ans << endl;
}
Problem p03106 (python)

Fixed submission:
a,b,c = map(int, input().split())
num = []
for i in range(1, 101):
  if(a % i == 0 and b % i == 0):
    num.append(i)
num.reverse()
print(num[c-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
cnt = 0
ans = 0
for i in range(1, 101): # 1から100まで
	if(A % i == 0 and B % i == 0):
		cnt = cnt + 1
	if(cnt == k):
		ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
cnt = 0
ans = 0
for i in range(1, 101): # 1から100まで
	if(A % i == 0 and B % i == 0):
 		cnt = cnt + 1
 	if(cnt == k):
 		ans = i
print(ans)
Problem p03274 (python)

Fixed submission:
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e13
for i in range(n-k+1):
    l = x[i]
    r = x[i+k-1]
    ans = min(ans, abs(r)+abs(l-r))
    ans = min(ans, abs(l)+abs(r-l))
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 1e13
for i in range(n-k+1):
    l = x[i]
    r = x[i+k]
    ans = min(ans, abs(l)+abs(r-l))
print(ans)
Problem p03549 (python)

Fixed submission:
n, m = map(int, input().split())
print((1900*m + 100*(n - m)) * 2**m)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
print(1900*m + 100(n - m) * 2**m)