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

Fixed submission:
s = int(input())
a = [s]

for i in range(1, 1000000):
    if a[i-1]%2 == 0:
        tmp = (a[i-1]//2)
    else:
        tmp = (3*a[i-1] + 1)
    
    if a.count(tmp):
        ans = i+1
        break
    else:
        a.append(tmp)
        
print(ans)

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

for i in range(1, 1000000):
    if a[i-1]%2 == 0:
        tmp = (a[i-1]//2)
    else:
        tmp = (3*a[i-1] + 1)
    
    if a.count(tmp):
        ans = i+1
        break
    else:
        a.append(tmp)
        
print(ans)
Problem p03264 (python)

Fixed submission:
k = int(input())
print((k//2)*(k-k//2))

Buggy submission (verdict: Runtime Error):
k = int(input())
print((n//2)*(k-n//2))
Problem p03436 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
p = [input() for i in range(h)]

# メモ配列
INF = 10**7
memo = [[INF]*w for i in range(h)]

# 白マスをカウント
wcnt = 0
for i in p:
    for j in i:
        if j == '.':
            wcnt+=1

# 幅探索用キュー初期化
q = deque()
q.append((0, 0))
memo[0][0]  = 0

# 探索用ベクトル
vx = (0, -1, 0, 1)
vy = (-1, 0, 1, 0)

ans = -1
for i in range(INF):
    # キューが空なら終了
    if len(q) == 0:
        break
        
    # キューから一つ取り出す
    x, y = map(int, q.pop())
    
    # ゴールなら終了
    if x == w-1 and y == h-1:
        ans = memo[y][x]
        break
        
    # 4方向の距離を確定して、エンキューする
    for j in range(4):
        nx, ny = x+vx[j], y+vy[j]
        
        # エリア外 or 探索済み or 黒色なら探索しない
        if nx < 0 or w <= nx or ny < 0 or h <= ny or memo[ny][nx] != INF or p[ny][nx] == '#':
            continue
            
        memo[ny][nx] = memo[y][x]+1
        q.appendleft((nx, ny))

if ans == -1:
    print(ans)
else:
    print(wcnt-ans-1)

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

h, w = map(int, input().split())
p = (input() for i in range(h))

# メモ配列
INF = 10**7
memo = [[INF]*w for i in range(h)]

# 白マスをカウント
wcnt = 0
for i in p:
    for j in i:
        if j == '.':
            wcnt+=1

# 幅探索用キュー初期化
q = deque()
q.append((0, 0))
memo[0][0]  = 0

# 探索用ベクトル
vx = (0, -1, 0, 1)
vy = (-1, 0, 1, 0)

ans = -1
for i in range(INF):
    # キューが空なら終了
    if len(q) == 0:
        break
        
    # キューから一つ取り出す
    x, y = map(int, q.pop())
    
    # ゴールなら終了
    if x == w-1 and y == h-1:
        ans = memo[y][x]
        break
        
    # 4方向の距離を確定して、エンキューする
    for j in range(4):
        nx, ny = x+vx[j], y+vy[j]
        
        # エリア外 or 探索済み or 黒色なら探索しない
        if nx < 0 or w <= nx or ny < 0 or h <= ny or memo[ny][nx] != INF or p[ny][nx] == '#':
            continue
            
        memo[ny][nx] = memo[y][x]+1
        q.appendleft((nx, ny))

if ans == -1:
    print(ans)
else:
    print(wcnt-ans-1)
Problem p03838 (python)

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

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1

print(ans)

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

ans = abs(abs(x)-abs(y))
if x > y and abs(x) != abs(y) and x*y > 0:
	ans+=2
elif x*y < 0 or (x>y and x==0) or (x>y and y==0):
	ans+=1a

print(ans)
Problem p04001 (python)

Fixed submission:
s = input()
n = len(s)

def dfs(tmp, s):
    if len(s) == 1:
        return int(tmp)+int(s)+int(tmp+s)
    
    return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])

if n > 1:
    print(dfs(s[0], s[1:]))
else:
    print(int(s))

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)

def dfs(tmp, s):
    if len(s) == 1:
        return int(tmp)+int(s)+int(tmp+s)
    
    return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])

print(dfs(s[0], s[1:]))
Problem p02806 (python)

Fixed submission:
# N is Amount of song
N = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X = input()
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
        else:
            continue
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
'''--- input ---'''

# N is Amount of song
N:int = input()
# Song_List has song title and song time.
# Song_List[title,time]
Song_List = []
for i in range (int(N)):
    Song_List.append(list(input().split()))
# X is song title when Niwango-kun started sleeping.
X:str = input()
#print("X = " + X)
'''--- search ---'''
ans = 0
for i in range(int(N)):
    if Song_List[i][0] == X:
        #print("mach is " + Song_List[i][0])
        #print("i is " + str(i))
        if i < int(N):
            for i in range(i,int(N)-1):
                ans +=int(Song_List[i+1][1])
                #print(str(i+1))
        else:
            continue
    else:
        continue
print(ans)
Problem p03567 (python)

Fixed submission:
ans=raw_input()
if ans.find('AC')!=-1:
    print "Yes"
else:
    print "No"

Buggy submission (verdict: Runtime Error):
ans=input()
if ans.find!=-1:
    print "Yes"
else:
    print "No"
Problem p02830 (python)

Fixed submission:
n = int(input())
k = input().split()
c = ""
for i in list(range(n)):
  c += k[0][i]
  c += k[1][i]
  
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = input().split()
c = ""
for i in list(range(2)):
  c += k[0][i]
  c += k[1][i]
  
print(c)
Problem p03071 (python)

Fixed submission:
def main():
	buttons = list(map(int, input().split()))
	aa = buttons[0] + (buttons[0] - 1)
	ab = buttons[0] + buttons[1]
	bb = buttons[1] + (buttons[1] - 1)
	print(max(aa, ab, bb))

main()

Buggy submission (verdict: Runtime Error):
def main():
	N = int(input())
	HeightList = list(map(int, input().split()))

	numOfOceanView = 1
	max = HeightList[0] # 0origin
	for i in range(1, N):
		if max < HeightList[i]:
			max = HeightList[i]
			numOfOceanView += 1
	print(numOfOceanView)

main()
Problem p03470 (python)

Fixed submission:
def kagamiMochi():
	N = int(input())
	d = []
	for _ in range(0, N):
		d.append(int(input()))
	d.sort()
	count = 1
	for j in range(1, N):
		if d[j] != d[j-1]:
			count += 1
	print(count)

kagamiMochi()

Buggy submission (verdict: Runtime Error):
# バケット法を用いる
def kagamiMochi():
	N = int(input())
	d = []
	for _ in range(0, N):
		d.append(int(input()))

	num = [0] * 100
	for i in range(0, N):
		num[d[i]] += 1

	count = 0
	for j in num:
		if j:
			count += 1
	print(count)

kagamiMochi()
Problem p02900 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def gcd(A,B):
    if B>A:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

A,B = map(int, input().split())
G = gcd(A,B)

ans = 1
for i in range(2,math.ceil(math.sqrt(G))+1):
    if G%i==0:
        ans+=1
        while G%i==0:
            G/=i
if G!=1:
    ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def gcd(A,B):
    if A>B:
        A,B = B,A

    if(A%B==0):
        return B
    else:
        return gcd(B,A%B)

A,B = map(int, input().split())
G = gcd(A,B)

ans = 1
for i in range(2,math.ceil(math.sqrt(G))+1):
    if G%i==0:
        ans+=1
        while G%i==0:
            G/=i
if G!=1:
    ans+=1

print(ans)
Problem p02917 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
B = list(map(int, input().split()))

ans=B[0]+B[N-2]
for i in range(N-2):
    ans+=min(B[i],B[i+1])

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())

