Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from requests import api

n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
sv = sum(v)
INF = float("INF")
dp = [[INF]*sv for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(sv):
        if j-v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i])
        dp[i+1][j] = min(dp[i+1][j],dp[i][j])
    #print(dp)
ans = 0
for i in range(sv):
    #print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)


Fixed submission:
n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
mv = sum(v)
INF = float("INF")
dp = [[INF]*(mv+100) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for sv in range(mv+100):
        if sv-v[i] >= 0:
            dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv-v[i]]+w[i])
        dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv])
    #print(dp)
ans = 0
for i in range(mv+100):
    #print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)

Buggy python submission (verdict: Runtime Error):
from requests import api

n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
sv = sum(v)
INF = float("INF")
dp = [[INF]*sv for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(sv):
        if j-v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i])
        dp[i+1][j] = min(dp[i+1][j],dp[i][j])
    #print(dp)
ans = 0
for i in range(sv):
    print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)


Fixed submission:
n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
mv = sum(v)
INF = float("INF")
dp = [[INF]*(mv+100) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for sv in range(mv+100):
        if sv-v[i] >= 0:
            dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv-v[i]]+w[i])
        dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv])
    #print(dp)
ans = 0
for i in range(mv+100):
    #print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans = 99999999999999999999999999
for i in range(n-k+1):
    x = h[i:i+k]
    ans = min(ans,max(x)-min(x))
print(ans)

Fixed submission:
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
l = [h[i+k-1]-h[i] for i in range(n-k+1)]
print(min(l))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
p = {str(i):[] for i in range(1,n+1)}
l = []
for i in range(m):
    t = input().split()
    l.append((t[0],int(t[1])))
    p[t[0]].append(int(t[1]))
for i in range(1,n+1):
    p[str(i)].sort()
for t in l:
    print(t[0].zfill(6)+str(p[t[0]].index(t[1])+1).zfill(6))

Fixed submission:
n,m = map(int,input().split())
p = {str(i):[] for i in range(1,n+1)}
l = []
for i in range(m):
    t = input().split()
    l.append((t[0],int(t[1])))
    p[t[0]].append(int(t[1]))
for i in range(1,n+1):
    i = str(i)
    p[i].sort()
    d = {}
    for j in range(len(p[i])):
        d[p[i][j]] = str(i).zfill(6)+str(j+1).zfill(6)
    p[i]=d
for t in l:
    print(p[t[0]][t[1]])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o(2)[0][1]-e(2)[0][1])

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o[0][1]-e[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())
a = list(map(int,input().split()))
s = list(set(a))
ans = 10**6
if len(s)==1:
    print(n//2)
else:
    for t in combinations(s,2):
        b = 0
        c = 0
        for i in range(n):
            if i%2==0:
                if t[1]!=a[i]:
                    b+=1
                if t[0]!=a[i]:
                    c+=1
            else:
                if t[0]!=a[i]:
                    b+=1
                if t[1]!=a[i]:
                    c+=1
        ans = min(ans,b,c)
    print(ans)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o[0][1]-e[0][1])
Buggy python submission (verdict: Runtime Error):
//#define _GLIBCXX_DEBUG
//#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int a[n]; for (int i = 0; i<n; i++) cin >> a[i];
    cout << (((n-k)+(k-2))/(k-1))+1 << "\n";
}

Fixed submission:
import math

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-k)/(k-1))+1)

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    int a[n];
    cout << (((n-k)+(k-2))/(k-1))+1 << "\n";
}

Fixed submission:
import math

n,k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-k)/(k-1))+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
while(any([ai % 2 == 0 for ai in a])):
    ans += 1
    for i in range(n):
        ai = a[i]
        if ai % 2 == 0:
            a[i] = ai // 2
            break
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    x = 0
    ai = a[i]
    while(ai%2==0):
        ai = ai//2
        x+=1
    ans+=x
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(ans)==20:
    print("Unfair")
