akhauriyash/Code-Regression huggingface dataset:
import sys

n = int(input())

if n == 1:
    print(0)
    sys.exit()

import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(n))
v = list(c.values())

count= 0
for e in v:
    for i in range(1,40):

        e -= i
        if e >= 0:
            count += 1
        else:
            break

print(count)

Measured memory_bytes: 9460
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

int main(){
    int a,b;
    cin >> a >> b;
    if(a > 12)cout << b << endl;
    else if(a > 5)cout << b / 2 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        char c = s.charAt(s.length() - 1);
        if (c == '3') {
            System.out.println("bon");
        } else if (c == '0' || c == '1' || c == '6' || c == '8') {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }
}

Measured memory_bytes: 35432
#include<bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define fLoop for(lli i = 0; i < N; i++)
lli DFS(vector<lli> adj[], lli index, bool *visited, lli *DP) {
	if(visited[index]) {
		return DP[index];
	}
	visited[index] = true;
	lli output = 0;
	for(lli i = 0; i < adj[index].size(); i++) {
		output = max(output, 1 + DFS(adj, adj[index][i], visited, DP));
	}
	DP[index] = output;
	return output;
}
main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    lli N, M;
    cin >> N >> M;
    vector<lli > adj[N + 1];
    for(lli i = 0; i < M; i++) {
    	lli X, Y;
    	cin >> X >> Y;
    	adj[X].push_back(Y);
	}
	bool *visited = new bool[N + 1];
	lli *DP = new lli[N + 1];
	for(lli i = 0; i <= N; i++) {
		visited[i] = false;
		DP[i] = 0;
	}
	lli output = 0;
	for(lli i = 1; i <= N; i++) {
		if(!visited[i]) {
			output = max(output, DFS(adj, i, visited, DP));
		}
	}
	cout << output << '\n';
  	delete[] visited;
  	delete[] DP;
}



Measured memory_bytes: 13052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
	int r; cin >> r; string ans;
	if(r < 1200) ans = "ABC";
	else if(r < 2800) ans = "ARC";
	else ans = "AGC";
	cout << ans << endl;
}


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

using namespace std;

int n, L;
int a[100010];
int memo[100010];

int f(int x) {
  if (x == 0 || x == n + 1 || memo[x]) return memo[x];
  int res = L - a[x];
  if (a[x - 1] > a[x] && a[x] > a[x + 1]) {
    res += f(x - 1);
  } else if (a[x - 1] < a[x] && a[x] < a[x + 1]) {
    res += f(x + 1);
  } else if (a[x - 1] > a[x] && a[x] < a[x + 1]) {
    res += max(f(x - 1), f(x + 1));
  }
  return memo[x] = res;
}

