akhauriyash/Code-Regression huggingface dataset:
def main():
	S = input()
	n = len(S)
	ans = 0

	black = 0
	f_pos = 0
	l_pos = 0

	for i, c in enumerate(S):
		if(c == 'B'):			
			f_pos += i
			black += 1

	l_pos = sum(list(range(n-1, n-1-black, -1)))
	

	ans = l_pos - f_pos

		
	print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 11240
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=2000005;
char s[N]; int n,ans;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n){
		if(s[i]=='?') s[i]='D';
	}
	puts(s+1);
	return 0;
}


Measured memory_bytes: 3928
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; 
ll n;
ll _gcd(ll a,ll b){
	if (a%b==0) return b;
	return _gcd(b,a%b);
}
ll a[100004];
int main(){
	cin>>n;
	for (ll i=0;i<n;i++) cin>>a[i];
	ll ans=a[0];
	for (ll i=1;i<n;i++) ans=_gcd(ans,a[i]);
	cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second     
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)      for(int i=b-1;i>=a;i--)
#define trav(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN             10001

using namespace std;

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 


//int dx[4]={0,0,1,-1};
//int dy[4]={1,-1,0,0};
void solve()
{
    
    int n;
    cin>>n;
    queue<int> q;
    vector<int>v;
    rep(i,1,10)
    q.push(i);
    int cnt=0;
    while(!q.empty())
    {
        int f=q.front();
        v.pb(f);q.pop();
        if(f%10==9)
        {
            cnt+=2;
            q.push((f*10)+8);
            q.push((f*10)+9);
        }
        else if(f%10==0)
        {
            cnt+=2;
            q.push((f*10)+0);
            q.push((f*10)+1);
        }
        else
        {
            cnt+=3;
            int p=f%10;
            q.push((f*10)+p-1);
            q.push((f*10)+p);
            q.push((f*10)+p+1);
        }
        if(cnt>=100000)
            break;
    }
    while(!q.empty())
    {
        int f=q.front();
        v.pb(f);q.pop();
    }
    sort(v.begin(),v.end());
    cout<<v[n-1];

    
    
}	
	


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)
    {
    	solve();
    }
}

Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
typedef pair<double,long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n,m;
	cin >> n;
	vector<ll>d(n);
	rep(i, n)cin >> d[i];
	cin >> m;
	vector<ll>t(m);
	rep(i, m)cin >> t[i];
	map<ll, ll>kindD,kindT;
	rep(i, n) kindD[d[i]]++;
	rep(i, m) kindT[t[i]]++;
	rep(i, m) {
		if (kindT[t[i]] > kindD[t[i]])return cout << "NO" << endl,0;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 28416
N = int(input())
upper = list(map(int,input().split()))
lower = list(map(int,input().split()))

temp_sum = sum(upper) + lower[N-1]
max_value =temp_sum

for i in range(N-1):
  temp_sum = temp_sum - upper[-(i+1)] +lower[-(i+2)]
  if temp_sum > max_value:
    max_value = temp_sum

print(max_value)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int,int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(int i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    for (int i = 0; i < a; i++) {
        if ( '0' <= s[i] && s[i] <= '9') {
        }
        else {
            cout << "No";
            return 0;
        }
    }
    if (s[a] == '-') {
    }
    else {
        cout << "No";
        return 0;
    }
    for (int i = a + 1; i < a + b + 1; i++) {
        if ( '0' <= s[i] && s[i] <= '9') {
        }
        else {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))
top = 1
item = 1
below = []
belows = 0
for i in a:
  top *= i
for num in range(len(a)):
  for _, j in enumerate(a):
    if _ != num:
    	item *= j
  below.append(item)
  item = 1
for b in below:
  belows += b
ans = top/belows
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin()) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    for (auto it = v.begin(); it != v.end(); ++it) {
        if ( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
    for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
//     FASTIO
//     ///*
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
//     freopen("out.txt", "w", stdout);
//     freopen("error.txt", "w", stderr);
// #endif
// //*/
    map<string, string> ans;
    ans["Sunny"] = "Cloudy";
    ans["Cloudy"] = "Rainy";
    ans["Rainy"] = "Sunny";
    string s;
    cin >> s;
    cout << ans[s] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 20002

int dy1[6]={1,0,-1,-1,0,1};
int dx1[6]={1,2,1,0,-1,0};

int dy2[6]={-1,-2,-1,0,1,0};
int dx2[6]={1,0,-1,-1,0,1};

int dy3[6]={1,0,-1,-1,0,1};
int dx3[6]={-1,-2,-1,0,1,0};

int dy4[6]={1,2,1,0,-1,0};
int dx4[6]={1,0,-1,-1,0,1};

int n;

map<P,int> T,F,vd;
map<P,P> G;

int Y[MAX],X[MAX];
char c[MAX];
bool flg[MAX];


bool rec(int x,int y){
  //  cout<<x<<' '<<y<<endl;

  P p=P(x,y);
  P q=G[p];
  vd[p]=true;
  vd[q]=true;
  F[p]=1;
  F[q]=2;
  int id=T[p];
  flg[id]=true;
  P to;
  int ny,nx;
  for(int i=0;i<6;i++){
    if(c[id]=='x'){
      if(y==Y[id]&&x==X[id]){
	ny=y+dy1[i];
	nx=x+dx1[i];
      }else{
	ny=y+dy3[i];
	nx=x+dx3[i];
      }
    }else{
      if(y==Y[id]&&x==X[id]){
	ny=y+dy4[i];
	nx=x+dx4[i];
      }else{
	ny=y+dy2[i];
	nx=x+dx2[i];
      }
    }
    to=P(nx,ny);

    if(i<3&&F[to]==1)return false;
    if(i>=3&&F[to]==2)return false;
    if(vd[to])continue;
    if(T[to]==0)continue;
    if(i<3){
      nx=G[to].first;
      ny=G[to].second;
    }
    if(!rec(nx,ny))return false;
  }

  return true;
}

bool solve(){
  for(int i=1;i<=n;i++){
    if(flg[i])continue;
    if(!rec(X[i],Y[i]))return false;
  }
  return true;
}


int main() {

  while(cin >> n && n) {
    T.clear();
    G.clear();
    vd.clear();
    F.clear();
    for(int i=1; i<=n; i++) {
      cin >> X[i] >> Y[i] >> c[i];
      P a,b;
      a.first=X[i],a.second=Y[i];
      if(c[i]=='x'){
	b.first=a.first+1;
	b.second=a.second;
	T[a]=i;
	T[b]=i;
	G[a]=b;
	G[b]=a;
      }else{
	b.first=a.first;
	b.second=a.second+1;
	T[a]=i;
	T[b]=i;
	G[a]=b;
	G[b]=a;
      }
    }
    for(int i=1;i<=n;i++)flg[i]=false;
    cout<<(solve()?"Yes":"No")<<endl;
    /*
    for(int i=5;i>=0;i--){
      for(int j=0;j<=5;j++){
	cout<<vd[P(i,j)];
      }
      cout<<endl;
    }
    */
  }
  return 0;
}

Measured memory_bytes: 39200
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
set<string> seti;

int main(){
    std::ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int k;
    cin>>k;
    string str;
    int n=s.length();
    int i,j;
    rep(i,s.length()){
    	str="";
    	rep(j,6){

    		if(i+j>=n)
    			break;
    		str+=s[i+j];
    		//cout<<str<<endl;
    		seti.insert(str);
    	}
    }
    k--;
    while(k--){
    	//cout<<*(seti.begin())<<endl;

    	seti.erase(seti.begin());
    }
    cout<<*(seti.begin())<<endl;
    return 0;  
    
}



Measured memory_bytes: 2176
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    flg=0
    k=INT()
    a,b=INTM()
    for i in range(a,b+1):
        if i%k==0:
            flg=1
    if flg==0:
        print('NG')
    else:
        print('OK')
if __name__ == '__main__':
    do()

Measured memory_bytes: 9136
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a>1&&b>1&&c>1&&a<10&&b<10&&c<10)
    {
        if((a==5&&b==5&&c==7)||(a==7&&b==5&&c==5||(a==5&&b==7&&c==5)))
        {
            printf("YES");
        }

        else
            printf("NO");
    }
    return 0;
}






Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
using namespace std;
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 pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
const int INF = 100100100;
int main(){
    int n,m; cin >> n >> m;
    vector<int> v;
    for(int i=1;i<n;i++) v.push_back(i);
    vector<vector<int>> to(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int ans=0;
    do{
        int res=0;
        rep(i,n-1){
            for(auto u:to[v[i]]){
                if(i==0 && u==0) res++;
                else if(u==v[i-1]) res++;
            }
        }
        if(res==n-1) ans++;
    }while(next_permutation(v.begin(),v.end()));
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << max(a*b,c*d) << endl;
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N, M;
int cnt[3][100];

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        string s;
        std::cin >> s;

        for(int j=0;j<M;++j){
            if(s[j] == 'W'){
                ++cnt[0][i];
            }else if(s[j] == 'B'){
                ++cnt[1][i];
            }else{
                ++cnt[2][i];
            }
        }
    }

    int res = N * M;
    for(int i=1;i<=N;++i){
        for(int j=1;j<N-i;++j){
            int k = N - (i + j);
            int x = (i * M - accumulate(&cnt[0][0], &cnt[0][0]+i, 0)) + (j * M - accumulate(&cnt[1][i], &cnt[1][i]+j, 0)) + (k * M - accumulate(&cnt[2][i+j], &cnt[2][i+j]+k, 0));
            res = min(res, x);
        }
    }

    std::cout << res << std::endl;
}



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

int main(){
	ll n,W,i,j;
	cin>>n>>W;
	vector<ll> w(n+1),v(n+1), dp(W+1);
	for(i=1; i<=n; ++i){
		cin>>w[i]>>v[i];
		for(j=W-w[i]; j>=0; --j){
			dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
		}
	}
	cout<<dp[W]<<"\n";
	return 0;
}


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

bool is_prime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;

  double sqrt_num = sqrt(num);
  for (ll i = 3; i <= sqrt_num; i += 2)
  {
    if (num % i == 0)
      return false;
  }

  return true;
}

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

  int n;
  cin >> n;
  vector<int> primes;
  rep(i, 2, 55556)
  {
    if (is_prime(i) && i % 5 == 1)
      primes.push_back(i);
    if (primes.size() == n)
      break;
  }

  rep(i, 0, n)
  {
    if (i > 0)
      cout << " ";
    cout << primes[i];
  }

  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Multiplication2 | diff Multiplication2.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Multiplication2.cpp && ./a.out

