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

Fixed submission:
N,M,X=list(map(int,input().split()))
C=[list(map(int,input().split())) for i in range(N)]
result=[]
for i in range(2**N):
    A=[]
    for j in range(N):
        if (i>>j)&1:
            A.append(C[j])
    result.append(A)
inf=float('inf')
ans2=inf

for i in result:
    D=dict()
    ans1=0
    ans3=0
    if i!=[]:
        for j in i:
            ans1+=j[0]
            for k,value in enumerate(j):
                if k!=0:
                    D[k]=D.get(k,0)+value
            
        for j in D.values():
            if j>=X:
                ans3+=1
        if ans3==M:
            ans2=min(ans2,ans1)
if ans2==inf:
    print(-1)
else:
    print(ans2)

Buggy submission (verdict: Runtime Error):
N,M,X=list(map(int,input().split()))
C=[list(map(int,input().split())) for i in range(N)]
result=[]
for i in range(2**N):
    A=[]
    for j in range(N):
        if (i>>j)&1:
            A.append(C[j])
    result.append(A)
inf=float('inf')
ans2=inf

for i in result:
    D=dict()
    ans1=0
    if i!=[]:
        for j in i:
            ans1+=j[0]
            D[1]=D.get(1,0)+j[1]
            D[2]=D.get(2,0)+j[2]
            D[3]=D.get(3,0)+j[3]
            
        if (D[1]>=X) and (D[2]>=X) and (D[3]>=X):
            ans2=min(ans2,ans1)
if ans2==inf:
    print(-1)
else:
    print(ans2)
Problem p02706 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=N-sum(A)
if ans<0:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=map(int,input().split())
if N>=sum(A):
    print(N-sum(A))
else:
    print(-1
Problem p02714 (python)

Fixed submission:
N=int(input())
S=input()
# N=int(Input[0][0])
# S=Input[1][0]
import math
count=0
counter={'R':0,'G':0,'B':0}
for i in S:
    counter[i]+=1
s=counter['R']*counter['G']*counter['B']
for i in range(1,N-1):
    for j in range(i+1,N):
        k=2*j-i
        if k<=N and (S[i-1]!=S[j-1] and S[i-1]!=S[k-1] and S[j-1]!=S[k-1]):
                count+=1
print(s-count)

Buggy submission (verdict: Runtime Error):
N=int(Input[0][0])
S=Input[1][0]
import math
count=0
counter={'R':0,'G':0,'B':0}
for i in S:
    counter[i]+=1
s=counter['R']*counter['G']*counter['B']
for i in range(1,N-1):
    for j in range(i+1,N):
        k=2*j-i
        if k<=N and (S[i-1]!=S[j-1] and S[i-1]!=S[k-1] and S[j-1]!=S[k-1]):
                count+=1
print(s-count)
Problem p02719 (python)

Fixed submission:
N,K=list(map(int,input().split()))
print(min(N%K,K-N%K))

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
ans=N
A=set()
while ans>0:
    A.add(ans)
    ans=ans-K
    A.add(ans)
print(min([abs(i) for i in A]))
Problem p02732 (python)

Fixed submission:
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
counter=[0 for i in range(N+1)]
ans2=[0 for i in range(N+1)]
B=[]
for i in A:
    counter[i]+=1
ans=[0 for i in range(N+1)]
for i,value in enumerate(counter):
    if value>0:
        ans[i]=(value*(value-1)//2)
        ans2[i]=((value-1)*(value-2)//2)
total=sum(ans)
for i in A:
    temp=total
    temp-=ans[i]
    temp+=ans2[i]
    print(temp)

Buggy submission (verdict: Runtime Error):
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
I=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(I)
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)/(f(2)*f(i-2)))
    print(int(sum(B)))

Buggy submission (verdict: Runtime Error):
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
I=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(I)
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)/(f(2)*f(i-2)))
    print(int(sum(B)))

Buggy submission (verdict: Runtime Error):
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
In=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(In)
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)//(f(2)*f(i-2)))
    print(sum(B))

