akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
 
using namespace std;

#define MAX (393+1)

int main(){
 
	int n;
	int s,l,p;
	int m;
	int w;
	int dp[MAX];
	bool f;
	int ans[MAX];

	cin>>n;

	for(int i=0;i<MAX;i++){
		dp[i]=-1;
	}

	dp[0]=0;

	for(int i=0;i<n;i++){
		cin>>s>>l>>p;
		f=true;
		while(f){
			f=false;
			for(int j=s;j<=l;j++){
				for(int k=0;k<MAX-j;k++){
					if(dp[k]>=0){
						if(dp[k+j]<dp[k]+p){
							dp[k+j]=dp[k]+p;
							f=true;
						}
					}
				}
			}
		}
	}

	cin>>m;
	for(int i=0;i<m;i++){
		cin>>w;
		ans[i]=dp[w];
		if(ans[i]==-1){
			cout<<"-1"<<endl;
			return 0;
		}
	}

	for(int i=0;i<m;i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}

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

int main(){
  
  int n,m;
  cin >>n>>m;
  vector<int> x(m);
  for(int i=0; i<m; i++) cin >> x[i];
  sort(x.begin(),x.end());
  
  vector<int> y(m-1);
  for(int i=0; i<m-1; i++){
  	y[i]=x[i+1]-x[i];
  }
 sort(y.begin(),y.end());
  int ans=0;
  if(m-n<=0) cout << 0 << endl;
  else{
  	for(int i=0; i<m-n; i++){
    	ans+=y[i];
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1024
from itertools import permutations

N = int(input())
P = input().split()
Q = input().split()
  
L = list(permutations("".join(list(map(str,list(range(1,N+1))))), N))

idx = 0
for l in L:
  #print(P,Q,l)
  if P == list(l):
    a = idx
  if Q == list(l):
    b = idx
  idx += 1
  
print(abs(b-a))


Measured memory_bytes: 8052
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let line = read_vector::<usize>();
	let (n, k) = (line[0], line[1]);
	let arr = read_chars();
	let mut starts = vec![];
	let mut ends = vec![];
	if arr[0] == '0' {
		starts.push(0);
		ends.push(0);
	}
	for i in 0..n {
		if arr[i] == '1' {
			if i == 0 || arr[i - 1] == '0' {
				starts.push(i);
			}
			if i == n - 1 || arr[i + 1] == '0' {
				ends.push(i);
			}
		}
	}
	if arr[n - 1] == '0' {
		starts.push(n - 1);
		ends.push(n - 1);
	}

	if starts.len() == 0 {
		println!("{}", n);
		return;
	}
	let mut ans = 0;
	for i in 0..starts.len() {
		ans = max(ends[min(i + k, ends.len() - 1)] - starts[i] + 1, ans);
	}
	println!("{}", ans);
}
#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> v(s.size(), 0);
    for (int i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
            v[i + 1] = v[i] + 1;
        else
        {
            v[i + 1] = v[i];
        }
    }
/*
    for (auto e : v)
        cout << e;
    cout << endl;
*/
    int ans = 0;
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        ans = v[r] - v[l];
        if (l == 1){
            cout << ans << endl;
        } else if ( s[r - 1] == 'A' && s[l] == 'C'){
            cout << ans << endl;
        } else {
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  string s; cin>>s;
  string t = s;
  ll K; cin>>K;
  ll cnt = 0, cnt2 = 0;
  ll N = s.size();
  int same = 1;
  rep(i,0,N-1){
    if(s[i] != s[i+1]) same = 0;
  }
  if(same){
    cout << K*N/2 << endl;
    return 0;
  }
  rep(i,0,N){
    ll j = i;
    while(j<N && s[j]==s[i]) j++;
    cnt += (j-i)/2;
    if(i != j) i = j-1;
  }
  cnt *= K;
  if(s[0] != s[N-1]){
  }else{
    ll i = 0, j=N-1;
    while(i<N && s[i]==s[0]) i++;
    while(j>=0 && s[j]==s[N-1]) j--;
    j = N - 1 - j;
    cnt -= (K-1)*(i/2 + j/2 - (i+j)/2);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3636
while true do
  m,f,r = gets.split.map!(& :to_i)
  break if m < 0 && f < 0 && r < 0

  sum = m + f
   
  if (m < 0 || f < 0 || sum < 30) then 
   	puts "F"
   	next

  elsif (sum >= 80) then 
   	puts "A"
   	next

  elsif (sum >= 65 && sum < 80) then
  	puts "B"
  	next

  elsif (sum >= 50 && sum < 65 || r >= 50) then
  	puts "C"
    next

  else
    puts "D"
  end

end

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

#define st first
#define nd second
#define mp make_pair
#define space << " " <<
#define END << endl
#define pb push_back
#define fo(i,n) for(int i = 0; i<n; ++i)
#define ff(i,n) for(int i = 1; i<n; ++i)

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pi;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> pl;
typedef vector<pil>vil;

const int N = 1e5 + 100;
const ll MX = 1e18;

vector<pil> board[N];

bool check[N];
ll far[N];
vector<pli> a;
bool ok[N];

void dijkstra()
{
    priority_queue< pli , vector<pli> , greater <pli> > pr;
    pr.push(mp(0,1));
    while(pr.size())
    {
        pli u = pr.top(); pr.pop();
        if(check[u.nd]) continue;
        far[u.nd] = u.st;
        check[u.nd] = 1;
        fo(i,int(board[u.nd].size()) )
        {
            pil v = board[u.nd][i];
            if(check[v.st]) continue;
            pr.push(mp(u.st + v.nd,v.st));
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,m; ll c; cin >> n >> m >> c;
    ll su = 0;
    fo(i,m) { int u,v; ll l; cin >> u >> v >> l; board[u].pb(mp(v,l)); board[v].pb(mp(u,l)); su += l;}
    dijkstra();
    ff(i,n+1) a.pb(mp(far[i],i)); sort(a.begin(),a.end());
    ll ans = su;
    fo(i,a.size()) {  ok[a[i].nd] = 1; int u = a[i].nd; fo(j,board[u].size()) if(ok[board[u][j].st]) su -= board[u][j].nd; ans = min(ans , su + 1LL * a[i].st * c); }
    cout << ans << endl;
}
/*
5 5 2
2 3 1
3 1 2
2 4 3
1 2 4
2 5 5

5 4 10
1 2 3
2 3 4
3 4 3
4 5 5

6 5 2
1 2 2
1 3 4
1 4 3
1 5 1
1 6 5
*/

Measured memory_bytes: 19596
#include<bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int a[maxn];
int main() {
    int n; cin >> n;
    for(int i = 0;  i < n; i++) cin >> a[i];
    sort(a, a+n);
    int ans = unique(a, a+n) - a;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, M; cin >> N >> M;
	vector<vector<int>> graph(N);

	REP(i,M){
		int A, B; cin >> A >> B;
		A--; B--;
		graph[A].push_back(B);
		graph[B].push_back(A);
	}

	vector<bool> was(N, false);
	vector<int> prev(N, -1);
	queue<int> q;
	was[0] = true;
	prev[0] = 0;
	q.push(0);
	while(!q.empty()){
		int v = q.front();
		q.pop();
	  for(int i:graph[v]){
			if(was[i]) continue;
			else if(!was[i]){
				q.push(i);
				prev[i] = v+1;
				was[i] = true;
			}
		}
	}


	bool flag = true;
	REP(i,N) if(!was[i]) flag = false;

	if(flag){
		cout << "Yes" << endl;
		FOR(i,1,N) cout << prev[i] << endl;

	}else{
		cout << "No" << endl;
	}


	return 0;

}


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

inline void Yes(){
    cout << "Yes" << "\n";
}
inline void No(){
    cout << "No" << "\n";
}
typedef pair<int,int> P;

int main(){
    int a;
    cin >> a;
    set<int>s;
    for (int i = 0; i < a; i++){
        int x;
        cin >> x;
        s.insert(x);
    }
    if (a == s.size()){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }
}

Measured memory_bytes: 9600
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, H: "List[int]"):

    ans = 0
    minh = -INF
    for h in H:
        if h >= minh:
            ans += 1
            minh = h
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#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 int long long
#define pb push_back
#define N 100009
#define inf 1e18
int mod=1e9+7;
//int mod=998244353;
#define P pair<int,int>
#define F first
#define S second
#define ll long long
#define all(v) v.begin(),v.end()

#define ordered_set tree<P, null_type,less<P>, rb_tree_tag,tree_order_statistics_node_update> 
int n,m,x;
int mat[20][20];
int cost[20];
int fun(vector<int>v,int idx){
	int ans=inf;
	for(int i=0;i<(1<<n);i++){
		vector<int>vv(m,0);
		int c=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				c+=cost[j];
				for(int k=0;k<m;k++){
					vv[k]+=mat[j][k];
				}
			}
		}
		bool ok=1;
		for(int j=0;j<m;j++){
			if(vv[j]<x)ok=0;
		}
		if(ok)ans=min(ans,c);
	}
	return ans;
}
void solve(){
	cin>>n>>m;
	cin>>x;
	for(int i=0;i<n;i++){
		cin>>cost[i];
		for(int j=0;j<m;j++)cin>>mat[i][j];
	}
	for(int i=0;i<m;i++){
		int all=0;
		for(int j=0;j<n;j++){
			all+=mat[j][i];
		}
		if(all<x){
			cout<<"-1\n";return ;
		}
	}
	vector<int>v(m,0);
	cout<<fun(v,0)<<"\n";
}

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

Measured memory_bytes: 3656
import os, sys, re, math, queue

N,M = map(int,input().split(' '))
cakes = []
for _ in range(N):
    temp = list(map(int,input().split(' ')))
    cakes.append(temp)

flg = [(1,1,1),(1,1,-1),(1,-1,1),(1,-1,-1),(-1,1,1),(-1,1,-1),(-1,-1,1),(-1,-1,-1)]
ret = 0

for f in flg:
    temp = sorted(list(map(lambda x: f[0]*x[0]+f[1]*x[1]+f[2]*x[2], cakes)),reverse=True)
    ret = max(sum(temp[:M]),ret)

print(ret)


Measured memory_bytes: 41324
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m, a, b, c = 0;
	cin >> n >> m;
	int h[n + 1];
	for (int i = 1; i <= n; ++i) cin >> h[i];
	vector<int> v[n+1];
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i) {
		bool good = true;
		for (unsigned j = 0; j < v[i].size(); ++j) {
			if (h[i] <= h[v[i][j]]) {
				good = false;
				break;
			}
		}
		if (good) {
			c++;
		}
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#define ll long long
#define CASE(k) printf("Case %lld: ",k++)
#define MX 25000000012
using namespace std;
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    if(n>m)
    {
        printf("%lld\n",n-1);
    }
    else
        printf("%lld\n",n);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n,m;
    cin>>n>>m;
    int ans=0;
    pair<int,int> a[n];
    for(int i=0;i<n;i++){
       cin>>a[i].first>>a[i].second; 
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
      if(a[i].second>=m){
          ans+=a[i].first*m;
          break;
      }
      else{
        ans+=a[i].first*a[i].second;
        m-=a[i].second;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N, M; cin >> N >> M;
  cout << N*(N-1)/2+M*(M-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
typedef long long ll;

ll N,P;
ll pw(ll n,int m){
	ll ret=1;
	while(m){
		if (m&1){
			ret*=n;
		}
		n*=n;
		m>>=1;
	}
	return ret;
}
int main(){
	cin>>N>>P;
	ll ans=1;
	for(ll i=2;i*i<=P;i++){
		int cnt=0;
		while(P%i==0){
			P/=i;
			cnt++;
		}
		if (cnt>=N){
			ans*=pw(i,(cnt/N));
		}
	}
	if (P!=1 && N==1){
		ans*=P;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n = 0;
	int x = 1;
	int cnt;

	do {
		cnt = 0;
		if (n >=3) {
			for (int i = 1; i <= n; i++) {
				for (int j = i + 1;j <= n;j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) cnt++;
					}
				}
			}
			printf("%d\n", cnt);
		}
		scanf("%d %d", &n, &x);
	} while (n != 0 || x != 0);
	return 0;
}

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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> rs(n, 0);
  vector<int> as(m);
  for (int &a : as) cin >> a;
  const int MOD = 1000000007;

  for (const int &a : as) {
    rs[a - 1] = -1;
  }

  for (int i = 0; i < n; i++) {
    if (rs[i] == -1) {
      rs[i] = 0;
    } else {
      if (i == 0) {
        rs[0] = 1;
      } else if (i == 1) {
        rs[1] = rs[0] + 1;
      } else {
        rs[i] = rs[i - 1] + rs[i - 2];
        if (rs[i] > MOD) rs[i] -= MOD;
      }
    }
  }

  cout << rs[n - 1] << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector< int > p(n), q(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                q[k] = p[k];
            }
            swap(q[i], q[j]);
            for (int k = 1; k < n - 1; k++) {
                if (!(q[k - 1] < q[k] && q[k] < q[k + 1])) {
                    goto END;
                }
            }
            cout << "YES" << endl;
            return 0;
        END:;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {


int a,b,c;
char op;

 while(op!='?') {
    scanf("%d %c %d\n", &a,&op,&b);
   
   switch (op) 
   {
     case '+':
      c=a+b;
      printf("%d\n",c);
      break;
      
     case '-':
      c=a-b;
      printf("%d\n",c);
      break;
      
     case '*':
      c=a*b;
      printf("%d\n",c);
      break;
      
     case '/':
      c=a/b;
      printf("%d\n",c);
      break;
      
     case '?':
     break;
   }  
  
  }

  return 0;
}


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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<int, int>
#define vi 		vector<int>
#define mii 	map<int, int>
#define umii 	unordered_map<int, int>
#define pb		push_back
#define mk		make_pair
#define all(a)	a.begin(), a.end()
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n, m, x, y;

	cin >> n >> m;

	vi g[n + 1];

	for (int i = 0; i < m; ++i) {
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}

	list<int> q;
	vector<bool> vis(n + 1);
	vector<int> res(n + 1);

	q.pb(1);
	vis[1] = 1;
	res[1] = 1;
	while(!q.empty()) {
		int s = q.front();
		// cout << s << ' ';
		q.pop_front();

		for (int i = 0; i < g[s].size(); ++i) {
			if (vis[g[s][i]] == 0) {
				q.pb(g[s][i]);
				res[g[s][i]] = s;
				vis[g[s][i]] = 1;
			}
		}
	}
	// cout << '\n';

	for (int i = 2; i <= n; ++i) {
		if (res[i] == 0) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes\n";
	for (int i = 2; i <= n; ++i)
		cout << res[i] << '\n';

	return 0;
}

Measured memory_bytes: 12628
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pll = pair<long long,long long>;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
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;
}
//以上テンプレ

int main(){
    ll N;
    cin>>N;
    string S;
    ll count=0;
    ll a=0;
    ll b=0;
    ll ab=0;
    rep(i,N){
        ll n;
        cin>>S;
        n=S.size();
        if(S.at(n-1)=='A'&&S.at(0)=='B'){
            ab++;
        }else if(S.at(n-1)=='A'){
            a++;
        }else if(S.at(0)=='B'){
            b++;
        }
        rep(j,n-1){
            if(S.at(j)=='A'&&S.at(j+1)=='B'){
                count++;
            }
        }
    }
    if(ab==0){
        count+=min(a,b);
    }
    else if(b!=0||a!=0){
        count+=ab+min(a,b);
    }else{
        count+=ab-1;
    }
    cout<<count<<endl;
    }


Measured memory_bytes: 256
X,N = [int(i) for i in input().split()]

if N == 0 :
  print(X)
  exit()
  
p = [int(j) for j in input().split()]
p.sort()

ans = 0
m = 0
while True :
  if not X + m in p:
    if not X - m in p:
      ans = X-m
      break
    else :
      ans = X+m
      break
  if not X - m in p :
    ans = X-m
    break
  m += 1
  
print(ans)

Measured memory_bytes: 9204
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int dx[]={1,0,-1,0,1,-1,-1,1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
int ceil(int a,int b){
    return (a+b-1)/b;
}
int main(void){
    int n,d,x;
    cin>>n>>d>>x;
    vector<int> v(n,0);
    rep(i,n){
        cin>>v[i];
    }
    int sum=0;
    rep(i,n){
        int k=1;
        while(k<=d){
            sum+=1;
            k+=v[i];
        }
    }

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

Measured memory_bytes: 256
S=int(input())

s=int(S%60)#秒60以下のあまり
ml=int(S//60)#分(60以上の可能性あり)

h=int(ml//60)#時間
m=int(ml%60)#分60以下

print(str(h)+":"+str(m)+":"+str(s))


Measured memory_bytes: 5588
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

// 'A' = 0, 'G' = 1, 'C' = 2, 'T' = 3 と数を対応させる

ll dp[110][4][4][4];  // dp[i+1][c3][c2][c1] : 長さi(iは0-index)で末尾3文字がc3,c2,c1のとき条件を満たす文字列の数

int main() {
    ll n;
    cin >> n;
 
    dp[0][3][3][3] = 1;
    rep(i, n) {
        rep(c3, 4) {
            rep(c2, 4) {
                rep(c1, 4) {
                    rep(next, 4) {  // 次に置く文字がnext
                        if(c2 == 0 && c1 == 1 && next == 2) {
                            continue;
                        }
                        if(c3 == 0 && c1 == 1 && next == 2) {
                            continue;
                        }
                        if(c3 == 0 && c2 == 1 && next == 2) {
                            continue;
                        }
                        if(c2 == 1 && c1 == 0 && next == 2) {
                            continue;
                        }
                        if(c2 == 0 && c1 == 2 && next == 1) {
                            continue;
                        }
                        dp[i+1][c2][c1][next] += dp[i][c3][c2][c1]; 
                        dp[i+1][c2][c1][next] %= mod;
                    }
                }
            }
        }
    }
 
    ll ans = 0;
    rep(c3, 4) {
        rep(c2, 4) {
            rep(c1, 4) {
                ans += dp[n][c3][c2][c1];
                ans %= mod;
            }
        }
    }
 
    out(ans);
    re0;
}

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

namespace Beg120D
{
    public class UnionFind
    {
        public int[] pars, ranks;

        public UnionFind(int N)
        {
            pars = new int[N];
            ranks = new int[N];
            for (int i = 0; i < N; i++)
            {
                ranks[i] = 0;
                pars[i] = i;
            }
        }

        private int root(int x)
        {
            if (pars[x] == x) return x;
            else
            {
                pars[x] = root(pars[x]);
                return pars[x];
            }
        }

        public void unit(int x, int y)
        {
            var rx = root(x);
            var ry = root(y);
            if (rx != ry)
            {
                pars[ry] = rx;
                var rank = ranks[rx] + ranks[ry] + 1;
                ranks[rx] = rank;
                ranks[ry] = rank;
            }
        }

        public bool isSame(int x, int y)
        {
            return root(x) == root(y);
        }
        public int getRootRank(int x)
        {
            return ranks[root(x)];
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = read[0];
            var M = read[1];

            var As = new int[M];
            var Bs = new int[M];
            var tree = new UnionFind(N);
            for (int i=0;i<M;i++)
            {
                read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                As[i] = read[0];
                Bs[i] = read[1];
            }

            var ans = new long[M];
            ans[M - 1] = (long)N * (long)(N - 1) / 2;
            //if (!tree.isSame(As[M -1] - 1, Bs[M - 1] - 1)) tree.unit(As[M - 1] - 1, Bs[M - 1] - 1);

            for (int i = M-2;i>=0;i--)
            {
                var N1 = tree.getRootRank(As[i+1] - 1) + 1;
                var N2 = tree.getRootRank(Bs[i+1] - 1) + 1;
                ans[i] = tree.isSame(As[i+1] - 1, Bs[i+1] - 1) ? ans[i + 1] : ans[i + 1] - N1 * N2;
                if (!tree.isSame(As[i+1] - 1, Bs[i+1] - 1)) tree.unit(As[i+1] - 1, Bs[i+1] - 1);
            }
            for (int i = 0; i < M; i++)
                Console.WriteLine(ans[i]);
        }
    }
}


Measured memory_bytes: 20276
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	if (n >= 3200) cout << s << endl;
	else cout << "red" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>


const int mod = 1000000007;

int main() {
	long long A, B, C, D;
	scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
	long long c, d;
	if (C < D) {
		c = D;
		d = C;
	}
	else {
		c = C;
		d = D;
	}
	long long r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}
	long long CD = C * D / d;
	long long dC, dD, dCD;
	dC = B / C - A / C + (A%C == 0 ? 1 : 0);
	dD = B / D - A / D + (A%D == 0 ? 1 : 0);
	dCD = B / CD - A / CD + (A%CD == 0 ? 1 : 0);
	printf("%lld", B - A + 1 - dC - dD + dCD);
}





Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            (long n, long m) = Slice2<long>();
            var Xi = Sarray();Array.Sort(Xi);
            var Yi = Sarray();Array.Sort(Yi);
            var xSum = 0L;
            for (var i = 1; i < n; ++i)
                xSum = (xSum + i * (n - i) % Mod * (Xi[i] - Xi[i - 1]) % Mod) % Mod;
            var ySum = 0L;
            for (var i = 1; i < m; ++i)
                ySum = (ySum + i * (m - i) % Mod * (Yi[i] - Yi[i - 1]) % Mod) % Mod;
            var ans = xSum * ySum % Mod;
            WriteLine(ans);
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 45724
def juni(tp):
    s = str(tp[0][0])
    for i in range(1, len(tp)):
        if tp[i - 1][1] == tp[i][1] and tp[i - 1][2] == tp[i][2]:
            s += "=" + str(tp[i][0])
        else:
            s += "," + str(tp[i][0])
    return s

while True:
    m, t, p, r = map(int, input().split())
    if m == 0:
        break
    tp = [[i, 0, 0, 0, [0 for j in range(p + 1)]] for i in range(t + 1)]
    for i in range(r):
        time, team, problem, hantei = map(int, input().split())
        if hantei > 0:
            tp[team][4][problem] += 1
        else:
            tp[team][1] += 1
            tp[team][2] += time
            tp[team][3] += tp[team][4][problem]
    tp.pop(0)
    for i in tp:
        i[2] += i[3] * 20
    tp.sort(reverse = True)
    tp.sort(key = lambda x:x[2])
    tp.sort(key = lambda x:x[1], reverse = True)
    print(juni(tp))


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

int main() {
	int m, d;
	while (cin >> m >> d&&m + d) {
		int days[11] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 };
		int sum = -1;
		for (int i = 0; i < m - 1; i++) {
			sum += days[i];
		}
		sum += d;
		switch (sum % 7) {
		case 0: cout << "Thursday\n"; break;
		case 1: cout << "Friday\n"; break;
		case 2: cout << "Saturday\n"; break;
		case 3: cout << "Sunday\n"; break;
		case 4: cout << "Monday\n"; break;
		case 5: cout << "Tuesday\n"; break;
		case 6: cout << "Wednesday\n"; break;
		}
	}
}


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

string getResult(const vector<pair<int, int>> &diceList){
  int doubleCount = 0;
  for(pair<int, int> dice : diceList){
    if(dice.first == dice.second){
      doubleCount++;
    }else{
      doubleCount = 0;
    }
    if(doubleCount >= 3){
      return "Yes";
    }
  }
  return "No";
}

int main(){
  int N;
  cin >> N;
  
  vector<pair<int, int>> D(N);
  for(int i = 0; i < N; i++){
    cin >> D[i].first >> D[i].second;
  }
  
  string result = getResult(D);  
  cout << result;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	std::vector<int> a(n - 1), b(n - 1);
	std::vector<std::vector<int>> g(n);
	for(int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--; b[i]--;

		g[a[i]].push_back(i);
		g[b[i]].push_back(i);
	}

	int ans = n;
	for(int i = 0; i < n; i++) {
		auto dfs = [&](auto&& dfs, int v, int par, int d) -> int {
			int ret = d <= (k / 2);
			for(auto id: g[v]) {
				int to = a[id] ^ b[id] ^ v;
				if(to == par) continue;
				ret += dfs(dfs, to, v, d + 1);
			}
			return ret;
		};

		if(k & 1) {
			// 中心が二つ
			for(auto id: g[i]) {
				int to = a[id] ^ b[id] ^ i;
				int ret = dfs(dfs, to, i, 0) + dfs(dfs, i, to, 0);

				ans = std::min(ans, n - ret);
			}
		} else {
			int ret = dfs(dfs, i, -1, 0);
			ans = std::min(ans, n - ret);
		}
	}

	printf("%d\n", ans);
	return 0;
}


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

int main(){
    int s;cin>>s;
    int a=s;
    vector<int> b;
    int c=a;
    b.push_back(c);
    while(true){
        bool is_same=false;
        if(a%2==0) a=a/2;
        else a=a*3+1;
        for(int i=0;i<b.size();i++){
            if(a==b[i]){
                is_same=true;
                break;
            }
        }
        int c=a;
        b.push_back(c);
        if(is_same) break;
    }
    cout<<b.size()<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000010
using namespace std;

int main()
{
	int n;
	cin >>n;
	set<int >a;
	for(int i=0;i<n;i++){
        int k=0;
        cin >>k;
        a.insert(k);
	}
	cout<<a.size()<<endl;
	return 0;
}



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

#include <algorithm>
using namespace std;

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int n;
    cin >> n;
    V<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    ll ans = 1;
    if (v[0] != 0) ans = 0;
    sort(ALL(v));
    if (2 < n && v[1] == 0) ans = 0;

    ll cnt = 1, p = 1;
    for(int i = 1; i < n; i++){
        if(v[i - 1] == v[i]) cnt++;
        else if(v[i - 1] + 1 == v[i]){
            p = cnt;
            cnt = 1;
        }else{
            ans = 0;
        }
        ans *= p;
        ans %= 998244353;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] line1 = line.split(" ");
        int n = Integer.parseInt(line1[0]);
        int k = Integer.parseInt(line1[1]);
        int q = Integer.parseInt(line1[2]);
        int[] ary = new int[n];
        for(int i = 0; i < n; i++)  ary[i] = k - q;
        for(int i = 0; i < q; i++){
            int a = sc.nextInt();
            ary[a - 1]++;
        }
        for(int i = 0; i < n; i++){
            if(ary[i] <= 0) System.out.println("No");
            else    System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 71672
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var work = line[0].split("");
    var ans = "yes";
    
    for(var i = 0; i<line[0].length; i++){
        for(var j = i+1; j<line[0].length; j++){
 //           console.log(work[i]+" "+work[j]);
            if(work[i]===work[j]){
                ans = "no";
            }
        }
    }
    
    
    console.log(ans);

    
   
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long ar[100005],coun,N, h[100006],i;
    cin>>N;
    long long maxi=0,kk=0;
    cin>>h[0];
    for(i=1;i<N;i++)
    {
        cin>>h[i];
        if(h[i]<=h[i-1]) {
                ar[i-1]=maxi+1;
                maxi=ar[i-1];
        }
        else {
                kk=max(kk,maxi);
                ar[i-1]=0;
                maxi=0;
        }

    }
                kk=max(kk,maxi);
    cout<<kk<<endl;
    return 0;
}



Measured memory_bytes: 1024
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
import heapq
heapq.heapify(a)

for i in range(m):
    am =  -1 * heapq.heappop(a)
    am = am // 2
    heapq.heappush(a, -am)
print(-1 * sum(a))

Measured memory_bytes: 14224
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
public class Hello{
    public static void Main(){
        var a = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var W = a[0];
        var H = a[1];
        var x = a[2];
        var y = a[3];
        var r = a[4];
        
        if(
            ((x + r) <= W && (y + r) <= H) &&
            ((x - r) >= 0 && (y - r) >= 0) 
            ){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}



Measured memory_bytes: 18404
N = int(input())
csf = [tuple(map(int,input().split())) for _ in range(N-1)]

ans = []
for i in range(N-1):
    t = csf[i][1] + csf[i][0]
    for j in range(i+1,N-1):
        if t < csf[j][1]: t=csf[j][1]
        elif t % csf[j][2] == 0: pass
        else: t += csf[j][2] - (t%csf[j][2])
        t += csf[j][0]
    ans.append(t)
ans.append(0)
for a in ans: print(a)

Measured memory_bytes: 3188
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
ll a[200007], b[200007];

void solve() {
    ll i, j, k, l, t, n, x, y, r;
    cin>>k;
    n=7;
    for(i=1;i<=20000000;i++) {
        n=n%k;
        if(n==0) break;
        n=( ((n%k)*(10%k)%k)+(7%k))%k;
    }
    //if(k%2==0) cout<<"-1";
    if(i>=10000000) cout<<"-1";
    else cout<<i;
}
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input1.txt", "r", stdin);
        freopen("output1.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll sum = 0;
  for (int i = 0; i < s.size(); i++) {
    sum += s[i] - '0';
  }
  if (sum % 9 == 0 || s == "0") {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3744
import java.io.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solutionB(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solutionA(String[] args) throws Exception{

		pw.println(nextInt()*nextInt());
	}
	public static void solutionB(String[] args) throws Exception{
		int N = nextInt();
		long[] a = nextLongs();
		Arrays.sort(a);
		long ans = a[0];
		for(int i=1;i<N;i++) {
			long x = 0;
			try{
				x= Math.multiplyExact(ans, a[i]);
			}catch(Exception e) {
				pw.println(-1);
				return;
			}
			if(x>=1000000000000000001L) {
				pw.println(-1);
				return;
			}
			ans=x;
		}
		pw.println(ans);
	}
	public static void solutionC(String[] args) throws Exception{

	}
	public static void solutionD(String[] args) throws Exception{

	}



	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 51880
#include<stdio.h>
#define MAX 100000

int partition(int,int);

int A[MAX];
int n;

int main(){
  int i,num;

  scanf("%d",&n);
  for(i=0;i<n;i++){

    scanf("%d",&A[i]);
  }
  
  num=partition(0,n-1);

  for(i=0;i<n;i++){
    if(i)printf(" ");
    if(i==num)printf("[");
    printf("%d",A[i]);
    if(i==num)printf("]");
  }
  printf("\n");

  return 0;
}

int partition(int p,int r){
  int x,i,j,num;

  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      num=A[i];
      A[i]=A[j];
      A[j]=num;	
    }
  }
  num=A[i+1];
  A[i+1]=A[r];
  A[r]=num;
  return i+1;
}




Measured memory_bytes: 2120
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a,n,x,i,sum=0;
    while(1){
		scanf("%d",&n);
		if(n==0)break;
		x=n/4;
		for(i=0;i<x;i++){
			cin>>a;
			sum +=a;
		}
        cout<<sum<<endl;
		sum=0;
    }
    return 0;
}

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

int main(){
        string s;
        cin >> s;
        rep(i,s.length()){
                if (s[i] != ',') cout << s[i];
                else cout << " ";
        }
        cout << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
vector<int> enumdiv(int n) {
    vector<int> S;
    for (int i = 1; 1LL * i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
    sort(S.begin(), S.end());
    return S;
}
vector<int> Zalgorithm(string S) {
    int N = S.length(); vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i + j < N and S[j] == S[i + j]) j++;
        res[i] = j;
        if (j == 0) { i++; continue; }
        int k = 1;
        while (i + k < N and k + res[k] < j) res[i + k] = res[k], k++;
        i += k; j -= k;
    }

    return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














string S;
int N;
vector<int> z1, z2;
int ok1[501010], ok2[501010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S; N = S.length();

    z1 = Zalgorithm(S);
    rep(i, 1, N + 1) ok1[i] = 1;
    rep(d, 1, N) {
        for (int i = d; i + d <= N; i += d) {
            if (d <= z1[i]) {
                ok1[i + d] = 0;
            }
            else break;
        }
    }

    reverse(all(S));
    z2 = Zalgorithm(S);
    rep(i, 1, N + 1) ok2[i] = 1;
    rep(d, 1, N) {
        for (int i = d; i + d <= N; i += d) {
            if (d <= z2[i]) {
                ok2[i + d] = 0;
            }
            else break;
        }
    }

    if (ok1[N]) {
        printf("1\n1\n");
        return;
    }

    set<char> s;
    fore(c, S) s.insert(c);
    if (s.size() == 1) {
        printf("%d\n1\n", N);
        return;
    }


    int ans = 0;
    rep(i, 1, N) {
        if (ok1[i] and ok2[N-i]) ans++;
    }

    printf("2\n%d\n", ans);
}

Measured memory_bytes: 9012
from math import sqrt

n=int(input())

count=0

for i in range(n):
    x=int(input())
    if x==1:
        count=count+1
    elif x!=2 and x%2==0:
        count=count+1
    elif x==2 or x==3 or x==5:
        count=count
    else:
        for j in range(2,int(sqrt(x))+1): 
            if x%j==0:
                count=count+1
                break


print(n-count)




Measured memory_bytes: 5668
mod=10**9+7
n,m=map(int,input().split())
X=tuple(map(int,input().split()))
Y=tuple(map(int,input().split()))
ans_x,ans_y=0,0
for i,x in enumerate(X):
    ans_x+=(2*i+1-n)*x
    ans_x%=mod
for i,y in enumerate(Y):
    ans_y+=(2*i+1-m)*y
    ans_y%=mod
print((ans_x*ans_y)%mod)

Measured memory_bytes: 85860
#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ll long long
using namespace std;
int bitCount(unsigned int bits) {
    int cnt = 0;
    for(unsigned int mask = 1; mask != 0; mask<<=1) {
        if( (bits & mask) != 0 )
            ++cnt;
    }
    return cnt;
}

int main() {
  ll int n;
  cin >> n;
  vector<ll int> in(n);
  rep(i, n) cin >> in[i];
  
  ll int all = 0;
  rep(i, n) all = all ^ in[i];
  
  rep(i, n) {
    ll int ans = all ^ in[i];
    cout << ans << " ";
  }
  
  cout << endl;
  return 0;
}


Measured memory_bytes: 4680
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
#define INF	100000000
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define SORT(x) sort((x).begin(), (x).end())
#define clr(a,b) memset((a),(b),sizeof(a))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

int main(){
	int q;
	int m, n;
	scanf("%d", &q);
	rep(i,q){
		scanf("%d%d", &m, &n);
		if(m < 0) m *= -1;
		if(n < 0) n *= -1;
		int sum = m*m+n*n;
		bool ok = false;
		rep(j,200){
			if(j*j > sum) break;
			rep(k,200){
				if((j==0&&k==1)||(j==1&&k==0)||(j==m&&k==n)||(j==n&&k==m)) continue;
				if(j*j+k*k > sum) break;
				rep(u,200){
					if((j*j+k*k)*u*u > sum) break;
					rep(v,200){
						if((j*j+k*k)*(u*u+v*v) == sum){
							//cout << j << " " << k << " " << u << " " << v << endl;
							printf("C\n");
							ok = true;
							break;
						}
					}
					if(ok) break;
				}
				if(ok) break;
			}
			if(ok) break;
		}
		if(!ok) printf("P\n");
	}
}

Measured memory_bytes: 1168
h = int(input())
n_list = [0 for i in range(40)]
n_list[0] = 1
count = 1
ans = 0
while h > 1:
    h = h // 2
    n_list[count] = 1
    count += 1
for i in range(40):
    ans += n_list[i] * (2**i)
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = n % 10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
  print('hon')
if a== 0 or a== 1 or a== 6 or a== 8:
  print('pon')
if a == 3:
  print('bon')


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

int main(void){
    string s, t;
    int n;
    cin >> n;
    cin >> s;
    cin >> t;
    
    int max = 0;
    for (int i = 1; i <= n; i++) {
        int j = 0;
        while (s[n - i + j] == t[j] && j < i) j++;
        if (j == i) max = j;
    }
    
    cout << 2 * n - max << endl;
    
}


Measured memory_bytes: 256