akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<int> z_algorithm(string s){
	// z[i] : s[i]から始まるtの部分列でsのprefixと一致するもののうち最長のものの長さ
	int n = s.length();
	vector<int> z(n,0);

	int l=0,r=0;
	z[0] = n;
	for (int i = 1; i < n; i++){
		if(i>r){
			l=i,r=i;
			while(r<n && s[r]==s[r-l]) r++;
			z[i]=r-l;
			r--;
		}else{
			int k = i-l;
			if(z[k]<r-i+1){
				z[i]=z[k];
			}else{
				l=i;
				while(r<n && s[r]==s[r-l]) r++;
				z[i]=r-l;
				r--;
			}
		}
	}
	return z;
}

P toporogical_sort(const vector<vector<int> > g){
	int n = g.size();
	vector<int> in_degree(n,0);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_degree[g[i][j]]++;
		}
	}

	vector<int> res,length(n);
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_degree[i]==0) S.push(i),length[i]=0;
	}

	while(!S.empty()){
		int p = S.top();
		S.pop();
		res.push_back(p);
		for(int i = 0; i < g[p].size(); i++){
			in_degree[g[p][i]]--;
			if(in_degree[g[p][i]]==0) S.push(g[p][i]),length[g[p][i]]=length[p]+1;
		}
	}

	return P(res.size(),*max_element(all(length)));
}

vector<vector<int>> g;
vector<int> used,deg;

bool dfs(int x){
	used[x] = 1;
	deg[x]--;
	for (int p = 0; p < g[x].size(); p++){
		if(used[g[x][p]]<0) dfs(g[x][p]);
		if(used[g[x][p]]){
			return false;
		}
	}
	return true;
}

int main()
{
	string s,t;
	cin>>s>>t;

	int n = s.size(), m = t.size();
	string res=s;
	for (int cnt = 0; cnt < m/n; cnt++){
		res += s;
	}
	s=res;
	s += s;
	// n = s.size();

	s = t + '0' + s;

	vector<int> z = z_algorithm(s);
	g.resize(n,vector<int>());
	set<P> edge;
	for (int i = m+1; i < s.size(); i++){
		if(z[i]==t.size()) edge.insert(P((i-(m+1))%n, (i-(m+1)+z[i])%n));
	}

	deg.resize(n,0);
	for(auto x: edge){
		g[x.first].push_back(x.second);
		deg[x.second]++;
	}
	// cout<<s<<endl;

	// for (int i = 0; i < n; i++){
	// 	cout<<"node = "<< i<< " ";
	// 	for (int j = 0; j < g[i].size(); j++){
	// 		cout<<g[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }


	P ans = toporogical_sort(g);
	cout<<(ans.first==n?ans.second:-1)<<endl;

	// cout<<toporogical_sort(g)<<endl;

	return 0;
}

