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

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

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorStorage.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[x]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = len(colorList)
print(maxL)

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

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorStorage.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[y]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = colorList
print(maxL)

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

color = []
colorStorage = []
for i in range(N):
    color.append(i)
    colorCount.append([i])

for _ in range(M):
    p,q = map(int,input().split())
    p -= 1
    q -= 1
    if color[p] == color[q]:
        continue
    else:
        x = color[p]
        y = color[q]
        if len(colorStorage[x]) >= len(colorStorage[y]):
            for elem in colorStorage[y]:
                color[elem] = x
                colorStorage[x].append(elem)
            colorStorage[y] = []
        else:
            for elem in colorStorage[y]:
                color[elem] = y
                colorStorage[y].append(elem)
            colorStorage[x] = []
maxL = 0
for colorList in colorStorage:
    if maxL < len(colorList):
        maxL = colorList
print(maxL)
Problem p02600 (python)

Fixed submission:
# Fast IO (only use in integer input)

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

X = int(input())
if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)

Buggy submission (verdict: Runtime Error):
# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

from copy import copy

N = int(input())
Resident = []
for i in range(N):
    x,y,p = map(int,input().split())
    Resident.append((x,y,p))

minCost = [-1] * (N+1)

preCalRange = 1 << N

horizontalLineDistance = []
verticalLineDistance = []

for i in range(preCalRange):
    railRoad = []
    tmp = i
    for j in range(N):
        railRoad.append(tmp % 2)
        tmp //= 2
    minDistance = [-1] * N
    for j in range(N):
        minDistance[j] = min(abs(Resident[j][0]),abs(Resident[j][1]))
        for k in range(N):
            if railRoad[k] == 1 and abs(Resident[j][0] - Resident[k][0]) < minDistance[j]:
                minDistance[j] = abs(Resident[j][0] - Resident[k][0])
    horizontalLineDistance.append(copy(minDistance))
    minDistance = [-1] * N
    for j in range(N):
        minDistance[j] = min(abs(Resident[j][0]),abs(Resident[j][1]))
        for k in range(N):
            if railRoad[k] == 1 and abs(Resident[j][1] - Resident[k][1]) < minDistance[j]:
                minDistance[j] = abs(Resident[j][1] - Resident[k][1])
    verticalLineDistance.append(copy(minDistance))

totalCases = 3 ** N

for i in range(totalCases):
    railRoad = []
    tmp = i
    for j in range(N):
        railRoad.append(tmp % 3)
        tmp //= 3
    horizontalCount = 0
    verticalCount = 0
    numNewRailroad = 0
    for j in range(N):
        if railRoad[j] == 1:
            numNewRailroad += 1
            horizontalCount += 1 << j
        if railRoad[j] == 2:
            verticalCount += 1 << j
            numNewRailroad += 1
    minDistance = []
    for j in range(N):
        minDistance.append(min(horizontalLineDistance[horizontalCount][j], verticalLineDistance[verticalCount][j]))

    cost = 0
    for j in range(N):
        cost += Resident[j][2] * minDistance[j]
    if minCost[numNewRailroad] == -1 or minCost[numNewRailroad] > cost:
        minCost[numNewRailroad] = cost
for elem in minCost:
    print(elem)
Problem p02610 (python)

Fixed submission:
# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import heapq

