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

Fixed submission:
n = input()
sn=0
for i in n:
    sn += int(i)
n = int(n)
if n%sn==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

string s;

int main(){
  cin >> s;
  int sn  = 0:
  int n
  for(int i=0;i<s.size();i++){
    sn += s[i]-'0';
    n = 10*n+(s[i]-'0');
  if(n%sn!=0)cout<<"No"<<endl;
  else cout <<"Yes"<<endl
  return 0
Problem p03324 (python)

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

tmp = []
for i in range(1,100):
    tmp.append(i*100**d)
tmp.append(101*100**d)
print(tmp[n-1])

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

tmp = []
for i in range(1,100):
    tmp.append(i*100**d)
print(tmp[n-1])

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

tmp = []
for i in range(1,100):
    tmp.append(i*100**d)
print(tmp[n])
Problem p03353 (python)

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

substringList = []
if(len(s) < 50):
    for i in range(len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
            for j in range(i, i+5):
                substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(list(set(substringList)))[K-1])

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

substringList = []
if(len(s) < 50):
    for i in range(len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
            for j in range(i, I+5):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(substringList)[K-1])

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

substringList = []
if(len(s) < 50):
    for i in range(len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
            for j in range(i, I+3):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(substringList)[K-1])

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

substringList = []
if(len(s) < 5):
    for i in range(len(s)):
        if(i+5 > len(s)):
            for j in range(i, len(s)):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
else:
    for i in range(len(s)):
        if(i+5 > len(s)):
            for j in range(i, i+5):
                #print(i,j)
                if(s[i:j+1] in substringList):
                    pass
                else:
                    substringList.append(s[i:j+1])
#substringList = list(set(substringList))
print(sorted(substringList)[K-1])
Problem p03388 (python)

Fixed submission:
Q = int(input())
for i in range(Q):
    a,b = (map(int, input().split()))
    if(a == b):
        print(2*a -2)
    elif(abs(a-b) == 1):
        print(2 * min(a,b) -2)
    else:
        c = int((a*b) ** 0.5)
        if c == (a*b) ** 0.5:
            c -= 1
        if(c*(c+1) >= a*b):
            print(2*c-2)
        else:
            print(2*c-1)

Buggy submission (verdict: Runtime Error):
Q = int(input())
for i in range(Q):
    a,b = (map(int, input().split()))
    if(a == b or a+1 == b):
        print(2*a -2)
    else:
        c = int(sqrt(a*b))
        if(c*(c+1) > a*b):
            print(2*c-2)
        else:
            print(2*c-1)
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())
mod = N % 500
if mod <= A:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = [input() for i in range(H)]
queue = [(0,0,1)]
shape = sum(row.count("#") for row in List)
used ={(0,0)}

def check(x,y,c):
    if(x>W-1 or y>H-1 or x<0 or y<0):
        return
    if(List[y][x] == '#'):
        return
    if(x,y) in used:
        return
    queue.append((x,y,c+1))
    used.add((x,y))

f= -1
while queue:
    x,y,c = queue[0]
    if x==W-1 and y==H-1:
        f=1
        break
    queue.pop(0)
    check(x+1,y,c)
    check(x, y+1,c)
    check(x-1,y,c)
    check(x, y-1,c)
print(f if f == -1 else(H*W-c-shape))
Problem p03436 (python)

Fixed submission:
H,W = map(int, input().split())
List = []
queue = [(0,0,1)]
shape = 0
used ={(0,0)}
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)

def check(x,y,c):
    if(x>W-1 or y>H-1 or x<0 or y<0):
        return
    if(List[y][x] == '#'):
        return
    if(x,y) in used:
        return
    queue.append((x,y,c+1))
    used.add((x,y))

flag = -1
while(len(queue) != 0):
    x,y,c = queue[0]
    if x==W-1 and y==H-1:
        flag = 1
        break
    queue.pop(0)
    check(x+1,y,c)
    check(x, y+1,c)
    check(x-1,y,c)
    check(x, y-1,c)
if(flag == 1):
    print(H*W - c - shape)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = []
