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

Fixed submission:
import math

n = int(input())

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
    
def lcm(x,y):
	return (x * y) // gcd(x, y)

ct = 1
for _ in range(n):
	t = int(input())
	ct = lcm(ct,t)
	
print(ct)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

def lcm(x,y):
	return (x * y) // math.gcd(x, y)

ct = 1
for _ in range(n):
	t = int(input())
	ct = lcm(ct,t)
	
print(ct)
Problem p03044 (python)

Fixed submission:
N = int(input())
nodes = [set() for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u, v = (u - 1, v - 1)
    nodes[u].add((v, w))
    nodes[v].add((u, w))


ans = [-1 for _ in range(N)]
q = [(0, 0, -1)]

while q:
    v, dist, parent = q.pop()

    if dist % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1

    for u, w in nodes[v]:
        if u == parent:
            continue

        q.append((u, dist + w, v))

print("\n".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
N = int(input())
nodes = [set() for _ in range(N)]
for line in sys.stdin:
    u, v, w = map(int, line.split())
    u, v = (u - 1, v - 1)
    nodes[u].add((v, w))
    nodes[v].add((u, w))


ans = [-1 for _ in range(N)]
q = [(0, 0, -1)]

while q:
    v, dist, parent = q.pop()

    if dist % 2 == 0:
        ans[v] = 0
    else:
        ans[v] = 1

    for u, w in nodes[v]:
        if u == parent:
            continue

        q.append((u, dist + w, v))

print("\n".join(map(str, ans)))
Problem p03076 (python)

Fixed submission:
if __name__ == '__main__':
    T = [int(input()) for _ in range(5)]
    
    del_max = -1
    idx_max = 0
    for i in range(5):
        if T[i]%10 == 0:
            pass
        elif 10 - T[i]%10 > del_max:
            del_max = 10 - T[i]%10
            idx_max = i
    
    count = 0
    for i in range(5):
        if i != idx_max:
            time = (T[i]//10)*10
            if time < T[i]:
                time += 10
            count += time
    count += T[idx_max]
    
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    T = [int(input()) for _ in range(5)]
    
    del_max = -1
    idx_max = None
    for i in range(5):
        if T[i]%10 == 0:
            pass
        elif 10 - T[i]%10 > del_max:
            del_max = 10 - T[i]%10
            idx_max = i
    
    count = 0
    for i in range(5):
        if i != idx_max:
            time = (T[i]//10)*10
            if time < T[i]:
                time += 10
            count += time
    count += T[idx_max]
    
    print(count)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    T = [int(input()) for _ in range(5)]
    
    del_max = 0
    idx_max = None
    for i in range(5):
        if T[i]%10 == 0:
            pass
        elif 10 - T[i]%10 > del_max:
            del_max = max(T[i]%10 - 5, 5 - T[i]%10)
            idx_max = i
    
    count = 0
    for i in range(5):
        if i != idx_max:
            time = (T[i]//10)*10
            if time < T[i]:
                time += 10
            count += time
    count += T[idx_max]
    
    print(count)
Problem p03087 (python)

Fixed submission:
if __name__ == '__main__':
    N, Q= map(int, input().split())
    S = str(input())
    L = [list(map(int, input().split())) for _ in range(Q)]
    
    nums = [0]*(N-1)
    
    for i in range(N-1):
        if S[i] == 'A' and S[i+1] == 'C':
            nums[i] += 1

    for i in range(1, len(nums)):
        nums[i] = nums[i] + nums[i-1]
    
    nums = [0] + nums
    
    for l, r in L:
        print(nums[r-1] - nums[l-1])

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N, Q= map(int, input().split())
    S = str(input())
    L = [list(map(int, input().split())) for _ in range(Q)]
    
    nums = [0]*(N-1)
    
    for i in range(N):
        if S[i] == 'A' and S[i+1] == 'C':
            nums[i] += 1

    for i in range(1, len(nums)):
        nums[i] = nums[i] + nums[i-1]
    
    nums = [0] + nums
    
    for l, r in L:
        print(nums[r-1] - nums[l-1])
Problem p03095 (python)

Fixed submission:
from collections import defaultdict
if __name__ == '__main__':
    mod = 10**9 +7
    N = int(input())
    S = str(input())
    
    letter = defaultdict(int)
    for i in range(N):
        letter[S[i]] += 1
    count = 1
    for c in letter:
        count *= (letter[c]+1)
        count %= mod
    print(count-1)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    mod = 10**9 +7
    N = int(input())
    S = str(input())
    
    letter = defaultdict(int)
    for i in range(N):
        letter[S[i]] += 1
    count = 1
    for c in letter:
        count *= (letter[c]+1)
        count%mod
    print(count-1)
Problem p03359 (python)

Fixed submission:
if __name__ == '__main__':
    a, b = map(int, input().split())
    if a > b:
        print(a-1)
    elif a <= b:
        print(a)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
  a, b = map(int, input().split())
  if a >= b:
    print(a)
  elif a < b:
	print(a-1)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
  a, b = map(int, input())
  if a >= b:
    print(a)
  elif a < b:
    print(b)
Problem p03434 (python)

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        if A:
            Bob += max(A)
            A.remove(max(A))
    print(Alice - Bob)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    Alice = 0
    Bob = 0
    while(A):
        Alice += max(A)
        A.remove(max(A))
        Bob += max(A)
        A.remove(max(A))
    print(Alice - Bob)
Problem p03457 (python)

Fixed submission:
if __name__ == '__main__':
    N = int(input())
    t = [None]*N
    x = [None]*N
    y = [None]*N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())
    flag=True
    # check first step
    if (t[0] - max(x[0], -x[0]) - max(y[0], -y[0])) %2 != 0 or t[0] < max(x[0], -x[0]) + max(y[0], -y[0]):
        print('No')
        flag = False
    
    for i in range(N-1):
        delta_t = t[i+1] - t[i]
        delta_x = x[i+1] - x[i]
        if delta_x < 0:
            delta_x = -delta_x
        delta_y = y[i+1] - y[i]
        if delta_y < 0:
            delta_y = -delta_y
        delta = delta_x + delta_y
        if (delta_t - delta) % 2 == 0 and delta_t >= delta:
            continue
        else:
            if flag:
                print('No')
                flag = False
            break
    if flag:
        print('Yes')

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    N = int(input())
    t = [None]*N
    x = [None]*N
    y = [None]*N
    for i in range(N):
        t[i], x[i], y[i] = map(int, input().split())
    flag=True
    # check first step
    if (t[0] - max(x[0], -x[0]) - max(y[0], -y[0])) %2 != 0 or t[0] < max(x[0], -x[0]) + max(y[0], -y[0]):
        print('No')
        flag = False
    
    for i in range(N):
        delta_t = t[i+1] - t[i]
        delta_x = x[i+1] - x[i]
        if delta_x < 0:
            delta_x = -delta_x
        delta_y = y[i+1] - y[i]
        if delta_y < 0:
            delta_y = -delta_y
        delta = delta_x + delta_y
        if (delta_t - delta) % 2 == 0 and delta_t >= delta:
            continue
        else:
            print('No')
            flag = False
            break
    if flag:
        print('Yes')
Problem p03573 (python)

Fixed submission:
if __name__ == '__main__':
  A, B, C = map(int, input().split())
  if A == B:
    print(C)
  elif A == C:
    print(B)
  else:
    print(A)

Buggy submission (verdict: Runtime Error):
if __name__ = '__main__':
  A, B, C = map(int, input().split())
  if A == B:
    print(C)
  elif A == C:
    print(B)
  else:
    print(A)
Problem p03633 (python)

Fixed submission:
import sys

sys.setrecursionlimit = 10000000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    ans = 1
    for t in T:
        gcd = get_gcd(ans, t)
        ans = t//gcd*ans
        
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit = 100000

def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)
           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    for n in range(N-1):
        gcd = get_gcd(T[n], T[n+1])
        T[n+1] = int(T[n]/gcd)*T[n+1]
        
    print(T[N-1])

Buggy submission (verdict: Runtime Error):
def get_gcd(A, B):
    r = A%B
    if r == 0:
        return B
    else:
        return get_gcd(B, r)

           
if __name__ == '__main__':
    N = int(input())
    T = [int(input()) for _ in range(N)]
    
    for n in range(N-1):
        gcd = get_gcd(T[n], T[n+1])
        T[n+1] = int(T[n]/gcd)*T[n+1]
        
    print(T[N-1])
Problem p02918 (python)

Fixed submission:
N,K = list(map(int, input().split(" ")))
p = input()
cnt = 0
for i in range(N):
  if p[i]=="L" and i!=0:
    if p[i]==p[i-1]:
      cnt += 1
  elif p[i]=="R" and i!=N-1:
    if p[i]==p[i+1]:
      cnt += 1
cnt += 2*K
if cnt>=N:
  cnt = N-1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,K = int(input())
p = list(map(int, input().split(" ")))
cnt = 0
for i in range(N):
  if p[i]=="l" and i!=0:
    if p[i]==p[i-1]:
      cnt += 1
  elif p[i]=="r" and i!=N-1:
    if p[i]==p[i+1]:
      cnt += 1
cnt += 2*K
if cnt>=N:
  cnt = N-1
print(cnt)
Problem p02923 (python)

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


maxcount = 0
count = 0
for i in range(n-1):
    if hs[i+1] - hs[i] == 0:
        count += 1
    elif hs[i+1] - hs[i] < 0:
        count += 1
    else:
        if count >= maxcount:
            maxcount = count
        count = 0


print(max(count, maxcount))

Buggy submission (verdict: Runtime Error):
import sys

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

gap = []
for i in range(n-1):
    if hs[i+1] - hs[i] == 0:
        gap.append(0)
    elif hs[i+1] - hs[i] > 0:
        gap.append(1)
    else:
        gap.append(-1)


maxcount = 0
count = 0
g_prev = gap[0]

for g in gap:
    if g == 1:
        g_prev = g
        continue
    if g == g_prev:
        count += 1
    elif g == 0:
        count += 1
    else:
        if count >= maxcount:
            maxcount = count
        count = 1
    g_prev = g

print(max(count, maxcount))
Problem p02995 (python)

Fixed submission:


a, b, c, d = map(int, input().split())


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

def lcm(x, y):
    return (x * y) // gcd(x, y)

cd = lcm(c, d)

div_c = b // c - (a-1)//c
div_d = b // d - (a-1)//d
div_cd = b // cd - (a-1)//cd
count = b - a + 1 - div_c - div_d + div_cd
print(count)

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

cd = lcm(c, d)

div_c = b // c - (a-1)//c
div_d = b // d - (a-1)//d
div_cd = b // cd - (a-1)//cd
count = b - a + 1 - div_c - div_d + div_cd
print(count)
Problem p02997 (python)

Fixed submission:
# https://img.atcoder.jp/abc131/editorial.pdf

import sys

n, k = map(int, input().split())

maxPossible = (n-2) * (n-1) // 2

if k > maxPossible:
    print(-1)
    sys.exit()
ret = []

# うに(1が中心)
for i in range(2, n+1):
    ret.append((1, i))

# maxPossible - k 個の辺を追加
count = 0
for i in range(2, n+1):
    if count == maxPossible - k:
        break
    for j in range(i+1, n+1):
        ret.append((i, j))
        count += 1
        if count == maxPossible - k:
            break

print(len(ret))
for u, v in ret:
    print(u, v)

Buggy submission (verdict: Runtime Error):
# https://img.atcoder.jp/abc131/editorial.pdf

import sys

n, k = map(int, input().split())

# n個の頂点から2つ選ぶ組み合わせ
comb = n*(n-1)/2

v = comb - (n-1)

# そのうちn-1組は距離１なので...
if k > v:
    print(-1)
    sys.exit()

# それ以外の場合(k <= comb - (n-1))は必ず解がある
# 「うに」を考える

add_edge = v - k

m = n - 1 + add_edge
print(m)

# まずはうにの辺を出力（n-1本）, １はうにの中心
for i in range(n-1):
    print(1, 2+i)

# その後 add_edgeを出力
for i in range(add_edge):
    start = 2*i + 2
    end = start+1
    print(start, end)
Problem p02999 (python)

Fixed submission:

X, A = map(int, input().split())

if(X < A):
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
# 尺取り法
import sys

def input():
    return sys.stdin.readline()[:-1]

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

count = 0
right = 0
sum = 0
for left in range(N):
    while(sum < K):
        if right == N:
            break
        else:
            sum += a[right]
            right += 1
    if sum < K:
        break
    count += N - right + 1
    sum -= a[left]

print(count)

Buggy submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline()[:-1]

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

from itertools import accumulate
count = 0
acum = list(accumulate(a))

for i in range(N-1, -1, -1):
    if acum[i] >= K:
        count += 1
    else:
        break

for i in range(N):
    for j in range(N-1, i, -1):
        s = acum[j]-acum[i]
        if s >= K:
            count += 1
        else:
            break

print(count)
Problem p03035 (python)

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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)

Buggy submission (verdict: Runtime Error):

import sys

def input():
    return sys.stdin.readline()[:-1]

n, m = map(int, input().split())

# 0 - n-1
a = sorted(list(map(int, input().split())))

for j in range(m):
    b, newVal = map(int, input().split())
    if b >= n:
        a_new = [i if i >= newVal else newVal for i in a]
    else:
        mae = a[:b]
        ato = a[b:]
        mae_new = [i if i >= newVal else newVal for i in mae]
        mae_new.extend(ato)
        a = sorted(mae_new)

print(sum(a))
Problem p03085 (python)

Fixed submission:

a = input()
if a == "A":
    print("T")
elif a == "T":
    print("A")
elif a == "G":
    print("C")
else:
    print("G")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    #tmp = {}
    # tmp = {i for i in range(a-1,b-1)}
    # print(tmp)
    # print(len(tmp&p))
    count=0
    for j in p:
        #print("j",j)
        if a <= j+1 and j+1 < b:
            count+=1
        elif j > b:
            break
    print(count)
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = input()
p = [0]*(N)
a = 0
for i in range(-1,N-2):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
p = [0]*(N+1)
a = 0
for i in range(-1,N-1):
    if S[i+1] == "A" and S[i+2]=="C":
        a+=1
    p[i+2]=a
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    print(p[b-1] - p[a-1])
Problem p03195 (python)

Fixed submission:
A = int(input())
ls = [int(input())%2 for i in range(A)]
if ls.count(1) != 0:
    print("first")
else:
    print("second")

Buggy submission (verdict: Runtime Error):
A = int(input())
ls = [int(input())%2 for i in range(A)]
if ls.count(1) % 2 == 1 or (A % 2 == 0 and s.count(1) % 2 == 0):
    print("first")
else:
    print("second")
Problem p03241 (python)

Fixed submission:
N,T  = list(map(int,input().split()))
d = int(T / N)
def ans():
    for i in range(d+1,0,-1):    
            if T % i ==0:
                print(i)
                break
if T % N == 0:
    print (d)
else:
    ans()

Buggy submission (verdict: Runtime Error):
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = []
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m.append(i)
    print (m[-1])
if T % N == 0:
    print (d)
else:
    ans()

Buggy submission (verdict: Runtime Error):
import math
N,T  = list(map(int,input().split()))
#d = int(T / N)
m = 1
def ans():
    for i in range(1,int(math.sqrt(T))):    
            if T % i ==0:
                m = max(1,i)
    print (m)
if T % N == 0:
    print (d)
else:
    ans()

Buggy submission (verdict: Runtime Error):
N,T  = map(int,input().split())
if T % N == 0:
    print (int(T / N))

d = int(T / N)
else:
    for i in range(d+1,0,-1):    
        if T % i ==0:
            print(i)
            break
Problem p03290 (python)

Fixed submission:
# coding: utf-8
# Your code here!

D,G = map(int,input().split()) # D問題数,G目標点
lst = [list(map(int,input().split()))for i in range(D)]
ans = float('inf')
for i in range(1 << D): # 全探索
    tmp = 0
    count = 0
    bit = ""
    for j in range(len(lst)):
        bit+=str((i >> j)&1)
        if ((i >> j) & 1) == 1:
            tmp = tmp + lst[j][1] + ((j + 1) * 100 * lst[j][0])
            count+=lst[j][0]
    #print("tmp",tmp)
    if tmp < G : #or tmp >= G
        #print(bit)
        for n,k in enumerate(list(bit)):
            if k == "0":
                for p in range(lst[len(bit) - n - 1][0]):
                    t = p * 100 * (n+1)
                    #print("p",p,t,tmp,G,count)
                    if t + tmp >= G:
                        ans = min(ans,p+count)
    
    #if tmp >= G :
    else:
        ans = min(ans,count)
    #print(ans,tmp,count)
print(int(ans))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

D,G = map(int,input().split()) # D問題数,G目標点
lst = [list(map(int,input().split()))for i in range(D)]
ans = float('inf')
for i in range(1 << D): # 全探索
    tmp = 0
    count = 0
    bit = ""
    for j in range(len(lst)):
        bit+=str((i >> j)&1)
        if ((i >> j) & 1) == 1:
            tmp = tmp + lst[j][1] + ((j + 1) * 100 * lst[j][0])
            count+=lst[j][0]
    #print("tmp",tmp)
    if tmp < G or tmp >= G:
        #print(bit)
        for n,k in enumerate(list(bit)):
            if k == "0":
                for p in range(lst[len(bit) - n - 1][0]):
                    t = p * 100 * (n+1)
                    #print("p",p,t,tmp,G,count)
                    if t + tmp >= G:
                        ans = min(ans,p+count)
    
    #if tmp >= G :
    else:
        ans = min(ans,count)
    #print(ans,tmp,count)

print(int(ans))
Problem p03067 (python)

Fixed submission:
#a.py
A,B,C = map(int,input().split())
if A < C and C < B:
  print('Yes')
  exit()
if B < C and C < A:
  print('Yes')
  exit()
print('No')

Buggy submission (verdict: Runtime Error):
c = map(int,input().split())
if c[0] < c[2] and c[2] < c[1]:
  print('Yes')
  exit()
if c[0] > c[2] and c[2] > c[1]:
  print('Yes')
  exit()
print('No')
Problem p03261 (python)

Fixed submission:
import collections

N = int(input())
W = [input() for i in range(N)]
c = collections.Counter(W)

for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
if len(c) != N:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import collecions

N = int(input())
W = [input() for i in range(N)]
c = collecions.Counter(W)

for i in range(N-1):
    if W[i][-1] != W[i+1][1]:
        print("No")
        exit()
if len(c) != N:
    print("No")
    exit()
print("Yes")
Problem p03274 (python)

Fixed submission:
N, K = map(int,input().split())
x = list(map(int,input().split()))

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
	cur1 = abs(x[l]) + abs(x[r]-x[l])
	cur2 = abs(x[r]) + abs(x[r]-x[l])
#	print([l,r,cur1,cur2])
	if cur1 < MIN:
		MIN = cur1
	if cur2 < MIN:
		MIN = cur2
print(MIN)

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

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K - 1
		cur1 = 2*abs(x[l]) + abs(x[r]-x[l])
		cur2 = abs(x[l]) + 2*abs(x[r]-x[l])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)

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

o = 0
if x[N-1] <= 0:
	print(x[N-K])
	exit()
if x[0] >= 0:
	print(x[K-1])
	exit()

MIN = float("inf")
for i in range(N-K+1):
	l = i
	r = i + K
		cur1 = 2*abs(x[l]) + abs(x[r]-x[l])
		cur2 = abs(x[l]) + 2*abs(x[r]-x[l])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)

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

