akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

const long long mod = 1000000007;
long long n;
long long a[510000] , tot;
long long x[1200000];
long long zero[1200000];
vector < long long > v[1200000];
long long b[1200000] , cnt;
long long dp[2][1200000];
long long ans;
long long ksm ( long long f , long long x ) {
	long long s = 1;
	while ( x ) {
		if ( x % 2 ) s = s * f % mod;
		f = f * f % mod; x = x / 2;
	}
	return s % mod;
}
void solve ( long long t , long long ned ) {
	long long i;
	cnt = 0;
	for ( i = 0 ; i < v[t].size() ; i++ ) {
		if ( i != 0 && zero[v[t][i]] != zero[v[t][i-1]] ) b[++cnt] = zero[v[t][i]] - zero[v[t][i-1]];
		b[++cnt] = -1;
	}
	if ( ned == 0 ) {
		if ( zero[n] - zero[v[t][i-1]] >= 1 ) {
			if ( zero[n] - zero[v[t][i-1]] > 1 )
				b[++cnt] = zero[n] - zero[v[t][i-1]] - 1;
			b[++cnt] = 1;
		}
	}
	dp[0][0] = 1;
	dp[1][0] = 0;
	//printf ( "%lld\n" , t );
	for ( i = 1 ; i <= cnt ; i++ ) {
		if ( b[i] == -1 ) {
			dp[1][i] = (dp[1][i-1] + dp[0][i-1]) % mod;
			dp[0][i] = dp[0][i-1];
		}
		else {
			dp[0][i] = (dp[0][i-1] + dp[1][i-1] * b[i]) % mod;
			dp[1][i] = dp[1][i-1];
		}
		//printf ( "%lld %lld %lld\n" , b[i] , dp[0][i] , dp[1][i] );
	}
	//printf ( "%lld %lld\n" , ned , cnt );
	//printf ( "\n" );
	ans = (ans + dp[ned][cnt]-dp[ned][cnt-1]+mod) % mod;
}
void work () {
	long long i , cnt , t;
	scanf ( "%lld" , &n );
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%lld" , &a[i] );
		tot ^= a[i];
		a[i] ^= a[i-1];
		x[tot]++;
		if ( tot == 0 ) {
			zero[i] = 1;
		}
		v[tot].push_back ( i );
	}
	for ( i = 2 ; i <= n ; i++ ) {
		zero[i] += zero[i-1];
	}
	if ( tot == 0 ) {
		for ( i = 1 ; i < (1<<20) ; i++ ) {
			if ( x[i] ) {
				solve ( i , 0 );
			}
		}
		ans = (ans + ksm ( 2 , x[0]-1)) % mod;
	}
	else { 
		solve ( tot , 1 );
	}
	printf ( "%lld\n" , ans );
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 68044
N = int(input())
S = input()
ans = 0
for i in range(1000):
    key = str(i)
    key = "0"*(3-len(key)) + key

    cur = 0
    for s in S:
        if s == key[cur]:
            cur += 1
        if cur >= 3:
            ans += 1
            break

print(ans)

Measured memory_bytes: 42716
#include <iostream>

int main(void){
  int price;

  while(1){
    int cnt = 0;
    std::cin >> price;
    if(price == 0)  return 0;
    price = 1000 - price;
    while(1){
      if(price >= 500){
        cnt++; price -= 500;
      }else if(price >= 100){
        cnt++; price -= 100;
      }else if(price >= 50){
        cnt++;  price -= 50;
      }else if(price >= 10){
        cnt++; price -=10;
      }else if(price >= 5){
        cnt++; price -= 5;
      }else{
        cnt += price;
        break;
      }
    }
    std::cout << cnt << std::endl;
  }
}

Measured memory_bytes: 1160
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)