queue = [(0,0,1)]
shape = 0
used ={(0,0)}
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)

def check(x,y,c):
    if(x > W-1 or y > H-1):
        return
    if(List[y][x] == '#'):
        return
    if(x,y) in used:
        return
    queue.append((x,y,c+1))
    used.add((x,y))

flag = -1
while(len(queue) != 0):
    x,y,c = queue[0]
    if x==W-1 and y==H-1:
        flag = 1
        break
    queue.pop(0)
    check(x+1,y,c)
    check(x, y+1,c)
    check(x-1,y,c)
    check(x, y-1,c)
if(flag == 1):
    print(H*W - c - shape)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = []
queue = [(0,0)]
shape = 0
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)

def check(x,y):
    if(x >= W-1 or y >= H-1):
        return
    if(List[y][x] == '#')
        return
    queue.append((x,y))

while(len(queue) != 0):
    x,y = queue[0]
    queue.pop(0)
    check(x+1,y)
    check(x, y+1)
if(flag == 1):
    print(H*W - (H-1 + W-1 + 1) - shape)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = []
queue = [(0,0)]
shape = 0
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)

def check(x,y):
    if(x > W-1 or y > H-1):
        return
    if(List[y][x] == '#')
        return
    queue.append((x,y))

while(len(queue) != 0):
    x,y = queue[0]
    queue.pop(0)
    check(x+1,y)
    check(x, y+1)
if(flag == 1):
    print(H*W - (H-1 + W-1 + 1) - shape)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
List = []
queue = [(0,0)]
shape = 0
for i in range(H):
    x = input()
    shape += x.count('#')
    List.append(x)
while(len(queue) != 0):
    x,y = queue[0]
    queue.pop(0)
    if(x == H-1 and y == W-1):
        flag = 1
        break
    if(x < H-1):
        if(List[x+1][y] == '.'):
            queue.append((x+1,y))
    if(y < W-1):
        if(List[x][y+1] == '.'):
            queue.append((x,y+1))
if(flag == 1):
    print(H*W - (H-1 + W-1 + 1) - shape)
else:
    print(-1)
Problem p03450 (python)

Fixed submission:
from collections import deque

#幅優先探索でラベリング
def bfs(x, graph, people):
    #people[x] is None -> まだ訪問していない．訪問していたらなラベルがつくので，
    if people[x] is not None:
        return
    unvisited = deque([x])
    people[x] = 0
    while unvisited:
        now = unvisited.popleft()
        for Next, d in graph[now]:
            if people[Next] is None:
                people[Next] = people[now] + d
                unvisited.append(Next)

def main():
    N, M = list(map(int, input().split()))
    graph = [ [] for i in range(N+1)]
    people = [None] * (N+1)

    #グラフの作成
    for i in range(M):
        L, R, D = list(map(int, input().split()))
        graph[L].append((R, D))
        graph[R].append((L, -D))
    #全ての頂点でサーチ ->ラベリングを行う
    for i in range(1,N+1):
        bfs(i, graph, people)

    for i in range(1,N+1):
        for j,d in graph[i]:
            if people[j] - people[i] != d:
                print("No")
                exit()
    print("Yes")
if __name__ == '__main__':
    main()

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

#幅優先探索でラベリング
def bfs(x, graph, people):
    #people[x] is None -> まだ訪問していない．訪問していたらなラベルがつくので，
    if people[x] is not None:
        return
    unvisited = deque([x])
    people[x] = 0
    while unvisited:
        now = unvisited.popleft()
        for Next, d in graph:
            if people[Next] is None:
                people[Next] = people[now] + d
                unvisited.append(Next)

def main():
    N, M = list(map(int, input().split()))
    graph = [ [] for i in range(N)]
    people = [None] * N

    #グラフの作成
    for i in range(M):
        L, R, D = list(map(int, input().split()))
        graph[L].append((R, D))
        graph[R].append((L, -D))
    #全ての頂点でサーチ ->ラベリングを行う
    for i in range(N):
        bfs(i, graph, people)

    for i in range(N):
        for j,d in graph[i]:
            if people[j] - people[i] != d:
                print("No")
                exit()
    print("Yes")