Measured memory_bytes: 97900
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for(int i = 1; i < n; i++) {
		if(a[i] >= a[i - 1]) {

		}
		else {
			ans += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 5204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   ll n,m;
   cin >> n >> m;
   if (n == 1 || m == 1){
      if (n*m - 2 == 0) cout << 0 << endl;
      else if (n*m -2 == -1) cout << 1 << endl;
      else cout << n*m -2 << endl;
   }
   else if (n == 2 || m == 2){
      cout << 0 << endl;
   }
   else{
      cout << (n-2)*(m-2) << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) :n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; i++) {
            if (f[i]) {
                continue;
            }
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) {
                    f[j] = i;
                }
            }
        }
    }

    bool isPrime(int x) {
        return f[x] == x;
    }

    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) {
            return {};
        }
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            }
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    int n;
    cin >> n;
    Sieve sieve(55555);
    int cnt = 0;
    for(int x : sieve.primes){
        if(x % 5 == 1){
            cout << x << ' ';
            cnt++;
        }
        if(cnt == n){
            cout << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if (a+b>c+d) {
    cout << "Left" << endl;
  }
  else if(a+b==c+d){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int f(int a, int b, int x, int y) {
	if(a > x) {
		swap(a, x);
		swap(b, y);
	}
	if(b < y)
		return x + y - a - b - min(x - a, y - b);
	return x - a + abs(y - b);
}

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n >> n >> n;
	int ans = 0, x = 0, y = 0;
	while(n --) {
		int a, b; cin >> a >> b;
		if(x)
			ans += f(a, b, x, y);
		x = a; y = b;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3120
import sys
from array import array

N = 1000000
primes = array('I',[1]) * (N//2)
primes[0] = 0

for i in range(3,int(N**0.5),2):
    if primes[i//2]:
        primes[(i*i)//2::i] = array('I',[0]) * len(primes[(i*i)//2::i])

for i in sys.stdin:
    n = int(i)
    if n < 4:
        print(n-1)
    else:
        print(sum(primes[:(n+1)//2])+1)

Measured memory_bytes: 12140
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp[-1])

Measured memory_bytes: 13980
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += sc.nextInt() - 1;
		}
		System.out.println(sum);
	}
}




Measured memory_bytes: 26600
H, W, D = list(map(int, input().split()))
A = []
for i in range(H):
    A.append(list(map(int, input().split())))
Q = int(input())
LR = []
for i in range(Q):
    LR.append(list(map(int, input().split())))

d = [0 for i in range(H*W+1)]
sA = [0 for i in range(H*W+1)]

for i in range(len(A)):
        for j in range(len(A[i])):
            sA[A[i][j]] = [i, j]

for i in range(D+1, H*W+1):
    d[i] = d[i-D] + abs(sA[i][0]-sA[i-D][0]) + abs(sA[i][1]-sA[i-D][1])

for lr in LR:
    l, r = lr[0], lr[1]
    print(d[r] - d[l])
    

Measured memory_bytes: 42212
# -*- coding: utf-8 -*-
"""
Basic Operations - Min-Max Element
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_3_B&lang=jp

"""

n = int(input())
A = [int(a) for a in input().split()]
for _ in range(int(input())):
    com, b, e = input().split()
    if com == '0':
        print(min(A[int(b):int(e)]))
    else:
        print(max(A[int(b):int(e)]))



Measured memory_bytes: 5644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in)).readLine());
		int val = 100;//壱百千円
		double exactVal;
		for (; 0 < period; period--) {
			exactVal = val * 1.05;
			val = (int) (exactVal - (int) exactVal > 0 ? exactVal + 1 : exactVal);
		}
		System.out.println(val * 1000);
	}
}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int MAX_PIERRE = 2*1e5;

int nbPierre, cost;

int hauteur[MAX_PIERRE];

struct Ligne{
    int coeffDirect, ordOrigine;
    long double f(int x) {return coeffDirect * x + ordOrigine;}
    long double intersecX(Ligne autre) {return (ordOrigine - autre.ordOrigine) / (autre.coeffDirect - coeffDirect);}
};

int32_t main()
{
    cin >> nbPierre >> cost;

    deque<Ligne> cht;

    int dp[nbPierre];

    cin >> hauteur[0];

    dp[0] = 0;

    Ligne premier = {-2 * hauteur[0], cost + hauteur[0]*hauteur[0]};

    cht.push_back(premier);

    for(int i = 1; i < nbPierre; i++) {
        cin >> hauteur[i];

        while(cht.size() >= 2 && cht[0].f(hauteur[i]) >= cht[1].f(hauteur[i])) {
            cht.pop_front();
        }

        int y = cht[0].f(hauteur[i]);

        dp[i] = y + hauteur[i]*hauteur[i];

        Ligne cur = {-2 * hauteur[i], cost + dp[i] + hauteur[i] * hauteur[i]};

        while(cht.size() >= 2 && cur.intersecX(cht[cht.size()-1]) <= cht[cht.size()-1].intersecX(cht[cht.size()-2])) {
            cht.pop_back();
        }

        cht.push_back(cur);


    }

    //for(int i = 0; i < nbPierre; i++) cout << dp[i] << endl;

    cout << dp[nbPierre-1];

    return 0;
}


Measured memory_bytes: 8920
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    string s;
    while(cin>>s)
    {
        string s1=s,s2,s3;
        reverse(s1.begin(),s1.end());
        if(s==s1)
        {
            int i;
            int n=s.size();
            for(i=0; i<(n-1)/2; i++)
            {
                s2+=s[i];
            }
            string s4=s2;
            reverse(s4.begin(),s4.end());
            if(s2==s4)
            {
                for(i=(n+3)/2-1; i<n; i++)
                {
                    s3+=s[i];
                }
                string s5=s3;
                reverse(s5.begin(),s5.end());
                if(s3==s5)
                {
                    cout<<"Yes"<<endl;
                }
                else
                    cout<<"No"<<endl;
            }
            else
            {
                cout<<"No"<<endl;
            }
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
}




Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

int main(void){
	int n;
	cin >> n;

	string s;
	cin >> s;

	ll ans = 1;

	map<char, ll> mp;

	for (int i = 0; i < n; i++){
		mp[s[i]]++;
	}

	int exc = 0;
	for (auto i : mp){
		ans *= i.second + 1;
		ans %= MOD;
	}

	cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, ans = 0, pre = 0;
	
	cin >> N;
	
	rep(i, N){
		int a;
		cin >> a;
		ans += max(a - pre, 0);
		pre = a;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back

using namespace std;
int main() {
    IOS;
    ll n,w;
    cin>>n>>w;
    ll arr[n][2];
    for(int y=0;y<n;y++)
        cin>>arr[y][0]>>arr[y][1];
    //sort(arr,arr+n);
    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    for(int y=0;y<=n;y++)
    {
        for(int h=0;h<=w;h++)
        {
            if(h==0||y==0)
                continue;
            else if(h-arr[y-1][0]>=0)
                dp[y][h] = max(dp[y-1][h],dp[y-1][h-arr[y-1][0]]+arr[y-1][1]);
            else
                dp[y][h]=dp[y-1][h];
        //    cout<<dp[y][h]<<" ";
            }
    }
    cout<<dp[n][w]<<"\n";
    return 0;
}


Measured memory_bytes: 79232
import java.util.Scanner;

/**
 * Finding a Word
 */
public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        String keyword = scan.next().toLowerCase();
        String str = null;
        int match = 0;
        while (scan.hasNext()) {
            str = scan.next();
            if (str.matches("END_OF_TEXT")) {
                break;
            }
            if (str.toLowerCase().matches(keyword)) {
                match ++ ;
            }
        }
        System.out.println(match);
    }
}

Measured memory_bytes: 18256
str_s = input()
ret = "Yes"
for i, n in enumerate(str_s):
    i = int(i)
    if (i+2) % 2 == 0:
        if n not in ("R", "U", "D"):
            ret = "No"
            break
    elif (i+1) % 2 == 0:
        if n not in ("L", "U", "D"):
            ret = "No"

print(ret)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int K=stdIn.nextInt();
		int z=0,y=0,ans=0;
		while(z<N){
			y=stdIn.nextInt();
			if(y==1){
				y=z;
				break;
			}
			z++;
		}z=0;
		ans+=(y-1)/(K-1);
		ans+=(N-y)/(K-1);
		if(((y-1)%(K-1))+((N-y)%(K-1))>K-1){
			ans+=2;
		}
		else
			ans+=1;
		if(((y-1)%(K-1))+((N-y)%(K-1))==0)
			ans-=1;
		System.out.println(ans);
	}
}