Buggy submission (verdict: Runtime Error):
import copy
# In=[list(map(int,i.split())) for i in Input.split('\n')]
# N=In[0][0]
# A=In[1]
N=int(input())
A=list(map(int,input().split()))
for j in range(N):
    counter=[0 for i in range(N+1)]
    A=copy.deepcopy(In[1])
    A.pop(j)
    B=[]
    for i in A:
        counter[i]+=1
    for i in counter:
        if i>1:
            B.append(f(i)//(f(2)*f(i-2)))
    print(sum(B))
Problem p02755 (python)

Fixed submission:
A,B=list(map(int,input().split()))
ans=[]
for i in range(10):
    if A==(8*B*10+8*i)//100:
        ans.append(i)
if ans==[]:
    print(-1)
else:
    print(B*10+min(ans))

Buggy submission (verdict: Runtime Error):
A,B=list(map(int,input().split()))
ans=[]
for i in range(1,1010):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans.append(i)
print(min(ans))
Problem p02760 (python)

Fixed submission:
import sys
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[list(map(int,input().split())) for i in range(N)]
flat=[j for i in A for j in i]
for i,value in enumerate(flat):
    if [value] in b:
         flat[i]=-1
for i in range(3):
    if flat[i*3]==flat[i*3+1]==flat[i*3+2]==-1:
        print('Yes')
        sys.exit()
    if flat[i]==flat[i+3]==flat[i+6]==-1:
        print('Yes')
        sys.exit()
if flat[0]==flat[4]==flat[8]==-1 or flat[2]==flat[4]==flat[6]==-1:
    print('Yes')
    sys.exit()
print('No')

Buggy submission (verdict: Runtime Error):
import sys
A=[list(map(int,input().split())) for i in range()]
N=int(input())
b=[list(map(int,input().split())) for i in range(N)]
flat=[j for i in A for j in i]
for i,value in enumerate(flat):
    if [value] in b:
         flat[i]=-1
for i in range(3):
    if flat[i]==flat[i+1]==flat[i+2]==-1:
        print('Yes')
        sys.exit()
    if flat[i]==flat[i+3]==flat[i+6]==-1:
        print('Yes')
        sys.exit()
if flat[0]==flat[4]==flat[8]==-1 or flat[2]==flat[4]==flat[6]==-1:
    print('Yes')
    sys.exit()
print('No')
Problem p02761 (python)

Fixed submission:
N,M=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
import sys
S=[-1 for i in range(N)]
visited=[[] for i in range(N)]

for i in A:
    S[i[0]-1]=i[1]
    visited[i[0]-1].append(i[1])
for i in visited:
    if len(set(i))>1:
        print(-1)
        sys.exit()
if len(S)>1:
    if S[0]==0:
        print(-1)
        sys.exit()
    if S[0]==-1:
        S[0]=1

for i,value in enumerate(S):
    if value==-1:
        S[i]=0

print(*S,sep='')

Buggy submission (verdict: Runtime Error):
N,M=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
import sys
S=[-1 for i in range(N)]
visited=[[] for i in range(N)]

for i in A:
    S[i[0]-1]=i[1]
    visited[i[0]-1].append(i[1])
for i in visited:
    if len(set(i))>1:
        print(-1)
        sys.exit()
if len(S)>1
    if S[0]==0:
        print(-1)
        sys.exit()
    if S[0]==-1:
        S[0]=1

for i,value in enumerate(S):
    if value==-1:
        S[i]=0

print(*S,sep='')

Buggy submission (verdict: Runtime Error):
N,M=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
import sys
S=[-1 for i in range(N)]
visited=[[] for i in range(N)]

for i in A:
    S[i[0]-1]=i[1]
    visited[i[0]-1].append(i[1])
for i in visited:
    if len(set(i))>1:
        print(-1)
        sys.exit()
if len(S)>1
    if S[0]==0:
        print(-1)
        sys.exit()
    if S[0]==-1:
        S[0]=1

for i,value in enumerate(S):
    if value==-1:
        S[i]=0

print(*S,sep='')
Problem p02768 (python)

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

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)

Buggy submission (verdict: Runtime Error):
p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)
Problem p02861 (python)

Fixed submission:
import itertools as it
import math
from statistics import mean
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
A=[]
for i in list(it.permutations(X,N)):
    B=[]
    for j in range(N-1):
        B.append(math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2))
    A.append(sum(B))
print(mean(A))