# 複数個の数値を、intの配列として取得
B = list(map(int, input().split()))

ans=B[0]+B[N-2]
for i in range(N-1):
    ans+=max(B[i],B[i+1])

print(ans)
Problem p02936 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

stack = [0]
while stack:
    s = stack.pop()
    color[s] = 1
    for t in edge[s]:
        if color[t]==0:
            stack.append(t)
            node[t] += node[s]
    color[s]=2

for n in node:
    print(n)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def dfs(x,node,edge,color):
    color[x]=1
    for i in edge[x]:
        if color[i]==0:
            node[i]+=node[x]
            dfs(i,node,edge,color)
    color[x]=2

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

node = [0]*N
edge = [[] for _ in range(N)]
color = [0]*N

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

dfs(0,node,edge,color)

for n in node:
    print(n)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

def dfs(x,node,edge):
    for i in edge[x]:
        node[i]+=node[x]
        dfs(i,node,edge)

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

node = [0]*N
edge = [[] for _ in range(N)]

for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

for i in range(Q):
    p,x = map(int, input().split())
    node[p-1] += x

dfs(0,node,edge)

for n in node:
    print(n)
Problem p03147 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N = int(input())
h = list(map(int, input().split()))

ans = h[0]
base = h[0]
for i in range(1,N):
    ans += max(h[i]-base,0)
    base = h[i]

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N = int(input())
h = list(map(int, input().split()))

