Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
B=list(set(A))
count=0
for i in range(len(B)):
  if A.count(B[i])%2!=0:
    count+=1
print(count)

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)]
d={}
for i in range(n):
  if a[i] in d:
    d[a[i]]+=1
  else:
    d[a[i]]=1
cnt=0
d=list(d.items())
for i in range(len(d)):
  if d[i][1]%2==1:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
m=min(a)
n=max(a)
c=[]
for i in range(m,n+1):
  count=0
  for j in range(N):
    if i-1<=a[j]<=i+1:
      count+=1
  c.append(count)
print(max(c))

Fixed submission:
from collections import Counter
N=int(input())
a=list(map(int,input().split()))
for i in range(N):
  a.append(a[i]+1)
  a.append(a[i]-1)
c=Counter(a).most_common()
print(c[0][1])
Buggy python submission (verdict: Runtime Error):
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
# 連結成分に分解、異なる連結成分から一人ずつ集めたグループが１セット。
# これを全ての連結成分が空になるまで繰り返す。
# 全ての連結成分が空になる <===> 連結成分の最大の要素数回この操作を繰り返せば良い。
# Union FInd が一番適してそう。
class UnionFind():
    
    def __init__(self,N):
        self.N = N
        self.par = [-1]*N
    
    def find(self,x):
        if self.par[x]<0:return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 
        
        if self.par[x]>self.par[y]:
            x,y = y,x
        
        self.par[x] += self.par[y]
        self.par[y] = x
    
    def members(self,x):
        root = self.find(x)
        return len([i for i in range(self.N) if self.find(i)==root])

    def roots(self):
        return [i for i,x in enumerate(self.par) if x < 0]
    
    def calc_max_mem(self):
        root = self.roots()
        nums = [self.members(r) for r in root]
        return max(nums)


N,M=map(int,input().split())
uf = UnionFind(N)
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1;b -= 1
    uf.union(a,b)
print(uf.calc_max_mem())

Fixed submission:
# 連結成分に分解、異なる連結成分から一人ずつ集めたグループが１セット。
# これを全ての連結成分が空になるまで繰り返す。
# 全ての連結成分が空になる <===> 連結成分の最大の要素数回この操作を繰り返せば良い。
# Union FInd が一番適してそう。
class UnionFind():
    
    def __init__(self,N):
        self.N = N
        self.par = [-1]*N
    
    def find(self,x):
        if self.par[x]<0:return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 
        
        if self.par[x]>self.par[y]:
            x,y = y,x
        
        self.par[x] += self.par[y]
        self.par[y] = x
    

N,M=map(int,input().split())
uf = UnionFind(N)
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1;b -= 1
    uf.union(a,b)
print(-min(uf.par))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
A = tuple(map(int,input().split()))
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
for k in d:
    ans *= k**d[k]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
    exit()
elif A[-1]*A[-2] > 10**18:
    print(-1)
    exit()
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
for k in d:
    ans *= k**d[k]
if ans > 10**18:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
flag = 0
for a in list(map(int,input().split())):
    ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
A.sort()
if A[0] == 0:
    print(0)
    exit()
elif A[-1]*A[-2] > 10**18:
    print(-1)
    exit()
from collections import defaultdict
d = defaultdict(int)
for a in A:
    d[a] += 1
for k in d:
    ans *= k**d[k]
if ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[state[i]]=i
        state.append(s)
        continue
else:
    print(s)


Fixed submission:
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[s]=i
        state.append(s)
        continue
else:
    print(s)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(k+1):
    s=A[s-1]
    if s in count:
        start=len(state)
        end=i=1
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[state[i]]=i
        state.append[s]
else:
    print(s)


Fixed submission:
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[s]=i
        state.append(s)
        continue
else:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
  N = int(input())
  ans = 0
  A = tuple(map(int,input().split()))
  for k in range(1,N):
    for i in range(0,N-k):
      if A[i]+A[i+k]==k:
        ans += 1
  print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