int main() {
    string s, t;
    cin >> t >> s;
    int cnt = 0, ans = 5000;
    int l = t.size(), m = s.size();
    rep(i, l - m) {
        cnt = 0;
        rep(j, m) {
            if (s[j] == t[i + j]) {
                cnt++;
            }

        }
        if (ans > m - cnt)ans = m - cnt;
       
    }
    if (l == m) {
        rep(i, l) {
            if (s[i] == t[i])cnt++;
        }
        ans = m - cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 3003;
ll n,m,x,y;
string a,b;
ll dp[N][N],gp[N][N];
ll solve(ll i,ll j)
{
    if(dp[i][j] != -1) return dp[i][j];
    
    if(i == 0 || j == 0) return dp[i][j] = 0;
    
    ll res = solve(i - 1,j);
    gp[i][j] = 1;
    
    ll g = solve(i,j - 1);
    if(res < g){
        res = g;
        gp[i][j] = 2;
    }
    if(a[i] == b[j]){
        g = solve(i - 1,j - 1) + 1;
        if(res < g){
            res = g;
            gp[i][j] = 3;
        }
    }
    return dp[i][j] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>a>>b;
    n = a.length(); m = b.length();
    a = "$" + a;
    b = "$" + b;
    solve(n,m);
    b = "";
    x = n; y = m;
    while(x > 0 && y > 0){
        if(gp[x][y] == 1)
            x -= 1;
        else{
            if(gp[x][y] == 3){
                b += a[x];
                x -= 1;
            }
            y -= 1;
        }
    }
    reverse(all(b));
    cout<<b;
    return 0;
}

Measured memory_bytes: 141568
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M >> X;
    vi c(N);
    vvi a(N, vi(M));
    REP(i, N) {
        cin >> c[i];
        cin >> a[i];
    }
    ans = INF;
    for (int bit = 0; bit < (1 << N); bit++) {
        vi x(M, 0);
        int m = 0;
        REP(i, N) {
            if ((bit >> i) & 1) {
                m += c[i];
                REP(j, M) {
                    x[j] += a[i][j];
                }
            }
        }
        int cnt = 0;
        REP(i, M) {
            if (x[i] >= X) {
                cnt++;
            }
        }
        if (cnt == M) {
            ans = min((int)ans, m);
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) v.erase(unique(ALL(v)), v.end())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int A,B;
  while(cin >> A >> B){
    int ans = 0;
    if(A>=13) ans = B;
    else if(A>=6) ans = B/2;
    
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;




int main(void) {
    string s, t;
    cin >> s >> t;
    ll i;
    vector<char> v;
    vector<char> u;
    
    for(i=0; i<s.size(); i++)
        v.pb(s[i]);
    sort(v.begin(), v.end());
    
    for(i=0; i<t.size(); i++)
        u.pb(t[i]);
    sort(u.begin(), u.end());
    
    string a="", b="";
    for(i=0; i<v.size(); i++)
        a+=v[i];
    
    for(i=0; i<u.size(); i++)
        b=u[i]+b;
    
    if(a<b) pt("Yes");
    else pt("No");
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 2e5+10;

ll n,k,x,s[maxn],tree[maxn*4];
vector<ll> v;

void add(ll x){
	while(x < maxn){
		tree[x] += 1;
		x += x&-x;
	}
}

ll sum(ll x){
	ll res = 0;
	while(x > 0){
		res += tree[x];
		x -= x&-x;
	}
	return res;
}

int main(){
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		x = read();
		x -= k;
		s[i] = s[i-1]+x;
	}
	for(int i=0; i<=n; i++) 
		v.push_back(s[i]);
	sort(v.begin(),v.end());
	v.resize(unique(v.begin(),v.end())-v.begin());
	for(int i=0; i<=n; i++) s[i] = lower_bound(v.begin(),v.end(),s[i])-v.begin()+1;

	ll ans = 0;
	for(int i=0; i<=n; i++){
		ans += sum(s[i]);
		add(s[i]);
	}
	cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5104
N=int(input())
s=[input() for i in range(N)]
M=int(input())
t=[input() for i in range(M)]

sl=set(s)
tl=set(t)
c=sl|tl
cl=[]
for item in c:
    cl.append(max(0,s.count(item)-t.count(item)))
print(max(cl))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void IsTriangle( int triangle[1000][3], int number )
{
	int i;
	int a, b, c;

	for ( i = 0 ; i < number ; i++ )
	{
		a = triangle[i][0] * triangle[i][0];
		b = triangle[i][1] * triangle[i][1];
		c = triangle[i][2] * triangle[i][2];
		if ( ( a == b + c ) || ( b == a + c ) || ( c == a + b ) )
		{
			fprintf( stdout, "YES\n" );
		}
		else
		{
			fprintf( stdout, "NO\n" );
		}
	}
}

int main()
{
	int tri[1000][3];
	int number;
	int roop_i;

	scanf( "%d", &number );
	for ( roop_i = 0 ; roop_i < number  ; roop_i++ )
	{
		scanf( "%d %d %d", &tri[roop_i][0], &tri[roop_i][1], &tri[roop_i][2] );
	}

	IsTriangle( tri, number );

	return 0;
}

Measured memory_bytes: 588
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 110;

char str[MAXN];

int main ()
{
    scanf ("%s", &str);
    int len = strlen (str);
    bool flag = false;
    for (int i = 0; i < len; i ++)
    {
        if ((str[i] == 'A') && (i + 1 < len) && (str[i + 1] == 'C'))
        {
            flag = true;
            break;
        }
    }
    if (flag)
    {
        printf ("Yes\n");
    }
    else
    {
        printf ("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

//桁DP
//dp[i][j] -> あまりj のカウント数
//2桁のときの疑問は解消->足しても0
int main() {
    ll A,B,C;
    cin >> A >> B >> C;

    string res = "No";

    if(A+B >= C)res = "Yes";

    cout << res <<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define IC_MAX 7
using namespace std;
int main()
{
	const int val[IC_MAX][IC_MAX]={
		{0,300,500,600,700,1350,1650},
		{300,0,350,450,600,1150,1500},
		{500,350,0,250,400,1000,1350},
		{600,450,250,0,250,850,1300},
		{700,600,400,250,0,600,1150},
		{1350,1150,1000,850,600,0,500},
		{1650,1500,1350,1300,1150,500,0}
	};
	const int dist[IC_MAX][IC_MAX] = {
		{0,6,13,18,23,43,58},
		{6,0,7,12,17,37,52},
		{13,7,0,5,10,30,45},
		{18,12,5,0,5,25,40},
		{23,17,10,5,0,20,35},
		{43,37,30,25,20,0,15},
		{58,52,45,40,35,15}
	};

	while(true){
		int ans = 0;
		int start, end;
		int start_h, end_h, start_m, end_m;
		int start_time, end_time;
		
		cin>>start;
		if( start == 0 )
			break;
		cin>>start_h>>start_m>>end>>end_h>>end_m;
		--start;--end;
		start_time = start_h * 100 + start_m;
		end_time = end_h * 100 + end_m;

		ans = val[start][end];
		if( dist[start][end] <= 40 &&
			(1730 <= start_time && start_time <= 1930) ||
			(1730 <= end_time && end_time <= 1930) ){
				ans /= 2;
		}
		if( ans % 50 != 0 ){
			ans = (ans / 50 + 1) * 50;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main(void){
	int n, i, j;
	int count=0;
	char *flag;

	while(scanf("%d", &n) != -1){
		flag = (char *)malloc(sizeof(char) * (n + 1));
		memset(flag, 0, sizeof(char) * (n+1));
		count = 0;
		for(i=2;i<=n;i++){
			if(flag[i] == 0){
				count++;
				for(j=1;i*j<=n;j++){
					flag[i*j] = 1;
					//printf("[%d]chk %d\n", i, i*j);
				}
			}
		}
		printf("%d\n", count);
		free(flag);
	}

	return 0;
}

Measured memory_bytes: 1556
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int a , b , c;
    cin >> a >> b >>c ;
    if(a+b+c == 17)
    cout << "YES" <<endl;
    else
    cout << "NO" <<endl;
}



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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    string s;
    cin >> s;

    if (s == "ABC")cout << "ARC";
    else cout << "ABC";
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int h,w;
int fi[100][100];
int res;

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

void dfs(int x,int y,int cnt){
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx&&nx<h&&0<=ny&&ny<w){
			if(fi[nx][ny]){
				fi[nx][ny]=0;
				dfs(nx,ny,cnt+1);
				fi[nx][ny]=1;
			}
		}
	}
	res=max(res,cnt);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		res=0;
		cin >> w >> h;
		if(!w)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> fi[i][j];
			}
		}
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(fi[i][j]){
					fi[i][j]=0;
					dfs(i,j,1);
					fi[i][j]=1;
				}
			}
		}
		printf("%d\n",res);
	}
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <iomanip>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i]--;
	}
	
	int ans = 0;
	int now = 0;
	for(int i = 0; i < n; ++i) {
		now = a[now];
		ans++;
		
		if( now == 1 ) break;
	}
	
	if( ans == n ) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3780
N, M = map(int, input().split())
end = 10 ** N
start = 10 ** (N-1)
if start == 1:
    start = 0

sc = [list(map(int, input().split())) for i in range(M)]
for k in range(start, end):
    flag = True
    for s, c in sc:
        r = k // (10 ** (N-s))
        r = r % 10
        if r != c:
            flag = False
            break
    if flag:
        print(k)
        exit(0)
print(-1)


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int N = 1000007, inf = 0x3f3f3f3f;


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

    int n; cin >> n;

    map<string, int> cnt;
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        cnt[s]++;
    }

    int m = 0;
    for(auto & aux : cnt) {
        int tot = aux.second;
        m = max(m, tot);
    }

    for(auto & aux : cnt) {
        int tot = aux.second;
        if(tot == m) cout << aux.first << '\n';
    }
}

Measured memory_bytes: 23808
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	An := make([]int, N)
	for i := range An {
		An[i] = nextInt()
		if An[i] == 0 {
			fmt.Println(0)
			return
		}
	}
	ans := 1
	for i := 0; i < N; i++ {
		// An[i]*ans <= int(1e18)を変形
		if An[i] <= int(1e18)/ans {
			ans *= An[i]
		} else {
			fmt.Println(-1)
			return
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 6128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> m(N);
	vector<vector<int>> g(N);
	for (auto i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		g[a - 1].push_back(b - 1);
		g[b - 1].push_back(a - 1);
	}

	queue<pair<int, int>> q;
	q.push(make_pair(0, 1));
	q.push(make_pair(N - 1, 2));
	while (!q.empty())
	{
		auto p = q.front();
		q.pop();
		if (m[p.first] != 0)
		{
			continue;
		}
		m[p.first] = p.second;

		auto& list = g[p.first];
		for (auto& e : list)
		{
			if (e != p.first)
			{
				q.push(make_pair(e, p.second));
			}
		}
	}

	auto f = 0;
	auto s = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (m[i] == 1)
		{
			++f;
		}
		else
		{
			++s;
		}
	}

	if (f > s)
	{
		cout << "Fennec" << endl;
	}
	else
	{
		cout << "Snuke" << endl;
	}

	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
ll INF = 1000000007;


/***************/
 #define amin main
/***************/

ll exp(ll x, ll n)
{if(n==0) return 1;if(n==1) return x%INF;if(n%2==0) return exp((x*x)%INF,n/2); else return(x*exp((x*x)%INF,n/2))%INF;}


int amin()
{
	ll t,i;
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	for(i=0;i<s.length();i++)
	{
		if(s[i]=='?')
		{
			s[i] = 'D';
		}
	}
	cout<<s<<endl;

	
	

	
	


	
	return 0;
}

Measured memory_bytes: 3748
#include<iostream>
#include<algorithm>
#include<stack>
#include<string>
#include"math.h"

using namespace std;


int main(){
    int a, b, c;
    cin >> a >> b >> c;

    cout <<min(a, min(b,c)) << " " <<max(a, max(b,c)) << endl;
    return 0;
}


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

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    if(m>n) swap(n,m);
    if(m == 1) printf("%d\n",(n == 1)?1:n-2);
    else printf("%lld\n",1LL*(n-2)*(m-2));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define reset(a,b) memset(a,b,sizeof a);
#define ll int
#define MOD 3210121
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define dalam fl<=l && r<=fr
#define kiwo 2*(idx),l,MID
#define tengen 2*idx+1,MID+1,r
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 605
#define pc(x) putchar_unlocked(x);

string ss[mx];
int n,jaw;

bool sama(int x,int y){
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(ss[x+i][y+j]!=ss[x+j][i+y])
				return false;
		}
	}
	return true;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>ss[i];
		string sem=ss[i];
		for(int j=0;j<n-1;j++)
			ss[i]+=sem[j];
	}	
	for(int i=0;i<n-1;i++)
		ss[i+n]=ss[i];
	for(int a=0;a<n;a++){
			int b=0;
			if(!sama(a,b))
				continue;
		//	cout<<a<<' '<<b<<endl;
			int x=a,y=b;
			while(x<n && y<n){
				x++;
				y++;
				jaw++;
			}
		
	}
	for(int b=1;b<n;b++){
			int a=0;
			if(a>=n)
				break;
			if(!sama(a,b))
				continue;
		//	cout<<a<<" "<<b<<endl;
			int x=a,y=b;
			while(x<n && y<n){
				x++;
				y++;
				jaw++;
			}
		
	}
	cout<<jaw;
}