Buggy submission (verdict: Runtime Error):

import itertools as it
import math
from statistics import mean
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
A=[]
for i in list(it.permutations(X,N)):
    B=[]
    for j in range(N-1):
        B.append(math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2))
    A.append(sum(B))
print(mean(A))
Problem p04044 (python)

Fixed submission:
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
b=a[0]+a[1]+a[2]
print(b)

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
b=a[0]+a[1]+a[2]
print(b)

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(a[0]+a[1]+a[2])

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(a[0]+a[1]+a[2])
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()

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

lis = [1] * 100
for p in P: lis[p-1] -= 1

for i in range(100):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()

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

lis = [1] * 100
for p in P: lis[p-1] -= 1

for i in range(50):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()

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

lis = [1] * 100
print(lis)
for p in P: lis[p-1] -= 1
print(lis)

for i in range(50):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()
Problem p02684 (python)

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

s = []
ord = [-1]*(n+1)
c = 1
l = 0


v = 1
while (ord[v] == -1):
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
    
c = len(s) - ord[v]
l = ord[v]


if (k < l): print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])

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

D = 60
MAX_N = 200005
to[D][MAX_N]

for i in range(n):
    to[0][i] = int(input())
    to[0][i] -= 1

for i in range(i, D-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]

v = 0
for i in range(D-1,0):
    l = 1<<i
    if (l <= k):
        v = to[i][v]
        k -= l

print(v+1)
Problem p02687 (python)

Fixed submission:
S=input()
if S=='ABC':
    print('ARC')
else :
    print('ABC')

Buggy submission (verdict: Runtime Error):
S=input()
if S=='ABC':
    print('ARC')
else S:
    print('ABC')
Problem p02713 (python)

Fixed submission:
N = int(input())
N = N+1
sum = 0

from math import gcd

for i in range(1, N):
    for j in range(1, N):
        for k in range(1, N):
            sum += gcd(gcd(i, j), k)

print( sum )

Buggy submission (verdict: Runtime Error):
N = int(input())
N = N+1
sum = 0

import math

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1, N):
    for j in range(1, N):
        for k in range(1, N):
            sum += gcd(gcd(i, j), k)

print( sum )

Buggy submission (verdict: Runtime Error):
N = int(input())
N = N+1
sum = 0

import math

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1, N):
    for j in range(1, N):
        for k in range(1, N):
            sum += (gcd(gcd(i, j), k)

print( sum )
Problem p02719 (python)

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

ans = N

tmp = N%K

if tmp > abs(tmp-K):
    print(abs(tmp-K))
else:
    print(tmp)

Buggy submission (verdict: Runtime Error):
from math

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

if N==1 or K==1:
    print(0)
else:
    print(math.gcd(N, K))

Buggy submission (verdict: Runtime Error):
from math import gcd

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

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))

Buggy submission (verdict: Runtime Error):
from math import gcd

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

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))

Buggy submission (verdict: Runtime Error):
from math import gcd

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

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))
Problem p02756 (python)

Fixed submission:
from collections import deque

q = deque(input())
Q = int(input())
reverse = -1

for i in range(Q):
    X = input().split()
    if X[0] == "1":
        reverse *= -1
    # if X[1] == "1":
    elif X[1] == "1":
        if reverse == -1:
            q.appendleft(X[2])
        else:
            q.append(X[2])
    elif X[1] == "2":
        if reverse == -1:
            q.append(X[2])
        else:
            q.appendleft(X[2])
# if reverse == 1: q.reverse()

if reverse == -1:
    print(''.join(q))
else:
    print(''.join(list(q)[::-1]))

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

S = input()
Q = int(input())
q = deque([S])
reverse = -1

for i in range(Q):
    print(reverse)
    X = input().split()
    if X[0] == "1":
        reverse *= -1
    # if X[1] == "1":
    elif X[1] == "1":
        if reverse == -1:
            q.appendleft(X[2])
        else:
            q.append(X[2])
    elif X[1] == "2":
        if reverse == -1:
            q.append(X[2])
        else:
            q.appendleft(X[2])
    print(reverse, q)
if reverse == 1: q.reverse()

for i in range(len(q)):
    print(q[i],end="")
print()

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