int main(void) {
  cin >> n >> L;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    memo[i] = f(i);
    ans = max(ans, memo[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define puts(s) cout<<(s)<<endl
#define inf (1000000007)
#define nil -1
class disjoint_set {
public:
	vi p, rank;
	disjoint_set(int size) {
		p.resize(size, 0);
		rank.resize(size, 0);
		for (int i = 0; i < size; i++)makeSet(i);
	}
	void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}
	void unite(int x, int y) {
		link(findSet(x), findSet(y));
	}
	void link(int x, int y) {
		if (rank[x] < rank[y]) {
			p[x] = y;
		}
		else {
			p[y] = x;
			if (rank[x] == rank[y]) {
				rank[x]++;
			}
		}
	}
	int findSet(int x) {
		if (x != p[x]) {
			p[x] = findSet(p[x]);
		}
		return p[x];
	}
};




int main() {
	int a;
	string s;
	cin >> a >> s;
	puts(a < 3200 ? "red" : s);
}


Measured memory_bytes: 256
num = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(num[k - 1])

Measured memory_bytes: 38384
#include <iostream>

int main()
{
	int S;
	std::cin >> S;

	int h, m, s;
	h = S / 3600;
	S -= h * 3600;
	m = S / 60;
	S -= m * 60;
	s = S;
	std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 3080
s = str(input())
m = s[::-1]
n = len(s)
c=0
for i in range(int((n-1)/2)):
    if (s[i]!=m[i]):
        print("No")
        c=1
        break

if c==0:
    a = s[:int((n-1)/2)]
    b = s[int((n+1)/2):]
    x = a[::-1]
    y = b[::-1]
    # print(a)
    # print(b)

    l = (n+1)/4
        # print(l)

    for i in range(int(l)):
        if (a[i]!=x[i])or (b[i]!=y[i]):
            print("No")
            c =1
            break
    if(c==0): 
        print("Yes")

Measured memory_bytes: 3064
x = int(input())

product = list(range(100,105+1))

dp = [0] * 10**6

dp[0] = 1
for i in product:
    dp[i] = 1

for i in range(0,10**5+1):
    for j in product:
        if dp[i] == 1:
            dp[i+j] = 1

print(dp[x])

Measured memory_bytes: 48492
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=100010;

void solve(){
    ll n;
    cin>>n;
    if(n%2==1){
        cout<<"0\n";
        return ;
    }
    ll tw=0,fiv=0;
    ll tPower=2,fPower=10;
    while(tPower<=n){
        tw+=n/tPower;
        tPower*=2LL;
    }
    while(fPower<=n){
        fiv+=n/fPower;
        fPower*=5LL;
    }
    ll ans=min(tw,fiv);
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
n,m=map(int,input().split())
c=[]
cnt=0
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(1,len(a)):
        c.append(a[j])
    
for j in range(1,m+1):
    if c.count(j)==n:
        cnt += 1
print(cnt)


Measured memory_bytes: 9184
sa = input()
sb = input()
sc = input()
s = []
s.append(sa.replace('a', '0').replace('b', '1').replace('c', '2'))
s.append(sb.replace('a', '0').replace('b', '1').replace('c', '2'))
s.append(sc.replace('a', '0').replace('b', '1').replace('c', '2'))
i = 0
while s[i]!='':
    j = int(s[i][0])
    s[i] = s[i][1:]
    i = j
ans = 'ABC'

print(ans[i])

Measured memory_bytes: 9012
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

lo n,m,b,a[li],k;
string s;
double cev;
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		//~ if(i>=k) break;
		lo at=i,yes=k-1;
		//~ if(i==k) yes=0;
		//~ elsee 
		yes/=at;
		double tut=1;
		while(yes){
			//~ cout<<1.0/2.0;
			tut=tut*(1.0/2.0);
			yes/=2;
		}
		tut=tut*(1.0/n);
		//~ cout<<tut<<endl;
		cev+=tut;
	}
	printf("%.12lf\n",cev);
	return 0;
}


Measured memory_bytes: 256
n,W = map(int,input().split())
dp = [[0 for i in range(W+1)] for j in range(n+1)]
for i in range(1,n+1):
    w,v = map(int,input().split())
    for j in range(1,W+1):
        dp[i][j] = dp[i-1][j]
        if j - w >= 0:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j - w] + v) 
print(dp[n][W])

Measured memory_bytes: 218736
#include<iostream>  
#include<cstdio>  
#include<cstring> 
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<cmath>
//#define inf  0x3f3f3f3f3f3f3f3f
#define bit(x) (1<<(x)) 
using namespace std;
const int maxn = int(1e5)+100;
const int mod = 998244353;
const int inf = 2 * int(1e9) + 100;
const double pi = acos(-1);
typedef long long LL;
int n;
int l, r, mid;
string L, R, M;
string query(int i) {
	cout << i << endl;
	string k;
	cin >> k;
	return k;
}
int main() {
	cin >> n;
	l = 0, r = n - 1;
	L = query(l);
	if (L == "Vacant") return 0;
	R = query(r);
	if (R == "Vacant") return 0;
	while (M != "Vacant") {
		mid = (r + l) / 2;
		M = query(mid);
		if (((mid - l) % 2 == 0 && M == L) || ((mid - l) % 2 == 1 && M != L)) l = mid, L = M;
		else r = mid, R = M;
	}
	return 0;
}

Measured memory_bytes: 852
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 300031;

int n;
long long C;
vector<pair<long long, long long> > order;
long long ans;

long long x[N],S[N],win[N];
long long v[N];
long long sv[N];

