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

Fixed submission:
N=int(input())
s=0
for i in range(N):
    x,u=map(str,input().split())
    if u=='JPY':
        s+=int(x)
    else:
        s+=380000.0*float(x)
print(s)

Buggy submission (verdict: Runtime Error):
N=int(input())
s=0
for i in range(N):
    x,u=map(str,input().split())
    if u=='JPY':
        s+=int(x)
    else:
        s+=380000*int(x)
print(s)
Problem p03125 (python)

Fixed submission:
A,B=map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
A,B=map(int(input().split()))
if B%A==0:
    print(A+B)
else:
    print(A-B)

Buggy submission (verdict: Runtime Error):
A,B=map(int(input().split()))
if A%B==0:
    print(A+B)
else:
    print(A-B)
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
l=[]
for i in range(N):
    c,t=map(int,input().split())
    if t<=T:
        l.append(c)
if len(l)>=1:
    print(min(l))
else:
    print('TLE')

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

Fixed submission:
l,r,d=map(int,input().split())
print(r//d-(l-1)//d)

Buggy submission (verdict: Runtime Error):
l,r,d=map(int(input().split()))
print(r//d-(l-1)//d)
Problem p02608 (python)

Fixed submission:
n = int(input())
t = [0]*10001
for i in range(1,41):
    t[6*i**2] += 1
for i in range(1,99):
    for j in range(1,99):
        if(i != j):
            a = (i+j)**2 + 2*j**2
            if(a <= 10000):
                t[a] += 3
            else:
                break
for i in range(3,100):
    for j in range(2,i):
        for k in range(1,j):
            a = ((i+j)**2 + (j+k)**2 + (k+i)**2)//2
            if(a <= 10000):
                t[a] += 6
            else:
                break
for i in range(1,n+1):
    print(t[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [0]*10001
for i in range(1,42):
    t[6*i**2] += 1
for i in range(1,59):
    for j in range(1,59):
        if(i != j):
            a = (i+j)**2 + 2*j**2
            if(a <= 10000):
                t[a] += 3
            else:
                break
for i in range(3,100):
    for j in range(2,i):
        for k in range(1,j):
            a = ((i+j)**2 + (j+k)**2 + (k+i)**2)//2
            if(a < 10000):
                t[a] += 6
            else:
                break
for i in range(1,n+1):
    print(t[i])
Problem p02618 (python)

Fixed submission:
import random as rd
d = int(input())
c = list(map(int,input().split()))
s = []
for i in range(d):
    s.append(list(map(int,input().split())))
for i in range(d):
    print(rd.randint(1,26))

Buggy submission (verdict: Runtime Error):
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (x[j]+13)(x[j]+14)*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])

Buggy submission (verdict: Runtime Error):
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (d-i)x[j]*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
t = [1]*(m+1)
for i in range(n):
    if(t[a[i]] == 1):
        x = a[i]*2
        while(x <= m):
            t[x] = 0
            x += a[i]
for i in range(n):
    if(t[a[i]] == 0):
        n -= 1
    elif(t[a[i]] == 1):
        t[a[i]] = -1
    elif(t[a[i]] == -1):
        t[a[i]] = -2
        n -= 2
    else:
        n -= 1
print(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
t = []
for i in range(10):
    t.append([])
for i in range(n):
    j = a[i]//10#24
    t[j].append(a[i])
#print(t)
p = n
for i in range(len(t[0])):
    for j in range(len(t[0])):
        if(i != j):
            if(t[0][i] % t[0][j] == 0):
                p -= 1
                #print(t[0][i],t[0][j])
                break
for i in range(1,10):
    for j in range(len(t[i])):
        x = 0
        for k in range(len(t[i])):
            if(j != k):
                if(t[i][j] ==  t[i][k]):
                    p -= 1
                    #print(t[i][j],t[i][k],-1)
                    x = 1
                    break
        if(x == 0):
            for k in range((i+2)//2):
                for l in range(len(t[k])):
                    if(t[i][j] % t[k][l] == 0):
                        p -= 1
                        #print(t[i][j],t[k][l])
                        x = 1
                        break
                if(x == 1):
                    break

print(p)
Problem p02660 (python)

Fixed submission:
n = int(input())
t = []
for i in range(2,int(-(-n**0.5//1))+1):
    if(n%i == 0):
        cmp = 0
        while(n%i == 0):
            cmp += 1
            n //= i
        t.append([i,cmp])
    if(n == 1):
        break
if(n != 1):
    z = 1
else:
    z = 0
z -= len(t)
for i in range(len(t)):
    j = 1
    while(t[i][1] >= 0):
        t[i][1] -= j
        j += 1
        z += 1
print(z)

Buggy submission (verdict: Runtime Error):
n = int(input())
x,y = map(int,input().split())
a = [x]
b = [y]
for i in range(n-1):
    x,y = map(int,input().split())
    if(a[-1] < x):
        a.append(x)
    elif(a[0] > x):
        a = [x] + a
    else:
        for j in range(len(a)):
            if(a[j] > x):
                a.insert(j,x)
                break
    if(b[-1] < y):
        b.append(y)
    elif(b[0] > y):
        b = [y] + b
    else:
        for j in range(len(b)):
            if(b[j] > y):
                b.insert(j,y)
                break
if(n%2 == 1):
    print(b[n//2]-a[n//2]+1)
else:
    print(b[n//2] + b[-1+n//2] - a[n//2] - a[-1+n//2]+1)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
t = [0]*(n+1)
l = [1]
t[1] = 1
x = 1
y = 0
for i in range(n):
    if(t[a[x]] == 0):
        x = a[x]
        t[x] = 1
        l.append(x)
    else:
        z = i+1
        y = l.index(a[x])
        break
if(k>y):
    print(l[(k-y)%(z-y)+y])
else:
    print(l[k])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
t = [0]*(n+1)
l = [1]
t[1] = 1
x = 1
for i in range(n):
    if(t[a[x]] == 0):
        x = a[x]
        l.append(x)
    else:
        z = i+1
        break
print(l[k%z])
Problem p02702 (python)

Fixed submission:
s = input()
if(len(s) < 5):
    print(0)
else:
    t = [0]*2019
    t[0] = 1
    p = 0
    temp = 0
    temp2 = 1
    for i in range(1,len(s)+1):
        temp2 *= 10
        temp2 %= 2019
        t[(temp + temp2*int(s[-i]))%2019] += 1
        temp += temp2*int(s[-i])
    for i in range(2019):
        p += (t[i]*(t[i]-1))//2
    print(p)

Buggy submission (verdict: Runtime Error):
s = input()
if(len(s) < 5):
    print(0)
else:
    p = 0
    for i in range(5,len(s)+1):
        for j in range(len(s)-i+1):
            if(int(s[j:j+i])%2019 == 0):
                p += 1
print(p)
Problem p02730 (python)

Fixed submission:
s=input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len(s)-3)//2-i]):
    a=0
    break
if(a==1):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
a=1
for i in range(len(s)):
  if(s[i]!=s[-i-1]):
    a=0
    break
for i in range((len(s)-1)//2):
  if(s[i]!=s[(len()-3)//2]):
    a=0
if(a==1):
  print("Yes")
else:
  print("No")
Problem p02718 (python)

Fixed submission:
a = input().split()

n = int(a[0])
m = int(a[1])

b = input().split()

x = [int(i) for i in b]

s = sum(x)
lim = s / (m*4)

c = 0

for i in range(0,n):
    if(x[i] >= lim):
      c = c + 1
    else:
      continue

if(c >= m):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a = input().split()

n = int(a[0])
m = int(a[1])

b = input().split()

x = [int(i) for i in b]

s = sum(x)
lim =int(s / (m*4) + 1

c = 0

for i in range(0,n):
    if(x[i] > lim):
      c = c + 1
    else:
      continue

if(c >= m):
  print("Yes")
else:
  print("No")
Problem p02743 (python)

Fixed submission:
s = input().split()

d = [int(s) for s in s]
a = d[0]
b = d[1]
c = d[2]

if(c-a-b > 0 and 4*a*b < (c-a-b)**2):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

double func(double a) {
    double b = a;
    for(int i = 0; i < 1000; i++) {
        b = (b * b + a) / (2 * b);
    }
    return b;
}

int main(void){
    int l, i=0, g[10];
    while(cin>>l){
        g[i] = l;
        i++;
    }
  float a,b,c=0;
  
  a = func(g[0]);
  b = func(g[1]);
  c = func(g[2]);
  printf("%f,%f,%f\n",a,b,c);
  
  if(a+b < c){
    printf("Yes");
  }
    else{
    printf("No");
    }
  
  return 0;
}
Problem p02784 (python)

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

for i in range(0,int(n)):
    h = int(h) - int(w[i])

if(h<=0):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
h,n = input().split()
w = [0]*int(n)

for i in range(0,int(n)):
    w[i] = input()

for i in range(0,int(n)):
    h = int(h) - int(w[i])

if(h<=0):
    print("Yes")
else:
    print("No")
Problem p02922 (python)

Fixed submission:
x = input().split()

a = int(x[0])
b = int(x[1])

c = 1
outlet = a
if(b==1):
  print(0)
  exit()

while True:
  if(outlet >= b):
    print(c)
    break
  elif(outlet < b):
    c = c + 1
    outlet = outlet + a - 1

Buggy submission (verdict: Runtime Error):
x = input().split()

a = int(x[0])
b = int(x[1])

c = 1
outlet = a
if(B==1):
  print(0)

while True:
  if(outlet >= b):
    print(c)
    break
  elif(outlet < b):
    c = c + 1
    outlet = outlet + a - 1
Problem p02999 (python)

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

if(x<a):
  print(0)
else:
  print(10)

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

if(x<a):
  print(0)
else:
  print(10)
Problem p03261 (python)

Fixed submission:
n = int(input())

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])
#print(w)

if(w[n-1] not in used):
  print("Yes")
else:
  print("No")

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

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])

if(w[n] not in used):
  print("Yes")
else:
  print("No")
Problem p03352 (python)

Fixed submission:
x = int(input())

ans = []
if x == 1:
  print(1)
  exit()

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)

if len(ans)==0:
  print(0)
else:
  print(max(ans))

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

ans = []

for i in range(2,x+1):
  for j in range(2,x+1):
    if i**j > x:
      break
    ans.append(i**j)
      
print(max(ans))
Problem p03369 (python)

Fixed submission:
s = input()
a = 700
for i in range(len(s)):
  if s[i] == "o":
    a += 100
print(a)

Buggy submission (verdict: Runtime Error):
s = input()
a = 700
for i in range(len(s)):
  if s[i] == "o":
    x += 100
print(x)
Problem p03473 (python)

Fixed submission:
x = int(input())
 
print(24 + (24 - x))

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

pritn(24 + (24 - x))
Problem p03485 (python)

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

Buggy submission (verdict: Runtime Error):
import math
x,y = int(input())

m = (x+y)/2

print(math.ceil(m))
Problem p03643 (python)

Fixed submission:
n = int(input())

ans = "{}{}".format("ABC",n)
print(ans)

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

ans = "{1}{2}".format("ABC",n)
print(ans)
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())

if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
  print("Possible")
else:
  print("Impossible")
Problem p03721 (python)

Fixed submission:
import itertools
n,k = map(int,input().split())

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
a = []
b = []
for i in range(n):
  tmp1 = int(ab[i][0])
  tmp2 = int(ab[i][1])
  a.append(tmp1)
  b.append(tmp2)
ab = zip(a,b)
ab = sorted(ab)
a,b = zip(*ab)

s = 0
for i in range(n):
  s += int(b[i])
  if s >= k:
    print(int(ab[i][0]))
    exit()

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

ab = [0]*n

for i in range(n):
  ab[i] = input().split()
  
ans = []

for i in range(n):
  tmp = [int(ab[i][0])]*int(ab[i][1])
  ans.append(tmp)

ans = list(itertools.chain.from_iterable(ans))
ans.sort()
print(ans[k-1])
Problem p03777 (python)

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

if a == b:
  print("H")
else:
  print("D")

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())

if s == b:
  print("H")
else:
  print("D")
Problem p03795 (python)

Fixed submission:
n = int(input())

print(800*n - int(n/15)*200)

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

print(800*n - int(n/15)200)
Problem p03814 (python)

Fixed submission:
s = input()
i = 0
j = len(s) - 1
t1 = []
t2 = []

while True:
  #print(i,j)
  if(s[i] == "A"):
    t1.append(i)
    #print(t1)
  if(s[j] == "Z"):
    t2.append(j)
  if(len(t1) != 0 and len(t2) != 0):
    break
  i += 1
  j -= 1
  
print(t2[0]-t1[0] +1)

Buggy submission (verdict: Runtime Error):
s = input()
i = 0
j = len(s) -1
t1 = 0
t2 = 0
while True:
  if(s[i] == "A"):
    t1 = i
  if(s[j] == "Z"):
    t2 = j
  if(t1 != 0 and t2 != 0):
    break
  
  i += 1
  j -= 1
print(t2-t1 +1)
Problem p02600 (python)

Fixed submission:
x = int(input())
ans = 8 - (x - 400) // 200
print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
ans = 8 - (X - 400) // 200
print(ans)
Problem p02609 (python)

Fixed submission:
n = int(input())
x = input()
x_popcnt = x.count('1')
one_popcnt = x_popcnt - 1
zero_popcnt = x_popcnt + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_popcnt != 0:
        one_mod = (one_mod*2 + int(b)) % one_popcnt
    zero_mod = (zero_mod*2 + int(b)) % zero_popcnt

f = [0]*220000
popcnt = [0]*220000
for i in range(1, 220000):
    popcnt[i] = popcnt[i//2] + i % 2
    f[i] = f[i % popcnt[i]] + 1

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_popcnt != 0:
            nxt = one_mod
            nxt -= pow(2, i, one_popcnt)
            nxt %= one_popcnt
            print(f[nxt]+1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += pow(2, i, zero_popcnt)
        nxt %= zero_popcnt
        print(f[nxt]+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
x_popcnt = x.count('1')
one_popcnt = x_popcnt - 1
zero_popcnt = x_popcnt + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_popcnt != 0:
        one_mod = (one_mod*2 + int(b)) % one_popcnt
    zero_mod = (zero_mod*2 + int(b)) % zero_popcnt

f = [0]*220000
popcnt = [0]*220000
for i in range(1, 220000):
    popcnt[i] = popcnt[i//2] + i % 2
    f[i] = f[i % popcnt[i]] + 1

onepow2 = [1]*220000
for i in range(1, 220000):
    onepow2[i] = 2*onepow2[i-1] % one_popcnt
zeropow2 = [1]*220000
for i in range(1, 220000):
    zeropow2[i] = 2*zeropow2[i-1] % zero_popcnt
for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_popcnt != 0:
            nxt = one_mod
            nxt -= onepow2[i]
            nxt %= one_popcnt
            print(f[nxt]+1)
        else:
            print(0)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zeropow2[i]
        nxt %= zero_popcnt
        print(f[nxt]+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
x_popcnt = x.count('1')
one_popcnt = x_popcnt - 1
zero_popcnt = x_popcnt + 1

one_mod = 0
zero_mod = 0
for b in x:
    one_mod = (one_mod*2 + int(b)) % one_popcnt
    zero_mod = (zero_mod*2 + int(b)) % zero_popcnt

f = [0]*220000
popcnt = [0]*220000
for i in range(1, 220000):
    popcnt[i] = popcnt[i//2] + i % 2
    f[i] = f[i % popcnt[i]] + 1

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        nxt = one_mod
        nxt -= pow(2, i, one_popcnt)
        nxt %= one_popcnt
        print(f[nxt]+1)
    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += pow(2, i, zero_popcnt)
        nxt %= zero_popcnt
        print(f[nxt]+1)
Problem p02632 (python)

Fixed submission:
MOD = 10**9 + 7
K = int(input())
S = input()
N = len(S)


class Combination:
    """
  O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
  n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
  使用例：
  comb = Combination(1000000)
  print(comb(5, 3))  # 10
  """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * \
                modinv[self.mod % i] % self.mod
        return modinv


comb = Combination(2100000)
ans = 0
for i in range(K + 1):

    temp = comb(N + K - i - 1, N - 1)
    temp %= MOD
    temp *= pow(26, i, MOD)
    temp %= MOD
    temp *= pow(25, K - i, MOD)
    temp %= MOD
    ans += temp
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
K = int(input())
S = input()
N = len(S)


class Combination:
    """
  O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
  n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
  使用例：
  comb = Combination(1000000)
  print(comb(5, 3))  # 10
  """

    def __init__(self, n_max, mod=10 ** 9 + 7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n - r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n + 1):
            fac.append(fac[i - 1] * i % self.mod)
            facinv.append(facinv[i - 1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n + 1)
        modinv[1] = 1
        for i in range(2, n + 1):
            modinv[i] = self.mod - self.mod // i * \
                modinv[self.mod % i] % self.mod
        return modinv


comb = Combination(1000000)
ans = 0
for i in range(K + 1):

    temp = comb(N + K - i - 1, N - 1)
    temp %= MOD
    temp *= pow(26, i, MOD)
    temp %= MOD
    temp *= pow(25, K - i, MOD)
    temp %= MOD
    ans += temp
    ans %= MOD
print(ans)
Problem p02703 (python)

Fixed submission:
N,M,S = map(int,input().split())
edges = [[] for _ in range(2500*50 + 100)]
def indexer(city,coin):
    return 50*coin + city

for _ in range(M):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    for scoin in range(a,2501):
        edges[indexer(u,scoin)].append((b,indexer(v,scoin-a)))
        edges[indexer(v,scoin)].append((b,indexer(u,scoin-a)))
## 両替
for i in range(N):
    c,d = map(int,input().split())
    for scoin in range(c,2501):
        edges[indexer(i,scoin-c)].append((d,indexer(i,scoin)))


def dijkstra(s,n,edges):
    import heapq
    dist = [float('inf')] * n
    fixed = [False]*n
    dist[s] = 0
    fixed[s] = True
    priority_que = []
    for e in edges[s]:
        heapq.heappush(priority_que,e)

    while len(priority_que):
        edge = heapq.heappop(priority_que)
        if fixed[edge[1]]:
            continue
        v = edge[1]
        dist[v] = edge[0]
        fixed[v] = True
        for ne in edges[v]:
            heapq.heappush(priority_que,(ne[0]+dist[v], ne[1]))
    return dist

d=dijkstra(indexer(0,min(2500,S)),2500*50 + 100,edges)
for i in range(1,N):
    ans = float('inf')
    for j in range(2501):
        ans = min(ans,d[indexer(i,j)])
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M,S = map(int,input().split())
edges = [[] for _ in range(2500*50 + 5)]
def indexer(city,coin):
    return 50*coin + city

for _ in range(M):
    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1
    for scoin in range(a,2501):
        edges[indexer(u,scoin)].append([b,indexer(v,scoin-a)])
        edges[indexer(v,scoin)].append([b,indexer(u,scoin-a)])
## 両替
for i in range(N):
    c,d = map(int,input().split())
    for scoin in range(c,2501):
        edges[indexer(i,scoin-c)].append([d,indexer(i,scoin)])


def dijkstra(s,n,edges):
    import heapq
    dist = [float('inf')] * n
    fixed = [False]*n
    dist[s] = 0
    fixed[s] = True
    priority_que = []
    for e in edges[s]:
        heapq.heappush(priority_que,e)

    while len(priority_que):
        edge = heapq.heappop(priority_que)
        if fixed[edge[1]]:
            continue
        v = edge[1]
        dist[v] = edge[0]
        fixed[v] = True
        for ne in edges[v]:
            heapq.heappush(priority_que,[ne[0]+dist[v], ne[1]])
    return dist

d=dijkstra(indexer(0,min(2500,S)),2500*50 + 5,edges)
for i in range(1,N):
    ans = float('inf')
    for j in range(2501):
        ans = min(ans,d[indexer(i,j)])
    print(ans)
Problem p02727 (python)

Fixed submission:
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
cur = sum(p[:X]) + sum(q[:Y])

eat = p[:X] + q[:Y]
eat.sort()
for i in range(min(C,X+Y)):
    if r[i] > eat[i]:
        eat[i] = r[i]

ans = sum(eat)
print(ans)

Buggy submission (verdict: Runtime Error):
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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
cur = sum(p[:X]) + sum(q[:Y])

eat = p[:X] + q[:Y]
eat.sort()
for i in range(C):
    if r[i] > eat[i]:
        eat[i] = r[i]

ans = sum(eat)
print(ans)
Problem p02748 (python)

Fixed submission:
a,b,M = map(int,input().split())
A = list(map(int,input().split()))

B = list(map(int,input().split()))
C = [list(map(int,input().split())) for _ in range(M)]
ans = min(A) + min(B)
for cp in C:
    temp = A[cp[0]-1] + B[cp[1]-1] - cp[2]
    ans = min(ans,temp)

print(ans)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split()))
B = list(map(int,input().split()))
M = int(input())
C = [list(map(int,input().split())) for _ in range(M)]
ans = min(A) + min(B)
for cp in C:
    temp = A[cp[0]-1] + B[cp[1]-1] + cp[2]
    ans = min(ans,temp)
    
print(ans)
Problem p02789 (python)

Fixed submission:
N,M = map(int,input().split())
if N == M:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))
lcm = A[0]
for i in range(1,N):
    lcm = (lcm*A[i])//gcd(lcm,A[i])

MOD = 10**9+7
ans = 0
for a in A:
    b = lcm//a
    ans += b
print(ans%MOD)