S = input()
Q = int(input())
q = deque([S])
reverse = False

for i in range(Q):
    X = sys.stdin.readline().split()
    if X[0] == "1":
        if reverse:
            reverse = False
        else:
            reverse = True
    elif X[0] == "2":
        if reverse:
            print(reverse)
            X[1] = str(3-int(X[1]))
        if X[1] == "1":
            q.appendleft(X[2])
        else:
            q.append(X[2])
        print(reverse, X[1], q)

if reverse: q.reverse()

for i in range(len(q)):
    print(q[i],end="")
print()

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  string s;
  cin >> s;
  string t;
  int q;
  cin >> q;
  rep(qi,q){
    int ty;
    cin >> ty;
    if (ty == 1){
      swap(s,t);
    }else{
      int f; char c;
      cin >> f >> c;
      if (f == 1){
	t += c;
      }else{
	s+=c;
      }}
  }
  reverse(t.begin(), t.end());
  t += s;
  cout << t << endl;
  return 0;
}
Problem p02911 (python)

Fixed submission:
n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]

mem = [k - len(a)] * n
for i in range(len(a)):
    mem[a[i]-1] += 1

for i in range(n):
    if mem[i] > 0:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n,k,q = map(int, input().split())
a = [int(input()) for _ in range(q)]

mem = [k - len(a)] * n
for i in range(len(a)):
    mem[a[i]] += 1

for i in range(n):
    if mem[i] > 0:
        print('Yes')
    else:
        print('No')
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
ctr = 0

for i in range(len(S)):
    if S[i] == T[i]:
        ctr = ctr+1

print(ctr)

Buggy submission (verdict: Runtime Error):
#Lower
N = int(input())
H = list(map(int, input().split()))
max = 0
n=0

for i in range(N-1):
    if H[i] >= H[i+1]:
        n = n+1
    else :
        n = 0
    if n > max:
        max = n

print(max)
Problem p02924 (python)

Fixed submission:
#ModSum
N = int(input())