o = 0
if x[N-1] <= 0:
	print(x[N-K])
	exit()
if x[0] >= 0:
	print(x[K-1])
	exit()
if 0 in x:
	i = x.index(0)
	del x[i]
	N,K = N-1,K=1

while x[o] < 0:
	o += 1
	if o == N-1:
		break

MIN = float("inf")
for i in range(-K-1,K+1,1):
	l = o - i+1
	r = o + K-i
	if not(l < 0 or l >= N or r < 0 or r >= N):
		cur1 = 2* abs(x[l]) + abs(x[r])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)

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

o = 0
if x[N-1] < 0:
	print(x[N-K])
	exit()
if x[0] > 0:
	print(x[K-1])
	exit()

while x[o] < 0:
	o += 1
	if o == N-1:
		break

MIN = float("inf")
for i in range(-K-1,K+1,1):
	l = o - i+1
	r = o + K-i
	if not(l < 0 or l >= N or r < 0 or r >= N):
		cur1 = 2* abs(x[l]) + abs(x[r])
		cur2 = abs(x[l]) + 2*abs(x[r])
#		print([l,r,cur1,cur2])
		if cur1 < MIN:
			MIN = cur1
		if cur2 < MIN:
			MIN = cur2
print(MIN)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
if K == 1:
	print(S[0])
	exit()
