akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  ll sum = 1;
  ll a[100010];
  rep(i, n)
  {
    cin >> a[i];
  }
  rep(i, n)
  {
    if (a[i] == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, n)
  {
    if (a[i] <= ll(1e18) / sum)
    {
      sum *= a[i];
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

const int N = 300005;
int n, a[N], s[N][2];
bool f[N];

bool check(int mid) {
	f[0] = true;
	int mx = 0;
	for (int i = 2; i < n; i += 2) {
		if (mx >= mid - s[i][1] + s[i - 1][0]) {
			f[i] = true;
			mx = max(mx, s[i][0] - s[i][1]);
			if ((s[n][1] - s[i][1]) - (s[n][0] - s[i][0]) >= mid)
				return true;
		} else
			f[i] = false;
	}
	return false;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		s[i][i - 1 & 1] = s[i - 1][i - 1 & 1];
		s[i][i & 1] = s[i - 1][i & 1] + a[i];
	}
	if (n % 2 == 0) {
		if (s[n][0] < s[n][1])
			swap(s[n][0], s[n][1]);
		printf("%d %d\n", s[n][0], s[n][1]);
		return 0;
	}
	int l = 0, r = s[n][1];
	while (l < r) {
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	if (s[n][0] + l > s[n][1])
		printf("%d %d\n", s[n][0] + l, s[n][1] - l);
	else
		printf("%d %d\n", s[n][1], s[n][0]);
	return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

struct line {
        int from;
        int to;
};

int main() {
        vector<vector< line > > amida;

        do {
        amida.clear();
        amida.resize(1001);
        int n, m, a;
        cin >> n >> m >> a;
        if (n == 0 && m == 0 && a == 0) return 0;

        int h, p, q;
        for (int loop = 0; loop < m; loop++) {
                line l;
                cin >> h >> p >> q;
                if (p > q) {
                        int temp = p;
                        p = q;
                        q = temp;
                }
                l.from = p;
                l.to = q;
                amida[h].push_back(l);
        }

        for (int i = 1000; i > 0; i--) {
                for (int j = 0; j < amida[i].size(); j++) {
                        if (amida[i][j].from == a) {
                                a = amida[i][j].to;
                                break;
                        }
                        else if (amida[i][j].to == a) {
                                a = amida[i][j].from;
                                break;
                        }
                }
        }
        cout << a << endl;

        } while (1);
        return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+7;
int main()
{
	int n,m;
	cin>>n>>m;
	vi x(n),y(m);
	for(int i=0;i<n;i++) cin>>x[i];
	for(int i=0;i<m;i++) cin>>y[i];
	ll ansx=0,ansy=0;
	ll pre=0;
	for(int i=0;i<n;i++)
	{
		ansx=(ansx+1LL*i*x[i]%mod-pre+mod)%mod;
		pre=(pre+x[i])%mod;
	}
	pre=0;
	for(int i=0;i<m;i++)
	{
		ansy=(ansy+1LL*i*y[i]%mod-pre+mod)%mod;
		pre=(pre+y[i])%mod;
	}
	cout<<ansx*ansy%mod<<'\n';

}


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll x,y;
int main() {
    cin >> x >> y;
    int cnt = 0;
    while(x<=y) {
        x *=2;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n,m;
  scanf("%d %d",&n,&m);
  if(n != 0)
    n = (n * (n-1))/2;
  if(m != 0)
     m = (m * (m-1))/2;
  printf("%d",m+n);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool sushu(int n)
{
    int k=sqrt(n)+1;
    for (int i = 2; i < k; i++)//也可用n/2，不过计算量要比sqrt大一些
    {
        if (n%i == 0)
            return false;
    }
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
    printf("3 13 23 43 53");
    n-=5;
    int min=2;
    int sum=28;
    for(int i=73;i<=55555;i++){
            if(n<=0)break;
            if(sushu(i)&&i%10==3){
                printf(" %d",i);
                n--;
            }

        }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

using Data = int;
const int len = 1 << 18;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n,k;
  cin>>n>>k;
  vecll a(n);
  REP(i,n) {
    int x;
    cin>>x;
    a[i] = x - k;
  }
  vecll psum(n+1);
  partial_sum(ALL(a), begin(psum)+1);
  vecll vals = psum;
  sort(ALL(vals));
  vals.erase(unique(ALL(vals)),end(vals));
  unordered_map<ll, int> idx;
  int m = vals.size();
  REP(i,m) {
    idx[vals[i]] = i;
  }
  BIT bit;
  bit.update(idx[0], 1);
  ll ans = 0;
  REP(i,n) {
    ans += bit.query(idx[psum[i+1]]);
    bit.update(idx[psum[i+1]], 1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 14280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		boolean judge = false;
		for (int i = 0; i < n; i++) {
			int d1 = sc.nextInt();
			int d2 = sc.nextInt();
			if (d1 == d2) {
				count = count + 1;
			} else {
				count = 0;
			}
			if (count == 3) {
				judge = true;
			}
		}
		if (judge) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 35856
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int m, d;
  cin >> m >> d;
  int ans = 0;
  REP1(i, m) REP1(j, d) {
    int d1 = j % 10;
    int d2 = j / 10;
    if (2 <= d1 && 2 <= d2 && d1 * d2 == i) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
   vector<pair<int,int > > v;
   long int n;
   scanf("%ld",&n);
   long int a[n+1],i,j;
   for(i=1;i<=n;++i)
       scanf("%ld",&a[i]);
  
    
   for(i=1;i<=n;++i)
     {
         v.push_back(make_pair(a[i],i));
     }
   
   
   sort(v.begin(),v.end());
   
   for(i=0;i<v.size();++i)
      printf("%ld ",v[i].second);
   
  
   
  
  
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
//////////////////////////////////////////////////



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); srand(time(0));
  
  int n;
  cin >> n;
  int a[2][n], d[2][n];
  memset(d, 0, sizeof d);
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin >> a[i][j];

  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++) {
      if( i == 0 and j == 0 ) {
	d[i][j] = a[i][j];
	continue;
      }
      if( i == 0 ) {
	d[i][j] = d[i][j-1] + a[i][j];
      } else {
	if( j == 0 ) {
	  d[i][j] = d[i-1][j] + a[i][j];
	} else {
	  d[i][j] = max(d[i][j-1], d[i-1][j]) + a[i][j];
	}
      }
    }
  cout << d[1][n-1] << nl;
  
  return 0;
}
/* -*- -*- */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    multiset<int, greater<int>> c;
    int sol = 0;
    for (int i = 0; i < n; ++i)
    {
        auto it = c.lower_bound(a[i]);
        if (it == c.end())
        {
            c.insert(a[i] + 1);
            sol++;
        }
        else
        {
            c.erase(it);
            c.insert(a[i] + 1);
        }
    }
    cout << sol;
}


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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i] >> t[i];
	}
	string x;
	cin >> x;
	int tot = 0;
	for (int i = n-1; i >= 0; i--) {
		if (s[i] == x) {
			cout << tot << '\n';
			exit(0);
		} else {
			tot += t[i];
		}
	}
	assert(false);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll ans = 0; ll ans2 = 0; ll INF = 9999999999999;
vll flag, color; vll path; vl A, T; vll D;
vector<string> S;
//***********//
//main内でCOMinit(N)を忘れずに！
vl fac, finv, inv;
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin >> N >> K;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	COMinit(N);
	//max計算
	ll sum1 = 0;
	for (i = 0; i < N; i++) {
		sum1 = (sum1 + A[i]*COM(i, K-1)) % MOD;
	}
	ll sum2 = 0;
	for (i = 0; i < N; i++) {
		sum2 = (sum2 + A[i]*COM(N-i-1, K-1)) % MOD;
	}
	if (sum1 - sum2 < 0) {
		sum1 += MOD;
	}
	cout << (sum1 - sum2) % MOD;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    string s;
    int K;
    cin >> s >> K;
    int current_pos = 0;
    for(int i=0; i<K; ) {
        if(current_pos == s.size()-1) {
            s[current_pos] = 'a' + static_cast<char>((s[current_pos] - 'a' + (K-i))%26);
            break;
        } else if(s[current_pos] == 'a' || 'z' - s[current_pos] + 1 > K-i) {
            current_pos++;
        } else if('z' - s[current_pos] + 1 <= K-i) {
            i += static_cast<int>('z' - s[current_pos] + 1);
            s[current_pos] = 'a';
            current_pos++;
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 640
// ABC073B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

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

	int ans = 0;

	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
Module _20190421

    Sub Main()

        Dim sRead As String = Console.ReadLine()

        Dim iHouse1 As Integer = sRead.Split(" ")(0)
        Dim iHouse2 As Integer = sRead.Split(" ")(1)
        Dim iHouse3 As Integer = sRead.Split(" ")(2)

        If iHouse1 < iHouse3 AndAlso iHouse3 < iHouse2 Then

            Console.WriteLine("Yes")

        ElseIf iHouse1 > iHouse3 AndAlso iHouse3 > iHouse2 Then

            Console.WriteLine("Yes")

        Else

            Console.WriteLine("No")

        End If

    End Sub

End Module


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f

using namespace std;

struct Edge {
	int t,f,next;
	Edge() {}
	Edge(int a,int b,int c):t(a),f(b),next(c) {}
};

Edge e[1000000];
int head[200005],vs,vt,tot=-1;

inline void addEdge(int x,int y,int z) {
	e[++tot]=Edge(y,z,head[x]);
	head[x]=tot;
	e[++tot]=Edge(x,0,head[y]);
	head[y]=tot;
}

namespace Flow {

	int d[200005],cur[200005];
	queue <int> q;

	bool bfs() {
		while (!q.empty()) q.pop();
		memset(d,255,sizeof(d));
		d[vs]=0;
		cur[vs]=head[vs];
		q.push(vs);
		while (!q.empty()) {
			int x=q.front();
			q.pop();
			for(int i=head[x]; i!=-1; i=e[i].next)
				if (e[i].f&&d[e[i].t]==-1) {
					int u=e[i].t;
					d[u]=d[x]+1;
					cur[u]=head[u];
					if (u==vt) return 1;
					q.push(u);
				}
		}
		return 0;
	}

	int dfs(int x,int a) {
		if (x==vt||!a) return a;
		int ans=0;
		for(int &i=cur[x]; i!=-1; i=e[i].next)
			if (e[i].f&&d[e[i].t]==d[x]+1) {
				int u=e[i].t;
				int f=dfs(u,min(a,e[i].f));
				if (f) {
					e[i].f-=f;
					e[i^1].f+=f;
					ans+=f;
					a-=f;
					if (!a) break;
				}
			}
		return ans;
	}

	int maxflow() {
		int ans=0;
		while (bfs())
			ans+=dfs(vs,inf);
		return ans;
	}

}

vector <int> bel[100005];
bool vis1[100005],vis2[100005];
int id[100005],nxt[100005];

queue <int> q;

bool solve(int n) {
	for(int i=1; i<n; i++)
		for(int j=head[n+i]; j!=-1; j=e[j].next)
			if (e[j].t&&!e[j].f) {
				int u=e[j].t;
				id[i]=u;
				vis1[u]=1;
			}
	for(int i=1; i<=n; i++)
		if (!vis1[i]) q.push(i);
	int cnt=0;
	while (!q.empty()) {
		int x=q.front();
		q.pop();
		cnt++;
		for(int i=0; i<bel[x].size(); i++)
			if (!vis2[bel[x][i]]) {
				int u=bel[x][i];
				vis2[u]=1;
				nxt[u]=x;
				q.push(id[u]);
			}
	}
	return cnt==n;
}

int main() {
	memset(head,255,sizeof(head));
	int n;
	scanf("%d",&n);
	vs=0;
	vt=2*n;
	for(int i=1; i<n; i++) {
		int x;
		scanf("%d",&x);
		addEdge(vs,n+i,1);
		for(int j=1; j<=x; j++) {
			int y;
			scanf("%d",&y);
			addEdge(n+i,y,1);
			bel[y].push_back(i);
		}
	}
	for(int i=1; i<=n; i++) addEdge(i,vt,1);
	if (Flow::maxflow()<n-1) {
		puts("-1");
		return 0;
	}
	if (!solve(n)) {
		puts("-1");
		return 0;
	}
	for(int i=1; i<n; i++) printf("%d %d\n",id[i],nxt[i]);
	return 0;
}

Measured memory_bytes: 23040
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int ans,a[5];
int main()
{
	scanf("%d%d%d",&a[1],&a[2],&a[3]);
	sort(a+1,a+3+1);
	ans=10*a[3]+a[2]+a[1];
	printf("%d\n",ans);
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e10
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    int n;
    cin >> n;
    vector<ll>a(n, 0);
    unordered_map<ll, ll>ct;
    REP(i, n) {
        cin >> a[i];
        ct[a[i]]++;
    }

    ll ans = 0;

    for (auto i : ct) {
        if (i.first > i.second){
            ans += i.second;
        }
        else if (i.first < i.second){
            ans += i.second - i.first;
        }
    }

    cout << ans << endl;
}
        


Measured memory_bytes: 8068
(n, m, l) = [int(i) for i in input().split()]
 
A = []
B = []
for _ in range(n):
    A.append([int(i) for i in input().split()])
for _ in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C = [0 for _ in range(l)]
    for j in range(l):
        for k in range(m):
            C[j] += A[i][k] * B[k][j]
    print(" ".join([str(a) for a in C]))

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

typedef long long int lli;
#define int lli
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<lli> vli;
typedef vector<pii> vii;

const int MOD	= 1e9 + 7;
const double PI = acos(-1.0);

#define fastio			ios_base::sync_with_stdio(false);cin.tie(0)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define endl "\n"
#define error_old(x) cerr << #x << " = " << (x) << endl
#define errorp(p) cerr << #p << " = " << (p.first) << ", " << (p.second) << endl
#ifdef DEBUG
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {it++;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); }
#else
#define error(args...)
#endif
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template <typename T> T lcm(T a, T b){return (a*b)/gcd(a,b); }

void solve(){
    int n;
    cin >> n;
    vi arr(n);
    rep(i, n){
        cin >> arr[i];
    }
    vi prefSum(n + 1, 0);
    rep(i, n){
        prefSum[i + 1] = prefSum[i] + arr[i];
    }

    vector<vi> dp(n, vi(n, __LONG_LONG_MAX__));
    repD(l, n - 1, 0){
        repA(r, l, n - 1){
            if(l == r){
                dp[l][r]= 0;
            }else{
                repA(k, l, r - 1){
                    dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + prefSum[r + 1] - prefSum[l]); 
                }
            }

        }
    }
    cout << dp[0][n - 1] << endl;
}

signed main(){
    #ifdef DEBUG
		freopen("test", "r", stdin);
	#endif
    fastio;
    
    solve();

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>

int main(void){
    int x1, y1, x2, y2, dx, dy;
    std::cin >> x1 >> y1 >> x2 >> y2;
    dx = x2 - x1;
    dy = y2 - y1;
    std::cout << x2 - dy << " " \
              << y2 + dx << " " \
              << x1 - dy << " " \
              << y1 + dx << std::endl;

    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <math.h>
using namespace std;

int main(){
	int max = 0;
	int A,B,C,K;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&K);
	
	for(int i=0; i <= K ; i++){
		for(int j = 0; i + j <= K; j ++){
			int temp = 	A * (int)pow(2,i) + B * (int)pow(2,j) + C * (int)pow(2,K-i-j);			
			if(temp > max) max =temp;
		}
	}				
	printf("%d",max);
	return 0;

}

Measured memory_bytes: 128
#include <stdlib.h>
#include <iostream>
using namespace std;


int main(){
	string s;

	cin >> s;
	int res = -1;
	int end_pos = (int)s.size();
	char prior = 'X';
	for(int i = 0; i < end_pos; i++){
		if(s[i] == prior) continue;
		res++;
		prior = s[i];
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll res;
    REP(i, s.size()){
        res = s[i] - '0';
        if(res != 1){
            cout << res << endl;
            return 0;
        }
        if(i + 1 >= k){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	ll n;
	cin >> n;

	VLL x(n+1);
	REP(i, n)cin >> x[i];
	x[n] = INFL;
	ll l;
	cin >> l;
	VVLL d(n + 5, VLL(30, 0));

	REP(i, n) {
		d[i][0] = upper_bound(ALL(x), x[i] + l) - x.begin();
		d[i][0]--;
	}
	
	REP(j, 29)REP(i, n) {
		d[i][j + 1] = max(d[d[i][j]][j], d[i][j]);
	}

	

	ll q;
	cin >> q;
	REP(i, q) {
		ll a, b;
		cin >> a >> b;
		if (a > b)swap(a, b);
		a--;
		b--;

		ll ans = 0;

		for (int i = 29; i >= 0; i--) {
			if (d[a][i] < b) {
				if (d[a][i] == 0)continue;
				a = d[a][i];
				ans += 1LL << i;
			}
		}
		ans++;
		cout << ans << endl;

	}

	return 0;


}



Measured memory_bytes: 28928
void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    int cnt, tmp;
    foreach (i; 0 .. n) {
        if (i == n - 1 && a[i] == n) {
            tmp = a[i];
            a[i] = a[i-1];
            a[i-1] = tmp;
            ++cnt;
        } else if (a[i] == i + 1) {
            tmp = a[i];
            a[i] = a[i+1];
            a[i+1] = tmp;
            ++cnt;
        }
    }

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4284
from string import ascii_lowercase


def main():
    word = input()
    if len(word) < 26:
        count = {}
        for a in ascii_lowercase:
            count[a] = 0
        for w in word:
            count[w] += 1
        count_l = list(count.items())
        count_l.sort(key=lambda x: x[0])
        add = ""
        for i in range(26):
            if count_l[i][1] == 0:
                add = count_l[i][0]
                break
        print(word + add)
    elif word == ascii_lowercase[::-1]:
        print(-1)
    else:
        is_printed = False
        while len(word) > 0 and not is_printed:
            for c in ascii_lowercase[ascii_lowercase.index(word[-1]) + 1:]:
                if c not in word[:-1]:
                    print(word[:-1] + c)
                    is_printed = True
                    break
            else:
                word = word[:-1]


if __name__ == '__main__':
    main()



Measured memory_bytes: 3772
N = int(input())

if N == 1:
  print(0)

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

      if temp!=1:
          arr.append(1)

      if arr==[]:
          arr.append(1)

      return arr

  f = factorization(N)
  ans = 0

  for i in range(1,100):
    f = list(map(lambda x:x-i,f))
    ans += len([j for j in f if j >= 0])

  print(ans)

Measured memory_bytes: 64760
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();int B=stdIn.nextInt();
		int x=A+B,y=A-B,z=A*B;
		x=(int)Math.max(x, y);
		z=(int)Math.max(x, z);
		System.out.println(z);
	}
}

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

int main(){
	int Vin;
	cin >> Vin;
	vector<vector<int>> M(Vin,vector<int>(Vin,0));
	int u,k,v;
	for(int loop=0;loop<Vin;loop++){
		cin >> u >> k;
		for(int loop2=0;loop2<k;loop2++){
			cin >> v;
			M[u-1][v-1]=1;
		}
	}
	for(int loop=0;loop<Vin;loop++){
		for(int loop2=0;loop2<Vin;loop2++){
			cout << M[loop][loop2];
			if(loop2<Vin-1) cout << " ";
			else cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3180
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vll a(n); REP(i, n) cin >> a[i];
    vll acca(n+1, 0);
    REP(i, n) acca[i+1] = acca[i] + a[i];
    ll li = 1, ri=3;
    ll diff = HIGHINF;
    for (; ri<n; ri++) {
        if (abs((acca[ri]-acca[2])-(acca[n]-acca[ri])) < diff) {
            diff = abs((acca[ri]-acca[2])-(acca[n]-acca[ri]));
        } else break;
    }
    ri--;
    ll ans = max({a[0], a[1], acca[n]-acca[ri], acca[ri]-acca[2]}) - min({a[0], a[1], acca[n]-acca[ri], acca[ri]-acca[2]});
    for (int i=2; i<n-1; i++) {
        ll ldif = abs((acca[i]-acca[li]) - (acca[li]-acca[0]));
        for (ll ltmp=li+1; ltmp<i; ltmp++) {
            if (ldif > abs((acca[i]-acca[ltmp]) - (acca[ltmp]-acca[0]))) {
                ldif = abs((acca[i]-acca[ltmp]) - (acca[ltmp]-acca[0]));
                li = ltmp;
            } else break;
        }

        if (ri <= i) ri = i+1;
        ll rdif = abs((acca[n]-acca[ri]) - (acca[ri]-acca[i]));
        for (ll rtmp=ri+1; rtmp<n; rtmp++) {
            if (rdif > abs((acca[n]-acca[rtmp]) - (acca[rtmp]-acca[i]))) {
                rdif = abs((acca[n]-acca[rtmp]) - (acca[rtmp]-acca[i]));
                ri = rtmp;
            } else break;
        }
        chmin(ans, max({acca[li]-acca[0], acca[i]-acca[li], acca[n]-acca[ri], acca[ri]-acca[i]}) - min({acca[li]-acca[0], acca[i]-acca[li], acca[n]-acca[ri], acca[ri]-acca[i]}));
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
pair<int, int> p[101010];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N){
        int a, b;
        scanf("%d %d", &a, &b);
        p[i] = {a, b};
    }
    
    // 2. sort.
    sort(p, p + N);
    
    // 3. ゲーム参加人数.
    int ans = p[0].a - 1;
    repx(i, 1, N) ans += min(p[i].a - p[i - 1].a, p[i - 1].b - p[i].b);
    ans += p[N - 1].b + 1;
    
    // 4. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  string s;
  cin>>s;
  int ans=0;
  rep(i,s.size()){
   if( s[i]=='o'){
     ans++;
   }
  }
  cout<<700+(ans*100)<<endl;
}

Measured memory_bytes: 256
S = input()

A = [[] for i in range(len(S)+1)]
ans = 0
j = 0
b = False
for i in range(len(S)):
    if b == True and S[i] == "A":
        j += 1
        A[j].append(0)
        b = False
    elif S[i] == "A":
        A[j].append(0)
        b = False
    elif b == False and S[i] == "B":
        b = True
    elif b == True and S[i] == "C":
        A[j].append(1)
        b = False
    else:
        b = False
        j += 1

for i in range(j+1):
    li = A[i]
    length = 0
    n = 0
    for k in range(len(li)):
        length += k*li[k]
        n += li[k]
    length -= n*(n-1)//2
    ans += length
print(ans)
        

Measured memory_bytes: 19688
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
 
class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    int N;
    void solve()
    {
        var T = cin.scanint;
        int ans = 0;
        for (int i = 0; i < 100; i++)
        {
            if (T[0] <= i && i < T[1] && T[2] <= i && i < T[3])
            {
                ans++;
            }
        }
        WriteLine(ans);
    }
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11216
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int MOD = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 素数
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// べき乗の余り
ll modpow(ll a, ll n){
    ll res = 1;
    while(n){
        if(n & 1){
            res = res * a % MOD;
        }
        a = a * a % MOD;
        n = n >> 1;
    }
    return res;
}

// コンビネーション
ll MAXN = 2e5+10;
vector<ll> inv(MAXN);
ll nCk(ll n, ll k) {
	ll res = 1;
	for(ll i = 1; i <= k; i++) {
		res = res*(n-i+1) % MOD;
	}
 
	for(ll i = 1; i <= k; i++) {
		res = res*inv[i] % MOD;
	}
	return res;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    ll ans = 1000;
    ll m = 0;
    ll now = a[0];
    for(ll i=0;i<n;++i){
        //cout<<m<<' '<<now<<' '<<ans<<endl;
        if(a[i] != now)continue;
        for(ll j=i+1;j<n;++j){
            if(now < a[j]){
                for(ll k=j;k<n;++k){
                    if(a[k] <= a[k+1]){
                        if(k == n-1){
                            m = ans / now;
                            ans -= m * now;
                            now = a[k];
                            break;
                        }
                        continue;
                    }else{
                        m = ans / now;
                        ans -= m * now;
                        now = a[k];
                        break;
                    }
                }
                break;
            }else if(now > a[j]){
                ans += m * now;
                m = 0;
                now = a[j];
                break;
            }
        }

    }
    ans += a[n-1] * m;
    cout<<ans<<endl;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int dp[1001][1001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        for(int i=0;i<=1000;i++)
            for(int j=0;j<=1000;j++)
                dp[i][j]=1e9;
        int ch,cw;
        cin>>ch>>cw;
        ch--;cw--;
        int dh,dw;
        cin>>dh>>dw;
        dh--;dw--;
        bool vis[n][m];
        bool vis1[n][m];
        memset(vis,false,sizeof(vis));
        memset(vis1,false,sizeof(vis1));
        string s[n];
        for(int i=0;i<n;i++)
            cin>>s[i];
        vis[ch][cw]=vis1[ch][cw]=true;
        deque <pair<int,int>> dq;
        dp[ch][cw]=0;
        dq.push_front(make_pair(ch,cw));
        while(!dq.empty()){
            pair<int,int> p1=dq.front();
            dq.pop_front();
            int i=p1.ff;
            int j=p1.ss;
            if(i+1<n&&s[i+1][j]=='.'&&vis[i+1][j]==false){
                vis[i+1][j]=true;
                dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
                dq.push_front(make_pair(i+1,j));
            }
            if(i-1>=0&&s[i-1][j]=='.'&&vis[i-1][j]==false){
                vis[i-1][j]=true;
                dp[i-1][j]=min(dp[i][j],dp[i-1][j]);
                dq.push_front(make_pair(i-1,j));
            }
            if(j+1<m&&s[i][j+1]=='.'&&vis[i][j+1]==false){
                vis[i][j+1]=true;
                dp[i][j+1]=min(dp[i][j],dp[i][j+1]);
                dq.push_front(make_pair(i,j+1));
            }
            if(j-1>=0&&s[i][j-1]=='.'&&vis[i][j-1]==false){
                vis[i][j-1]=true;
                dp[i][j-1]=min(dp[i][j],dp[i][j-1]);
                dq.push_front(make_pair(i,j-1));
            }
            for(int p=-2;p<=2;p++){
                for(int q=-2;q<=2;q++){
                    if(i+p>=0&&i+p<n&&j+q<m&&j+q>=0&&s[i+p][j+q]=='.'&&abs(p)+abs(q)!=1){
                        if(vis1[i+p][j+q]==false&&vis[i+p][j+q]==false){
                            dp[i+p][j+q]=min(dp[i+p][j+q],dp[i][j]+1);
                            vis1[i+p][j+q]=true;
                            dq.push_back(make_pair(i+p,j+q));
                        }
                    }
                }
            }
        }
        if(dp[dh][dw]==1e9)
            dp[dh][dw]=-1;
        cout<<dp[dh][dw]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 10644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	ll n;
	int m, x, y;
	vector<int> e[100010];
	cin >> n >> m;
	rep(i, m)
	{
		cin >> x >> y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	int done[100010]={};
	int muri=0;
	queue<int> q;
	q.push(1);
	done[1]=1;
	while(!q.empty())
	{
		int tmp=q.front();
		q.pop();
		rep(i, e[tmp].size())
		{
			int j=e[tmp][i];
			if(done[j]==0)
			{
				q.push(j);
				done[j]=(-1)*done[tmp];
			}
			if(done[j]!=0 && done[j]==done[tmp])
			{
				muri=1;
				break;
			}
		}
	}
	if(muri==1) cout << n*(n-1)/2-(ll)m << endl;
	else
	{
		ll gu=0, ki=0;
		reps(i, n)
		{
			if(done[i]==1) gu++;
			else ki++;
		}
		cout << gu*ki-(ll)m << endl;
	}
	return 0;
}

Measured memory_bytes: 6272
import math

def func(val):
    d = range(2, val+1)
    ans = []

    for i in range(2, val+1):
        if i in d:
            ans.append(i)
            d = [n for n in d if n % i != 0]
    #print(ans)
    return ans

n = int(input())

p = 1
pn_list = {}
for l in range(2, n+1):
    for pn in func(l):
        m = 0
        while(1):
            if l % pn != 0:
                break
            else:
                l /= pn
                m += 1
        
        pn_list.setdefault(pn, 0)
        pn_list[pn] += m

p = 1
for v in pn_list.values():
    p *= (v+1)

ans = p % (10**9 + 7)

print(ans)



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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int fib[100];

ll f(int n) {
   if (n == 0 || n == 1) return fib[n] = 1;
   if (fib[n]) return fib[n];
   return fib[n] = f(n-1) + f(n-2);
}

int main() {
   int n;
   cin >> n;
   cout << f(n) << endl;

   return 0;
}


Measured memory_bytes: 3080
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BCountingOfTrees {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> D(N), cnt(N);
	    REP(i,0,N) in >> D[i];
	    if (D[0] != 0) {
	        out << 0 << "\n";
	        return;
	    }
	    sort(all(D));
	    REP(i,0,N) {
	        cnt[D[i]]++;
	    }
        int cntAll = 1;
	    ll answer = 1;
	    REP(i,1,N) {
	        if (cnt[i] == 0) break;
	        REP(j,0,cnt[i]) {
	            answer *= cnt[i-1];
	            answer %= 998244353;
	            cntAll++;
	        }
	    }
	    if (cntAll != N) {
            out << 0 << "\n";
            return;
	    }
	    out << answer << "\n";
    }
};


int main() {
	BCountingOfTrees solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
import std.stdio;
import std.regex;

void main(){
	auto io = new IO();
	auto ABC = io.rect!BigInt()[0];
	if( ABC[0]%2==0 || ABC[1]%2==0 || ABC[2]%2==0 ){
		writeln("0");
		return;
	}else{
		ABC.sort();
		writeln(ABC[0]*ABC[1]);
		return;
	}
}


import std.stdio,std.conv,std.string;
import std.algorithm,std.array,std.math;
import std.bigint;

immutable PRIME = 1_000_000_007;
immutable alphaB = "abcdefghijklmnopqrstuvwxyz";
immutable alphaU = "ABCDRFGHIJKLMNOPQRSTUVWXYZ";

class IO
{
	T[] line( T = real , string token = " " )( size_t m = 1 ){
		T[] arr = [];
		foreach( i ; 0..m ){
			arr ~= this.read!T();
		}
		return arr;
	}
	T[][] rect( T = real , string token = " " )( size_t m = 1 ){
		T[][] arr = new T[][](m);
		foreach( i ; 0..m ){
			arr[i] = this.read!T(token);
		}
		return arr;
	}
	private T[] read( T = size_t )( string token = " " ){
		T[] arr;
		foreach( elm ; readln().chomp().split(token) ){
			arr ~= elm.to!T();
		}
		return arr;
	}
	void swap( T )( ref T x , ref T y ){
		x = x^y;
		y = x^y;
		x = x^y;
	}
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int n, m, q;
    readVars(n, m, q);
    auto s = new int[][](n, m);

    foreach(i ; 0 .. n){
        auto line = readln.chomp;
        foreach(j, ch; line){
            s[i][j] = ch - '0';
        }
    }

    //stderr.writefln("%(%(%s %)\n%)", s);

    auto sxy = new int[][](n, m);

    foreach(i ; 0 .. n){
        sxy[i][] = s[i][];
    }

    //stderr.writefln("%(%(%s %)\n%)", sxy);

    foreach(i ; 0 .. n){
        foreach(j ; 0 .. m - 1){
            sxy[i][j + 1] += sxy[i][j];
        }
    }

    foreach(j ; 0 .. m){
        foreach(i ; 0 .. n - 1){
            sxy[i + 1][j] += sxy[i][j];
        }
    }

    //stderr.writefln("%(%(%s %)\n%)", sxy);
    //stderr.writefln("%(%(%s %)\n%)", s);

    auto exy = new int[][](2*n, 2*m);

    foreach(i ; 0 .. 2*n - 1){
        if (i % 2 == 0) {
            foreach(j ; 0 .. 2*m - 1){
                exy[i][j + 1] += exy[i][j];

                if (j % 2 == 0 && j < 2*m - 2) {
                    exy[i][j + 1] += (s[i/2][j/2] == 1 && s[i/2][j/2 + 1] == 1);
                }
            }
        }
        else
        {
            foreach(j ; 0 .. 2*m - 1){
                if (j % 2 == 0){
                    exy[i][j] += (s[i/2][j/2] == 1 && s[i/2 + 1][j/2] == 1);
                }

                exy[i][j + 1] += exy[i][j];
            }
        }
    }

    foreach(j ; 0 .. 2*m){
        foreach(i ; 0 .. 2*n - 1){
            exy[i + 1][j] += exy[i][j];
        }
    }

    int x1, x2, y1, y2, nv, ne, ans;

    foreach(qi ; 0 .. q){
        readVars(x1, y1, x2, y2);
        x1--;
        x2--;
        y1--;
        y2--;

        nv = sxy[x2][y2];

        if (x1 - 1 >= 0) nv -= sxy[x1 - 1][y2];
        if (y1 - 1 >= 0) nv -= sxy[x2][y1 - 1];
        if (x1 - 1 >= 0 && y1 - 1 >= 0) nv += sxy[x1 - 1][y1 - 1];

        ne = exy[2*x2][2*y2];

        if (2*x1 - 1 >= 0) ne -= exy[2*x1 - 1][2*y2];
        if (2*y1 - 1 >= 0) ne -= exy[2*x2][2*y1 - 1];
        if (2*x1 - 1 >= 0 && 2*y1 - 1 >= 0) ne += exy[2*x1 - 1][2*y1 - 1];

        ans = nv - ne;

        writeln(ans);
    }
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}

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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    bool f = false;
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= m; j++)
        {
            if(i * m + j * n - 2* i * j == k) f= true;
        }
    }
    cout << (f ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
const int N=1e3+10;
const int mod=1e9+7;
int n,m,dp[N][N];char s[N][N];
inline int MOD(int x,int y){x+=y;x-=x>=mod? mod:0;return x;}
int main(){
	scanf("%d%d",&n,&m);
	for(register int i=1;i<=n;i++)scanf("%s",s[i]+1);
	dp[1][1]=1;
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++){
			if(s[i][j]=='#'||(i==1&&j==1))continue;
			dp[i][j]=MOD(dp[i-1][j],dp[i][j-1]);
		}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>

struct Node{int l, r, p, d, h;};

Node T[100];
int Preorder[100] = {};
int Inorder[100] = {};
int Postorder[100] = {};
int n = 0;

void SetDepth(int id, int d = 0) {
    T[id].d = d;
    if (T[id].l < 0) {
    }
}

int pos = 0;

int Reconstruct(int l, int r, int o = 0) {
    if (l >= r) {
        return o;
    }
    if (pos == n) {
        return o;
    }
    int tgt = Preorder[pos++];
    int idx = -1;
    for (int i = 0; i < n; i++) {
        if (Inorder[i] == tgt) {
            idx = i;
            break;
        }
    }
    o = Reconstruct(l, idx, o);
    o = Reconstruct(idx + 1, r, o);
    Postorder[o] = tgt;
    return ++o;
}


int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        T[i] = {-1, -1 ,-1, -1, -1};
    }

    for (int i = 0; i < n; i++) {
        std::cin >> Preorder[i];
    }

    for (int i = 0; i < n; i++) {
        std::cin >> Inorder[i];
    }

    Reconstruct(0, n, 0);
    for (int i = 0; i < n; i++) {
        if (i) std::cout << " ";
        std::cout << Postorder[i];
    }
    std::cout << std::endl;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>

using namespace std;

int main()
{
    char s[5];
    scanf("%s",s);
    int sum=700;
    for (int i=0;i<3;i++)
        if (s[i]=='o') sum+=100;
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a[3];
    cin >> a[0] >> a[1] >>  a[2];
    for(int i = 0; i < 2; i ++){
        for(int j = i + 1 ; j < 3;  j++){
                if(a[i] > a[j]){
                    int temp  = a[i];
                    a[i] = a[j];
                    a[j] = temp ;
                }
        }
    }

    cout << a[0] + a[1];
    return 0;
}


Measured memory_bytes: 256