else:
    print(ans)

Fixed submission:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 or k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(abs(ans)))==20:
    print("Unfair")
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())
n = [a,b,c]
for i in range(k):
    t = n[:]
    for i,ind in zip(n,range(3)):
        t[ind] = sum(n)-i
    n=t[:]
print(n[0]-n[1])

Fixed submission:
a,b,c,k = map(int,input().split())
ans = 0
if k==0 or k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(abs(ans)))==20:
    print("Unfair")
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
if max(a,b,k) == k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,b+1):
        if abs(i-a)<k or abs(i-b)<k:
            print(i)

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

Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for i in range(1,b+1):
    if (a<=i and b>=i) and (abs(a-i)<k or b-i<k):
        print(i)


Fixed submission:
a,b,k = map(int,input().split())
if b-a<2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))

_ = 0
while all(a % 2 == 0 for a in A):
    A = [i/2 for i in A]
    _ += 1
print(_)


Fixed submission:
a = 0
s = input()
for i in s:
    if i == '1':
        a = a + 1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
for ai in a:
  for bi in b:
    for ci in c:
      if ai<bi and bi<ci:
        ans+=1
print(ans)

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(),c.sort()
x=len(c)
ans=0
for bi in b:
  xa=bisect.bisect_right(c,bi)
  xb=bisect.bisect_left(a,bi)
  ans+=xb*(x-xa)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
w = []
for i in range(len(s) - len(t) + 1):
    f = True
    sx = s[i:i + len(t)]
    for si, ti in zip(sx, t):
        if si != ti and si != "?":
            f = False
        else:
            pass
    if f:
        w.append((s[:i] + t).replace("?", "a"))
if w == []:
    print("UNRESTORABLE")
else
w.sort()
print(w[0])


Fixed submission:
sd = input()
t = input()
oks = []
if len(sd) < len(t):
    print("UNRESTORABLE")
else:
    for i in range(len(sd)-len(t)+1):
        sdd = sd[i:i+len(t)]
        f = True
        for j,sddj in enumerate(sdd):
            if sddj == "?":
                continue
            elif sddj != t[j]:
                f = False
                break
        if f:
            oks.append(i)
    if oks:
        k = oks[-1]
        print((sd[:k]+t+sd[k+len(t):]).replace("?","a"))
    else:
        print("UNRESTORABLE")
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=int(input())
print((i*i)-m)

Fixed submission:
n=int(input())
m=int(input())
print((n*n)-m)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cx=[0]*max(a)
for ai in a:
  cx[ai-1]+=1
ans=0
for ci in cx:
  if ci%2!=0:
    ans+=1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
c = Counter(a)
for i in c.values():
    if i%2!=0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
ans=0
for ai in a:
  if a.count(ai)%2!=0:
    ans+=1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
c = Counter(a)
for i in c.values():
    if i%2!=0:
        ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
x=[]
for ai in a:
  if ai in x:
    x.pop(x.index(ai))
  else:
    x.append(ai)
print(len(x))

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
c = Counter(a)
for i in c.values():
    if i%2!=0:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+1)
for i in a:
  an[i-1]+=1
  an[i-2]+=1
  an[i]+=1
print(max(an))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
  if i!=0:
    an[i-1]+=1
  an[i+1]+=1
  an[i]+=1
print(max(an))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
r=a[:]
r.extend([i-1 for i in a])
r.extend([i+1 for i in a])
for i in set(r):
  x=0
  for ai in a:
    if ai==i or ai-1==i or ai+1==i:
      x+=1
  ans=max(ans,x)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
  if i!=0:
    an[i-1]+=1
  an[i+1]+=1
  an[i]+=1
print(max(an))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
r=a[:]
r.extend([i-1 for i in a])
r.extend([i+1 for i in a])