if __name__ == '__main__':
    main()
Problem p03480 (python)

Fixed submission:
S = input()

# s = S[0]
temp_T = len(S)
for i in range(len(S)-1):
    if(S[i] != S[i+1]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)

print(temp_T)

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

# s = S[0]
temp_T = 100000
for i in range(len(S)-1):
    if(S[i+1] != s[i]):
        judge = max(i+1,len(S)-(i+1))
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)

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

s = S[0]
temp_T = 100000
for i in range(1, len(S)+1):
    if(S[i] != s):
        judge = max(i,len(S)-i)
        temp_T = min(judge, temp_T)
        s = S[i]

print(temp_T)
Problem p02732 (python)

Fixed submission:
#coding:utf-8


def nC2(n):
    return n * (n-1) // 2
  
def main():
    n = int(input())
    li = list(map(int, input().split()))
    nums = [0] * n
    for num in li:
        nums[num - 1] += 1
        
    sumv = 0
    for num in nums:
        if num == 0:
            continue
        sumv += nC2(num)
    
    for num in li:
        cnt = nums[num - 1]
        v = sumv + nC2(cnt-1) - nC2(cnt)
        print(v)
        
  
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#coding:utf-8
from copy import copy

MOD = 1000000007

def add(a, b):
    return (a + b) % mod

def sub(a, b):
    return (a + mod - b) % mod

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, pow(b, mod-2, mod))

f = [1]
for i in range(10**5+5):
    f.append(f[-1]*(i+1)%MOD)
    
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % MOD

def nCr(n, r):
    return f[n] // (f[r] * f[n-r])
  
def main():
    n = int(input())
    li = list(map(int, input().split()))
    nums = [0] * n
    for num in li:
        nums[num - 1] += 1
        
    sumv = 0
    for num in nums:
        if num == 0:
            continue
        sumv += nCr(num, 2)
    
    for num in li:
        cnt = nums[num - 1]
        if cnt == 1:
            print(sumv)
            continue
        v = sumv + nCr(cnt-1, 2) - nCr(cnt, 2)
        print(v)
        
  
if __name__ == '__main__':
    main()
Problem p02787 (python)

Fixed submission:
#coding:utf-8

def main():
    h, n = map(int, input().split())
    ab = []
    for _ in range(n):
        ab.append(list(map(int, input().split())))
    
    inf = 100000000000
    # indexがモンスターに与えたダメージで、中身がトキのダメージ
    damages = [0] + [inf] * h
    for i in range(1, h + 1):
        for j in range(n):
            damage_monster = ab[j][0]
            damage_toki = ab[j][1]
            
            damages[i] = min(damages[max(0, i - damage_monster)] + damage_toki, damages[i])


    print(min(damages[h:]))
main()

Buggy submission (verdict: Runtime Error):
#coding:utf-8

def main():
    h, n = map(int, input().split())
    ab = []
    for _ in range(n):
        ab.append(list(map(int, input().split())))
    
    inf = 1000000
    # indexがモンスターに与えたダメージで、中身がトキのダメージ
    damages = [inf for _ in range(100000)]
    damages[0] = 0
    for i in range(h):
        if damages[i] == inf:
            continue
        for j in range(n):
            new_damage = ab[j][0]
            if damages[i + new_damage] > damages[i] + ab[j][1]:
                damages[i + new_damage] = damages[i] + ab[j][1]
    
    k = h
    while damages[k] == inf:
        k += 1
    print(damages[k])
main()
Problem p02811 (python)

Fixed submission:
#coding:utf-8

k, x = map(int, input().split(' '))
if k * 500 >= x:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):

#coding:utf-8

from functools import reduce
import fractions

n, x = map(int, input().split(' '))
nums = list(map(int, input().split(' ')))