T = int(input())
for _ in range(T):
    N = int(input())
    frontCamel = []
    backCamel = []
    indifferentCamel = []
    Happiness = 0
    for _ in range(N):
        k,l,r = map(int,input().split())
        if l > r:
            frontCamel.append((k,l-r))
            Happiness += r
        elif r > l:
            backCamel.append((N-k,r-l))
            Happiness += l
        else:
            indifferentCamel.append((k,0))
            Happiness += l
    frontQ = []
    backQ = []
    frontCamel.sort(key = lambda x:x[0])
    backCamel.sort(key = lambda x:x[0])
    for Camel in frontCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(frontQ):
            heapq.heappush(frontQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(frontQ,Camel[1])
    for Camel in backCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(backQ):
            heapq.heappush(backQ,Camel[1])
        else:
            if backQ[0] < Camel[1]:
                heapq.heapreplace(backQ,Camel[1])
    Happiness += sum(frontQ)
    Happiness += sum(backQ)
    print(Happiness)

Buggy submission (verdict: Runtime Error):
# Fast IO (only use in integer input)

# import os,io
# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import heapq

T = int(input())
for _ in range(T):
    N = int(input())
    frontCamel = []
    backCamel = []
    indifferentCamel = []
    Happiness = 0
    for _ in range(N):
        k,l,r = map(int,input().split())
        if l > r:
            frontCamel.append((k,l-r))
            Happiness += r
        elif r > l:
            backCamel.append((N-k,r-l))
            Happiness += l
        else:
            indifferentCamel.append((k,0))
            Happiness += l
    frontQ = []
    backQ = []
    frontCamel.sort(key = lambda x:x[0])
    backCamel.sort(key = lambda x:x[0])
    for Camel in frontCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(frontQ):
            heapq.heappush(frontQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(frontQ,Camel[1])
    for Camel in backCamel:
        if Camel[0] == 0:
            continue
        if Camel[0] > len(backQ):
            heapq.heappush(backQ,Camel[1])
        else:
            if frontQ[0] < Camel[1]:
                heapq.heapreplace(backQ,Camel[1])
    Happiness += sum(frontQ)
    Happiness += sum(backQ)
    print(Happiness)
Problem p02613 (python)

Fixed submission:
import sys
input = sys.stdin.readline
 
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0
 
for _ in range(N):
  str1 = input()
  if str1[0] == 'A':
    AC += 1
  elif str1[0] == 'W':
    WA += 1
  elif str1[0] == 'T':
    TLE += 1
  elif str1[0] == 'R':
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Buggy submission (verdict: Runtime Error):
# Fast IO (only use in integer input) or take care about string

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for _ in range(N):
  str = input()
  if str[0] == 'A':
    AC += 1
  elif str[0] == 'W':
    WA += 1
  elif str[0] == 'T':
    TLE += 1
  elif str[0] == 'R':
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))
Problem p02617 (python)

Fixed submission:
# Fast IO (only use in integer input) or take care about string
 
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
 
N = int(input())
 
ans = 0
for i in range(N):
  ans += (N-i) * (i+1)
for _ in range(N-1):
  a,b = map(int,input().split())
  if a > b:
    c = a
    a = b
    b = c
  ans -= a * (N - b + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
# Fast IO (only use in integer input) or take care about string

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())

ans = 0
for i in range(N):
  ans += (N-i) * (i+1)
for _ in range(N-1):
  a,b = map(int,input().split())
  if a > b:
    c = a
    a = b
    b = c
  ans -= a * (n - b + 1)
print(ans)

Buggy submission (verdict: Runtime Error):
# Fast IO (only use in integer input) or take care about string

import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

N = int(input())

Ans = 0
for i in range(N):
  Ans += (N-i) * (i+1)
for _ in range(N-1):
  a,b = map(int,input().split())
  if a > b:
    c = a
    a = b
    b = c
  ans -= a * (n - b + 1)
print(ans)
Problem p02626 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
xorValue = 0
sumValue = A[0] + A[1]
for i in range(2,N):
    xorValue ^= A[i]
if sumValue % 2 != xorValue % 2:
    print(-1)
else:
    Base = (sumValue - xorValue) // 2
    if Base > A[0]:
        print(-1)
    else:
        strXOR = bin(xorValue)[2:]
        minStoneMovement = A[0] - Base
        strBase = bin(Base)[2:]
        lenStrXOR = len(strXOR)
        cannotMove = False
        if Base < 0:
            cannotMove = True
        for i in range(-1,-1 * min(len(strXOR),len(strBase)) - 1,-1):
            if strBase[i] == '1' and strXOR[i] == '1':
                cannotMove = True
                break
        if not cannotMove:
            for i in range(lenStrXOR):
                if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):
                    minStoneMovement -= 2 ** (lenStrXOR - 1 - i)
        if minStoneMovement == A[0] or cannotMove:
            print(-1)
        else:
            print(minStoneMovement)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