Measured memory_bytes: 46512
#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC";
    else cout << "ABC";
    return 0;
}


Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))

# from math import gcd # Python versions 3.5 and above
from functools import reduce # Python version 3.x


def computeGCD(x, y):
    while (y):
        x, y = y, x % y
    
    return x

def lcm(a, b):
    return (a * b) // computeGCD(a, b)

# def lcm(denominators):
#     return reduce(lambda a,b: a*b // gcd(a,b), denominators)

res = reduce(lcm, A, 1)
# res = lcm(A)
print(sum(res // A[i] for i in range(N)) % (10 ** 9 + 7))

Measured memory_bytes: 4208
n = gets.chomp.to_i
s = {}
t = {}
for i in 0...n
    k = gets.chomp
    if s.key?(k)
        s[k] += 1
    else
        s[k] = 1
        t[k] = 0
    end
end
m = gets.chomp.to_i
for i in 0...m
    k = gets.chomp
    if t.key?(k)
        t[k] += 1
    else
        t[k] = 1
    end
end
max_ans = 0
for i in s.keys
    if s[i] - t[i] > max_ans
        max_ans = s[i] - t[i]
    end
end
print(max_ans)

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(2147483647)

#
n,k=map(int,input().split())
red=n-k

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10**9+7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,k+1):
    print((cmb(n-k+1, i, p)*cmb(k-1,i-1,p))%p)


Measured memory_bytes: 127776
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
const int N = 2e5;

vi fact(N + 1);

void meow()
{
    fact[0] = 1;
    fori (i, 1, N) fact[i] = fact[i-1] * i % mod;
}

int power (int x, int y) 
{ 
    int res = 1;
    x = x % mod; 
  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % mod; 
        y = y>>1; 
        x = (x*x) % mod;   
    } 
    return res; 
}