for i in r:
  x=0
  for ai in a:
    if ai==i or ai-1==i or ai+1==i:
      x+=1
  ans=max(ans,x)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
  if i!=0:
    an[i-1]+=1
  an[i+1]+=1
  an[i]+=1
print(max(an))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(max(a)+1):
  x=0
  for ai in a:
    if ai==i or ai-1==i or ai+1==i:
      x+=1
  ans=max(ans,x)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
  if i!=0:
    an[i-1]+=1
  an[i+1]+=1
  an[i]+=1
print(max(an))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
ans = []
for i in range(1,n):
    ans.append(abs(x-2*sum(a[:i])))
print(min(ans))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = 9e11
s = sum(a)
for i in range(1,n):
    x=min(x,abs(s-sum(a[:i]*2)))
print(x)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = 1145141919810
for i in range(1,n):
    x=min(x,abs(sum(a[:i])-sum(a[i:])))
print(x)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = []
for i in range(1,n):
    x.append(abs(sum(a[:i])-sum(a[i:])))
print(min(x))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(input()) for i in range(n)]
ans=0
for i in range(2**len(s)):
    x=0
    for j in range(n):
        if (i>>j)&1:
            x+=s[j]
    if x%10!=0:
        ans=max(ans,x)
print(ans)

Fixed submission:
n = int(input())
s = [int(input()) for i in range(n)]
ans=0
m = sum(s)
if m%10==0:
    f = True
    s.sort()
    for si in s:
        if si%10!=0:
            print(m-si)
            f = False
            break
    if f:
        print(0)
else:
    print(m)
Buggy python submission (verdict: Runtime Error):
n=int(input().split())
a=list(map(int,input().split()))
if sum(a)%2==0:
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if sum(a)%2==0:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if len(a)%3 == 0
  print("YES")
else:
  print("NO")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if sum(a)%2==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0

ab = [tuple(map(int,input().split())) for i in range(n)]
a,b = [],[]
for ai,bi in ab:
    a.append(ai)
    b.append(bi)

c = 0
for i in reversed(range(n)):
    a[i] += c
    while(a[i]%b[i]):
        c+=1
        a[i]+=1
    
print(c)

Fixed submission:
n = int(input())
ans = 0

a, b = [], []
for i in range(n):
    ai, bi = map(int, input().split())

    a.append(ai)
    b.append(bi)

c = 0
for i in reversed(range(n)):
    a[i] += c
    x = a[i] % b[i]
    if x:
        if a[i] < b[i]:
            c += b[i] - a[i]
        elif a[i] > b[i]:
            c += b[i] - x

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0

ab = [tuple(map(int,input().split())) for i in range(n)]
a,b = [],[]
for ai,bi in ab:
    a.append(ai)
    b.append(bi)

c = 0
for i in reversed(range(n)):
    a[i] += c
    while(a[i]%b[i]):
        c+=1
        a[i]+=1
    
print(c)

Fixed submission:
n = int(input())
ans = 0

a, b = [], []
for i in range(n):
    ai, bi = map(int, input().split())

    a.append(ai)
    b.append(bi)

c = 0
for i in reversed(range(n)):
    a[i] += c
    x = a[i] % b[i]
    if x:
        if a[i] < b[i]:
            c += b[i] - a[i]
        elif a[i] > b[i]:
            c += b[i] - x

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
n = 0
for i in range(a,b+1):
  if (i%x) == 0:
    n += 1
print(n)