xorValue = 0
sumValue = A[0] + A[1]
for i in range(2,N):
    xorValue ^= A[i]
if sumValue % 2 != xorValue % 2:
    print(-1)
else:
    Base = (sumValue - xorValue) // 2
    if Base > A[0]:
        print(-1)
    else:
        strXOR = bin(xorValue)[2:]
        minStoneMovement = A[0] - Base
        strBase = bin(Base)[2:]
        lenStrXOR = len(strXOR)
        cannotMove = False
        for i in range(-1,-1 * min(len(strXOR),len(strBase)) - 1,-1):
            if Base[i] == '1' and strXOR[i] == '1':
                cannotMove = True
                break
        if not cannotMove:
            for i in range(lenStrXOR):
                if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):
                    minStoneMovement -= 2 ** (lenStrXOR - 1 - i)
        if minStoneMovement == A[0] or cannotMove:
            print(-1)
        else:
            print(minStoneMovement)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
xorValue = 0
sumValue = A[0] + A[1]
for i in range(2,N):
    xorValue ^= A[i]
if sumValue % 2 != xorValue % 2:
    print(-1)
else:
    Base = (sumValue - xorValue) // 2
    if Base > A[0]:
        print(-1)
    else:
        strXOR = bin(xorValue)[2:]
        minStoneMovement = A[0] - Base
        strBase = bin(Base)[2:]
        lenStrXOR = len(strXOR)
        cannotMove = False
        for i in range(-1,-1 * min(len(strXOR),str(Base)) - 1,-1):
            if Base[i] == '1' and strXOR[i] == '1':
                cannotMove = True
                break
        if not cannotMove:
            for i in range(lenStrXOR):
                if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):
                    minStoneMovement -= 2 ** (lenStrXOR - 1 - i)
        if minStoneMovement == A[0] or cannotMove:
            print(-1)
        else:
            print(minStoneMovement)
Problem p03946 (python)

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

a = list(map(int,input().split()))
maxDiff = 0
curMin = a[0]
for i in range(n):
  if curMin > a[i]:
    curMin = a[i]
  if maxDiff < a[i] - curMin:
    maxDiff = a[i] - curMin

isCovered = False
count = 0

curMin = a[0]

for i in range(n):
  if curMin > a[i]:
    curMin = a[i]
    isCovered = False
  if maxDiff == a[i] - curMin:
    if not isCovered:
      count += 1
      isCovered = True

print(count)

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

a = list(map(int,input().split()))
maxDiff = 0
curMin = a[0]
for i in range(n):
  if curMin > a[i]:
    curMin = a[i]
  if maxDiff < a[i] - curMin:
    maxDiff = a[i] - curMin

isCovered = False
count = 0

curMin = a[0]

for i in range(n):
  if curMin > a[i]:
    curMin = a[i]
    isCovered = False
  if maxDiff == a[i] - curMin:
    if not isCovered:
      count += 1
      isCovered = True

print(count)
Problem p02765 (python)

Fixed submission:
a,b=map(int,input().split())
print(b+100*max(10-a,0))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(b+100*max(10-a,0)
Problem p03105 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(min(b//a,c))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(max(b//a,c)
Problem p02842 (python)

Fixed submission:
import math
N = int(input())
f = False
for i in range(N+1):
    if math.floor(i * 1.08) == N:
        print(i)
        f = True
        break
if not f:
    print(':(')

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
    if math.floor(i * 1.08) == N:
        print(i)
        exit(0)
print(':(')

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
for i in range(N):
  if int(math.floor(i*1.08)) == N:
    print(i)
    return
print(-1)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(500000)
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
E = [[] for _ in range(N+1)]
D = list(zip(*[iter(D)]*2))
assert(len(D) == N+Q-1)
for i in range(N+Q-1):
  l, r = D[i][0], D[i][1]
  if i < N - 1:
  	E[l].append(r)
  	E[r].append(l)
  else:
    val[l] += r
visited = [False for _ in range(N+1)]
def dfs(c):
  visited[c] = True
  for ch in E[c]:
    if not visited[ch]:
      val[ch] += val[c]
      dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:N+1])))