from bisect import bisect_left
input = sys.stdin.readline
def main():
    N = int(input())
    ans = 0
    L = {}
    R = {}
    A = tuple(map(int,input().split()))
    for i,a in enumerate(A):
        if a+i in L:
            L[a+i] += 1
        else:
            L[a+i] = 1
        if i-a in R:
            R[i-a] += 1
        else:
            R[i-a] = 1
    for k in L:
        if k in R:
            ans += L[k]*R[k]
    print(ans)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    a,b,n = map(int,input().split())
    l = gcd(a,b)
    print(a*min(n,(b-1))//b-a*(min(b-1,n)//b))

if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    a,b,n = map(int,input().split())
    print(a*min(n,(b-1))//b-a*(min(b-1,n)//b))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1
    if m%2:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2+1):
            ans.append([i,m+1+r-i])
    else:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2):
            ans.append([i,m+1+r-i])            
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    if m%2:
        l = 1
        r = m
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    else:
        l = 1
        r = m+1
        while l+1<r:
            ans.append(l,r)
            l += 1;r-=1
        l = r
        r = 2*m+1
        while l<r:
            ans.append([l,r])
            l+=1;r-=1
    
    for a in ans:
        print(*ans)


if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = []
    r = 2*m+1
    if m%2:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2+1):
            ans.append([i,m+1+r-i])
    else:
        for i in range(1,m//2+1):
            ans.append([i,m+1-i])
        for i in range(m+1,(m+1+r)//2):
            ans.append([i,m+1+r-i])            
    for a in ans:
        print(*a)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
if K == 1:
    ans = 0
else:
    if N >= K:
        N -= (N//K)*K
        ans = min(N,abs(N-K))
    else:
        min(N,abs(N-K))
print(ans)


Fixed submission:
N,K = map(int,input().split())
if K == 1:
    ans = 0
else:
    if N >= K:
        N -= (N//K)*K
        ans = min(N,abs(N-K))
    else:
        ans = min(N,abs(N-K))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
INF = float('inf')
from heapq import *
from collections import defaultdict

N,X,Y = map(int,input().split())
X -= 1
Y -= 1
cost_pri = defaultdict(list)
for i in range(N-1):
    cost_pri[i].append((i+1,1))
    cost_pri[i+1].append((i,1))
cost_pri[X].append((Y,1))
cost_pri[Y].append((X,1))
ans = [0]*(N-1)
for s in range(N):
    dist = [2**60]*N
    dist[s] = 0
    que = [[0,s]]
    heapify(que)
    while que:
        p = heappop(que)
        v = p[1]
        if dist[v] < p[0]:continue
        for e in cost_pri[v]:
            if dist[e[0]] > dist[v] + e[1]:
                dist[e[0]] = dist[v] + e[1]
                heappush(que,[dist[e[0]],e[0]])
    
    for a in dist[s+1:]:
        ans[a-1] += 1

for a in ans:
    print(a)

Fixed submission:
from heapq import *
from collections import defaultdict

N,X,Y = map(int,input().split())
X -= 1
Y -= 1
cost_pri = defaultdict(list)
for i in range(N-1):
    cost_pri[i].append((i+1,1))
    cost_pri[i+1].append((i,1))
cost_pri[X].append((Y,1))
cost_pri[Y].append((X,1))
ans = [0]*(N-1)
for s in range(N):
    dist = [2**60]*N
    dist[s] = 0
    que = [(0,s)]
    heapify(que)
    while que:
        p = heappop(que)
        v = p[1]
        if dist[v] < p[0]:continue
        for e in cost_pri[v]:
            if dist[e[0]] > dist[v] + e[1]:
                dist[e[0]] = dist[v] + e[1]
                heappush(que,(dist[e[0]],e[0]))
    
    for a in dist[s+1:]:
        ans[a-1] += 1

for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
S = [s for s in input()]
Q = int(input())
front = []
end = []
cnt = 0
for _ in range(Q):
    T = input().split()
    if int(T[0]) == 1:
        cnt += 1
    else:
        F = int(T[1])
        C = [s for s in T[2]]
        if F == 1:
            if cnt%2==0:
                front = C+front
            else:
                end = end+C
        else:
            if cnt%2==0:
                end = end+C
            else:
                front=C+front
if cnt % 2 == 0:
    S = front+S+end
else:
    S.reverse()
    end.reverse()
    front.reverse()
    S = end+S+front

print(''.join(S))

Fixed submission:
S = input()
Q = int(input())
front = ''
end = ''
cnt = 0
for _ in range(Q):
    T = input().split()
    if int(T[0]) == 1:
        cnt += 1
    else:
        F = int(T[1])
        C = T[2]
        if F == 1:
            if cnt%2==0:
                front = C+front
            else:
                end = end+C
        else:
            if cnt%2==0:
                end = end+C
            else:
                front=C+front
if cnt % 2 == 0:
    S = front+S+end
    print(S)
else:
    S = list(reversed(S))
    end = list(reversed(end))
    front = list(reversed(front))
    S = end+S+front
    print(''.join(S))

Buggy python submission (verdict: Time Limit Exceeded):
S = [s for s in input()]
Q = int(input())
for _ in range(Q):
    T = input().split()
    if int(T[0]) == 1:
        S.reverse()
    else:
        F = int(T[1])
        C = [s for s in T[2]]
        if F == 1:
            S = C + S
        else:
            S = S + C
print(''.join(S))

Fixed submission:
S = input()
Q = int(input())
front = ''
end = ''
cnt = 0
for _ in range(Q):
    T = input().split()
    if int(T[0]) == 1:
        cnt += 1
    else:
        F = int(T[1])
        C = T[2]
        if F == 1:
            if cnt%2==0:
                front = C+front
            else:
                end = end+C
        else:
            if cnt%2==0:
                end = end+C
            else:
                front=C+front
if cnt % 2 == 0:
    S = front+S+end
    print(S)
else:
    S = list(reversed(S))
    end = list(reversed(end))
    front = list(reversed(front))
    S = end+S+front
    print(''.join(S))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        exit()
    else:
        ans[s-1] = c
if ans[0] == 0:
    print(-1)
    exit()  
for i in range(N):
    if ans[i] == -1:
        if i != 0:
            ans[i] = 0
        else:
            ans[i] = 1
    ans[i] = str(ans)
ans = ''.join(ans)
print(int(ans))

Fixed submission:
N,M = map(int,input().split(" "))
ans = [-1 for _ in range(N)]
flag = 0
for i in range(M):
    s,c = map(int,input().split(" "))
    if ans[s-1] != -1 and ans[s-1] != c:
        flag = 1
    else:
        ans[s-1] = c
if N != 1 and ans[0] == 0:
    flag = 1
elif N == 1 and ans[0] == 0:
    print(0)
    exit()
if N == 1:
    if ans[0] == -1:
        print(0)
        exit()
for i in range(N):
    if ans[i] == -1:
        if i == 0:
            ans[i] = 1
        else:
            ans[i] = 0
    ans[i] = str(ans[i])
ans = ''.join(ans)
if flag == 1:
    print(-1)
    exit()
print(int(ans))
Buggy python submission (verdict: Runtime Error):
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n/2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1)
  B = mfac(k,1)
  B = mpow(B,mod-2,mod)
  return A*B%mod

def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1+mcomb(n,a,mod)-mcomv(n,b,mod)
  ans %= mod
  print(ans)

if __name__ == "__main__":
  main()
  

Fixed submission:
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n//2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1,mod)
  B = mfac(k,1,mod)
  B = mpow(B,mod-2,mod)
  return A*B%mod

def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1-mcomb(n,a,mod)-mcomb(n,b,mod)
  ans %= mod
  print(ans)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1
ans = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
ans.sort()
for s in ans:
    print(s)

Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
for i in range(N):
    d[input()] += 1
m = max(d.values())
d = sorted(d.items(), key=lambda x:x[1])
d.reverse()
ans = []
for s in d:
    if s[1] == m:
        ans.append(s[0])
    else:
        break
ans.sort()
for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
s = list(map(int,input()))
L = len(s)
o = s[0]
p = 11-s[1]
for i in range(1,L):
    n = s[i]
    np = min(o+n,p+n)
    d = min(p+9-n,o+11-n)
    o = np
    p = d
print(min(o,p))

Fixed submission:
N = str(input())
L = len(N)
ans = 0
dp = [[0,0] for _ in range(L)]
s = list(map(int,N))
dp[0] = [s[0],11-s[0]]
for i in range(1,L):
    n = s[i]
    dp[i][0] = min(dp[i-1][0]+n,dp[i-1][1]+n)
    dp[i][1] = min(dp[i-1][1]+9-n,dp[i-1][0]+11-n)
print(min(dp[-1]))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Fixed submission:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)//2+1):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2,(pp[-1-i]-pp[-1-i-K]+K)/2)
print(ans)

Fixed submission:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
ans = 0
i = 0
while i <= N-K:
    tmp = p[i:i+K]
    ans = max(ans,(sum(tmp)+K)/2)
    i += 1
print(ans)

Fixed submission:
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7

def f(n,k,p):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer*pow(denom,p-2,p)%p

r1,c1,r2,c2 = map(int,input().split(" "))
ans = f(r2+c2+2,c2+1,mod)-f(r2+c1+1,c1,mod)-f(r1+c2+1,c2+1,mod)+f(r1+c1,c1,mod)
print(ans%mod)

Fixed submission:
mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7

def f(n,k,p):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer*pow(denom,p-2,p)%p

r1,c1,r2,c2 = map(int,input().split(" "))
ans = f(r2+c2+2,c2+1,mod)-f(r2+c1+1,c1,mod)-f(r1+c2+1,c2+1,mod)+f(r1+c1,c1,mod)
print(ans%mod)

Fixed submission:
mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
mod = 10**9+7

def f(n,k,p):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer*pow(denom,p-2,p)%p

r1,c1,r2,c2 = map(int,input().split(" "))
ans = f(r2+c2+2,c2+1,mod)-g(r2+c1+1,c1,mod)-g(r1+c2+1,c2+1,mod)+g(r1+c1,c1,mod)
print(ans%mod)

Fixed submission:
mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
mod = 10**9+7

f = [1]*(2*10**6+2)
f[0] = 1
for i in range(1,2*10**6+2):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)

Fixed submission:
mod = 10**9+7

f = [1]*(2*10**6+5)
f[0] = 1
for i in range(1,2*10**6+4):
    f[i] = f[i-1]*i%mod

def inv(i):
    return pow(f[i],mod-2,mod)

def g(x,y):
    return f[x+y]*inv(x)*inv(y)%mod

r1,c1,r2,c2 = map(int,input().split(" "))
ans = g(r2+1,c2+1)-g(r2+1,c1)-g(r1,c2+1)+g(r1,c1)
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = list(map(int,input().split(" ")))
ans = 0
for i in range(n):
    tmp = min(P[:i+1])
    if tmp == P[i]:
        ans += 1
print(ans)


Fixed submission:
n = int(input())
tmp = 2**60
ans = 0
for i in input().split(" "):
  tmp = min(tmp,int(i))
  if int(i) == tmp:
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lis = [[0,0] for _ in range(N)]
X = [0 for _ in range(N)]
ans = []
for i in range(N):
    x,l = map(int, input().split(" "))
    lis[i] = (x-l,x+l)
    X[i] = x
s = []
ans_append = ans.append
s_append = s.append
for i in range(N):
    cnt = 0
    for j,v in enumerate(lis):
        a,b = v
        if i == j:
            continue
        else:
            if a < X[i] < b:
                cnt += 1
    if cnt == 0:
        ans_append(lis[i])
    if cnt == 1:
        s_append(lis[i])
print(len(ans) + len(s)//2)

Fixed submission:
from collections import deque
N = int(input())
lis = []
ans = []
lis_append=lis.append
for i in range(N):
    x,l = map(int, input().split(" "))
    lis_append((x+l,x-l))
lis.sort()
lis = deque(lis)
ans.append(lis.popleft())
while lis:
    a = lis.popleft()
    if a[1] >= ans[-1][0]:
        ans.append(a)
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lis = []
X = []
ans = []
for i in range(N):
    x,l = map(int, input().split(" "))
    lis.append((x-l,x+l))
    X.append(x)
s = []
for i in range(N):
    cnt = 0
    for j,v in enumerate(lis):
        a,b = v
        if i == j:
            continue
        else:
            if a < X[i] < b:
                cnt += 1
    if cnt == 0:
        ans.append(lis[i])
    if cnt == 1:
        s.append(lis[i])
print(len(ans) + len(s)//2)

Fixed submission:
from collections import deque
N = int(input())
lis = []
ans = []
lis_append=lis.append
for i in range(N):
    x,l = map(int, input().split(" "))
    lis_append((x+l,x-l))
lis.sort()
lis = deque(lis)
ans.append(lis.popleft())
while lis:
    a = lis.popleft()
    if a[1] >= ans[-1][0]:
        ans.append(a)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
#LCMを求めれば良い
a, b = map(int, input().split())

import math

c = math.gcd(a, b)
ans = a * b//c
print(ans)

Fixed submission:
#LCMを求めれば良い
a, b = map(int, input().split())
s, t = max(a, b), min(a, b)
c = s%t
while (c != 0):
    s = t
    t = c
    c = s%t

ans = a * b//t
print(ans)