def devide_cnt(num):
    cnt = 0
    while num % 2 == 0:
        cnt += 1
        num //= 2
    return cnt, num

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def main():
    odd_nums = []
    cnt = -1
    for num in nums:
        tmp, num = devide_cnt(num)
        if cnt == -1:
            cnt = tmp
        if cnt != tmp:
            print(0)
            return
        odd_nums.append(num)
        
    minv = 2 ** cnt * lcm_list(odd_nums)

    
    l = 1
    r = 10000000001
    tmp = -1
    while l < r + 1:
        m = l + (r - l) // 2
        p = m * minv + 0.5 * minv
        if p > x:
            r = m
        else:
            l = m
        
        if tmp == p:
            break
        tmp = p
        
            
    print(l+1)
    
    
    

main()
Problem p03311 (python)

Fixed submission:
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = nums[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)

Buggy submission (verdict: Runtime Error):
#coding:utf-8
n = int(input())
nums = sorted([num - i for i, num in enumerate(list(map(int,input().split())), 1)])


sums = [None for i in range(n)]
sums[0] = nums[0]
allv = sum(nums)

minv = nums[0] * (2 - n) - 2 * sums[0] + allv
for i in range(n-1):
    sums[i+1] = sums[i] + nums[i+1]
    p = sum[i] * (2*(i+1) - n) -2 * sums[i] + allv
    minv = min(minv,p)

print(minv)
Problem p03323 (python)

Fixed submission:
#coding:utf-8
A,B = map(int, input().split())

if A <= 8 and B <= 8:
    print("Yay!")

else:
    print(":(")

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import itertools
import numpy as np

N,M = map(int,input().split())
cakeList = [list(map(int,input().split())) for i in range(N)]
cakeList = np.array(cakeList)
numList = [i for i in range(N)]


maxv = 0
if M < N/2:
    combi = list(itertools.combinations(numList,M))
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(total,maxv)
    print(maxv)


else:
    M = N - M
    combi = list(itertools.combinations(numList,M))
    BDP = [np.sum(cakeList[:,i]) for i in range(3)]
    for indexs in combi:
        cakes = [cakeList[i] for i in indexs]
        cakes = np.array(cakes)
        total = [abs(BDP[i] - np.sum(cakes[:,i])) for i in range(3)]
        total = sum(total)
        maxv = max(maxv,total)
    print(maxv)
Problem p02755 (python)

Fixed submission:
a,b=map(int,input().split())
for i in  range(1,1300):
  if int(i*0.08)==a and int(i*0.1)==b:
    print(i)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
a,b= map(int, input().split())
aa = a + 0.9
bb = b + 0.9

if int(bb/0.1) > 1000:
bb = 1000

aaa = set(range(int(a/0.08),int(aa/0.08)))
bbb = set(range(int(b/0.1), int(bb/0.1)))

x = list(aaa.intersection(bbb))

if len(x) == 0:
  print('-1')
else:
  print(min(x))
Problem p02772 (python)

Fixed submission:
a = int(input())
 
b=list(map(int, input().split())) 
x = 0
c = 0
    
for i in b:
  if ((i % 3 == 0) or (i % 5 == 0)) and (i % 2 == 0):
    x += 1

for t in b:
  if (t%2==0):
    c += 1;

if x == c:
  print('APPROVED')
else :
  print('DENIED')

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

b=[]
for i in range(a):
	b.append(int(input()))
x = 0
 
if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')

Buggy submission (verdict: Runtime Error):
a = int(input())
b=[]
b.append(int(input()))
x = 0
 
if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
x = 0
 
if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:
      print('DENIED')

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

if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:
      print('DENIED')

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

if (a==0) :
	print('DENIED')
elif (b.count(0) > 0):
	print('DENIED')
else:
  for i in b:
      if i % a == 0:
          x += 1
  if x == len(b):
      print('APPROVED')
  else:
      print('DENIED')

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

for i in b:
	if i % a == 0:
		x += 1
if x == len(b):
	print('APPROVED')
else:
	print('DENIED')
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
 
if 2019 <= R - L:
    print(0)
else:
    a=min([(i*j)%2019 for i in range(L,R+1) for j in range(i+1,R+1)])
    print(a)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

mod = []
if 2019 <= R - L:
    print(0)
else:
    for i in range(L, R):
        j = i + 1
        mod.append((i * j % 2019))