int inv (int n) 
{ 
    return power(n, mod-2); 
} 

int ncr (int n, int r)
{
    return fact[n] * inv(fact[n-r]) % mod * inv(fact[r]) % mod;
}
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    meow();
    readc(n, m, k)

    int x = ncr(n*m - 2, k-2);

    int ans = 0;

    fori (i, 1, n)
    {
        fori (j, 1, m)
        {
            int l = j - 1;
            int r = m - j;
            int up = i - 1; 

            up = up * (up + 1) / 2 % mod;
            l = l * (l + 1) / 2 % mod; r = r * (r + 1) / 2 % mod;

            ans += l % mod;  ans %= mod;
            ans += (l + r) % mod * (i - 1) % mod; ans %= mod;
            ans += up * m % mod; ans %= mod;
        }
    }

    print(ans * x % mod)

    return 0;
}


Measured memory_bytes: 4664
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
       ll a,b;
       cin>>a>>b;
       cout<<a*b;
        
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];
inline int mul(int a, int b) { return (1ll * a * b) % M; };
inline int add(int a, int b)
{
	if ( a + b < 0 ) return a + b + M;
	if ( a + b >= M) return a + b - M;
	return a + b;
}


int pwrmod(int a, int b)
{
	int res = 1;
	while (b )
	{
		if (b & 1) res = (1ll * res * a) % M;
		a = (1ll * a * a) % M;
		b >>= 1;
	}
	return res;
}

int fact[N + 2], ifact[N + 2];
void allfact()
{
	fact[0] = 1; for (int i = 1; i <= N; i++) fact[i] = mul(i, fact[i - 1]);
	ifact[N] = pwrmod(fact[N], M - 2); for (int i = N - 1; i >= 0; i--) ifact[i] = mul(ifact[i + 1], i + 1);
}

int ncr(int n1, int r1) { if ( n1 < r1 ) return 0; return mul( mul(fact[n1], ifact[r1]), ifact[n1 - r1]);}

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}