else:
	i = 0
	K -= 1
	while S[i] == "1" and K > 0:
		i += 1
		K -= 1
	print(S[i])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
if K == 1:
	print(S[0])
	exit()
i = 0
while S[i] == "1":
	i += 1
print(S[i])

Buggy submission (verdict: Runtime Error):
S = int(input())
K = int(input())
if K == 1:
	print(S[0])
	exit()
i = 0
while S[i] == "1":
	i += 1
print(S[i])
Problem p03283 (python)

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

C = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
	L,R = map(int,input().split())
	C[L][R] += 1


D = [[0 for i in range(N+4)] for j in range(N+4)]
E = [0 for i in range(N+4)]
F = [[0 for i in range(N+4)] for j in range(N+4)]
for i in range(N+1):
	for j in range(N+1):
		D[i][j+1] = D[i][j] + C[i][j]
for i in range(N+1):
	E[i+1] = E[i] + D[i][i]
for i in range(N+2):
	for j in range(N+2):
		F[i+1][j] = F[i][j] + D[i][j]

# C[l][l] + ... + C[l][r] = D[l][r+1] - D[l][l]
# C[i][i] + ... + C[i][r] = D[i][r+1] - D[i][i]
# C[r][r] + ... + C[r][r] = D[r][r+1] - D[r][r]

for j in range(Q):
	p,q = map(int,input().split())
	s = F[q+1][q+1] - F[p][q+1] - (E[q+1] - E[p])
	print(s)

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

C = [[0 for in range(N)] in range(N)]
for i in range(M):
	L,R = map(int,input().split())
	C[L][R] += 1

for j in range(Q):
	p,q = map(int,input().split())
	s = 0
	for i in range(p,q+1):
		for j in range(p,q+1):
			s += C[i][j]
	print(s)
Problem p03287 (python)

Fixed submission:
from collections import Counter
c = Counter()

N, M = map(int,input().split())
a = list(map(int,input().split())) 
s = 0
c[s] += 1
for i in range(N):
  s = (s + a[i]) % M
  c[s] += 1
# print(c)
S=0
# t=0
for (i,k) in c.items():
  if k > 1:
    S += (k-1)*k//2
  # t += k
print(S)
# print(t)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from itertools import accumulate
from functools import reduce

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

c = Counter([0] + [x % M for x in accumulate(A)])
ans = reduce(add, [v*(v-1)//2 for v in c.values()])
print(ans)