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

Fixed submission:
H,W=[int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(H)]
res = []
for h in range(H):
    for w in range(W-1):
        if a[h][w] % 2 is not 0:
            res += ["{0} {1} {2} {3}".format(h+1,w+1,h+1,w+2)]
            a[h][w+1] += 1
for h in range(H-1):
    w = W - 1
    if a[h][w] % 2 is not 0:
        res += ["{0} {1} {2} {3}".format(h+1,w+1,h+2,w+1)]
        a[h+1][w]+=1

print(len(res))
for t in res:
    print(t)

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int map[500][500];
    int a[10000], b[10000], c[10000], d[10000];
    int H, W;
    cin >> H >>W;
    REP(y, H) REP(x, W) {
        cin >> map[y][x];
    }
    
    int dx = 1, x = 0, y = 0, x2, y2;
    int cnt = 0;
    while(1) {
        if(x + dx == W || x + dx == -1) {
            dx *= -1;
            x2 = x;
            y2 = y + 1;
        } else {
            x2 = x + dx;
            y2 = y;
        }

        if(y2 >= H) {
            break;
        }

        if(map[y][x] % 2 == 1) {
            a[cnt] = y+1;
            b[cnt] = x+1;
            c[cnt] = y2+1;
            d[cnt] = x2+1;
            map[y][x]--;
            map[y2][x2]++;
            cnt++;
        }

        x = x2;
        y = y2;
    }
  　cout<<cnt <<endl;
    REP(i, cnt) {
        cout << a[i]<<b[i]<<c[i]<<d[i]<<endl;
    }
}
Problem p03282 (python)

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

for c in S:
  K-=1
  if K==0:
    print(c)
    break
  if c!='1':
    print(c)
    break

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

for c in S:
	K-=1
    if K==0:
      print(c)
      break
    if c!='1':
      print(c)
      break
Problem p03391 (python)

Fixed submission:
N=int(input())
ab=[[int(i) for i in input().split()] for j in range(N)]
total = sum([sum(row) for row in ab])//2
diff = [row[1] for row in ab if row[0]>row[1]]
if len(diff)==0:
    print(0)
else:
    print(total-min(diff))

Buggy submission (verdict: Runtime Error):
N=int(input())
ab=[[int(i) for i in input().split()] for j in range(N)]
total = sum([sum(row) for row in ab])//2
diff = [row[1] for row in ab if row[0]>row[1]]
if len(diff)==0:
    print(0)
else:
    print(total-diff)
Problem p03463 (python)

Fixed submission:
a,b,c=[int(i) for i in input().split()]
if abs(b-c)%2==0:
	print("Alice")
else:
	print("Borys")

Buggy submission (verdict: Runtime Error):
a,b,c=[int(i) for i in input().split()]                                                                  2 flag=(abs(b-c)%2)==0

if flag:
	print("Alice")
else:
	print("Borys")
Problem p03489 (python)

Fixed submission:
N=int(input())
a=[int(i) for i in input().split()]
data={}
for num in a:
        if num in data:
                data[num]+=1
        else:
                data[num]=1

ans=0
for key in data.keys():
        if data[key]<key:
                ans+=data[key]
        else:
                ans+=data[key]-key
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]
data={}
for num in a:
    data[num]+=1
 
ans=0
for key in data.keys():
        if data[key]<key:
                ans+=data[key]
        else:
                ans+=data[key]-key
print(ans)
Problem p03574 (python)

Fixed submission:
H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]

def search(h,w):
        if s[h][w]=='#':
                return '#'
        count=0
        for i in range(-1,2):
                for j in range(-1,2):
                        if 0<=h+i and h+i<H and 0<=w+j and w+j<W:
                                if i!=0 or j!=0:
                                        if s[h+i][w+j]=='#':
                                                count+=1
        return count

for h in range(H):
        for w in range(W):
                print(search(h,w),end='')
        print()

Buggy submission (verdict: Runtime Error):
H,W=[int(i) for i in input().split()]
s=[input() for i in range(H)]

def search(h,w):
        if s[h][w]=='#':
                return '#'
        count=0
        for i in range(-1,2):
                for j in range(-1,2):
                        if (i!=0 or j!=0) and 0<=h+i and h+i<H and 0<=w+j and w+j<W:                                if s[h+i][w+j]=='#':
                                        count+=1
        return count

for h in range(H):
        for w in range(W):
                print(search(h,w),end='')
        print()
Problem p03639 (python)

Fixed submission:
N=int(input())
a=[int(i) for i in input().split()]
num4=0
num2=0
num1=0
for i in a:
        if i%4==0:
                num4+=1
        elif i%2==0:
                num2+=1
num1=N-num4-num2

if num2>0:
        num1+=1

if num1<=num4+1:
        print("Yes")
else:
        print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]
