akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e2+10;
const int maxm=1e2+10;
const int mod=1e9+7;
int n,p;
ll dp[maxn][2];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d %d",&n,&p))
    {
        dp[0][0]=1;
        dp[0][1]=0;
        for(int i=1;i<=n;i++)
        {
            int t;
            scanf("%d",&t);
            t=t%2;
            if(t==1)
            {
                dp[i][0]=dp[i-1][0]+dp[i-1][1];
                dp[i][1]=dp[i-1][1]+dp[i-1][0];
            }
            else if(t==0)
            {
                dp[i][0]=dp[i-1][0]+dp[i-1][0];
                dp[i][1]=dp[i-1][1]+dp[i-1][1];
            }
        }
        printf("%lld\n",dp[n][p]);
    }
    return 0;
}


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

//#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int cnt[n+1];
    for (int i = 0; i <= n; i++) cnt[i] = 0;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        if (u == 1 || u == n) cnt[v]++;
        if (v == n || v == 1) cnt[u]++;
    }

    bool flag = false;
    for (int i = 2; i < n; i++) if (cnt[i] >= 2) flag = true;


    if (flag) cout << "POSSIBLE\n";
    else cout << "IMPOSSIBLE\n";
}
/*

 */

Measured memory_bytes: 4436
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

#if __has_include("debugger.cpp")
  #include "debugger.cpp"
#else
void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) > 0) cout << " ";
  print(std::forward<Tail>(tail)...);
}
# endif

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