Fixed submission:
a,b,x = map(int,input().split())
print((b//x)-(a//x)+(a%x == 0))
Buggy python submission (verdict: Runtime Error):
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    short h,w,ans = 0;
    cin >> h >> w;
    char ai[10];
    rep(i,h) {
        cin >> ai;
        rep(j,8) if (ai[j] == '#') ans ++;
    }
    if (ans == h+w-1) cout << "Possible\n";
    else cout << "Impossible\n";
}

Fixed submission:
def search(y,x,oy,ox,r):
    if y == h-1 and x == w-1:
        return r
    l = []
    for i,j in t:
        ny,nx = y+i,x+j
        if (0 <= ny < h and 0 <= nx < w) and not (ny == oy and nx == ox):
            if a[ny][nx] == "#":
                l.append((ny,nx))

    if 1 < len(l) or len(l) == 0:
        return r
    else:
        r.add((l[0][0],l[0][1]))
        return search(l[0][0],l[0][1],y,x,r)

h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
t = ((0,1),(1,0))

s = search(0,0,0,0,set([(0,0),(h-1,w-1)]))
f = True
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and not (i,j) in s:
            print("Impossible")
            exit(0)
print("Possible")
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}

Fixed submission:
s = input()
ans = 0
p = s[0]
for si in s:
    ans += p != si
    p = si
print(ans)

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}

Fixed submission:
s = input()
ans = 0
p = s[0]
for si in s:
    ans += p != si
    p = si
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,b = map(int,input().split())
for i in range(x+1,b+1):
    x=x*i
if x>0:
    print("Positive")
elif x<0:
    print("Negative")
elif x==0:
    print("Zero")

Fixed submission:
a,b = map(int,input().split())
if 0<a and a<=b:
    print("Positive")
elif a<=b and b<0:
    if (b-a+1)%2==0:
        print("Positive")
    else:
        print("Negative")
elif a<=0 and 0<=b:
    print("Zero")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
mem = defaultdict(lambda : None)
mem[(0,0,0)] = 0
def dp(a,b,s):
  if mem[(a,b,s)] is not None:
    return mem[(a,b,s)]
  x = a&1
  y = b&1
  xor = s&1
  res = float("inf")
  if x^y != xor:
    mem[(a,b,s)] = res
    return res
  else:
    res = 2*dp(a>>1,b>>1,s>>1)
    if a > 1:
      pants = 2*dp((a-1)>>1,(b+1)>>1,s>>1)+1
      if pants < res:
        res = pants
  mem[(a,b,s)] = res
  return res

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a[2:]:
  s ^= i
b = a[1]
a = a[0]
ans = dp(a,b,s)
if ans == float("inf"):
  ans = -1
print(ans)


Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a = I()
    print(a+a**2+a**3)
    return

#Solve
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
mem = defaultdict(lambda : None)
mem[(0,0,0)] = 0
def dp(a,b,s):
  if mem[(a,b,s)] is not None:
    return mem[(a,b,s)]
  x = a&1
  y = b&1
  xor = s&1
  res = float("inf")
  if x^y != xor:
    mem[(a,b,s)] = res
    return res
  else:
    res = 2*dp(a>>1,b>>1,s>>1)
    if a > 1:
      pants = 2*dp((a-1)>>1,(b+1)>>1,s>>1)+1
      if pants < res:
        res = pants
  mem[(a,b,s)] = res
  return res

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a[2:]:
  s ^= i
b = a[1]
a = a[0]
ans = dp(a,b,s)
if ans == float("inf"):
  ans = -1
print(ans)


Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def comb(a,b):
        return f[a]*inv[b]*inv[a-b]%mod
    n,m = LI()
    N = n+m
    f = [1]*(N+1)
    for i in range(1,N+1):
        f[i] = f[i-1]*i%mod
    inv = [None]*(N+1)
    inv[N] = pow(f[N],mod-2,mod)
    for i in range(N)[::-1]:
        inv[i] = inv[i+1]*(i+1)%mod
    ans = comb(m,n)*f[n]
    for i in range(1,n+1):
        if i&1:
            ans -= comb(n,i)*comb(m-i,n-i)*f[n-i]%mod
        else:
            ans += comb(n,i)*comb(m-i,n-i)*f[n-i]%mod
        ans %= mod
    print(ans*comb(m,n)*f[n]%mod)
    return

#Solve
if __name__ == "__main__":
    solve()