num4=0
num2=0
num1=0
for i in a:
        if i%4==0:
                num4+=1
        elif i%2==0:
                num2+=1
num1=N-num4-num2

if num2>0:
        num1+=1

if num1<=num4+1:
        print("Yes")
else:
        print("No")                                                                      ~                                                                                   ~
Problem p03689 (python)

Fixed submission:
H,W,h,w=[int(i) for i in input().split()]

if H%h==0 and W%w==0:
        print("No")
elif W%w!=0:
        print("Yes")
        for y in range(H):
                for x in range(W):
                        if x!=0:
                                print(" ",end="")
                        if (x%w)!=(w-1):
                                print(100000,end="")
                        else:
                                print(-100000*(w-1)-1,end="")
                print()
else:
        print("Yes")
        for y in range(H):
                for x in range(W):
                        if x!=0:
                                print(" ",end="")
                        if (y%h)!=(h-1):
                                print(100000,end="")
                        else:
                                print(-100000*(h-1)-1,end="")
                print()

Buggy submission (verdict: Runtime Error):
temp=input().split()
H=int(temp[0])
W=int(temp[1])
h=int(temp[2])
w=int(temp[3])

countT=0
ans=[]
if H%h==0 and W%w==0:
	print("No")
else:
	for i in range(H):
		tempAns=[]
		for j in range(W):
			if (i+1)%h==0 and (j+1)%w==0:
				countT-=h*w
				tempAns.append(-1*h*w)
			else:
				tempAns.append(1)
				countT+=1
		ans.append(tempAns)
		print("Yes")
		for i in range(H):
			for j in range(W):
				print(ans[i][j],end="")
				if j!=W-1:
					print(" ",end="")
			print()
Problem p03795 (python)