ll MOD = 1'000'000'007;
ll powmod(ll v, ll x) {
  if (x == 0) return 1;
  if (x % 2 == 0) {
    ll tmp = powmod(v, x / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (powmod(v, x - 1) * v) % MOD;
  }
}

ll mod(ll x) {
  if (x < 0) {
    x += ((-x) / MOD + 1) * MOD;
  }
  x %= MOD;
  return x;
}

int main() {
  ll input(n, k);
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  sort(a.begin(), a.end(), greater<ll>());
  if (a[0] < 0) {
    if (k % 2 == 0) {
      sort(a.begin(), a.end());
    }
    ll m = 1;
    REP(i, k) {
      m *= a[i];
      m = mod(m);
    }
    print(m);
    return 0;
  }

  if (k == n) {
    ll m = 1;
    REP(i, k) {
      m *= a[i];
      m = mod(m);
    }
    print(m);
    return 0;
  }

  ll ans = 1;
  ll left = 0;
  ll right = n - 1;

  if (k % 2 == 1) {
    ans *= a[0];
    left++;
    k--;
  }

  for(ll i = 0; i < k; i += 2) {
    ll vleft = a[left] * a[left + 1];
    ll rleft = a[right] * a[right - 1];

    if (vleft < 0) vleft = 0;
    if (rleft < 0) rleft = 0;

    if (vleft > rleft) {
      (ans *= vleft % MOD) %= MOD;
      left += 2;
    } else {
      (ans *= rleft % MOD) %= MOD;
      right -= 2;
    }
  }
  print(ans);
}


Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();

#define MAXN 100010

struct UnionFind{
	vi p, rank;
	UnionFind(int N){
		p.resize(N+1);
		rank.resize(N+1);
		for(int i=0; i<N; i++) {
			p[i] = i;
			rank[i] = 0;
		}
	}

	int findSet(int i){
		if(p[i] == i) return i;
		else return (p[i] = findSet(p[i]));
	}

	void unionSet(int i, int j){
		int x = findSet(i), y = findSet(j);
		if(x != y){
			if(rank[x] > rank[y]){
				p[y] = x;
			}
			else {
				p[x] = y;
				if(rank[x] == rank[y]) rank[y]++;
			}
		}
	}
};


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

	int n, m;
	cin >> n >> m;

	UnionFind ds(n+1);

	for(int i=1; i<=m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		ds.unionSet(x, y);
	}

	vi cnt(n+1);
	for(int i=1; i<=n; i++){
		cnt[ds.findSet(i)]++;
	}

	int ans = 0;

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

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<limits.h>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
using namespace std;

long long  mod = 1000000007;

long max(long x, long y) {
	return x > y ? x : y;
}

long min(long x, long y) {
	return x < y ? x : y;
}

long factorial(long n) {
	if (n == 1) {
		return 1;
	}
	else {
		return n * factorial(n - 1);
	}
}

long long  fel(long long  n,long long  f) {

		if (f == 1) {
			return n % mod;
		}
		else if (f % 2 == 0) {
			return (fel(n,f / 2) * fel(n,f / 2)) % mod;
		}
		else {
			return ((n  * fel(n,f / 2) %mod) * fel(n,f / 2))% mod;
		}
	

}


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

	}
	cout << sum;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define IREP(i,n) for(ll i=1;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define DEBUG(x) cerr << x << "\n"

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    printf("%d\n",min({a+b,b+c,c+a}));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int n, lsum = 0;
  cin >> n;
  vector<int> l(n, 0);
  for (int i = n; i--;) { cin >> l[i]; lsum += l[i]; }
  cout << (2 * (*max_element(l.begin(), l.end())) < lsum ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
s=input()
A=list(set(s))
ans=100
for i in A:
  B=s+i
  C=[]
  pre=-1
  for j in range(len(s)+1):
    if B[j]==i:
      C.append(j-pre-1)
      pre=j
  ans=min(ans,max(C))
print(ans)

Measured memory_bytes: 3064
S = list(input())
l = len(S)
for i in range(l):
	S.pop()
	l = len(S)
	if (l%2 == 0):
		for j in range(l//2):
			if (S[j] != S[j+(l//2)]):
				break
		else:
			print(l)
			exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define PI acos(-1)
#define sz 18500000
#define RUN_FAST ios::sync_with_stdio(false);
using namespace std;

int main()
{
    RUN_FAST; cin.tie(nullptr);
    ll a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    ans=max(max(a*c, a*d), max(b*c, b*d));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
import numpy as np

H,W,K = map(int, input().split())
graph = np.array([[1 if x == "#" else 0 for x in list(input()) ] for _ in range(H)])
count = 0
ans = 0
for i in range(2**H):
    mas = np.copy(graph)
    for h in range(H):
        if 1 & (i >> h) == 1:
            mas[h,:] = 0
    for j in range(2**W):
        mass = np.copy(mas)
        for w in range(W):
            if 1 & (j >> w):
                mass[:,w] = 0
        if mass.sum() == K:
            count += 1

print(count)




Measured memory_bytes: 26980
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<double, double> P;

const ll MOD = 1E+09 + 7;
const double INF = 1E18;
const int MAX_N = 100;

int N;

double T[MAX_N + 3], V[MAX_N + 3], ST[MAX_N + 3];

double f(int i, double t);

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

    cin >> N;

    for (int i = 2; i <= N + 1; i++) {
        cin >> T[i];
    }
    for (int i = 2; i <= N + 1; i++) {
        cin >> V[i];
    }
    for (int i = 2; i <= N + 1; i++) {
        ST[i] = ST[i - 1] + T[i];
    }
    ST[N + 2] = ST[N + 1];

    double ans = 0;
    for (int i = 0; i < ST[N + 1] * 2; i++) {
        double vl = INF;
        int mini = 0;
        for (int j = 1; j <= N + 2; j++) {
            if (vl > f(j, i * 0.5 + 0.1)) {
                vl = f(j, i * 0.5 + 0.1);
                mini = j;
            }
        }
        //cout << "x = " << i * 0.5 << ", mini = " << mini << ", fs = " << f(mini, i * 0.5) << ", fg = " << f(mini, (i + 1) * 0.5) << "\n";
        ans += 0.25 * (f(mini, i * 0.5) + f(mini, (i + 1) * 0.5));
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << fixed << setprecision(15) << ans << "\n";

    return 0;
}

double f(int i, double t)
{
    if (t < ST[i - 1]) {
        return V[i] - t + ST[i - 1];
    } else if (t < ST[i]) {
        return V[i];
    } else {
        return V[i] + t - ST[i];
    }
}

Measured memory_bytes: 3748
#include"bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int,int>> a(n + 1);
	for (int i = 1;i <= n;i++) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a.begin(),a.end());
	for (int i = 1;i <= n;i++) {
		cout << a[i].second << " ";
	}
}


Measured memory_bytes: 1536
#!/usr/bin/env python3


def main() -> None:
    N = ri()
    a = rmi()
    assert len(a) == N
    result = []
    all_xor = 0
    for item in a:
        all_xor ^= item
    for item in a:
        result.append(item ^ all_xor)
    w(' '.join(map(str, result)))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


Measured memory_bytes: 122720
#include <iostream>

using namespace std;
int main()
{
    int N;
    cin >> N;

    int ans = N;
    int cnt = 0;
    int max = 0;
    for (int i = 0; i <= N; i++)
    {
        int tmp = i;
        while (true)
        {
            if (tmp % 2 == 0 && tmp != 0)
            {
                cnt++;
                if (cnt > max)
                {
                    ans = i;
                    max = cnt;
                }
                tmp /= 2;
            }
            else
            {
                break;
            }
        }
        cnt = 0;
    }

    cout << ans;
}

Measured memory_bytes: 3552
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }


int main()
{
	ll d, t, s;
	cin >> d >> t >> s;

	if ( ( (double)d / s ) <= t )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return ( 0 );
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define MN 200010
struct que{
	int val,l,r;
};
bool operator<(que a,que b)
{
	return a.val>b.val;
}
std::priority_queue<que> pq;
int n,p[MN],ha[MN];
int jump[MN][18],v[MN][18];
int serch(int l,int r)
{
	int now=n;
	for(int i=17;i>=0&&l<=r;i--)
	{
		if(!jump[l][i]||jump[l][i]>r+1) continue;
		now=std::min(now,v[l][i]);
		l=jump[l][i];
	}
	return now;
}
void ins(int l,int r)
{
	if(l>r) return ;
	que x;
	x.l=l;x.r=r;
	x.val=serch(l,r);
	pq.push(x);
}
void init()
{
	p[n+1]=p[n+2]=n+2;
	for(int i=1;i<=n+1;i++) jump[i][0]=i+2,v[i][0]=p[i];
	for(int i=1;i<=17;i++)
	{
		for(int j=1;j<=n+1;j++)
		{
			jump[j][i]=jump[jump[j][i-1]][i-1];
			v[j][i]=std::min(v[j][i-1],v[jump[j][i-1]][i-1]);
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&p[i]),ha[p[i]]=i;
	init();
	ins(1,n);
	while(!pq.empty())
	{
		que x=pq.top();
		pq.pop();
		int l=x.l,r=x.r,v1=x.val,v2;
		v2=serch(ha[v1]+1,r+1);
		ins(l,ha[v1]-1);
		ins(ha[v1]+1,ha[v2]-1);
		ins(ha[v2]+1,r);
		printf("%d %d ",v1,v2);
	}
}

Measured memory_bytes: 31740
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    string s;
    ll k;
    cin>>k>>s;
    ll n=s.size();
    if(n>k)
    {
        f(i,k)
            cout<<s[i];
        cout<<"...";
    }
    else
        cout<<s;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int fee(int x, int y, int b, int p)
{
	int A, B;
	
	if (b >= 5 && p >= 2){
		return ((x * b + y * p) * 0.8);
	}
	
	else {
		A = x * b + y * p;
		
		if (b < 5){
			b = 5;
		}
		if (p < 2){
			p = 2;
		}
		
		B = (x * b + y * p) * 0.8;
		
		if (A < B){
			return (A);
		}
		else {
			return (B);
		}
	}
}

int main(void)
{
	int N, i, x, y, b, p;
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++){
		scanf("%d %d %d %d", &x, &y, &b, &p);
		
		printf("%d\n", fee(x, y, b, p));
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,A,B;
    cin >> N >> A >> B;
    int ans=min(A*N,B);
    cout << ans << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) cout << c << endl;
  if (b == c) cout << a << endl;
  if (c == a) cout << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

const string YES = "Yes";
const string NO = "No";

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;

    ll pass_a = 0, pass_b = 0;
    REP(i, n){
        if(s.at(i) == 'a'){
            if(pass_a + pass_b < a + b){
                cout << YES << endl;
                pass_a++;
            }else{
                cout << NO << endl;
            }
        }else if(s.at(i) == 'b'){
            if(pass_a + pass_b < a + b && pass_b < b){
                cout << YES << endl;
                pass_b++;
            }else{
                cout << NO << endl;
            }
        }else{
            cout << NO << endl;
        }
    }
    return 0;
}


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

#define INF 100100100
#define MOD 1000000007

using namespace std;
using ll = long long;
using ull = unsigned long long ;

int main(int argc, char const* argv[]){
   ios::sync_with_stdio(false);
   cin.tie(0);

   int N;
   cin>>N;
   vector<ll>A(N);
   for(int i=0;i<N;i++)cin>>A[i];
   ll MIN = INF;
   for(int i=0;i<N;i++){
      ll a = A[i];
      ll ans = 0;
      while(a%2==0){
         a/=2;
         ans++;
      }
      MIN = min(MIN,ans);
   }

   cout<<MIN<<endl;
   return 0;
}


Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n)
    cin >> a[i];

    vector<ll> odd;
    vector<ll> even;
    REP(i, n)
    {
        if (i % 2 == 0)
        {
            even.PB(a[i]);
        }
        else
        {
            odd.PB(a[i]);
        }
    }

    vector<ll> ans;
    if (n % 2 == 0)
    {
        reverse(ALL(odd));
        copy(ALL(even), back_insert_iterator(odd));
        ans = odd;
    }
    else
    {
        reverse(ALL(even));
        copy(ALL(odd), back_insert_iterator(even));
        ans = even;
    }

    REP(i, n)
    {
        cout << ans[i] << (i != n - 1 ? " " : "\n");
    }

    return 0;
}


Measured memory_bytes: 8500
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	char s[4];
	scanf("%s",s);
	if(s[0]==s[1] && s[1]==s[2])	printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=k;i<n;i++){
        if(a[i]>a[i-k])cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 4408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

vector<int> x, y;

bool isOK(int index, int key){
  if(x[index] >= key) return true;
  else return false;
}

int binary_search(int key){
  int ng = -1;
  int ok = (int)x.size();
  while(abs(ok - ng) > 1){
    int mid = (ok + ng) / 2;
    if(isOK(mid, key)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main(){
  int n, m;
  cin >> n >> m;
  rep(i, m){
    int a, b;
    cin >> a >> b;
    if (a == 1) x.push_back(b);
    else if (b == n) y.push_back(a);
  }
  x.push_back(20000000);
  sort(ALL(x));
  bool ok = false;
  rep(i, y.size()){
    int v = binary_search(y[i]);
    if (x[v] == y[i]) ok = true;
  }
  if (ok) cout << "POSSIBLE\n";
  else cout << "IMPOSSIBLE\n";
}

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

int main(){
  string com;
  int v;
  priority_queue<ll> pq;
  while(true){
    cin >> com;
    if(com == "insert"){
      cin >> v;
      pq.push(v);
    }else if(com == "extract"){
      cout << pq.top() << endl;
      pq.pop();
    }else{
      break;
    }
  }
}


Measured memory_bytes: 11300
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  string S;
  cin >> S;
  int l = S.size();
  int ret = 0;
  for(int i=0; i<l-1-i; ++i) {
    if(S[i] != S[l-1-i]) {
      ret++;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n=input().split()
c=0
while len(n)!=1:
	if n[c]=='+':
		n[c-2]=int(n[c-2])+int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='-':
		n[c-2]=int(n[c-2])-int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='*':
		n[c-2]=int(n[c-2])*int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	elif n[c]=='/':
		n[c-2]=int(n[c-2])/int(n[c-1])
		del n[c-1]
		del n[c-1]
		c=0
	c+=1
a=int(n[0])
print(a)


Measured memory_bytes: 5608
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cctype>
using namespace std;

map<char,int> M;
map<pair<char,int>,int> V;

pair<string, string> getP(string &s) {
   s[1] = s[(int)s.size()-1] = ' ';
   stringstream ss;
   ss << s;
   pair<string, string> p;
   ss >> p.first >> p.second;
   return p;
}

int getValue(string s) {
   if(isdigit(s[0])) return atoi(s.c_str());
   pair<string, string> p = getP(s);
   int x = getValue(p.second);
   if(x == -1) return -1;
   if(V.find(make_pair(p.first[0],x)) == V.end()) return -1;
   return V[make_pair(p.first[0],x)];
}

void product(string &s) {
   pair<string, string> p = getP(s);
   M[p.first[0]] = atoi(p.second.c_str());
}

bool store(string &s) {
   replace(s.begin(), s.end(), '=', ' ');
   string t[2];
   {
      stringstream ss;
      ss << s;
      ss >> t[0] >> t[1];
   }
   int idx;
   {
      string tmp = t[0].substr(2);
      tmp = tmp.substr(0, (int)tmp.size()-1);
      idx = getValue(tmp);
   }
   int value = getValue(t[1]);
   if(idx == -1 || value == -1) return false;
   if(M.find(t[0][0]) == M.end() || idx >= M[t[0][0]]) return false;
   V[make_pair(t[0][0],idx)] = value;
   return true;
}

int main() {
   string line;
   while(getline(cin, line) && line != ".") {
      M.clear();
      V.clear();
      int n = 1;
      bool flag = false;
      int res = 0;
      do {
         if(!flag) {
            if(line.find('=') == string::npos) {
               product(line);
            } else {
               if(!store(line)) {
                  res = n;
                  flag = true;
               }
            }
         }
         ++n;
      } while(getline(cin, line) && line != ".");
      cout << res << endl;
   }
   return 0;
}

Measured memory_bytes: 980
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

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

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		cout << (n - 1) / 2 << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define X first
#define Y second
#define pb push_back
#define make_unique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define int long long

const LL mod = 1e9 + 7;


template<class T>
istream& operator >> (istream& in, vector<T>& v){ for (auto &x : v) { in >> x; } return in; }

template<class T, class U>
istream& operator >> (istream& in, pair<T, U> & v){ in >> v.X >> v.Y;return in; }

template<class T, class U>
ostream& operator << (ostream& out, pair<T, U> & v){ out << v.X << " " << v.Y;return out; }

void chkmax(int &a, int b) {
    a = max(a, b);
    return;
}

void chkmin(int &a, int b) {
    a = min(a, b);
    return;
}

LL ppow (LL x, LL s) {
    if (!s) return 1;
    if (!(s - 1)) return x % mod;
    if (s % 2) return (x * ppow (x, s - 1)) % mod;
    LL b = ppow (x, s / 2);
    return (b * b) % mod;
}

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("ILUXA.in", "r", stdin);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    int MAXN = 1e6 + 10;
    vector<int> cnt(MAXN, 0);
    vector<int> res(MAXN, 1);
    for (int i = 2;i < MAXN;i++) {
        if (res[i] == 1) {
            for (int j = i;j < MAXN;j += i) {
                res[j] = i;
            }
        }
    }

    for (auto x : a) {
        int g = x;
        unordered_map<int,int> m;
        while (g != 1) {
            m[res[g]]++;
            g /= res[g];
        }
        for (auto y : m) {
            chkmax(cnt[y.X], y.Y);
        }
    }


    int ans = 0;

    int f = 1;

    for (int i = 0;i < MAXN;i++) {
        for (int j = 0;j < cnt[i];j++) {
            (f *= i) %= mod;
        }
    }

    for (auto x : a) {
        int g = x;
        unordered_map<int,int> m;
        int cur = f;
        while (g != 1) {
            (cur *= ppow(res[g], mod - 2)) %= mod;
            g /= res[g];
        }
        (ans += cur) %= mod;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
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() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N; cin >> N;
  int M; cin >> M;
  int C; cin >> C;
  
  int B[M];
  rep(i, M) {
    cin >> B[i];
  }
  
  int ans = 0;
  rep(j, N) {
    int sum = 0;
    int A;
    rep(i, M) {
      cin >> A;
      sum += A*B[i];
    }
    if (sum + C > 0) {
      ans++;
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 256
x = int(input())
a = []
for i in range(1000):
    a.append(i**5)

for i in range(999):
    for j in range(i+1,1000):
        if a[i]-a[j]==x:
            A=i
            B=j
            break
        elif -a[i]-a[j]==x:
            A=-i
            B=j
            break
        elif -a[i]+a[j]==x:
            A=-i
            B=-j
            break
        elif a[i]+a[j]==x:
            A=i
            B=-j
            break
print('%d %d'%(A,B))



Measured memory_bytes: 67892
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int cnt=count(s.begin(),s.end(),'o');
  cout<<(cnt+(15-s.size())>=8?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n,m;
    cin>>n>>m;
    vector <string> a(n),b(n);
    for (int i=0;i<n;i++) cin>>a[i];
    for (int i=0;i<m;i++) cin>>b[i];
    bool ok=false;
    for (int i=0;i<=n-m;i++){ // row.... 
        for (int j=0;j<=n-m;j++){ // column.... 
            ok=true;
            for (int k=0;k<m;k++){
                for (int l=0;l<m;l++){
                    if (a[i+k][j+l] != b[k][l]) ok=false;
                    //cout << a[i+k][j+l] << " ";
                }
                //cout << endl ; 
                if (!ok) break;
            }
            if (ok) break;
        }
        if (ok) break;
    }
    if(ok) cout << "Yes"<< endl;
    else cout << "No"<< endl;
}

signed main()
{
    int n=1;  //cin>>n;
    while (n--) solve();
    return 0;
}
// 10111101000010100 
// https://codeforces.com/contest/1363/problem/B

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

int n;
int dp[10][10];
long long ans=0;
void debug()
{
	for(int i=1;i<10;i++)
	{
		for(int j=1;j<10;j++) printf("%d ",dp[i][j]);
		puts("");
	}
	puts("**************");
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		if(i%10==0) continue;
		int a=i,last=i%10,first;//temp=1;
		while(a)
		{
			first=a%10;
			// if(a/10&&i!=a)
			// 	temp*=first+1;
			a/=10;
		}
		ans+=dp[last][first]*2;
		if(last==first) ans++;
		dp[first][last]++;
		// printf("%d:%d %d     %lld\n",i,first,last,ans);
		// debug();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
H,W = map(int,input().split())
L = []
ANS = [['#']*W for _ in range(H)]
for i in range(H):
  L.append(list(input()))
dx = [0,0,1,1,1,-1,-1,-1]
dy = [1,-1,1,-1,0,1,-1,0]
for i in range(H):
  for j in range(W):
    cnt = 0
    if L[i][j] == '#':
        continue
    else:
      for k in range(8):
        if i+dy[k] < 0 or i+dy[k] >= H or j+dx[k] < 0 or j+dx[k] >= W:
          None
        else:
          if L[i+dy[k]][j+dx[k]] == '#':
            cnt += 1
      ANS[i][j] = cnt
for i in range(H):
  for j in range(W):
    print(ANS[i][j],end = '')
  print()

Measured memory_bytes: 3572
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int [] a = new int[5];
    for (int i=0;i<5;i++){
      a[i] = scan.nextInt();
    }

    for (int j=0;j<5;j++){
      if (a[j] == 0){
        System.out.println(j+1);
        return;
      }
    }
  }
}


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

using namespace std;

class UnionFind{
public:
  UnionFind(int N);
  int root(int x);
  bool connect(int x, int y);
  int size(int x);
private:
  vector<int> parent;
};

UnionFind::UnionFind(int N)
{
  parent = vector<int>(N, -1);
}

int UnionFind::root(int x)
{
  if(parent[x] < 0) return x;
  return parent[x] = root(parent[x]);
}

int UnionFind::size(int x)
{
  return -parent[root(x)];
}

bool UnionFind::connect(int x, int y)
{
  x = root(x);
  y = root(y);
  if( x == y){
    return false;
  }
  if(size(x) < size(y))
    swap(x, y);

  parent[x] += parent[y];
  parent[y] = x;

  return true;
}

int main(void)
{
  typedef unsigned long long lint;
  int N, M;
  cin >> N >> M;
  vector<int> qA(M);
  vector<int> qB(M);
  for(int i = 1; i <= M; i++){
    cin >> qA[M-i] >> qB[M-i];
    qA[M-i]--;
    qB[M-i]--;
  }
  lint size = (lint)N * (N - 1) / 2;
  vector<lint> ans;
  UnionFind uf(N);
  for(int i = 0; i < M; i++){
    ans.push_back(size);
    lint sizeA = uf.size(qA[i]);
    lint sizeB = uf.size(qB[i]);
    //cout << ans.back() << endl;
    if(uf.connect(qA[i], qB[i])){
      size = ans.back() - (long long)(sizeA * sizeB);
    }
  }
  for(int i = M-1; i >= 0; i--){
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 3444
#C
A,B,C,D,E,F=map(int,input().split())
density=0
Ans1=0
Ans2=0
water=set() 
sugar=set()

bm=F//(100*B)
for i in range(bm+1):
    rw=F-100*i*B
    am=rw//(100*A)
    for j in range(am+1):
        water.add(100*i*B+100*j*A)

dm=F//D
for i in range(dm+1):
    rs=F-i*D
    cm=rs//C
    for j in range(cm+1):
        sugar.add(i*D+j*C)
sugar=sorted(sugar)
water=sorted(water)
for s in sugar:
    for w in water:
        if w/100*E>=s and s+w<=F and s+w!=0:
            den=s/(s+w)
            if den>=density:
                density=den
                Ans1=s+w
                Ans2=s
            else:
                break
print(Ans1,Ans2)

Measured memory_bytes: 3188
n = int(input())
x = [0]*n
u = [0]*n
for i in range(n):
    x[i],u[i] = map(str,input().split())

sum = 0
for i in range(n):
    if u[i] == "JPY":
        sum+=int(x[i])
    else:
        sum+=380000.0*float(x[i])

print(sum)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(1000000)

nVertices, nEdges = map(int, input().split())
edges = [[] for _ in range(nVertices + 1)]
for _ in range(nEdges):
    u, v = map(int, input().split())
    edges[u].append(v)
    edges[v].append(u)

if nEdges & 1 == 1:
    print(-1)
    exit()

def dfs(v):
    visited[v] = True
    for next in edges[v]:
        if not visited[next]:
            mst[v].add(next)
            mst[next].add(v)
            dfs(next)

def dfs2(par, v):
    for child in mst[v]:
        if child != par:
            dfs2(v, child)
    if par == 0:
        return
    if len(out[v]) & 1 == 1:
        out[v].add(par)
    else:
        out[par].add(v)

mst = [set() for _ in range(nVertices + 1)]
visited = [False] * (nVertices + 1)
dfs(1)

out = [set() for _ in range(nVertices + 1)]
for u in range(1, nVertices + 1):
    for v in edges[u]:
        if v not in mst[u] and u not in out[v]:
            out[u].add(v)

dfs2(0, 1)
for u in range(1, nVertices + 1):
    for v in out[u]:
        print(u, v)



Measured memory_bytes: 211276
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

using Vec = pair<double, double>;

double prod(const Vec &a, const Vec &b) {
    double xa, ya, xb, yb;
    tie(xa, ya) = a;
    tie(xb, yb) = b;
    return xa * xb + ya * yb;
}

int main() {
    ll N;
    cin >> N;
    V<Vec> vec(N);
    for(auto &&ele : vec) cin >> ele.first >> ele.second;
    double ans = 0;
    for(double theta = 0; theta < 2 * M_PI; theta += 2 * M_PI / 1e5) {
        Vec v(0, 0);
        Vec base(cos(theta), sin(theta));
        for(auto &&ele : vec) {
            if(prod(base, ele) < 0) continue;
            v.first += ele.first;
            v.second += ele.second;
        }
        double x, y;
        tie(x, y) = v;
        chmax(ans, sqrt(x * x + y * y));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAXN 10000

char v[1 + MAXN];
std::vector <std::string> V;
int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    int n = 0;
    char c = fgetc(fi);
    while('a' <= c && c <= 'z'){
        v[++n] = c;
        c = fgetc(fi);
    }

    for(int i = 1; i <= n; i++){
        std::string s = "";
        for(int j = i; j < i + 5 && j <= n; j++){
            s.push_back(v[j]);
            V.push_back(s);
        }
    }
    std::sort(V.begin(), V.end());
    int k;
    fscanf(fi,"%d", &k);
    k--;
    int i = 0;
    while(k){
        if(V[i + 1] != V[i]) k--;
        i++;
    }
    std::cout << V[i];

    fclose(fi);
    fclose(fo);
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;if(m<0) return 0;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}

ll solve(int a[][12],int b[],int c[],int n,int m,int x)
{
    int cost[m]={0};
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]==1)
        {
            ans+=c[i];
            for(int j=0;j<m;j++)
            {
                cost[j]+=a[i][j];
            }
        }
    }
    int f=0;
    for(int i=0;i<m;i++)
    {
        if(cost[i]<x)
        {
            f=1;
            break;
        }
    }
    if(f==0)
    {
        return ans;
    }
    else
    {
        return 1e9;
    }
}
int main()
{
    
    int n,m,x;
    cin>>n>>m>>x;
    int c[n];
    int a[n][12];
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    ll p = powe(2,12),ans=1e10;
    for(int i=0;i<p+1;i++)
    {
        int k=i;
        int b[n]={0};
        for(int i=0;i<n;i++)
        {
            b[i]=k%2;
            k=k/2;
        }
        ll ma=solve(a,b,c,n,m,x);
        ans = min(ans,ma);
    }
    if(ans==1e9)
        ans=-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3520
#include <stdio.h>

#define N 100000

typedef struct{
  int p;
  int l;
  int r;
}Node;

int main(){

   int i;
   int j;
   int id;
   int k;
   int c;
   int tmp;
   int n;
   int depth;
  Node T[N];

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p = -1;
    T[i].l = -1;
    T[i].r = -1;
  }
  
  for(i=0;i<n;i++){
  scanf("%d%d",&id,&k);
 
  for(j=0;j<k;j++){
    
    scanf("%d",&c);
    T[c].p = id;
    
    if(j==0){
    T[id].l = c;
    tmp = c;
    }
    
    if(j>0){
    T[tmp].r = c;
    tmp = c;
    }
    
   }
  }
  
    for(i=0;i<n;i++){
      printf("node %d: parent = %d, ",i,T[i].p);
 
        depth=0;
        id=i;
        while(T[id].p != -1){
            depth++;
            id=T[id].p;
        }
        printf("depth = %d, ",depth);
 
        if(T[i].p==-1) printf("root, ");
        else if(T[i].l==-1) printf("leaf, ");
        else printf("internal node, ");
 
        printf("[");
    if(T[i].l!=-1){
        id=T[i].l;
        printf("%d",id);
     while(T[id].r!=-1){
        id=T[id].r;
        printf(", %d",id);
            }
        }
        printf("]\n");
 }
  
  return 0;
}

Measured memory_bytes: 1788
h,w,k=map(int,input().split())
mod=10**9+7
R=[[],[1],[1,1],[2,1,2],[3,2,2,3],[5,3,4,3,5],[8,5,6,6,5,8],[13,8,10,9,10,8,13]]
T=[1,2,3,5,8,13,21,34]
r=R[w-1]
t=T[w-1]
A=[0]*w
A[0]=1
if w==1:
    print(1)
else:
    for i in range(h):
        C=[0]*w
        for i in range(w):
            if i==0:
                C[0]+=(t-r[0])*A[0]
                C[1]+=r[0]*A[0]
            elif i==w-1:
                C[w-1]+=(t-r[w-2])*A[w-1]
                C[w-2]+=r[w-2]*A[w-1]
            else:
                C[i-1]+=r[i-1]*A[i]
                C[i]+=(t-r[i-1]-r[i])*A[i]
                C[i+1]+=r[i]*A[i]
        for i in range(w):
            C[i]%=mod
        A=C
    print(A[k-1])

Measured memory_bytes: 3064
n,m=gets.split.map &:to_i
a=[]
n.times{
  a << gets.split.map(&:to_i)
}
b=[]
m.times{
  b << gets.to_i
}
n.times{|i|
  c=0
  m.times{|j|
    c+=a[i][j]*b[j]
  }
  puts c
}


Measured memory_bytes: 6972
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int count = 0;

    for (char c : str.toCharArray()) {
      count = (c == 'o') ? count + 1 : count;
    }

    System.out.println(700 + 100 * count);
  }
}


Measured memory_bytes: 21844
n = int(input())
A = list(map(int, input().split()))
c = [0]*100000
ans = 0
for a in A:
    c[a] += 1

for i in range(1, 99999):
    cnt = c[i-1] + c[i] +c[i+1]
    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 84680
// C++ Program to implement 
// iterative segment tree. 
#include <bits/stdc++.h> 
#define ll long long int
using namespace std; 

void construct_segment_tree(vector<ll>& segtree, 
							vector<ll>& a, int n) 
{ 
	// assign values to leaves of the segment tree 
	for (int i = 0; i < n; i++) 
		segtree[n + i] = a[i]; 

	/* assign values to internal nodes 
	to compute maximum in a given range */
	for (int i = n - 1; i >= 1; i--) 
		segtree[i] = max(segtree[2 * i], 
						segtree[2 * i + 1]); 
} 

void update(vector<ll>& segtree, int pos, ll value, 
			int n) 
{ 
	// change the index to leaf node first 
	pos += n; 

	// update the value at the leaf node 
	// at the exact index 
	segtree[pos] = value; 

	while (pos > 1) { 

		// move up one level at a time in the tree 
		pos >>= 1; 

		// update the values in the nodes in 
		// the next higher level 
		segtree[pos] = max(segtree[2 * pos], 
						segtree[2 * pos + 1]); 
	} 
} 

ll range_query(vector<ll>& segtree, int left, int
													right, 
				int n) 
{ 
	/* Basically the left and right indices will move 
		towards right and left respectively and with 
		every each next higher level and compute the 
		maximum at each height. */
	// change the index to leaf node first 
	left += n; 
	right += n; 

	// initialize maximum to a very low value 
	ll ma = INT_MIN; 

	while (left < right) { 

		// if left index in odd 
		if (left & 1) { 
			ma = max(ma, segtree[left]); 

			// make left index even 
			left++; 
		} 

		// if right index in odd 
		if (right & 1) { 

			// make right index even 
			right--; 

			ma = max(ma, segtree[right]); 
		} 

		// move to the next higher level 
		left /= 2; 
		right /= 2; 
	} 
	return ma; 
} 

// Driver code 
int main() 
{ 
	int n;
	cin>>n;
	int h[n];
	ll beauty[n];
	vector<ll> ans(n);
	for(int i=0;i<n;i++){
	    cin>>h[i];
	    h[i]--;
	    ans[i]=-1e18;
	}
	for(int i=0;i<n;i++){
	    cin>>beauty[i];
	}
	vector<ll> segtree(4*n);
	construct_segment_tree(segtree,ans,n);
	update(segtree,h[0],beauty[0],n);
	for(int i=1;i<n;i++){
	    update(segtree,h[i],max(0ll,range_query(segtree,0,h[i],n))+beauty[i],n);
	}
	cout<<range_query(segtree,0,n,n);
} 


Measured memory_bytes: 10368
from collections import Counter
s = input()
c = Counter(s)
if (c['N'] == 0 and c['S'] > 0) or (c['S'] == 0 and c['N'] > 0):
    print('No')
elif (c['W'] == 0 and c['E'] > 0) or (c['E'] == 0 and c['W'] > 0):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3316
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();

        if (w >= s) System.out.println("unsafe");
        else System.out.println("safe");
    }
}


Measured memory_bytes: 35724