ans += h[0]
base = h[0]
for i in range(1,N):
    ans += max(h[i]-base,0)
    base = h[i]

print(ans)
Problem p03361 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

H,W = map(int, input().split())

s = ['.'*(W+2)]
for i in range(H):
    row = input()
    s.append('.' + row + '.')
s.append('.'*(W+2))

flg = 1
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j] == "#":
            if s[i-1][j] == "." and s[i+1][j] == "." and s[i][j-1] == "." and s[i][j+1] == ".":
                flg = 0

if flg:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int H,W;
    scanf("%d%d",&H,&W);

    char map[H][W+1];
    for(int i=0;i<H;i++) scanf("%s",map[i]);

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int flg=0;
            if(map[i][j]=='#'){
                if(i>0 && map[i-1][j]=='#') flg=1;
                if(i<H-1 && map[i+1][j]=='#') flg=1;
                if(j>0 && map[i][j-1]=='#') flg=1;
                if(j<W-1 && map[i][j+1]=='#') flg=1;
                if(!flg){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
    
    printf("Yes\n");

    return 0;
}

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int H,W;
    scanf("%d%d",&H,&W);

    char map[H][W+1];
    for(int i=0;i<H;i++) scanf("%s",map[i]);

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int flg=0;
            if(map[i][j]=='#'){
                if(i>0 && map[i-1][j]=='#') flg=1;
                if(i<H-1 && map[i+1][j]=='#') flg=1;
                if(j>0 && map[i][j-1]=='#') flg=1;
                if(j<W-1 && map[i][j+1]=='#') flg=1;
            }
            if(!flg){
                printf("No\n");
                return 0;
            }
        }
    }
    
    printf("Yes\n");

    return 0;
}
Problem p03379 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)

for x in X:
    if x <= Y[N//2-1]:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int N;
    scanf("%d",&N);

    int* X;
    NEW(X,N);
    for(int i=0;i<N;i++){
        scanf("%d",&X[i]);
    }

    int* Y;
    NEW(Y,N);
    for(int i=0;i<N;i++) Y[i]=X[i];
    qsort(Y,N,sizeof(int),asc);

    for(int i=0;i<N;i++){
        if(X[i]>=Y[N/2]) printf("%d\n",Y[N/2-1]);
        else printf("%d\n",Y[N/2]);
    }

    return 0;
}
Problem p03387 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

A = list(map(int, input().split()))
A.sort()

ans = (A[2]-A[1]) + (A[1]-A[0])//2 + ((A[1]-A[0])%2)*2
print(ans)

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,3);
    for(int i=0;i<3;i++){
        scanf("%d",&A[i]);
    }
    qsort(A,3,sizeof(int),asc);

    int ans=(A[2]-A[1])+(A[1]-A[0])/2+((A[1]-A[0])%2)*2;
    printf("%d\n",ans);

    return 0;
}
Problem p03409 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N = int(input())
red = [list(map(int,input().split())) for i in range(N)]
blue = [list(map(int,input().split())) for i in range(N)]
red.sort()
blue.sort()

ans = 0
for c,d in blue:
    x = []
    for a,b in red:
        if a < c and b < d:
            x.append([a,b])
    if len(x) > 0:
        ans += 1
        x = sorted(x, key=lambda x:x[1])
        red.remove(x[-1])

print(ans)

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

typedef struct{
    int x;
    int y;
    int flg;
}data;

//x軸の昇順
int xasc(const void* a, const void* b){
    data p = *(data*)a;
    data q = *(data*)b;
    if(p.x!=q.x) return p.x-q.x;
    else return p.y-q.y;
}

//y軸の降順
int ydesc(const void* a, const void* b){
    data p = *(data*)a;
    data q = *(data*)b;
    if(p.y!=q.y) return q.y-p.y;
    else return q.x-p.x;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    data* red;
    NEW(red,N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&red[i].x,&red[i].y);
        red[i].flg=0;
    }
    qsort(red,N,sizeof(data),ydesc);

    data* blue;
    NEW(blue,N);
    for(int i=0;i<N;i++){
        scanf("%d%d",&blue[i].x,&blue[i].y);
        blue[i].flg=0;
    }
    qsort(blue,N,sizeof(data),xasc);

    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(red[j].flg) continue;
            if(red[j].x<blue[i].x && red[j].y<blue[i].y){
                ans++;
                red[j].flg=1;
                break;
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}
Problem p03435 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

C = [list(map(int, input().split())) for i in range(3)]
A = [0]*3
B = [0]*3