Buggy submission (verdict: Runtime Error):
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+2)]
E = [[] for _ in range(N+2)]
D = list(zip(*[iter(D)]*2))
assert(len(D) == N+Q-1)
for i in range(N+Q-1):
  l, r = D[i][0], D[i][1]
  if i < N - 1:
  	E[l].append(r)
  	E[r].append(l)
  else:
    val[l] += r
visited = [False for _ in range(N+1)]
def dfs(c):
  visited[c] = True
  for ch in E[c]:
    if not visited[ch]:
      val[ch] += val[c]
      dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:])))

Buggy submission (verdict: Runtime Error):
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
E = [[] for _ in range(N+1)]
for i in range(N+Q-1):
  l, r = D[2*i], D[2*i+1]
  if i < N - 1:
  	E[l].append(r)
  	E[r].append(l)
  else:
    val[l] += r
visited = [False for _ in range(N+1)]
def dfs(c):
  visited[c] = True
  for ch in E[c]:
    if not visited[ch]:
      val[ch] += val[c]
      dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:])))

Buggy submission (verdict: Runtime Error):
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
E = [[] for _ in range(N+1)]
for i in range(N-1):
  l, r = D[2*i], D[2*i+1]
  E[l].append(r)
  E[r].append(l)
D = D[-2*Q:]
for i in range(Q):
  l, r = D[2*i], D[2*i+1]
  val[l] += r
visited = [False for _ in range(N+1)]
def dfs(c):
  visited[c] = True
  for ch in E[c]:
    if not visited[ch]:
      val[ch] += val[c]
      dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:])))

Buggy submission (verdict: Runtime Error):
N, Q, *D = map(int, open(0).read().split())
val = [0 for _ in range(N+1)]
child = [[] for _ in range(N+1)]
for i in range(N-1):
  l, r = D[2*i], D[2*i+1]
  child[l].append(r)
D = D[-2*Q:]
for i in range(Q):
  l, r = D[2*i], D[2*i+1]
  val[l] += r
def dfs(c):
  for ch in child[c]:
    val[ch] += val[c]
    dfs(ch)
dfs(1)
print(' '.join(map(str, val[1:])))
Problem p03007 (python)