void solve(vector<pair<long long, long long> > V){
	for (int i=1;i<=n;i++){
		x[i]=V[i-1].first;
		v[i]=V[i-1].second;
	}

	for (int i=n;i>=1;--i){
		S[i]=S[i+1]+v[i];
		win[i]=S[i]-(C-x[i])*2;
	}
	for (int i=n;i>=1;--i){
		win[i]=max(win[i],win[i+1]);
	}

	/*for (int i=1;i<=n;i++){
		cout<<win[i]<<endl;
	}*/
	ans=max(ans,win[1]);

	for (int i=1;i<=n;i++){
		sv[i]=sv[i-1]+v[i];
	}
	for (int i=1;i<=n;i++){
		ans=max(ans,win[i+1]+sv[i]-x[i]);
	}
}
int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n>>C;
	for (int i=1;i<=n;i++){
		long long a,b;
		cin>>a>>b;
		order.push_back(make_pair(a,b));
	}

	solve(order);
	for (int i=0;i<order.size();i++){
		order[i].first=C-order[i].first;
	}
	sort(order.begin(),order.end());

	solve(order);

	cout<<ans<<endl;


//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 12528
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val s = new Array[String](n)
    val t = new Array[Int](n)
    for (i <- 0 until n) {
      s(i) = sc.next
      t(i) = sc.nextInt
    }
    val x = sc.next

    var sum = 0
    var flg = false
    for(i <- 0 until n) {
      if(flg){
        sum += t(i)
      }else if(x == s(i)){
        flg = true
      }
    }

    println(sum)
  }
}


Measured memory_bytes: 25684
n=int(input())
a=list(map(int,input().split()))
print(*a)
for i in range(1,n):
    num=a[i]
    j=i-1
    while j>=0 and a[j]>num:
        a[j+1]=a[j]
        j-=1
    a[j+1]=num
    print(*a)


Measured memory_bytes: 5984
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a  = sc.nextInt();
        int b = sc.nextInt();

        int res = 0;
        int num = 1;
        while(num < b) {
            res++;
            num += a - 1;
        }
        System.out.println(res);

    }


}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
    int ans=0,b=0;
    string a;
    cin >> a;
    for(int i=0;i<3;i++){
        if(a[i] == '1'){
            ans++;
        }
    }
    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 __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

// /mnt/c/Users/vince/Desktop/POST-IOI/  

int n;
int A[1000003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	string s; cin >> s;
	if(s.back() == 's') s += "es";
	else s += "s";
	cout << s << "\n";
}

Measured memory_bytes: 3624
from collections import deque


h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]
directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
nokoshi = 1
que = deque([(0, 0)])
done = [[False] * w for _ in range(h)]

white_num = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == ".":
            white_num += 1

while que:
    for i in range(len(que)):
        y, x = que.popleft()

        if y == h - 1 and x == w - 1:
            print(white_num - nokoshi)
            exit()

        if y < 0 or y >= h or x < 0 or x >= w or field[y][x] == "#" or done[y][x] is True:
            continue
        done[y][x] = True

        for dy, dx in directions:
            que.append((y+dy, x+dx))

    nokoshi += 1
print(-1)








Measured memory_bytes: 3444
h,w = map(int,input().split())
a = [ input() for i in range(h)]

b = []
for i in range(h):
  if a[i].count('.') != w:
    b.append(a[i])
  else:
    h -= 1

c = [''] * h
for i in range(w):
  x = [row[i] for row in b] 
  if x.count('.') != h:
    for j in range(h):
      c[j] = c[j] + x[j]
    
for i in c:
  print(i)
  

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

typedef long long ll;
#define M 1000000007

ll pow(ll m, ll n){
	  if(n==0) return 1;
	  if(n%2 == 0)
			return pow( m*m%M, n/2)%M;
	  else
			return (pow( m*m%M, (n-1)/2)%M * m)%M;
}

int main (){

	  ll m,n;
	  cin >> m >> n;
	  cout << pow(m,n) << endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

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

void solve();

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

    solve();
}
void solve() {
    ll n;
    std::cin >> n;

    vll a(n);
    for (ll i = 0; i < n; i++)
        std::cin >> a[i];

    vll box(n + 1, 0);
    for (ll i = n; i >= 1; i--) {
        ll sum = 0;
        for (ll j = 1; i * j <= n; j++)
            sum += box[i * j];
        if ((sum ^ a[i - 1]) & 1)
            box[i]++;
    }

    ll m = 0;
    for (ll i = 1; i <= n; i++)
        m += box[i] > 0;

    std::cout << m << '\n';

    ll cnt = 0;
    for (ll i = 1; i <= n; i++) if (box[i] > 0)
        std::cout << i << (++cnt < m ? ' ' : '\n');
}


Measured memory_bytes: 6312
#include<stdio.h>
#define NUM 13
   