/*

 5/31/2020

 5:01-5:05 AC

 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

const __uint128_t inf=1e18;
void solve() {
  LL res=1;
  REP(i,N) {
    __uint128_t a=A[i];
    if(a*res>inf) res=inf+10;
    else res=(LL)(a*res);
  }
  cout<<(res>inf?-1:res)<<endl;
}

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

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 2e3 + 20;

vector<int> adj[maxn];

string s;

int sum , h[maxn] , mn[maxn] , mx[maxn] , num[maxn];

void dfs(int v , int p = -1)
{
	mn[v] = mx[v] = 0;
	num[v] = (s[v] == '1');

	for(auto u : adj[v])
		if(u != p)
		{
			dfs(u , v);
			num[v] += num[u];

			mn[u] += num[u];
			mx[u] += num[u];
			if(max(mn[v] , mn[u]) <= min(mx[v] , mx[u]))
			{
				mx[v] += mx[u];
				mn[v] = (mn[v] % 2 != mn[u] % 2);
			}
			else
			{
				mn[v] = max(mn[v] , mn[u]) - min(mx[v] , mx[u]);
				mx[v] += mx[u];
			}
		}
}

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

	int n;
	cin >> n >> s;

	for(int i = 0; i < n - 1; i++)
	{
		int a , b;
		cin >> a >> b;
		a-- , b--;

		adj[a].pb(b);
		adj[b].pb(a);
	}

	int res = 1e9;
	for(int i = 0; i < n; i++)
	{
		sum = 0;
		dfs(i);
		if(!mn[i])
			res = min(res , mx[i] / 2);
	}

	if(res >= 1e8)
		res = -1;
	cout << res << endl;
}











Measured memory_bytes: 640
N = int(input())
S = input()
numbers=[str(i).zfill(3) for i in range(1000)]
 
count=0
for num in numbers:
  j=0
  for i in range(N):
    if num[j]==S[i]:
      j+=1
      if j==3:
        count+=1
        break
print(count)

Measured memory_bytes: 40924
// ABC 50 C

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) {
    cin >> a[i];
  }

  sort(a.begin(), a.end());

  struct mint base;
  base.x = 2;

  if (n % 2 == 0) {
    for (int i = 0; i < n; i += 2) {
      if (a[i] != i + 1 || a[i] != a[i+1]) {
        cout << 0 << endl;
        return 0;
      }
    }
    mint ans = base.pow(n/2);
    cout << ans.x << endl;
  } else {
    if (a[0] != 0) {
      cout << 0 << endl;
      return 0;
    }
    for (int i = 1; i < n; i += 2) {
      if (a[i] != i + 1 || a[i] != a[i+1]) {
        cout << 0 << endl;
        return 0;
      }
    }

    mint ans = base.pow((n-1)/2);
    cout << ans.x << endl;
  }

  return 0;
}


Measured memory_bytes: 640
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
3776
---+/
/+---test
8080
---+/

void main(string[] args) {
  const S = readln.chomp;
  (S.uniq.equal(S)? "Good": "Bad").writeln;
}


Measured memory_bytes: 256
s = list(input())

for i in range(2**3):
	res = int(s[0])
	m = []
	for j in range(3):
		if i>>j&1:
			res += int(s[j+1])
			m.append("+")
		else:
			res -= int(s[j+1])
			m.append("-")
	if res == 7:
		m.append("")
		break
		
for i in range(4):
	print(s[i] + m[i], end = "")
print("=7")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a=0;cin>>n;
  vector<int> v(n),c(n);
  for(int i=0;i<n;i++)cin>>v.at(i);
  for(int j=0;j<n;j++){
    cin>>c.at(j);
    if(v.at(j)>c.at(j))a+=v.at(j)-c.at(j);
  }
  cout<<a<<endl;
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, m, k, i;
	cin >> n >> m >> k;
	int arr[n], b[m];
	fo(i, 0, n)
	cin >> arr[i];
	fo(i, 0, m)
	cin >> b[i];
	
	int ans = inf;
	fo(i, 0, k){
		int x, y, c;
		cin >> x >> y >> c;
		--x, --y;
		ans = min(ans, arr[x] + b[y] - c);
	}
	int mn1 = *min_element(arr, arr + n);
	int mn2 = *min_element(b, b + m);
	ans = min(ans, mn1 + mn2);
	cout << ans;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;
ll pre[maxn];
ll inv[maxn];
ll prei[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
int main() {
    int n, k;
    cin >> n >> k;
    build(n);
    ll ans = 0;
    for (int i = 0 ; i < n ; i++) {
        if (i > k)break;
        ans += C(n,i) * C(n-1,n-i-1) % mod;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6144
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int a, b, c;
	int k;
	int ans = 0;
	cin >> a >> b >> c >> k;
	int max = a;
	if (max < b)max = b;
	if (max < c)max = c;
	REP(i, k) {
		if (max == a) {
			a *= 2;
			max = a;
		}
		else if (max == b) {
			b *= 2;
			max = b;
		}
		else if (max == c) {
			c *= 2;
			max = c;
		}
	}
	cout << a + b + c << endl;
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

typedef pair<long double,int> D;

struct cir{long double x,y,r;};

long double sx,sy,gx,gy;
int n;
long double dp[1010][1010];
vector<cir> v;


int main()
{
	cin >> sx >> sy >>gx >> gy;
	cin >> n;
	v.PB({sx,sy,0});	
	REP(i,n)
	{
		long double a,b,c;
		cin >> a >> b >> c;
		v.PB({a,b,c});
	}
	v.PB({gx,gy,0});
	
	long double dist[1010];
	REP(i,1010)dist[i] = 1000000000000000;
	dist[0] = 0;
		
	REP(i,v.size())
	{
		REP(j,v.size())
		{
			if(i == j)continue;
			long double tmp;
			long double A = (v[i].x - v[j].x) * (v[i].x - v[j].x);
			long double B = (v[i].y - v[j].y) * (v[i].y - v[j].y);
			tmp = max((long double)0,sqrt(A + B) -v[i].r - v[j].r);
			dp[i][j] = dp[j][i] = tmp;
		}
	}
	
	priority_queue<D,vector<D>,greater<D> > pq;
	pq.push(MP(0,0));
	
	while(!pq.empty())
	{
		auto now = pq.top();pq.pop();
		if(now.FI > dist[now.SE])continue;
		REP(i,n+2)
		{
			if(now.SE == i)continue;
			if(dist[i] > now.FI + dp[now.SE][i])
			{
				dist[i] = now.FI + dp[now.SE][i];
				pq.push(MP(dist[i],i));
			}
		}
	}
	
	cout << Decimal << dist[n+1] << endl;
	
	
	return 0;
}

Measured memory_bytes: 26512
from math import gcd
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    w = gcd(i, j)
    if w==1:
      m += K
    else:
      for k in range(1, K+1):
        m += gcd(w, k)
print(m)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MAX 52

int main() {
  int H,W;
  cin >> H >> W;
  char S[MAX][MAX]={};
  char Pri[MAX][MAX]={};

  for(int i=0;i<H;i++) {
    cin >> S[i];
  }
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++) {
      if(S[i][j] != '#') {
        int count=0;
        if(i>=0&&j+1>=0&&S[i][j+1]=='#') count++;
        if(i>=0&&j-1>=0&&S[i][j-1]=='#') count++;
        if(i+1>=0&&j>=0&&S[i+1][j]=='#') count++;
        if(i-1>=0&&j>=0&&S[i-1][j]=='#') count++;

        if(i+1>=0&&j+1>=0&&S[i+1][j+1]=='#') count++;
        if(i+1>=0&&j-1>=0&&S[i+1][j-1]=='#') count++;
        if(i-1>=0&&j+1>=0&&S[i-1][j+1]=='#') count++;
        if(i-1>=0&&j-1>=0&&S[i-1][j-1]=='#') count++;
        Pri[i][j] = count+'0';
      } else {
        Pri[i][j]='#';
      }
    }
  }
  for(int i=0;i<H;i++) {
    cout << Pri[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define INF 1000000000

int main(){
  int N,M,X;
  cin >> N>> M>>X;
  
  int C[13] = {0};
  int A[13][13] = {0};
  for(int i=1; i<=N;i++){
    cin >> C[i];
    for(int j=1; j<=M; j++){
     cin >> A[i][j] ;
    }
  }
  int min = INF;
  for(unsigned p=0; p<(1<<N); p++){
     int sum = 0;
     int score[13] = {0};
     for(int i=1; i<=N; i++){
       if((p<<1)&(1<<i)){
         sum += C[i];
         for(int j=1; j<=M; j++){
           score[j] += A[i][j]; 
         }
       }
     }
    
     int count = 0;
     for(int j=1; j<=M; j++){
       if(score[j]>=X)
         count++;
     }
     if(count == M){
      min = (sum>min?min:sum); 
     }
  }
  
  if(min == INF){
   cout << -1 << endl; 
  }else{
   cout << min << endl; 
  }
  
  return 0;
  
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int m; cin>>m;
    vector<ll> d(m), c(m);
    ll all_sum = 0;
    for(int i=0; i<m; i++){
        cin>>d[i]>>c[i];
        all_sum += d[i] * c[i];
    }

    ll length = accumulate(c.begin(), c.end(), 0LL);

    ll ans = (all_sum - 1) / 9 + length - 1;

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {
  string S;
  
  cin >> S;
  
  if ((S[0] == S[1] && S[2] == S[3] && S[0] != S[2])
  ||  (S[0] == S[2] && S[1] == S[3] && S[0] != S[1])
  ||  (S[0] == S[3] && S[1] == S[2] && S[0] != S[1])) {
    cout << "Yes" << endl;
    
    return 0;
  }
  
  cout << "No" << endl;
  
  return 0;
}


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

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

  int tmp = 1;
  for (int i=0; i<N; i++) {
    if (tmp*2 <= tmp+K) {
      tmp *= 2;
    }
    else {
      tmp += K;
    }
  }
  
  cout << tmp << endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
int main(){
    int N, M, a, p=1000000007;
    std::cin >> N >> M;
    int k[++N]={},s[N]={1};
    while(M--)std::cin>>a,k[a] = 1;
    s[1] = !k[1];
    for(a=2; a<N; a++)
        if(!k[a])s[a] = (s[a-1] + s[a-2])%p;
    std::cout << s[N-1] << '\n';
}

Measured memory_bytes: 1024
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int c, d;	string s;
	int ans[1001][2];
	for (int i = 0; i < 1001; i++) {
		ans[i][0] = ans[i][1] = 0;
	}
	while (getline(cin, s), s != "") {
		rep(i, s.size()) {
			if (s[i] == ',') { s[i] = ' '; }
		}
		stringstream ss(s);
		ss >> c >> d;
		ans[c][0]++;

	}
	while (getline(cin, s), s != "") {
		rep(i, s.size()) {
			if (s[i] == ',') { s[i] = ' '; }
		}
		stringstream ss(s);
		ss >> c >> d;
		ans[c][1]++;
	}
	for (int i = 1; i <= 1000; i++) {
		if (ans[i][0] > 0 && ans[i][1] > 0) {
			cout << i << " " << ans[i][0]+ans[i][1] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


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


Measured memory_bytes: 256
(_, _, x, y), xs, ys = gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i), gets.chomp.split.map(&:to_i)
zf, zt = x, y # zf < z <= zt
if zf >= zt
    puts 'War'
else
    xs.each {|xx| zf = xx if zf < xx  }
    ys.each {|yy| zt = yy if zt >= yy }
    puts zf < zt ? 'No War' : 'War'
end

Measured memory_bytes: 1788
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

template<int size>
struct sieve {
  sieve(): factor(), primes() {
    factor[0] = factor[1] = 1;
    for (int p = 2; p < size; ++p) {
      if (factor[p]) { continue; }
      primes.push_back(p);
      for (long long n = p*(long long)p; n < size; n += p) {
        factor[n] = p;
      }
    }
  }
  long long int limit() const {
    const auto p = static_cast<long long int>(primes.back());
    return p * p;
  }
  int divisor(int n) const {
    assert(1 < n && n <= limit());
    if (n < size) { return factor[n]? factor[n]:n; }
    for (auto &&p : primes) {
      if (n % p == 0) { return p; }
    }
    return n;
  }
  bool is_prime(int n) const {
    assert(1 < n && n <= limit());
    return divisor(n) == n;
  }
  std::vector<int> prime_factors(int n) const {
    assert(0 < n && n <= limit());
    std::vector<int> ans;
    while (n > 1) {
      const auto p = divisor(n);
      ans.push_back(p);
      while (n % p == 0) { n /= p; }
    }
    return ans;
  }
  int factor[size];
  std::vector<int> primes;
};

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  sieve<20'000> sv;
  int N; cin >> N;
  int cnt = 0;
  REP(i, N) {
    int X; cin >> X;
    if (sv.is_prime(X)) { ++cnt; }
  }
  cout << cnt << endl;
  return 0;
}



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

#define pb push_back
#define ff first
#define ss second

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

int n, k;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k;
	cout << (n + k - 1) / k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
map<string,int> mp;
int a,b;
string s,st,u;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
		cout<<'x';
	return 0;
 } 

Measured memory_bytes: 256
open System
open System.Collections.Generic
open System.Linq
open System

let Puts = Console.WriteLine : 'a -> unit
let Reads () = Console.ReadLine().Split()
let ReadDouble () = Reads() |> (fun x -> x.[0], x.[1])
let ReadTriple () = Reads() |> (fun x -> x.[0], x.[1], x.[2])
let ReadQuadruple () = Reads() |> (fun x -> x.[0], x.[1], x.[2], x.[3])

let FuncDouble f1 f2 (t1, t2) = (f1 t1, f2 t2)
let FuncTriple f1 f2 f3 (t1, t2, t3) = (f1 t1, f2 t2, f3 t3)
let FuncQuadruple f1 f2 f3 f4 (t1, t2, t3, t4) = (f1 t1, f2 t2, f3 t3, f4 t4)

let ensmallen l = l % 1000000007L

// main code


let (n, m) = ReadDouble() |> FuncDouble int int


let bigger = seq { for _ in 1..n -> Console.ReadLine() } |> List.ofSeq
let smaller = [1..m] |> Seq.map (fun _ -> Console.ReadLine()) |> List.ofSeq

let isSameImage(i, j) =
    let bImage = bigger.[i..i+m-1] |> Seq.collect (fun s -> s.[j..j+m-1]) |> Array.ofSeq |> String
    let sImage = smaller |> Seq.concat |> Array.ofSeq |> String
    bImage = sImage

let b = seq { for i in 0..n-m do for j in 0..n-m -> i, j } |> Seq.exists isSameImage
if b then Puts "Yes" else Puts "No"


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

int main()
{
    int h, w;

    while (true)
    {
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for (int i = 1; i <= h; i++)
        {
            for (int j = 1; j <= w; j++)
            {
                if (i == 1 or i == h)
                {
                    cout << "#";
                }
                else if (j == 1 or j == w)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

signed main(){
	int N, K, i, j;
	scanf("%lld%lld", &N, &K);
	int *a = (int *)malloc(sizeof(int) * (N + 1));
	for(i = 1; i <= N; i++){
		scanf("%lld", &a[i]);
	}
	int **dp = (int **)malloc(sizeof(int *) * (N + 1));
	int **s = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		dp[i] = (int *)malloc(sizeof(int) * (K + 1));
		s[i] = (int *)malloc(sizeof(int) * (K + 1));
		for(j = 0; j <= K; j++){
			dp[i][j] = 0;
			s[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(j = 0; j <= K; j++){
		s[0][j] = 1;
	}
	for(i = 1; i <= N; i++){
		for(j = 0; j <= K; j++){
			if(j <= a[i]){
				dp[i][j] = s[i - 1][j];
			}
			else{
				dp[i][j] = MOD(s[i - 1][j] - s[i - 1][j - a[i] - 1]);
			}
		}
		s[i][0] = dp[i][0];
		for(j = 1; j <= K; j++){
			s[i][j] = MOD(s[i][j - 1] + dp[i][j]);
		}
	}
	printf("%lld\n", dp[N][K]);
	return 0;
}

Measured memory_bytes: 158592
#!/usr/bin/env python3
import sys

H, W = map(int, input().split())
A = []
for i in range(H):
    temp = list(input())
    A.append(temp)

def is_sharp(i, j):
    # print(i,j)
    if i<0 or j<0 or i>=H or j>=W:
        return False
    if A[i][j] == "#":
        return True
    else:
        return False

def ok(i,j):
    if is_sharp(i-1, j) and is_sharp(i,j-1):
        return False
    if is_sharp(i+1, j) and is_sharp(i,j+1):
        return False
    return True

for i in range(H):
    for j in range(W):
        if is_sharp(i,j) and (not ok(i,j)):
            print("Impossible")
            sys.exit(0)
print("Possible")


Measured memory_bytes: 38512
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


S = si()

if '7' in S:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 10284
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <vector>

using namespace std;
typedef long long ll;

ll ans, mx, mn, flag, sum, cnt;

int main(){
	string s,t;
	cin>>s>>t;
	for(ll i=0; i<100; i++){
		if(s==t){
			cout<<"Yes";
			return 0;
		}
		string temp="";
		temp=s[s.size()-1];
		//cout<<temp<<endl;
		s.erase(s.size()-1,s.size());
		s =temp+s;
		//cout<<s<<endl;
	}
	cout<<"No";
}


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

int main()
{
    long n, d, x, a[101], sum = 0;
    cin >> n >> d >> x;
    for (int i = 0 ; i < n ; i++)
        cin >> a[i];
    for (int i = 0 ; i < n ; i++){
        int y = 0;
        while (y*a[i]+1 <= d){
            sum += 1;
            y++;
        }
    }
    cout << sum + x;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
map<ll,ll> ma;
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  int n;  cin >> n;
  vector<ll> v(n);
  rep(i,0,n){
    cin >> v[i];
  }
  vector<ll> l(n+1), r(n+1);
  rep(i,0,n){
    l[i+1] = gcd(l[i], v[i]);
    r[i+1] = gcd(r[i], v[n-i-1]);
  }
  reverse(all(r));
  ll gc=0;
  rep(i,0,n){
    chmax(gc, gcd(l[i], r[i+1]));
  }
  cout << gc << endl;
  return 0;
}


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

int main()
{
	int n,maxn=0,ans=0;cin>>n;
	char a;
	while (n--)
	{
		cin>>a;
		if(a=='I') ans++;
		else ans--;
		maxn=max(maxn,ans);
	}
	cout<<maxn<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, d = na()
id = d * 2 + 1
print(n // id if n % id == 0 else n // id + 1)


Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
	int n,m,a,i,sum=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		sum+=a;
	}
	if((n-sum)>=0){
		printf("%d\n",n-sum);
	}else{
		printf("-1\n");
	}
	
	return 0;
}

Measured memory_bytes: 1732