akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
int main() {
	vector<LL> input;
	int N;
	cin >> N;
	LL ans = 0;
	LL sum = 0;
	for(int i=0; i<N; i++) {
		LL s;
		cin >> s;
		input.push_back(s);
		sum += s;
		if(s == 0) {
			ans += sum/2;
			//cout << sum << endl;
			sum = 0;
		}
		
	}
//	cout << sum << endl;
	ans += sum/2;
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 1400
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
t = 0
s = []
for i in range(m-1):
    t += x[i+1]-x[i]
    s.append(x[i+1]-x[i])
s.sort(reverse = True)
for i in range(min(n-1,m-1)):
    t -= s[i]
print(t)

Measured memory_bytes: 20588
#include<bits/stdc++.h>
using namespace std;
int main (){
   int a, b, c, d, f ,e, g , h, i ,j;
    cin >> a >> b >> c >> d >> f;
   e = c - a;
    g = d -b;
    h = 60 * e;
    i = h + g - f;
    cout << i << endl;
}

Measured memory_bytes: 3620
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	cout << "? ";
	for (int i = 1; i <= N; i++) cout << i << " ";
	cout << endl;

	string s_0;
	cin >> s_0;

	auto flip = [](string &s) {

		if (s == "Red") return "Blue";
		if (s == "Blue") return "Red";

		exit(-1);

	};

	string s_N = flip(s_0);

	auto binary_search = [&]() {

		auto ok = 1;
		auto ng = N + 1;

		while (abs(ok - ng) > 1) {
			int mid = (ok + ng) / 2;

			cout << "?";
			for (int i = mid; i < mid + N; i++) cout << " " << i;
			cout << endl;

			string s_mid;
			cin >> s_mid;

			if (s_mid == s_0) ok = mid;
			else ng = mid;

		}

		return ok;
	};

	int lb = binary_search();

	vector<char> ans(2 * N);
	ans[lb - 1] = s_0[0];
	ans[lb + N - 1] = s_N[0];

	for (int i = 1; i < lb; i++) {

		cout << "? " << i;
		for (int j = lb + 1; j < lb + N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	cerr << "--";

	for (int i = lb + N + 1; i <= 2 * N; i++) {

		cout << "? " << i;
		for (int j = lb + 1; j < lb + N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	cerr << "--";

	for (int i = lb + 1; i < lb + N; i++) {

		cout << "? " << i;
		for (int j = 1; j < lb; j++) cout << " " << j;
		for (int j = lb + N + 1; j <= 2 * N; j++) cout << " " << j;
		cout << endl;

		string s_i;
		cin >> s_i;

		ans[i - 1] = s_i[0];

	}

	cout << "! ";
	for (int i = 0; i < 2 * N; i++) cout << ans[i];
	cout << endl;

	return 0;
}

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

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};



int H, W, A, B;
string c[1010];

int sx, sy, gx, gy;
int cost[1010][1010];


struct State {
	int x, y, cost;
	bool operator > (const State& obj) const { return cost > obj.cost; }
};

bool inRange(int x, int y) { return 0 <= x && x < W && 0 <= y && y < H; }

void solve() {
	memset(cost, -1, sizeof(cost));
	
	priority_queue< State, vector< State >, greater< State > > que;
	que.push(State{sx, sy, 0});
	cost[sy][sx] = 0;
	
	while (!que.empty()) {
		State s = que.top(); que.pop();
		
		bool bomb = (c[s.y][s.x] == '*');
		for (int d=0; d<8; ++d) {
			int nx = s.x + Dx[d];
			int ny = s.y + Dy[d];
			if (!inRange(nx, ny)) continue;
			bomb |= (c[ny][nx] == '*');
		}
		
		for (int d=0; d<8; ++d) {			
			int nx = s.x + Dx[d];
			int ny = s.y + Dy[d];
			if (!inRange(nx, ny)) continue;
			
			int nxt_cost = s.cost + A;
			
			if (d % 2 == 0) {
				if (c[ny][nx] == '#') {
					nxt_cost += B;
					if (bomb) continue;
				}
			}
			
			if (d % 2 == 1) {
				nxt_cost += A;
				if (c[ny][nx] == '#' || c[ny][s.x] == '#' || c[s.y][nx] == '#')	{
					nxt_cost += B;
					if (bomb) continue;
				}
			}
				
			if (cost[ny][nx] < 0 || cost[ny][nx] > nxt_cost) {
				cost[ny][nx] = nxt_cost;
				que.push(State{nx, ny, nxt_cost});
			}
		}
	}
	
	if (cost[gy][gx] == -1) cout << "INF" << endl;
	else cout << cost[gy][gx] << endl;
}



int main() {
	cin >> H >> W >> A >> B;
	for (int y=0; y<H; ++y) {
		cin >> c[y];
		for (int x=0; x<W; ++x) {
			if (c[y][x] == 'g') {
				gx = x;
				gy = y;
			}
			if (c[y][x] == 's') {
				sx = x;
				sy = y;
			}
			
		}
	}
	solve();
}


Measured memory_bytes: 8092
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(ll i=1;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;

int main()
{
	cin >> n;
	int sum = 0;
	for (int i = 1; i < n + 1; i++) {
		for (int j = i; j < n + 1;j++) {
			int x = gcd(i, j);
			for(int k=j;k<n+1;k++) { 
				int y=gcd(x, k);
				if (j == i && k == i)sum += y;
				else if (j == i || k == j)sum += y * 3;
				else sum += y * 6;
			}
		}
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3596
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxn = 2e6+100;
int n,m,cnt;
int x,y,z;
vector<int> f[maxn],g[maxn];
map<pair<int,int>,int> P;
int get(int x,int y)
{
	if(P.find(make_pair(x,y))!=P.end()) return P[make_pair(x,y)];
	else return P[make_pair(x,y)]=++cnt;
}
void add(int x,int y,int z)
{
	f[x].push_back(y);f[y].push_back(x);
	g[x].push_back(z);g[y].push_back(z);
}
int dis[maxn];
bool vis[maxn];
void spfa(int src)
{
	memset(dis,63,sizeof(dis));
	queue<int> Q;
	Q.push(1);
	vis[1]=true;
	dis[1]=0;
	while(!Q.empty())
	{
		int u=Q.front();Q.pop();
		for(int i=0;i<f[u].size();i++)
		{
			int v=f[u][i];
			if(dis[v]>dis[u]+g[u][i])
			{
				dis[v]=dis[u]+g[u][i];
				if(!vis[v])
				{
					vis[v]=true;
					Q.push(v);
				}
			}
		}
		vis[u]=false;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	cnt=n;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		int id1=get(x,z),id2=get(y,z);
		add(id1,id2,0);add(x,id2,1);
		add(y,id1,1);
	}
	spfa(1);
	if(dis[n]>1e7) puts("-1");
	else cout<<dis[n]/2;
	return 0;
}


Measured memory_bytes: 154240
#include <algorithm>
#include <array>
#include <atcoder/all>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	int a;
	cin >> a;
	string ret;

	for (int i = 0; i < a; ++i) {
		ret += "ACL";
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

int main(void) {
	string str;
	while (getline(cin, str), str != ".") {
		bool hasBalance = true;
		stack<int> sKako;
		for (int i = 0; i < str.size(); i++) {
			if (str[i] == '(') {
				sKako.push(1);
			}else if (str[i] == ')') {
				if (sKako.empty()) {
					hasBalance = false;
					break;
				}
				if (sKako.top() != 1) {
					hasBalance = false;
					break;
				}
				sKako.pop();
			}else if( str[i] == '[') {
				sKako.push(2);
			}else if (str[i] == ']') {
				if (sKako.empty()) {
					hasBalance = false;
					break;
				}
				if (sKako.top() != 2) {
					hasBalance = false;
					break;
				}
				sKako.pop();
			}
		}
		if (!sKako.empty()) {
			hasBalance = false;
		}

		cout << (hasBalance ? "yes" : "no") << endl;
	}

	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e7+5;
ll f[N],n,ans;
int main(){
   for(int i=1;i<N;i++) for(int j=i;j<N;j+=i) f[j]++;
   cin>>n; for(int i=1;i<=n;i++) ans+=f[i]*i; cout<<ans;
}


Measured memory_bytes: 81772
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int n;
void init(){
    n = read();
}
void solve(){
    int ans = poww(9, n);
    ans = modadd(ans, poww(9, n));
    ans = modadd(ans, MOD - poww(8, n));
    ans = modadd(MOD - ans, poww(10, n));
    printf("%d\n", ans);
}
int main(){
    int T = 1;
    while (T--){
        init();
        solve();
    }
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
int main(void){
char buf[1000];
int n ,m ,l;
int a = 0;

fgets(buf, sizeof(buf), stdin);
sscanf(buf, "%d %d %d", &n, &m, &l);

if((n % m) != 0) {
a = (n / m)*l + l;
printf("%d\n", a);
}

else if(n % m == 0) {
printf("%d\n", (n/m)*l);    
}

return 0;    
}

Measured memory_bytes: 2168
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.02 21:01:01
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int x;cin >> x;
    if (x >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define endl '\n'

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

    int n, m, ac=0; cin >> n >> m;
    for (int i=0; i<m; i++){
        int a; cin >> a;
        ac += a;
    }
    if (ac > n) cout << "-1\n";
    else cout << n - ac << endl;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N];
    ll sum = 0;
    map<ll, ll> mp;
    REP(i, 0, N) {
        cin >> A[i];
        sum += A[i];
        mp[A[i]]++;
    }
    ll Q;
    cin >> Q;
    REP(i, 0, Q) {
        ll b, c;
        cin >> b >> c;
        ll num = mp[b];
        sum += num * (c - b);
        mp[b] = 0;
        mp[c] += num;
        cout << sum << endl;
    }
}


Measured memory_bytes: 10228
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long Q; cin >> Q;
	for (long long i = 0; i < Q; i++) {
		string X, Y; cin >> X >> Y;
		long long X_size = X.size(), Y_size = Y.size();
		vector<vector<long long>>DP(1100, vector<long long>(1100, 0));
		for (long long j = 0; j < X_size; j++) {
			DP.at(j).at(0) = 0;
		}
		for (long long j = 0; j < Y_size; j++) {
			DP.at(0).at(j) = 0;
		}
		for (long long j = 0; j < X_size; j++) {
			for (long long k = 0; k < Y_size; k++) {
				if (X.at(j) == Y.at(k)) DP.at(j + 1).at(k + 1) = max({ DP.at(j).at(k) + 1, DP.at(j).at(k + 1), DP.at(j + 1).at(k) });
				else DP.at(j + 1).at(k + 1) = max(DP.at(j).at(k + 1), DP.at(j + 1).at(k));
			}
		}
		cout << DP.at(X_size).at(Y_size) << endl;
	}
}


Measured memory_bytes: 12392
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    int A[N];
    P maxi = P(-1,-INF);
    P mini = P(-1, INF);
    rep(i,N){
        cin >> A[i];
        if(maxi.second < A[i]){
            maxi = P(i,A[i]);
        }
        if(mini.second > A[i]){
            mini = P(i,A[i]);
        }
    }
    if(maxi.second >= 0 && -mini.second <= maxi.second){
        cout << 2*(N-1) << endl;
        rep(i,N){
            if(maxi.first == i) continue;
            cout << maxi.first+1 << " " << i+1 << endl;
        }
        rep(i,N-1){
            cout << i+1 << " " << i+2 << endl;
        }
    }
    else{
        cout << 2*(N-1) << endl;
        rep(i,N){
            if(mini.first == i) continue;
            cout << mini.first+1 << " " << i+1 << endl;
        }
        rep(i,N-1){
            cout << N-i << " " << N-1-i << endl;
        }
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
int n, a[222];
signed main() {
	cin >> n;
	n *= 2;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i += 2) {
		ans += a[i];
	}
	cout << ans << endl;
	END;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

vector<int> ans;

void solve(int left, int right, int a, int b, int n){
    if(n == 1){
        ans[left] = a;
        ans[right - 1] = b;
        return;
    }

    int x;
    rep(i, n){
        if((a >> i & 1) != (b >> i & 1)){
            x = i;
            break;
        }
    }

    int la = 0, c, rb = 0;
    REP(i, x + 1, n){
        la += (a & (1 << i));
        rb += (b & (1 << i));
    }
    la >>= 1;
    rb >>= 1;
    rep(i, x){
        la += (a & (1 << i));
        rb += (b & (1 << i));
    }
    c = la ^ 1;

    solve(left, (left + right) / 2, la, c, n - 1);
    solve((left + right) / 2, right, c, rb, n - 1);

    REP(i, left, (left + right) / 2){
        int t = 0;
        REP(j, x, n - 1){
            t += (ans[i] & (1 << j));
        }
        t <<= 1;
        t += (a & (1 << x));
        rep(j, x){
            t += (ans[i] & (1 << j));
        }
        ans[i] = t;
    }
    REP(i, (left + right) / 2, right){
        int t = 0;
        REP(j, x, n - 1){
            t += (ans[i] & (1 << j));
        }
        t <<= 1;
        t += (b & (1 << x));
        rep(j, x){
            t += (ans[i] & (1 << j));
        }
        ans[i] = t;
    }

    return;
}

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

    int n, a, b;
    cin >> n >> a >> b;

    int cnta = 0, cntb = 0;
    rep(i, n){
        cnta += (a >> i & 1);
        cntb += (b >> i & 1);
    }

    if(abs(cnta - cntb) % 2 == 0){
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;

    ans.resize(1 << n);

    solve(0, 1 << n, a, b, n);

    cout << ans[0];
    REP(i, 1, 1 << n){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(2));
    for (int i = 0; i < n; i++) cin >> a.at(i).at(0);
    for (int i = 0; i < n; i++) cin >> a.at(i).at(1);
    
    int count = a.at(0).at(0);

    for (int i = 0; i < n; i++) {
        int tmpCount = 0;
        for (int j = 0; j <= i; j++) {
            tmpCount += a.at(j).at(0);
        }
        for (int j = i; j < n; j++) {
            tmpCount += a.at(j).at(1);
        }
        count = max(tmpCount, count);
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3608
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        A: [usize; N],
    }
    let mut count = vec![0; N];
    for &a in A.iter() {
        if a%2 == N%2 {
            println!("0");
            return
        } else if a == 0 && count[a] == 1 {
            println!("0");
            return
        } else if count[a] == 2 {
            println!("0");
            return
        } else {
            count[a] += 1;
        }
    }
    let ans = (0..N/2).fold(1, |acc, _| (acc*2)%MOD);
    println!("{}", ans);
}

Measured memory_bytes: 4352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int K = in.nextInt();
            Set<Integer> set = new TreeSet<>();
            for (int i = A; i < A + K; i++) {
                if (i > B) continue;
                set.add(i);
            }
            for (int i = B - K + 1; i <= B; i++) {
                if (i < A) continue;
                set.add(i);
            }
            for (Integer i : set) {
                out.println(i);
            }
        }

    }
}



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

using namespace std;

int main() {
  int n, c[20], v[20];
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> c[i];
  for (int i = 0; i < n; i++)
    cin >> v[i];
  for (int i = 0; i < n; i++)
     c[i] = c[i] - v[i];
  v[0] = 0;
  for (int i = 0; i < n; i++) 
    if (c[i] > 0) v[0] += c[i];
  cout << v[0];
  return 0;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int MOD = 100000007;
const int MAXN = 1000000;
const int inf = 0x3f3f3f3f;
int main()
{
	int n, r = 0, b = 0;
	char str[1000];
	scanf("%d%s", &n, str);
	for (int i = 0; i < n; i++)
	{
		if (str[i] == 'R') r++;
		if (str[i] == 'B') b++;
	}
	if (r > b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
# 最大公約数ごとの数を列挙
N,K=map(int,input().split())
li=[0]*(K+1)
out=0
mod=10**9+7

for i in range(K,0,-1):
    li[i]=pow(K//i,N,mod)
    for j in range(i*2,K+1,i):
        li[i]-=li[j]
    out+=li[i]*i

print(out%mod)

Measured memory_bytes: 11112
//submitted by Himj
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
    while(t--){
      ll n,h,w,ans;
      cin>>n>>h>>w;
      ans=(n-h+1)*(n-w+1);
      cout<<ans;
       
    }
  return 0;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll m = x / d;
  ll ans;
  if (k <= m) {
    ans = abs(x - k * d);
  } else {
    if (m == 0) m = 1;
    ans = abs(x - m * d);
    if (m % 2 != k % 2) ans = abs(ans - d);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a == b){cout << "Draw" << endl;}
    else if(a == 1){cout << "Alice" << endl;}
    else if(b == 1){cout << "Bob" << endl;}
    else if(a < b){cout << "Bob" << endl;}

    else cout << "Alice" << endl;

    return 0;
}

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

int main() {
    long long N,x;
    cin >> N >> x;

    vector<long long> num1;
    vector<long long> num2;
    
    long long a;
    for(int i=0;i<N;i++){
        cin >> a;
        num1.push_back(a);
        num2.push_back(a);
    }
    long long ans1=0,ans2=0;
    for(int i=0;i<N;i++){
        if(i==0){
            if(num1[0]>x) {
                ans1+=num1[0]-x;
                num1[0]=x;
            }

            if(num2[N-1]>x){
                ans2+=num2[N-1]-x;
                num2[N-1]=x;
            }
        }
        else{
            ans1+=max((long long)0,(num1[i]+num1[i-1]-x));
            num1[i]=min(x-num1[i-1],num1[i]);

            ans2+=max((long long)0,(num2[N-1-i]+num2[N-i]-x));
            num2[N-1-i]=min(num2[N-1-i],x-num2[N-i]);
        }
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 2036
S = [int(i) for i in input()]
result = 0

for i, b1 in enumerate(S):
    if i < len(S)-1:
        b2 = S[i+1]
    else:
        break
    
    if b1 == b2:
        result += 1
        if b2 == 1:
            S[i+1] -= 1
        else:
            S[i+1] += 1

print(result)

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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  srand((unsigned)time(NULL));
  int d;
  int res = 0;
  cin >> d;
  vector<int> c(26);
  rep(i,26)cin >> c[i];
  vector<vector<int>> v(d,vector<int>(26));
  vector<int> contest(d,0);
  vector<int> last(26,0);
  vector<int> satisfy(26,0);
  rep(i,d)rep(j,26){
    int x;cin >> x;
    v[i][j] = x;
  }
  {
    int j = d;
    for(int i = 0;j;i++){
      contest[d-j] = (i%26);
      j--;
    }
  }
  for(int i = 1;i <= d;i++){
    //rep(j,26)if(v[i-1][contest[i-1]] < v[i-1][j])contest[i-1] = j;
    last[contest[i-1]] = i;
    res += v[i-1][contest[i-1]];
    rep(j,26)res -= c[j]*(i-last[j]),satisfy[j] += c[j]*(i-last[j]);
  }
  while(1.0*clock()/CLOCKS_PER_SEC <= 1.7){
    //int now_time = clock();
    //if(1.0*now_time/CLOCKS_PER_SEC > 1.7)break;
    int day = rand()%d,pos = rand()%26;
    vector<int> new_contest = contest;
    int res_ = res;
    int pre = new_contest[day];
    res_ += satisfy[pos];
    res_ += satisfy[pre];
    res_ -= v[day][pre];
    res_ += v[day][pos];
    int pos_satisfy = 0,pre_satisfy = 0;
    last[pos] = last[pre] = 0;
    new_contest[day] = pos;
    for(int i = 1;i <= d;i++)last[pos] = (new_contest[i-1] == pos ? last[pos] = i : last[pos]),pos_satisfy += c[pos]*(i-last[pos]);
    for(int i = 1;i <= d;i++)last[pre] = (new_contest[i-1] == pre ? last[pre] = i : last[pre]),pre_satisfy += c[pre]*(i-last[pre]);
    res_ -= (satisfy[pos]+satisfy[pre]);
    if(res < res_){
      res = res_;
      contest = new_contest;
      satisfy[pre] = pre_satisfy;
      satisfy[pos] = pos_satisfy;
    }
  }
  rep(i,d)cout << contest[i]+1 << endl;
  


  return 0;
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d",&a,&b);
    c=a*a-b;
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<cstdlib>
#define ll long long
#define lowbit(x) (x&(-x))
using namespace std;

int ac[100007];
int n,m,ans1,ans2,Num[100007];

int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;++i){
        int p;char s[10];
        scanf("%d%s",&p,s);
        if (s[0]=='A') ans1+=ac[p]^1,ac[p]|=1;
        else Num[p]+=ac[p]^1;
    }
    for (int i=1;i<=n;++i)
     if (ac[i]) ans2+=Num[i];
    printf("%d %d\n",ans1,ans2);
}

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

int main(){
  int n,t;
  int a[200000];
  cin >> n >> t;
  for(int i = 0;i < n;i++) cin >> a[i];

  int time = 0;
  int ryou = 0;
  for(int i = 0;i < n;i++){
    if(time > a[i]){
      ryou += (a[i]+t - time);
    }else{
      ryou += t;
    }
    time = a[i] + t;
  }

  cout << ryou << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;

int a[10000][100];

int main(){
    int n, m;
    cin >> n >> m;
    int tmp = 0, pos = -1;
    for(int j = 0; j < m; j++){
        for(int i = 0; i < n; i++){
            char c; cin >> c;
            a[i][j] = (c == 'W');
            tmp += a[i][j];
        }
    }
    int ans = tmp;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            tmp += a[i][j]==0 ? 1 : -1;
        }
        if(tmp < ans){
            ans = tmp, pos = i;
        }
    }
    cout << pos+1 << " " << pos+2 << endl;
    return 0;
}


Measured memory_bytes: 6996
import java.math.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(bu.readLine()),i,a[]=new int[n];
		String s[]=bu.readLine().split(" ");
		for(i=0;i<n-1;i++)
		{
			int k=Integer.parseInt(s[i]);
			a[k-1]++;
		}
		StringBuilder sb=new StringBuilder();
		for(i=0;i<n;i++)
		sb.append(a[i]+"\n");
		System.out.print(sb);
	}
}

Measured memory_bytes: 64360
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input()
X = {'r':P, 's':R, 'p':S}
win = [False]*K

ans = 0
for i in range(N):
    if i<K or T[i]!=T[i-K] or not win[i%K]:
        ans += X[T[i]]
        win[i%K]=True
    else:
        win[i%K]=False

print(ans)

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    ll K;cin>>K;
    ll M=(K%50==0?K/50:K/50+1);
    vector<ll> a(50,49+M);
    REP(i,50){
        if(i<50*M-K)a[i]+=-51+50*M-K;
        else a[i]+50*M-K;
    }
    cout<<50<<endl;
    REP(i,50){
        if(i)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
from math import floor

n = int(input())
A = list(map(int, input().split()))

for i in range(n):
    A[i] = (A[i]-1-i)
b = sorted(A)[floor(len(A)/2)]

sum = 0

for a in A:
    sum += abs(a-b)
print(sum)


Measured memory_bytes: 88020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Vector;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		String[] tmpArray;
		Node nodes[] = new Node[n];
		for(int i = 0; i < n; i++) {
			nodes[i] = new Node();
		}
		
		Edge[] edges = new Edge[n - 1];
		for(int i = 0; i < n - 1; i++) {
			tmpArray = br.readLine().split(" ");
			int start = Integer.parseInt(tmpArray[0]) - 1;
			int end = Integer.parseInt(tmpArray[1]) - 1;
			
			edges[i] = new Edge(start, end);
			
			nodes[start].edges.add(edges[i]);
			nodes[end].edges.add(edges[i]);
		}
	
		int maxIndex = 0;
		int maxColors = 0;
		
		for(int i = 0; i < n; i++) {
			if(maxColors < nodes[i].edges.size()) {
				maxColors = nodes[i].edges.size();
				maxIndex = i;
			}
		}
		
		System.out.println(maxColors);
		
		//BFS
		ArrayList<Node> queue = new ArrayList<Node>();
		queue.add(nodes[maxIndex]);
		nodes[maxIndex].visit = true;
		
		while(!queue.isEmpty()) {
			Node v = queue.remove(0);
			
			//coloring
			int prevColor = 0;
			for(int i = 0; i < v.edges.size(); i++) {
				Edge target = v.edges.get(i);
				
				if(target.color == -1) {
					for(int j = prevColor + 1; j <= maxColors; j++) {
						if(!v.usedColors.contains(j)) {
							target.color = j;
							nodes[target.start].usedColors.add(j);
							nodes[target.end].usedColors.add(j);
							prevColor = j;
							break;
						}
					}
				}
				
				if(!nodes[target.start].visit) {
					nodes[target.start].visit = true;
					queue.add(nodes[target.start]);
				}
				if(!nodes[target.end].visit) {
					nodes[target.end].visit = true;
					queue.add(nodes[target.end]);
				}

			}
			
			
		}
		
		for(int i = 0; i < n - 1; i++) {
			if(edges[i].color > maxColors || edges[i].color <= 0) {
				System.out.println("ERROR!!");
				System.exit(0);
			}
			System.out.println(edges[i].color);
		}
	}

}

class Node {
	Vector<Edge> edges = new Vector<Edge>();
	boolean visit = false;
	HashSet<Integer> usedColors = new HashSet<Integer>();

}
class Edge {
	int start;
	int end;
	int color;
	
	Edge(int start, int end){
		this.start = start;
		this.end = end;
		this.color = -1;
	}
}

Measured memory_bytes: 86684
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, T, L, B;
    vector<vector<double>> dp;
    string tapi;

    void input() {
        cin >> N >> T >> L >> B;
        dp.resize(T + 3, vector<double>(N + 1, 0.0));
        dp[0][0] = 1.0;
        for (int i = 0; i <= N; ++i) {
            tapi[i] = '.';
        }
        for (int i = 0; i < L; ++i) {
            int tmp;
            cin >> tmp;
            tapi[tmp] = 'L';
        }
        for (int i = 0; i < B; ++i) {
            int tmp;
            cin >> tmp;
            tapi[tmp] = 'B';
        }

    }

    bool solve() {
        input();
        if (N == 0) return false;


        for (int t = 0; t < T; ++t) {
            for (int x = 0; x < N; ++x) {
                for (int d = 1; d <= 6; ++d) {
                    int y = x + d;
                    if (y > N) y = 2 * N - x - d;
                    if (tapi[y] == 'L') {
                        dp[t + 2][y] += dp[t][x] / 6;
                    } else if (tapi[y] == 'B') {
                        dp[t + 1][0] += dp[t][x] / 6;
                    } else {
                        dp[t + 1][y] += dp[t][x] / 6;
                    }
                }
            }
            //ゴール更新
            dp[t + 1][N] += dp[t][N];
        }
        double ans = dp[T][N];
        cout << ans << endl;

        return true;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while (Solve().solve());


    return 0;
}



Measured memory_bytes: 3372
#include <iostream>
#include <string>
using namespace std;
string a;
int n;
int main () {
    cin >> a;
    n = 0;
    for (int i = 0 ; i < a.size() ; i ++ ) {
        if ( a[i] == '-' ) { n --; }
        else { n ++; }
    }
    cout << n << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
int n,ans;
map <int, int> mp;
int poww[35];
int z[maxn];
int main()
{
    poww[0] = 1;
    for (int i = 1; i <= 30; ++i)
        poww[i] = poww[i - 1] * 2;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", z + i);
        if (!mp.count(z[i]))
            mp[z[i]] = 1;
        else
            ++mp[z[i]];
    }
    sort(z, z + n);
    for (int i = n - 1; i >= 0; --i)
    {
        int tmp = z[i];
        if (mp[z[i]] < 1)
            continue;
        --mp[z[i]];
        for (int j = 30; j >= 0; --j)
        {
            if (poww[j] < tmp)
                break;
            int t = poww[j] - tmp;
            if (!mp.count(t))
                continue;
            if (mp[t])
            {
                --mp[t];
                ++ans;
                break;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 10368
import itertools
from collections import Counter

N = int(input())
V = [int(x) for x in input().split()]
EV_counter = Counter(V[::2])
OD_counter = Counter(V[1::2])

# 1種類しかないとき対策
EV_counter[-1] = 0
OD_counter[-2] = 0

# 上位2種しか使う必要がない
EV = EV_counter.most_common(2)
OD = OD_counter.most_common(2)

answer = N
for (k1,v1), (k2,v2) in itertools.product(EV,OD):
  if k1 == k2:
    continue
  x = (N - v1 - v2)
  if answer > x:
    answer = x

print(answer)

Measured memory_bytes: 18656
# -*- coding: utf-8 -*-
from collections import defaultdict
from math import sqrt,floor
num,product = map(int,input().split())
cnt = int(sqrt(product) + 2)
dd = defaultdict(int)

for i in range(2,cnt):
    if product % i == 0:
        a = 0
        while product % i == 0:
            a += 1
            product = product // i
        dd[i] = a
if product != 1:
    dd[product] =  1
ans = 1
for p,n in dd.items():
    ans *= pow(p,floor(n/num))
print(ans)

Measured memory_bytes: 9464
N = int(input())
Ds  = list(map(int, input().split()))
if Ds[0] != 0:
    print(0)
    exit()
Ds.sort()

mod = 998244353

from collections import defaultdict
d = defaultdict(int)

d_max = Ds[-1]
for D in Ds:
    d[D] += 1

ans = 1

for i in range(1,d_max+1):
    ans *= pow(d[i-1],d[i],mod)%mod
if d[0] > 1:
    print(0)
else:
    print(ans%mod)

Measured memory_bytes: 62316
#include <iostream>

using namespace std;

typedef long long ll;

int blen (ll x) {
  return 63 - __builtin_clzll(x);
}

void failure () {
  cout << -1 << endl;
  exit(0);
}

const ll MAX_V = 1e18;
const int MAX_L = 60;

int main () {
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;

  ll ans = 1;
  int fail = 0;
  for (int i = 0; i < n; i++) {
    ll x;
    cin >> x;

    if (x == 0) {
      cout << 0 << endl;
      exit(0);
    }
    if (blen(x) + blen(ans) > MAX_L) fail = 1;
    ans *= x;
  }

  if (ans > MAX_V) fail = 1;

  if (fail) failure();
  cout << ans << endl;
}


Measured memory_bytes: 3656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int h = cin.Int();
			int w = cin.Int();
			int a = cin.Int();
			int b = cin.Int();

			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (j < a && i < b) {
						sb.Append("0");
					} else if (j >= a && i >= b) {
						sb.Append("0");
					} else {
						sb.Append("1");
					}
				}

				sb.AppendLine();
			}

			Console.WriteLine(sb.ToString());
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 17760
#include<stdio.h>
int main(void){
    int data[9]={399,799,1199,1599,1999,2399,2799,3199,4800};
    int sta[9]={0};
    int n,i,j,tmp,min=0,max=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<=399){
            sta[0]++;
        }
        for(j=0;j<8;j++){
            if((tmp>data[j])&&(tmp<=data[j+1])){
                sta[j+1]++;
            }
        }
    }
    for(i=0;i<8;i++){
        if(sta[i]>0){
            min++;
        }
    }
    max=min+sta[8];
    if(min==0){
        min++;
    }
    printf("%d %d\n",min,max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i = a; i <= b; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline ll Pow(ll a, ll b) { ll ans = 1; for( ; b; b >>= 1) { if(b&1) ans = ans * a % mod; a = a * a % mod;} return ans;}
inline ll Mul ( ll a, ll b)  { ll lf = a * ( b >> 25ll ) % mod * ( 1LL << 25 ) % mod; ll rg = a * ( b & ( ( 1ll << 25 ) - 1 ) ) % mod; return ( lf + rg ) % mod;}
inline ll C(ll y, ll x) { ll ans = 1; if(y < 0 || x < 0 || y < x) return 0; y %= mod; if(!y || !x) return 1; rep(i, 0, x-1) ans = ans * (y-i) % mod; rep(i, 1, x) ans = ans * Pow(i, mod-2) % mod; return ans; }
/*==================================================*/

ll n, k;

int main() {
   scanf("%d %d", &n, &k);
   if(n > k) puts("0");
   else {
      ll ans = 1;
      rep(i, 0, n-1) {
         (ans *= k - i) %= mod;
      }
      printf("%lld\n", ans);
   }
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
int main (){
int n;
cin>>n;
double a,c=0;
int i;
string s;
for(i=0;i<n;i++){
cin>>a>>s;
if(s=="JPY")
c+=a;
else
c+=a*380000;
}
cout<<c;
return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define int long long
int n,s;
struct T{
	int x,y;
}a[100100];
int sta[100100],L;
inline int operator <(T a,T b){
	return a.x<b.x;
}
main(){
	scanf("%lld%lld",&n,&s);
	for(int i=1;i<=n;++i)
		scanf("%lld%lld",&a[i].x,&a[i].y);
	std::sort(a+1,a+1+n);
	int l=1,r=n;
	long long ans=0;
	while(1){
		if(a[l].x>=s){
			ans=a[r].x-s;
			s=a[r].x;
			break;
		}
		if(a[r].x<=s){
			ans=s-a[l].x;
			s=a[l].x;
			break;
		}
		if(a[l].y>=a[r].y){
			a[l].y+=a[r].y;
			r--;
			sta[L++]=a[r+1].x;
		}else{
			a[r].y+=a[l].y;
			l++;
			sta[L++]=a[l-1].x;
		}
	}
	while(L--!=0){
		ans+=abs(sta[L]-s),
		s=sta[L];
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>

using namespace std;
 
int main(){
    int n,k,a,b,tile;
   
    cin >> n >> k;   
    for( int i = 0 ; i < k ; i++ ){
	cin >> a >> b;
	a = min( a , n - a + 1 );
	b = min( b , n - b + 1 );    
	tile = min( a , b ) % 3;
	if( tile == 0 ) tile = 3;
	cout << tile << endl;    
    }
    return 0;
}

Measured memory_bytes: 3092
h,w=map(int, input().split())
lst = [input() for i in range(h)] 
for i in range(h):
  for j in range(w): 
    if(lst[i][j]=="#"):
      u=1
      l=1
      r=1
      d=1
      if(i==0):
        u=0
      if(i==h-1):
        d=0
      if(j==0):
        l=0
      if(j==w-1):
        r=0
      if not(lst[i-u][j]=="#" or lst[i+d][j]=="#" or 
         lst[i][j-l]=="#" or lst[i][j+r]=="#"):
        print("No")
        quit()
else:
    print("Yes")


Measured memory_bytes: 3064
N = input()
num = input().split(' ')
count = 0
for i in range(int(N) - 2):
  if (int(num[i]) < int(num[i+1]) and int(num[i+1]) < int(num[i+2])) or (int(num[i+2]) < int(num[i+1]) and int(num[i+1]) < int(num[i])):
      count += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
	int u,minv;
	int d[MAX], p[MAX], color[MAX];

	for(int i=0;i<n;i++){
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while(1){
		minv = INFTY;
		u = -1;
		for(int i=0;i<n;i++){
			if(minv > d[i] && color[i]!=BLACK){
				u = i;
				minv = d[i];
			}
		}
		if(u==-1) break;
		color[u] = BLACK;
		for(int v=0; v<n; v++){
			if(color[v] != BLACK && M[u][v] != INFTY){
				if(d[v] > M[u][v]){
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}

	int sum = 0;
	for(int i=0; i<n; i++){
		if(p[i] != -1) sum += M[i][p[i]];
	}

	return sum;
}

int main(){
	cin >> n;
	for(int i=0; i<n;i++){
		for(int j=0; j<n; j++){
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	cout << prim() << endl;

	return 0;
}



Measured memory_bytes: 3124