int main(){
 int num[NUM*4-1],ncmp,n,i,j;
 char pcmp;
 for(i=0; i<NUM; i++){
  num[NUM*0+i] = i+1;
  num[NUM*1+i] = i+1;
  num[NUM*2+i] = i+1;
  num[NUM*3+i] = i+1;
 }
 scanf("%d", &n);
 for(i=0; i<n; i++){
  scanf(" %c",&pcmp);
  scanf("%d", &ncmp);
  for(j=0; j<NUM; j++){
   switch(pcmp){
    case 'S': if(ncmp==num[NUM*0+j]){num[NUM*0+j] = -1;} break;     
    case 'H': if(ncmp==num[NUM*1+j]){num[NUM*1+j] = -1;} break;
    case 'C': if(ncmp==num[NUM*2+j]){num[NUM*2+j] = -1;} break;
    case 'D': if(ncmp==num[NUM*3+j]){num[NUM*3+j] = -1;} break;
   }
  }
 }
 for(i=0; i<NUM*4; i++){
  if(num[i]!=-1){
   if(i<NUM){printf("S %d\n", num[i]);}
   else if(NUM*1<=i&&i<NUM*2){printf("H %d\n", num[i]);}
   else if(NUM*2<=i&&i<NUM*3){printf("C %d\n", num[i]);}
   else if(NUM*3<=i&&i<NUM*4){printf("D %d\n", num[i]);}
  }
 }
 return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main(){
	stack<int> s;
	int n;
	while (cin >> n){
		if (n != 0) {
			s.push(n);
		}
		else {
			cout << s.top() << endl;
			s.pop();
		}
	}
	return 0;
}


Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
int main(){
  double x,h,area=0;
  while(1){
    cin >> x >> h;
    if( x == 0 && h == 0) break;
    area+=(x*x);
    double y=sqrt((x/2)*(x/2)+h*h);
    area+=x*y*2;
    printf("%lf\n",area);
    area=0;
  }
  return 0;
}

Measured memory_bytes: 3124
void main()
{
    long n = rdElem;

    long[][] tree = new long[][](n);
    foreach (i; 0 .. n-1)
    {
        long a, b;
        rdVals(a, b);
        --a, --b;
        tree[a] ~= b, tree[b] ~= a;
    }

    long[] c = rdRow;
    c.sort!"a > b";

    long[] edge = new long[n];
    edge[] = -1;
    long[] que;
    que ~= 0;
    long idx;
    while (!que.empty)
    {
        long f = que[0];
        que.popFront;
        edge[f] = c[idx++];
        foreach (t; tree[f])
        {
            if (edge[t] != -1) continue;
            que ~= t;
        }
    }

    c[1..$].sum.writeln;
    foreach (i, e; edge)
    {
        e.write;
        if (i == n - 1) writeln;
        else " ".write;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 3836
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 2e5 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;
 

int a1, a2, a3;


main () {
	cin >> a1 >> a2 >> a3;
	if (a1 + a2 + a3 >= 22)
		cout << "bust";
	else
		cout << "win";	
} 

Measured memory_bytes: 256
// Cursor jump numbers
// main @ 39
// global @ 35
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define ll long long int
#define MOD ((int)(1e9) + 7)

int sieve[1000000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x;
  cin >> x;
  if(x == 2) {
    cout << 2 << '\n';
    return 0;
  }
  for(int i=1; (2*i+1) * (2*i+1) <= 100005; i++) {
    int k = 2*i + 1;
    if(sieve[k] == 1) continue;
    for(int j=2; k*j <= 100005; j++) {
      sieve[k*j] = 1;
    }
  }
  int k=x;
  while((k&1) == 0 || sieve[k] !=0)
    k++;
  cout << k << '\n';
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

    int main(){
      ll n;
      cin >> n;
      int count=0;
      REP(x,1,3501){
       REP(y,1,3501){
         ll p=n*x*y;
         ll q=4*x*y-n*(x+y);
        if(q>0 && p%q==0){ 
         cout << x << ' ' << y << ' ' << p/q << endl;
          count++;
          break;
        }
       }
        if(count==1)break;
      }
      return 0;}

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

int main(){
    int n, a[101];
    cin >> n;

    for (int i = 0; i < n; ++i) cin >> a[i];

    int max = a[1], min = a[1];

    for (int i = 0; i < n; ++i) max = (a[i] >= max)?a[i]:max;
    for (int i = 0; i < n; ++i) min = (min <= a[i])?min:a[i];

    cout << max - min << endl;
   
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
int a[205],fst[205],match[205],p[1000000],tot=0;
bool u[10000005],vis[205];
struct Edge{int to,nxt;}e[10005];
void addedge(int x,int y){
	e[++tot].to=y;e[tot].nxt=fst[x];fst[x]=tot;
}
void init(int n){
	for (int i=2;i<=n;i++){
		if (!u[i]) p[++p[0]]=i;
		for (int j=1;j<=p[0] && i*p[j]<=n;j++){
			u[i*p[j]]=1;
			if (i%p[j]==0) break;
		}
	}
	u[0]=u[1]=u[2]=1;
}
bool dfs(int x){
	if (vis[x]) return 0;
	vis[x]=1;
	for (int i=fst[x];i;i=e[i].nxt){
		int y=e[i].to;
		if (!match[y] || dfs(match[y])){
			match[y]=x;
			return 1;
		}
	}
	return 0;
}
int main(){
	int n,m=0;
	scanf("%d\n",&n);
	for (int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		if (a[m]==x) m--;else a[++m]=x;
		a[++m]=x+1;
	}
	init(a[m]-a[1]);
	for (int i=1;i<=m;i++)
	if (a[i]&1)
		for (int j=1;j<=m;j++)
		if (!u[abs(a[i]-a[j])]) addedge(i,j);
	int ans=0,cnt=0;
	for (int i=1;i<=m;i++)
	if (a[i]&1){
		memset(vis,0,sizeof vis);
		if (dfs(i)) ans++;else cnt++;
	}
	printf("%d\n",m-ans+(cnt&1));
}

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

ll n,k;
vector<vector<ll>> v(111111);
ll mod=1e9+7;

ll cnt[111111];
bool used[111111];

void dfs(int p,int d){
    used[p]=true;
    int c;
    if(d==0){
        c=1;
    }
    else c=2;
    for(auto i:v[p]){
        if(!used[i]){
            cnt[i]=c;
            c++;
            dfs(i,d+i);
        }
    }
}


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

    
    cin>>n>>k;
    for(int i=0;i<n-1;i++){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll ans=1;
    dfs(0,0);
    for(int i=0;i<n;i++){
        ans*=(k-cnt[i])%mod;
        ans%=mod;
    }
    cout<<ans<<endl;

    
}

Measured memory_bytes: 10368
import math
def prime(n): #n以下の素数の入ったリストを返す
    lst = [2]
    for i in range(3, n+1):
        flag = True
        for j in lst:
            if j > math.sqrt(i):
                break
                
            if i % j == 0:
                flag = False
                break
        if flag:
            lst.append(i)
    return lst
N = int(input())
primes = prime(55555)
ans = []
cnt = 0
for p in primes:
    if p % 5 == 1:
        ans.append(p)
        cnt += 1
        if cnt == N:
            break
print(*ans)
    

Measured memory_bytes: 3188
class BinaryIndexedTree:
    def __init__(self, size):
        self.data = [0] * (size+1)
        self.size = size+1
        self.msb = 1 << (size.bit_length()-1)
    
    def _add(self, i, w):
        i += 1
        while i < self.size:
            self.data[i] += w
            i += i & -i
    
    def _get_sum(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    def __getitem__(self, i):
        """
        [0,i)
        """
        if isinstance(i, slice):
            if i.start is None:
                return self._get_sum(i.stop)
            else:
                return self._get_sum(i.stop) - self._get_sum(i.start)
        else:
            return 0 # fake value
    
    __setitem__ = _add
    
    def bisect_left(self, v):
        """
        return smallest i s.t v <= sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] < v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    def bisect_right(self, v):
        """
        return smallest i s.t v < sum[:i]
        """
        i = 0
        k = self.msb
        while k > 0:
            i += k
            if i < len(self.data) and self.data[i] <= v:
                v -= self.data[i]
            else:
                i -= k
            k >>= 1
        return i
    
    bisect = bisect_right



def solve(C, queries):
    N = len(C)
    Q = len(queries)
    bit = BinaryIndexedTree(N)

    last_ind = [None]*(N + 1)
    queries = sorted(((r,l-1,i) for i,(l,r) in enumerate(queries)), key=lambda x:x[0])

    res = [None]*Q
    pr = 0
    for r,l,i in queries:
        for j in range(pr,r):
            c = C[j]
            if last_ind[c] is not None:
                bit._add(last_ind[c], -1)
            last_ind[c] = j
            bit._add(j, 1)
        res[i] = bit._get_sum(r)-bit._get_sum(l)
        pr = r

    return res

# from random import randrange, seed
# from time import perf_counter

# def test():
#     seed(1234)
#     N = 5*10**5
#     C = [randrange(N) for _ in range(N)]
#     queries = [tuple(sorted((randrange(1,N+1),randrange(1,N+1)))) for _ in range(N)]
#     solve(C,queries)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

if __name__ == '__main__':
    N,Q = map(int,readline().split())
    C = list(map(int,readline().split()))

    m = map(int,read().split())
    queries = list(zip(m,m))

    print(*solve(C,queries), sep='\n')
    # test()

Measured memory_bytes: 264788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if (b < a) {
		cout << 0 << endl;
		return 0;
	}
	if (a == b) {
		cout << 1 << endl;
		return 0;
	}
	if (n == 1) {
		cout << 0 << endl;
	}
	else if (n == 2) {
		cout << 1 << endl;
	}
	else if (n == 3) {
		cout << 2 << endl;
	}
	else {
		int w = n - 2;
		ll suma = a * (ll)w, sumb = b * (ll)w;
		ll ans = sumb - suma + 1;
		cout << ans << endl;
	}
	return 0;
}


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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  
  int min = 0, max = 0, tmp;
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    if (tmp < x) {
      min++;
    } else {
      max++;
    }
  }
  
  if (min < max) {
    cout << min << endl;
  } else {
    cout << max << endl;
  }
    
  
  return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

int main(){
	int N, K; cin >> N >> K;
	vector<int> p(N);

	double ans = 0.0;
	for(int i = 0; i < N; ++i) cin >> p[i];

	vector<double> a(N), cul(N+1);
	for(int i = 0; i < N; ++i){
		a[i] = (p[i]*(p[i]+1)/2) / (double)p[i];
	}

	cul[0] = 0;
	for(int i = 1; i < N+1; ++i){
		cul[i] = cul[i-1] + a[i-1];
	}

	for(int i = K; i < N+1; ++i){
		if(ans < cul[i]-cul[i-K]) ans = cul[i]-cul[i-K];
	}

	cout << fixed << setprecision(10) << ans << endl;

	return 0;
}


Measured memory_bytes: 4096
import java.util.Scanner;
import java.util.Arrays;

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

    int []i = new int[3];

    i[0] = sc.nextInt();

    i[1] = sc.nextInt();

    i[2] = sc.nextInt();

    Arrays.sort(i);

    System.out.println( i[0] + " " + i[1] + " " + i[2] );


    } 
}


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

int a[15][15];
int dx[] = { 0,0,1,-1 }, dy[] = { 1,-1,0,0 };
int nx[] = { 0,0,2,-2 }, ny[] = { 2,-2,0,0 };
int main() {
	string S;
	while (cin >> S) {
		int x, y, s;
		sscanf(S.data(), "%d,%d,%d", &x, &y, &s);
		if (s == 1) {
			a[x][y]++;
			rep(i, 4) {
				if (x + dx[i] >= 0 && y + dy[i] >= 0)
					a[x + dx[i]][y + dy[i]]++;
			}
		}
		else for (int i = -1; i <= 1; i++)for (int j = -1; j <= 1; j++) {
			if (x + i >= 0 && x + j >= 0)a[x + i][y + j]++;
		}
		if (s == 3)rep(i, 4) {
			if (x + nx[i] >= 0 && y + ny[i] >= 0)
				a[x + nx[i]][y + ny[i]]++;
		}
	}
	int cnt = 0, Max = 0;
	rep(i, 10) {
		rep(j, 10) {
			if (!a[i][j])cnt++;
			Max = max(Max, a[i][j]);
		}
	}
	cout << cnt << endl << Max << endl;
	return 0;
}

Measured memory_bytes: 3128
import sys
S=int(input())
A=[0,0,0,1,1]
if S<=4:
    print(A[S])
    sys.exit()


else:
    k=10**9+7
    for i in range(S-4):
        A.append(sum(A[1:-1])%k)
        A=A[1:]
        
print(A[-1])

Measured memory_bytes: 9196
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

import collections
import itertools
import operator


class UnionFind:
    def __init__(self, x):
        class KeyDict(dict):
            def __missing__(self, key):
                self[key] = key
                return key

        self.parent = KeyDict()
        self.rank = collections.defaultdict(int)
        self.size = collections.defaultdict(lambda: 1)
        if x is not None:
            for elem in range(x+1):
                _, _, _ = self.parent[elem], self.rank[elem],self.size[elem]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.are_same(x,y):
            xx = self.size[x]
            yy = self.size[y]
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += xx
            else:
                self.parent[y] = x
                self.size[x] += yy
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def Size(self,x):
        return self.size[self.find(x)]

    def are_same(self, x, y):
        '''print(x,y,self.find(x),self.find(y),self.find(x) == self.find(y))'''
        return self.find(x) == self.find(y)

    def grouper(self):
        roots = [(x, self.find(x_par)) for x, x_par in self.parent.items()]
        root = operator.itemgetter(1)
        for _, group in itertools.groupby(sorted(roots, key=root), root):
            yield [x for x, _ in group]

n,g = m()

u = UnionFind(n-1)
co = 0
for i in range(g):
	z,x,v = m()
	u.unite(z-1,x-1)

k = list(u.grouper())

print(len(k))



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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
// #include <bits/stdc++.h>

struct KMP {
    const std::string& pattern;
    std::vector<int> table;

    explicit KMP(const std::string& p): pattern(p), table(p.size() + 1) {
        table[0] = -1;
        table[1] = 0;

        int i = 2;
        int j = 0;
        while (i < pattern.size()) {
            if (pattern[i - 1] == pattern[j]) {
                table[i] = j + 1;
                i += 1;
                j += 1;
            } else if (j > 0) {
                j = table[j];
            } else {
                table[i] = 0;
                i += 1;
            }
        }
        if (pattern.size() > 1) {
            table[pattern.size()] = j + 1;
        }
    }

    std::vector<int> search(const std::string& text) {
        std::vector<int> matches;
        int m = 0;
        int i = 0;
        while (m + i < text.size()) {
            if (i < pattern.size() && pattern[i] == text[m + i]) {
                i += 1;
            } else {
                if (i == pattern.size()) {
                    matches.push_back(m);
                }
                m = m + i - table[i];
                if (i > 0) {
                    i = table[i];
                }
            }
        }
        return matches;
    }
};


using namespace std;
typedef long long li;

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

    string s;
    cin >> s;

    int n = s.size();
    for (int l = 1; l < n; ++l) {
        if (n % l != 0) {
            continue;
        }
        bool ok = true;
        for (int i = 0; i < n; i += l) {
            for (int j = 0; j < l; ++j) {
                if (s[i + j] != s[j]) {
                    ok = false;
                }
            }
        }
        if (ok) {
            if (l == 1) {
                cout << n << endl << 1 << endl;
                return 0;
            } else {
                KMP kmp(s);
                reverse(s.begin(), s.end());
                KMP kmp_rev(s);
                li ans = 0;
                for (int l = 1; l < n; ++l) {
                    li rev_l = n - l;
                    bool ng = kmp.table[l] > 0 && kmp.table[l] % (l - kmp.table[l]) == 0;
                    bool rev_ng = kmp_rev.table[rev_l] > 0 && kmp_rev.table[rev_l] % (rev_l - kmp_rev.table[rev_l]) == 0;
                    if (ng || rev_ng) {
                        continue;
                    } else {
                        ans += 1;
                    }
                }
                cout << 2 << endl << ans << endl;
                return 0;
            }
        }
    }

    cout << 1 << endl << 1 << endl;
    return 0;
}


Measured memory_bytes: 4764
n, m = list(map(int, input().split()))

ans = 0
if n == 1 and m == 1:
    ans = 1
elif n == 1:
    ans = m - 2
elif m == 1:
    ans = n - 2
else:
    ans = (m - 2) * (n - 2)
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
string s;
std::cin >>x>>s>>y;
if(s=="+")std::cout << x+y << '\n';
else std::cout << x-y << '\n';
}



Measured memory_bytes: 256
n = int(input())
prod = 1
maxx = 10**18
found = 2
arr = list(map(int,input().split()))
if(0 in arr):
    found = 1
if(found==2):
    for i in arr:
        if(prod*i>maxx):
            found = 0
            break
        else:
            prod*=i
if(found==2):
    print(prod)
elif(found==1):
    print(0)
else:
    print(-1)

    
    

Measured memory_bytes: 21712
n=gets.to_i
if n<3 then
    puts "POSSIBLE"
    exit(0)
end
p=gets.split(" ").map{|i|i.to_i-1}
p.unshift 0
x=gets.split(" ").map(&:to_i)
edge=Array.new(n){[]}
isLeaf=Array.new(n,true)
sum=Array.new(n,0)
n.times{|i|
    isLeaf[p[i]]=false
    if p[i]!=i then
        edge[p[i]].<<i
    end
}
[*0...n].reverse_each{|i|
    if isLeaf[i] then
        sum[i]=x[i]
        next
    end
    edge[i].each{|from|
        sum[i]+=sum[from]
    }
    dp=Array.new(x[i]+1,false)
    dp2=Array.new(x[i]+1,false)
    dp[0]=true
    edge[i].each{|from|
        a=x[from]
        b=sum[from]-x[from]
        [*0..x[i]].reverse_each{|j|
            if !dp[j] then
                next
            end
            if j+a<=x[i] then
                dp2[j+a]=true
            end
            if j+b<=x[i] then
                dp2[j+b]=true
            end
        }
        dp=dp2
        dp2=Array.new(x[i]+1,false)
    }
    black=-1
    [*0..x[i]].reverse_each{|j|
        if dp[j] then
            black=j
            break
        end
    }
    if black==-1 then
        puts "IMPOSSIBLE"
        exit(0)
    end
    sum[i]=sum[i]-black+x[i]
}
puts "POSSIBLE"

Measured memory_bytes: 36960
#include <stdio.h>
// There is a right triangle ABC with ∠ABC = 90°. Given the lengths of the three sides, |AB|,|BC| and |CA|, find the area of the right triangle ABC. It is guaranteed that the area of the triangle ABC is an integer.
// 1 ≤ |AB|,|BC|,|CA| ≤ 100
// The area of the triangle ABC is an integer.

int main() {
    int leg1;
    int leg2;
    int hypotenuse;

    scanf("%d %d %d", &leg1, &leg2, &hypotenuse);
    printf("%d\n", leg1 * leg2 / 2);

    return 0;
}

Measured memory_bytes: 1712
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine();

            var sum = 0;
            foreach (var item in ss)
            {
                if (item == '1')
                    sum++;
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main()
{
	const int month[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1)
	{
		int a,b,count=0;
		cin >> a >> b;
		if(a==0&&b==0)break;
		for(int i=0;i<(a-1);i++)
		{
			count += month[i];
		}
		count += b;
		count %= 7;
		switch(count)
		{
			case 1:cout << "Thursday" << endl;break;
			case 2:cout << "Friday" << endl;break;
			case 3:cout << "Saturday" << endl;break;
			case 4:cout << "Sunday" << endl;break;
			case 5:cout << "Monday" << endl;break;
			case 6:cout << "Tuesday" << endl;break;
			case 0:cout << "Wednesday" << endl;break;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int child;
    cin>>N;
    vector<int>sub(N,0);
    for(int i=1;i<N;i++)
    {
        cin>>child;
        sub.at(child-1)++;
        
    }
    for(auto a : sub)
    {
        cout<<a<<endl;
    }
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	string s; cin >> s;
	int n=s.size();
	string k = s;
	REV(k);
	string a,b;
	rep(i,n/2){
		a+=s[i];
		b+=s[i];
	}
	REV(b);
	string c,d;
	rep2(i,n/2+1,n){
		c+=s[i];
		d+=s[i];
	}
	REV(d);
	if(s==k&&a==b&&c==d) cout << "Yes" << endl;
	else cout << "No" << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define vi vector<int>
#define deb(n) cout<<"[ "#n<<" = "<<n<<" ]"<<endl;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1e18;
int case_no=1;
#define w(x) int x; cin>>x; while(x--)

bool solve(int n, int m) {
	if(m >= 2*n and m <= 4*n) {
		if(m%2 == 0) return true;
	}
	return false;
}

int main()
{
	FIO
	int x, y;
	cin >> x >> y;
	if(solve(x, y)) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main() {
	int N, X;
	cin >> N >> X;
	vector<int> length(N);
	int LONG = 0;
	int count = 1;

	for (int i = 0; i < N; i++) {
		cin >> length.at(i);
		LONG += length.at(i);

		if (LONG > X)
			break;

		count++;
	}
		
	cout << count << endl;
}

Measured memory_bytes: 256