print( (N*(N-1))//2 )

#sum = ( int(N*(N-1)/2) )
#print(sum)

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

print( int(N*(N-1)//2 )

#sum = ( int(N*(N-1)/2) )
#print(sum)
Problem p03457 (python)

Fixed submission:
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Buggy submission (verdict: Runtime Error):
スコード 拡げる

Copy
Copy
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
T=X=Y=0
ans = "Yes"
 
for t,x,y in txy:
  a = (t-T) - (abs(X-x) + abs(Y-y))
  if a % 2 == 0 and abs(X-x) + abs(Y-y) <= t - T:
    T,X,Y = t,x,y
  else:
    ans = "No"
    break
print(ans)
Problem p03545 (python)

Fixed submission:
A = input()

op = ['+', '-']

for i in range(len(op)):
    for j in range(len(op)):
        for k in range(len(op)):
            if eval(A[0]+op[i]+A[1]+op[j]+A[2]+op[k]+A[3]) == 7:
                print(A[0]+op[i]+A[1]+op[j]+A[2]+op[k]+A[3]+'=7')
                exit()

Buggy submission (verdict: Runtime Error):
ans = [''] * len(A)

for i in range(len(op)):
    sum = int(A[0])
    if op[i] == '+':
        sum += int(A[1])
        ans[0] = op[i]
    else:
        sum -= int(A[1])
        ans[0] = op[i]
    for j in range(len(op)):
        if op[j] == '+':
            sum += int(A[2])
            ans[1] = op[j]
        else:
            sum -= int(A[2])
            ans[1] = op[j]
        for k in range(len(op)):
            if op[k] == '+':
                sum += int(A[3])
                ans[2] = op[k]
            else:
                sum -= int(A[3])
                ans[2] = op[k]
            if sum == 7:
                print(A[0]+ans[0]+A[1]+ans[1]+A[2]+ans[2]+A[3]+'=7')
                exit()
Problem p03565 (python)

Fixed submission:
S = input()
T = input()

ans = 'UNRESTORABLE' 

def match(k):
    for i in range(len(T)):
        if T[i] != S[i+k] and S[i+k] != '?':
            return False
    return True

def construct(k):
    ans = []
    for i in range(len(S)): ans.append(S[i])
    for i in range(len(T)): ans[i+k] = T[i]
    for i in range(len(S)):
        if ans[i] == '?':
            ans[i] = 'a'
    return ans

for i in range(len(S)-len(T)+1):
    if match(i):
        ans=construct(i)

for i in range(len(ans)):
    print(ans[i], end='')
print()

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

tmp = 'UNRESTORABLE' 
ans = []
flag = True

for i in range(len(S)):
    if S[i] == T[0]:
        for j in range(0, len(T)):
            if S[i+j] != T[j] and S[i+j] != '?':
                flag = False
            ans.append(T[j])
    elif len(ans) < len(S):
        if S[i] == '?':
            ans.append('a')
        else:
            ans.append(S[i])

for i in range(len(T)):
    if not T[i] in ans:
        flag = False
if flag:
    for i in range(len(ans)):
        print(ans[i], end='')
    print()
else:
    print(tmp)
Problem p03567 (python)

Fixed submission:
S = input()

for i in range(len(S)):
    if S[i] == 'A' and S[i+1]=='C':
        print('Yes')
        exit()

print('No')

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

for i in range(len(S)):
  if S[i] == 'A' ans S[i+1]:
    print('Yes')
    exit()
print('No')

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

for i in range(len(S)):
  if S[i] == 'A' ans S[i+1]:
    print('Yes')
    exit()
print('No')
Problem p03695 (python)

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

ans = [0]*8
leng = 0

for i in range(N):
    if 1 <= A[i] <= 399:
        ans[0] = 1
    elif 400 <= A[i] <= 799:
        ans[1] = 1
    elif 800 <= A[i] <= 1199:
        ans[2] = 1
    elif 1200 <= A[i] <= 1599:
        ans[3] = 1
    elif 1600 <= A[i] <= 1999:
        ans[4] = 1
    elif 2000 <= A[i] <= 2399:
        ans[5] = 1
    elif 2400 <= A[i] <= 2799:
        ans[6] = 1
    elif 2800 <= A[i] <= 3199:
        ans[7] = 1
    else:
        leng += 1

mi = sum(ans) if sum(ans) > 0 else 1
print(mi, sum(ans) + leng)

Buggy submission (verdict: Runtime Error):
ans = [0]*8
leng = 0

for i in range(N):
    if 1 <= A[i] <= 399:
        ans[0] = 1
    elif 400 <= A[i] <= 799:
        ans[1] = 1
    elif 800 <= A[i] <= 1199:
        ans[2] = 1
    elif 1200 <= A[i] <= 1599:
        ans[3] = 1
    elif 1600 <= A[i] <= 1999:
        ans[4] = 1
    elif 2000 <= A[i] <= 2399:
        ans[5] = 1
    elif 2400 <= A[i] <= 2799:
        ans[6] = 1
    elif 2800 <= A[i] <= 3199:
        ans[7] = 1
    else:
        leng += 1

maxi = sum(ans)+leng
mini = sum(ans)

if sum(ans)+leng >= 8:
    maxi = 8
if sum(ans) < 1:
    mini = 1

print(mini, maxi)
Problem p03963 (python)

Fixed submission:
import sys
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

sum = K
for i in range(N-1):
    sum = sum*(K-1)

if __name__ == '__main__':
    print(sum)

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""

Buggy submission (verdict: Runtime Error):
import sys
from sys import stdin

N, k = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

sum = K
for i in range(N-1):
    sum = sum*(K-1)

if __name__ == '__main__':
    print(sum)

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""

Buggy submission (verdict: Runtime Error):
import sys
from sys import stdin

N, k = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

sum = K
for i in range(N-1):
    sum = sum*(K-1)

if __name__ == '__main__':
    print(sum)

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""
Problem p02640 (python)

Fixed submission:
x,y=map(int,input().split())
if x==1 and x*4>=y and y%2==0 and x*2<=y:
  print('Yes')
elif x*4>= y and y%2==0 and x*2<=y:
    print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ls.sort()
if n==0:
    print(x)
    exit(0)
else:
    ans=0
    d=1000000000
    for i in range(1,101):
        if i in ls:
            continue
        tmp=abs(x-i)
        if tmp<d:
            d=tmp
            ans=i
    print(ans)