Fixed submission:
N=int(input())
ans=N*800-(N-N%15)*200/15
print(int(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=N*800-(N-N%15)*200/15
print ans

Buggy submission (verdict: Runtime Error):
N=input()
print N*800-(N-N%15)*200/15
Problem p03807 (python)

Fixed submission:
N=int(input())
A=[int(i) for i in input().split()]

count=0
for i in A:
	if i%2==1:
		count+=1
if count%2==0:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[int(i) for i in input().split()]

count=0
for i in A:
	if i%2==1:
		count+=1
if count%2==0:
	print("YES")
else:
	print("NO)
Problem p03228 (python)

Fixed submission:
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a // 2
        a //= 2
        
    else:
        if b % 2 == 1:
            b -= 1
        a += b // 2
        b //= 2
print(a, b)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        b += a / 2
        a /= 2
        
    else:
        if b % 2 == 1:
            b -= 1
        a += b / 2
        b /= 2
print(f"{a} {b}")
Problem p02536 (python)

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

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.siz=[1]*n

    def root(self,x):
        while self.par[x]!=x:
            self.par[x]=self.par[self.par[x]]
            x=self.par[x]
        return x

    def unite(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.siz[x]<self.siz[y]:
            x,y=y,x
        self.siz[x]+=self.siz[y]
        self.par[y]=x
        return True

    def is_same(self,x,y):
        return self.root(x)==self.root(y)

    def size(self,x):
        return self.siz[self.root(x)]

uni = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    uni.unite(a-1, b-1)

cnt = [0]*(n)
for i in range(n):
    cnt[uni.root(i)] = 1

print(sum(cnt)-1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
    # ノードxのrootノードを見つける
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
    # 木の併合、入力は併合したい各ノード⇒(a,b)
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
    # ノードxが属する木のサイズを返す
        return -self.parents[self.find(x)]

    def same(self, x, y):
    # 入力ノード(x,y)が同じグループに属するかを返す
        return self.find(x) == self.find(y)

    def members(self, x):
    #ノードxが属するメンバーをリスト形式で返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
    #親全てをリスト形式で返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
    #グループ数の合計を返す
        return len(self.roots())

uni = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    uni.unite(a-1, b-1)

cnt = [0]*(n)
for aa in uni.par:
    cnt[aa] = 1

print(sum(cnt)-1)
Problem p02609 (python)

Fixed submission:
n = int(input())
x = input()
import copy

memo = [0]*n
ans = [-1]*n
popcnt = 0

for i in range(n):
    if x[i] == "1":
        popcnt += 1

amariStaticA = 0
amariStaticB = 0
aaa = -1
if popcnt == 1:
    for i in range(n):
        if x[i] == "1":
            ans[i] = 0
            aaa = i
            amariStaticB += pow(2, n-i-1, popcnt+1)
    amariStaticB %= popcnt+1
else:
    for i in range(n):
        if x[i] == "1":
            amariStaticA += pow(2, n-i-1, max(1, popcnt-1))
            amariStaticB += pow(2, n-i-1, popcnt+1)
    amariStaticA %= max(1, popcnt-1)
    amariStaticB %= popcnt+1

for i in range(n):
    if popcnt == 1 and i == aaa:
        continue
    if x[i] == "0":
        amari = amariStaticB + pow(2, n-i-1, popcnt+1)
        amari %= popcnt+1
    else:
        amari = amariStaticA - pow(2, n-i-1, max(1, popcnt-1))
        amari %= max(1, popcnt-1)
    if amari == 0:
        ans[i] = 1
    else:
        memo[i] = amari

for i in range(len(memo)):
    cnt = 1
    firstMemo = copy.deepcopy(memo[i])
    while memo[i] != 0:
        popcnt = bin(memo[i]).count("1")
        memo[i] %= max(1, popcnt)
        cnt += 1
        if memo[i] == 0:
            ans[i] = cnt
            break


for anss in ans:
    print(anss)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = input()
ans = [0]*n

popcnt = 0
for i in range(n):
    if x[i] == "1":
        popcnt += 1
if popcnt == 0:
    print("owari")

amari = 0
for i in range(len(x)):
    if x[i] == "1":
        amari += pow(2, len(x)-i-1, popcnt)
amari %= popcnt

print(amari)
Problem p02691 (python)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    if -1*fromLeft[i] < 3*10**5-10:
        ldList[-1*fromLeft[i]] += 1
    if a[i]+i < 3*10**5-10:
        ans += ldList[a[i]+i]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    if fromLeft[i] < 3*10**5-10:
        ldList[fromLeft[i]] += 1
    ans += ldList[-1*a[i]-i]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    ldList[fromLeft[i]] += 1
    ans += ldList[-1*a[i]-i]

print(ans)
Problem p02722 (python)

Fixed submission:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
divsN = make_divisors(N)
divsN2 = make_divisors(N-1)
divsN.pop(0)

ans = len(divsN2)-1

for div in divsN:
    n = N+1-1
    while True:
        if n%div != 0 or n==1:
            break
        n //= div
    if n%div == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 2:
    print(1)
elif n == 3:
    print(2)
else:
    #print(make_divisors(n-1))
    print(len(make_divisors(n-1))+1)
Problem p02732 (python)

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

data = [0]*(n+1)

for aa in a:
  data[aa] += 1

allans = 0
for d in data:
  if d >= 2:
    allans += (d*(d-1))//2
    
for aa in a:
  if data[aa] == 2:
    print(allans - (data[aa]*(data[aa]-1))//2)
  elif data[aa] > 2:
    print(allans - (data[aa]-1))
  else:
    print(allans)

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

data = [0]*n

for aa in a:
  data[aa] += 1

allans = 0
for d in data:
  if d >= 2:
    allans += (d*(d-1))//2
    
for aa in a:
  if data[aa] == 2:
    print(allans - (data[aa]*(data[aa]-1))//2)
  elif data[aa] > 2:
    print(allans - (data[aa]-1))
  else:
    print(allans)
Problem p02743 (python)

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

if c - a - b < 0:
  print("No")
  sys.exit()

if 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
a, b, c = input().split()

if c - a - b > 0:
  print("No")
  sys.exit()

if 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
mod = 10**9 + 7

def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod

def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod

ans = powerDX(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
ans = pow(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod
 
ans = pow(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod
 
ans = power(2, n, mod) - 1
ans -=  combination(n, a, mod)
ans -=  combination(n, b, mod)
ans += 3*mod
ans %= mod
print(ans)
Problem p02900 (python)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    return arr

a, b = map(int, input().split())
fa = factorization(a)
fb = factorization(b)

i = 0
j = 0
cnt = 1
while i < len(fa) and j < len(fb):
  if fa[i][0] == fb[j][0]:
    cnt += 1
    i += 1
    j += 1
  elif fa[i][0] < fb[j][0]:
    i += 1
  else:
    j += 1

print(cnt)

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

dp = [[10**10 for _ in range(2**n)] for j in range(m)]
dp[0][0] = 0
a, b = map(int, input().split())
c = list(map(int, input().split()))
idx = 0
for cc in c:
  idx += 2**(cc-1)
for j in range(1, 2**n):
  if ~idx & j == 0:
    dp[0][j] = a

for i in range(1, m):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  idx = 0
  for cc in c:
    idx += 2**(cc-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j], dp[i-1][(j|idx)^idx]+a)

if dp[-1][-1] != 10**10:
  print(dp[-1][-1])
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
mport fractions
A,B = map(int, input().split())
C = fractions.gcd(A, B)
counter = 1

for i in range(C):
  if i==0:
    continue
  if C%(i+1) == 0:
    j = 2
    whileFin = i+1
    while True:
      if j > whileFin or i+1 == 2:
        counter += 1
        break
      if (i+1)%j == 0:
        break
      else:
        whileFin = int((i+1)/(j+1)) + 1
      j += 1

print(counter)
Problem p02910 (python)

Fixed submission:
s = input()
 
flag = True
for i in range(len(s)):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False
 
if flag:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
 
flag = True
for i in range(s):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False
 
if flag:
  print("Yes")
else:
  print("No")

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

flag = True
for i in range(s):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False

if flag:
  print("Yes")
else:
  print("No")
Problem p02608 (python)

Fixed submission:
n = int(input())
cnt = [0] * (n*n+1000)
for a in range(1, int(n**0.5)+1):
    for b in range(1, int(n**0.5)+1):
        for c in range(1, int(n**0.5)+1):
            cnt[a*a + b*b + c*c + a*b + b*c + c*a] += 1

for i in range(1, n+1):
    print(cnt[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
cnt = [0] * (n*n)
for a in range(1, int(n**0.5)+1):
    for b in range(1, int(n**0.5)+1):
        for c in range(1, int(n**0.5)+1):
            cnt[a*a + b*b + c*c + a*b + b*c + c*a] += 1

for i in range(1, n+1):
    print(cnt[i])
Problem p02780 (python)

Fixed submission:
fact = [0]*1010
for i in range(1, 1010): fact[i] = fact[i-1]+i

n, k, *a = map(int, open(0).read().split())
a = list(map(lambda x:fact[x]/x, a))
ans = tmp = sum(a[:k])
for i in range(n-k):
    tmp -= a[i]
    tmp += a[i+k]
    ans = max(ans, tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
import strutils, sequtils
var
  a, p = stdin.readline.split.map(parseFloat)
  n, k: int
(n, k) = a.map(toInt)

p = @[0.0] & p
for i in 1..n:
  p[i] *= (p[i]+1) / (2*p[i])
  p[i] += p[i-1]

var ans = 0.0
for i in 0..n-k: ans = max(ans, p[i+k]-p[i])
echo ans
Problem p02796 (python)

Fixed submission:
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:sum(x))

ans = 0
now = -1e11
for i in range(n):
    if now<=xls[i][0]-xls[i][1]:
        ans += 1
        now = xls[i][0]+xls[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:x[0])
flag = 1
ans1 = ans2 = 1
x, l = xls[0]
for i in range(1, n):
    nx, nl = xls[i]
    if nx-nl+1<x+l: continue
    if i==1: flag=0
    ans1 += 1
    x, l = nx, nl

if flag:
    x, l = xls[1]
    for i in range(2, n):
        nx, nl = xls[i]
        if nx-nl+1<x+l: continue
        if i==1: flag=0
        ans2 += 1
        x, l = nx, nl
print(max(ans1, ans2))
Problem p02866 (python)

Fixed submission:
n, *a = map(int, open(0).read().split())
if a[0]!=0:
    print(0)
    exit()

b = [0]*n
for i in a: b[i]+=1

if b[0]!=1:
    print(0)
    exit()

ans = 1
i = 0
while i<n-1:
    if b[i]==0:
        if sum(b[i:])>0:
            print(0)
            exit()
        else:
            break
    ans *= b[i]**b[i+1]
    i += 1

print(ans%998244353)

Buggy submission (verdict: Runtime Error):
n, *a = map(int, open(0).read().split())
a.sort()
if a[0]!=0:
    print(0)
    exit()

b = [0]*n
for i in a: b[i]+=1

if b[0]!=1:
    print(0)
    exit()

ans = 1
i = 0
while 1:
    if b[i]==0:
        if sum(b[i:])>0:
            print(0)
            exit()
        else:
            break
    ans *= b[i]**b[i+1]
    i += 1

print(ans)
Problem p02900 (python)

Fixed submission:
def prefactor(x):
  ret = set()
  for i in range(2, int(x**0.5)+1):
    if x%i==0: ret.add(i)
    while x%i==0: x //= i
  if x>1: ret.add(x)
  return ret
    

a, b = map(int, input().split())
print(1+len(prefactor(a) & prefactor(b)))

Buggy submission (verdict: Runtime Error):
  def gcd(a,b):
    if a<b: a,b=b,a
    while b: a,b = b, a%b
    return a
def main():
  a, b = map(int, input().split())
  c = gcd(a, b)
  ans = 1
  i = 2
  while c!=1:
    if c%i==0: ans+=1
    while c%i==0: c//=i
    i+=1
  print(ans)
if __name__=="__main__":main()
Problem p02923 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(n-1):
  if a[i] >= a[i+1]: cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
print(max(cnt, ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  if a[-i]>a[-i-1]: break
print(i-1)
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(range(2, n+1))
l.append(1)
ans = 0
for i, m in enumerate(l): ans += (i+1)%m
print(ans)