print(min(mod))
Problem p03759 (python)

Fixed submission:
abc = raw_input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])

if b - a == c - b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
abc = raw_input().split()
a = int(abc[0])
b = int(abc[1])
c = int(abc[2])

if b - a == c - b:
    print("YES")
else:
    print("NO")
Problem p03773 (python)

Fixed submission:
#coding:utf-8

AB = raw_input().split()
A = int(AB[0])
B = int(AB[1])

if A+B > 24:
    print (A+B)%24
elif A+B == 24:
    print 0
else:
    print A+B

Buggy submission (verdict: Runtime Error):
#coding:utf-8

AB = raw_input().split()
A = int(AB[0])
B = int(AB[1])

if A+B > 24:
    print (A+B)%24
elif A+B = 24:
    print 0
else:
    print A+B
Problem p02713 (python)

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

def resolve():
    k = int(input())

    tmp = []
    for a in range(1, k+1):
        for b in range(1, k+1):
            tmp.append(gcd(a,b))

    ans = 0
    for c in range(1,k+1):
        for i in tmp:
            ans += gcd(i, c)
    
    print(ans)
    
resolve()

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

sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1,k+1):
            sum += gcd(gcd(a,b), c)

print(sum)
Problem p02730 (python)

Fixed submission:
str = input()
n = len(str)
str_list = list(str)

ans = 'Yes'
for i in range(0,n//2):
    if str_list[i] != str_list[n//2-i-1]:
        ans = 'No'

for j in range(n//2+1,n):
    if str_list[i] != str_list[-i-1]:
        ans = 'No'

for i in range(n):
    if str_list[i] != str_list[-i-1]:
        ans = 'No'

print(ans)

Buggy submission (verdict: Runtime Error):
str = input()
n = len(str)
str_list = list(str)

for i in range(0,n//2):
    if str_list[i] != str_list[n//2-i-1]:
        print('No')
        return

for j in range(n//2+1,n):
    if str_list[i] != str_list[-i-1]:
        print('No')
        return

print('Yes')
Problem p02747 (python)

Fixed submission:
import re

def resolve():
    str = input()
    if re.match('^(hi)+$', str):
        print("Yes")
    else:
        print("No")
        
resolve()

Buggy submission (verdict: Runtime Error):
import sys

def resolve():
    input = sys.stdin.readline
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    str = input()
    if re.match('(hi)+', str):
        print("Yes")
    else:
        print("No")

resolve()
Problem p02748 (python)

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

    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)
    for m in grid:
        if m[0]-1 < A and m[1]-1 < B:
            tmp = a[m[0]-1] + b[m[1]-1] - m[2]
        
            if tmp < res:
                res = tmp

    print(res)
    
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    input = sys.stdin.readline
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    grid=[list(map(int,input().split())) for i in range(M)]

    res = min(a) + min(b)

    for x, y, c in grid:
        res = min(res, a[x-1]+b[y-1]-c)

    print(res)
    
resolve()
Problem p02780 (python)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = sum(P[:K])
ans = memo

for i in range(K, N):
    memo = memo - P[i-K] + P[i]
    ans = max(ans, memo)

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(int, input().split()))
memo = P[:K]
ans = sum(memo)

for i in range(K, N):
    memo.pop(0)
    memo.append(P[i])
    if sum(memo) > ans:
        ans = memo

print(K-1+((ans-K+1) - 0.5*((ans-K+1)-1)))

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

ans = -1
memo = [-1]*(K-1)

for memo_i in range(K-1):
    memo[memo_i] = P[memo_i]

for i in range(K-1, N):
    sum_ = sum(memo) + P[i]
    ans = max(ans, sum_)
    memo.pop(0)
    memo.append(P[i])

tmp = ans - K + 1
print(K-1+(tmp - 0.5*(tmp-1)))
Problem p04044 (python)

Fixed submission:
N, L = map(int, input().split())
S = [input() for _ in range(N)]

print(''.join(sorted(S)))

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for _ in range(L)]

ans = sorted(S)
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for _ in range(L)]

print(''.join(sorted(S)))