flg = 0
for i in range(C[0][0]+1):
    A[0] = i
    B[0] = C[0][0]-i
    for j in range(1,3):
        A[j] = C[j][0]-B[0]
        B[j] = C[0][j]-A[0]
    
    tmp = abs(C[1][1]-A[1]-B[1])+abs(C[1][2]-A[1]-B[2])+abs(C[2][1]-A[2]-B[1])+abs(C[2][2]-A[2]-B[2])
    if tmp==0:
        flg = 1

if flg:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++) scanf("%d",&c[i][j]);
    }

    int a[3]={0,c[1][0]-c[0][0],c[2][0]-c[0][0]};
    int b[3]={c[0][0],c[0][1],c[0][2]};

    if(c[1][1]!=a[1]+b[1]){
        printf("No\n");
        return 0;
    }
    if(c[1][2]!=a[1]+b[2]){
        printf("No\n");
        return 0;
    }
    if(c[2][1]!=a[2]+b[1]){
        printf("No\n");
        return 0;
    }
    if(c[2][2]!=a[2]+b[2]){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");

    return 0;
}
Problem p03449 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

MOD = 10**9+7

N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

ans = 0
for i in range(N):
    tmp = 0
    for j in range(i+1):
        tmp += A[0][j]
    for j in range(i,N):
        tmp += A[1][j]
    ans = max(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

int main(void){
    int N;
    scanf("%d",&N);

    int M[2][N];
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++) scanf("%d",&M[i][j]);
    }
    
    //累積和をとる
    for(int i=1;i<N;i++) M[0][i]+=M[0][i-1];
    for(int i=N-2;i>=0;i--) M[1][i]+=M[1][i+1];
    
    int ans=0;
    for(int i=0;i<N;i++) ans=MAX(ans, M[0][i]+M[1][i]);
    printf("%d\n",ans);
    
    return 0;
}
Problem p03504 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,C = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

T_MAX = 10**5
time = [[0]*C for i in range(T_MAX)]

for s,t,c in L:
    time[s-1][c-1] += 1
    time[t-1][c-1] -= 1
 
ans = 0
tmp = 0
for i in range(T_MAX):
    tmp += time[i].count(1)
    ans = max(ans,tmp)
    tmp -= time[i].count(-1)

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,C = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

T_MAX = 2*(10**5)+1

time = [0]*(T_MAX)
for l in L:
    time[l[0]*2-1] += 1
    time[l[1]*2+1] -= 1

ans = 0
tmp = 0
for t in time:
    tmp += t
    ans = max(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,C = map(int, input().split())
L = [list(map(int, input().split())) for i in range(N)]

time = [0]*(2*(10**5))
for l in L:
    time[l[0]*2-1] += 1
    time[l[1]*2] -= 1

ans = 0
tmp = 0
for t in time:
    tmp += t
    ans = max(ans, tmp)

print(ans)
Problem p03565 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

S = input()
T = input()
 
for i in reversed(range(len(S)-len(T)+1)):
    flag = 1
    for j in range(len(T)) :
        if S[i+j] != T[j] and S[i+j] != "?":
            flag = 0
    if flag:
        ans = S[:i] + T + S[i+len(T):]
        print(ans.replace("?", "a"))
        exit()
 
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

S = input()
T = input()

start = -1
for i in range(len(S)-len(T),-1,-1):
    flg = 1
    for j in range(len(T)):
        if S[i+j] != '?' and S[i+j] != T[j]:
            flg = 0
            break
    if flg:
        start = i
        break

if flg == -1:
    ans = 'UNRESTORABLE'
else:
    S = S.replace('?', 'a')
    ans = S[:start] + T + S[start+len(T)+1:]

print(ans)
Problem p03575 (python)

Fixed submission:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,M = map(int, input().split())
G = [[] for _ in range(N)]

E = []
for _ in range(M):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    E.append((a-1,b-1))

d = [0] + [-1]*(N-1)

def dfs(n):
    d[n] = 0
    for v in G[n]:
        if d[v] == -1:
            dfs(v)

ans = 0
for a,b in E:
    G[a].remove(b)
    G[b].remove(a)

    dfs(0)

    if -1 in d:
        ans += 1
    
    for i in range(1,N):
        d[i] = -1
    G[a].append(b)
    G[b].append(a)

print(ans)

Buggy submission (verdict: Runtime Error):
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,M = map(int, input().split())
G = [[] for _ in range(N)]

E = []
for _ in range(M):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
    E.append((a-1,b-1))

d = [0] + [-1]*(N-1)

def dfs(n):
    for v in G[n]:
        if d[v] == -1:
            dfs(v)

ans = 0
for a,b in E:
    G[a].remove(b)
    G[b].remove(a)

    dfs(0)

    if -1 in d:
        ans += 1
    
    for i in range(1,N):
        d[i] = -1

print(ans)