Fixed submission:
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(A[-1] + sum(map(abs, A[1:-1])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
  else:
    print(A[-1], a)
    A[-1] -= a
print(A[-1], A[0])

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

using namespace std;
using i64 = int64_t;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for(auto&& x:A)cin >> x;
    sort(A.begin(), A.end());
    int sum = 0;
    for(int i=1;i<N-1;i++)sum += abs(A[i]);
    cout << A[N-1] + sum - A[0] << endl;
    for(int i=1;i<N-1;i++){
        if(A[i] < 0){
            cout << A[N-1] << " " << A[i] << endl;
            A[N-1] -= A[i];
        }else{
            cout << A[0] << " " << A[i] << endl;
            A[0] -= A[i];
        }
    }
    cout << A[N-1] << " " << A[0] << endl;
    return 0;
}
Problem p03274 (python)

Fixed submission:
def dist(a, b):
  if a * b < 0:
    return 2 * min(abs(a), abs(b)) + max(abs(a), abs(b))
  else:
    return max(abs(a), abs(b))

def solve(A, K):
  ans = dist(A[0], A[K-1])
  for i in range(len(A)-K+1):
    ans = min(ans, dist(A[i], A[i+K-1]))
  return ans
               
N, K, *A = map(int, open(0).read().split())
print(solve(A, K))

Buggy submission (verdict: Runtime Error):
def dist(a, b):
  if a * b < 0:
    return 2 * min(abs(a), abs(b)) + max(abs(a), abs(b))
  else:
    return max(abs(a), abs(b))

def solve(A, K):
  ans = dist(A[0], A[K])
  for i in range(len(A)-K+1):
    ans = min(ans, dist(A[i], A[i+K-1]))
  return ans
               
N, K, *A = map(int, open(0).read().split())
print(solve(A, K))
Problem p03473 (python)

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

Buggy submission (verdict: Runtime Error):
print(24+24-int(input())
Problem p03651 (python)

Fixed submission:
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  g = A[0]
  for a in A:
    g = gcd(g, a)
  if K % g == 0 and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def gcd(l, r):
  while r != 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = abs(A[1] - A[0])
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if (K % g) == (A[0] % g) and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def gcd(l, r):
  while r != 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if (K % g) == (A[0] % g) and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  if N == 1:
    if K == A[0]:
      print('POSSIBLE')
      return
    else:
      print('IMPOSSIBLE')
      return
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, abs(A[i+1] - A[i]))
  if K % g == A[0] % g and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
def gcd(l, r):
  while r > 0:
    l, r = r, l % r
  return l

def main():
  N, K, *A = map(int, open(0).read().split())
  g = A[1] - A[0]
  for i in range(N-1):
    g = gcd(g, A[i+1] - A[i])
  if K % g == A[0] % g and K <= max(A):
    print('POSSIBLE')
  else:
    print('IMPOSSIBLE')

if __name__ == '__main__':
  main()
Problem p04025 (python)

Fixed submission:
N, *a = map(int, open(0).read().split())
ave = round(sum(a) / N)
ans = 0
for x in a:
  ans += (x - ave) * (x - ave)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, *a = map(int, open(0).read().split())
ave = math.round(sum(a) / N)
ans = 0
for x in a:
  ans += (x - ave) * (x - ave)
print(ans)
Problem p02603 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)N = int(input())
a = list(map(int, input().split()))
slst = []
llst = []
stmp = 201
ltmp = 0
for i in a:
    if stmp >= i:
        stmp = i
    else:
        slst.append(stmp)
        stmp = i

for i in reversed(a):
    if ltmp <= i:
        ltmp = i
    else:
        llst.insert(0, ltmp)
        ltmp = i

total = 1000
for i in range(len(slst)):
    cnt = total // slst[i]
    total -= (slst[i] * cnt)
    total += (llst[i] * cnt)

print(total)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
a = list(map(int, input().split()))
chk = [0] * N
start = -1
ido = [0]
chk[0] = 1
index = 0
cnt = 0
while True:
    index = a[index] - 1
    if chk[index] == 0:
        chk[index] += 1
        cnt += 1
        ido.append(index)
    else:
        start = index
        break

if cnt >= K:
    print(ido[K] + 1)
    exit()
tmp = ido.index(start)
ido = ido[tmp:]
K -= tmp
print(ido[K % len(ido)] + 1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
a = list(map(int, input().split()))
chk = [0] * N
start = -1
ido = [0]
chk[0] = 1
index = 0
cnt = 0
while True:
    index = a[index] - 1
    if chk[index] == 0:
        chk[index] += 1
        cnt += 1
        ido.append(index)
    else:
        start = index
        break

if cnt > K:
    print(a[ido[K]])
    exit()
tmp = ido.index(start)
ido = ido[index:]
K -= tmp
print(ido[K % len(ido)] + 1)
Problem p03059 (python)

Fixed submission:
a, b, t = map(int, input().split())
print(b*(t//a))

Buggy submission (verdict: Runtime Error):
a, b, t = map(int, input().split)
print(b*(t//a))
Problem p03260 (python)

Fixed submission:
print(" YNeos"[eval(input().replace(" ","*"))%2::2])

Buggy submission (verdict: Runtime Error):
print(" YNeos"eval(input()).replace(" ","*")%2::2))