Measured memory_bytes: 640
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] inputs = readln.chomp.split.to!(int[]);
  int N = inputs[0],
      K = inputs[1];
  string D = readln.chomp.split.join;

  while (any!(c => D.canFind(c))(N.to!string)) {
    N++;
  }

  N.writeln;
}


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

int main(void) {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x >= r && x <= w - r && y >= r && y <= h -r) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int main()
{

    int a , b , c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int z = 1<<k;
    if( a >= b && a >= c)
    {
        cout << a*z+b+c;
    }
    else if( b >= c)
    {
        cout << a + z*b + c;
    }
    else
    {
        cout << a+b+z*c;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
int i, j, k, a, b, c ,d;
int e[100000];
int f[100000];
int war = 0;
int po = 0;
int op = 0;

scanf("%d %d %d %d", &a, &b, &c, &d);
for(j = 0; j < a; j++){
scanf("%d", &e[j]);
}
for(j = 0; j < b; j++){
scanf("%d", &f[j]);
}

for(i = 0; i < a; i++){
  for(k = 0; k < b; k++){
    if(f[k] - e[i] < 1) war++;

  }
}
for(i = 0; i < a; i++){
  if(e[i] > c) po++;
}
for(i = 0; i < b; i++){
  if(f[i] < d) op++;
}
//for

if (war == 0 && po != 0 && op !=0){
  printf("No War\n");
}else{
  /*if(pop == 0){  printf("No War\n");}else{*/
  printf("War\n");
}

  return 0;
}


Measured memory_bytes: 256
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut count = vec![0; n + 1];
    for &a in a.iter() {
        count[a] += 1;
    }
    count.sort();
    let mut sum = n;
    let mut carry = 0;
    let mut ans = vec![0; n + 1];
    for turns in (1..(n + 1)).rev() {
        let k = sum / turns + carry;
        ans[k] = cmp::max(ans[k], turns);
        while let Some(c) = count.pop() {
            if c >= turns {
                sum -= c;
                carry += 1;
            } else {
                count.push(c);
                break;
            }
        }
    }

    for k in (0..n).rev() {
        ans[k] = cmp::max(ans[k + 1], ans[k]);
    }

    for i in 1..(n + 1) {
        sc.write(ans[i]);
        sc.write("\n");
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int a;
string s;

void input() {
    cin >> a >> s;
}

void solve() {
    if(a >= 3200) {
        cout << s;
    } else {
        cout << "red";
    }
}

int main() {
    input();
    solve();

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<tuple>
#define MAX 1000007
#define MP make_pair
#define ii long long
#define dd double
#define MAX_SIZE 1e7
#define mod 1000000007
#define gc getchar_unlocked
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define REP(i, b, n) for (long long i = b; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)  ..> ||
#define w(x) int x; cin>>x; while(x--)
#define inp(tmp) ii tmp; cin>>tmp
#define DBG 0
#define print if(DBG)
using namespace std;
typedef pair<ii, ii>	pii;
typedef pair<ll, ll>	pl;
typedef vector<ii>		vi;
typedef vector<ll>		vl;
typedef vector<string>	vs;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
typedef pair<int,vi>	Node;


int main(){
	int n;
    cin>>n;
   for(int i=0;i<n;i++){
     cout<<"ACL";
   }
}

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  vector<ll>a(m);
  vector<ll>t={0,2,5,5,4,5,6,3,7,6};
  rep(i,0,m)cin>>a[i];
  vector<P>p(n+1,MP(-1,-1));
  p[0]=MP(0,0);
  rep(i,0,n){
    if(p[i].fi==-1)continue;
    rep(j,0,m){
      if(t[a[j]]+i>n)continue;
      chmax(p[t[a[j]]+i],MP(p[i].fi+1,a[j]));
    }
  }
  ll now=n;
  string ret;
  //rep(i,0,n+1)cout<<p[i]<<endl;
  while(now){
    ret.PB(p[now].se+'0');
    now-=t[p[now].se];
  }
  cout<<ret<<endl;
  return 0;
}

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

int main(){

    int input_num;
    cin >> input_num;

    int count_a, count_b, count_c;
    int ans = 0;
    int ans_buf = 0;
    int sum = 0;

    for (count_a=1; count_a<=input_num; count_a++){
        for (count_b=1; count_b<=input_num; count_b++){
            for (count_c=1; count_c<=input_num; count_c++){
                ans_buf = __gcd(count_a, count_b);
                ans = __gcd(count_c, ans_buf);
                sum += ans;
            }
        }
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
N=input()
nums=[int(N[0]), int(N[0])-1]
for i in range(1, len(N)):
  nums=[nums[0]+int(N[i]), max(nums[1]+9, nums[0]+int(N[i])-1)] if N[i]!='0' else [nums[0]+int(N[i]), nums[1]+9]
print(max(nums))

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

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

int main() {
  long long int n,k;
  cin>>n>>k;;
  long long int a[n];
  long long int g;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==0)
      g=gcd(a[i],a[i]);
    else g=gcd(g,a[i]);
  }
  
  sort(a,a+n);
  
  
  for(int i=n-1;i>=0;i++){
    if(a[i]>=k && (a[i]-k)%g==0){
      cout<<"POSSIBLE";
      return 0;
    }
    if(a[i]<k)
      break;
  }
      cout<<"IMPOSSIBLE";
  
}

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


void solve(long long A, long long B, long long C){
  int i=A-B;
  cout<<max(0,(int)C-i)<<endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
		scanf("%lld",&A);
		long long B;
		scanf("%lld",&B);
		long long C;
		scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i+=2){
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#define N 200100
using namespace std;
typedef long long ll;

int n, trfa[N], a[N], sum[N];
vector<int> G[N];

int fa[N];
inline int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

struct P {
    int id; ll num; ll sum;
    P(int z = 0, ll x = 0, ll y = 0) {
        id = z, sum = x, num = y;
    }
    friend bool operator<(const P &x, const P &y) {
        if (x.sum * y.num == x.num * y.sum)
            if (x.sum == y.sum)
                return x.num == y.num ? x.id < y.id : x.num < y.num;
            else return x.sum < y.sum;
        else return x.sum * y.num < y.sum * x.num;
    }
};

struct heap {
    priority_queue<P> q, d;
    inline void push(const P &x) {
        q.push(x);
    }
    inline bool eql(const P &x, const P &y) {
        return x.id == y.id && x.sum == y.sum && x.num == y.num;
    }
    inline void update() {
        while (!d.empty() && eql(d.top(), q.top()))
            d.pop(), q.pop();
    }
    inline bool empty() {
        return update(), q.empty();
    }
    inline void erase(const P &x) {
        d.push(x);
    }
    inline P top() {
        return update(), q.top();
    }
};

void dfs(int u, int p = 0) {
    if (!a[u]) sum[u] = 1, fa[u] = p;
    else sum[u] = 0, fa[u] = u;
    for (int v : G[u])
        dfs(v, u), sum[u] += (a[v] ^ 1) * sum[v];
}

heap h;
P now[N];

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n;
    
    for (int i = 2; i <= n; ++i)
        scanf("%d", trfa + i),
        G[trfa[i]].push_back(i);
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);
    bool chk = a[1]; a[1] = 1;
    dfs(1);

    ll ans = 0;
    for (int i = 1; i <= n; ++i)
        if (a[i]) {
            now[i] = P(i, sum[i], 1), ans += sum[i];
            if (i > 1) h.push(now[i]);
        }

    while (!h.empty()) {
        P u = h.top();
        h.erase(u);
        int anc = find(trfa[u.id]);
        if (anc > 1) h.erase(now[anc]);
        fa[u.id] = anc;
        ans += u.sum * now[anc].num;
        now[anc].num += u.num;
        now[anc].sum += u.sum;
        if (anc > 1) h.push(now[anc]);
    }

    if (!chk) {
        for (int i = 2; i <= n; ++i)
            ans -= a[i] ^ 1;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    string o,e;
    cin >> o >> e;
    for(int i=0;i<o.size();++i){
        cout << o[i];
        if(i != e.size())cout << e[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 4003
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >vp,fin;
vector<ll>v,v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>power;
int main()
{
    string s;
    cin>>n;
    FOR(i,n)
    {
        cin>>a;
        vp.p_b(m_p(a,i+1));
    }
    sort(vp.begin(),vp.end());
    FOR(i,n) cout<<vp[i].ss<<" ";
}
/*
5
4
3
2
3
4
4
3
3
4
2
3
*/


Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

int main() {
    int n, m;
    cin >> n >> m;
    ll s[n], t[m];

    rep(i, n) { cin >> s[i]; }
    rep(j, m) { cin >> t[j]; }

    ll dp[n + 1][m + 1];

    rep(i, n + 1) { dp[i][0] = 1; }
    rep(i, m + 1) { dp[0][i] = 1; }

    rep(i, n) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
            } else {
                dp[i + 1][j + 1] =
                    (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + mod) % mod;
            }
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 31616
#include<iostream>
#include<cstdlib>
int main(){
  long long n,k;
  std::cin>>n>>k;
  if(n>k){
    long long ans=n%k;
    if(ans == 0)
      std::cout<<0<<std::endl;
    else{
      long long res = llabs(ans-k) > k ?k:llabs(ans-k);
      std::cout<<res<<std::endl;
    }
  }
  else if(n<k){
    if(((long double)k)/2.0 > n)
      std::cout<<n<<std::endl;
    else
      std::cout<<llabs(n-k)<<std::endl;
  }
  else
    std::cout<<0<<std::endl;
}


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

int main() {
  int N;
  string S,answer = "Yes";
  cin>>N;
  cin>>S;
  
  if(N%2 == 1){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i = N/2; i<N; i++){
    if(S[i%(N/2)] != S[i]){
      answer = "No";
      break;
    }
  }
  
  
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_088
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var marchCnt = new ulong[5];
            for(int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                switch (s[0])
                {
                    case 'M':
                        marchCnt[0]++;
                        break;
                    case 'A':
                        marchCnt[1]++;
                        break;
                    case 'R':
                        marchCnt[2]++;
                        break;
                    case 'C':
                        marchCnt[3]++;
                        break;
                    case 'H':
                        marchCnt[4]++;
                        break;
                }
            }

            ulong allCnt = 0;
            for(int i = 0; i < 3; i++)
            {
                for(int j = i + 1; j < 4; j++)
                {
                    for(int k = j + 1; k < 5; k++)
                    {
                        allCnt += marchCnt[i] * marchCnt[j] * marchCnt[k];
                    }
                }
            }

            Console.WriteLine(allCnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 15188
def decode():
    n = int(input())
    cards = []
    for i in range(n):
        [m, v] = input().split()
        cards.append((m, int(v), i))

    return n, cards


def partition(a, p, r):
    x = a[r][1]
    i = p - 1

    for j in range(p, r):
        if a[j][1] <= x:
            i += 1
            t = a[j]
            a[j] = a[i]
            a[i] = t
    t = a[i+1]
    a[i+1] = a[r]
    a[r] = t

    return i+1


def disp(cards):
    for (m, n, _) in cards:
        print("{0} {1}".format(m, n))


def quicksort(a, p, r):
    if p < r:
        q = partition(a, p, r)
        quicksort(a, p, q-1)
        quicksort(a, q+1, r)


def isstable(cards):
    for i in range(len(cards) - 1):
        if cards[i][1] == cards[i+1][1]:
            if cards[i][2] < cards[i+1][2]:
                pass
            else:
                return False
    return True

if __name__ == '__main__':
    n, cards = decode()

    quicksort(cards, 0, n-1)

    if isstable(cards):
        print("Stable")
    else:
        print("Not stable")

    disp(cards)


Measured memory_bytes: 20156
h,w,k=map(int,input().split())
board=[list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h): #すべての行の塗りつぶし方を2進数で列挙する
 for paint_w in range(2**w): #すべての列の塗りつぶし方を2進数で列挙する
   cnt=0
   for i in range(h): #すべてのi行目j列目の要素についてみる
     for j in range(w):
       if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: #各行のi番目のビットと各列のj番目のビットがともに0であればそのマスは塗りつぶされない
         if board[i][j]=='#': #塗りつぶされないマスが黒マスであれば個数を+1する
           cnt+=1
   if cnt==k: #塗りつぶされない黒マスの個数がKに等しければ答えを+1する
     ans+=1
print(ans)


Measured memory_bytes: 9108
N,K = map(int,input().split())
P = list(input())
count = 0
count2 = 0
for i in range(N-1):
    if P[i] == P[i+1]:
        count2 += 1
if P[0] == 'L':
    for i in range(N - 1):
        if P[i] == 'L' and P[i + 1] == 'R':
            count += 1
    if P[N-1] == 'L':
        print(count2 + 2*min(K,count))
    else:
        if K == count:
            print(count2 + (2*K) -1)
        elif K > count:
            print(count2 + (2 * count -1))
        else:
            print(count2 + (2*K))
else:
    for i in range(N - 1):
        if P[i] == 'R' and P[i + 1] == 'L':
            count += 1
    if P[N-1] == 'R':
        print(count2 + 2*min(K,count))
    else:
        if K == count:
            print(count2 + 2*K -1)
        elif K > count:
            print(count2 + 2*count -1)
        else:
            print(count2 + 2*K)





Measured memory_bytes: 4084
#include <cstdio>
#include <cmath>
int main()
{
	int r,g,x;
	scanf("%d", &r);
	scanf("%d", &g);
	if(0<=r && g<=4500)
	{

       x = 2*g - r;
       printf("%d\n", x);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
const int MAXN=101;
int A[MAXN],B[MAXN],C[MAXN];
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
struct node
{
	int ma;
	int x,y;
	node(int m,int xx,int yy)
	{
		ma=m;x=xx;y=yy;
	}
	bool operator < (const node& a) const
	{
		return ma<a.ma;
	}
};
priority_queue<node> que;
int main()
{
	int n=read();
	for(int i=1;i<n;++i) 
	B[i]=read(),que.push(node(B[i],i,i+1));
	for(int i=1;i<=n;++i) A[i]=0x3f3f3f3f;
	while(!que.empty())
	{
		int v=que.top().ma;
		int x=que.top().x;
		int y=que.top().y;
		A[x]=min(A[x],v);
		A[y]=min(A[y],v);
		que.pop();
	}
	int sum=0;
	for(int i=1;i<=n;++i) sum+=A[i];
	cout<<sum<<endl;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll nck[5005][5005],dp[5005],fac[5005],inv[5005];
int main(){
  int n,a,b,c; scanf("%d%d%d%d",&n,&a,&b,&c);
  if(b%2==1){
    //assert(0);
    printf("0\n"); exit(0);
  }
  nck[0][0]=1;
  fac[0]=1;
  inv[0]=1;
  REPP(i,1,n+1){
    
    nck[i][0]=1;

    REPP(j,1,i+1) nck[i][j]=(nck[i-1][j]+nck[i-1][j-1])%mod;
  }
  b/=2;
  ll ans=0;
  REP(i,c+1){
    REP(j,i+1)if(i-j<=a){
      if(b) dp[i]=(dp[i]+nck[b+j-1][j]*nck[a][i-j]%mod*nck[b+a][a]%mod)%mod;
      else if(j==0) dp[i]=(dp[i]+nck[a][i-j]*nck[b+a][a]%mod)%mod;
    }
    dp[i]%=mod;
    //printf("%d %lld\n",i,dp[i]);
    if((c-i)%3==0){
      ans=(ans+dp[i]*nck[a+b+(c-i)/3][a+b]%mod)%mod;
    }
  }
  printf("%lld\n",ans%mod);
  return 0;
}

Measured memory_bytes: 116992
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using namespace std;

int main(){
  ll n,m;cin>>n>>m;
  ll mod=7+1e9;
  ll ans=1;
  if(n<m)swap(n,m);
  if(n-m>1)ans=0;

  rep(i,m)ans=ans*(i+1)%mod*(i+1)%mod;
  rep(i,n-m)ans=ans*(m+i+1)%mod;
  if(n==m)ans=ans*2%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 256