akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  string S; cin >> S;
  vector<bool> v1(10);
  vector<vector<bool>> v2(10, vector<bool>(10));
  vector<vector<vector<bool>>>
    v3(10, vector<vector<bool>>(10, vector<bool>(10)));
  for (int i = 0; i < N; i++) {
    int k = S.at(i) - '0';
    for (int p = 0; p < 10; p++) {
      if (v1.at(p)) {
	for (int q = 0; q < 10; q++) {
	  if (v2.at(p).at(q)) v3.at(p).at(q).at(k) = true;
	}
	v2.at(p).at(k) = true;
      }
    }
    v1.at(k) = true;
  }

  int cnt = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
	if (v3.at(i).at(j).at(k)) cnt ++;
      }
    }
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 384
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
        SAME AS EDITORIAL
       
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
void solve()
{
  int h,a;cin>>h>>a;
  int ans=h/a;
  if(h%a)ans++;
  cout<<ans<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 #include<vector>
 #include<algorithm>
 using namespace std;
 typedef long long ll;
 int main()
 {
 int a, b, x, y;
 scanf("%d%d%d%d", &a, &b, &x, &y);
 printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
 }

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
long long x[200005];
int loc[200005];
long long l[200005],r[200005];
int stk[200005],top;
long long ans;
int main()
{
    top = 0;
    ans = 0;
    int n;
    scanf("%d",&n);
    x[0] = 0;
    loc[0] = 0;
    for(int i=1; i<=n; i++)
    {
        cin>>x[i];
        loc[x[i]]=i;
    }
    ++top;
    stk[top] = 0;
    for(int i=1; i<=n; i++)
    {
        while(x[i] < stk[top])
        {
            top--;
        }
        l[i] = loc[stk[top]] + 1;
        ++top;
        stk[top] = x[i];
    }
    top = 1;
    stk[top] = 0;
    loc[0] = n+1;
    for(int i=n; i>=1; i--)
    {
        while(x[i] < stk[top])
        {
            top--;
        }
        r[i] = loc[stk[top]] - 1;
        ++top;
        stk[top] = x[i];
    }
    for(long long i=1;i<=n;i++)
    {
        ans += (i - l[i] + 1) * (r[i] - i + 1) * x[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<int> c(3, -1);
    ll ans = 1;
    for(int i = 0; i < n; i++){
        int cnt = 0;
        bool f = false;
        for(int j = 0; j < 3; j++){
            if(a[i] - 1 == c[j]){
                if(!f){
                    f = true;
                    c[j]++;
                }
                cnt++;
            }
        }
        ans *= cnt;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

import javax.net.ssl.SSLContext;

public class Main {
	
	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = 1000000007;
	final int INF = Integer.MAX_VALUE / 2;
	
	/* solve */
	void solve(){
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		if(2 * K - 1 <= N){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws IOException {
		new Main().m();
	}
	
	void m() throws IOException {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll INF = 1000000009;
ll MOD = 1000000007;



void solve(){

    ll a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;

}

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


Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O25")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/multiprecision/cpp_dec_float.hpp>
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
10 5
4 7 10 6 5
)X";
stringstream iss{text};
#endif 

void procedures( ) {
	ll X, N; iss >> X >> N;
	set<ll> s;
	rep(i, 120) {
		s.insert(-10 + i);
	}
	rep(i, N) {
		ll dame; iss >> dame;
		s.erase(dame);
	}
	ll minABS{100000};
	ll mine{12345};
	//for (auto &e : s) {
	//	if (abs(X - e) < minABS) {
	//		minABS = abs(X - e);
	//		mine = e;
	//	}
	//}
	auto e = rbegin(s);
	while (e != rend(s)) {
		//p(*e);
		if (abs(X - *e) <= minABS) {
			minABS = abs(X - *e);
			mine = *e;
		}
		++e;
	}
	p(mine);
}
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	procedures( );
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb emplace_back
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define deb(x) cout << #x << " - " << x << endl;

using namespace std;

vector<int> initializeDiffArray(vector<int>& A) 
{ 
    int n = A.size(); 
  
    // We use one extra space because 
    // update(l, r, x) updates D[r+1] 
    vector<int> D(n + 1); 
  
    D[0] = A[0], D[n] = 0; 
    for (int i = 1; i < n; i++) 
        D[i] = A[i] - A[i - 1]; 
    return D; 
} 
  
// Does range update 
void update(vector<int>& D, int l, int r, int x) 
{ 
    D[l] += x; 
    D[r + 1] -= x; 
} 
  
// Prints updated Array 
int printArray(vector<int>& A, vector<int>& D,int m) 
{ 
    int cnt=0;
    for (int i = 0; i < A.size(); i++) { 
        if (i == 0) 
            A[i] = D[i]; 
  
        // Note that A[0] or D[0] decides 
        // values of rest of the elements. 
        else
            A[i] = D[i] + A[i - 1]; 
  
        if(A[i]==m) cnt++;
    } 
    return cnt;
} 
  
// Driver Code 
int main() 
{ 
    // Array to be updated 
    int n,m; cin>>n>>m;
    vector<pair<int,int> >v(m);
    vector<int>a(n+1,0);
    // Create and fill difference Array 
    vector<int> D = initializeDiffArray(a); 
  
  
    for(int i=0;i<m;i++){
        cin>>v[i].first>>v[i].second;
    }
    
    for(int i=0;i<m;i++){
        update(D,v[i].first-1,v[i].second-1,1);
    }
    
    int ans=printArray(a,D,m);
    cout<<ans;
  
    return 0; 
} 

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

using namespace std;

#define llong long long
#define sz(v) ((int)v.size())
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )

llong n, a, b, c, d;

int main() {
  cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> a >> b >> c >> d;
  n -= 1;

  rep(plus, n + 1) {
    llong minus = n - plus;
    llong maxr = a + plus * d - minus * c;
    llong minr = a + plus * c - minus * d;
    if (maxr >= b and b >= minr) {
      cout << "YES";
      clog << plus << ' ' << minus << ' ' << maxr << ' ' << minr << endl;
      return 0;
    }
  }

  cout << "NO";

  return 0;
}



Measured memory_bytes: 256
S=input()
S=S[::-1]
cnt=["dream","dreamer","erase","eraser"]

for i in range(4):
  s=cnt[i]
  s=s[::-1]
  cnt[i]=s

while len(S):
  if S[:5]==cnt[0]:
    S=S[5:]
  elif S[:7]==cnt[1]:
    S=S[7:]
  elif S[:5]==cnt[2]:
    S=S[5:]
  elif S[:6]==cnt[3]:
    S=S[6:]
  else:
    break

if len(S):
  print("NO")
else:
  print("YES")


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

int main()
{
    long long r, D, prev;
    cin >> r >> D >> prev;
    for (int i = 0; i < 10; ++i)
    {
        long long cur = prev * r - D;
        cout << cur << endl;
        prev = cur;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n,p;
  cin>>n>>p;
  int a[n];
  int even = 0, odd = 0;
  rep(i,n) {
    cin>>a[i];
    if(a[i] % 2 == 0) even++;
    else odd++;
  }
  ll y;
  if(odd == 0) y = 1;
  else y = (ll)pow(2, odd) / 2;
  ll ans = (ll)pow(2,even) * y;
  if(p == 1 && odd == 0) ans = 0;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds ;
#define ll long long
#define ld long double
#define pp pair<ll,pair<ll,ll> >
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define sz(a) int((a).size())
#define hell 1000000007
#define f first
#define s second
#define sll(x) scanf("%lld",&x)
#define si(x) scanf("%d",&x)
typedef tree<ll , null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update > ordered_set ;
ll t = 1 ;
void solve()
{
    ll a , b , k ;
    cin >> k >> a >> b ;
    if( a >= b )
    {
        cout << k + 1 ;
    }
    else
    {
        if( k < a + 1 )
        {
            cout << k + 1 ;
        }
        else
        {
            ll left = k - (a+1) , ans = b ;
            ans += ((b-a)*(left/2)) + (left%2) ;
            ans = max( ans , 1 + k ) ;
            cout << ans ;
        }
    }
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin>>t;
    while(t--)
        solve();
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll X,Y,Z;
    cin>>X>>Y>>Z;
    cout<<Z<<" "<<X<<" "<<Y<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(){
  int n;
  int i,j;
  int u,k,v,g[N][N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      g[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      g[u-1][v-1]=1;
    }
  }

  for(i=0;i<n;i++){
    printf("%d",g[i][0]);
    for(j=1;j<n;j++){
      printf(" %d",g[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 636
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int n;
	cin >> n;
	string a;
	cin >> a;
	if (n % 2 == 1) {
		cout << "No";
	}
	else {
		string f = "", s = "";
		for (int i = 0; i < n / 2; i ++) f += a[i];
		for (int i = n / 2; i < n; i ++) s += a[i];
		if (f == s) {
			cout << "Yes";
		}	
		else cout << "No";
	}
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int n;
    cin >> n;
    int min = 2e9, bf, ans = 0;
    rep(i, n) {
        cin >> bf;
        if(bf < min) {
            ans++;
            min = bf;
        }
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define P pair<int,int>

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int,null_type,less<int>,rb_tree_tag,
		tree_order_statistics_node_update> indexed_set;

#define P pair<int,int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define str std::string 
#define pb push_back 
#define ll long long 
#define inint(s) int s; std::cin>>s; 
#define inll(s) ll s; std::cin>>s; 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> 
#define show_pq(x) for(int i = 0; i < n; i++){cout<<yes.top(); yes.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<nl;} 
#define vec(x) std::vector<x> 
#define nl '\n' 

void solve(){
   
   ll a,b;
   cin>>a>>b;
   cout<<a*b;
}


int main(int argc, char* argv[]) {
	IOS;
    


    int n=1;
   // cin>>n;

    while (n--)
    {
        solve();
    }


	
}

Measured memory_bytes: 3640
N,M = map(int,input().split())
#N = count(S),M = count(c)
Max_count=0
if M>=2*N:
  Max_count+=N
  M-=2*N
  if M>0:
    Max_count+=M//4
elif M>N:
  Max_count+=(M-N)
else:
  Max_count+=M//2
print(Max_count)

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

D = [0]*(10**6+1)
for i in A:
    # ダブってる値は2以上に
    D[i] += 1

U = []
for i in range(10**6+1):
    # ダブってる値は2以上に
    if D[i] == 1:
        U.append(i)

A = list(set(A))

T = [0]*(10**6+1)
for i in A:
    # iの2以上の倍数の値は1に
    for j in range(2*i, 10**6+1, i):
        T[j] = 1

# Tが0かつDが1の数を数える
ans = 0
for i in U:
    if T[i] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 45992
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#define  go return 0
#define pb push_back
#include<utility>
#include <algorithm>
#include<iterator>
#define lp(i, n)  for(int i=0; i<(int)(n); ++i)
#define all(v)   ((v).begin()), ((v).end())
#define sz(v)    ( (int)((v).size()) )
typedef long long ll;
typedef double db;
typedef vector<int> vi;
const int N=1e5+5;
int arr[N];
int main()
{

   int count=0,n,a=0;
   scanf("%d",&n);
   lp(i,n)
   scanf("%d",arr+i);

   lp(i,n)
   {
       if(arr[i]>=a){
        count++;
       a=arr[i];
       }
   }
   printf("%d",count);

go;
}


Measured memory_bytes: 256
"""
    This template is made by Satwik_Tiwari.
    python programmers can use this template :)) .
"""

#===============================================================================================
#importing some useful libraries.
from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
#If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
#If the element is already present in the list,
# the right most position where element has to be inserted is returned

#===============================================================================================
#some shortcuts

mod = 1000000007
def inp(): return sys.stdin.readline().strip() #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)


#===============================================================================================
# code here ;))

def solve():
    n = int(inp())
    a = lis()
    ans = 1
    if(a.count(0)>0):
        print(0)
    else:
        ans = 1
        f = False
        for i in range(0,n):
            ans*=a[i]
            if(ans > (10**18)):
                f = True
                break
        if(f):
            print(-1)
        else:
            print(ans)

testcase(1)


Measured memory_bytes: 86812
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,ida=0,idb=1;
    cin>>n>>a>>b;
    string s;
    cin>>s;
    s=" "+s;
    vector<int> v;
    for(int i=1;i<=n;i++){
    	if(s[i]=='c'){
    		v.pb(0);
    	}else if(s[i]=='a'){
    		if(ida<a+b){v.pb(1);ida++;}
    		else v.pb(0);
    	}else{
    		if(ida<a+b&&idb<=b){v.pb(1);ida++;idb++;}
    		else v.pb(0);
    	}
    }
    for(auto& i:v){
    	cout << (i?"Yes":"No") <<endl;
    }
    return 0;
}


Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 1 ; i <=(n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
double pi=3.141592;
int main() {
  double a,b,x;
  cin>>a>>b>>x;
  
  x/=a;
  cout<<fixed<<setprecision(6);
  if(2*x<a*b){//三角形  ,tanθ=b/(2x/b)
    
    cout<< 180/pi*atan(b*b/(2*x))<<endl;
  }
  else{//上の部分面積　ab-x ,,a,2(ab-x)/a tans=2()/a*a
    cout<<180/pi*atan(2*(a*b-x)/(a*a))<<endl;
  }
  
}

Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, T, AB):
    dpL = [[0] * (T + 1) for _ in range(N + 2)]
    for i in range(1, N + 1):
        a, b = AB[i - 1]
        for t in range(T):
            dpL[i][t] = dpL[i - 1][t]
            if t >= a:
                dpL[i][t] = max(dpL[i][t], dpL[i - 1][t - a] + b)

    dpR = [[0] * (T + 1) for _ in range(N + 2)]
    for i in range(N, 0, -1):
        a, b = AB[i - 1]
        for t in range(T):
            dpR[i][t] = dpR[i + 1][t]
            if t >= a:
                dpR[i][t] = max(dpR[i][t], dpR[i + 1][t - a] + b)

    ans = 0
    for i in range(1, N + 1):
        a, b = AB[i - 1]
        for t in range(T):
            ans = max(ans, dpL[i - 1][t] + dpR[i + 1][T - 1 - t] + b)
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, T = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]
    main(N, T, AB)


Measured memory_bytes: 216304
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  int N,M;cin>>N>>M;
  vint As(N+1,0);
  repeat(i,N){
    int A;cin>>A;
    As[i+1]=As[i]+A;
    As[i+1]%=M;
  }
  sort(As.begin(),As.end());
  ll ans=0;
  repeat(i,N+1){
    int j=i;
    while(j<N+1&&As[j]==As[i]){
      j++;
    }
    ans += (j-i)*(j-i-1)/2;
    i=j-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class AOddsOfOddness {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            out.println(Util.formatDouble((double) ((n + 1) / 2) / n));
        }

    }

    static class Util {
        public static String formatDouble(double x) {
            return String.format("%.15f", x);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21584
///
// File:  2006.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 06:23:37 2017
//

#include <cstdint>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

static vector<string> arr({"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"});

int32_t main()
{
  uint32_t N;
  cin >> N;

  for (uint32_t i = 0; i < N; i++) {
    string str;
    cin >> str;
    uint32_t pre = 0;
    int32_t num = -1;
    for (uint32_t j = 0; j < str.size(); j++) {
      int32_t but = str[j] - '0';
      if (but == 0) {
        if (pre != 0) {
          cout << arr[pre][num];
        }
        pre = 0;
        num = -1;
      } else {
        pre = but;
        num++;
        num = num % arr[but].size();
      }
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<vector>
#include<set>
#include<map>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
string s;
int main()
{
    cin>>s;
    ll res=0;
    for(auto t:s) res+=t-'0';
    if(res%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(){
    int num[101]={};
    int i,nmax=0;
    while(cin>>i){
        num[i]++;
        nmax=max(nmax, num[i]);
    }
    for(int i=1; i<=100; i++){
        if(num[i]==nmax) cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
<?php
fscanf(STDIN, '%d', $n);
$s = [];
for ($i = 0;$i<$n;$i++) {
    fscanf(STDIN, '%s', $input);

    if (isset($s[$input])) {
        $s[$input]++;
    } else {
        $s[$input] = 1;
    }
}


arsort($s);
//var_dump($s);

$cnt = 0;
foreach ($s as $name => $num) {
    $cnt = $num;
    break;
}

$res = [];
foreach ($s as $name => $num) {
    if ($cnt === $num) {
        $res[] = $name;
    }
}

sort($res);
foreach ($res as $hoge){
    echo $hoge.PHP_EOL;
}




Measured memory_bytes: 29176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF=1e18;

int main(){
  ll a,b,c;
  while(cin>>a>>b>>c,a){
  ll sum=INF;
  ll x,y;
  x=y=INF;
  for(int i=0;i*a<=c;i++){
    ll tmp=c-a*i;
    if(tmp%b)continue;
    ll tx=i,ty=tmp/b;
    if(tx+ty<x+y||(tx+ty==x+y&&tx*a+ty*b<sum)){
      x=tx;
      y=ty;
      sum=tx*a+ty*b;
    }
  }
  {
    ll used[11111]={};
    ll k=0;
    ll i=0;
  
    while(1){
      if(used[k])break;
      if((k+c)%b==0){
	ll tx=i;
	ll ty=((i*a)+c)/b;
	if(tx+ty<x+y||(tx+ty==x+y&&tx*a+ty*b<sum)){
	  x=tx;
	  y=ty;
	  sum=tx*a+ty*b;
	}
      }
      used[k]=1;
      k+=a;
      k%=b;
      i++;
    }
  }
  {
    ll used[11111]={};
    ll k=0;
    ll i=0;
  
    while(1){
      if(used[k])break;
      if((k+c)%a==0){
	ll tx=((i*b)+c)/a;
	ll ty=i;
	if(tx+ty<x+y||(tx+ty==x+y&&tx*a+ty*b<sum)){
	  x=tx;
	  y=ty;
	  sum=tx*a+ty*b;
	}
      }
      used[k]=1;
      k+=b;
      k%=a;
      i++;
    }
  }
  cout<<x<<" "<<y<<endl;
}
  return 0;
}



Measured memory_bytes: 3180
#input
n = int(input())
w = list(map(int,input().split())) #input from array of integer like "1 2 3"

ans = []
sumw = sum(w)
s1 = 0
for i in w:
  s1 += i
  s2 = sumw - s1
  if (s1 - s2) < 0:
    ans.append(s2-s1)
  else:
    ans.append(s1-s2)

print(min(ans))


Measured memory_bytes: 2940
from itertools import combinations

n = int(input())
c = [0, 0, 0, 0, 0]

indices = [0, 1, 2, 3, 4]
letters = ["M", "A", "R", "C", "H"]
mapping = dict(zip(letters, indices))

for i in range(n):
    s = input()
    if s[0] in mapping:
        c[mapping[s[0]]] += 1

cnt = 0
for combo in combinations(c, 3):
    cnt += combo[0]*combo[1]*combo[2]

print(cnt)

Measured memory_bytes: 9112
#include<stdio.h>
int main(void){
        int i,j=0,tmp;
        char str[32];
        scanf("%s",str);
        for(i=1;i<4;i++){
                if(str[0]==str[i]){
                        j++;
                        tmp=str[1];
                        str[1]=str[i];
                        str[i]=tmp;
                }
}
        if(j==1){
                if(str[2]==str[3]){
                        printf("Yes");
                }
                else{
                        printf("No");

                }
        }
        else{
                  printf("No");
        }
        return 0;
}



Measured memory_bytes: 128
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
// #define MOD (998244353)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    double n, m, d; cin >> n >> m >> d;
    // int cnt = 0;
    if(d!=0) printf("%.10lf\n", (double)(n-d)*(m-1)*2/(n*n));
    else printf("%.10lf\n", (double)(n-d)*(m-1)/(n*n));
    return 0;}

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

int main(){
   int n;cin>>n;
   long int a[n+1];
   //vector<long int> m(1000000001,0);
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   sort(a,a+n);
   int ans=0;
   int i=0;
   int now=0;
   while(now<n){
       int cnt=0;
       i=now;
       while(a[i]==a[now])now++,cnt++;
       ans+=cnt%2;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.next();
            if(s.equals("0")) break;
            int ret = 0;
            for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
            System.out.println(ret);
        }
    }
}


Measured memory_bytes: 26396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;string s;cin>>n>>s;
	int ans = 0;
	rep(i, s.size()-2){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    string s;
    cin >> s;
    ll n = s.length();
    auto m = n /2;
    ll count = 0;
    for (ll i = 0 ; i < m; ++i) {
        if (s[i] != s[n-i-1]) {
            ++count;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;



int main(){
  int N,K;
  cin>>N>>K;
  if(N%K==0) cout<<0<<endl;
  else cout<<1<<endl;
}


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

int main()
{
    int ans,x;
    char op;

    cin>>ans;

    while(1){
        cin>>op;
        if(op=='=')break;
        cin>>x;

        if(op=='+'){
            ans+=x;
        }else if(op=='-'){
            ans-=x;
        }else if(op=='*'){
            ans*=x;
        }else if(op=='/'){
            ans/=x;
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

#ifdef SG
	#include <debug.h>
#else
	template<typename T> struct outputer;
	struct outputable {};
	#define PRINT(...)
	#define OUTPUT(...)
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
	#define fbegin(...)
	#define fend
	#define pbegin(...)
	#define pend
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb emplace_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef int64_t ll;
typedef uint64_t ull;
typedef uint32_t ui;
typedef uint16_t us;
typedef uint8_t uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const int N = 100;
const int C = 26;

struct Input {
	string s;
	
	bool read () {
		return !!getline(cin, s) && sz(s);
	}

	void init (const Input &input) {
		*this = input;
	}
};

struct Data: Input {
	int ans;
	
	void write () {
		cout << ans << endl;
	}
};


namespace Main {
	
	struct Solution: Data {
		vi v[C];
		
		void solve () {
			forn (i, C) {
				v[i].pb(-1);
			}
			forn (i, sz(s)) {
				v[s[i] - 'a'].pb(i);
			}
			forn (i, C) {
				v[i].pb(sz(s));
			}
			ans = sz(s);
			forn (i, C) {
				int mx = 0;
				forn (j, sz(v[i]) - 1) {
					umx(mx, v[i][j + 1] - v[i][j] - 1);
				}
				umn(ans, mx);
			}
		}
		
		void clear () {
			*this = Solution();
		}
	};
}


Main::Solution sol;

int main () {
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);

	#ifdef SG
		freopen((problemname + ".in").c_str(), "r", stdin);
//		freopen((problemname + ".out").c_str(), "w", stdout);
		while (sol.read()) {
			sol.solve();
			sol.write();
			sol.clear();
		}
	#else
		sol.read();
		sol.solve();
		sol.write();
	#endif
	
	/*
	int t;
	cin >> t;
	forn (i, t) {
		sol.read();
		sol.solve();
		sol.write();
		sol.clear();
	}
	*/
	
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[11];
int main()
{
 gets(s);
 if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
  printf("Yes\n");
 else 
  printf("No\n");
 return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        int n = in.nextInt(), k = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] >= k) ++cnt;
        }

        System.out.println(cnt);
    }
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

bool
softCatCheck(string s) {
  const int n = s.size();
  if (s[0] != 'm') return false;
  if (s[n-1] != 'w') return false;
  if (n % 3) return false;

  int k[3] = {0};
  for (int i = 0; i < n; ++i) {
    char c = s[i];
    if (c == 'm') ++k[0];
    if (c == 'e') ++k[1];
    if (c == 'w') ++k[2];
  }
  return (k[0] == k[1] && k[1] == k[2]);
}

bool
isCat(string s) {
  if (s == "") return true;
  if (s == "mew") return true;
  if (!softCatCheck(s)) return false;

  const int n = s.size();

  vector<int> indis;
  for (int i = 1; i < n - 1; ++i) {
    if (s[i] == 'e' && ((i - 1) % 3 == 0)) {
      indis.push_back(i);
    }
  }

  if (indis.size() == 0) return false;

  for (int idx : indis) {
    string t1 = s.substr(1, idx - 1);
    string t2 = s.substr(idx + 1, n - idx - 2);
    if (isCat(t1) && isCat(t2)) return true;
  }

  return false;
}

string n(string s) {
  return isCat(s) ? "Cat" : "Rabbit";
}

int main() {
  string s; cin >> s;
  cout << n(s) << endl;
  return 0;
}

Measured memory_bytes: 1360
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X, K, D):
    X = abs(X)
    n = X // D
    if n > K:
        return  abs(X-D*K)

    return abs(X-(n + (K-n) % 2) * D)


def main():
    X, K, D = read_int_n()
    print(slv(X, K, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76936
#include<stdio.h>
int main(void){
int kane,mai,dai,kaz,i;
for(;;){
kaz=0;
scanf("%d",&dai);
if(dai==0)break;
kane=1000-dai;
if(kane>=500){
    mai=kane/500;
    kane=kane%500;
    kaz+=mai;
}if(kane>=100){
    mai=kane/100;
    kane=kane%100;
    kaz+=mai;
}if(kane>=50){
    mai=kane/50;
    kane=kane%50;
    kaz+=mai;
}if(kane>=10){
    mai=kane/10;
    kane=kane%10;
    kaz+=mai;
}if(kane>=5){
    mai=kane/5;
    kane=kane%5;
    kaz+=mai;
}
kaz=kaz+kane;
printf("%d\n",kaz);
}
return 0;
}

Measured memory_bytes: 600
data = list(map(int, input().split()))
# data = list(map(int, "41 2".split()))

N = data[0] # days of summer vacation
M = data[1] # summer assignments

A = 0 # days to do the i-th assignment.

assignments = list(map(int, input().split()))
# assignments = list(map(int, "5 6".split()))

if sum(assignments) <= N :
    print(N-sum(assignments))
else :
    print(-1)


Measured memory_bytes: 9880
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

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

		// 入力値の取得
		int N = sc.nextInt();
		int M = sc.nextInt();
		
		// ACとWAの集計
		Set<Integer> ACset = new HashSet<>();
		Map<Integer, Integer> WAmap = new HashMap<>();
		for (int i = 0; i < M; i++) {
			int pi = sc.nextInt();
			String Si = sc.next();
			if (Si.equals("AC")) {
				ACset.add(pi);
			}
			else if (!ACset.contains(pi)){
				if (WAmap.containsKey(pi)) {
					int count = WAmap.get(pi) + 1;
					WAmap.put(pi, count);
				}
				else {
					WAmap.put(pi, 1);
				}
			}
		}
		
		// WAmapのうちACが一度でも出たものだけ集計
		int WAcount = 0;
		for (int key : WAmap.keySet()) {
			if (ACset.contains(key)) {
				WAcount += WAmap.get(key);
			}
		}
		// 結果の出力
		System.out.println(ACset.size() + " " + WAcount);

		sc.close();
	}
}


Measured memory_bytes: 68660
import sys
import math
# from itertools import permutations
input = sys.stdin.readline
p=1000000007
N,M=map(int,input().split())
fib=[1,1]
for i in range(N):
	fib.append(fib[-1]+fib[-2])

cur=0
ans=1
flag=False
for i in range(M):
	x=int(input())
	if x==cur:
		flag=True
		print(0)
		break
	ans*=fib[x-cur-1]
	ans%=p
	cur=x+1
ans*=fib[N-cur]
ans%=p
if not flag:
	print(ans%p)

Measured memory_bytes: 460148
#include <cstdio>
#include <algorithm>

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

using namespace std;

const int inf = 1000000;

int n, m;
int s[20][100001];
int r[1 << 20];
int dp[1 << 20];

int main(){
  scanf("%d%d", &n, &m);
  rep(j, n){
    int x;
    scanf("%d", &x);
    s[x - 1][j + 1] = 1;
  }
  rep(i, m){
    rep(j, n){
      s[i][j + 1] += s[i][j];
    }
  }
  rep(i, 1 << m){
    rep(j, m){
      if(!(i >> j & 1)){
        r[i] += s[j][n];
      }
    }
  }
  fill_n(dp, 1 << m, inf);
  dp[(1 << m) - 1] = 0;
  for(int i = (1 << m) - 1; i >= 0; --i){
    rep(j, m){
      if(i >> j & 1){
        dp[i - (1 << j)] = min(dp[i] + s[j][n] - (s[j][r[i - (1 << j)]] - s[j][r[i]]), dp[i - (1 << j)]);
      }
    }
  }
  printf("%d\n", dp[0]);
  return 0;
}

Measured memory_bytes: 18620
#include <bits/stdc++.h>
#define err(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

using namespace std;

typedef long long ll;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	
	int ans = (int)1e9 + 7;
	for (int i = 0; i + k <= n; i++) ans = min(ans, a[i + k - 1] - a[i]);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
value = input();

j = 0
s = 0
n = len(value)
stack1 = list()
stack2 = []#[[[] for i in range(2)] for j in range(n)]
while(j < n):
    if value[j] == '\\':
        stack1.append(j)
    if value[j] == '/' :
        if len(stack1) != 0:
            idx1 = stack1[-1]
            idx2 = j
            stack2.append([idx1,idx2 - idx1])
            stack1.pop(-1)
            s += 1
    if s - 2 >= 0:
        if stack2[s-1][0] < stack2[s-2][0]:
            stack2[s-2][0] = stack2[s-1][0]
            stack2[s-2][1] += stack2[s-1][1]
            s -= 1
            stack2.pop(-1)
        
    j += 1

if s - 2 >= 0:
    for i in reversed(range(2, s+1)):
        if stack2[i-1][0] < stack2[i-2][0]:
            stack2[i-2][0] = stack2[i-1][0]
            stack2[i-2][1] += stack2[i-1][1]
            #s -= 1
            stack2.pop(i-1)


sumi = 0
s = len(stack2)
for i in range(0, s):
    sumi += stack2[i][1]
    
print(sumi)
if sumi == 0:
    print(s)
else:
    print(s, end = " ")

for i in range(0, s):
    if i != s - 1:
        print(stack2[i][1], end=" ")
    else:
        print(stack2[i][1])



Measured memory_bytes: 6400