TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
from sys import stdin,stdout
n=int(stdin.readline());ans=0
fctrs=[0]*(n+1)
for i in range(1,n+1):
        for j in range(i,n+1,i):
            fctrs[j]+=1
for i in range(1,n+1):
    ans+=(i*fctrs[i])
stdout.write(str(ans))


from sys import stdin,stdout
from numba import njit
@njit
def solve(n):
	fctrs=[0]*(n+1)
	ans=0
	for i in range(1,n+1):
		for j in range(i,n+1,i):
			fctrs[j]+=1
	for i in range(1,n+1):
		ans+=(i*fctrs[i])
	return ans
n=int(stdin.readline())
print(solve(n))

Verdicts: Time Limit Exceeded

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n=int(input())
ans=0
for i in range(1,n+1):
    A=n//i
    ans+=(A*(A+1)//2+i)
print(ans)

n=int(input())
ans=0
for i in range(1,n+1):
    A=n//i
    ans+=((A*A+A)*i//2)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import math
n=int(input())
l=[]
for i in range(1,n+1):
  cnt=0
  j=1
  while j<=i**0.5:
    if i%j==0:
      cnt+=1
    j+=1
  if i**0.5==int(i**0.5):
    l.append(cnt*2-1)
  else:
    l.append(cnt*2)
ans=0
for t in range(n):
  p=(t+1)*l[t]
  ans+=p
  print(l[t])
print(ans)

n=int(input())
ans=0
for i in range(1,n+1):
  ans+=i*(1+n//i)*(n//i)//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())
sum = 0
for k in range(N):
  for j in range(k):
  	if k % j == 0：
    	sum += k
print(f)

N = int(input())
sum = 0
f = 0
for k in range(1,N):
  
  #f = 0
  for j in range(1,k)
  	if k % j == 0：
    	f += k
  
print(f)

N = input()
sum = 0
f = 0
for k in range(1,N):
  for j in range(1,k):
  	if k % j == 0：
    	sum += k
print(f)

N = int(input())
sum = 0
for k in range(N):
  for j in range(k):
  	if k % j == 0：
    	sum += k
print(sum)

N = int(input())
sum = 0
for k in range(N):
  
  f = 0
  for j in range(1,k)
  	if k%j == 0:
      f = f+1
  sum = sum + k*f
print(sum)

n = int(input())
sum = 0
for k in range(1,n+1):
  y = n // i
  sum += y*(y+1)*i//2
print(sum)

n = int(input())
sum = 0
for k in range(n):
  for j in range(k):
  	if k % j == 0：
    	sum += k
print(sum)

N = int(input())
sum = 0
f = 0
for k in range(1,N):
  
  #f = 0
  for j in range(1,k)
  	if k%j == 0：
    	f += k
  
print(sum)

N = int(input())
sum = 0
f = 0
for i in range(1,N):
  for j in range(1,N):
  	if k % j == 0：
    	sum += 1
print(f)

N = int(input())
sum = 0
f = 0
for k in range(1,N):
  for j in range(1,k):
  	if k % j == 0：
    	sum += k
print(f)

N = int(input())
sum = 0
for k in range(N):
  for j in range(int(k)):
  	if k % j == 0：
    	sum += k
print(sum)

n = int(input())
ans = 0
for i in range(1, n+1):
  y = n//i
  ans += y*(y+1)*i//2
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())
f = 0
for j in range(1,N+1):
    count = 0
    for i in range(1,int(j**0.5)+4):
        if j%i == 0:
            count +=1
    print(count)
    f = f + (j * count)
print(f)

N = int(input())
count = 0
for i in range(1,N+1):
    t = N//i
    count += i * t*(t+1)/2
print(int(count))

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.ceil(N/i)
  ans+=(Y*(Y+1)*x)//2
print(ans)

import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.floor(N/i)
  ans+=(Y*(Y+1)*i)//2
print(ans)

import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.ceil(N/i)
  ans+=(Y*(Y+1)*i)//2
print(ans)


N = int(input())
ans = 0
for i in range(1, N + 1):
    largest = N // i * i
    ans += ((largest + i) * (N // i)) // 2
print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())
import numpy
div = np.zeros(N+1, np.int64)
for n in range(1, N+1):
  for m in range(n, N+1, n):
    div[m] += m
print(sum(div))

n = int(input())
res = 0
for i in range(1,n+1):
    res += (i*(n//i)+i)*(n//i)//2
print(res)

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import math

n = int(input())
result = 0
for k in range(1, n+1):
    result += k


print(result)


import math

n = int(input())
result = 0

for i in range(1, n+1):
    sub = n//i
    result += (sub+1)*sub*i/2


print(int(result))


Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def func(n):
    div = 0 
    for i in range(1, int(n**0.5)+1):
        if(n%i == 0):
            div += 1
            if(i != n //i):
                div += 1
    return div

def main():
    N = int(input())

    ans = 0
    for i in range(1, N+1):
        ans += i*func(i)
    print(ans)

N = int(input())

ans = 0

for i in range(1, N+1):
    y = N//i
    ans += ((y*(y+1))//2)*i
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n=int(input())

ans=0
for i in range(1,n+1):
  num=n//i
  ans+=i*num*(num+1)/2
  
print(ans)


n=int(input())

ans=0
for i in rabge(1,n+1):
  num=n//i
  ans+=i*num*(num+1)/2
  
print(ans)

n=int(input())

ans=0
for i in range(1,n+1):
  num=n//i
  ans+=num*i

print(ans)

n=int(input())

ans=0
for i in range(1,n+1):
  num=n//i
  ans+=i*num*(num+1)//2
  
print(ans)


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
N, M = map(int, input().split())
import math
anss = 0
for i in range(abs(M - 2 * N), N + 1):
    d = math.factorial(i)
    for i in range(1, N - i + 1):
        d *= i
    anss += d
ans = 1
mod = 10 ** 9 + 7
for i in range(M, M - N, -1):
    ans *= i
    ans %= mod
ans = ans * anss
ans %= mod
print(ans)

N, M = map(int, input().split())
mod = 10 ** 9 + 7

def calc(n):
    f = 1
    factorials = [1]
    for m in range(1, n + 1):
        f *= m
        f %= mod
        factorials.append(f)
    inv = pow(f, mod - 2, mod)
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv
    return factorials, invs

factorials, invs = calc(M)
mPn = (factorials[M] * invs[M - N]) % mod
ans = (mPn * mPn) % mod
for k in range(1, N + 1):
    v = pow(-1, k - 1) * factorials[N] * factorials[M - k] * invs[N - k] * invs[k] * invs[M - N] % mod
    ans -= v * mPn
print(ans % mod)

Verdicts: Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
SIZE=4*10**5+1; MOD=10**9+7 
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): 
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(n,r): 
    return choose(n+r-1,r)

def narabekae(n,r): 
    return fac[n]*finv[n-r]%MOD


N,M=map(int,input().split())
ans=0
for k in range(N+1):
    ans+=choose(N,k)*narabekae(M-k,N-k)*(-1 if k%2==0 else 1)
    ans%=MOD
ans*=narabekae(M,N)

print(ans%MOD)


SIZE=5*10**5+1; MOD=10**9+7 
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): 
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(n,r): 
    return choose(n+r-1,r)

def narabekae(n,r): 
    return fac[n]*finv[n-r]%MOD


N,M=map(int,input().split())
ans=0
for k in range(N+1):
    ans+=choose(N,k)*narabekae(M-k,N-k)*(-1 if k%2==0 else 1)
    ans%=MOD
ans*=narabekae(M,N)
print(ans%MOD)


SIZE=5*10**5+1; MOD=10**9+7 
 
SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD
 
def choose(n,r): 
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
 
def chofuku(n,r): 
    return choose(n+r-1,r)

def narabekae(n,r): 
    return fac[n]*finv[n-r]%MOD


N,M=map(int,input().split())
ans=0
for k in range(N+1):
    ans+=choose(N,k)*narabekae(M-k,N-k)*(-1 if k%2==1 else 1)
    ans%=MOD
ans*=narabekae(M,N)
print(ans%MOD)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
M=10**9+7
n,m=map(int,input().split())
import sys, functools as ft
sys.setrecursionlimit(10**18)
@ft.lru_cache(None)
def f(n):
  if n<2: return 1
  return n*f(n-1)%M
a=0
for k in range(n+1):
  a+=(-1)**k*f(m-k)*pow(f(k)*f(n-k),-1,M)%M
print(a*f(n)*f(m)*pow(f(m-n)**2,-1,M)%M)

n,m=map(int,input().split())
M,F=10**9+7,[1]
for i in range(m): F+=[-~i*F[i]%M]
print(sum((-1)**k*F[m-k]*pow(F[k]*F[n-k]*F[m-n]**2,-1,M) for k in range(n+1))*F[n]*F[m]%M)

Verdicts: Runtime Error

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
import numpy as np

N = 10 ** 6
Nsq = 10 ** 3
mod = 10 ** 9 + 7

fac = np.arange(N, dtype=np.int64).reshape(Nsq, Nsq)
fac[0, 0] = 1
for i in range(1, Nsq):
    fac[:, i] *= fac[:, i - 1]
    fac[:, i] %= mod
for i in range(1, Nsq):
    fac[i] *= fac[i - 1, -1]
    fac[i] %= mod
fac = fac.ravel()

finv = np.arange(1, N + 1, dtype=np.int64)[::-1].reshape(Nsq, Nsq)
finv[0, 0] = pow(int(fac[N - 1]), mod - 2, mod)
for i in range(1, Nsq):
    finv[:, i] *= finv[:, i - 1]
    finv[:, i] %= mod
for i in range(1, Nsq):
    finv[i] *= finv[i - 1, -1]
    finv[i] %= mod
finv = finv.ravel()[::-1]


def nCr(a, b):
    if not a or not b:
        return 1
    comb = fac[a] * finv[b] % mod * finv[a - b] % mod
    return comb


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

res = 0
for i in range(1, n + 1):
    res += nCr(n, i) * nCr(m - n, i)
    res %= mod
print(res)


import numpy as np

N = 10 ** 6
Nsq = 10 ** 3
mod = 10 ** 9 + 7

fac = np.arange(N, dtype=np.int64).reshape(Nsq, Nsq)
fac[0, 0] = 1
for i in range(1, Nsq):
    fac[:, i] *= fac[:, i - 1]
    fac[:, i] %= mod
for i in range(1, Nsq):
    fac[i] *= fac[i - 1, -1]
    fac[i] %= mod
fac = fac.ravel()

finv = np.arange(1, N + 1, dtype=np.int64)[::-1].reshape(Nsq, Nsq)
finv[0, 0] = pow(int(fac[N - 1]), mod - 2, mod)
for i in range(1, Nsq):
    finv[:, i] *= finv[:, i - 1]
    finv[:, i] %= mod
for i in range(1, Nsq):
    finv[i] *= finv[i - 1, -1]
    finv[i] %= mod
finv = finv.ravel()[::-1]


def nCr(a, b):
    comb = fac[a] * finv[b] % mod * finv[a - b] % mod
    return comb


def nPr(a, b):
    comb = fac[a] * finv[a - b] % mod
    return comb


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

res = 0
for i in range(n + 1):
    res += nCr(n, i) * (-1) ** i * nPr(m - i, n - i)
    res %= mod
print(res * nPr(m, n) % mod)


Verdicts: Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
from scipy.special import perm
from scipy.special import comb

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

p = perm(m,n,exact=True)
mod = 10**9 + 7

d = [0]*n
d[0] += p
for i in range(1,n):
  d[i] += ((perm(m,n-i,exact=True)*(perm(m-n+i,i,exact=True)**2) - sum(d[:i]))*comb(n,i,exact=True)) % mod
  
print(d)

ans = (p**2 - sum(d[:n])) % mod
print(ans)

from scipy.special import perm
from scipy.special import comb

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

p = perm(m,n,exact=True)
mod = 10**9 + 7

d = [0]*n
d[0] += p
for i in range(1,n):
  d[i] += ((perm(m,n-i,exact=True)*(perm(m-n+i,i,exact=True)**2) - sum(d[:i]))*comb(n,i,exact=True)) % mod
  
print(d)

ans = (p**2 - sum(d[:n])) % mod
print(ans)

def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs
        

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

MOD = 10 ** 9 + 7
modFacts, invs = prepare(max(N, M))

ans = 0
for i in range(N + 1):
    Ti = (modFacts[N] * invs[i] * invs[N - i]) % MOD
    Ti *= (modFacts[M] * invs[M - i]) % MOD
    Ti %= MOD
    Ti *= pow(modFacts[M - i] * invs[(M - i) - (N - i)], 2, MOD)
    Ti %= MOD
    ans += pow(-1, i) * Ti
    ans %= MOD

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
n = int(input())
alst = list(map(int, input().split()))
if n == 2:
    if sum(alst) % 2 != 0:
        print(-1)
    elif alst[0] < alst[1]:
        print(-1)
    else:
        print((alst[0] - alst[1]) // 2)
    exit()

if alst.count(1) == n:
    if n % 2 == 0:
        print(0)
    else:
        print(-1)
    exit()
    
if alst.count(1) == n - 1:
    if n % 2 == 1:
        print(0)
    else:
        print(-1)
    exit()

xor = 0
for num in alst[2:]:
    xor ^= num
total = alst[0] + alst[1]
if xor > total:
    print(-1)
    exit()

diff = total - xor
if diff % 2 == 1:
    print(-1)
    exit()

if alst[0] == 1:
    if xor == alst[0] ^ alst[1]:
        print(0)
    else:
        print(-1)
    exit()
    
diff //= 2
total_bin = format(total, "b")
diff_bin = format(diff,"b")
xor_bin = format(xor,"b")
i = len(total_bin)
ans = 0
for j in range(i, 0, -1):
    if j <= len(diff_bin):
        if diff_bin[-j] == "1":
            ans += 2 ** (j - 1)
            continue
for j in range(i, 0, -1):
    if j <= len(diff_bin):
        if diff_bin[-j] == "1":
            continue
    if j <= len(xor_bin):
        if xor_bin[-j] == "0":
            continue    
    if ans + 2 ** (j - 1) < alst[0]:
        ans += 2 ** (j - 1)
if ans == 0 or ans >= alst[0]:
    print(-1)
else:
    print(alst[0] - ans)

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

N = m + 100
MOD = 10 ** 9 + 7
fact = [0 for _ in range(N)]
invfact = [0 for _ in range(N)]
fact[0] = 1
for i in range(1, N):
    fact[i] = i * fact[i - 1] % MOD

invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)

for i in range(N - 2, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % MOD
    
def nCk(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return fact[n] * invfact[k] * invfact[n - k] % MOD
        
def nPk(n, k):
    return fact[n] * invfact[n - k] % MOD
    
ans = 0
sign = 1

for i in range(n + 1):
    ans = (ans + nPk(m, i) * nCk(n, i) * nPk(m - i, n - i) ** 2 * sign) % MOD
    sign *= -1
    
print(ans)
    
    

Verdicts: Runtime Error

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
from functools import reduce
mod = 10**9 + 7
n, m = map(int, input().split())
 
def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD
 
a = 1
for i in range(1, n+1):
    a *= i
    a %= mod
 
print((comb(m, n, mod) * comb(m, n, mod) - (a*comb(m, n, mod)%mod)%mod))

import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10**9+7
N, M = map(int, readline().split())
 
fact = [1] * (M+1)
fact_inv = [1] * (M+1)
for i in range(1,M+1):
    fact[i] = fact[i-1] * i % mod 
fact_inv[M] = pow(fact[M],mod-2,mod)
for i in range(M,0,-1):
    fact_inv[i-1] = (i * fact_inv[i]) % mod 
 
def comb(n,r):
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod
total = 0
for k in range(N+1):
    a = fact[M-k] * fact_inv[M-N] * comb(N,k) % mod
    if k % 2 == 0:
        total += a
    else:
        total -= a
ans = (comb(M,N) * fact[N]) % mod * total 
print(ans%mod)

Verdicts: Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
max_fact = 5 * 10**5
mod = 10**9 + 7

f = [1] * (max_fact + 1)
for idx in range(2, max_fact + 1):
    f[idx] = f[idx - 1] * idx
    f[idx] %= mod
fi = [pow(f[-1], mod - 2, mod)]
for idx in range(max_fact, 0, -1):
    fi += [fi[-1] * idx % mod]
fi = fi[::-1]

def factorial(self, n):
    return f[n]

def factorial_inverse(self, n):
    return fi[n]

def combination(self, n, r):
    return f[n] * fi[r] * fi[n - r] % mod

def permutation(self, n, r):
    return f[n] * fi[n - r] % mod

def homogeneous_product(self, n, r):
    return f[n + r - 1] * fi[r] * fi[n - 1] % mod


comb = combination
perm = permutation

N, M = [int(_) for _ in input().split()]
ans = 0
for p in range(N + 1):
    ans += (-1)**p * comb(N, p) * perm(M - p, N - p)
    ans %= mod
ans *= perm(M, N)
ans %= mod
print(ans)


class Factorial:
    def __init__(self, max_fact, mod):
        #mod should be prime number
        
        f = [1] * (max_fact + 1)
        for idx in range(2, max_fact + 1):
            f[idx] = f[idx - 1] * idx
            f[idx] %= mod
        fi = [pow(f[-1], mod - 2, mod)]
        for idx in range(max_fact, 0, -1):
            fi += [fi[-1] * idx % mod]
        fi = fi[::-1]
        self.mod = mod
        self.f = f
        self.fi = fi

    def factorial(self, n):
        return self.f[n]

    def factorial_inverse(self, n):
        return self.fi[n]

    def combination(self, n, r):
        f = self.f
        fi = self.fi
        return f[n] * fi[r] * fi[n - r] % self.mod

    def permutation(self, n, r):
        return self.f[n] * self.fi[n - r] % self.mod

    def homogeneous_product(self, n, r):
        f = self.f
        fi = self.fi
        return f[n + r - 1] * fi[r] * fi[n - 1] % self.mod


max_fact = 5*10**5
mod = 10**9 + 7
fact_instance = Factorial(max_fact, mod)
comb = fact_instance.combination
perm = fact_instance.permutation

N, M = [int(_) for _ in input().split()]
ans = 0
for p in range(N + 1):
    ans += (-1)**p * comb(N, p) * perm(M - p, N - p)
    ans %= mod
ans *= perm(M, N)
ans %= mod
print(ans)


Verdicts: Runtime Error

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
MAX = 5 * (10**5)
MOD = 10**9 + 7
def inv(p):
    q = MOD - 2
    res = 1
    while q:
        if q % 2 == 1:
            res = (res*p) % MOD
        p = (p*p) % MOD
        q //= 2
    return res

_fact = [0] * (MAX + 1)
_inv = [0] * (MAX + 1)
_fact[0] = 1
_inv[0] = 1
for k in range(1, MAX + 1):
    _fact[k] = _fact[k-1] * k % MOD
    _inv[k] = inv(_fact[k])

def P(m, n):
    return _fact[m] * _inv[m-n] % MOD

def C(m, n):
    return _fact[m] * _inv[m-n] * _inv[n] % MOD

def solve(n, m):
    res = 0
    for k in range(n+1):
        sign = 1 - 2 * (k%2)
        cur = sign * C(n, k) * P(m, k) * (P(m-k, n-k) ** 2)
        res = (res + cur) % MOD
    return res

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

MAX = 5 * (10**5)
MOD = 10**9 + 7

_fact = [1,1] + [0] * MAX
_inv = [0,1] + [0] * MAX
_fact_inv = [1,1] + [0] * MAX
for k in range(2, MAX + 1):
    _fact[k] = _fact[k-1] * k % MOD
    _inv[k] = (-_inv[MOD % k] * (MOD // k)) % MOD
    _fact_inv[k] = _fact_inv[k-1] * _inv[k] % MOD

def P(m, n):
    return _fact[m] * _fact_inv[m-n] % MOD

def C(m, n):
    return _fact[m] * _fact_inv[m-n] * _fact_inv[n] % MOD

def solve(n, m):
    res = 0
    for k in range(n+1):
        sign = 1 - 2 * (k%2)
        cur = sign * C(n, k) * P(m, k) * (P(m-k, n-k) ** 2)
        res = (res + cur) % MOD
    return res

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

Verdicts: Time Limit Exceeded

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
# -*- coding: utf-8 -*-

from math import factorial
n,m=map(int,input().split())
nf=factorial(n)
mf=factorial(m)
mnf=factorial((m-n))

def ko1(x):
  kosuu1=0
  for i in range(x+1):
    kf=factorial(i)
    kosuu1+=int((nf/kf)*((-1)**i))
  kosuu1*=nf
  return kosuu1

def ko2(x,y):
  kosuu2=0
  for i in range(x+1):
    kf=factorial(i)
    mi=factorial((y-i))
    ni=factorial((x-i))
    kosuu2+=int((((-1)**i)*mi*nf)/(ni*mnf*kf))
  kosuu2*=int(mf/mnf)
  return kosuu2
if n==m:
  kosuu=int(ko1(n)/(10**9+1))
else:
  kosuu=int((ko2(n,m))%(10**9+1))
print(kosuu)

# -*- coding: utf-8 -*-

def facto(x):
  sumf=1
  if x==0:
    sumf=1
  else:
    for i in range(x):
      k=i+1
      sumf*=k
  return sumf
n,m=map(int,input().split())
nf=facto(n)
mf=facto(m)
mnf=facto((m-n))

def ko1(x):
  kosuu1=0
  for i in range(x+1):
    kf=facto(i)
    kosuu1+=int((nf/kf)*((-1)**i))
  kosuu1*=nf
  return kosuu1

def ko2(x,y):
  kosuu2=0
  for i in range(x+1):
    kf=facto(i)
    mi=facto((y-i))
    ni=facto((x-i))
    kosuu2+=int((((-1)**i)*mi*nf)/(ni*mnf*kf))
  kosuu2*=int(mf/mnf)
  return kosuu2
if n==m:
  kosuu=int(ko1(n)/(10**9+1))
else:
  kosuu=int((ko2(n,m))%(10**9+1))
print(kosuu)

# -*- coding: utf-8 -*-

def cmb(n,r,p):
  if r<0 or n<r:
    return 0
  r=min(r,n-r)
  return facto[n]*factoinv[r]*factoinv[n-r]%p
p=10**9+7
n,m=map(int,input().split())

facto=[1,1]

factoinv=[1,1]

inv=[0,1]

for i in range(2,m+1):
  facto.append((facto[-1]*i)%p)
  inv.append((-inv[p%i]*(p//i))%p)
  factoinv.append((factoinv[-1]*inv[-1])%p)
if n==m:
  kosuub=0
  for i in range(n+1):
    kosuub+=(facto[(n-i)]*cmb(n,i,p)*((-1)**i))%p
  kosuu=(kosuub*facto[(n)])%p
  print(kosuu)
else:
  kosuub=0
  for i in range(n+1):
    kosuub+=(cmb((m-i),(n-i),p)*facto[(n-i)]*cmb(n,i,p)*((-1)**i))%p
  kosuu=(kosuub*cmb(m,n,p)*facto[n])%p
  print(kosuu)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
MOD = 10**9 + 7
MAX = 5*10**5 + 1

fact = [0 for _ in range(MAX)]
factinv = [0 for _ in range(MAX)]

fact[0] = 1
for k in range(1, MAX):
    fact[k] = fact[k - 1]*k
    fact[k] %= MOD

factinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for k in range(MAX - 1, 0, -1):
    factinv[k - 1] = factinv[k]*k
    factinv[k - 1] %= MOD

def nCk(n, k):
    return fact[n]*factinv[k]*factinv[n - k] % MOD

def nPk(n, k):
    return fact[n]*factinv[n - k] % MOD

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

ans = 0
for k in range(n + 1):
    tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD
    if k % 2: ans += tmp
    else: ans -= tmp
    ans %= MOD

print(ans)

MOD = 10**9 + 7
MAX = 5*10**6 + 1

fact = [0 for _ in range(MAX)]
factinv = [0 for _ in range(MAX)]

fact[0] = 1
for k in range(1, MAX):
    fact[k] = fact[k - 1]*k
    fact[k] %= MOD

factinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for k in range(MAX - 1, 0, -1):
    factinv[k - 1] = fact[k]*k
    factinv[k - 1] %= MOD

def nCk(n, k):
    return fact[n]*factinv[k]*factinv[n - k] % MOD

def nPk(n, k):
    return fact[n]*factinv[n - k] % MOD

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

ans = 0
for k in range(n + 1):
    tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD
    if k % 2: ans += tmp
    else: ans -= tmp
    ans %= MOD

print(ans)

MOD = 10**9 + 7
MAX = 5*10**5 + 1

fact = [0 for _ in range(MAX)]
factinv = [0 for _ in range(MAX)]

fact[0] = 1
for k in range(1, MAX):
    fact[k] = fact[k - 1]*k
    fact[k] %= MOD

factinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for k in range(MAX - 1, 0, -1):
    factinv[k - 1] = fact[k]*k
    factinv[k - 1] %= MOD

def nCk(n, k):
    return fact[n]*factinv[k]*factinv[n - k] % MOD

def nPk(n, k):
    return fact[n]*factinv[n - k] % MOD

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

ans = 0
for k in range(n + 1):
    tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD
    if k % 2: ans += tmp
    else: ans -= tmp
    ans %= MOD

print(ans)

MOD = 10**9 + 7
MAX = 5*10**5 + 1

fact = [0 for _ in range(MAX)]
factinv = [0 for _ in range(MAX)]

fact[0] = 1
for k in range(1, MAX):
    fact[k] = fact[k - 1]*k
    fact[k] %= MOD

factinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)
for k in range(MAX - 1, 0, -1):
    factinv[k - 1] = factinv[k]*k
    factinv[k - 1] %= MOD

def nCk(n, k):
    return fact[n]*factinv[k]*factinv[n - k] % MOD

def nPk(n, k):
    return fact[n]*factinv[n - k] % MOD

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

ans = 0
for k in range(n + 1):
    tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD
    if not k % 2: ans += tmp
    else: ans -= tmp
    ans %= MOD

print(ans)

Verdicts: Wrong Answer

Time Limit Exceeded

Wrong Answer

Accepted
Problem: Count the pairs of length-N sequences consisting of integers between 1 and M (inclusive), A_1, A_2, \cdots, A_{N} and B_1, B_2, \cdots, B_{N}, that satisfy all of the following conditions:    * A_i \neq B_i, for every i such that 1\leq i\leq N.   * A_i \neq A_j and B_i \neq B_j, for every (i, j) such that 1\leq i < j\leq N.  Since the count can be enormous, print it modulo (10^9+7).

Submission attempts (in order):
MOD = 1000000007

COM_MAX = 10 ** 6

fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1

for i in range(2, COM_MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def com(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD


def perm(n, r):
    if n < 0 or r < 0 or n < r:
        return 0
    return fac[n] * finv[n - r] % MOD


def mod_com_once(n, r, MOD):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(n - r + 1, n + 1):
        numer = numer * i % MOD
    for i in range(1, r + 1):
        denom = denom * i % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())

    COM_MAX = M

    fac, finv, inv = [0] * (COM_MAX + 1), [0] * (COM_MAX + 1), [0] * (COM_MAX + 1)
    fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1

    for i in range(2, COM_MAX + 1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    def com(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD

    def perm(n, r):
        if n < 0 or r < 0 or n < r:
            return 0
        return fac[n] * finv[n - r] % MOD

    ans = 0
    for k in range(N + 1):
        tmp = perm(M - k, N - k) * com(N, k) % MOD
        if k & 1:
            tmp *= -1
        ans = (ans + tmp) % MOD

    ans = ans * perm(M, N) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: There are N piles of stones. The i-th pile has A_i stones.  Aoki and Takahashi are about to use them to play the following game:    * Starting with Aoki, the two players alternately do the following operation:     * Operation: Choose one pile of stones, and remove one or more stones from it.   * When a player is unable to do the operation, he loses, and the other player wins.  When the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.  In such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.  If this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print `-1` instead.

Submission attempts (in order):
print(-1)

import sys
from functools import lru_cache


def solve(n, aaa):
    if n == 2:
        h, m = divmod(sum(aaa), 2)
        if m == 1 or h > aaa[0]:
            return -1
        return aaa[0] - h

    x = 0
    for a in aaa[2:]:
        x ^= a
    a0, a1 = aaa[:2]
    s = a0 + a1

    if s & 1 != x & 1:
        return -1

    b = 1 << 40
    MASK = (b << 1) - 1

    @lru_cache(maxsize=None)
    def dfs(p, b):
        if b == 0:
            return p
        m = (MASK ^ (b - 1)) << 1
        q = p ^ x & m
        if x & b == 0:
            if s >= p + q + 2 * b:
                if p | b <= a0:
                    return dfs(p | b, b >> 1)
                else:
                    return -1
            return dfs(p, b >> 1)
        else:
            if s < p + q + b:
                return -1
            if p | b <= a0:
                ret = dfs(p | b, b >> 1)
                if ret != -1:
                    return ret
            return dfs(p, b >> 1)

    ret = dfs(0, b)

    if ret <= 0:
        return -1
    return a0 - ret


n, *aaa = map(int, sys.stdin.buffer.read().split())
print(solve(n, aaa))


Verdicts: Wrong Answer

Accepted
Problem: There are N piles of stones. The i-th pile has A_i stones.  Aoki and Takahashi are about to use them to play the following game:    * Starting with Aoki, the two players alternately do the following operation:     * Operation: Choose one pile of stones, and remove one or more stones from it.   * When a player is unable to do the operation, he loses, and the other player wins.  When the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.  In such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.  If this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print `-1` instead.

Submission attempts (in order):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    xorR = 0
    for i in range(2, N):
        xorR ^= A[i]
    rbit = [0] * 40
    K = xorR
    for i in range(40):
        rbit[i] = K % 2
        K //= 2
    
    D = A[0] + A[1] - xorR
    if D < 0 or D % 2 == 1:
        print(-1)
        return 0
    else:
        D //= 2
        K = D
        dbit = [0] * 40
        for i in range(40):
            dbit[i] = K % 2
            K //= 2
        A0, A1 = 0, 0
        for i in range(40):
            if rbit[39 - i] == dbit[39 - i] == 1:
                print(-1)
                break
            else:
                if rbit[39 - i] == 1:
                    if (A0 + pow(2, 39 - i)) ^ D <= A[0]:
                        A0 += pow(2, 39 - i)
                    else:
                        A1 += pow(2, 39 - i)
        if A0 > 0: print(A[0] - A0)
        else: print(-1)

    return 0

if __name__ == "__main__":
    solve()

import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    xorR = 0
    for i in range(2, N):
        xorR ^= A[i]
    rbit = [0] * 41
    K = xorR
    for i in range(41):
        rbit[i] = K % 2
        K //= 2
    
    D = A[0] + A[1] - xorR
    if D < 0 or D % 2 == 1:
        print(-1)
        return 0
    else:
        D //= 2
        if D > A[0]:
            print(-1)
            return 0

        K = D
        dbit = [0] * 41
        for i in range(41):
            dbit[i] = K % 2
            K //= 2
            
        A0 = D
        for i in range(41):
            if rbit[40 - i] == dbit[40 - i] and rbit[40 - i] == 1:
                print(-1)
                return 0
            else:
                if rbit[40 - i] == 1:
                    if A0 + pow(2, 40 - i) <= A[0]:
                        A0 += pow(2, 40 - i)
        if A0 > 0: print(A[0] - A0)
        else: print(-1)

    return 0

if __name__ == "__main__":
    solve()

Verdicts: Wrong Answer

Accepted
Problem: There are N piles of stones. The i-th pile has A_i stones.  Aoki and Takahashi are about to use them to play the following game:    * Starting with Aoki, the two players alternately do the following operation:     * Operation: Choose one pile of stones, and remove one or more stones from it.   * When a player is unable to do the operation, he loses, and the other player wins.  When the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.  In such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.  If this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print `-1` instead.

Submission attempts (in order):
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

v = 0
for i in a[2:]:
    v ^= i

w = a[0]+a[1]

z = w-v
if z&1 or z<0 or z&w:
    print(-1)
else:
    z //= 2
    
    #print(z,v,z&w)
    ans = z
    for i in range(60,-1,-1):
        m = 1<<i
        if v&m:
            if ans+m <= a[0]:
                ans += m
                #print(ans,i)

    if ans >= a[0] or ans==0: print(-1)
    else: print(a[0]-ans)        
        
        
        
        
            






# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,*a = map(int,read().split())

v = 0
for i in a[2:]:
    v ^= i

w = a[0]+a[1]

z = w-v
if z&1==1 or z<0:
    print(-1)
else:
    z //= 2
    
    if z&v:
        print(-1)
        exit()

    ans = z
    for i in range(60,-1,-1):
        m = 1<<i
        if v&m:
            if ans+m <= a[0]:
                ans += m
                #print(ans,i)

    if ans > a[0] or ans==0: print(-1)
    else: print(a[0]-ans)        
        
        
        
        
            






Verdicts: Wrong Answer

Accepted
Problem: There are N piles of stones. The i-th pile has A_i stones.  Aoki and Takahashi are about to use them to play the following game:    * Starting with Aoki, the two players alternately do the following operation:     * Operation: Choose one pile of stones, and remove one or more stones from it.   * When a player is unable to do the operation, he loses, and the other player wins.  When the two players play optimally, there are two possibilities in this game: the player who moves first always wins, or the player who moves second always wins, only depending on the initial number of stones in each pile.  In such a situation, Takahashi, the second player to act, is trying to guarantee his win by moving at least zero and at most (A_1 - 1) stones from the 1-st pile to the 2-nd pile before the game begins.  If this is possible, print the minimum number of stones to move to guarantee his victory; otherwise, print `-1` instead.

Submission attempts (in order):
n=int(input())
a=list(map(int, input().split()))
X=0
for i in a[2:]:X^=i
m=a[0]+a[1]-X
if m>a[0]or(m&X)!=0:exit(print(-1))
l=1<<max(x.bit_length(),m.bit_length())
while l > 0:
 if (m&l)!=0and(a|b)<=a[0]:a|=b
 b>>=1
print(a[0]-m if a!=0else-1)

n=int(input())
a=list(map(int,input().split()))
x=0
for i in a[2:]:x^=i
m=(a[0]+a[1]-x)//2
if a[0]+a[1]!=x+m*2or m>a[0]or(x&m)!=0:exit(print(-1))
l=1<<(max(x.bit_length(),m.bit_length())+1)
while l>0:
 if((x&l)!=0)and((m|l)<=a[0]):m|=l
 l>>=1
print(a[0]-m if m!=0else-1)

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
a=input()
if(a.islower()==True):
    print(a.upper())
else:
    print(a.lower())

a=input()
if(a.islower()==True):
    print("A")
else:
    print("a")

a=input()
if(a.islower()==True):
    print("a")
else:
    print("A")

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
a = input()
if a.upper() == True:
  print('A')
else:
  print("a")

a = input()
if a.isupper() == True:
  print('A')
else:
  print("a")

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
N = int(input())
ab = [chr(ord('a') + i) for i in range(26)]
j = 1
while True:
  temp = 1000000000000001//(26**j)
  j+=1
  if temp<1:
    break
ans = ''
for i in range(1, j+2):
  ax = (N//(26**(i-1)))%26
  if ax==0:
    ax = 25
  ans += ab[ax]
  if N//(26**i)<1:
    print(ans[::-1])
    sys.exit()

# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
a = str(input())
if a.isupper():
  print('A')
else:
  print('a')

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
print(chr(ord(input())+32))

if 'a' <= input() <= 'z':print('a')
else:print('A')

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
alf=input()
if 'alf'.isupper():
  print('A')
else:
  print('a')
  

alf=input()
if alf.isupper():
  print('A')
else:
  print('a')
  

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
n,m=map(int,input().split())
l=list(map(int,input().split()))
s=0
l.sort()
x=l[:m]
   
print(sum(x))


s=input()
if s.isupper():
    print("A")
else:
    print("a")


Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
N=input()
if N.isupper()=="TRUE":
    print("A")
else:
    print("a")

N=input()

if N.isupper()==True:
    print("A")
else:
    print("a")

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
def main():
  c = input()
  if c.isupper():
    print(c.lower())
  else:
    print(c.upper())

main()


def main():
  c = input()
  if c.isupper():
    print('A')
  else:
    print('a')
 
main()

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
a = input()
print(a)

if a.isupper():
    print('A')
else:
    print('a')

a = input()

if a.isupper():
    print('A')
else:
    print('a')

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):

def test(a):
	if tmp.isupper():
		return 'A'
	else:
		return 'a'
      
test(input())


def test(a):
	if a.isupper():
		return 'A'
	else:
		return 'a'
      
test(input())

tmp = input()
if tmp.isupper():
  print 'A'
else:
  print'a'

def test(a):
	if a.isupper():
		print('A')
	else:
		print('a')

        
test(input())

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
num=int(input())


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans=num2alpha(num).lower()

print(ans)

str=input()
a=str.isupper()
if a==True:
    print("A")
else:
    print("a")

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
print(input().swapcase())

X=int(input())
n=26

a=[]
X_dumy = X
out = ''
while X_dumy>0:
  out = str(X_dumy%n)
  X_dumy = int(X_dumy/n)
  a.append(out)

l = list('abcdefghijklmnopqrstuvwxyz')
N=0
for x in a:
  a[N]=l[int(a[N])-1]
  N=N+1
pg = ''.join(a)
print(pg)

if input().isupper():
  print("A")
else:
  print("a")

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
s=str(input())
S=s.swapcase()
print(S)

s=str(input())
if(s.islower()==True):
    print('a')
else:
    print('A')

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
if input().issuper():
  print("a")
else:
  print("a")

if input().isupper():
  print("A")
else:
  print("a")

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
alpha = str(input())
if str.isupper(alpha) = True:
  print("A")
else:
  print("a")

alpha = input()
if alpha.isupper():
  print("A")
else:
  print("a")

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
print(“aA”[input().isupper()])

print("aA"[input().isupper()])

Verdicts: Runtime Error

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
if(input().islower):print('a')
else: print('A')

if (input().islower()):print('a')
else: print('A')

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
c = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

a=input()

for i in range(52):
    if c[i]== a:
        d = i + 26
        if d > 51:
            d = i-26
        print(c[d])
        exit(0)

c = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'

a=input()

for i in range(52):
    if c[i]== a:
        if i > 25:
            print("A")
        else:
            print("a")
        exit(0)

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):
a = input()
print(a.lower())

a = input()
if a.isupper():
    print("A")
else:
    print("a")

Verdicts: Wrong Answer

Accepted
Problem: An uppercase or lowercase English letter \alpha will be given as input. If \alpha is uppercase, print `A`; if it is lowercase, print `a`.

Submission attempts (in order):

A = input()



N = A.isupper()

print(N)

if N == True:
    print("A")
else :
    print("a")


A = input()



N = A.isupper()

#print(N)

if N == True:
    print("A")
else :
    print("a")

Verdicts: Wrong Answer

Accepted