void solve()
{
	allfact();
	int m;
	cin >> n >> m;
	int ans = 1;
	lop(i, 0, n) ans = mul(ans, m - i);
	int res = mul(ans, ans);
	// cout << res << endl;
	arr[n] = 1;
	rlop(i, n - 1, 0)
	{
		arr[i] = mul(arr[i + 1], m - i);
	}

	lop(i, 1, n + 1)
	{
		int val = mul(ncr(n, i) , mul( ncr(m, i) , fact[i] ));
		val = mul(val, mul(arr[i], arr[i]));
		if (i & 1) res = add(res, -val);
		else res = add(res, +val);
	}

	cout << res << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





Measured memory_bytes: 54356
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int INF = 1e9+100;
const int MOD = 1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> nums(n);
	for (int i = 0; i < n; i++){
		cin>>nums[i];
	}
	ll p = 0;
	ll ans = 0;
	for (int i = n-1; i >= 0; i--){
		ans += (nums[i] * p) % MOD; ans %= MOD;
		p += nums[i]; p %= MOD;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define PI 2 * acos(0)
#define ones(n) __builtin_popcount(n)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 9000000
#define debug(x) cerr << #x << " = " << x << '\n';
#define LOOP printf("LOOP!!")
#define READ freopen("input.txt", "r", stdin)
#define PRINT freopen("output.txt", "w", stdout);
#define print(a, b) printf("Case %d: %lld\n", a, b)
#define all(x) (x).begin(), (x).end()
const ll MOD = 1e9 + 7;
using namespace std;
const int VAL = 2e5 + 10;
vector<int> v[VAL];

bool vis[VAL];

void dfs(int n)
{

    vis[n] = true;

    for (int i = 0; i < v[n].size(); i++)
    {
        int next = v[n][i];

        if (!vis[next])
            dfs(next);
    }
}

/************MAIN_FUNCTION**********/
int main(int argc, char *argv[])
{
    ///Disjoint set union
    int n, m, a, b;
    cin >> n >> m;

    for (int i = 0; i < m; i++)
    {

        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int c = 0;
    for (int i = 1; i <= n; i++)
        if (!vis[i])
            dfs(i), c++;

    cout << c - 1 << '\n';
    return 0;
}

Measured memory_bytes: 11984
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
#define ll long long
const int inf = 1e9;
const int mod = 1e9 + 7;
using namespace std;
vector <int> vect;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int n, a[100005], b[100005];
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    b[0] = b[1] = 0;
    b[2] = abs(a[2] - a[1]);
    for(int i = 3; i <= n; i++){
        b[i] = min(abs(a[i] - a[i - 1]) + b[i - 1], abs(a[i] - a[i - 2]) + b[i - 2]);
    }
    cout<<b[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n; cin >> n;

	if (n % 4 == 0 || n % 7 == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 1; i < 25; i++) {
		for (int j = 1; j < 15; j++) {
			int curr = 4 * i + 7 * j;
			if (curr > n)
				continue;
			if (n % curr == 0) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,x;
	cin>>n>>x;
	if(x==1 or x==2*n-1){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	if(n==2){
		cout<<1<<endl;
		cout<<2<<endl;
		cout<<3<<endl;
		return 0;
	}
	if(x==2){
		rep(i,n-3){
			cout<<5+i<<endl;
		}
		cout<<3<<endl;
		cout<<2<<endl;
		cout<<1<<endl;
		cout<<4<<endl;
		rep(i,n-2){
			cout<<2*n-1-i<<endl;
		}
	}else{
		int p=1;
		rep(i,n-3){
			if(p==x-2)p=x+2;
			cout<<p<<endl;
			p++;
		}
		cout<<x-1<<endl;
		cout<<x<<endl;
		cout<<x+1<<endl;
		cout<<x-2<<endl;
		rep(i,n-2){
			if(p==x-2)p=x+2;
			cout<<p<<endl;
			p++;
		}
	}
	return 0;
}


Measured memory_bytes: 1536
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, m; cin >> n >> m;
    int s[5], c[5];
    rep(i, m) {
        cin >> s[i] >> c[i];
        --s[i];
    }
    rep(ans, 1000) {
        string S = to_string(ans);
        if(S.size() != n) continue;

        bool ok = 1;
        rep(i, m) {
            if(S[s[i]] != '0' + c[i]) {
                ok = 0;
            }
        }
        if(ok) {
            cout << ans << endl;
            return;
        }
    }
    cout << -1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;long long n,x[1<<20],t,p=1,i,s,j;main() {cin>>n>>t;for(i=0;i<n;i++){cin>>x[i];}sort(x,x+n);for(i=0;i<n;i++){s=0;for(j=i;j>=0;j--){if(x[i]-x[j]>t){break;}s++;}p*=s;p%=1000000007;}cout<<p<<endl;}

Measured memory_bytes: 1956
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int cnt0 = 0;
    REP(i, n) if (a[i] == 0) cnt0++;

    Bint sum = 1;
    if (cnt0 > 0) sum = 0;
    else {
        REP(i, n) {
            sum *= a[i];
            if (sum > 1000000000000000000) {
                sum = -1;
                break ;
            }
        }
    }

    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    bool ans = true;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) ans = false;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
struct data {
  string name;
  int time;
};

#define MAX 100000
int head = 0, tail = 0;
data queue[100010];
void enqueue(data x) {
  queue[tail] = x;
  tail = (tail+1)%MAX;
}

data dequeue() {
  data d = queue[head];
  head = (head+1)%MAX;
  return d;
}

// returns true if the queue is empty
bool isEmpty() {
  return (head == tail);
}

int main() {
  int n, q;
  cin >> n >> q;
  data d;
  for (int i = 0; i < n; i++) {
    cin >> d.name >> d.time;
    enqueue(d);
  }
  
  int time = 0;
  while (!isEmpty()) {
    d = dequeue();
    if (d.time <= q) {
      time += d.time;
      cout << d.name << " " << time << endl;
    } else {
      time += q;
      d.time -= q;
      enqueue(d);
    }
  }
}




Measured memory_bytes: 7060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int m=1e9+7;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fastio
    int n;
    cin>>n;
    cout<<(n+1)/2/(double)n;
    return 0;
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n; sc(n)
    char x;
    vector<string> vec(n);
    vector<char> M = {'M', 'A', 'R', 'C', 'H'};
    map<char, ll> mp;
    for (int i = 0; i < n; i++) cin >> vec[i];
    for (int i = 0; i < n; i++){
        x = vec[i][0];
        if (x != 'M' && x != 'A' && x != 'R' && \
        x != 'C' && x != 'H') continue;
        ++mp[x];
    }
    ll ans = 0;
    for (int i = 0; i < 5; i++){
        if (mp.find(M[i]) == mp.end()) continue;
        for (int j = i + 1; j < 5; j++){
            if (mp.find(M[j]) == mp.end()) continue;
            for (int k = j + 1; k < 5; k++){
                if (mp.find(M[k]) == mp.end()) continue;
                ans += mp[M[i]] * mp[M[j]] * mp[M[k]];
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
  	int n;
	cin >> n;
	//105 135 165 189 195
    if(n<105){
	    cout << 0 << endl;
    }
  	else if(n<135){
      cout << 1 << endl;
	}
	else if(n<165){
      cout << 2 << endl;
	}
	else if(n<189){
      cout << 3 << endl;
	}
  else if(n<195){
      cout << 4 << endl;
	}
  else{
      cout << 5 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
const int N = 1e7 + 10;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
#define endl '\n'
#define pb(a) push_back(a)
#define al(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define IOS ios::sync_with_stdio(0);
bool mark[N];
int prim[N], d[N], num[N];
int cnt;
void initial() {
    cnt = 0;
    d[1] = 1;
    for (int i = 2; i < N; ++i) {
        if (!mark[i]) {
            prim[cnt++] = i;
            num[i] = 1;
            d[i] = 2;
        }
        for (int j = 0; j < cnt && i * prim[j] < N; ++j) {
            mark[i * prim[j]] = 1;
            if (!(i % prim[j])) {
                num[i * prim[j]] = num[i] + 1;
                d[i * prim[j]] = d[i] / (num[i] + 1) * (num[i * prim[j]] + 1);
                break;
            }
            d[i * prim[j]] = d[i] * d[prim[j]];
            num[i * prim[j]] = 1;
        }
    }
}
int main() {
    ll n;
    scanf("%lld", &n);
    initial();
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        ans += i * d[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 94316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   ll K;
   cin>>K;
   cout<<(K/2)*((K+1)/2)<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  
    for(int i = 0; i < 2*k - 2; i++){
      cout << x - k + i + 1 << " ";
    }
    cout << x + k - 1 << endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var v = o.l();
  var c = o.l();
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(v[i] > c[i])ans += v[i] - c[i];
  }
  return ans;
}

Measured memory_bytes: 21192
#include<bits/stdc++.h>
using namespace std;
#define SIZE 12
#define R(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define aah ios::sync_with_stdio(false)
char str[SIZE];
int main()
{
	aah;
    cin>>str;
	long long int ans=0;
	int w=strlen(str);
	for(int S=0;S<1<<(w-1);S++)
	{
		 long long int now=0,sum=0;
		 for(int i=0;i<w;i++)
		 {
		 	now*=10LL;
		 	now+=str[i]-48;
		 	if(i<w-1&&(S>>i&1))
		 	{
		 		sum+=now;
		 		now=0;
			}
		 }
		 sum+=now;
		 ans+=sum;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "5 2", "5 3 1 4 2", "1 3", "5 4" ].parse.expand.solve == 2 );
	assert( [ "3 2", "3 2 1", "1 2", "2 3" ].parse.expand.solve == 3 );
	assert( [ "10 8", "5 3 6 8 7 10 9 1 2 4", "3 1", "4 1", "5 9", "2 5", "6 5", "3 5", "8 9", "7 9" ].parse.expand.solve == 8 );
	assert( [ "5 1", "1 2 3 4 5", "1 5" ].parse.expand.solve == 5 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	ps[] -= 1;
	auto xys = new long[ 2 ][ nm[ 1 ] ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
		xy[] -= 1;
	}
	return tuple( ps, xys );
}

auto solve( long[] ps, long[ 2 ][] xys )
{
	// 入れ替えできるグループを判定
	auto uft = UnionFindTree( ps.length );
	foreach( xy; xys )
	{
		uft.unite( xy[ 0 ], xy[ 1 ] );
	}
	
	// グループごとにpiを収集
	auto bss = new long[][ ps.length ];
	foreach( i; 0L .. ps.length.signed )
	{
		bss[ uft.root( i ) ] ~= ps[ i ];
	}
	foreach( ref bs; bss )
	{
		bs.sort();
	}
	
	// i == pi にできる数を集計
	auto ans = 0L;
	foreach( i; 0L .. ps.length.signed )
	{
		auto r = uft.root( i );
		while( !bss[ r ].empty && bss[ r ].front < i )
		{
			bss[ r ].popFront;
		}
		ans += ( !bss[ r ].empty && bss[ r ].front == i );
	}
	return ans;
}

// UnionFind木
struct UnionFindTree
{
	private long[] ps;
	private long[] rs;
	
	// 重み無し初期化
	public this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
	}
	
	public long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	public bool same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	public void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
	}
}


Measured memory_bytes: 11196
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

const ll MAX_N=2e5+3;
ll n;
vll a(MAX_N);
vvll edge(MAX_N);
vll ans(MAX_N);

vll table(MAX_N,LLINF);

void dfs(ll now, ll par){
  auto it=lower_bound(ALL(table),a[now]);
  ll before = *it;
  *it=a[now];
  ans[now]=it-table.begin()+1;
  if(par!=-1)
    ans[now]=max(ans[now],ans[par]);

  for(auto e:edge[now]){
    if(e==par)
      continue;

    dfs(e,now);
  }
  *it=before;
}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin>>n;
  REP(i,n)cin>>a[i];
  REP(i,n-1){
    ll u,v;
    cin>>u>>v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }

  dfs(0,-1);

  REP(i,n)cout<<ans[i]<<endl;
}



Measured memory_bytes: 30308
#include<bits/stdc++.h>
using namespace std;

int main()
{
    long long n,m, sum=0;
    cin>>n>>m;
    long long a[m];
    for(int i=0;i<m;++i)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
    cout<<-1<<endl;
    else
    cout<<n-sum<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int n;
    int ans=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%2==0) continue;
        int count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) count++;
        }
        if(count==8)ans++;
    }
    cout <<ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int d;
  cin >> d;
  if(d==25)cout<<"Christmas"<<endl;
  else if(d==24)cout<<"Christmas Eve"<<endl;
  else if(d==23)cout<<"Christmas Eve Eve"<<endl;
  else if(d==22)cout<<"Christmas Eve Eve Eve"<<endl;
}


Measured memory_bytes: 256
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

// template<typename T> constexpr T inf;
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  int N;
  cin >> N;
  vector<int> a(N), b(N);
  for (int &i: a) cin >> i;
  REP(i,N) b[i] = abs(N - i * 2 - 1);
  sort(ALL(a));
  sort(ALL(b));
  REP(i,N) {
    if (a[i] != b[i]) {
      cout << 0 << endl;
      return;
    }
  }
  int res = 1;
  REP(i,N/2) res = res * 2 % int(1e9 + 7);
  cout << res << endl;
  return;
}


Measured memory_bytes: 1024